@deepfrog/pangents-widget 2.1.6 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Widget.d.ts +2 -1
- package/dist/components/WidgetBubble.d.ts +2 -1
- package/dist/components/WidgetPopup.d.ts +2 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/{widget-embed-9DdEqVMP.cjs.js → widget-embed-BPoilyw_.cjs.js} +3 -3
- package/dist/widget-embed-BPoilyw_.cjs.js.map +1 -0
- package/dist/{widget-embed-LzSoeVtX.es.js → widget-embed-CtD27t5y.es.js} +21 -8
- package/dist/widget-embed-CtD27t5y.es.js.map +1 -0
- package/dist/widget-embed.cjs.js +1 -1
- package/dist/widget-embed.es.js +1 -1
- package/dist/widget.js +19 -6
- package/package.json +2 -2
- package/dist/widget-embed-9DdEqVMP.cjs.js.map +0 -1
- package/dist/widget-embed-LzSoeVtX.es.js.map +0 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
}
|
|
7
7
|
} catch (error) {}
|
|
8
8
|
})();
|
|
9
|
-
"use strict";var e,t,s,n,r,a,i,o,l,c,d,u,h,m,p,f,g,y,x,v,b,w,S,j,k,N,E,C,T,P,A,R,M,D,$,O,F,z,L,I,_,V,B,q,U,W,H,K,Y,Q,G,J,X,Z,ee,te,se,ne,re,ae,ie,oe,le,ce,de,ue,he,me,pe,fe,ge,ye,xe,ve,be,we,Se,je,ke,Ne=Object.defineProperty,Ee=e=>{throw TypeError(e)},Ce=(e,t,s)=>((e,t,s)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s),Te=(e,t,s)=>t.has(e)||Ee("Cannot "+s),Pe=(e,t,s)=>(Te(e,t,"read from private field"),s?s.call(e):t.get(e)),Ae=(e,t,s)=>t.has(e)?Ee("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Re=(e,t,s,n)=>(Te(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s),Me=(e,t,s)=>(Te(e,t,"access private method"),s),De=(e,t,s,n)=>({set _(n){Re(e,t,n,s)},get _(){return Pe(e,t,n)}});const $e=require("react/jsx-runtime"),Oe=require("react"),Fe=require("react-dom");function ze(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const s in e)if("default"!==s){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}return t.default=e,Object.freeze(t)}const Le=ze(Oe);var Ie=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_e={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ve=new(s=class{constructor(){Ae(this,e,_e),Ae(this,t,!1)}setTimeoutProvider(s){"production"!==process.env.NODE_ENV&&Pe(this,t)&&s!==Pe(this,e)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:Pe(this,e),provider:s}),Re(this,e,s),"production"!==process.env.NODE_ENV&&Re(this,t,!1)}setTimeout(s,n){return"production"!==process.env.NODE_ENV&&Re(this,t,!0),Pe(this,e).setTimeout(s,n)}clearTimeout(t){Pe(this,e).clearTimeout(t)}setInterval(s,n){return"production"!==process.env.NODE_ENV&&Re(this,t,!0),Pe(this,e).setInterval(s,n)}clearInterval(t){Pe(this,e).clearInterval(t)}},e=new WeakMap,t=new WeakMap,s);var Be="undefined"==typeof window||"Deno"in globalThis;function qe(){}function Ue(e){return"number"==typeof e&&e>=0&&e!==1/0}function We(e,t){return Math.max(e+(t||0)-Date.now(),0)}function He(e,t){return"function"==typeof e?e(t):e}function Ke(e,t){return"function"==typeof e?e(t):e}function Ye(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:a,queryKey:i,stale:o}=e;if(i)if(n){if(t.queryHash!==Ge(i,t.options))return!1}else if(!Xe(t.queryKey,i))return!1;if("all"!==s){const e=t.isActive();if("active"===s&&!e)return!1;if("inactive"===s&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&((!r||r===t.state.fetchStatus)&&!(a&&!a(t)))}function Qe(e,t){const{exact:s,status:n,predicate:r,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(Je(t.options.mutationKey)!==Je(a))return!1}else if(!Xe(t.options.mutationKey,a))return!1}return(!n||t.state.status===n)&&!(r&&!r(t))}function Ge(e,t){return((null==t?void 0:t.queryKeyHashFn)||Je)(e)}function Je(e){return JSON.stringify(e,(e,t)=>nt(t)?Object.keys(t).sort().reduce((e,s)=>(e[s]=t[s],e),{}):t)}function Xe(e,t){return e===t||typeof e==typeof t&&(!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(s=>Xe(e[s],t[s])))}var Ze=Object.prototype.hasOwnProperty;function et(e,t){if(e===t)return e;const s=st(e)&&st(t);if(!(s||nt(e)&&nt(t)))return t;const n=(s?e:Object.keys(e)).length,r=s?t:Object.keys(t),a=r.length,i=s?new Array(a):{};let o=0;for(let l=0;l<a;l++){const a=s?l:r[l],c=e[a],d=t[a];if(c===d){i[a]=c,(s?l<n:Ze.call(e,a))&&o++;continue}if(null===c||null===d||"object"!=typeof c||"object"!=typeof d){i[a]=d;continue}const u=et(c,d);i[a]=u,u===c&&o++}return n===a&&o===n?e:i}function tt(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function st(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function nt(e){if(!rt(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!!rt(s)&&(!!s.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype)}function rt(e){return"[object Object]"===Object.prototype.toString.call(e)}function at(e,t,s){if("function"==typeof s.structuralSharing)return s.structuralSharing(e,t);if(!1!==s.structuralSharing){if("production"!==process.env.NODE_ENV)try{return et(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`),n}return et(e,t)}return t}function it(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function ot(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var lt=Symbol();function ct(e,t){return"production"!==process.env.NODE_ENV&&e.queryFn===lt&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(null==t?void 0:t.initialPromise)?()=>t.initialPromise:e.queryFn&&e.queryFn!==lt?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function dt(e,t){return"function"==typeof e?e(...t):!!e}var ut=new(i=class extends Ie{constructor(){super(),Ae(this,n),Ae(this,r),Ae(this,a),Re(this,a,e=>{if(!Be&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){Pe(this,r)||this.setEventListener(Pe(this,a))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Pe(this,r))||e.call(this),Re(this,r,void 0))}setEventListener(e){var t;Re(this,a,e),null==(t=Pe(this,r))||t.call(this),Re(this,r,e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){Pe(this,n)!==e&&(Re(this,n,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return"boolean"==typeof Pe(this,n)?Pe(this,n):"hidden"!==(null==(e=globalThis.document)?void 0:e.visibilityState)}},n=new WeakMap,r=new WeakMap,a=new WeakMap,i);function ht(){let e,t;const s=new Promise((s,n)=>{e=s,t=n});function n(e){Object.assign(s,e),delete s.resolve,delete s.reject}return s.status="pending",s.catch(()=>{}),s.resolve=t=>{n({status:"fulfilled",value:t}),e(t)},s.reject=e=>{n({status:"rejected",reason:e}),t(e)},s}var mt=function(e){setTimeout(e,0)};var pt=function(){let e=[],t=0,s=e=>{e()},n=e=>{e()},r=mt;const a=n=>{t?e.push(n):r(()=>{s(n)})};return{batch:a=>{let i;t++;try{i=a()}finally{t--,t||(()=>{const t=e;e=[],t.length&&r(()=>{n(()=>{t.forEach(e=>{s(e)})})})})()}return i},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{s=e},setBatchNotifyFunction:e=>{n=e},setScheduler:e=>{r=e}}}(),ft=new(d=class extends Ie{constructor(){super(),Ae(this,o,!0),Ae(this,l),Ae(this,c),Re(this,c,e=>{if(!Be&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}})}onSubscribe(){Pe(this,l)||this.setEventListener(Pe(this,c))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Pe(this,l))||e.call(this),Re(this,l,void 0))}setEventListener(e){var t;Re(this,c,e),null==(t=Pe(this,l))||t.call(this),Re(this,l,e(this.setOnline.bind(this)))}setOnline(e){Pe(this,o)!==e&&(Re(this,o,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return Pe(this,o)}},o=new WeakMap,l=new WeakMap,c=new WeakMap,d);function gt(e){return Math.min(1e3*2**e,3e4)}function yt(e){return"online"!==(e??"online")||ft.isOnline()}var xt=class extends Error{constructor(e){super("CancelledError"),this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent}};function vt(e){let t,s=!1,n=0;const r=ht(),a=()=>"pending"!==r.status,i=()=>ut.isFocused()&&("always"===e.networkMode||ft.isOnline())&&e.canRun(),o=()=>yt(e.networkMode)&&e.canRun(),l=e=>{a()||(null==t||t(),r.resolve(e))},c=e=>{a()||(null==t||t(),r.reject(e))},d=()=>new Promise(s=>{var n;t=e=>{(a()||i())&&s(e)},null==(n=e.onPause)||n.call(e)}).then(()=>{var s;t=void 0,a()||null==(s=e.onContinue)||s.call(e)}),u=()=>{if(a())return;let t;const r=0===n?e.initialPromise:void 0;try{t=r??e.fn()}catch(o){t=Promise.reject(o)}Promise.resolve(t).then(l).catch(t=>{var r;if(a())return;const o=e.retry??(Be?0:3),l=e.retryDelay??gt,h="function"==typeof l?l(n,t):l,m=!0===o||"number"==typeof o&&n<o||"function"==typeof o&&o(n,t);var p;!s&&m?(n++,null==(r=e.onFail)||r.call(e,n,t),(p=h,new Promise(e=>{Ve.setTimeout(e,p)})).then(()=>i()?void 0:d()).then(()=>{s?c(t):u()})):c(t)})};return{promise:r,status:()=>r.status,cancel:t=>{var s;if(!a()){const n=new xt(t);c(n),null==(s=e.onCancel)||s.call(e,n)}},continue:()=>(null==t||t(),r),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:o,start:()=>(o()?u():d().then(u),r)}}var bt=(h=class{constructor(){Ae(this,u)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ue(this.gcTime)&&Re(this,u,Ve.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Be?1/0:3e5))}clearGcTimeout(){Pe(this,u)&&(Ve.clearTimeout(Pe(this,u)),Re(this,u,void 0))}},u=new WeakMap,h),wt=(S=class extends bt{constructor(e){super(),Ae(this,b),Ae(this,m),Ae(this,p),Ae(this,f),Ae(this,g),Ae(this,y),Ae(this,x),Ae(this,v),Re(this,v,!1),Re(this,x,e.defaultOptions),this.setOptions(e.options),this.observers=[],Re(this,g,e.client),Re(this,f,Pe(this,g).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Re(this,m,jt(this.options)),this.state=e.state??Pe(this,m),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return null==(e=Pe(this,y))?void 0:e.promise}setOptions(e){if(this.options={...Pe(this,x),...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=jt(this.options);void 0!==e.data&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),Re(this,m,e))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||Pe(this,f).remove(this)}setData(e,t){const s=at(this.state.data,e,this.options);return Me(this,b,w).call(this,{data:s,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt,manual:null==t?void 0:t.manual}),s}setState(e,t){Me(this,b,w).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var t,s;const n=null==(t=Pe(this,y))?void 0:t.promise;return null==(s=Pe(this,y))||s.cancel(e),n?n.then(qe).catch(qe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Pe(this,m))}isActive(){return this.observers.some(e=>!1!==Ke(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===lt||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===He(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!We(this.state.dataUpdatedAt,e))}onFocus(){var e;const t=this.observers.find(e=>e.shouldFetchOnWindowFocus());null==t||t.refetch({cancelRefetch:!1}),null==(e=Pe(this,y))||e.continue()}onOnline(){var e;const t=this.observers.find(e=>e.shouldFetchOnReconnect());null==t||t.refetch({cancelRefetch:!1}),null==(e=Pe(this,y))||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Pe(this,f).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(Pe(this,y)&&(Pe(this,v)?Pe(this,y).cancel({revert:!0}):Pe(this,y).cancelRetry()),this.scheduleGc()),Pe(this,f).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Me(this,b,w).call(this,{type:"invalidate"})}async fetch(e,t){var s,n,r,a,i,o,l,c,d,u,h,m;if("idle"!==this.state.fetchStatus&&"rejected"!==(null==(s=Pe(this,y))?void 0:s.status()))if(void 0!==this.state.data&&(null==t?void 0:t.cancelRefetch))this.cancel({silent:!0});else if(Pe(this,y))return Pe(this,y).continueRetry(),Pe(this,y).promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}"production"!==process.env.NODE_ENV&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const x=new AbortController,S=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(Re(this,v,!0),x.signal)})},j=()=>{const e=ct(this.options,t),s=(()=>{const e={client:Pe(this,g),queryKey:this.queryKey,meta:this.meta};return S(e),e})();return Re(this,v,!1),this.options.persister?this.options.persister(e,s,this):e(s)},k=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:Pe(this,g),state:this.state,fetchFn:j};return S(e),e})();null==(n=this.options.behavior)||n.onFetch(k,this),Re(this,p,this.state),"idle"!==this.state.fetchStatus&&this.state.fetchMeta===(null==(r=k.fetchOptions)?void 0:r.meta)||Me(this,b,w).call(this,{type:"fetch",meta:null==(a=k.fetchOptions)?void 0:a.meta}),Re(this,y,vt({initialPromise:null==t?void 0:t.initialPromise,fn:k.fetchFn,onCancel:e=>{e instanceof xt&&e.revert&&this.setState({...Pe(this,p),fetchStatus:"idle"}),x.abort()},onFail:(e,t)=>{Me(this,b,w).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,b,w).call(this,{type:"pause"})},onContinue:()=>{Me(this,b,w).call(this,{type:"continue"})},retry:k.options.retry,retryDelay:k.options.retryDelay,networkMode:k.options.networkMode,canRun:()=>!0}));try{const e=await Pe(this,y).start();if(void 0===e)throw"production"!==process.env.NODE_ENV&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(e),null==(o=(i=Pe(this,f).config).onSuccess)||o.call(i,e,this),null==(c=(l=Pe(this,f).config).onSettled)||c.call(l,e,this.state.error,this),e}catch(N){if(N instanceof xt){if(N.silent)return Pe(this,y).promise;if(N.revert){if(void 0===this.state.data)throw N;return this.state.data}}throw Me(this,b,w).call(this,{type:"error",error:N}),null==(u=(d=Pe(this,f).config).onError)||u.call(d,N,this),null==(m=(h=Pe(this,f).config).onSettled)||m.call(h,this.state.data,N,this),N}finally{this.scheduleGc()}}},m=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,y=new WeakMap,x=new WeakMap,v=new WeakMap,b=new WeakSet,w=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...St(t.data,this.options),fetchMeta:e.meta??null};case"success":const s={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Re(this,p,e.manual?s:void 0),s;case"error":const n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),pt.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),Pe(this,f).notify({query:this,type:"updated",action:e})})},S);function St(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:yt(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function jt(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,s=void 0!==t,n=s?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var kt=(Y=class extends Ie{constructor(e,t){super(),Ae(this,L),Ae(this,j),Ae(this,k),Ae(this,N),Ae(this,E),Ae(this,C),Ae(this,T),Ae(this,P),Ae(this,A),Ae(this,R),Ae(this,M),Ae(this,D),Ae(this,$),Ae(this,O),Ae(this,F),Ae(this,z,new Set),this.options=t,Re(this,j,e),Re(this,A,null),Re(this,P,ht()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(Pe(this,k).addObserver(this),Nt(Pe(this,k),this.options)?Me(this,L,I).call(this):this.updateResult(),Me(this,L,q).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Et(Pe(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Et(Pe(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Me(this,L,U).call(this),Me(this,L,W).call(this),Pe(this,k).removeObserver(this)}setOptions(e){const t=this.options,s=Pe(this,k);if(this.options=Pe(this,j).defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof Ke(this.options.enabled,Pe(this,k)))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Me(this,L,H).call(this),Pe(this,k).setOptions(this.options),t._defaulted&&!tt(this.options,t)&&Pe(this,j).getQueryCache().notify({type:"observerOptionsUpdated",query:Pe(this,k),observer:this});const n=this.hasListeners();n&&Ct(Pe(this,k),s,this.options,t)&&Me(this,L,I).call(this),this.updateResult(),!n||Pe(this,k)===s&&Ke(this.options.enabled,Pe(this,k))===Ke(t.enabled,Pe(this,k))&&He(this.options.staleTime,Pe(this,k))===He(t.staleTime,Pe(this,k))||Me(this,L,_).call(this);const r=Me(this,L,V).call(this);!n||Pe(this,k)===s&&Ke(this.options.enabled,Pe(this,k))===Ke(t.enabled,Pe(this,k))&&r===Pe(this,F)||Me(this,L,B).call(this,r)}getOptimisticResult(e){const t=Pe(this,j).getQueryCache().build(Pe(this,j),e),s=this.createResult(t,e);return function(e,t){if(!tt(e.getCurrentResult(),t))return!0;return!1}(this,s)&&(Re(this,E,s),Re(this,T,this.options),Re(this,C,Pe(this,k).state)),s}getCurrentResult(){return Pe(this,E)}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),null==t||t(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==Pe(this,P).status||Pe(this,P).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,s))})}trackProp(e){Pe(this,z).add(e)}getCurrentQuery(){return Pe(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=Pe(this,j).defaultQueryOptions(e),s=Pe(this,j).getQueryCache().build(Pe(this,j),t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return Me(this,L,I).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Pe(this,E)))}createResult(e,t){var s;const n=Pe(this,k),r=this.options,a=Pe(this,E),i=Pe(this,C),o=Pe(this,T),l=e!==n?e.state:Pe(this,N),{state:c}=e;let d,u={...c},h=!1;if(t._optimisticResults){const s=this.hasListeners(),a=!s&&Nt(e,t),i=s&&Ct(e,n,t,r);(a||i)&&(u={...u,...St(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:f}=u;d=u.data;let g=!1;if(void 0!==t.placeholderData&&void 0===d&&"pending"===f){let e;(null==a?void 0:a.isPlaceholderData)&&t.placeholderData===(null==o?void 0:o.placeholderData)?(e=a.data,g=!0):e="function"==typeof t.placeholderData?t.placeholderData(null==(s=Pe(this,D))?void 0:s.state.data,Pe(this,D)):t.placeholderData,void 0!==e&&(f="success",d=at(null==a?void 0:a.data,e,t),h=!0)}if(t.select&&void 0!==d&&!g)if(a&&d===(null==i?void 0:i.data)&&t.select===Pe(this,R))d=Pe(this,M);else try{Re(this,R,t.select),d=t.select(d),d=at(null==a?void 0:a.data,d,t),Re(this,M,d),Re(this,A,null)}catch(j){Re(this,A,j)}Pe(this,A)&&(m=Pe(this,A),d=Pe(this,M),p=Date.now(),f="error");const y="fetching"===u.fetchStatus,x="pending"===f,v="error"===f,b=x&&y,w=void 0!==d,S={status:f,fetchStatus:u.fetchStatus,isPending:x,isSuccess:"success"===f,isError:v,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:v&&!w,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:v&&w,isStale:Tt(e,t),refetch:this.refetch,promise:Pe(this,P),isEnabled:!1!==Ke(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===S.status?e.reject(S.error):void 0!==S.data&&e.resolve(S.data)},s=()=>{const e=Re(this,P,S.promise=ht());t(e)},r=Pe(this,P);switch(r.status){case"pending":e.queryHash===n.queryHash&&t(r);break;case"fulfilled":"error"!==S.status&&S.data===r.value||s();break;case"rejected":"error"===S.status&&S.error===r.reason||s()}}return S}updateResult(){const e=Pe(this,E),t=this.createResult(Pe(this,k),this.options);if(Re(this,C,Pe(this,k).state),Re(this,T,this.options),void 0!==Pe(this,C).data&&Re(this,D,Pe(this,k)),tt(t,e))return;Re(this,E,t);Me(this,L,K).call(this,{listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!Pe(this,z).size)return!0;const n=new Set(s??Pe(this,z));return this.options.throwOnError&&n.add("error"),Object.keys(Pe(this,E)).some(t=>{const s=t;return Pe(this,E)[s]!==e[s]&&n.has(s)})})()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Me(this,L,q).call(this)}},j=new WeakMap,k=new WeakMap,N=new WeakMap,E=new WeakMap,C=new WeakMap,T=new WeakMap,P=new WeakMap,A=new WeakMap,R=new WeakMap,M=new WeakMap,D=new WeakMap,$=new WeakMap,O=new WeakMap,F=new WeakMap,z=new WeakMap,L=new WeakSet,I=function(e){Me(this,L,H).call(this);let t=Pe(this,k).fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(qe)),t},_=function(){Me(this,L,U).call(this);const e=He(this.options.staleTime,Pe(this,k));if(Be||Pe(this,E).isStale||!Ue(e))return;const t=We(Pe(this,E).dataUpdatedAt,e)+1;Re(this,$,Ve.setTimeout(()=>{Pe(this,E).isStale||this.updateResult()},t))},V=function(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(Pe(this,k)):this.options.refetchInterval)??!1},B=function(e){Me(this,L,W).call(this),Re(this,F,e),!Be&&!1!==Ke(this.options.enabled,Pe(this,k))&&Ue(Pe(this,F))&&0!==Pe(this,F)&&Re(this,O,Ve.setInterval(()=>{(this.options.refetchIntervalInBackground||ut.isFocused())&&Me(this,L,I).call(this)},Pe(this,F)))},q=function(){Me(this,L,_).call(this),Me(this,L,B).call(this,Me(this,L,V).call(this))},U=function(){Pe(this,$)&&(Ve.clearTimeout(Pe(this,$)),Re(this,$,void 0))},W=function(){Pe(this,O)&&(Ve.clearInterval(Pe(this,O)),Re(this,O,void 0))},H=function(){const e=Pe(this,j).getQueryCache().build(Pe(this,j),this.options);if(e===Pe(this,k))return;const t=Pe(this,k);Re(this,k,e),Re(this,N,e.state),this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))},K=function(e){pt.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(Pe(this,E))}),Pe(this,j).getQueryCache().notify({query:Pe(this,k),type:"observerResultsUpdated"})})},Y);function Nt(e,t){return function(e,t){return!1!==Ke(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&Et(e,t,t.refetchOnMount)}function Et(e,t,s){if(!1!==Ke(t.enabled,e)&&"static"!==He(t.staleTime,e)){const n="function"==typeof s?s(e):s;return"always"===n||!1!==n&&Tt(e,t)}return!1}function Ct(e,t,s,n){return(e!==t||!1===Ke(n.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&Tt(e,s)}function Tt(e,t){return!1!==Ke(t.enabled,e)&&e.isStaleByTime(He(t.staleTime,e))}function Pt(e){return{onFetch:(t,s)=>{var n,r,a,i,o;const l=t.options,c=null==(a=null==(r=null==(n=t.fetchOptions)?void 0:n.meta)?void 0:r.fetchMore)?void 0:a.direction,d=(null==(i=t.state.data)?void 0:i.pages)||[],u=(null==(o=t.state.data)?void 0:o.pageParams)||[];let h={pages:[],pageParams:[]},m=0;const p=async()=>{let s=!1;const n=ct(t.options,t.fetchOptions),r=async(e,r,a)=>{if(s)return Promise.reject();if(null==r&&e.pages.length)return Promise.resolve(e);const i=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:a?"backward":"forward",meta:t.options.meta};var n;return n=e,Object.defineProperty(n,"signal",{enumerable:!0,get:()=>(t.signal.aborted?s=!0:t.signal.addEventListener("abort",()=>{s=!0}),t.signal)}),e})(),o=await n(i),{maxPages:l}=t.options,c=a?ot:it;return{pages:c(e.pages,o,l),pageParams:c(e.pageParams,r,l)}};if(c&&d.length){const e="backward"===c,t={pages:d,pageParams:u},s=(e?Rt:At)(l,t);h=await r(t,s,e)}else{const t=e??d.length;do{const e=0===m?u[0]??l.initialPageParam:At(l,h);if(m>0&&null==e)break;h=await r(h,e),m++}while(m<t)}return h};t.options.persister?t.fetchFn=()=>{var e,n;return null==(n=(e=t.options).persister)?void 0:n.call(e,p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=p}}}function At(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function Rt(e,{pages:t,pageParams:s}){var n;return t.length>0?null==(n=e.getPreviousPageParam)?void 0:n.call(e,t[0],t,s[0],s):void 0}var Mt=(te=class extends bt{constructor(e){super(),Ae(this,Z),Ae(this,Q),Ae(this,G),Ae(this,J),Ae(this,X),Re(this,Q,e.client),this.mutationId=e.mutationId,Re(this,J,e.mutationCache),Re(this,G,[]),this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Pe(this,G).includes(e)||(Pe(this,G).push(e),this.clearGcTimeout(),Pe(this,J).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Re(this,G,Pe(this,G).filter(t=>t!==e)),this.scheduleGc(),Pe(this,J).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Pe(this,G).length||("pending"===this.state.status?this.scheduleGc():Pe(this,J).remove(this))}continue(){var e;return(null==(e=Pe(this,X))?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var t,s,n,r,a,i,o,l,c,d,u,h,m,p,f,g,y,x,v,b;const w=()=>{Me(this,Z,ee).call(this,{type:"continue"})},S={client:Pe(this,Q),meta:this.options.meta,mutationKey:this.options.mutationKey};Re(this,X,vt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,S):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{Me(this,Z,ee).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,Z,ee).call(this,{type:"pause"})},onContinue:w,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Pe(this,J).canRun(this)}));const j="pending"===this.state.status,k=!Pe(this,X).canStart();try{if(j)w();else{Me(this,Z,ee).call(this,{type:"pending",variables:e,isPaused:k}),await(null==(s=(t=Pe(this,J).config).onMutate)?void 0:s.call(t,e,this,S));const a=await(null==(r=(n=this.options).onMutate)?void 0:r.call(n,e,S));a!==this.state.context&&Me(this,Z,ee).call(this,{type:"pending",context:a,variables:e,isPaused:k})}const m=await Pe(this,X).start();return await(null==(i=(a=Pe(this,J).config).onSuccess)?void 0:i.call(a,m,e,this.state.context,this,S)),await(null==(l=(o=this.options).onSuccess)?void 0:l.call(o,m,e,this.state.context,S)),await(null==(d=(c=Pe(this,J).config).onSettled)?void 0:d.call(c,m,null,this.state.variables,this.state.context,this,S)),await(null==(h=(u=this.options).onSettled)?void 0:h.call(u,m,null,e,this.state.context,S)),Me(this,Z,ee).call(this,{type:"success",data:m}),m}catch(N){try{throw await(null==(p=(m=Pe(this,J).config).onError)?void 0:p.call(m,N,e,this.state.context,this,S)),await(null==(g=(f=this.options).onError)?void 0:g.call(f,N,e,this.state.context,S)),await(null==(x=(y=Pe(this,J).config).onSettled)?void 0:x.call(y,void 0,N,this.state.variables,this.state.context,this,S)),await(null==(b=(v=this.options).onSettled)?void 0:b.call(v,void 0,N,e,this.state.context,S)),N}finally{Me(this,Z,ee).call(this,{type:"error",error:N})}}finally{Pe(this,J).runNext(this)}}},Q=new WeakMap,G=new WeakMap,J=new WeakMap,X=new WeakMap,Z=new WeakSet,ee=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),pt.batch(()=>{Pe(this,G).forEach(t=>{t.onMutationUpdate(e)}),Pe(this,J).notify({mutation:this,type:"updated",action:e})})},te);var Dt=(ae=class extends Ie{constructor(e={}){super(),Ae(this,se),Ae(this,ne),Ae(this,re),this.config=e,Re(this,se,new Set),Re(this,ne,new Map),Re(this,re,0)}build(e,t,s){const n=new Mt({client:e,mutationCache:this,mutationId:++De(this,re)._,options:e.defaultMutationOptions(t),state:s});return this.add(n),n}add(e){Pe(this,se).add(e);const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t);s?s.push(e):Pe(this,ne).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Pe(this,se).delete(e)){const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t);if(s)if(s.length>1){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}else s[0]===e&&Pe(this,ne).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t),n=null==s?void 0:s.find(e=>"pending"===e.state.status);return!n||n===e}return!0}runNext(e){var t;const s=$t(e);if("string"==typeof s){const n=null==(t=Pe(this,ne).get(s))?void 0:t.find(t=>t!==e&&t.state.isPaused);return(null==n?void 0:n.continue())??Promise.resolve()}return Promise.resolve()}clear(){pt.batch(()=>{Pe(this,se).forEach(e=>{this.notify({type:"removed",mutation:e})}),Pe(this,se).clear(),Pe(this,ne).clear()})}getAll(){return Array.from(Pe(this,se))}find(e){const t={exact:!0,...e};return this.getAll().find(e=>Qe(t,e))}findAll(e={}){return this.getAll().filter(t=>Qe(e,t))}notify(e){pt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(e=>e.state.isPaused);return pt.batch(()=>Promise.all(e.map(e=>e.continue().catch(qe))))}},se=new WeakMap,ne=new WeakMap,re=new WeakMap,ae);function $t(e){var t;return null==(t=e.options.scope)?void 0:t.id}var Ot=(me=class extends Ie{constructor(e,t){super(),Ae(this,de),Ae(this,ie),Ae(this,oe),Ae(this,le),Ae(this,ce),Re(this,ie,e),this.setOptions(t),this.bindMethods(),Me(this,de,ue).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const s=this.options;this.options=Pe(this,ie).defaultMutationOptions(e),tt(this.options,s)||Pe(this,ie).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Pe(this,le),observer:this}),(null==s?void 0:s.mutationKey)&&this.options.mutationKey&&Je(s.mutationKey)!==Je(this.options.mutationKey)?this.reset():"pending"===(null==(t=Pe(this,le))?void 0:t.state.status)&&Pe(this,le).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||null==(e=Pe(this,le))||e.removeObserver(this)}onMutationUpdate(e){Me(this,de,ue).call(this),Me(this,de,he).call(this,e)}getCurrentResult(){return Pe(this,oe)}reset(){var e;null==(e=Pe(this,le))||e.removeObserver(this),Re(this,le,void 0),Me(this,de,ue).call(this),Me(this,de,he).call(this)}mutate(e,t){var s;return Re(this,ce,t),null==(s=Pe(this,le))||s.removeObserver(this),Re(this,le,Pe(this,ie).getMutationCache().build(Pe(this,ie),this.options)),Pe(this,le).addObserver(this),Pe(this,le).execute(e)}},ie=new WeakMap,oe=new WeakMap,le=new WeakMap,ce=new WeakMap,de=new WeakSet,ue=function(){var e;const t=(null==(e=Pe(this,le))?void 0:e.state)??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};Re(this,oe,{...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset})},he=function(e){pt.batch(()=>{var t,s,n,r,a,i,o,l;if(Pe(this,ce)&&this.hasListeners()){const c=Pe(this,oe).variables,d=Pe(this,oe).context,u={client:Pe(this,ie),meta:this.options.meta,mutationKey:this.options.mutationKey};"success"===(null==e?void 0:e.type)?(null==(s=(t=Pe(this,ce)).onSuccess)||s.call(t,e.data,c,d,u),null==(r=(n=Pe(this,ce)).onSettled)||r.call(n,e.data,null,c,d,u)):"error"===(null==e?void 0:e.type)&&(null==(i=(a=Pe(this,ce)).onError)||i.call(a,e.error,c,d,u),null==(l=(o=Pe(this,ce)).onSettled)||l.call(o,void 0,e.error,c,d,u))}this.listeners.forEach(e=>{e(Pe(this,oe))})})},me),Ft=(fe=class extends Ie{constructor(e={}){super(),Ae(this,pe),this.config=e,Re(this,pe,new Map)}build(e,t,s){const n=t.queryKey,r=t.queryHash??Ge(n,t);let a=this.get(r);return a||(a=new wt({client:e,queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){Pe(this,pe).has(e.queryHash)||(Pe(this,pe).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=Pe(this,pe).get(e.queryHash);t&&(e.destroy(),t===e&&Pe(this,pe).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){pt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Pe(this,pe).get(e)}getAll(){return[...Pe(this,pe).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(e=>Ye(t,e))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ye(e,t)):t}notify(e){pt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){pt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){pt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},pe=new WeakMap,fe),zt=(ke=class{constructor(e={}){Ae(this,ge),Ae(this,ye),Ae(this,xe),Ae(this,ve),Ae(this,be),Ae(this,we),Ae(this,Se),Ae(this,je),Re(this,ge,e.queryCache||new Ft),Re(this,ye,e.mutationCache||new Dt),Re(this,xe,e.defaultOptions||{}),Re(this,ve,new Map),Re(this,be,new Map),Re(this,we,0)}mount(){De(this,we)._++,1===Pe(this,we)&&(Re(this,Se,ut.subscribe(async e=>{e&&(await this.resumePausedMutations(),Pe(this,ge).onFocus())})),Re(this,je,ft.subscribe(async e=>{e&&(await this.resumePausedMutations(),Pe(this,ge).onOnline())})))}unmount(){var e,t;De(this,we)._--,0===Pe(this,we)&&(null==(e=Pe(this,Se))||e.call(this),Re(this,Se,void 0),null==(t=Pe(this,je))||t.call(this),Re(this,je,void 0))}isFetching(e){return Pe(this,ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Pe(this,ye).findAll({...e,status:"pending"}).length}getQueryData(e){var t;const s=this.defaultQueryOptions({queryKey:e});return null==(t=Pe(this,ge).get(s.queryHash))?void 0:t.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=Pe(this,ge).build(this,t),n=s.state.data;return void 0===n?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(He(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return Pe(this,ge).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),r=Pe(this,ge).get(n.queryHash),a=function(e,t){return"function"==typeof e?e(t):e}(t,null==r?void 0:r.state.data);if(void 0!==a)return Pe(this,ge).build(this,n).setData(a,{...s,manual:!0})}setQueriesData(e,t,s){return pt.batch(()=>Pe(this,ge).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,s)]))}getQueryState(e){var t;const s=this.defaultQueryOptions({queryKey:e});return null==(t=Pe(this,ge).get(s.queryHash))?void 0:t.state}removeQueries(e){const t=Pe(this,ge);pt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const s=Pe(this,ge);return pt.batch(()=>(s.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=pt.batch(()=>Pe(this,ge).findAll(e).map(e=>e.cancel(s)));return Promise.all(n).then(qe).catch(qe)}invalidateQueries(e,t={}){return pt.batch(()=>(Pe(this,ge).findAll(e).forEach(e=>{e.invalidate()}),"none"===(null==e?void 0:e.refetchType)?Promise.resolve():this.refetchQueries({...e,type:(null==e?void 0:e.refetchType)??(null==e?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=pt.batch(()=>Pe(this,ge).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,s);return s.throwOnError||(t=t.catch(qe)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(n).then(qe)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const s=Pe(this,ge).build(this,t);return s.isStaleByTime(He(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(qe).catch(qe)}fetchInfiniteQuery(e){return e.behavior=Pt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(qe).catch(qe)}ensureInfiniteQueryData(e){return e.behavior=Pt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ft.isOnline()?Pe(this,ye).resumePausedMutations():Promise.resolve()}getQueryCache(){return Pe(this,ge)}getMutationCache(){return Pe(this,ye)}getDefaultOptions(){return Pe(this,xe)}setDefaultOptions(e){Re(this,xe,e)}setQueryDefaults(e,t){Pe(this,ve).set(Je(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Pe(this,ve).values()],s={};return t.forEach(t=>{Xe(e,t.queryKey)&&Object.assign(s,t.defaultOptions)}),s}setMutationDefaults(e,t){Pe(this,be).set(Je(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Pe(this,be).values()],s={};return t.forEach(t=>{Xe(e,t.mutationKey)&&Object.assign(s,t.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...Pe(this,xe).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ge(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===lt&&(t.enabled=!1),t}defaultMutationOptions(e){return(null==e?void 0:e._defaulted)?e:{...Pe(this,xe).mutations,...(null==e?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Pe(this,ge).clear(),Pe(this,ye).clear()}},ge=new WeakMap,ye=new WeakMap,xe=new WeakMap,ve=new WeakMap,be=new WeakMap,we=new WeakMap,Se=new WeakMap,je=new WeakMap,ke),Lt=Le.createContext(void 0),It=e=>{const t=Le.useContext(Lt);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_t=({client:e,children:t})=>(Le.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),$e.jsx(Lt.Provider,{value:e,children:t})),Vt=Le.createContext(!1);Vt.Provider;var Bt=Le.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),qt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ut(e,t,s){var n,r,a,i,o;if("production"!==process.env.NODE_ENV&&("object"!=typeof e||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const l=Le.useContext(Vt),c=Le.useContext(Bt),d=It(),u=d.defaultQueryOptions(e);null==(r=null==(n=d.getDefaultOptions().queries)?void 0:n._experimental_beforeQuery)||r.call(n,u),"production"!==process.env.NODE_ENV&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=l?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,s=e=>"static"===e?e:Math.max(e??t,t),n=e.staleTime;e.staleTime="function"==typeof n?(...e)=>s(n(...e)):s(n),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(u),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(u,c),(e=>{Le.useEffect(()=>{e.clearReset()},[e])})(c);const h=!d.getQueryCache().get(u.queryHash),[m]=Le.useState(()=>new t(d,u)),p=m.getOptimisticResult(u),f=!l&&!1!==e.subscribed;if(Le.useSyncExternalStore(Le.useCallback(e=>{const t=f?m.subscribe(pt.batchCalls(e)):qe;return m.updateResult(),t},[m,f]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),Le.useEffect(()=>{m.setOptions(u)},[u,m]),((e,t)=>(null==e?void 0:e.suspense)&&t.isPending)(u,p))throw qt(u,m,c);if((({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(r&&void 0===e.data||dt(s,[e.error,n])))({result:p,errorResetBoundary:c,throwOnError:u.throwOnError,query:d.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw p.error;if(null==(i=null==(a=d.getDefaultOptions().queries)?void 0:a._experimental_afterQuery)||i.call(a,u,p),u.experimental_prefetchInRender&&!Be&&((e,t)=>e.isLoading&&e.isFetching&&!t)(p,l)){const e=h?qt(u,m,c):null==(o=d.getQueryCache().get(u.queryHash))?void 0:o.promise;null==e||e.catch(qe).finally(()=>{m.updateResult()})}return u.notifyOnChangeProps?p:m.trackResult(p)}function Wt(e,t){const s=It(),[n]=Le.useState(()=>new Ot(s,e));Le.useEffect(()=>{n.setOptions(e)},[n,e]);const r=Le.useSyncExternalStore(Le.useCallback(e=>n.subscribe(pt.batchCalls(e)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=Le.useCallback((e,t)=>{n.mutate(e,t).catch(qe)},[n]);if(r.error&&dt(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}const Ht=[{id:"session-1",title:"General Inquiry",messages:[{id:"1",content:"Hello! How can I help you today?",sender:"bot",timestamp:new Date(Date.now()-3e5)},{id:"2",content:"Hi there! I have a question about your services.",sender:"user",timestamp:new Date(Date.now()-24e4)},{id:"3",content:"I'd be happy to help! What would you like to know?",sender:"bot",timestamp:new Date(Date.now()-18e4)}],createdAt:new Date(Date.now()-864e5),updatedAt:new Date(Date.now()-18e4)},{id:"session-2",title:"Product Support",messages:[{id:"4",content:"I need help with product installation.",sender:"user",timestamp:new Date(Date.now()-1728e5)},{id:"5",content:"Sure! Let me guide you through the installation process.",sender:"bot",timestamp:new Date(Date.now()-17274e4)}],createdAt:new Date(Date.now()-1728e5),updatedAt:new Date(Date.now()-17274e4)}],Kt=["That's a great question! Let me help you with that.","I understand your concern. Here's what I can suggest...","Thanks for reaching out! I'm here to assist you.","Let me provide you with some helpful information.","I'd be happy to clarify that for you.","That's an interesting point. Here's my perspective...","I can definitely help you with that request.","Thanks for your patience. Here's what you need to know..."],Yt={SESSIONS:"chatbot-sessions",THEME:"chatbot-theme",CURRENT_SESSION:"chatbot-current-session",AUTH:"chatbot-auth",API_KEY:"chatbot-api-key",CURRENT_ROUTE:"chatbot-current-route"},Qt=e=>({...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),messages:e.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}))}),Gt={getAuth(){try{const e=localStorage.getItem(Yt.AUTH);return e?JSON.parse(e):null}catch(e){return console.error("Failed to get auth data:",e),null}},saveAuth(e){try{localStorage.setItem(Yt.AUTH,JSON.stringify(e))}catch(t){console.error("Failed to save auth data:",t)}},clearAuth(){try{localStorage.removeItem(Yt.AUTH)}catch(e){console.error("Failed to clear auth data:",e)}},getApiKey(){try{return localStorage.getItem(Yt.API_KEY)}catch(e){return console.error("Failed to get API key:",e),null}},saveApiKey(e){try{localStorage.setItem(Yt.API_KEY,e)}catch(t){console.error("Failed to save API key:",t)}},clearApiKey(){try{localStorage.removeItem(Yt.API_KEY)}catch(e){console.error("Failed to clear API key:",e)}},getSessions(){try{const e=localStorage.getItem(Yt.SESSIONS);if(!e)return[];return JSON.parse(e).map(Qt)}catch(e){return console.error("Failed to get sessions:",e),[]}},saveSessions(e){try{localStorage.setItem(Yt.SESSIONS,JSON.stringify(e))}catch(t){console.error("Failed to save sessions:",t)}},getCurrentSession(){try{const e=localStorage.getItem(Yt.CURRENT_SESSION);if(!e)return null;const t=JSON.parse(e);return Qt(t)}catch(e){return console.error("Failed to get current session:",e),null}},saveCurrentSession(e){try{e?localStorage.setItem(Yt.CURRENT_SESSION,JSON.stringify(e)):localStorage.removeItem(Yt.CURRENT_SESSION)}catch(t){console.error("Failed to save current session:",t)}},getTheme(){try{const e=localStorage.getItem(Yt.THEME);return e?JSON.parse(e):null}catch{return null}},saveTheme(e){try{localStorage.setItem(Yt.THEME,JSON.stringify(e))}catch(t){console.error("Failed to save theme:",t)}},getCurrentRoute(){try{return localStorage.getItem(Yt.CURRENT_ROUTE)}catch(e){return console.error("Failed to get current route:",e),null}},saveCurrentRoute(e){try{localStorage.setItem(Yt.CURRENT_ROUTE,e)}catch(t){console.error("Failed to save current route:",t)}},clearAll(){try{Object.values(Yt).forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Failed to clear storage:",e)}}};function Jt(e){e=e.replace("#","");const t=parseInt(e.substr(0,2),16)/255,s=parseInt(e.substr(2,2),16)/255,n=parseInt(e.substr(4,2),16)/255,r=Math.max(t,s,n),a=Math.min(t,s,n);let i=0,o=0;const l=(r+a)/2;if(r!==a){const e=r-a;switch(o=l>.5?e/(2-r-a):e/(r+a),r){case t:i=(s-n)/e+(s<n?6:0);break;case s:i=(n-t)/e+2;break;case n:i=(t-s)/e+4}i/=6}return`${Math.round(360*i)} ${Math.round(100*o)}% ${Math.round(100*l)}%`}const Xt={primaryColor:"#b07e48",headerBg:"#1f2937",headerText:"#ffffff",userBubble:"#3b82f6",botBubble:"#f3f4f6",fontFamily:"Inter, system-ui, sans-serif"},Zt={isOpen:!1,currentSession:null,sessions:[],isLoading:!1,error:null,currentScreen:"chat",theme:Xt,isAuthenticated:!1,user:null,authLoading:!1};function es(e,t){var s;switch(console.log("ChatReducer: Action received:",t.type),console.log("ChatReducer: Current state:",e),t.type){case"OPEN_WIDGET":console.log("ChatReducer: Processing OPEN_WIDGET");const n={...e,isOpen:!0};return console.log("ChatReducer: New state after OPEN_WIDGET:",n),n;case"CLOSE_WIDGET":return{...e,isOpen:!1};case"SET_SCREEN":return{...e,currentScreen:t.payload};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"SET_AUTH_LOADING":return{...e,authLoading:t.payload};case"SET_AUTHENTICATED":return{...e,isAuthenticated:!0,user:t.payload,authLoading:!1};case"LOGOUT":return{...e,isAuthenticated:!1,user:null,currentSession:null,sessions:[],currentScreen:"chat"};case"ADD_MESSAGE":if(!e.currentSession)return e;const r={...e.currentSession,messages:[...e.currentSession.messages,t.payload],updatedAt:new Date},a=e.sessions.map(e=>e.id===r.id?r:e);return{...e,currentSession:r,sessions:a};case"CREATE_SESSION":return{...e,currentSession:t.payload,sessions:[t.payload,...e.sessions]};case"LOAD_SESSION":return{...e,currentSession:t.payload};case"UPDATE_SESSIONS":return{...e,sessions:t.payload};case"DELETE_SESSION":const i=e.sessions.filter(e=>e.id!==t.payload),o=(null==(s=e.currentSession)?void 0:s.id)===t.payload?null:e.currentSession;return{...e,sessions:i,currentSession:o};case"UPDATE_THEME":return{...e,theme:{...e.theme,...t.payload}};case"CLEAR_DATA":return{...Zt,theme:e.theme};default:return console.log("ChatReducer: Unknown action type:",t),e}}const ts=Oe.createContext(void 0);function ss({children:e,initialTheme:t,apiKey:s,tenantId:n,email:r}){const[a,i]=Oe.useReducer(es,Zt),o=Oe.useRef({});Oe.useEffect(()=>{const e=Gt.getAuth(),s=Gt.getSessions(),n=Gt.getCurrentSession(),r=Gt.getTheme();e&&e.email&&(i({type:"SET_AUTHENTICATED",payload:e}),s.length>0?i({type:"UPDATE_SESSIONS",payload:s}):i({type:"UPDATE_SESSIONS",payload:Ht}),n&&i({type:"LOAD_SESSION",payload:n})),r?i({type:"UPDATE_THEME",payload:r}):t&&i({type:"UPDATE_THEME",payload:t})},[]),Oe.useEffect(()=>{t&&i({type:"UPDATE_THEME",payload:t})},[t]),Oe.useEffect(()=>{a.isAuthenticated&&Gt.saveSessions(a.sessions)},[a.sessions,a.isAuthenticated]),Oe.useEffect(()=>{a.isAuthenticated&&Gt.saveCurrentSession(a.currentSession)},[a.currentSession,a.isAuthenticated]),Oe.useEffect(()=>{Gt.saveTheme(a.theme),function(e){const t=document.documentElement;if(e.primaryColor){const s=Jt(e.primaryColor);t.style.setProperty("--primary",s);const n=parseInt(s.split(" ")[2])>50?"0 0% 98%":"0 0% 9%";t.style.setProperty("--primary-foreground",n)}if(e.userBubble){const s=Jt(e.userBubble);t.style.setProperty("--user-bubble",s)}if(e.botBubble){const s=Jt(e.botBubble);t.style.setProperty("--bot-bubble",s)}}(a.theme)},[a.theme]),Oe.useEffect(()=>{a.user&&Gt.saveAuth(a.user)},[a.user]);const l=e=>i({type:"SET_SCREEN",payload:e}),c=async e=>{if(!e.trim())return;if(!a.currentSession)return d(),void setTimeout(()=>c(e),100);const t={id:`msg-${Date.now()}-user`,content:e.trim(),sender:"user",timestamp:new Date};i({type:"ADD_MESSAGE",payload:t}),i({type:"SET_LOADING",payload:!0}),setTimeout(()=>{const e={id:`msg-${Date.now()}-bot`,content:Kt[Math.floor(Math.random()*Kt.length)],sender:"bot",timestamp:new Date};i({type:"ADD_MESSAGE",payload:e}),i({type:"SET_LOADING",payload:!1})},1e3+2e3*Math.random())},d=()=>{const e={id:`session-${Date.now()}`,title:"New Conversation",messages:[],createdAt:new Date,updatedAt:new Date};i({type:"CREATE_SESSION",payload:e})};Oe.useEffect(()=>{const e=Gt.getApiKey();s&&s!==e&&Gt.saveApiKey(s),!s&&e&&Gt.clearApiKey();const t=Gt.getAuth(),a=null==t?void 0:t.email;r&&r!==a&&(Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null)),n&&o.current.tenantId!==n&&(Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null)),o.current={apiKey:s,tenantId:n,email:r}},[s,n,r]);const u={...a,openWidget:()=>{console.log("ChatContext: openWidget called"),console.log("ChatContext: Current state before dispatch:",a),i({type:"OPEN_WIDGET"}),console.log("ChatContext: OPEN_WIDGET dispatched")},closeWidget:()=>i({type:"CLOSE_WIDGET"}),setCurrentScreen:l,authenticate:async(e,t)=>{i({type:"SET_AUTH_LOADING",payload:!0});try{if(await new Promise(e=>setTimeout(e,1500)),e&&6===t.length){const t=`token_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return i({type:"SET_AUTHENTICATED",payload:{email:e,token:t}}),!0}return!1}catch(s){return i({type:"SET_AUTH_LOADING",payload:!1}),!1}},login:e=>{const t=`token_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;i({type:"SET_AUTHENTICATED",payload:{email:e,token:t}})},logout:()=>{Promise.resolve().then(()=>kp).then(({clearTokens:e,clearAutoRefresh:t})=>{t(),e()}),Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null),i({type:"LOGOUT"})},sendMessage:c,createNewSession:d,loadSession:e=>{const t=a.sessions.find(t=>t.id===e);t&&(i({type:"LOAD_SESSION",payload:t}),l("chat"))},deleteSession:e=>{i({type:"DELETE_SESSION",payload:e})},updateTheme:e=>{i({type:"UPDATE_THEME",payload:e})},resetTheme:()=>{i({type:"UPDATE_THEME",payload:Xt})},clearAllData:()=>{Gt.clearAll(),i({type:"CLEAR_DATA"})},apiKey:s,tenantId:n,email:r};return $e.jsx(ts.Provider,{value:u,children:e})}function ns(){const e=Oe.useContext(ts);if(void 0===e)throw new Error("useChatContext must be used within a ChatProvider");return e}const rs=Oe.createContext({});function as(e){const t=Oe.useRef(null);return null===t.current&&(t.current=e()),t.current}const is="undefined"!=typeof window,os=is?Oe.useLayoutEffect:Oe.useEffect,ls=Oe.createContext(null);function cs(e,t){-1===e.indexOf(t)&&e.push(t)}function ds(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}const us=(e,t,s)=>s>t?t:s<e?e:s;function hs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let ms=()=>{},ps=()=>{};"production"!==process.env.NODE_ENV&&(ms=(e,t,s)=>{e||"undefined"==typeof console||console.warn(hs(t,s))},ps=(e,t,s)=>{if(!e)throw new Error(hs(t,s))});const fs={},gs=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ys(e){return"object"==typeof e&&null!==e}const xs=e=>/^0[^.\s]+$/u.test(e);function vs(e){let t;return()=>(void 0===t&&(t=e()),t)}const bs=e=>e,ws=(e,t)=>s=>t(e(s)),Ss=(...e)=>e.reduce(ws),js=(e,t,s)=>{const n=t-e;return 0===n?1:(s-e)/n};class ks{constructor(){this.subscriptions=[]}add(e){return cs(this.subscriptions,e),()=>ds(this.subscriptions,e)}notify(e,t,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](e,t,s);else for(let r=0;r<n;r++){const n=this.subscriptions[r];n&&n(e,t,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ns=e=>1e3*e,Es=e=>e/1e3;function Cs(e,t){return t?e*(1e3/t):0}const Ts=new Set;function Ps(e,t,s){e||Ts.has(t)||(console.warn(hs(t,s)),Ts.add(t))}const As=(e,t,s)=>(((1-3*s+3*t)*e+(3*s-6*t))*e+3*t)*e;function Rs(e,t,s,n){if(e===t&&s===n)return bs;const r=t=>function(e,t,s,n,r){let a,i,o=0;do{i=t+(s-t)/2,a=As(i,n,r)-e,a>0?s=i:t=i}while(Math.abs(a)>1e-7&&++o<12);return i}(t,0,1,e,s);return e=>0===e||1===e?e:As(r(e),t,n)}const Ms=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ds=e=>t=>1-e(1-t),$s=Rs(.33,1.53,.69,.99),Os=Ds($s),Fs=Ms(Os),zs=e=>(e*=2)<1?.5*Os(e):.5*(2-Math.pow(2,-10*(e-1))),Ls=e=>1-Math.sin(Math.acos(e)),Is=Ds(Ls),_s=Ms(Ls),Vs=Rs(.42,0,1,1),Bs=Rs(0,0,.58,1),qs=Rs(.42,0,.58,1),Us=e=>Array.isArray(e)&&"number"==typeof e[0],Ws={linear:bs,easeIn:Vs,easeInOut:qs,easeOut:Bs,circIn:Ls,circInOut:_s,circOut:Is,backIn:Os,backInOut:Fs,backOut:$s,anticipate:zs},Hs=e=>{if(Us(e)){ps(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,s,n,r]=e;return Rs(t,s,n,r)}return"string"==typeof e?(ps(void 0!==Ws[e],`Invalid easing type '${e}'`,"invalid-easing-type"),Ws[e]):e},Ks=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ys(e,t){let s=!1,n=!0;const r={delta:0,timestamp:0,isProcessing:!1},a=()=>s=!0,i=Ks.reduce((e,t)=>(e[t]=function(e){let t=new Set,s=new Set,n=!1,r=!1;const a=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function o(t){a.has(t)&&(l.schedule(t),e()),t(i)}const l={schedule:(e,r=!1,i=!1)=>{const o=i&&n?t:s;return r&&a.add(e),o.has(e)||o.add(e),e},cancel:e=>{s.delete(e),a.delete(e)},process:e=>{i=e,n?r=!0:(n=!0,[t,s]=[s,t],t.forEach(o),t.clear(),n=!1,r&&(r=!1,l.process(e)))}};return l}(a),e),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:h,render:m,postRender:p}=i,f=()=>{const a=fs.useManualTiming?r.timestamp:performance.now();s=!1,fs.useManualTiming||(r.delta=n?1e3/60:Math.max(Math.min(a-r.timestamp,40),1)),r.timestamp=a,r.isProcessing=!0,o.process(r),l.process(r),c.process(r),d.process(r),u.process(r),h.process(r),m.process(r),p.process(r),r.isProcessing=!1,s&&t&&(n=!1,e(f))};return{schedule:Ks.reduce((t,a)=>{const o=i[a];return t[a]=(t,a=!1,i=!1)=>(s||(s=!0,n=!0,r.isProcessing||e(f)),o.schedule(t,a,i)),t},{}),cancel:e=>{for(let t=0;t<Ks.length;t++)i[Ks[t]].cancel(e)},state:r,steps:i}}const{schedule:Qs,cancel:Gs,state:Js,steps:Xs}=Ys("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:bs,!0);let Zs;function en(){Zs=void 0}const tn={now:()=>(void 0===Zs&&tn.set(Js.isProcessing||fs.useManualTiming?Js.timestamp:performance.now()),Zs),set:e=>{Zs=e,queueMicrotask(en)}},sn=e=>t=>"string"==typeof t&&t.startsWith(e),nn=sn("--"),rn=sn("var(--"),an=e=>!!rn(e)&&on.test(e.split("/*")[0].trim()),on=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ln={test:e=>"number"==typeof e,parse:parseFloat,transform:e=>e},cn={...ln,transform:e=>us(0,1,e)},dn={...ln,default:1},un=e=>Math.round(1e5*e)/1e5,hn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const mn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,pn=(e,t)=>s=>Boolean("string"==typeof s&&mn.test(s)&&s.startsWith(e)||t&&!function(e){return null==e}(s)&&Object.prototype.hasOwnProperty.call(s,t)),fn=(e,t,s)=>n=>{if("string"!=typeof n)return n;const[r,a,i,o]=n.match(hn);return{[e]:parseFloat(r),[t]:parseFloat(a),[s]:parseFloat(i),alpha:void 0!==o?parseFloat(o):1}},gn={...ln,transform:e=>Math.round((e=>us(0,255,e))(e))},yn={test:pn("rgb","red"),parse:fn("red","green","blue"),transform:({red:e,green:t,blue:s,alpha:n=1})=>"rgba("+gn.transform(e)+", "+gn.transform(t)+", "+gn.transform(s)+", "+un(cn.transform(n))+")"};const xn={test:pn("#"),parse:function(e){let t="",s="",n="",r="";return e.length>5?(t=e.substring(1,3),s=e.substring(3,5),n=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),s=e.substring(2,3),n=e.substring(3,4),r=e.substring(4,5),t+=t,s+=s,n+=n,r+=r),{red:parseInt(t,16),green:parseInt(s,16),blue:parseInt(n,16),alpha:r?parseInt(r,16)/255:1}},transform:yn.transform},vn=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),bn=vn("deg"),wn=vn("%"),Sn=vn("px"),jn=vn("vh"),kn=vn("vw"),Nn=(()=>({...wn,parse:e=>wn.parse(e)/100,transform:e=>wn.transform(100*e)}))(),En={test:pn("hsl","hue"),parse:fn("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:s,alpha:n=1})=>"hsla("+Math.round(e)+", "+wn.transform(un(t))+", "+wn.transform(un(s))+", "+un(cn.transform(n))+")"},Cn={test:e=>yn.test(e)||xn.test(e)||En.test(e),parse:e=>yn.test(e)?yn.parse(e):En.test(e)?En.parse(e):xn.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?yn.transform(e):En.transform(e),getAnimatableNone:e=>{const t=Cn.parse(e);return t.alpha=0,Cn.transform(t)}},Tn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Pn="number",An="color",Rn=/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 Mn(e){const t=e.toString(),s=[],n={color:[],number:[],var:[]},r=[];let a=0;const i=t.replace(Rn,e=>(Cn.test(e)?(n.color.push(a),r.push(An),s.push(Cn.parse(e))):e.startsWith("var(")?(n.var.push(a),r.push("var"),s.push(e)):(n.number.push(a),r.push(Pn),s.push(parseFloat(e))),++a,"${}")).split("${}");return{values:s,split:i,indexes:n,types:r}}function Dn(e){return Mn(e).values}function $n(e){const{split:t,types:s}=Mn(e),n=t.length;return e=>{let r="";for(let a=0;a<n;a++)if(r+=t[a],void 0!==e[a]){const t=s[a];r+=t===Pn?un(e[a]):t===An?Cn.transform(e[a]):e[a]}return r}}const On=e=>"number"==typeof e?0:Cn.test(e)?Cn.getAnimatableNone(e):e;const Fn={test:function(e){var t,s;return isNaN(e)&&"string"==typeof e&&((null==(t=e.match(hn))?void 0:t.length)||0)+((null==(s=e.match(Tn))?void 0:s.length)||0)>0},parse:Dn,createTransformer:$n,getAnimatableNone:function(e){const t=Dn(e);return $n(e)(t.map(On))}};function zn(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e}function Ln(e,t){return s=>s>0?t:e}const In=(e,t,s)=>e+(t-e)*s,_n=(e,t,s)=>{const n=e*e,r=s*(t*t-n)+n;return r<0?0:Math.sqrt(r)},Vn=[xn,yn,En];function Bn(e){const t=(s=e,Vn.find(e=>e.test(s)));var s;if(ms(Boolean(t),`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!Boolean(t))return!1;let n=t.parse(e);return t===En&&(n=function({hue:e,saturation:t,lightness:s,alpha:n}){e/=360,s/=100;let r=0,a=0,i=0;if(t/=100){const n=s<.5?s*(1+t):s+t-s*t,o=2*s-n;r=zn(o,n,e+1/3),a=zn(o,n,e),i=zn(o,n,e-1/3)}else r=a=i=s;return{red:Math.round(255*r),green:Math.round(255*a),blue:Math.round(255*i),alpha:n}}(n)),n}const qn=(e,t)=>{const s=Bn(e),n=Bn(t);if(!s||!n)return Ln(e,t);const r={...s};return e=>(r.red=_n(s.red,n.red,e),r.green=_n(s.green,n.green,e),r.blue=_n(s.blue,n.blue,e),r.alpha=In(s.alpha,n.alpha,e),yn.transform(r))},Un=new Set(["none","hidden"]);function Wn(e,t){return s=>In(e,t,s)}function Hn(e){return"number"==typeof e?Wn:"string"==typeof e?an(e)?Ln:Cn.test(e)?qn:Qn:Array.isArray(e)?Kn:"object"==typeof e?Cn.test(e)?qn:Yn:Ln}function Kn(e,t){const s=[...e],n=s.length,r=e.map((e,s)=>Hn(e)(e,t[s]));return e=>{for(let t=0;t<n;t++)s[t]=r[t](e);return s}}function Yn(e,t){const s={...e,...t},n={};for(const r in s)void 0!==e[r]&&void 0!==t[r]&&(n[r]=Hn(e[r])(e[r],t[r]));return e=>{for(const t in n)s[t]=n[t](e);return s}}const Qn=(e,t)=>{const s=Fn.createTransformer(t),n=Mn(e),r=Mn(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?Un.has(e)&&!r.values.length||Un.has(t)&&!n.values.length?function(e,t){return Un.has(e)?s=>s<=0?e:t:s=>s>=1?t:e}(e,t):Ss(Kn(function(e,t){const s=[],n={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const a=t.types[r],i=e.indexes[a][n[a]],o=e.values[i]??0;s[r]=o,n[a]++}return s}(n,r),r.values),s):(ms(!0,`Complex values '${e}' and '${t}' 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"),Ln(e,t))};function Gn(e,t,s){if("number"==typeof e&&"number"==typeof t&&"number"==typeof s)return In(e,t,s);return Hn(e)(e,t)}const Jn=e=>{const t=({timestamp:t})=>e(t);return{start:(e=!0)=>Qs.update(t,e),stop:()=>Gs(t),now:()=>Js.isProcessing?Js.timestamp:tn.now()}},Xn=(e,t,s=10)=>{let n="";const r=Math.max(Math.round(t/s),2);for(let a=0;a<r;a++)n+=Math.round(1e4*e(a/(r-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},Zn=2e4;function er(e){let t=0;let s=e.next(t);for(;!s.done&&t<Zn;)t+=50,s=e.next(t);return t>=Zn?1/0:t}function tr(e,t,s){const n=Math.max(t-5,0);return Cs(s-e(n),t-n)}const sr=100,nr=10,rr=1,ar=0,ir=800,or=.3,lr=.3,cr={granular:.01,default:2},dr={granular:.005,default:.5},ur=.01,hr=10,mr=.05,pr=1,fr=.001;function gr({duration:e=ir,bounce:t=or,velocity:s=ar,mass:n=rr}){let r,a;ms(e<=Ns(hr),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=us(mr,pr,i),e=us(ur,hr,Es(e)),i<1?(r=t=>{const n=t*i,r=n*e,a=n-s,o=xr(t,i),l=Math.exp(-r);return fr-a/o*l},a=t=>{const n=t*i*e,a=n*s+s,o=Math.pow(i,2)*Math.pow(t,2)*e,l=Math.exp(-n),c=xr(Math.pow(t,2),i);return(-r(t)+fr>0?-1:1)*((a-o)*l)/c}):(r=t=>Math.exp(-t*e)*((t-s)*e+1)-.001,a=t=>Math.exp(-t*e)*(e*e*(s-t)));const o=function(e,t,s){let n=s;for(let r=1;r<yr;r++)n-=e(n)/t(n);return n}(r,a,5/e);if(e=Ns(e),isNaN(o))return{stiffness:sr,damping:nr,duration:e};{const t=Math.pow(o,2)*n;return{stiffness:t,damping:2*i*Math.sqrt(n*t),duration:e}}}const yr=12;function xr(e,t){return e*Math.sqrt(1-t*t)}const vr=["duration","bounce"],br=["stiffness","damping","mass"];function wr(e,t){return t.some(t=>void 0!==e[t])}function Sr(e=lr,t=or){const s="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:n,restDelta:r}=s;const a=s.keyframes[0],i=s.keyframes[s.keyframes.length-1],o={done:!1,value:a},{stiffness:l,damping:c,mass:d,duration:u,velocity:h,isResolvedFromDuration:m}=function(e){let t={velocity:ar,stiffness:sr,damping:nr,mass:rr,isResolvedFromDuration:!1,...e};if(!wr(e,br)&&wr(e,vr))if(e.visualDuration){const s=e.visualDuration,n=2*Math.PI/(1.2*s),r=n*n,a=2*us(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:rr,stiffness:r,damping:a}}else{const s=gr(e);t={...t,...s,mass:rr},t.isResolvedFromDuration=!0}return t}({...s,velocity:-Es(s.velocity||0)}),p=h||0,f=c/(2*Math.sqrt(l*d)),g=i-a,y=Es(Math.sqrt(l/d)),x=Math.abs(g)<5;let v;if(n||(n=x?cr.granular:cr.default),r||(r=x?dr.granular:dr.default),f<1){const e=xr(y,f);v=t=>{const s=Math.exp(-f*y*t);return i-s*((p+f*y*g)/e*Math.sin(e*t)+g*Math.cos(e*t))}}else if(1===f)v=e=>i-Math.exp(-y*e)*(g+(p+y*g)*e);else{const e=y*Math.sqrt(f*f-1);v=t=>{const s=Math.exp(-f*y*t),n=Math.min(e*t,300);return i-s*((p+f*y*g)*Math.sinh(n)+e*g*Math.cosh(n))/e}}const b={calculatedDuration:m&&u||null,next:e=>{const t=v(e);if(m)o.done=e>=u;else{let s=0===e?p:0;f<1&&(s=0===e?Ns(p):tr(v,e,t));const a=Math.abs(s)<=n,l=Math.abs(i-t)<=r;o.done=a&&l}return o.value=o.done?i:t,o},toString:()=>{const e=Math.min(er(b),Zn),t=Xn(t=>b.next(e*t).value,e,30);return e+"ms "+t},toTransition:()=>{}};return b}function jr({keyframes:e,velocity:t=0,power:s=.8,timeConstant:n=325,bounceDamping:r=10,bounceStiffness:a=500,modifyTarget:i,min:o,max:l,restDelta:c=.5,restSpeed:d}){const u=e[0],h={done:!1,value:u},m=e=>void 0===o?l:void 0===l||Math.abs(o-e)<Math.abs(l-e)?o:l;let p=s*t;const f=u+p,g=void 0===i?f:i(f);g!==f&&(p=g-u);const y=e=>-p*Math.exp(-e/n),x=e=>g+y(e),v=e=>{const t=y(e),s=x(e);h.done=Math.abs(t)<=c,h.value=h.done?g:s};let b,w;const S=e=>{var t;(t=h.value,void 0!==o&&t<o||void 0!==l&&t>l)&&(b=e,w=Sr({keyframes:[h.value,m(h.value)],velocity:tr(x,e,h.value),damping:r,stiffness:a,restDelta:c,restSpeed:d}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return w||void 0!==b||(t=!0,v(e),S(e)),void 0!==b&&e>=b?w.next(e-b):(!t&&v(e),h)}}}function kr(e,t,{clamp:s=!0,ease:n,mixer:r}={}){const a=e.length;if(ps(a===t.length,"Both input and output ranges must be the same length","range-length"),1===a)return()=>t[0];if(2===a&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=function(e,t,s){const n=[],r=s||fs.mix||Gn,a=e.length-1;for(let i=0;i<a;i++){let s=r(e[i],e[i+1]);if(t){const e=Array.isArray(t)?t[i]||bs:t;s=Ss(e,s)}n.push(s)}return n}(t,n,r),l=o.length,c=s=>{if(i&&s<e[0])return t[0];let n=0;if(l>1)for(;n<e.length-2&&!(s<e[n+1]);n++);const r=js(e[n],e[n+1],s);return o[n](r)};return s?t=>c(us(e[0],e[a-1],t)):c}function Nr(e){const t=[0];return function(e,t){const s=e[e.length-1];for(let n=1;n<=t;n++){const r=js(0,t,n);e.push(In(s,1,r))}}(t,e.length-1),t}function Er({duration:e=300,keyframes:t,times:s,ease:n="easeInOut"}){const r=(e=>Array.isArray(e)&&"number"!=typeof e[0])(n)?n.map(Hs):Hs(n),a={done:!1,value:t[0]},i=function(e,t){return e.map(e=>e*t)}(s&&s.length===t.length?s:Nr(t),e),o=kr(i,t,{ease:Array.isArray(r)?r:(l=t,c=r,l.map(()=>c||qs).splice(0,l.length-1))});var l,c;return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}Sr.applyToOptions=e=>{const t=function(e,t=100,s){const n=s({...e,keyframes:[0,t]}),r=Math.min(er(n),Zn);return{type:"keyframes",ease:e=>n.next(r*e).value/t,duration:Es(r)}}(e,100,Sr);return e.ease=t.ease,e.duration=Ns(t.duration),e.type="keyframes",e};const Cr=e=>null!==e;function Tr(e,{repeat:t,repeatType:s="loop"},n,r=1){const a=e.filter(Cr),i=r<0||t&&"loop"!==s&&t%2==1?0:a.length-1;return i&&void 0!==n?n:a[i]}const Pr={decay:jr,inertia:jr,tween:Er,keyframes:Er,spring:Sr};function Ar(e){"string"==typeof e.type&&(e.type=Pr[e.type])}class Rr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}const Mr=e=>e/100;class Dr extends Rr{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var e,t;const{motionValue:s}=this.options;s&&s.updatedAt!==tn.now()&&this.tick(tn.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),null==(t=(e=this.options).onStop)||t.call(e))},this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){const{options:e}=this;Ar(e);const{type:t=Er,repeat:s=0,repeatDelay:n=0,repeatType:r,velocity:a=0}=e;let{keyframes:i}=e;const o=t||Er;"production"!==process.env.NODE_ENV&&o!==Er&&ps(i.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${i}`,"spring-two-frames"),o!==Er&&"number"!=typeof i[0]&&(this.mixKeyframes=Ss(Mr,Gn(i[0],i[1])),i=[0,100]);const l=o({...e,keyframes:i});"mirror"===r&&(this.mirroredGenerator=o({...e,keyframes:[...i].reverse(),velocity:-a})),null===l.calculatedDuration&&(l.calculatedDuration=er(l));const{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+n,this.totalDuration=this.resolvedDuration*(s+1)-n,this.generator=l}updateTime(e){const t=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){const{generator:s,totalDuration:n,mixKeyframes:r,mirroredGenerator:a,resolvedDuration:i,calculatedDuration:o}=this;if(null===this.startTime)return s.next(0);const{delay:l=0,keyframes:c,repeat:d,repeatType:u,repeatDelay:h,type:m,onUpdate:p,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);const g=this.currentTime-l*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?g<0:g>n;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let x=this.currentTime,v=s;if(d){const e=Math.min(this.currentTime,n)/i;let t=Math.floor(e),s=e%1;!s&&e>=1&&(s=1),1===s&&t--,t=Math.min(t,d+1);Boolean(t%2)&&("reverse"===u?(s=1-s,h&&(s-=h/i)):"mirror"===u&&(v=a)),x=us(0,1,s)*i}const b=y?{done:!1,value:c[0]}:v.next(x);r&&(b.value=r(b.value));let{done:w}=b;y||null===o||(w=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);const S=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return S&&m!==jr&&(b.value=Tr(c,this.options,f,this.speed)),p&&p(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return Es(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Es(e)}get time(){return Es(this.currentTime)}set time(e){var t;e=Ns(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),null==(t=this.driver)||t.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(tn.now());const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=Es(this.currentTime))}play(){var e,t;if(this.isStopped)return;const{driver:s=Jn,startTime:n}=this.options;this.driver||(this.driver=s(e=>this.tick(e))),null==(t=(e=this.options).onPlay)||t.call(e);const r=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=r):null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(tn.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,t;this.notifyFinished(),this.teardown(),this.state="finished",null==(t=(e=this.options).onComplete)||t.call(e)}cancel(){var e,t;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),null==(t=(e=this.options).onCancel)||t.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var t;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),null==(t=this.driver)||t.stop(),e.observe(this)}}const $r=e=>180*e/Math.PI,Or=e=>{const t=$r(Math.atan2(e[1],e[0]));return zr(t)},Fr={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Or,rotateZ:Or,skewX:e=>$r(Math.atan(e[1])),skewY:e=>$r(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},zr=e=>((e%=360)<0&&(e+=360),e),Lr=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ir=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),_r={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Lr,scaleY:Ir,scale:e=>(Lr(e)+Ir(e))/2,rotateX:e=>zr($r(Math.atan2(e[6],e[5]))),rotateY:e=>zr($r(Math.atan2(-e[2],e[0]))),rotateZ:Or,rotate:Or,skewX:e=>$r(Math.atan(e[4])),skewY:e=>$r(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Vr(e){return e.includes("scale")?1:0}function Br(e,t){if(!e||"none"===e)return Vr(t);const s=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,r;if(s)n=_r,r=s;else{const t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Fr,r=t}if(!r)return Vr(t);const a=n[t],i=r[1].split(",").map(qr);return"function"==typeof a?a(i):i[a]}function qr(e){return parseFloat(e.trim())}const Ur=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Wr=(()=>new Set(Ur))(),Hr=e=>e===ln||e===Sn,Kr=new Set(["x","y","z"]),Yr=Ur.filter(e=>!Kr.has(e));const Qr={width:({x:e},{paddingLeft:t="0",paddingRight:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),height:({y:e},{paddingTop:t="0",paddingBottom:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Br(t,"x"),y:(e,{transform:t})=>Br(t,"y")};Qr.translateX=Qr.x,Qr.translateY=Qr.y;const Gr=new Set;let Jr=!1,Xr=!1,Zr=!1;function ea(){if(Xr){const e=Array.from(Gr).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),s=new Map;t.forEach(e=>{const t=function(e){const t=[];return Yr.forEach(s=>{const n=e.getValue(s);void 0!==n&&(t.push([s,n.get()]),n.set(s.startsWith("scale")?1:0))}),t}(e);t.length&&(s.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();const t=s.get(e);t&&t.forEach(([t,s])=>{var n;null==(n=e.getValue(t))||n.set(s)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}Xr=!1,Jr=!1,Gr.forEach(e=>e.complete(Zr)),Gr.clear()}function ta(){Gr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Xr=!0)})}class sa{constructor(e,t,s,n,r,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=s,this.motionValue=n,this.element=r,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Gr.add(this),Jr||(Jr=!0,Qs.read(ta),Qs.resolveKeyframes(ea))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:s,motionValue:n}=this;if(null===e[0]){const r=null==n?void 0:n.get(),a=e[e.length-1];if(void 0!==r)e[0]=r;else if(s&&t){const n=s.readValue(t,a);null!=n&&(e[0]=n)}void 0===e[0]&&(e[0]=a),n&&void 0===r&&n.set(e[0])}!function(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Gr.delete(this)}cancel(){"scheduled"===this.state&&(Gr.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const na=vs(()=>void 0!==window.ScrollTimeline),ra={};function aa(e,t){const s=vs(e);return()=>ra[t]??s()}const ia=aa(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),oa=([e,t,s,n])=>`cubic-bezier(${e}, ${t}, ${s}, ${n})`,la={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:oa([0,.65,.55,1]),circOut:oa([.55,0,1,.45]),backIn:oa([.31,.01,.66,-.59]),backOut:oa([.33,1.53,.69,.99])};function ca(e,t){return e?"function"==typeof e?ia()?Xn(e,t):"ease-out":Us(e)?oa(e):Array.isArray(e)?e.map(e=>ca(e,t)||la.easeOut):la[e]:void 0}function da(e,t,s,{delay:n=0,duration:r=300,repeat:a=0,repeatType:i="loop",ease:o="easeOut",times:l}={},c=void 0){const d={[t]:s};l&&(d.offset=l);const u=ca(o,r);Array.isArray(u)&&(d.easing=u);const h={delay:n,duration:r,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:a+1,direction:"reverse"===i?"alternate":"normal"};c&&(h.pseudoElement=c);return e.animate(d,h)}function ua(e){return"function"==typeof e&&"applyToOptions"in e}class ha extends Rr{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:t,name:s,keyframes:n,pseudoElement:r,allowFlatten:a=!1,finalKeyframe:i,onComplete:o}=e;this.isPseudoElement=Boolean(r),this.allowFlatten=a,this.options=e,ps("string"!=typeof e.type,'Mini animate() doesn\'t support "type" as a string.',"mini-spring");const l=function({type:e,...t}){return ua(e)&&ia()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}(e);this.animation=da(t,s,n,l,r),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const e=Tr(n,this.options,i,this.speed);this.updateMotionValue?this.updateMotionValue(e):function(e,t,s){(e=>e.startsWith("--"))(t)?e.style.setProperty(t,s):e.style[t]=s}(t,s,e),this.animation.cancel()}null==o||o(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,t;null==(t=(e=this.animation).finish)||t.call(e)}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,t;this.isPseudoElement||null==(t=(e=this.animation).commitStyles)||t.call(e)}get duration(){var e,t;const s=(null==(t=null==(e=this.animation.effect)?void 0:e.getComputedTiming)?void 0:t.call(e).duration)||0;return Es(Number(s))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Es(e)}get time(){return Es(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ns(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:t}){var s;return this.allowFlatten&&(null==(s=this.animation.effect)||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&na()?(this.animation.timeline=e,bs):t(this)}}const ma={anticipate:zs,backInOut:Fs,circInOut:_s};function pa(e){"string"==typeof e.ease&&e.ease in ma&&(e.ease=ma[e.ease])}class fa extends ha{constructor(e){pa(e),Ar(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:t,onUpdate:s,onComplete:n,element:r,...a}=this.options;if(!t)return;if(void 0!==e)return void t.set(e);const i=new Dr({...a,autoplay:!1}),o=Ns(this.finishedTime??this.time);t.setWithVelocity(i.sample(o-10).value,i.sample(o).value,10),i.stop()}}const ga=(e,t)=>"zIndex"!==t&&(!("number"!=typeof e&&!Array.isArray(e))||!("string"!=typeof e||!Fn.test(e)&&"0"!==e||e.startsWith("url(")));function ya(e){e.duration=0,e.type="keyframes"}const xa=new Set(["opacity","clipPath","filter","transform"]),va=vs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class ba extends Rr{constructor({autoplay:e=!0,delay:t=0,type:s="keyframes",repeat:n=0,repeatDelay:r=0,repeatType:a="loop",keyframes:i,name:o,motionValue:l,element:c,...d}){var u;super(),this.stop=()=>{var e,t;this._animation&&(this._animation.stop(),null==(e=this.stopTimeline)||e.call(this)),null==(t=this.keyframeResolver)||t.cancel()},this.createdAt=tn.now();const h={autoplay:e,delay:t,type:s,repeat:n,repeatDelay:r,repeatType:a,name:o,motionValue:l,element:c,...d},m=(null==c?void 0:c.KeyframeResolver)||sa;this.keyframeResolver=new m(i,(e,t,s)=>this.onKeyframesResolved(e,t,h,!s),o,l,c),null==(u=this.keyframeResolver)||u.scheduleResolve()}onKeyframesResolved(e,t,s,n){this.keyframeResolver=void 0;const{name:r,type:a,velocity:i,delay:o,isHandoff:l,onUpdate:c}=s;this.resolvedAt=tn.now(),function(e,t,s,n){const r=e[0];if(null===r)return!1;if("display"===t||"visibility"===t)return!0;const a=e[e.length-1],i=ga(r,t),o=ga(a,t);return ms(i===o,`You are trying to animate ${t} from "${r}" to "${a}". "${i?a:r}" is not an animatable value.`,"value-not-animatable"),!(!i||!o)&&(function(e){const t=e[0];if(1===e.length)return!0;for(let s=0;s<e.length;s++)if(e[s]!==t)return!0}(e)||("spring"===s||ua(s))&&n)}(e,r,a,i)||(!fs.instantAnimations&&o||null==c||c(Tr(e,s,t)),e[0]=e[e.length-1],ya(s),s.repeat=0);const d={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...s,keyframes:e},u=!l&&function(e){var t;const{motionValue:s,name:n,repeatDelay:r,repeatType:a,damping:i,type:o}=e;if(!((null==(t=null==s?void 0:s.owner)?void 0:t.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=s.owner.getProps();return va()&&n&&xa.has(n)&&("transform"!==n||!c)&&!l&&!r&&"mirror"!==a&&0!==i&&"inertia"!==o}(d)?new fa({...d,element:d.motionValue.owner.current}):new Dr(d);u.finished.then(()=>this.notifyFinished()).catch(bs),this.pendingTimeline&&(this.stopTimeline=u.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=u}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||(null==(e=this.keyframeResolver)||e.resume(),Zr=!0,ta(),ea(),Zr=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),null==(e=this.keyframeResolver)||e.cancel()}}const wa=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Sa(e,t,s=1){ps(s<=4,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,r]=function(e){const t=wa.exec(e);if(!t)return[,];const[,s,n,r]=t;return[`--${s??n}`,r]}(e);if(!n)return;const a=window.getComputedStyle(t).getPropertyValue(n);if(a){const e=a.trim();return gs(e)?parseFloat(e):e}return an(r)?Sa(r,t,s+1):r}function ja(e,t){return(null==e?void 0:e[t])??(null==e?void 0:e.default)??e}const ka=new Set(["width","height","top","left","right","bottom",...Ur]),Na=e=>t=>t.test(e),Ea=[ln,Sn,wn,bn,kn,jn,{test:e=>"auto"===e,parse:e=>e}],Ca=e=>Ea.find(Na(e));function Ta(e){return"number"==typeof e?0===e:null===e||("none"===e||"0"===e||xs(e))}const Pa=new Set(["brightness","contrast","saturate","opacity"]);function Aa(e){const[t,s]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;const[n]=s.match(hn)||[];if(!n)return e;const r=s.replace(n,"");let a=Pa.has(t)?1:0;return n!==s&&(a*=100),t+"("+a+r+")"}const Ra=/\b([a-z-]*)\(.*?\)/gu,Ma={...Fn,getAnimatableNone:e=>{const t=e.match(Ra);return t?t.map(Aa).join(" "):e}},Da={...ln,transform:Math.round},$a={borderWidth:Sn,borderTopWidth:Sn,borderRightWidth:Sn,borderBottomWidth:Sn,borderLeftWidth:Sn,borderRadius:Sn,radius:Sn,borderTopLeftRadius:Sn,borderTopRightRadius:Sn,borderBottomRightRadius:Sn,borderBottomLeftRadius:Sn,width:Sn,maxWidth:Sn,height:Sn,maxHeight:Sn,top:Sn,right:Sn,bottom:Sn,left:Sn,padding:Sn,paddingTop:Sn,paddingRight:Sn,paddingBottom:Sn,paddingLeft:Sn,margin:Sn,marginTop:Sn,marginRight:Sn,marginBottom:Sn,marginLeft:Sn,backgroundPositionX:Sn,backgroundPositionY:Sn,...{rotate:bn,rotateX:bn,rotateY:bn,rotateZ:bn,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:bn,skewX:bn,skewY:bn,distance:Sn,translateX:Sn,translateY:Sn,translateZ:Sn,x:Sn,y:Sn,z:Sn,perspective:Sn,transformPerspective:Sn,opacity:cn,originX:Nn,originY:Nn,originZ:Sn},zIndex:Da,fillOpacity:cn,strokeOpacity:cn,numOctaves:Da},Oa={...$a,color:Cn,backgroundColor:Cn,outlineColor:Cn,fill:Cn,stroke:Cn,borderColor:Cn,borderTopColor:Cn,borderRightColor:Cn,borderBottomColor:Cn,borderLeftColor:Cn,filter:Ma,WebkitFilter:Ma},Fa=e=>Oa[e];function za(e,t){let s=Fa(e);return s!==Ma&&(s=Fn),s.getAnimatableNone?s.getAnimatableNone(t):void 0}const La=new Set(["auto","none","0"]);class Ia extends sa{constructor(e,t,s,n,r){super(e,t,s,n,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:s}=this;if(!t||!t.current)return;super.readKeyframes();for(let o=0;o<e.length;o++){let s=e[o];if("string"==typeof s&&(s=s.trim(),an(s))){const n=Sa(s,t.current);void 0!==n&&(e[o]=n),o===e.length-1&&(this.finalKeyframe=s)}}if(this.resolveNoneKeyframes(),!ka.has(s)||2!==e.length)return;const[n,r]=e,a=Ca(n),i=Ca(r);if(a!==i)if(Hr(a)&&Hr(i))for(let o=0;o<e.length;o++){const t=e[o];"string"==typeof t&&(e[o]=parseFloat(t))}else Qr[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,s=[];for(let n=0;n<e.length;n++)(null===e[n]||Ta(e[n]))&&s.push(n);s.length&&function(e,t,s){let n,r=0;for(;r<e.length&&!n;){const t=e[r];"string"==typeof t&&!La.has(t)&&Mn(t).values.length&&(n=e[r]),r++}if(n&&s)for(const a of t)e[a]=za(s,n)}(e,s,t)}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:s}=this;if(!e||!e.current)return;"height"===s&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Qr[s](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;const n=t[t.length-1];void 0!==n&&e.getValue(s,n).jump(n,!1)}measureEndState(){var e;const{element:t,name:s,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const r=t.getValue(s);r&&r.jump(this.measuredOrigin,!1);const a=n.length-1,i=n[a];n[a]=Qr[s](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),(null==(e=this.removedTransforms)?void 0:e.length)&&this.removedTransforms.forEach(([e,s])=>{t.getValue(e).set(s)}),this.resolveNoneKeyframes()}}const _a=(e,t)=>t&&"number"==typeof e?t.transform(e):e;function Va(e){return ys(e)&&"offsetHeight"in e}class Ba{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{var t;const s=tn.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(null==(t=this.events.change)||t.notify(this.current),this.dependents))for(const n of this.dependents)n.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=tn.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return"production"!==process.env.NODE_ENV&&Ps(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new ks);const s=this.events[e].add(t);return"change"===e?()=>{s(),Qs.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,s){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;null==(e=this.events.change)||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=tn.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return Cs(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),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 e,t;null==(e=this.dependents)||e.clear(),null==(t=this.events.destroy)||t.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function qa(e,t){return new Ba(e,t)}const{schedule:Ua}=Ys(queueMicrotask,!1),Wa={x:!1,y:!1};function Ha(){return Wa.x||Wa.y}function Ka(e,t){const s=function(e,t,s){if(e instanceof EventTarget)return[e];if("string"==typeof e){let t=document;const n=(null==s?void 0:s[e])??t.querySelectorAll(e);return n?Array.from(n):[]}return Array.from(e)}(e),n=new AbortController;return[s,{passive:!0,...t,signal:n.signal},()=>n.abort()]}function Ya(e){return!("touch"===e.pointerType||Ha())}const Qa=(e,t)=>!!t&&(e===t||Qa(e,t.parentElement)),Ga=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary,Ja=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const Xa=new WeakSet;function Za(e){return t=>{"Enter"===t.key&&e(t)}}function ei(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function ti(e){return Ga(e)&&!Ha()}function si(e,t,s={}){const[n,r,a]=Ka(e,s),i=e=>{const n=e.currentTarget;if(!ti(e))return;Xa.add(n);const a=t(n,e),i=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",l),Xa.has(n)&&Xa.delete(n),ti(e)&&"function"==typeof a&&a(e,{success:t})},o=e=>{i(e,n===window||n===document||s.useGlobalTarget||Qa(n,e.target))},l=e=>{i(e,!1)};window.addEventListener("pointerup",o,r),window.addEventListener("pointercancel",l,r)};return n.forEach(e=>{var t;(s.useGlobalTarget?window:e).addEventListener("pointerdown",i,r),Va(e)&&(e.addEventListener("focus",e=>((e,t)=>{const s=e.currentTarget;if(!s)return;const n=Za(()=>{if(Xa.has(s))return;ei(s,"down");const e=Za(()=>{ei(s,"up")});s.addEventListener("keyup",e,t),s.addEventListener("blur",()=>ei(s,"cancel"),t)});s.addEventListener("keydown",n,t),s.addEventListener("blur",()=>s.removeEventListener("keydown",n),t)})(e,r)),t=e,Ja.has(t.tagName)||-1!==t.tabIndex||e.hasAttribute("tabindex")||(e.tabIndex=0))}),a}function ni(e){return ys(e)&&"ownerSVGElement"in e}const ri=e=>Boolean(e&&e.getVelocity),ai=[...Ea,Cn,Fn],ii=Oe.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function oi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function li(...e){return Le.useCallback(function(...e){return t=>{let s=!1;const n=e.map(e=>{const n=oi(e,t);return s||"function"!=typeof n||(s=!0),n});if(s)return()=>{for(let t=0;t<n.length;t++){const s=n[t];"function"==typeof s?s():oi(e[t],null)}}}}(...e),e)}class ci extends Le.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const e=t.offsetParent,s=Va(e)&&e.offsetWidth||0,n=this.props.sizeRef.current;n.height=t.offsetHeight||0,n.width=t.offsetWidth||0,n.top=t.offsetTop,n.left=t.offsetLeft,n.right=s-n.width-n.left}return null}componentDidUpdate(){}render(){return this.props.children}}function di({children:e,isPresent:t,anchorX:s,root:n}){const r=Oe.useId(),a=Oe.useRef(null),i=Oe.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:o}=Oe.useContext(ii),l=li(a,null==e?void 0:e.ref);return Oe.useInsertionEffect(()=>{const{width:e,height:l,top:c,left:d,right:u}=i.current;if(t||!a.current||!e||!l)return;const h="left"===s?`left: ${d}`:`right: ${u}`;a.current.dataset.motionPopId=r;const m=document.createElement("style");o&&(m.nonce=o);const p=n??document.head;return p.appendChild(m),m.sheet&&m.sheet.insertRule(`\n [data-motion-pop-id="${r}"] {\n position: absolute !important;\n width: ${e}px !important;\n height: ${l}px !important;\n ${h}px !important;\n top: ${c}px !important;\n }\n `),()=>{p.contains(m)&&p.removeChild(m)}},[t]),$e.jsx(ci,{isPresent:t,childRef:a,sizeRef:i,children:Le.cloneElement(e,{ref:l})})}const ui=({children:e,initial:t,isPresent:s,onExitComplete:n,custom:r,presenceAffectsLayout:a,mode:i,anchorX:o,root:l})=>{const c=as(hi),d=Oe.useId();let u=!0,h=Oe.useMemo(()=>(u=!1,{id:d,initial:t,isPresent:s,custom:r,onExitComplete:e=>{c.set(e,!0);for(const t of c.values())if(!t)return;n&&n()},register:e=>(c.set(e,!1),()=>c.delete(e))}),[s,c,n]);return a&&u&&(h={...h}),Oe.useMemo(()=>{c.forEach((e,t)=>c.set(t,!1))},[s]),Le.useEffect(()=>{!s&&!c.size&&n&&n()},[s]),"popLayout"===i&&(e=$e.jsx(di,{isPresent:s,anchorX:o,root:l,children:e})),$e.jsx(ls.Provider,{value:h,children:e})};function hi(){return new Map}function mi(e=!0){const t=Oe.useContext(ls);if(null===t)return[!0,null];const{isPresent:s,onExitComplete:n,register:r}=t,a=Oe.useId();Oe.useEffect(()=>{if(e)return r(a)},[e]);const i=Oe.useCallback(()=>e&&n&&n(a),[a,n,e]);return!s&&n?[!1,i]:[!0]}const pi=e=>e.key||"";function fi(e){const t=[];return Oe.Children.forEach(e,e=>{Oe.isValidElement(e)&&t.push(e)}),t}const gi=({children:e,custom:t,initial:s=!0,onExitComplete:n,presenceAffectsLayout:r=!0,mode:a="sync",propagate:i=!1,anchorX:o="left",root:l})=>{const[c,d]=mi(i),u=Oe.useMemo(()=>fi(e),[e]),h=i&&!c?[]:u.map(pi),m=Oe.useRef(!0),p=Oe.useRef(u),f=as(()=>new Map),[g,y]=Oe.useState(u),[x,v]=Oe.useState(u);os(()=>{m.current=!1,p.current=u;for(let e=0;e<x.length;e++){const t=pi(x[e]);h.includes(t)?f.delete(t):!0!==f.get(t)&&f.set(t,!1)}},[x,h.length,h.join("-")]);const b=[];if(u!==g){let e=[...u];for(let t=0;t<x.length;t++){const s=x[t],n=pi(s);h.includes(n)||(e.splice(t,0,s),b.push(s))}return"wait"===a&&b.length&&(e=b),v(fi(e)),y(u),null}"production"!==process.env.NODE_ENV&&"wait"===a&&x.length>1&&console.warn('You\'re attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.');const{forceRender:w}=Oe.useContext(rs);return $e.jsx($e.Fragment,{children:x.map(e=>{const g=pi(e),y=!(i&&!c)&&(u===x||h.includes(g));return $e.jsx(ui,{isPresent:y,initial:!(m.current&&!s)&&void 0,custom:t,presenceAffectsLayout:r,mode:a,root:l,onExitComplete:y?void 0:()=>{if(!f.has(g))return;f.set(g,!0);let e=!0;f.forEach(t=>{t||(e=!1)}),e&&(null==w||w(),v(p.current),i&&(null==d||d()),n&&n())},anchorX:o,children:e},g)})})},yi=Oe.createContext({strict:!1}),xi={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"]},vi={};for(const zv in xi)vi[zv]={isEnabled:e=>xi[zv].some(t=>!!e[t])};const bi=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","ignoreStrict","viewport"]);function wi(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||bi.has(e)}let Si=e=>!wi(e);try{"function"==typeof(ji=require("@emotion/is-prop-valid").default)&&(Si=e=>e.startsWith("on")?!wi(e):ji(e))}catch{}var ji;const ki=Oe.createContext({});function Ni(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function Ei(e){return"string"==typeof e||Array.isArray(e)}const Ci=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ti=["initial",...Ci];function Pi(e){return Ni(e.animate)||Ti.some(t=>Ei(e[t]))}function Ai(e){return Boolean(Pi(e)||e.variants)}function Ri(e){const{initial:t,animate:s}=function(e,t){if(Pi(e)){const{initial:t,animate:s}=e;return{initial:!1===t||Ei(t)?t:void 0,animate:Ei(s)?s:void 0}}return!1!==e.inherit?t:{}}(e,Oe.useContext(ki));return Oe.useMemo(()=>({initial:t,animate:s}),[Mi(t),Mi(s)])}function Mi(e){return Array.isArray(e)?e.join(" "):e}const Di={};function $i(e,{layout:t,layoutId:s}){return Wr.has(e)||e.startsWith("origin")||(t||void 0!==s)&&(!!Di[e]||"opacity"===e)}const Oi={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Fi=Ur.length;function zi(e,t,s){const{style:n,vars:r,transformOrigin:a}=e;let i=!1,o=!1;for(const l in t){const e=t[l];if(Wr.has(l))i=!0;else if(nn(l))r[l]=e;else{const t=_a(e,$a[l]);l.startsWith("origin")?(o=!0,a[l]=t):n[l]=t}}if(t.transform||(i||s?n.transform=function(e,t,s){let n="",r=!0;for(let a=0;a<Fi;a++){const i=Ur[a],o=e[i];if(void 0===o)continue;let l=!0;if(l="number"==typeof o?o===(i.startsWith("scale")?1:0):0===parseFloat(o),!l||s){const e=_a(o,$a[i]);l||(r=!1,n+=`${Oi[i]||i}(${e}) `),s&&(t[i]=e)}}return n=n.trim(),s?n=s(t,r?"":n):r&&(n="none"),n}(t,e.transform,s):n.transform&&(n.transform="none")),o){const{originX:e="50%",originY:t="50%",originZ:s=0}=a;n.transformOrigin=`${e} ${t} ${s}`}}const Li=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ii(e,t,s){for(const n in t)ri(t[n])||$i(n,s)||(e[n]=t[n])}function _i(e,t){const s={};return Ii(s,e.style||{},e),Object.assign(s,function({transformTemplate:e},t){return Oe.useMemo(()=>{const s={style:{},transform:{},transformOrigin:{},vars:{}};return zi(s,t,e),Object.assign({},s.vars,s.style)},[t])}(e,t)),s}function Vi(e,t){const s={},n=_i(e,t);return e.drag&&!1!==e.dragListener&&(s.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=!0===e.drag?"none":"pan-"+("x"===e.drag?"y":"x")),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=n,s}const Bi={offset:"stroke-dashoffset",array:"stroke-dasharray"},qi={offset:"strokeDashoffset",array:"strokeDasharray"};function Ui(e,{attrX:t,attrY:s,attrScale:n,pathLength:r,pathSpacing:a=1,pathOffset:i=0,...o},l,c,d){if(zi(e,o,c),l)return void(e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox));e.attrs=e.style,e.style={};const{attrs:u,style:h}=e;u.transform&&(h.transform=u.transform,delete u.transform),(h.transform||u.transformOrigin)&&(h.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),h.transform&&(h.transformBox=(null==d?void 0:d.transformBox)??"fill-box",delete u.transformBox),void 0!==t&&(u.x=t),void 0!==s&&(u.y=s),void 0!==n&&(u.scale=n),void 0!==r&&function(e,t,s=1,n=0,r=!0){e.pathLength=1;const a=r?Bi:qi;e[a.offset]=Sn.transform(-n);const i=Sn.transform(t),o=Sn.transform(s);e[a.array]=`${i} ${o}`}(u,r,a,i,!1)}const Wi=()=>({style:{},transform:{},transformOrigin:{},vars:{},attrs:{}}),Hi=e=>"string"==typeof e&&"svg"===e.toLowerCase();function Ki(e,t,s,n){const r=Oe.useMemo(()=>{const s={style:{},transform:{},transformOrigin:{},vars:{},attrs:{}};return Ui(s,t,Hi(n),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const t={};Ii(t,e.style,e),r.style={...t,...r.style}}return r}const Yi=["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 Qi(e){return"string"==typeof e&&!e.includes("-")&&!!(Yi.indexOf(e)>-1||/[A-Z]/u.test(e))}function Gi(e,t,s,{latestValues:n},r,a=!1){const i=(Qi(e)?Ki:Vi)(t,n,r,e),o=function(e,t,s){const n={};for(const r in e)"values"===r&&"object"==typeof e.values||(Si(r)||!0===s&&wi(r)||!t&&!wi(r)||e.draggable&&r.startsWith("onDrag"))&&(n[r]=e[r]);return n}(t,"string"==typeof e,a),l=e!==Oe.Fragment?{...o,...i,ref:s}:{},{children:c}=t,d=Oe.useMemo(()=>ri(c)?c.get():c,[c]);return Oe.createElement(e,{...l,children:d})}function Ji(e){const t=[{},{}];return null==e||e.values.forEach((e,s)=>{t[0][s]=e.get(),t[1][s]=e.getVelocity()}),t}function Xi(e,t,s,n){if("function"==typeof t){const[r,a]=Ji(n);t=t(void 0!==s?s:e.custom,r,a)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){const[r,a]=Ji(n);t=t(void 0!==s?s:e.custom,r,a)}return t}function Zi(e){return ri(e)?e.get():e}function eo(e,t,s,n){const r={},a=n(e,{});for(const h in a)r[h]=Zi(a[h]);let{initial:i,animate:o}=e;const l=Pi(e),c=Ai(e);t&&c&&!l&&!1!==e.inherit&&(void 0===i&&(i=t.initial),void 0===o&&(o=t.animate));let d=!!s&&!1===s.initial;d=d||!1===i;const u=d?o:i;if(u&&"boolean"!=typeof u&&!Ni(u)){const t=Array.isArray(u)?u:[u];for(let s=0;s<t.length;s++){const n=Xi(e,t[s]);if(n){const{transitionEnd:e,transition:t,...s}=n;for(const n in s){let e=s[n];if(Array.isArray(e)){e=e[d?e.length-1:0]}null!==e&&(r[n]=e)}for(const n in e)r[n]=e[n]}}}return r}const to=e=>(t,s)=>{const n=Oe.useContext(ki),r=Oe.useContext(ls),a=()=>function({scrapeMotionValuesFromProps:e,createRenderState:t},s,n,r){return{latestValues:eo(s,n,r,e),renderState:t()}}(e,t,n,r);return s?a():as(a)};function so(e,t,s){var n;const{style:r}=e,a={};for(const i in r)(ri(r[i])||t.style&&ri(t.style[i])||$i(i,e)||void 0!==(null==(n=null==s?void 0:s.getValue(i))?void 0:n.liveStyle))&&(a[i]=r[i]);return a}const no=to({scrapeMotionValuesFromProps:so,createRenderState:Li});function ro(e,t,s){const n=so(e,t,s);for(const r in e)if(ri(e[r])||ri(t[r])){n[-1!==Ur.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]}return n}const ao=to({scrapeMotionValuesFromProps:ro,createRenderState:Wi}),io=Symbol.for("motionComponentSymbol");function oo(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}function lo(e,t,s){return Oe.useCallback(n=>{n&&e.onMount&&e.onMount(n),t&&(n?t.mount(n):t.unmount()),s&&("function"==typeof s?s(n):oo(s)&&(s.current=n))},[t])}const co=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uo="data-"+co("framerAppearId"),ho=Oe.createContext({});function mo(e,t,s,n,r){var a,i;const{visualElement:o}=Oe.useContext(ki),l=Oe.useContext(yi),c=Oe.useContext(ls),d=Oe.useContext(ii).reducedMotion,u=Oe.useRef(null);n=n||l.renderer,!u.current&&n&&(u.current=n(e,{visualState:t,parent:o,props:s,presenceContext:c,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:d}));const h=u.current,m=Oe.useContext(ho);!h||h.projection||!r||"html"!==h.type&&"svg"!==h.type||function(e,t,s,n){const{layoutId:r,layout:a,drag:i,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutCrossfade:d}=t;e.projection=new s(e.latestValues,t["data-framer-portal-id"]?void 0:po(e.parent)),e.projection.setOptions({layoutId:r,layout:a,alwaysMeasureLayout:Boolean(i)||o&&oo(o),visualElement:e,animationType:"string"==typeof a?a:"both",initialPromotionConfig:n,crossfade:d,layoutScroll:l,layoutRoot:c})}(u.current,s,r,m);const p=Oe.useRef(!1);Oe.useInsertionEffect(()=>{h&&p.current&&h.update(s,c)});const f=s[uo],g=Oe.useRef(Boolean(f)&&!(null==(a=window.MotionHandoffIsComplete)?void 0:a.call(window,f))&&(null==(i=window.MotionHasOptimisedAnimation)?void 0:i.call(window,f)));return os(()=>{h&&(p.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),g.current&&h.animationState&&h.animationState.animateChanges())}),Oe.useEffect(()=>{h&&(!g.current&&h.animationState&&h.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var e;null==(e=window.MotionHandoffMarkAsComplete)||e.call(window,f)}),g.current=!1),h.enteringChildren=void 0)}),h}function po(e){if(e)return!1!==e.options.allowProjection?e.projection:po(e.parent)}function fo(e,{forwardMotionProps:t=!1}={},s,n){s&&function(e){for(const t in e)vi[t]={...vi[t],...e[t]}}(s);const r=Qi(e)?ao:no;function a(a,i){let o;const l={...Oe.useContext(ii),...a,layoutId:go(a)},{isStatic:c}=l,d=Ri(a),u=r(a,c);if(!c&&is){!function(e,t){const s=Oe.useContext(yi).strict;if("production"!==process.env.NODE_ENV&&t&&s){const t="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?ms(!1,t,"lazy-strict-mode"):ps(!1,t,"lazy-strict-mode")}}(l,s);const t=function(e){const{drag:t,layout:s}=vi;if(!t&&!s)return{};const n={...t,...s};return{MeasureLayout:(null==t?void 0:t.isEnabled(e))||(null==s?void 0:s.isEnabled(e))?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(l);o=t.MeasureLayout,d.visualElement=mo(e,u,l,n,t.ProjectionNode)}return $e.jsxs(ki.Provider,{value:d,children:[o&&d.visualElement?$e.jsx(o,{visualElement:d.visualElement,...l}):null,Gi(e,a,lo(u,d.visualElement,i),u,c,t)]})}a.displayName=`motion.${"string"==typeof e?e:`create(${e.displayName??e.name??""})`}`;const i=Oe.forwardRef(a);return i[io]=e,i}function go({layoutId:e}){const t=Oe.useContext(rs).id;return t&&void 0!==e?t+"-"+e:e}function yo(e,t){if("undefined"==typeof Proxy)return fo;const s=new Map,n=(s,n)=>fo(s,n,e,t);return new Proxy((e,t)=>("production"!==process.env.NODE_ENV&&Ps(!1,"motion() is deprecated. Use motion.create() instead."),n(e,t)),{get:(r,a)=>"create"===a?n:(s.has(a)||s.set(a,fo(a,void 0,e,t)),s.get(a))})}function xo({top:e,left:t,right:s,bottom:n}){return{x:{min:t,max:s},y:{min:e,max:n}}}function vo(e){return void 0===e||1===e}function bo({scale:e,scaleX:t,scaleY:s}){return!vo(e)||!vo(t)||!vo(s)}function wo(e){return bo(e)||So(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function So(e){return jo(e.x)||jo(e.y)}function jo(e){return e&&"0%"!==e}function ko(e,t,s){return s+t*(e-s)}function No(e,t,s,n,r){return void 0!==r&&(e=ko(e,r,n)),ko(e,s,n)+t}function Eo(e,t=0,s=1,n,r){e.min=No(e.min,t,s,n,r),e.max=No(e.max,t,s,n,r)}function Co(e,{x:t,y:s}){Eo(e.x,t.translate,t.scale,t.originPoint),Eo(e.y,s.translate,s.scale,s.originPoint)}const To=.999999999999,Po=1.0000000000001;function Ao(e,t){e.min=e.min+t,e.max=e.max+t}function Ro(e,t,s,n,r=.5){Eo(e,t,s,In(e.min,e.max,r),n)}function Mo(e,t){Ro(e.x,t.x,t.scaleX,t.scale,t.originX),Ro(e.y,t.y,t.scaleY,t.scale,t.originY)}function Do(e,t){return xo(function(e,t){if(!t)return e;const s=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:s.y,left:s.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),t))}const $o=()=>({x:{min:0,max:0},y:{min:0,max:0}}),Oo={current:null},Fo={current:!1};const zo=new WeakMap;const Lo=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Io{scrapeMotionValuesFromProps(e,t,s){return{}}constructor({parent:e,props:t,presenceContext:s,reducedMotionConfig:n,blockInitialAnimation:r,visualState:a},i={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=sa,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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 e=tn.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Qs.render(this.render,!1,!0))};const{latestValues:o,renderState:l}=a;this.latestValues=o,this.baseTarget={...o},this.initialValues=t.initial?{...o}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=n,this.options=i,this.blockInitialAnimation=Boolean(r),this.isControllingVariants=Pi(t),this.isVariantNode=Ai(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(const u in d){const e=d[u];void 0!==o[u]&&ri(e)&&e.set(o[u])}}mount(e){var t;this.current=e,zo.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),Fo.current||function(){if(Fo.current=!0,is)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Oo.current=e.matches;e.addEventListener("change",t),t()}else Oo.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Oo.current),"production"!==process.env.NODE_ENV&&Ps(!0!==this.shouldReduceMotion,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),null==(t=this.parent)||t.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Gs(this.notifyUpdate),Gs(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),null==(e=this.parent)||e.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Wr.has(e);s&&this.onBindTransform&&this.onBindTransform();const n=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&Qs.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{n(),r&&r(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in vi){const t=vi[e];if(!t)continue;const{isEnabled:s,Feature:n}=t;if(!this.features[e]&&n&&s(this.props)&&(this.features[e]=new n(this)),this.features[e]){const t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let s=0;s<Lo.length;s++){const t=Lo[s];this.propEventSubscriptions[t]&&(this.propEventSubscriptions[t](),delete this.propEventSubscriptions[t]);const n=e["on"+t];n&&(this.propEventSubscriptions[t]=this.on(t,n))}this.prevMotionValues=function(e,t,s){for(const n in t){const r=t[n],a=s[n];if(ri(r))e.addValue(n,r);else if(ri(a))e.addValue(n,qa(r,{owner:e}));else if(a!==r)if(e.hasValue(n)){const t=e.getValue(n);!0===t.liveStyle?t.jump(r):t.hasAnimated||t.set(r)}else{const t=e.getStaticValue(n);e.addValue(n,qa(void 0!==t?t:r,{owner:e}))}}for(const n in s)void 0===t[n]&&e.removeValue(n);return t}(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){const s=this.values.get(e);t!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return void 0===s&&void 0!==t&&(s=qa(null===t?void 0:t,{owner:this}),this.addValue(e,s)),s}readValue(e,t){let s=void 0===this.latestValues[e]&&this.current?this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];var n;return null!=s&&("string"==typeof s&&(gs(s)||xs(s))?s=parseFloat(s):(n=s,!ai.find(Na(n))&&Fn.test(t)&&(s=za(e,t))),this.setBaseTarget(e,ri(s)?s.get():s)),ri(s)?s.get():s}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:s}=this.props;let n;if("string"==typeof s||"object"==typeof s){const r=Xi(this.props,s,null==(t=this.presenceContext)?void 0:t.custom);r&&(n=r[e])}if(s&&void 0!==n)return n;const r=this.getBaseTargetFromProps(this.props,e);return void 0===r||ri(r)?void 0!==this.initialValues[e]&&void 0===n?void 0:this.baseTarget[e]:r}on(e,t){return this.events[e]||(this.events[e]=new ks),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Ua.render(this.render)}}class _o extends Io{constructor(){super(...arguments),this.KeyframeResolver=Ia}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:s}){delete t[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;ri(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}function Vo(e,{style:t,vars:s},n,r){const a=e.style;let i;for(i in t)a[i]=t[i];for(i in null==r||r.applyProjectionStyles(a,n),s)a.setProperty(i,s[i])}class Bo extends _o{constructor(){super(...arguments),this.type="html",this.renderInstance=Vo}readValueFromInstance(e,t){var s,n;if(Wr.has(t))return(null==(s=this.projection)?void 0:s.isProjecting)?Vr(t):((e,t)=>{const{transform:s="none"}=getComputedStyle(e);return Br(s,t)})(e,t);{const s=(n=e,window.getComputedStyle(n)),r=(nn(t)?s.getPropertyValue(t):s[t])||0;return"string"==typeof r?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Do(e,t)}build(e,t,s){zi(e,t,s.transformTemplate)}scrapeMotionValuesFromProps(e,t,s){return so(e,t,s)}}const qo=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"]);class Uo extends _o{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=$o}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Wr.has(t)){const e=Fa(t);return e&&e.default||0}return t=qo.has(t)?t:co(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,s){return ro(e,t,s)}build(e,t,s){Ui(e,t,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,t,s,n){!function(e,t,s,n){Vo(e,t,void 0,n);for(const r in t.attrs)e.setAttribute(qo.has(r)?r:co(r),t.attrs[r])}(e,t,0,n)}mount(e){this.isSVGTag=Hi(e.tagName),super.mount(e)}}const Wo=(e,t)=>Qi(e)?new Uo(t):new Bo(t,{allowProjection:e!==Oe.Fragment});function Ho(e,t,s){const n=e.getProps();return Xi(n,t,void 0!==s?s:n.custom,e)}const Ko=e=>Array.isArray(e);function Yo(e,t,s){e.hasValue(t)?e.getValue(t).set(s):e.addValue(t,qa(s))}function Qo(e){return Ko(e)?e[e.length-1]||0:e}function Go(e,t){const s=e.getValue("willChange");if(n=s,Boolean(ri(n)&&n.add))return s.add(t);if(!s&&fs.WillChange){const s=new fs.WillChange("auto");e.addValue("willChange",s),s.add(t)}var n}function Jo(e){return e.props[uo]}const Xo=e=>null!==e;const Zo={type:"spring",stiffness:500,damping:25,restSpeed:10},el={type:"keyframes",duration:.8},tl={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},sl=(e,{keyframes:t})=>t.length>2?el:Wr.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===t[1]?2*Math.sqrt(550):30,restSpeed:10}:Zo:tl;const nl=(e,t,s,n={},r,a)=>i=>{const o=ja(n,e)||{},l=o.delay||n.delay||0;let{elapsed:c=0}=n;c-=Ns(l);const d={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{i(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:a?void 0:r};(function({when:e,delay:t,delayChildren:s,staggerChildren:n,staggerDirection:r,repeat:a,repeatType:i,repeatDelay:o,from:l,elapsed:c,...d}){return!!Object.keys(d).length})(o)||Object.assign(d,sl(e,d)),d.duration&&(d.duration=Ns(d.duration)),d.repeatDelay&&(d.repeatDelay=Ns(d.repeatDelay)),void 0!==d.from&&(d.keyframes[0]=d.from);let u=!1;if((!1===d.type||0===d.duration&&!d.repeatDelay)&&(ya(d),0===d.delay&&(u=!0)),(fs.instantAnimations||fs.skipAnimations)&&(u=!0,ya(d),d.delay=0),d.allowFlatten=!o.type&&!o.ease,u&&!a&&void 0!==t.get()){const e=function(e,{repeat:t,repeatType:s="loop"}){const n=e.filter(Xo);return n[t&&"loop"!==s&&t%2==1?0:n.length-1]}(d.keyframes,o);if(void 0!==e)return void Qs.update(()=>{d.onUpdate(e),d.onComplete()})}return o.isSync?new Dr(d):new ba(d)};function rl({protectedKeys:e,needsAnimating:t},s){const n=e.hasOwnProperty(s)&&!0!==t[s];return t[s]=!1,n}function al(e,t,{delay:s=0,transitionOverride:n,type:r}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:i,...o}=t;n&&(a=n);const l=[],c=r&&e.animationState&&e.animationState.getState()[r];for(const d in o){const t=e.getValue(d,e.latestValues[d]??null),n=o[d];if(void 0===n||c&&rl(c,d))continue;const r={delay:s,...ja(a||{},d)},i=t.get();if(void 0!==i&&!t.isAnimating&&!Array.isArray(n)&&n===i&&!r.velocity)continue;let u=!1;if(window.MotionHandoffAnimation){const t=Jo(e);if(t){const e=window.MotionHandoffAnimation(t,d,Qs);null!==e&&(r.startTime=e,u=!0)}}Go(e,d),t.start(nl(d,t,n,e.shouldReduceMotion&&ka.has(d)?{type:!1}:r,e,u));const h=t.animation;h&&l.push(h)}return i&&Promise.all(l).then(()=>{Qs.update(()=>{i&&function(e,t){const s=Ho(e,t);let{transitionEnd:n={},transition:r={},...a}=s||{};a={...a,...n};for(const i in a)Yo(e,i,Qo(a[i]))}(e,i)})}),l}function il(e,t,s,n=0,r=1){const a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),i=e.size,o=(i-1)*n;return"function"==typeof s?s(a,i):1===r?a*n:o-a*n}function ol(e,t,s={}){var n;const r=Ho(e,t,"exit"===s.type?null==(n=e.presenceContext)?void 0:n.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=r||{};s.transitionOverride&&(a=s.transitionOverride);const i=r?()=>Promise.all(al(e,r,s)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(n=0)=>{const{delayChildren:r=0,staggerChildren:i,staggerDirection:o}=a;return function(e,t,s=0,n=0,r=0,a=1,i){const o=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),o.push(ol(l,t,{...i,delay:s+("function"==typeof n?0:n)+il(e.variantChildren,l,n,r,a)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}(e,t,n,r,i,o,s)}:()=>Promise.resolve(),{when:l}=a;if(l){const[e,t]="beforeChildren"===l?[i,o]:[o,i];return e().then(()=>t())}return Promise.all([i(),o(s.delay)])}function ll(e,t){if(!Array.isArray(t))return!1;const s=t.length;if(s!==e.length)return!1;for(let n=0;n<s;n++)if(t[n]!==e[n])return!1;return!0}const cl=Ti.length;function dl(e){if(!e)return;if(!e.isControllingVariants){const t=e.parent&&dl(e.parent)||{};return void 0!==e.props.initial&&(t.initial=e.props.initial),t}const t={};for(let s=0;s<cl;s++){const n=Ti[s],r=e.props[n];(Ei(r)||!1===r)&&(t[n]=r)}return t}const ul=[...Ci].reverse(),hl=Ci.length;function ml(e){return t=>Promise.all(t.map(({animation:t,options:s})=>function(e,t,s={}){let n;if(e.notify("AnimationStart",t),Array.isArray(t)){const r=t.map(t=>ol(e,t,s));n=Promise.all(r)}else if("string"==typeof t)n=ol(e,t,s);else{const r="function"==typeof t?Ho(e,t,s.custom):t;n=Promise.all(al(e,r,s))}return n.then(()=>{e.notify("AnimationComplete",t)})}(e,t,s)))}function pl(e){let t=ml(e),s=yl(),n=!0;const r=t=>(s,n)=>{var r;const a=Ho(e,n,"exit"===t?null==(r=e.presenceContext)?void 0:r.custom:void 0);if(a){const{transition:e,transitionEnd:t,...n}=a;s={...s,...n,...t}}return s};function a(a){const{props:i}=e,o=dl(e.parent)||{},l=[],c=new Set;let d={},u=1/0;for(let t=0;t<hl;t++){const h=ul[t],m=s[h],p=void 0!==i[h]?i[h]:o[h],f=Ei(p),g=h===a?m.isActive:null;!1===g&&(u=t);let y=p===o[h]&&p!==i[h]&&f;if(y&&n&&e.manuallyAnimateOnMount&&(y=!1),m.protectedKeys={...d},!m.isActive&&null===g||!p&&!m.prevProp||Ni(p)||"boolean"==typeof p)continue;const x=fl(m.prevProp,p);let v=x||h===a&&m.isActive&&!y&&f||t>u&&f,b=!1;const w=Array.isArray(p)?p:[p];let S=w.reduce(r(h),{});!1===g&&(S={});const{prevResolvedValues:j={}}=m,k={...j,...S},N=t=>{v=!0,c.has(t)&&(b=!0,c.delete(t)),m.needsAnimating[t]=!0;const s=e.getValue(t);s&&(s.liveStyle=!1)};for(const e in k){const t=S[e],s=j[e];if(d.hasOwnProperty(e))continue;let n=!1;n=Ko(t)&&Ko(s)?!ll(t,s):t!==s,n?null!=t?N(e):c.add(e):void 0!==t&&c.has(e)?N(e):m.protectedKeys[e]=!0}m.prevProp=p,m.prevResolvedValues=S,m.isActive&&(d={...d,...S}),n&&e.blockInitialAnimation&&(v=!1);const E=y&&x;v&&(!E||b)&&l.push(...w.map(t=>{const s={type:h};if("string"==typeof t&&n&&!E&&e.manuallyAnimateOnMount&&e.parent){const{parent:n}=e,r=Ho(n,t);if(n.enteringChildren&&r){const{delayChildren:t}=r.transition||{};s.delay=il(n.enteringChildren,e,t)}}return{animation:t,options:s}}))}if(c.size){const t={};if("boolean"!=typeof i.initial){const s=Ho(e,Array.isArray(i.initial)?i.initial[0]:i.initial);s&&s.transition&&(t.transition=s.transition)}c.forEach(s=>{const n=e.getBaseTarget(s),r=e.getValue(s);r&&(r.liveStyle=!0),t[s]=n??null}),l.push({animation:t})}let h=Boolean(l.length);return!n||!1!==i.initial&&i.initial!==i.animate||e.manuallyAnimateOnMount||(h=!1),n=!1,h?t(l):Promise.resolve()}return{animateChanges:a,setActive:function(t,n){var r;if(s[t].isActive===n)return Promise.resolve();null==(r=e.variantChildren)||r.forEach(e=>{var s;return null==(s=e.animationState)?void 0:s.setActive(t,n)}),s[t].isActive=n;const i=a(t);for(const e in s)s[e].protectedKeys={};return i},setAnimateFunction:function(s){t=s(e)},getState:()=>s,reset:()=>{s=yl()}}}function fl(e,t){return"string"==typeof t?t!==e:!!Array.isArray(t)&&!ll(t,e)}function gl(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function yl(){return{animate:gl(!0),whileInView:gl(),whileHover:gl(),whileTap:gl(),whileDrag:gl(),whileFocus:gl(),exit:gl()}}class xl{constructor(e){this.isMounted=!1,this.node=e}update(){}}let vl=0;const bl={animation:{Feature:class extends xl{constructor(e){super(e),e.animationState||(e.animationState=pl(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Ni(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),null==(e=this.unmountControls)||e.call(this)}}},exit:{Feature:class extends xl{constructor(){super(...arguments),this.id=vl++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const n=this.node.animationState.setActive("exit",!e);t&&!e&&n.then(()=>{t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wl(e,t,s,n={passive:!0}){return e.addEventListener(t,s,n),()=>e.removeEventListener(t,s)}function Sl(e){return{point:{x:e.pageX,y:e.pageY}}}function jl(e,t,s,n){return wl(e,t,(e=>t=>Ga(t)&&e(t,Sl(t)))(s),n)}function kl(e){return e.max-e.min}function Nl(e,t,s,n=.5){e.origin=n,e.originPoint=In(t.min,t.max,e.origin),e.scale=kl(s)/kl(t),e.translate=In(s.min,s.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function El(e,t,s,n){Nl(e.x,t.x,s.x,n?n.originX:void 0),Nl(e.y,t.y,s.y,n?n.originY:void 0)}function Cl(e,t,s){e.min=s.min+t.min,e.max=e.min+kl(t)}function Tl(e,t,s){e.min=t.min-s.min,e.max=e.min+kl(t)}function Pl(e,t,s){Tl(e.x,t.x,s.x),Tl(e.y,t.y,s.y)}function Al(e){return[e("x"),e("y")]}const Rl=({current:e})=>e?e.ownerDocument.defaultView:null,Ml=(e,t)=>Math.abs(e-t);class Dl{constructor(e,t,{transformPagePoint:s,contextWindow:n=window,dragSnapToOrigin:r=!1,distanceThreshold:a=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const e=Fl(this.lastMoveEventInfo,this.history),t=null!==this.startEvent,s=function(e,t){const s=Ml(e.x,t.x),n=Ml(e.y,t.y);return Math.sqrt(s**2+n**2)}(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!s)return;const{point:n}=e,{timestamp:r}=Js;this.history.push({...n,timestamp:r});const{onStart:a,onMove:i}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),i&&i(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=$l(t,this.transformPagePoint),Qs.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();const{onEnd:s,onSessionEnd:n,resumeAnimation:r}=this.handlers;if(this.dragSnapToOrigin&&r&&r(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const a=Fl("pointercancel"===e.type?this.lastMoveEventInfo:$l(t,this.transformPagePoint),this.history);this.startEvent&&s&&s(e,a),n&&n(e,a)},!Ga(e))return;this.dragSnapToOrigin=r,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=n||window;const i=$l(Sl(e),this.transformPagePoint),{point:o}=i,{timestamp:l}=Js;this.history=[{...o,timestamp:l}];const{onSessionStart:c}=t;c&&c(e,Fl(i,this.history)),this.removeListeners=Ss(jl(this.contextWindow,"pointermove",this.handlePointerMove),jl(this.contextWindow,"pointerup",this.handlePointerUp),jl(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Gs(this.updatePoint)}}function $l(e,t){return t?{point:t(e.point)}:e}function Ol(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Fl({point:e},t){return{point:e,delta:Ol(e,Ll(t)),offset:Ol(e,zl(t)),velocity:Il(t,.1)}}function zl(e){return e[0]}function Ll(e){return e[e.length-1]}function Il(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const r=Ll(e);for(;s>=0&&(n=e[s],!(r.timestamp-n.timestamp>Ns(t)));)s--;if(!n)return{x:0,y:0};const a=Es(r.timestamp-n.timestamp);if(0===a)return{x:0,y:0};const i={x:(r.x-n.x)/a,y:(r.y-n.y)/a};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function _l(e,t,s){return{min:void 0!==t?e.min+t:void 0,max:void 0!==s?e.max+s-(e.max-e.min):void 0}}function Vl(e,t){let s=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([s,n]=[n,s]),{min:s,max:n}}const Bl=.35;function ql(e,t,s){return{min:Ul(e,t),max:Ul(e,s)}}function Ul(e,t){return"number"==typeof e?e:e[t]||0}const Wl=new WeakMap;class Hl{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;const{dragSnapToOrigin:r}=this.getProps();this.panSession=new Dl(e,{onSessionStart:e=>{const{dragSnapToOrigin:s}=this.getProps();s?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(Sl(e).point)},onStart:(e,t)=>{const{drag:s,dragPropagation:n,onDragStart:r}=this.getProps();if(s&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(a=s)||"y"===a?Wa[a]?null:(Wa[a]=!0,()=>{Wa[a]=!1}):Wa.x||Wa.y?null:(Wa.x=Wa.y=!0,()=>{Wa.x=Wa.y=!1}),!this.openDragLock))return;var a;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Al(e=>{let t=this.getAxisMotionValue(e).get()||0;if(wn.test(t)){const{projection:s}=this.visualElement;if(s&&s.layout){const n=s.layout.layoutBox[e];if(n){t=kl(n)*(parseFloat(t)/100)}}}this.originPoint[e]=t}),r&&Qs.postRender(()=>r(e,t)),Go(this.visualElement,"transform");const{animationState:i}=this.visualElement;i&&i.setActive("whileDrag",!0)},onMove:(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;const{dragPropagation:s,dragDirectionLock:n,onDirectionLock:r,onDrag:a}=this.getProps();if(!s&&!this.openDragLock)return;const{offset:i}=t;if(n&&null===this.currentDirection)return this.currentDirection=function(e,t=10){let s=null;Math.abs(e.y)>t?s="y":Math.abs(e.x)>t&&(s="x");return s}(i),void(null!==this.currentDirection&&r&&r(this.currentDirection));this.updateAxis("x",t.point,i),this.updateAxis("y",t.point,i),this.visualElement.render(),a&&a(e,t)},onSessionEnd:(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},resumeAnimation:()=>Al(e=>{var t;return"paused"===this.getAnimationState(e)&&(null==(t=this.getAxisMotionValue(e).animation)?void 0:t.play())})},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:r,distanceThreshold:s,contextWindow:Rl(this.visualElement)})}stop(e,t){const s=e||this.latestPointerEvent,n=t||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!n||!s)return;const{velocity:a}=n;this.startAnimation(a);const{onDragEnd:i}=this.getProps();i&&Qs.postRender(()=>i(s,n))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,s){const{drag:n}=this.getProps();if(!s||!Kl(e,n,this.currentDirection))return;const r=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=function(e,{min:t,max:s},n){return void 0!==t&&e<t?e=n?In(t,e,n.min):Math.max(e,t):void 0!==s&&e>s&&(e=n?In(s,e,n.max):Math.min(e,s)),e}(a,this.constraints[e],this.elastic[e])),r.set(a)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:s}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null==(e=this.visualElement.projection)?void 0:e.layout,r=this.constraints;t&&oo(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!n)&&function(e,{top:t,left:s,bottom:n,right:r}){return{x:_l(e.x,s,r),y:_l(e.y,t,n)}}(n.layoutBox,t),this.elastic=function(e=Bl){return!1===e?e=0:!0===e&&(e=Bl),{x:ql(e,"left","right"),y:ql(e,"top","bottom")}}(s),r!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&Al(e=>{!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=function(e,t){const s={};return void 0!==t.min&&(s.min=t.min-e.min),void 0!==t.max&&(s.max=t.max-e.min),s}(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!oo(e))return!1;const s=e.current;ps(null!==s,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:n}=this.visualElement;if(!n||!n.layout)return!1;const r=function(e,t,s){const n=Do(e,s),{scroll:r}=t;return r&&(Ao(n.x,r.offset.x),Ao(n.y,r.offset.y)),n}(s,n.root,this.visualElement.getTransformPagePoint());let a=function(e,t){return{x:Vl(e.x,t.x),y:Vl(e.y,t.y)}}(n.layout.layoutBox,r);if(t){const e=t(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(a));this.hasMutatedConstraints=!!e,e&&(a=xo(e))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:n,dragTransition:r,dragSnapToOrigin:a,onDragTransitionEnd:i}=this.getProps(),o=this.constraints||{},l=Al(i=>{if(!Kl(i,t,this.currentDirection))return;let l=o&&o[i]||{};a&&(l={min:0,max:0});const c=n?200:1e6,d=n?40:1e7,u={type:"inertia",velocity:s?e[i]:0,bounceStiffness:c,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...r,...l};return this.startAxisValueAnimation(i,u)});return Promise.all(l).then(i)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return Go(this.visualElement,e),s.start(nl(e,s,0,t,this.visualElement,!1))}stopAnimation(){Al(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Al(e=>{var t;return null==(t=this.getAxisMotionValue(e).animation)?void 0:t.pause()})}getAnimationState(e){var t;return null==(t=this.getAxisMotionValue(e).animation)?void 0:t.state}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),n=s[t];return n||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){Al(t=>{const{drag:s}=this.getProps();if(!Kl(t,s,this.currentDirection))return;const{projection:n}=this.visualElement,r=this.getAxisMotionValue(t);if(n&&n.layout){const{min:s,max:a}=n.layout.layoutBox[t];r.set(e[t]-In(s,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!oo(t)||!s||!this.constraints)return;this.stopAnimation();const n={x:0,y:0};Al(e=>{const t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){const s=t.get();n[e]=function(e,t){let s=.5;const n=kl(e),r=kl(t);return r>n?s=js(t.min,t.max-n,e.min):n>r&&(s=js(e.min,e.max-r,t.min)),us(0,1,s)}({min:s,max:s},this.constraints[e])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Al(t=>{if(!Kl(t,e,null))return;const s=this.getAxisMotionValue(t),{min:r,max:a}=this.constraints[t];s.set(In(r,a,n[t]))})}addListeners(){if(!this.visualElement.current)return;Wl.set(this.visualElement,this);const e=jl(this.visualElement.current,"pointerdown",e=>{const{drag:t,dragListener:s=!0}=this.getProps();t&&s&&this.start(e)}),t=()=>{const{dragConstraints:e}=this.getProps();oo(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,n=s.addEventListener("measure",t);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Qs.read(t);const r=wl(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Al(t=>{const s=this.getAxisMotionValue(t);s&&(this.originPoint[t]+=e[t].translate,s.set(s.get()+e[t].translate))}),this.visualElement.render())});return()=>{r(),e(),n(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:n=!1,dragConstraints:r=!1,dragElastic:a=Bl,dragMomentum:i=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:n,dragConstraints:r,dragElastic:a,dragMomentum:i}}}function Kl(e,t,s){return!(!0!==t&&t!==e||null!==s&&s!==e)}const Yl=e=>(t,s)=>{e&&Qs.postRender(()=>e(t,s))};const Ql={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Gl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Jl={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e){if(!Sn.test(e))return e;e=parseFloat(e)}return`${Gl(e,t.target.x)}% ${Gl(e,t.target.y)}%`}},Xl={correct:(e,{treeScale:t,projectionDelta:s})=>{const n=e,r=Fn.parse(e);if(r.length>5)return n;const a=Fn.createTransformer(e),i="number"!=typeof r[0]?1:0,o=s.x.scale*t.x,l=s.y.scale*t.y;r[0+i]/=o,r[1+i]/=l;const c=In(o,l,.5);return"number"==typeof r[2+i]&&(r[2+i]/=c),"number"==typeof r[3+i]&&(r[3+i]/=c),a(r)}};let Zl=!1;class ec extends Oe.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:n}=this.props,{projection:r}=e;!function(e){for(const t in e)Di[t]=e[t],nn(t)&&(Di[t].isCSSVariable=!0)}(sc),r&&(t.group&&t.group.add(r),s&&s.register&&n&&s.register(r),Zl&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Ql.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:n,isPresent:r}=this.props,{projection:a}=s;return a?(a.isPresent=r,Zl=!0,n||e.layoutDependency!==t||void 0===t||e.isPresent!==r?a.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?a.promote():a.relegate()||Qs.postRender(()=>{const e=a.getStack();e&&e.members.length||this.safeToRemove()})),null):null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Ua.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:n}=e;Zl=!0,n&&(n.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(n),s&&s.deregister&&s.deregister(n))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function tc(e){const[t,s]=mi(),n=Oe.useContext(rs);return $e.jsx(ec,{...e,layoutGroup:n,switchLayoutGroup:Oe.useContext(ho),isPresent:t,safeToRemove:s})}const sc={borderRadius:{...Jl,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Jl,borderTopRightRadius:Jl,borderBottomLeftRadius:Jl,borderBottomRightRadius:Jl,boxShadow:Xl};const nc=(e,t)=>e.depth-t.depth;class rc{constructor(){this.children=[],this.isDirty=!1}add(e){cs(this.children,e),this.isDirty=!0}remove(e){ds(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(nc),this.isDirty=!1,this.children.forEach(e)}}const ac=["TopLeft","TopRight","BottomLeft","BottomRight"],ic=ac.length,oc=e=>"string"==typeof e?parseFloat(e):e,lc=e=>"number"==typeof e||Sn.test(e);function cc(e,t){return void 0!==e[t]?e[t]:e.borderRadius}const dc=hc(0,.5,Is),uc=hc(.5,.95,bs);function hc(e,t,s){return n=>n<e?0:n>t?1:s(js(e,t,n))}function mc(e,t){e.min=t.min,e.max=t.max}function pc(e,t){mc(e.x,t.x),mc(e.y,t.y)}function fc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function gc(e,t,s,n,r){return e=ko(e-=t,1/s,n),void 0!==r&&(e=ko(e,1/r,n)),e}function yc(e,t,[s,n,r],a,i){!function(e,t=0,s=1,n=.5,r,a=e,i=e){wn.test(t)&&(t=parseFloat(t),t=In(i.min,i.max,t/100)-i.min);if("number"!=typeof t)return;let o=In(a.min,a.max,n);e===a&&(o-=t),e.min=gc(e.min,t,s,o,r),e.max=gc(e.max,t,s,o,r)}(e,t[s],t[n],t[r],t.scale,a,i)}const xc=["x","scaleX","originX"],vc=["y","scaleY","originY"];function bc(e,t,s,n){yc(e.x,t,xc,s?s.x:void 0,n?n.x:void 0),yc(e.y,t,vc,s?s.y:void 0,n?n.y:void 0)}function wc(e){return 0===e.translate&&1===e.scale}function Sc(e){return wc(e.x)&&wc(e.y)}function jc(e,t){return e.min===t.min&&e.max===t.max}function kc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Nc(e,t){return kc(e.x,t.x)&&kc(e.y,t.y)}function Ec(e){return kl(e.x)/kl(e.y)}function Cc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Tc{constructor(){this.members=[]}add(e){cs(this.members,e),e.scheduleRender()}remove(e){if(ds(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){const t=this.members.findIndex(t=>e===t);if(0===t)return!1;let s;for(let n=t;n>=0;n--){const e=this.members[n];if(!1!==e.isPresent){s=e;break}}return!!s&&(this.promote(s),!0)}promote(e,t){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,t&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:n}=e.options;!1===n&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:s}=e;t.onExitComplete&&t.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const Pc=["","X","Y","Z"];let Ac=0;function Rc(e,t,s,n){const{latestValues:r}=t;r[e]&&(s[e]=r[e],t.setStaticValue(e,0),n&&(n[e]=0))}function Mc(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const s=Jo(t);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:t,layoutId:n}=e.options;window.MotionCancelOptimisedAnimation(s,"transform",Qs,!(t||n))}const{parent:n}=e;n&&!n.hasCheckedOptimisedAppear&&Mc(n)}function Dc({attachResizeListener:e,defaultParent:t,measureScroll:s,checkIsScrollRoot:n,resetTransform:r}){return class{constructor(e={},s=(null==t?void 0:t())){this.id=Ac++,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.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(Fc),this.nodes.forEach(qc),this.nodes.forEach(Uc),this.nodes.forEach(zc)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let t=0;t<this.path.length;t++)this.path[t].shouldResetTransform=!0;this.root===this&&(this.nodes=new rc)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ks),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){const s=this.eventHandlers.get(e);s&&s.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;var s;this.isSVG=ni(t)&&!(ni(s=t)&&"svg"===s.tagName),this.instance=t;const{layoutId:n,layout:r,visualElement:a}=this.options;if(a&&!a.current&&a.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let s,n=0;const r=()=>this.root.updateBlockedByResize=!1;Qs.read(()=>{n=window.innerWidth}),e(t,()=>{const e=window.innerWidth;e!==n&&(n=e,this.root.updateBlockedByResize=!0,s&&s(),s=function(e,t){const s=tn.now(),n=({timestamp:r})=>{const a=r-s;a>=t&&(Gs(n),e(a-t))};return Qs.setup(n,!0),()=>Gs(n)}(r,250),Ql.hasAnimatedSinceResize&&(Ql.hasAnimatedSinceResize=!1,this.nodes.forEach(Bc)))})}n&&this.root.registerSharedNode(n,this),!1!==this.options.animate&&a&&(n||r)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:s,layout:n})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const r=this.options.transition||a.getDefaultTransition()||Gc,{onLayoutAnimationStart:i,onLayoutAnimationComplete:o}=a.getProps(),l=!this.targetLayout||!Nc(this.targetLayout,n),c=!t&&s;if(this.options.layoutRoot||this.resumeFrom||c||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const t={...ja(r,"layout"),onPlay:i,onComplete:o};(a.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,c)}else t||Bc(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Gs(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(Wc),this.animationId++)}getTransformTemplate(){const{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Mc(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let r=0;r<this.path.length;r++){const e=this.path[r];e.shouldResetTransform=!0,e.updateScroll("snapshot"),e.options.layoutRoot&&e.willUpdate(!1)}const{layoutId:t,layout:s}=this.options;if(void 0===t&&!s)return;const n=this.getTransformTemplate();this.prevTransformTemplateValue=n?n(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){this.updateScheduled=!1;if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(Ic);if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(_c);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Vc),this.nodes.forEach($c),this.nodes.forEach(Oc)):this.nodes.forEach(_c),this.clearAllSnapshots();const e=tn.now();Js.delta=us(0,1e3/60,e-Js.timestamp),Js.timestamp=e,Js.isProcessing=!0,Xs.update.process(Js),Xs.preRender.process(Js),Xs.render.process(Js),Js.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ua.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Lc),this.sharedNodes.forEach(Hc)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Qs.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Qs.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||kl(this.snapshot.measuredBox.x)||kl(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let s=0;s<this.path.length;s++){this.path[s].updateScroll()}const e=this.layout;this.layout=this.measure(!1),this.layoutCorrected={x:{min:0,max:0},y:{min:0,max:0}},this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:t}=this.options;t&&t.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e="measure"){let t=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){const t=n(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!r)return;const e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Sc(this.projectionDelta),s=this.getTransformTemplate(),n=s?s(this.latestValues,""):void 0,a=n!==this.prevTransformTemplateValue;e&&this.instance&&(t||wo(this.latestValues)||a)&&(r(this.instance,n),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){const t=this.measurePageBox();let s=this.removeElementScroll(t);var n;return e&&(s=this.removeTransform(s)),Zc((n=s).x),Zc(n.y),{animationId:this.root.animationId,measuredBox:t,layoutBox:s,latestValues:{},source:this.id}}measurePageBox(){var e;const{visualElement:t}=this.options;if(!t)return{x:{min:0,max:0},y:{min:0,max:0}};const s=t.measureViewportBox();if(!((null==(e=this.scroll)?void 0:e.wasRoot)||this.path.some(td))){const{scroll:e}=this.root;e&&(Ao(s.x,e.offset.x),Ao(s.y,e.offset.y))}return s}removeElementScroll(e){var t;const s={x:{min:0,max:0},y:{min:0,max:0}};if(pc(s,e),null==(t=this.scroll)?void 0:t.wasRoot)return s;for(let n=0;n<this.path.length;n++){const t=this.path[n],{scroll:r,options:a}=t;t!==this.root&&r&&a.layoutScroll&&(r.wasRoot&&pc(s,e),Ao(s.x,r.offset.x),Ao(s.y,r.offset.y))}return s}applyTransform(e,t=!1){const s={x:{min:0,max:0},y:{min:0,max:0}};pc(s,e);for(let n=0;n<this.path.length;n++){const e=this.path[n];!t&&e.options.layoutScroll&&e.scroll&&e!==e.root&&Mo(s,{x:-e.scroll.offset.x,y:-e.scroll.offset.y}),wo(e.latestValues)&&Mo(s,e.latestValues)}return wo(this.latestValues)&&Mo(s,this.latestValues),s}removeTransform(e){const t={x:{min:0,max:0},y:{min:0,max:0}};pc(t,e);for(let s=0;s<this.path.length;s++){const e=this.path[s];if(!e.instance)continue;if(!wo(e.latestValues))continue;bo(e.latestValues)&&e.updateSnapshot();const n=$o();pc(n,e.measurePageBox()),bc(t,e.latestValues,e.snapshot?e.snapshot.layoutBox:void 0,n)}return wo(this.latestValues)&&bc(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:void 0===e.crossfade||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Js.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){var t;const s=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=s.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=s.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=s.isSharedProjectionDirty);const n=Boolean(this.resumingFrom)||this!==s;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||(null==(t=this.parent)?void 0:t.isProjectionDirty)||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:r,layoutId:a}=this.options;if(this.layout&&(r||a)){if(this.resolvedRelativeTargetAt=Js.timestamp,!this.targetDelta&&!this.relativeTarget){const e=this.getClosestProjectingParent();e&&e.layout&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pl(this.relativeTargetOrigin,this.layout.layoutBox,e.layout.layoutBox),pc(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}var i,o,l;if(this.relativeTarget||this.targetDelta)if(this.target||(this.target={x:{min:0,max:0},y:{min:0,max:0}},this.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}}),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),i=this.target,o=this.relativeTarget,l=this.relativeParent.target,Cl(i.x,o.x,l.x),Cl(i.y,o.y,l.y)):this.targetDelta?(Boolean(this.resumingFrom)?this.target=this.applyTransform(this.layout.layoutBox):pc(this.target,this.layout.layoutBox),Co(this.target,this.targetDelta)):pc(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const e=this.getClosestProjectingParent();e&&Boolean(e.resumingFrom)===Boolean(this.resumingFrom)&&!e.options.layoutScroll&&e.target&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pl(this.relativeTargetOrigin,this.target,e.target),pc(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(this.parent&&!bo(this.parent.latestValues)&&!So(this.parent.latestValues))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var e;const t=this.getLead(),s=Boolean(this.resumingFrom)||this!==t;let n=!0;if((this.isProjectionDirty||(null==(e=this.parent)?void 0:e.isProjectionDirty))&&(n=!1),s&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Js.timestamp&&(n=!1),n)return;const{layout:r,layoutId:a}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!r&&!a)return;pc(this.layoutCorrected,this.layout.layoutBox);const i=this.treeScale.x,o=this.treeScale.y;!function(e,t,s,n=!1){const r=s.length;if(!r)return;let a,i;t.x=t.y=1;for(let o=0;o<r;o++){a=s[o],i=a.projectionDelta;const{visualElement:r}=a.options;r&&r.props.style&&"contents"===r.props.style.display||(n&&a.options.layoutScroll&&a.scroll&&a!==a.root&&Mo(e,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Co(e,i)),n&&wo(a.latestValues)&&Mo(e,a.latestValues))}t.x<Po&&t.x>To&&(t.x=1),t.y<Po&&t.y>To&&(t.y=1)}(this.layoutCorrected,this.treeScale,this.path,s),!t.layout||t.target||1===this.treeScale.x&&1===this.treeScale.y||(t.target=t.layout.layoutBox,t.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}});const{target:l}=t;l?(this.projectionDelta&&this.prevProjectionDelta?(fc(this.prevProjectionDelta.x,this.projectionDelta.x),fc(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),El(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===i&&this.treeScale.y===o&&Cc(this.projectionDelta.x,this.prevProjectionDelta.x)&&Cc(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l))):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if(null==(t=this.options.visualElement)||t.scheduleRender(),e){const e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDeltaWithTransform={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}}setAnimationOrigin(e,t=!1){const s=this.snapshot,n=s?s.latestValues:{},r={...this.latestValues},a={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;const i={x:{min:0,max:0},y:{min:0,max:0}},o=(s?s.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),c=!l||l.members.length<=1,d=Boolean(o&&!c&&!0===this.options.crossfade&&!this.path.some(Qc));let u;this.animationProgress=0,this.mixTargetDelta=t=>{const s=t/1e3;var l,h,m,p,f,g;Kc(a.x,e.x,s),Kc(a.y,e.y,s),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pl(i,this.layout.layoutBox,this.relativeParent.layout.layoutBox),m=this.relativeTarget,p=this.relativeTargetOrigin,f=i,g=s,Yc(m.x,p.x,f.x,g),Yc(m.y,p.y,f.y,g),u&&(l=this.relativeTarget,h=u,jc(l.x,h.x)&&jc(l.y,h.y))&&(this.isProjectionDirty=!1),u||(u={x:{min:0,max:0},y:{min:0,max:0}}),pc(u,this.relativeTarget)),o&&(this.animationValues=r,function(e,t,s,n,r,a){r?(e.opacity=In(0,s.opacity??1,dc(n)),e.opacityExit=In(t.opacity??1,0,uc(n))):a&&(e.opacity=In(t.opacity??1,s.opacity??1,n));for(let i=0;i<ic;i++){const r=`border${ac[i]}Radius`;let a=cc(t,r),o=cc(s,r);void 0===a&&void 0===o||(a||(a=0),o||(o=0),0===a||0===o||lc(a)===lc(o)?(e[r]=Math.max(In(oc(a),oc(o),n),0),(wn.test(o)||wn.test(a))&&(e[r]+="%")):e[r]=o)}(t.rotate||s.rotate)&&(e.rotate=In(t.rotate||0,s.rotate||0,n))}(r,n,this.latestValues,s,d,c)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=s},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){var t,s,n;this.notifyListeners("animationStart"),null==(t=this.currentAnimation)||t.stop(),null==(n=null==(s=this.resumingFrom)?void 0:s.currentAnimation)||n.stop(),this.pendingAnimation&&(Gs(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Qs.update(()=>{Ql.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=qa(0)),this.currentAnimation=function(e,t,s){const n=ri(e)?e:qa(e);return n.start(nl("",n,t,s)),n.animation}(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{},onComplete:()=>{e.onComplete&&e.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 e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const e=this.getLead();let{targetWithTransforms:t,target:s,layout:n,latestValues:r}=e;if(t&&s&&n){if(this!==e&&this.layout&&n&&ed(this.options.animationType,this.layout.layoutBox,n.layoutBox)){s=this.target||{x:{min:0,max:0},y:{min:0,max:0}};const t=kl(this.layout.layoutBox.x);s.x.min=e.target.x.min,s.x.max=s.x.min+t;const n=kl(this.layout.layoutBox.y);s.y.min=e.target.y.min,s.y.max=s.y.min+n}pc(t,s),Mo(t,r),El(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Tc);this.sharedNodes.get(e).add(t);const s=t.options.initialPromotionConfig;t.promote({transition:s?s.transition:void 0,preserveFollowOpacity:s&&s.shouldPreserveFollowOpacity?s.shouldPreserveFollowOpacity(t):void 0})}isLead(){const e=this.getStack();return!e||e.lead===this}getLead(){var e;const{layoutId:t}=this.options;return t&&(null==(e=this.getStack())?void 0:e.lead)||this}getPrevLead(){var e;const{layoutId:t}=this.options;return t?null==(e=this.getStack())?void 0:e.prevLead:void 0}getStack(){const{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:s}={}){const n=this.getStack();n&&n.promote(this,s),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){const e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){const{visualElement:e}=this.options;if(!e)return;let t=!1;const{latestValues:s}=e;if((s.z||s.rotate||s.rotateX||s.rotateY||s.rotateZ||s.skewX||s.skewY)&&(t=!0),!t)return;const n={};s.z&&Rc("z",e,n,this.animationValues);for(let r=0;r<Pc.length;r++)Rc(`rotate${Pc[r]}`,e,n,this.animationValues),Rc(`skew${Pc[r]}`,e,n,this.animationValues);e.render();for(const r in n)e.setStaticValue(r,n[r]),this.animationValues&&(this.animationValues[r]=n[r]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible)return void(e.visibility="hidden");const s=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,e.visibility="",e.opacity="",e.pointerEvents=Zi(null==t?void 0:t.pointerEvents)||"",void(e.transform=s?s(this.latestValues,""):"none");const n=this.getLead();if(!this.projectionDelta||!this.layout||!n.target)return this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=Zi(null==t?void 0:t.pointerEvents)||""),void(this.hasProjected&&!wo(this.latestValues)&&(e.transform=s?s({},""):"none",this.hasProjected=!1));e.visibility="";const r=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=function(e,t,s){let n="";const r=e.x.translate/t.x,a=e.y.translate/t.y,i=(null==s?void 0:s.z)||0;if((r||a||i)&&(n=`translate3d(${r}px, ${a}px, ${i}px) `),1===t.x&&1===t.y||(n+=`scale(${1/t.x}, ${1/t.y}) `),s){const{transformPerspective:e,rotate:t,rotateX:r,rotateY:a,skewX:i,skewY:o}=s;e&&(n=`perspective(${e}px) ${n}`),t&&(n+=`rotate(${t}deg) `),r&&(n+=`rotateX(${r}deg) `),a&&(n+=`rotateY(${a}deg) `),i&&(n+=`skewX(${i}deg) `),o&&(n+=`skewY(${o}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return 1===o&&1===l||(n+=`scale(${o}, ${l})`),n||"none"}(this.projectionDeltaWithTransform,this.treeScale,r);s&&(a=s(r,a)),e.transform=a;const{x:i,y:o}=this.projectionDelta;e.transformOrigin=`${100*i.origin}% ${100*o.origin}% 0`,n.animationValues?e.opacity=n===this?r.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:r.opacityExit:e.opacity=n===this?void 0!==r.opacity?r.opacity:"":void 0!==r.opacityExit?r.opacityExit:0;for(const l in Di){if(void 0===r[l])continue;const{correct:t,applyTo:s,isCSSVariable:i}=Di[l],o="none"===a?r[l]:t(r[l],n);if(s){const t=s.length;for(let n=0;n<t;n++)e[s[n]]=o}else i?this.options.visualElement.renderState.vars[l]=o:e[l]=o}this.options.layoutId&&(e.pointerEvents=n===this?Zi(null==t?void 0:t.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>{var t;return null==(t=e.currentAnimation)?void 0:t.stop()}),this.root.nodes.forEach(Ic),this.root.sharedNodes.clear()}}}function $c(e){e.updateLayout()}function Oc(e){var t;const s=(null==(t=e.resumeFrom)?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&s&&e.hasListeners("didUpdate")){const{layoutBox:t,measuredBox:n}=e.layout,{animationType:r}=e.options,a=s.source!==e.layout.source;"size"===r?Al(e=>{const n=a?s.measuredBox[e]:s.layoutBox[e],r=kl(n);n.min=t[e].min,n.max=n.min+r}):ed(r,s.layoutBox,t)&&Al(n=>{const r=a?s.measuredBox[n]:s.layoutBox[n],i=kl(t[n]);r.max=r.min+i,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+i)});const i={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};El(i,t,s.layoutBox);const o={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};a?El(o,e.applyTransform(n,!0),s.measuredBox):El(o,t,s.layoutBox);const l=!Sc(i);let c=!1;if(!e.resumeFrom){const n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){const{snapshot:r,layout:a}=n;if(r&&a){const i={x:{min:0,max:0},y:{min:0,max:0}};Pl(i,s.layoutBox,r.layoutBox);const o={x:{min:0,max:0},y:{min:0,max:0}};Pl(o,t,a.layoutBox),Nc(i,o)||(c=!0),n.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=i,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:t,snapshot:s,delta:o,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Fc(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=Boolean(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function zc(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Lc(e){e.clearSnapshot()}function Ic(e){e.clearMeasurements()}function _c(e){e.isLayoutDirty=!1}function Vc(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Bc(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function qc(e){e.resolveTargetDelta()}function Uc(e){e.calcProjection()}function Wc(e){e.resetSkewAndRotation()}function Hc(e){e.removeLeadSnapshot()}function Kc(e,t,s){e.translate=In(t.translate,0,s),e.scale=In(t.scale,1,s),e.origin=t.origin,e.originPoint=t.originPoint}function Yc(e,t,s,n){e.min=In(t.min,s.min,n),e.max=In(t.max,s.max,n)}function Qc(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}const Gc={duration:.45,ease:[.4,0,.1,1]},Jc=e=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Xc=Jc("applewebkit/")&&!Jc("chrome/")?Math.round:bs;function Zc(e){e.min=Xc(e.min),e.max=Xc(e.max)}function ed(e,t,s){return"position"===e||"preserve-aspect"===e&&(n=Ec(t),r=Ec(s),a=.2,!(Math.abs(n-r)<=a));var n,r,a}function td(e){var t;return e!==e.root&&(null==(t=e.scroll)?void 0:t.wasRoot)}const sd=Dc({attachResizeListener:(e,t)=>wl(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),nd={current:void 0},rd=Dc({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!nd.current){const e=new sd({});e.mount(window),e.setOptions({layoutScroll:!0}),nd.current=e}return nd.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>Boolean("fixed"===window.getComputedStyle(e).position)}),ad={pan:{Feature:class extends xl{constructor(){super(...arguments),this.removePointerDownListener=bs}onPointerDown(e){this.session=new Dl(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Rl(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:n}=this.node.getProps();return{onSessionStart:Yl(e),onStart:Yl(t),onMove:s,onEnd:(e,t)=>{delete this.session,n&&Qs.postRender(()=>n(e,t))}}}mount(){this.removePointerDownListener=jl(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends xl{constructor(e){super(e),this.removeGroupControls=bs,this.removeListeners=bs,this.controls=new Hl(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||bs}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:rd,MeasureLayout:tc}};function id(e,t,s){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover","Start"===s);const r=n["onHover"+s];r&&Qs.postRender(()=>r(t,Sl(t)))}function od(e,t,s){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap","Start"===s);const r=n["onTap"+("End"===s?"":s)];r&&Qs.postRender(()=>r(t,Sl(t)))}const ld=new WeakMap,cd=new WeakMap,dd=e=>{const t=ld.get(e.target);t&&t(e)},ud=e=>{e.forEach(dd)};function hd(e,t,s){const n=function({root:e,...t}){const s=e||document;cd.has(s)||cd.set(s,{});const n=cd.get(s),r=JSON.stringify(t);return n[r]||(n[r]=new IntersectionObserver(ud,{root:e,...t})),n[r]}(t);return ld.set(e,s),n.observe(e),()=>{ld.delete(e),n.unobserve(e)}}const md={some:0,all:1};const pd=yo({...bl,...{inView:{Feature:class extends xl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:n="some",once:r}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:"number"==typeof n?n:md[n]};return hd(this.node.current,a,e=>{const{isIntersecting:t}=e;if(this.isInView===t)return;if(this.isInView=t,r&&!t&&this.hasEnteredView)return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);const{onViewportEnter:s,onViewportLeave:n}=this.node.getProps(),a=t?s:n;a&&a(e)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return s=>e[s]!==t[s]}(e,t))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends xl{mount(){const{current:e}=this.node;e&&(this.unmount=si(e,(e,t)=>(od(this.node,t,"Start"),(e,{success:t})=>od(this.node,e,t?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends xl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&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=Ss(wl(this.node.current,"focus",()=>this.onFocus()),wl(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends xl{mount(){const{current:e}=this.node;e&&(this.unmount=function(e,t,s={}){const[n,r,a]=Ka(e,s),i=e=>{if(!Ya(e))return;const{target:s}=e,n=t(s,e);if("function"!=typeof n||!s)return;const a=e=>{Ya(e)&&(n(e),s.removeEventListener("pointerleave",a))};s.addEventListener("pointerleave",a,r)};return n.forEach(e=>{e.addEventListener("pointerenter",i,r)}),a}(e,(e,t)=>(id(this.node,t,"Start"),e=>id(this.node,e,"End"))))}unmount(){}}}},...ad,...{layout:{ProjectionNode:rd,MeasureLayout:tc}}},Wo);function fd(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function gd(e){const t=xd(e),s=Le.forwardRef((e,s)=>{const{children:n,...r}=e,a=Le.Children.toArray(n),i=a.find(bd);if(i){const e=i.props.children,n=a.map(t=>t===i?Le.Children.count(e)>1?Le.Children.only(null):Le.isValidElement(e)?e.props.children:null:t);return $e.jsx(t,{...r,ref:s,children:Le.isValidElement(e)?Le.cloneElement(e,void 0,n):null})}return $e.jsx(t,{...r,ref:s,children:n})});return s.displayName=`${e}.Slot`,s}var yd=gd("Slot");function xd(e){const t=Le.forwardRef((e,t)=>{const{children:s,...n}=e;if(Le.isValidElement(s)){const e=function(e){var t,s;let n=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=n&&"isReactWarning"in n&&n.isReactWarning;if(r)return e.ref;if(n=null==(s=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s),r=function(e,t){const s={...t};for(const n in t){const r=e[n],a=t[n];/^on[A-Z]/.test(n)?r&&a?s[n]=(...e)=>{const t=a(...e);return r(...e),t}:r&&(s[n]=r):"style"===n?s[n]={...r,...a}:"className"===n&&(s[n]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}(n,s.props);return s.type!==Le.Fragment&&(r.ref=t?function(...e){return t=>{let s=!1;const n=e.map(e=>{const n=fd(e,t);return s||"function"!=typeof n||(s=!0),n});if(s)return()=>{for(let t=0;t<n.length;t++){const s=n[t];"function"==typeof s?s():fd(e[t],null)}}}}(t,e):e),Le.cloneElement(s,r)}return Le.Children.count(s)>1?Le.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vd=Symbol("radix.slottable");function bd(e){return Le.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===vd}function wd(e){var t,s,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=wd(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Sd(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=wd(e))&&(n&&(n+=" "),n+=t);return n}const jd=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,kd=Sd,Nd=e=>{const t=Pd(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:e=>{const s=e.split("-");return""===s[0]&&1!==s.length&&s.shift(),Ed(s,t)||Td(e)},getConflictingClassGroupIds:(e,t)=>{const r=s[e]||[];return t&&n[e]?[...r,...n[e]]:r}}},Ed=(e,t)=>{var s;if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?Ed(e.slice(1),r):void 0;if(a)return a;if(0===t.validators.length)return;const i=e.join("-");return null==(s=t.validators.find(({validator:e})=>e(i)))?void 0:s.classGroupId},Cd=/^\[(.+)\]$/,Td=e=>{if(Cd.test(e)){const t=Cd.exec(e)[1],s=null==t?void 0:t.substring(0,t.indexOf(":"));if(s)return"arbitrary.."+s}},Pd=e=>{const{theme:t,classGroups:s}=e,n={nextPart:new Map,validators:[]};for(const r in s)Ad(s[r],n,r,t);return n},Ad=(e,t,s,n)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:Rd(t,e)).classGroupId=s)}if("function"==typeof e)return Md(e)?void Ad(e(n),t,s,n):void t.validators.push({validator:e,classGroupId:s});Object.entries(e).forEach(([e,r])=>{Ad(r,Rd(t,e),s,n)})})},Rd=(e,t)=>{let s=e;return t.split("-").forEach(e=>{s.nextPart.has(e)||s.nextPart.set(e,{nextPart:new Map,validators:[]}),s=s.nextPart.get(e)}),s},Md=e=>e.isThemeGetter,Dd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=new Map,n=new Map;const r=(r,a)=>{s.set(r,a),t++,t>e&&(t=0,n=s,s=new Map)};return{get(e){let t=s.get(e);return void 0!==t?t:void 0!==(t=n.get(e))?(r(e,t),t):void 0},set(e,t){s.has(e)?s.set(e,t):r(e,t)}}},$d=e=>{const{prefix:t,experimentalParseClassName:s}=e;let n=e=>{const t=[];let s,n=0,r=0,a=0;for(let l=0;l<e.length;l++){let i=e[l];if(0===n&&0===r){if(":"===i){t.push(e.slice(a,l)),a=l+1;continue}if("/"===i){s=l;continue}}"["===i?n++:"]"===i?n--:"("===i?r++:")"===i&&r--}const i=0===t.length?e:e.substring(a),o=Od(i);return{modifiers:t,hasImportantModifier:o!==i,baseClassName:o,maybePostfixModifierPosition:s&&s>a?s-a:void 0}};if(t){const e=t+":",s=n;n=t=>t.startsWith(e)?s(t.substring(e.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:t,maybePostfixModifierPosition:void 0}}if(s){const e=n;n=t=>s({className:t,parseClassName:e})}return n},Od=e=>e.endsWith("!")?e.substring(0,e.length-1):e.startsWith("!")?e.substring(1):e,Fd=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(e=>[e,!0]));return e=>{if(e.length<=1)return e;const s=[];let n=[];return e.forEach(e=>{"["===e[0]||t[e]?(s.push(...n.sort(),e),n=[]):n.push(e)}),s.push(...n.sort()),s}},zd=/\s+/;function Ld(){let e,t,s=0,n="";for(;s<arguments.length;)(e=arguments[s++])&&(t=Id(e))&&(n&&(n+=" "),n+=t);return n}const Id=e=>{if("string"==typeof e)return e;let t,s="";for(let n=0;n<e.length;n++)e[n]&&(t=Id(e[n]))&&(s&&(s+=" "),s+=t);return s};function _d(e,...t){let s,n,r,a=function(o){const l=t.reduce((e,t)=>t(e),e());return s=(e=>({cache:Dd(e.cacheSize),parseClassName:$d(e),sortModifiers:Fd(e),...Nd(e)}))(l),n=s.cache.get,r=s.cache.set,a=i,i(o)};function i(e){const t=n(e);if(t)return t;const a=((e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:r,sortModifiers:a}=t,i=[],o=e.trim().split(zd);let l="";for(let c=o.length-1;c>=0;c-=1){const e=o[c],{isExternal:t,modifiers:d,hasImportantModifier:u,baseClassName:h,maybePostfixModifierPosition:m}=s(e);if(t){l=e+(l.length>0?" "+l:l);continue}let p=!!m,f=n(p?h.substring(0,m):h);if(!f){if(!p){l=e+(l.length>0?" "+l:l);continue}if(f=n(h),!f){l=e+(l.length>0?" "+l:l);continue}p=!1}const g=a(d).join(":"),y=u?g+"!":g,x=y+f;if(i.includes(x))continue;i.push(x);const v=r(f,p);for(let s=0;s<v.length;++s){const e=v[s];i.push(y+e)}l=e+(l.length>0?" "+l:l)}return l})(e,s);return r(e,a),a}return function(){return a(Ld.apply(null,arguments))}}const Vd=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Bd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,qd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ud=/^\d+\/\d+$/,Wd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hd=/\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$/,Kd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Yd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gd=e=>Ud.test(e),Jd=e=>!!e&&!Number.isNaN(Number(e)),Xd=e=>!!e&&Number.isInteger(Number(e)),Zd=e=>e.endsWith("%")&&Jd(e.slice(0,-1)),eu=e=>Wd.test(e),tu=()=>!0,su=e=>Hd.test(e)&&!Kd.test(e),nu=()=>!1,ru=e=>Yd.test(e),au=e=>Qd.test(e),iu=e=>!lu(e)&&!pu(e),ou=e=>wu(e,Nu,nu),lu=e=>Bd.test(e),cu=e=>wu(e,Eu,su),du=e=>wu(e,Cu,Jd),uu=e=>wu(e,ju,nu),hu=e=>wu(e,ku,au),mu=e=>wu(e,Pu,ru),pu=e=>qd.test(e),fu=e=>Su(e,Eu),gu=e=>Su(e,Tu),yu=e=>Su(e,ju),xu=e=>Su(e,Nu),vu=e=>Su(e,ku),bu=e=>Su(e,Pu,!0),wu=(e,t,s)=>{const n=Bd.exec(e);return!!n&&(n[1]?t(n[1]):s(n[2]))},Su=(e,t,s=!1)=>{const n=qd.exec(e);return!!n&&(n[1]?t(n[1]):s)},ju=e=>"position"===e||"percentage"===e,ku=e=>"image"===e||"url"===e,Nu=e=>"length"===e||"size"===e||"bg-size"===e,Eu=e=>"length"===e,Cu=e=>"number"===e,Tu=e=>"family-name"===e,Pu=e=>"shadow"===e,Au=_d(()=>{const e=Vd("color"),t=Vd("font"),s=Vd("text"),n=Vd("font-weight"),r=Vd("tracking"),a=Vd("leading"),i=Vd("breakpoint"),o=Vd("container"),l=Vd("spacing"),c=Vd("radius"),d=Vd("shadow"),u=Vd("inset-shadow"),h=Vd("text-shadow"),m=Vd("drop-shadow"),p=Vd("blur"),f=Vd("perspective"),g=Vd("aspect"),y=Vd("ease"),x=Vd("animate"),v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",pu,lu],b=()=>[pu,lu,l],w=()=>[Gd,"full","auto",...b()],S=()=>[Xd,"none","subgrid",pu,lu],j=()=>["auto",{span:["full",Xd,pu,lu]},Xd,pu,lu],k=()=>[Xd,"auto",pu,lu],N=()=>["auto","min","max","fr",pu,lu],E=()=>["auto",...b()],C=()=>[Gd,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],T=()=>[e,pu,lu],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",yu,uu,{position:[pu,lu]}],A=()=>["auto","cover","contain",xu,ou,{size:[pu,lu]}],R=()=>[Zd,fu,cu],M=()=>["","none","full",c,pu,lu],D=()=>["",Jd,fu,cu],$=()=>[Jd,Zd,yu,uu],O=()=>["","none",p,pu,lu],F=()=>["none",Jd,pu,lu],z=()=>["none",Jd,pu,lu],L=()=>[Jd,pu,lu],I=()=>[Gd,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[eu],breakpoint:[eu],color:[tu],container:[eu],"drop-shadow":[eu],ease:["in","out","in-out"],font:[iu],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[eu],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[eu],shadow:[eu],spacing:["px",Jd],text:[eu],"text-shadow":[eu],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gd,lu,pu,g]}],container:["container"],columns:[{columns:[Jd,lu,pu,o]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"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"],sr:["sr-only","not-sr-only"],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:v()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{start:w()}],end:[{end:w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:["visible","invisible","collapse"],z:[{z:[Xd,"auto",pu,lu]}],basis:[{basis:[Gd,"full","auto",o,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Jd,Gd,"auto","initial","none",lu]}],grow:[{grow:["",Jd,pu,lu]}],shrink:[{shrink:["",Jd,pu,lu]}],order:[{order:[Xd,"first","last","none",pu,lu]}],"grid-cols":[{"grid-cols":S()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":k()}],"col-end":[{"col-end":k()}],"grid-rows":[{"grid-rows":S()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":k()}],"row-end":[{"row-end":k()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":N()}],"auto-rows":[{"auto-rows":N()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:E()}],mx:[{mx:E()}],my:[{my:E()}],ms:[{ms:E()}],me:[{me:E()}],mt:[{mt:E()}],mr:[{mr:E()}],mb:[{mb:E()}],ml:[{ml:E()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:C()}],w:[{w:[o,"screen",...C()]}],"min-w":[{"min-w":[o,"screen","none",...C()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[i]},...C()]}],h:[{h:["screen","lh",...C()]}],"min-h":[{"min-h":["screen","lh","none",...C()]}],"max-h":[{"max-h":["screen","lh",...C()]}],"font-size":[{text:["base",s,fu,cu]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,pu,du]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Zd,lu]}],"font-family":[{font:[gu,lu,t]}],"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:[r,pu,lu]}],"line-clamp":[{"line-clamp":[Jd,"none",pu,du]}],leading:[{leading:[a,...b()]}],"list-image":[{"list-image":["none",pu,lu]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pu,lu]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Jd,"from-font","auto",pu,cu]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[Jd,"auto",pu,lu]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pu,lu]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pu,lu]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:P()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:A()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Xd,pu,lu],radial:["",pu,lu],conic:[Xd,pu,lu]},vu,hu]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:M()}],"rounded-s":[{"rounded-s":M()}],"rounded-e":[{"rounded-e":M()}],"rounded-t":[{"rounded-t":M()}],"rounded-r":[{"rounded-r":M()}],"rounded-b":[{"rounded-b":M()}],"rounded-l":[{"rounded-l":M()}],"rounded-ss":[{"rounded-ss":M()}],"rounded-se":[{"rounded-se":M()}],"rounded-ee":[{"rounded-ee":M()}],"rounded-es":[{"rounded-es":M()}],"rounded-tl":[{"rounded-tl":M()}],"rounded-tr":[{"rounded-tr":M()}],"rounded-br":[{"rounded-br":M()}],"rounded-bl":[{"rounded-bl":M()}],"border-w":[{border:D()}],"border-w-x":[{"border-x":D()}],"border-w-y":[{"border-y":D()}],"border-w-s":[{"border-s":D()}],"border-w-e":[{"border-e":D()}],"border-w-t":[{"border-t":D()}],"border-w-r":[{"border-r":D()}],"border-w-b":[{"border-b":D()}],"border-w-l":[{"border-l":D()}],"divide-x":[{"divide-x":D()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":D()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Jd,pu,lu]}],"outline-w":[{outline:["",Jd,fu,cu]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","none",d,bu,mu]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",u,bu,mu]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[Jd,cu]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":D()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",h,bu,mu]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[Jd,pu,lu]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Jd]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[pu,lu]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[Jd]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:P()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:A()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pu,lu]}],filter:[{filter:["","none",pu,lu]}],blur:[{blur:O()}],brightness:[{brightness:[Jd,pu,lu]}],contrast:[{contrast:[Jd,pu,lu]}],"drop-shadow":[{"drop-shadow":["","none",m,bu,mu]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",Jd,pu,lu]}],"hue-rotate":[{"hue-rotate":[Jd,pu,lu]}],invert:[{invert:["",Jd,pu,lu]}],saturate:[{saturate:[Jd,pu,lu]}],sepia:[{sepia:["",Jd,pu,lu]}],"backdrop-filter":[{"backdrop-filter":["","none",pu,lu]}],"backdrop-blur":[{"backdrop-blur":O()}],"backdrop-brightness":[{"backdrop-brightness":[Jd,pu,lu]}],"backdrop-contrast":[{"backdrop-contrast":[Jd,pu,lu]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Jd,pu,lu]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Jd,pu,lu]}],"backdrop-invert":[{"backdrop-invert":["",Jd,pu,lu]}],"backdrop-opacity":[{"backdrop-opacity":[Jd,pu,lu]}],"backdrop-saturate":[{"backdrop-saturate":[Jd,pu,lu]}],"backdrop-sepia":[{"backdrop-sepia":["",Jd,pu,lu]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pu,lu]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Jd,"initial",pu,lu]}],ease:[{ease:["linear","initial",y,pu,lu]}],delay:[{delay:[Jd,pu,lu]}],animate:[{animate:["none",x,pu,lu]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,pu,lu]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:F()}],"rotate-x":[{"rotate-x":F()}],"rotate-y":[{"rotate-y":F()}],"rotate-z":[{"rotate-z":F()}],scale:[{scale:z()}],"scale-x":[{"scale-x":z()}],"scale-y":[{"scale-y":z()}],"scale-z":[{"scale-z":z()}],"scale-3d":["scale-3d"],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[pu,lu,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:I()}],"translate-x":[{"translate-x":I()}],"translate-y":[{"translate-y":I()}],"translate-z":[{"translate-z":I()}],"translate-none":["translate-none"],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],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",pu,lu]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"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",pu,lu]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[Jd,fu,cu,du]}],stroke:[{stroke:["none",...T()]}],"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-x","border-w-y","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-x","border-color-y","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"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Ru(...e){return Au(Sd(e))}const Mu=(Du="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",$u={variants:{variant:{default:"text-white shadow",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/95",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/90",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline active:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}},e=>{var t;if(null==(null==$u?void 0:$u.variants))return kd(Du,null==e?void 0:e.class,null==e?void 0:e.className);const{variants:s,defaultVariants:n}=$u,r=Object.keys(s).map(t=>{const r=null==e?void 0:e[t],a=null==n?void 0:n[t];if(null===r)return null;const i=jd(r)||jd(a);return s[t][i]}),a=e&&Object.entries(e).reduce((e,t)=>{let[s,n]=t;return void 0===n||(e[s]=n),e},{}),i=null==$u||null===(t=$u.compoundVariants)||void 0===t?void 0:t.reduce((e,t)=>{let{class:s,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,s]=e;return Array.isArray(s)?s.includes({...n,...a}[t]):{...n,...a}[t]===s})?[...e,s,r]:e},[]);return kd(Du,r,i,null==e?void 0:e.class,null==e?void 0:e.className)});var Du,$u;const Ou=Le.forwardRef(({className:e,variant:t,size:s,asChild:n=!1,textColor:r,style:a,disabled:i,...o},l)=>{const{theme:c}=ns(),d=n?yd:"button",u=(e,t)=>`rgba(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)}, ${t})`,h=(()=>{if("default"!==t||!(null==c?void 0:c.primaryColor))return{};const e=c.primaryColor;return{backgroundColor:i?u(e,.5):e,"--hover-bg":u(e,.9),"--active-bg":u(e,.95)}})();return $e.jsx(d,{className:Ru(Mu({variant:t,size:s,className:e}),"default"===t&&(null==c?void 0:c.primaryColor)&&"hover:[background-color:var(--hover-bg)] active:[background-color:var(--active-bg)]"),style:{...h,...r&&{color:r},...a},disabled:i,ref:l,...o})});Ou.displayName="Button";const Fu=e=>{let t;const s=new Set,n=(e,n)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=n?n:"object"!=typeof r||null===r)?r:Object.assign({},t,r),s.forEach(s=>s(t,e))}},r=()=>t,a={setState:n,getState:r,getInitialState:()=>i,subscribe:e=>(s.add(e),()=>s.delete(e))},i=t=e(n,r,a);return a},zu=e=>e;const Lu=e=>{const t=(e=>e?Fu(e):Fu)(e),s=e=>function(e,t=zu){const s=Oe.useSyncExternalStore(e.subscribe,Oe.useCallback(()=>t(e.getState()),[e,t]),Oe.useCallback(()=>t(e.getInitialState()),[e,t]));return Oe.useDebugValue(s),s}(t,e);return Object.assign(s,t),s},Iu=e=>e?Lu(e):Lu,_u=e=>(t,s,n)=>{const r=n.subscribe;n.subscribe=(e,t,s)=>{let a=e;if(t){const r=(null==s?void 0:s.equalityFn)||Object.is;let i=e(n.getState());a=s=>{const n=e(s);if(!r(i,n)){const e=i;t(i=n,e)}},(null==s?void 0:s.fireImmediately)&&t(i,i)}return r(a)};return e(t,s,n)};function Vu(e,t){return function(){return e.apply(t,arguments)}}const{toString:Bu}=Object.prototype,{getPrototypeOf:qu}=Object,{iterator:Uu,toStringTag:Wu}=Symbol,Hu=(e=>t=>{const s=Bu.call(t);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ku=e=>(e=e.toLowerCase(),t=>Hu(t)===e),Yu=e=>t=>typeof t===e,{isArray:Qu}=Array,Gu=Yu("undefined");function Ju(e){return null!==e&&!Gu(e)&&null!==e.constructor&&!Gu(e.constructor)&&eh(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Xu=Ku("ArrayBuffer");const Zu=Yu("string"),eh=Yu("function"),th=Yu("number"),sh=e=>null!==e&&"object"==typeof e,nh=e=>{if("object"!==Hu(e))return!1;const t=qu(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Wu in e||Uu in e)},rh=Ku("Date"),ah=Ku("File"),ih=Ku("Blob"),oh=Ku("FileList"),lh=Ku("URLSearchParams"),[ch,dh,uh,hh]=["ReadableStream","Request","Response","Headers"].map(Ku);function mh(e,t,{allOwnKeys:s=!1}={}){if(null==e)return;let n,r;if("object"!=typeof e&&(e=[e]),Qu(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(Ju(e))return;const r=s?Object.getOwnPropertyNames(e):Object.keys(e),a=r.length;let i;for(n=0;n<a;n++)i=r[n],t.call(null,e[i],i,e)}}function ph(e,t){if(Ju(e))return null;t=t.toLowerCase();const s=Object.keys(e);let n,r=s.length;for(;r-- >0;)if(n=s[r],t===n.toLowerCase())return n;return null}const fh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,gh=e=>!Gu(e)&&e!==fh;const yh=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&qu(Uint8Array)),xh=Ku("HTMLFormElement"),vh=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),bh=Ku("RegExp"),wh=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),n={};mh(s,(s,r)=>{let a;!1!==(a=t(s,r,e))&&(n[r]=a||s)}),Object.defineProperties(e,n)};const Sh=Ku("AsyncFunction"),jh=(kh="function"==typeof setImmediate,Nh=eh(fh.postMessage),kh?setImmediate:Nh?(Eh=`axios@${Math.random()}`,Ch=[],fh.addEventListener("message",({source:e,data:t})=>{e===fh&&t===Eh&&Ch.length&&Ch.shift()()},!1),e=>{Ch.push(e),fh.postMessage(Eh,"*")}):e=>setTimeout(e));var kh,Nh,Eh,Ch;const Th="undefined"!=typeof queueMicrotask?queueMicrotask.bind(fh):"undefined"!=typeof process&&process.nextTick||jh,Ph={isArray:Qu,isArrayBuffer:Xu,isBuffer:Ju,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||eh(e.append)&&("formdata"===(t=Hu(e))||"object"===t&&eh(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Xu(e.buffer),t},isString:Zu,isNumber:th,isBoolean:e=>!0===e||!1===e,isObject:sh,isPlainObject:nh,isEmptyObject:e=>{if(!sh(e)||Ju(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(t){return!1}},isReadableStream:ch,isRequest:dh,isResponse:uh,isHeaders:hh,isUndefined:Gu,isDate:rh,isFile:ah,isBlob:ih,isRegExp:bh,isFunction:eh,isStream:e=>sh(e)&&eh(e.pipe),isURLSearchParams:lh,isTypedArray:yh,isFileList:oh,forEach:mh,merge:function e(){const{caseless:t,skipUndefined:s}=gh(this)&&this||{},n={},r=(r,a)=>{const i=t&&ph(n,a)||a;nh(n[i])&&nh(r)?n[i]=e(n[i],r):nh(r)?n[i]=e({},r):Qu(r)?n[i]=r.slice():s&&Gu(r)||(n[i]=r)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&mh(arguments[a],r);return n},extend:(e,t,s,{allOwnKeys:n}={})=>(mh(t,(t,n)=>{s&&eh(t)?e[n]=Vu(t,s):e[n]=t},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,s,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),s&&Object.assign(e.prototype,s)},toFlatObject:(e,t,s,n)=>{let r,a,i;const o={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),a=r.length;a-- >0;)i=r[a],n&&!n(i,e,t)||o[i]||(t[i]=e[i],o[i]=!0);e=!1!==s&&qu(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},kindOf:Hu,kindOfTest:Ku,endsWith:(e,t,s)=>{e=String(e),(void 0===s||s>e.length)&&(s=e.length),s-=t.length;const n=e.indexOf(t,s);return-1!==n&&n===s},toArray:e=>{if(!e)return null;if(Qu(e))return e;let t=e.length;if(!th(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},forEachEntry:(e,t)=>{const s=(e&&e[Uu]).call(e);let n;for(;(n=s.next())&&!n.done;){const s=n.value;t.call(e,s[0],s[1])}},matchAll:(e,t)=>{let s;const n=[];for(;null!==(s=e.exec(t));)n.push(s);return n},isHTMLForm:xh,hasOwnProperty:vh,hasOwnProp:vh,reduceDescriptors:wh,freezeMethods:e=>{wh(e,(t,s)=>{if(eh(e)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const n=e[s];eh(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))})},toObjectSet:(e,t)=>{const s={},n=e=>{e.forEach(e=>{s[e]=!0})};return Qu(e)?n(e):n(String(e).split(t)),s},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,s){return t.toUpperCase()+s}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ph,global:fh,isContextDefined:gh,isSpecCompliantForm:function(e){return!!(e&&eh(e.append)&&"FormData"===e[Wu]&&e[Uu])},toJSONObject:e=>{const t=new Array(10),s=(e,n)=>{if(sh(e)){if(t.indexOf(e)>=0)return;if(Ju(e))return e;if(!("toJSON"in e)){t[n]=e;const r=Qu(e)?[]:{};return mh(e,(e,t)=>{const a=s(e,n+1);!Gu(a)&&(r[t]=a)}),t[n]=void 0,r}}return e};return s(e,0)},isAsyncFn:Sh,isThenable:e=>e&&(sh(e)||eh(e))&&eh(e.then)&&eh(e.catch),setImmediate:jh,asap:Th,isIterable:e=>null!=e&&eh(e[Uu])};function Ah(e,t,s,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),s&&(this.config=s),n&&(this.request=n),r&&(this.response=r,this.status=r.status?r.status:null)}Ph.inherits(Ah,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ph.toJSONObject(this.config),code:this.code,status:this.status}}});const Rh=Ah.prototype,Mh={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Mh[e]={value:e}}),Object.defineProperties(Ah,Mh),Object.defineProperty(Rh,"isAxiosError",{value:!0}),Ah.from=(e,t,s,n,r,a)=>{const i=Object.create(Rh);Ph.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const o=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Ah.call(i,o,l,s,n,r),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};function Dh(e){return Ph.isPlainObject(e)||Ph.isArray(e)}function $h(e){return Ph.endsWith(e,"[]")?e.slice(0,-2):e}function Oh(e,t,s){return e?e.concat(t).map(function(e,t){return e=$h(e),!s&&t?"["+e+"]":e}).join(s?".":""):t}const Fh=Ph.toFlatObject(Ph,{},null,function(e){return/^is[A-Z]/.test(e)});function zh(e,t,s){if(!Ph.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(s=Ph.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ph.isUndefined(t[e])})).metaTokens,r=s.visitor||c,a=s.dots,i=s.indexes,o=(s.Blob||"undefined"!=typeof Blob&&Blob)&&Ph.isSpecCompliantForm(t);if(!Ph.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ph.isDate(e))return e.toISOString();if(Ph.isBoolean(e))return e.toString();if(!o&&Ph.isBlob(e))throw new Ah("Blob is not supported. Use a Buffer instead.");return Ph.isArrayBuffer(e)||Ph.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,s,r){let o=e;if(e&&!r&&"object"==typeof e)if(Ph.endsWith(s,"{}"))s=n?s:s.slice(0,-2),e=JSON.stringify(e);else if(Ph.isArray(e)&&function(e){return Ph.isArray(e)&&!e.some(Dh)}(e)||(Ph.isFileList(e)||Ph.endsWith(s,"[]"))&&(o=Ph.toArray(e)))return s=$h(s),o.forEach(function(e,n){!Ph.isUndefined(e)&&null!==e&&t.append(!0===i?Oh([s],n,a):null===i?s:s+"[]",l(e))}),!1;return!!Dh(e)||(t.append(Oh(r,s,a),l(e)),!1)}const d=[],u=Object.assign(Fh,{defaultVisitor:c,convertValue:l,isVisitable:Dh});if(!Ph.isObject(e))throw new TypeError("data must be an object");return function e(s,n){if(!Ph.isUndefined(s)){if(-1!==d.indexOf(s))throw Error("Circular reference detected in "+n.join("."));d.push(s),Ph.forEach(s,function(s,a){!0===(!(Ph.isUndefined(s)||null===s)&&r.call(t,s,Ph.isString(a)?a.trim():a,n,u))&&e(s,n?n.concat(a):[a])}),d.pop()}}(e),t}function Lh(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ih(e,t){this._pairs=[],e&&zh(e,this,t)}const _h=Ih.prototype;function Vh(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Bh(e,t,s){if(!t)return e;const n=s&&s.encode||Vh;Ph.isFunction(s)&&(s={serialize:s});const r=s&&s.serialize;let a;if(a=r?r(t,s):Ph.isURLSearchParams(t)?t.toString():new Ih(t,s).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}_h.append=function(e,t){this._pairs.push([e,t])},_h.toString=function(e){const t=e?function(t){return e.call(this,t,Lh)}:Lh;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class qh{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ph.forEach(this.handlers,function(t){null!==t&&e(t)})}}const Uh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wh={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ih,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},Hh="undefined"!=typeof window&&"undefined"!=typeof document,Kh="object"==typeof navigator&&navigator||void 0,Yh=Hh&&(!Kh||["ReactNative","NativeScript","NS"].indexOf(Kh.product)<0),Qh="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Gh=Hh&&window.location.href||"http://localhost",Jh={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Hh,hasStandardBrowserEnv:Yh,hasStandardBrowserWebWorkerEnv:Qh,navigator:Kh,origin:Gh},Symbol.toStringTag,{value:"Module"})),...Wh};function Xh(e){function t(e,s,n,r){let a=e[r++];if("__proto__"===a)return!0;const i=Number.isFinite(+a),o=r>=e.length;if(a=!a&&Ph.isArray(n)?n.length:a,o)return Ph.hasOwnProp(n,a)?n[a]=[n[a],s]:n[a]=s,!i;n[a]&&Ph.isObject(n[a])||(n[a]=[]);return t(e,s,n[a],r)&&Ph.isArray(n[a])&&(n[a]=function(e){const t={},s=Object.keys(e);let n;const r=s.length;let a;for(n=0;n<r;n++)a=s[n],t[a]=e[a];return t}(n[a])),!i}if(Ph.isFormData(e)&&Ph.isFunction(e.entries)){const s={};return Ph.forEachEntry(e,(e,n)=>{t(function(e){return Ph.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,s,0)}),s}return null}const Zh={transitional:Uh,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",n=s.indexOf("application/json")>-1,r=Ph.isObject(e);r&&Ph.isHTMLForm(e)&&(e=new FormData(e));if(Ph.isFormData(e))return n?JSON.stringify(Xh(e)):e;if(Ph.isArrayBuffer(e)||Ph.isBuffer(e)||Ph.isStream(e)||Ph.isFile(e)||Ph.isBlob(e)||Ph.isReadableStream(e))return e;if(Ph.isArrayBufferView(e))return e.buffer;if(Ph.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(r){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return zh(e,new Jh.classes.URLSearchParams,{visitor:function(e,t,s,n){return Jh.isNode&&Ph.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((a=Ph.isFileList(e))||s.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return zh(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),function(e,t,s){if(Ph.isString(e))try{return(t||JSON.parse)(e),Ph.trim(e)}catch(n){if("SyntaxError"!==n.name)throw n}return(s||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Zh.transitional,s=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Ph.isResponse(e)||Ph.isReadableStream(e))return e;if(e&&Ph.isString(e)&&(s&&!this.responseType||n)){const s=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(r){if(s){if("SyntaxError"===r.name)throw Ah.from(r,Ah.ERR_BAD_RESPONSE,this,null,this.response);throw r}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Jh.classes.FormData,Blob:Jh.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ph.forEach(["delete","get","head","post","put","patch"],e=>{Zh.headers[e]={}});const em=Ph.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tm=Symbol("internals");function sm(e){return e&&String(e).trim().toLowerCase()}function nm(e){return!1===e||null==e?e:Ph.isArray(e)?e.map(nm):String(e)}function rm(e,t,s,n,r){return Ph.isFunction(n)?n.call(this,t,s):(r&&(t=s),Ph.isString(t)?Ph.isString(n)?-1!==t.indexOf(n):Ph.isRegExp(n)?n.test(t):void 0:void 0)}let am=class{constructor(e){e&&this.set(e)}set(e,t,s){const n=this;function r(e,t,s){const r=sm(t);if(!r)throw new Error("header name must be a non-empty string");const a=Ph.findKey(n,r);(!a||void 0===n[a]||!0===s||void 0===s&&!1!==n[a])&&(n[a||t]=nm(e))}const a=(e,t)=>Ph.forEach(e,(e,s)=>r(e,s,t));if(Ph.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(Ph.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))a((e=>{const t={};let s,n,r;return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),s=e.substring(0,r).trim().toLowerCase(),n=e.substring(r+1).trim(),!s||t[s]&&em[s]||("set-cookie"===s?t[s]?t[s].push(n):t[s]=[n]:t[s]=t[s]?t[s]+", "+n:n)}),t})(e),t);else if(Ph.isObject(e)&&Ph.isIterable(e)){let s,n,r={};for(const t of e){if(!Ph.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[n=t[0]]=(s=r[n])?Ph.isArray(s)?[...s,t[1]]:[s,t[1]]:t[1]}a(r,t)}else null!=e&&r(t,e,s);return this}get(e,t){if(e=sm(e)){const s=Ph.findKey(this,e);if(s){const e=this[s];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=s.exec(e);)t[n[1]]=n[2];return t}(e);if(Ph.isFunction(t))return t.call(this,e,s);if(Ph.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=sm(e)){const s=Ph.findKey(this,e);return!(!s||void 0===this[s]||t&&!rm(0,this[s],s,t))}return!1}delete(e,t){const s=this;let n=!1;function r(e){if(e=sm(e)){const r=Ph.findKey(s,e);!r||t&&!rm(0,s[r],r,t)||(delete s[r],n=!0)}}return Ph.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let s=t.length,n=!1;for(;s--;){const r=t[s];e&&!rm(0,this[r],r,e,!0)||(delete this[r],n=!0)}return n}normalize(e){const t=this,s={};return Ph.forEach(this,(n,r)=>{const a=Ph.findKey(s,r);if(a)return t[a]=nm(n),void delete t[r];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}(r):String(r).trim();i!==r&&delete t[r],t[i]=nm(n),s[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ph.forEach(this,(s,n)=>{null!=s&&!1!==s&&(t[n]=e&&Ph.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(e=>s.set(e)),s}static accessor(e){const t=(this[tm]=this[tm]={accessors:{}}).accessors,s=this.prototype;function n(e){const n=sm(e);t[n]||(!function(e,t){const s=Ph.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+s,{value:function(e,s,r){return this[n].call(this,t,e,s,r)},configurable:!0})})}(s,e),t[n]=!0)}return Ph.isArray(e)?e.forEach(n):n(e),this}};function im(e,t){const s=this||Zh,n=t||s,r=am.from(n.headers);let a=n.data;return Ph.forEach(e,function(e){a=e.call(s,a,r.normalize(),t?t.status:void 0)}),r.normalize(),a}function om(e){return!(!e||!e.__CANCEL__)}function lm(e,t,s){Ah.call(this,null==e?"canceled":e,Ah.ERR_CANCELED,t,s),this.name="CanceledError"}function cm(e,t,s){const n=s.config.validateStatus;s.status&&n&&!n(s.status)?t(new Ah("Request failed with status code "+s.status,[Ah.ERR_BAD_REQUEST,Ah.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}am.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ph.reduceDescriptors(am.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[s]=e}}}),Ph.freezeMethods(am),Ph.inherits(lm,Ah,{__CANCEL__:!0});const dm=(e,t,s=3)=>{let n=0;const r=function(e,t){e=e||10;const s=new Array(e),n=new Array(e);let r,a=0,i=0;return t=void 0!==t?t:1e3,function(o){const l=Date.now(),c=n[i];r||(r=l),s[a]=o,n[a]=l;let d=i,u=0;for(;d!==a;)u+=s[d++],d%=e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),l-r<t)return;const h=c&&l-c;return h?Math.round(1e3*u/h):void 0}}(50,250);return function(e,t){let s,n,r=0,a=1e3/t;const i=(t,a=Date.now())=>{r=a,s=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),o=t-r;o>=a?i(e,t):(s=e,n||(n=setTimeout(()=>{n=null,i(s)},a-o)))},()=>s&&i(s)]}(s=>{const a=s.loaded,i=s.lengthComputable?s.total:void 0,o=a-n,l=r(o);n=a;e({loaded:a,total:i,progress:i?a/i:void 0,bytes:o,rate:l||void 0,estimated:l&&i&&a<=i?(i-a)/l:void 0,event:s,lengthComputable:null!=i,[t?"download":"upload"]:!0})},s)},um=(e,t)=>{const s=null!=e;return[n=>t[0]({lengthComputable:s,total:e,loaded:n}),t[1]]},hm=e=>(...t)=>Ph.asap(()=>e(...t)),mm=Jh.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,Jh.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(Jh.origin),Jh.navigator&&/(msie|trident)/i.test(Jh.navigator.userAgent)):()=>!0,pm=Jh.hasStandardBrowserEnv?{write(e,t,s,n,r,a){const i=[e+"="+encodeURIComponent(t)];Ph.isNumber(s)&&i.push("expires="+new Date(s).toGMTString()),Ph.isString(n)&&i.push("path="+n),Ph.isString(r)&&i.push("domain="+r),!0===a&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function fm(e,t,s){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==s)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const gm=e=>e instanceof am?{...e}:e;function ym(e,t){t=t||{};const s={};function n(e,t,s,n){return Ph.isPlainObject(e)&&Ph.isPlainObject(t)?Ph.merge.call({caseless:n},e,t):Ph.isPlainObject(t)?Ph.merge({},t):Ph.isArray(t)?t.slice():t}function r(e,t,s,r){return Ph.isUndefined(t)?Ph.isUndefined(e)?void 0:n(void 0,e,0,r):n(e,t,0,r)}function a(e,t){if(!Ph.isUndefined(t))return n(void 0,t)}function i(e,t){return Ph.isUndefined(t)?Ph.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(s,r,a){return a in t?n(s,r):a in e?n(void 0,s):void 0}const l={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:o,headers:(e,t,s)=>r(gm(e),gm(t),0,!0)};return Ph.forEach(Object.keys({...e,...t}),function(n){const a=l[n]||r,i=a(e[n],t[n],n);Ph.isUndefined(i)&&a!==o||(s[n]=i)}),s}const xm=e=>{const t=ym({},e);let{data:s,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:a,headers:i,auth:o}=t;if(t.headers=i=am.from(i),t.url=Bh(fm(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&i.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Ph.isFormData(s))if(Jh.hasStandardBrowserEnv||Jh.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Ph.isFunction(s.getHeaders)){const e=s.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,s])=>{t.includes(e.toLowerCase())&&i.set(e,s)})}if(Jh.hasStandardBrowserEnv&&(n&&Ph.isFunction(n)&&(n=n(t)),n||!1!==n&&mm(t.url))){const e=r&&a&&pm.read(a);e&&i.set(r,e)}return t},vm="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,s){const n=xm(e);let r=n.data;const a=am.from(n.headers).normalize();let i,o,l,c,d,{responseType:u,onUploadProgress:h,onDownloadProgress:m}=n;function p(){c&&c(),d&&d(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let f=new XMLHttpRequest;function g(){if(!f)return;const n=am.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());cm(function(e){t(e),p()},function(e){s(e),p()},{data:u&&"text"!==u&&"json"!==u?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f}),f=null}f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(s(new Ah("Request aborted",Ah.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const n=new Ah(t&&t.message?t.message:"Network Error",Ah.ERR_NETWORK,e,f);n.event=t||null,s(n),f=null},f.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||Uh;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),s(new Ah(t,r.clarifyTimeoutError?Ah.ETIMEDOUT:Ah.ECONNABORTED,e,f)),f=null},void 0===r&&a.setContentType(null),"setRequestHeader"in f&&Ph.forEach(a.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Ph.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),u&&"json"!==u&&(f.responseType=n.responseType),m&&([l,d]=dm(m,!0),f.addEventListener("progress",l)),h&&f.upload&&([o,c]=dm(h),f.upload.addEventListener("progress",o),f.upload.addEventListener("loadend",c)),(n.cancelToken||n.signal)&&(i=t=>{f&&(s(!t||t.type?new lm(null,e,f):t),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);y&&-1===Jh.protocols.indexOf(y)?s(new Ah("Unsupported protocol "+y+":",Ah.ERR_BAD_REQUEST,e)):f.send(r||null)})},bm=(e,t)=>{const{length:s}=e=e?e.filter(Boolean):[];if(t||s){let s,n=new AbortController;const r=function(e){if(!s){s=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Ah?t:new lm(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,r(new Ah(`timeout ${t} of ms exceeded`,Ah.ETIMEDOUT))},t);const i=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)}),e=null)};e.forEach(e=>e.addEventListener("abort",r));const{signal:o}=n;return o.unsubscribe=()=>Ph.asap(i),o}},wm=function*(e,t){let s=e.byteLength;if(s<t)return void(yield e);let n,r=0;for(;r<s;)n=r+t,yield e.slice(r,n),r=n},Sm=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{await t.cancel()}},jm=(e,t,s,n)=>{const r=async function*(e,t){for await(const s of Sm(e))yield*wm(s,t)}(e,t);let a,i=0,o=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await r.next();if(t)return o(),void e.close();let a=n.byteLength;if(s){let e=i+=a;s(e)}e.enqueue(new Uint8Array(n))}catch(t){throw o(t),t}},cancel:e=>(o(e),r.return())},{highWaterMark:2})},{isFunction:km}=Ph,Nm=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ph.global),{ReadableStream:Em,TextEncoder:Cm}=Ph.global,Tm=(e,...t)=>{try{return!!e(...t)}catch(s){return!1}},Pm=e=>{e=Ph.merge.call({skipUndefined:!0},Nm,e);const{fetch:t,Request:s,Response:n}=e,r=t?km(t):"function"==typeof fetch,a=km(s),i=km(n);if(!r)return!1;const o=r&&km(Em),l=r&&("function"==typeof Cm?(e=>t=>e.encode(t))(new Cm):async e=>new Uint8Array(await new s(e).arrayBuffer())),c=a&&o&&Tm(()=>{let e=!1;const t=new s(Jh.origin,{body:new Em,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=i&&o&&Tm(()=>Ph.isReadableStream(new n("").body)),u={stream:d&&(e=>e.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!u[e]&&(u[e]=(t,s)=>{let n=t&&t[e];if(n)return n.call(t);throw new Ah(`Response type '${e}' is not supported`,Ah.ERR_NOT_SUPPORT,s)})});const h=async(e,t)=>{const n=Ph.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Ph.isBlob(e))return e.size;if(Ph.isSpecCompliantForm(e)){const t=new s(Jh.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ph.isArrayBufferView(e)||Ph.isArrayBuffer(e)?e.byteLength:(Ph.isURLSearchParams(e)&&(e+=""),Ph.isString(e)?(await l(e)).byteLength:void 0)})(t):n};return async e=>{let{url:r,method:i,data:o,signal:l,cancelToken:m,timeout:p,onDownloadProgress:f,onUploadProgress:g,responseType:y,headers:x,withCredentials:v="same-origin",fetchOptions:b}=xm(e),w=t||fetch;y=y?(y+"").toLowerCase():"text";let S=bm([l,m&&m.toAbortSignal()],p),j=null;const k=S&&S.unsubscribe&&(()=>{S.unsubscribe()});let N;try{if(g&&c&&"get"!==i&&"head"!==i&&0!==(N=await h(x,o))){let e,t=new s(r,{method:"POST",body:o,duplex:"half"});if(Ph.isFormData(o)&&(e=t.headers.get("content-type"))&&x.setContentType(e),t.body){const[e,s]=um(N,dm(hm(g)));o=jm(t.body,65536,e,s)}}Ph.isString(v)||(v=v?"include":"omit");const t=a&&"credentials"in s.prototype,l={...b,signal:S,method:i.toUpperCase(),headers:x.normalize().toJSON(),body:o,duplex:"half",credentials:t?v:void 0};j=a&&new s(r,l);let m=await(a?w(j,b):w(r,l));const p=d&&("stream"===y||"response"===y);if(d&&(f||p&&k)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=m[t]});const t=Ph.toFiniteNumber(m.headers.get("content-length")),[s,r]=f&&um(t,dm(hm(f),!0))||[];m=new n(jm(m.body,65536,s,()=>{r&&r(),k&&k()}),e)}y=y||"text";let E=await u[Ph.findKey(u,y)||"text"](m,e);return!p&&k&&k(),await new Promise((t,s)=>{cm(t,s,{data:E,headers:am.from(m.headers),status:m.status,statusText:m.statusText,config:e,request:j})})}catch(E){if(k&&k(),E&&"TypeError"===E.name&&/Load failed|fetch/i.test(E.message))throw Object.assign(new Ah("Network Error",Ah.ERR_NETWORK,e,j),{cause:E.cause||E});throw Ah.from(E,E&&E.code,e,j)}}},Am=new Map,Rm=e=>{let t=e?e.env:{};const{fetch:s,Request:n,Response:r}=t,a=[n,r,s];let i,o,l=a.length,c=Am;for(;l--;)i=a[l],o=c.get(i),void 0===o&&c.set(i,o=l?new Map:Pm(t)),c=o;return o};Rm();const Mm={http:null,xhr:vm,fetch:{get:Rm}};Ph.forEach(Mm,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(s){}Object.defineProperty(e,"adapterName",{value:t})}});const Dm=e=>`- ${e}`,$m=e=>Ph.isFunction(e)||null===e||!1===e,Om=(e,t)=>{e=Ph.isArray(e)?e:[e];const{length:s}=e;let n,r;const a={};for(let i=0;i<s;i++){let s;if(n=e[i],r=n,!$m(n)&&(r=Mm[(s=String(n)).toLowerCase()],void 0===r))throw new Ah(`Unknown adapter '${s}'`);if(r&&(Ph.isFunction(r)||(r=r.get(t))))break;a[s||"#"+i]=r}if(!r){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Ah("There is no suitable adapter to dispatch the request "+(s?e.length>1?"since :\n"+e.map(Dm).join("\n"):" "+Dm(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Fm(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lm(null,e)}function zm(e){Fm(e),e.headers=am.from(e.headers),e.data=im.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Om(e.adapter||Zh.adapter,e)(e).then(function(t){return Fm(e),t.data=im.call(e,e.transformResponse,t),t.headers=am.from(t.headers),t},function(t){return om(t)||(Fm(e),t&&t.response&&(t.response.data=im.call(e,e.transformResponse,t.response),t.response.headers=am.from(t.response.headers))),Promise.reject(t)})}const Lm="1.12.2",Im={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Im[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const _m={};Im.transitional=function(e,t,s){function n(e,t){return"[Axios v"+Lm+"] Transitional option '"+e+"'"+t+(s?". "+s:"")}return(s,r,a)=>{if(!1===e)throw new Ah(n(r," has been removed"+(t?" in "+t:"")),Ah.ERR_DEPRECATED);return t&&!_m[r]&&(_m[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(s,r,a)}},Im.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};const Vm={assertOptions:function(e,t,s){if("object"!=typeof e)throw new Ah("options must be an object",Ah.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;for(;r-- >0;){const a=n[r],i=t[a];if(i){const t=e[a],s=void 0===t||i(t,a,e);if(!0!==s)throw new Ah("option "+a+" must be "+s,Ah.ERR_BAD_OPTION_VALUE);continue}if(!0!==s)throw new Ah("Unknown option "+a,Ah.ERR_BAD_OPTION)}},validators:Im},Bm=Vm.validators;let qm=class{constructor(e){this.defaults=e||{},this.interceptors={request:new qh,response:new qh}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{s.stack?t&&!String(s.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(s.stack+="\n"+t):s.stack=t}catch(n){}}throw s}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ym(this.defaults,t);const{transitional:s,paramsSerializer:n,headers:r}=t;void 0!==s&&Vm.assertOptions(s,{silentJSONParsing:Bm.transitional(Bm.boolean),forcedJSONParsing:Bm.transitional(Bm.boolean),clarifyTimeoutError:Bm.transitional(Bm.boolean)},!1),null!=n&&(Ph.isFunction(n)?t.paramsSerializer={serialize:n}:Vm.assertOptions(n,{encode:Bm.function,serialize:Bm.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Vm.assertOptions(t,{baseUrl:Bm.spelling("baseURL"),withXsrfToken:Bm.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=r&&Ph.merge(r.common,r[t.method]);r&&Ph.forEach(["delete","get","head","post","put","patch","common"],e=>{delete r[e]}),t.headers=am.concat(a,r);const i=[];let o=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let d,u=0;if(!o){const e=[zm.bind(this),void 0];for(e.unshift(...i),e.push(...l),d=e.length,c=Promise.resolve(t);u<d;)c=c.then(e[u++],e[u++]);return c}d=i.length;let h=t;for(;u<d;){const e=i[u++],t=i[u++];try{h=e(h)}catch(m){t.call(this,m);break}}try{c=zm.call(this,h)}catch(m){return Promise.reject(m)}for(u=0,d=l.length;u<d;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Bh(fm((e=ym(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ph.forEach(["delete","get","head","options"],function(e){qm.prototype[e]=function(t,s){return this.request(ym(s||{},{method:e,url:t,data:(s||{}).data}))}}),Ph.forEach(["post","put","patch"],function(e){function t(t){return function(s,n,r){return this.request(ym(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:n}))}}qm.prototype[e]=t(),qm.prototype[e+"Form"]=t(!0)});const Um={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Um).forEach(([e,t])=>{Um[t]=e});const Wm=function e(t){const s=new qm(t),n=Vu(qm.prototype.request,s);return Ph.extend(n,qm.prototype,s,{allOwnKeys:!0}),Ph.extend(n,s,null,{allOwnKeys:!0}),n.create=function(s){return e(ym(t,s))},n}(Zh);Wm.Axios=qm,Wm.CanceledError=lm,Wm.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const s=this;this.promise.then(e=>{if(!s._listeners)return;let t=s._listeners.length;for(;t-- >0;)s._listeners[t](e);s._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{s.subscribe(e),t=e}).then(e);return n.cancel=function(){s.unsubscribe(t)},n},e(function(e,n,r){s.reason||(s.reason=new lm(e,n,r),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},Wm.isCancel=om,Wm.VERSION=Lm,Wm.toFormData=zh,Wm.AxiosError=Ah,Wm.Cancel=Wm.CanceledError,Wm.all=function(e){return Promise.all(e)},Wm.spread=function(e){return function(t){return e.apply(null,t)}},Wm.isAxiosError=function(e){return Ph.isObject(e)&&!0===e.isAxiosError},Wm.mergeConfig=ym,Wm.AxiosHeaders=am,Wm.formToJSON=e=>Xh(Ph.isHTMLForm(e)?new FormData(e):e),Wm.getAdapter=Om,Wm.HttpStatusCode=Um,Wm.default=Wm;const{Axios:Hm,AxiosError:Km,CanceledError:Ym,isCancel:Qm,CancelToken:Gm,VERSION:Jm,all:Xm,Cancel:Zm,isAxiosError:ep,spread:tp,toFormData:sp,AxiosHeaders:np,HttpStatusCode:rp,formToJSON:ap,getAdapter:ip,mergeConfig:op}=Wm;class lp extends Error{}function cp(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(t)}catch(s){return atob(t)}}function dp(e,t){if("string"!=typeof e)throw new lp("Invalid token specified: must be a string");t||(t={});const s=!0===t.header?0:1,n=e.split(".")[s];if("string"!=typeof n)throw new lp(`Invalid token specified: missing part #${s+1}`);let r;try{r=cp(n)}catch(a){throw new lp(`Invalid token specified: invalid base64 for part #${s+1} (${a.message})`)}try{return JSON.parse(r)}catch(a){throw new lp(`Invalid token specified: invalid json for part #${s+1} (${a.message})`)}}lp.prototype.name="InvalidTokenError";const up="pangents_bearer_token",hp="pangents_refresh_token",mp="pangents_token_expiry",pp=()=>{try{return localStorage.getItem(up)}catch(e){return console.error("[Token Storage] Failed to get access token:",e),null}},fp=()=>{try{return localStorage.getItem(hp)}catch(e){return console.error("[Token Storage] Failed to get refresh token:",e),null}},gp=(e,t)=>{try{localStorage.setItem(up,e),t&&localStorage.setItem(hp,t);const s=dp(e);localStorage.setItem(mp,s.exp.toString()),console.log("[Token Storage] Tokens stored successfully")}catch(s){console.error("[Token Storage] Failed to store tokens:",s)}},yp=e=>{try{localStorage.setItem(up,e);const t=dp(e);localStorage.setItem(mp,t.exp.toString()),console.log("[Token Storage] Bearer token stored successfully")}catch(t){console.error("[Token Storage] Failed to store bearer token:",t),localStorage.setItem(up,e)}},xp=()=>{try{localStorage.removeItem(up),localStorage.removeItem(hp),localStorage.removeItem(mp),console.log("[Token Storage] Tokens cleared successfully")}catch(e){console.error("[Token Storage] Failed to clear tokens:",e)}},vp=e=>{try{const t=e||pp();if(!t)return!0;const s=dp(t),n=Date.now()/1e3;return s.exp<n+300}catch(t){return console.error("[Token Validation] Failed to check token expiry:",t),!0}},bp=()=>{try{const e=localStorage.getItem(mp);return e?parseInt(e,10):null}catch(e){return console.error("[Token Storage] Failed to get token expiry:",e),null}},wp=async()=>{try{const e=fp();if(!e)throw new Error("No refresh token available");if(vp(e))throw new Error("Refresh token is expired");const{api:t}=await Promise.resolve().then(()=>Dp),s=await t.post("/auth/refresh",{refreshToken:e}),{accessToken:n,refreshToken:r}=s.data;if(n&&r)return gp(n,r),console.log("[Token Refresh] Tokens refreshed successfully"),n;throw new Error("Invalid refresh response")}catch(e){return console.error("[Token Refresh] Failed to refresh tokens:",e),xp(),null}};let Sp=null;const jp=()=>{const e=()=>{const t=bp();if(!t)return;const s=t-Date.now()/1e3,n=Math.max(0,1e3*(s-600));Sp&&clearTimeout(Sp),Sp=setTimeout(async()=>{console.log("[Auto Refresh] Attempting to refresh tokens");await wp()?e():window.dispatchEvent(new CustomEvent("auth:logout",{detail:{reason:"auto_refresh_failed"}}))},n),console.log(`[Auto Refresh] Scheduled for ${new Date(Date.now()+n).toISOString()}`)};e()},kp=Object.freeze(Object.defineProperty({__proto__:null,clearAutoRefresh:()=>{Sp&&(clearTimeout(Sp),Sp=null,console.log("[Auto Refresh] Cleared refresh timer"))},clearTokens:xp,getAccessToken:pp,getRefreshToken:fp,getTokenExpiry:bp,isTokenExpired:vp,refreshAccessToken:wp,setBearerToken:yp,setTokens:gp,setupAutoRefresh:jp},Symbol.toStringTag,{value:"Module"}));class Np{constructor(){Ce(this,"failures",0),Ce(this,"lastFailureTime",0),Ce(this,"state","closed"),Ce(this,"failureThreshold",5),Ce(this,"recoveryTimeout",6e4),Ce(this,"halfOpenMaxCalls",3),Ce(this,"halfOpenCalls",0)}canExecute(){const e=Date.now();switch(this.state){case"closed":return!0;case"open":return e-this.lastFailureTime>=this.recoveryTimeout&&(this.state="half-open",this.halfOpenCalls=0,!0);case"half-open":return this.halfOpenCalls<this.halfOpenMaxCalls;default:return!1}}onSuccess(){this.failures=0,this.state="closed",this.halfOpenCalls=0}onFailure(){this.failures++,this.lastFailureTime=Date.now(),"half-open"===this.state?(this.state="open",this.halfOpenCalls=0):this.failures>=this.failureThreshold&&(this.state="open")}getState(){return this.state}}class Ep{constructor(){Ce(this,"requests",[]),Ce(this,"maxRequests",10),Ce(this,"windowMs",6e4)}canMakeRequest(){const e=Date.now();return this.requests=this.requests.filter(t=>e-t<this.windowMs),this.requests.length<this.maxRequests}recordRequest(){this.requests.push(Date.now())}getRemainingRequests(){const e=Date.now();return this.requests=this.requests.filter(t=>e-t<this.windowMs),Math.max(0,this.maxRequests-this.requests.length)}}const Cp=new class{constructor(){Ce(this,"errorQueue",[]),Ce(this,"isOnline",navigator.onLine),Ce(this,"maxQueueSize",50),Ce(this,"retryAttempts",2),Ce(this,"retryDelay",2e3),Ce(this,"circuitBreaker",new Np),Ce(this,"rateLimiter",new Ep),Ce(this,"reportingEnabled",!0),Ce(this,"duplicateErrorCache",new Map),Ce(this,"duplicateTimeWindow",3e4),this.setupEventListeners()}setupEventListeners(){window.addEventListener("online",()=>{this.isOnline=!0,this.flushErrorQueue()}),window.addEventListener("offline",()=>{this.isOnline=!1}),window.addEventListener("error",e=>{this.handleJavaScriptError(e.error,{component:"Global",action:"Runtime Error"})}),window.addEventListener("unhandledrejection",e=>{this.handleJavaScriptError(new Error(e.reason),{component:"Global",action:"Unhandled Promise Rejection"})})}async validateApiKeyBeforeRequest(e){return e?!(!e.startsWith("pangents_wk_")||e.length<20)||(console.warn("[Enhanced Error Handler] Invalid API key format"),!1):(console.warn("[Enhanced Error Handler] No API key provided for validation"),!1)}generateErrorFingerprint(e,t){return`${e.message}-${e.status}-${t.component}-${t.action}`}isDuplicateError(e){const t=Date.now(),s=this.duplicateErrorCache.get(e);if(s&&t-s<this.duplicateTimeWindow)return!0;this.duplicateErrorCache.set(e,t);for(const[n,r]of this.duplicateErrorCache.entries())t-r>this.duplicateTimeWindow&&this.duplicateErrorCache.delete(n);return!1}handleApiError(e,t){var s,n,r,a,i;const o={message:e.message||"An unexpected error occurred",status:e.status||(null==(s=e.response)?void 0:s.status)||0,code:e.code||(null==(r=null==(n=e.response)?void 0:n.data)?void 0:r.code),details:(null==(i=null==(a=e.response)?void 0:a.data)?void 0:i.details)||e.details,timestamp:(new Date).toISOString()},l={component:(null==t?void 0:t.component)||"Unknown",action:(null==t?void 0:t.action)||"Unknown",userId:null==t?void 0:t.userId,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,apiKey:(null==t?void 0:t.apiKey)?t.apiKey.substring(0,20)+"...":void 0},c=this.determineSeverity(o),d={error:o,context:l,stack:e.stack,severity:c},u=this.generateErrorFingerprint(o,l);return this.isDuplicateError(u)?(console.log("[Enhanced Error Handler] Duplicate error detected, skipping report"),o):(this.reportError(d),this.showUserNotification(o,c),o)}handleJavaScriptError(e,t){const s={error:{message:e.message,status:0,code:"JAVASCRIPT_ERROR",details:{name:e.name},timestamp:(new Date).toISOString()},context:{component:(null==t?void 0:t.component)||"JavaScript",action:(null==t?void 0:t.action)||"Runtime",userId:null==t?void 0:t.userId,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href},stack:e.stack,severity:"medium"};this.reportError(s)}determineSeverity(e){return e.status>=500||"NETWORK_ERROR"===e.code?"critical":401===e.status||403===e.status||429===e.status?"high":e.status>=400&&e.status<500?"medium":"low"}async reportError(e){try{if(!this.reportingEnabled)return void console.log("[Enhanced Error Handler] Error reporting is disabled");if(!this.circuitBreaker.canExecute())return void console.warn("[Enhanced Error Handler] Circuit breaker is open, skipping error report");if(!this.rateLimiter.canMakeRequest())return void console.warn("[Enhanced Error Handler] Rate limit exceeded, skipping error report");if(this.errorQueue.push(e),this.errorQueue.length>this.maxQueueSize){const e=this.errorQueue.shift();console.warn("[Enhanced Error Handler] Queue full, removed oldest error:",null==e?void 0:e.error.message)}this.isOnline&&await this.flushErrorQueue()}catch(t){console.error("[Enhanced Error Handler] Failed to report error:",t)}}async flushErrorQueue(){var e,t,s,n;if(0===this.errorQueue.length)return;if(!this.circuitBreaker.canExecute())return void console.warn("[Enhanced Error Handler] Circuit breaker prevents error reporting");const r=[...this.errorQueue];this.errorQueue=[];for(let i=1;i<=this.retryAttempts;i++)try{const s=null==(t=null==(e=r[0])?void 0:e.context)?void 0:t.apiKey;if(!(await this.validateApiKeyBeforeRequest(s)))return console.warn("[Enhanced Error Handler] Invalid API key, skipping error report"),void this.circuitBreaker.onFailure();if(!this.rateLimiter.canMakeRequest())return console.warn("[Enhanced Error Handler] Rate limit exceeded during flush"),void this.errorQueue.unshift(...r);this.rateLimiter.recordRequest();const{api:n}=await Promise.resolve().then(()=>Dp);return await n.post("/errors/report",{errors:r,clientInfo:{userAgent:navigator.userAgent,timestamp:(new Date).toISOString(),url:window.location.href,circuitBreakerState:this.circuitBreaker.getState(),remainingRateLimit:this.rateLimiter.getRemainingRequests()}},{timeout:15e3}),console.log(`[Enhanced Error Handler] Successfully reported ${r.length} errors`),void this.circuitBreaker.onSuccess()}catch(a){if(console.warn(`[Enhanced Error Handler] Failed to send errors (attempt ${i}):`,a),401===(null==(s=a.response)?void 0:s.status)||403===(null==(n=a.response)?void 0:n.status))return console.error("[Enhanced Error Handler] Authentication error, stopping retries"),void this.circuitBreaker.onFailure();if(i===this.retryAttempts){this.circuitBreaker.onFailure();const e=r.filter(e=>"critical"===e.severity);e.length>0&&(this.errorQueue.unshift(...e),console.error(`[Enhanced Error Handler] Re-queued ${e.length} critical errors`)),console.error("[Enhanced Error Handler] All retry attempts failed")}else await new Promise(e=>setTimeout(e,this.retryDelay*Math.pow(2,i-1)))}}showUserNotification(e,t){const s=this.getUserFriendlyMessage(e);window.dispatchEvent(new CustomEvent("error:notification",{detail:{message:s,severity:t,error:e,timestamp:(new Date).toISOString(),canRetry:this.canRetryError(e)}}))}canRetryError(e){return 401!==e.status&&403!==e.status&&!(e.status>=400&&e.status<500&&429!==e.status)}getUserFriendlyMessage(e){switch(e.status){case 400:return"Please check your input and try again.";case 401:return"Invalid API key. Please check your credentials.";case 403:return"Access denied. Please check your API key permissions.";case 404:return"The requested resource was not found.";case 422:return"Please check your data and try again.";case 429:return"Too many requests. Please wait a moment and try again.";case 500:return"A server error occurred. Our team has been notified.";case 503:return"The service is temporarily unavailable. Please try again later.";default:return"NETWORK_ERROR"===e.code?"Network connection error. Please check your internet connection.":e.message||"An unexpected error occurred."}}enableReporting(){this.reportingEnabled=!0,console.log("[Enhanced Error Handler] Error reporting enabled")}disableReporting(){this.reportingEnabled=!1,console.log("[Enhanced Error Handler] Error reporting disabled")}getQueueSize(){return this.errorQueue.length}getCircuitBreakerState(){return this.circuitBreaker.getState()}getRemainingRateLimit(){return this.rateLimiter.getRemainingRequests()}clearQueue(){this.errorQueue=[],console.log("[Enhanced Error Handler] Error queue cleared")}async forceFlush(){await this.flushErrorQueue()}};const Tp=new class{formatResponse(e){return e&&"object"==typeof e&&"success"in e?e:{success:!0,data:e,message:"Request completed successfully",status:200,timestamp:(new Date).toISOString()}}formatPaginatedResponse(e,t){const s=t.totalPages||Math.ceil(t.total/t.limit);return{success:!0,data:e,pagination:{page:t.page,limit:t.limit,total:t.total,totalPages:s,hasNext:t.page<s,hasPrev:t.page>1},message:"Request completed successfully",status:200,timestamp:(new Date).toISOString()}}formatErrorResponse(e){return{success:!1,data:null,error:{message:e.message||"An error occurred",status:e.status||500,code:e.code,details:e.details,timestamp:(new Date).toISOString()},message:e.message||"Request failed",status:e.status||500,timestamp:(new Date).toISOString()}}transformResponseData(e){if(null==e)return e;if(Array.isArray(e))return e.map(e=>this.transformResponseData(e));if("object"==typeof e&&e.constructor===Object){const t={};for(const[s,n]of Object.entries(e)){t[this.toCamelCase(s)]=this.transformResponseData(n)}return t}return e}transformRequestData(e){if(null==e)return e;if(Array.isArray(e))return e.map(e=>this.transformRequestData(e));if("object"==typeof e&&e.constructor===Object){const t={};for(const[s,n]of Object.entries(e)){t[this.toSnakeCase(s)]=this.transformRequestData(n)}return t}return e}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}toSnakeCase(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}validateResponse(e){return"object"==typeof e&&null!==e&&"boolean"==typeof e.success&&"data"in e&&"message"in e&&"timestamp"in e}validatePaginatedResponse(e){return this.validateResponse(e)&&"pagination"in e&&"object"==typeof e.pagination&&null!==e.pagination&&"page"in e.pagination&&"limit"in e.pagination&&"total"in e.pagination&&"number"==typeof e.pagination.page&&"number"==typeof e.pagination.limit&&"number"==typeof e.pagination.total}extractData(e){var t;if(!e.success)throw new Error((null==(t=e.error)?void 0:t.message)||"Request failed");return e.data}extractPaginatedData(e){var t;if(!e.success)throw new Error((null==(t=e.error)?void 0:t.message)||"Request failed");return{data:e.data,pagination:e.pagination}}mergeResponses(e){const t=e.filter(e=>e.success),s=e.filter(e=>!e.success);return s.length>0?{success:!1,data:null,status:400,error:{message:`${s.length} out of ${e.length} requests failed`,status:400,code:"BATCH_PARTIAL_FAILURE",details:{successful:t.length,failed:s.length,errors:s.map(e=>e.error)},timestamp:(new Date).toISOString()},message:"Batch operation partially failed",timestamp:(new Date).toISOString()}:{success:!0,data:t.map(e=>e.data),status:200,message:`All ${e.length} requests completed successfully`,timestamp:(new Date).toISOString()}}createResponseWithMetadata(e,t={}){return{...this.formatResponse(e),metadata:t}}formatFileUploadResponse(e,t){return this.formatResponse({filename:t.filename||e.name,originalName:e.name,size:e.size,mimeType:e.type,url:t.url,id:t.id})}formatSearchResponse(e,t,s){return{...this.formatPaginatedResponse(e,s),filters:t}}},Pp=e=>Tp.transformRequestData(e),Ap=e=>{var t;return(e=>Tp.validateResponse(e))(e.data)||(e.data=(t=e.data,Tp.formatResponse(t))),e},Rp=Wm.create({baseURL:"https://dev.backend.pangents.deepfrog.ai/",timeout:1e4,headers:{"Content-Type":"application/json",Accept:"application/json"}});Rp.interceptors.request.use(e=>{var t,s;e=(e=>(e.data&&(e.data=Pp(e.data)),e.params&&(e.params=Pp(e.params)),e))(e);const n=pp();n&&e.headers&&(e.headers.Authorization=`Bearer ${n}`);const r=Gt.getApiKey();return r&&e.headers&&(e.headers.api_key=r,e.headers.request_origin="tenant"),e.metadata={...e.metadata,requestTime:Date.now(),url:e.url,method:null==(t=e.method)?void 0:t.toUpperCase()},"development"===process.env.NODE_ENV&&console.log(`🚀 API Request: ${null==(s=e.method)?void 0:s.toUpperCase()} ${e.url}`,{headers:e.headers,data:e.data,params:e.params}),e}),Rp.interceptors.response.use(e=>{var t,s;const n=null==(t=(e=Ap(e)).config.metadata)?void 0:t.requestTime,r=n?Date.now()-n:0;return"development"===process.env.NODE_ENV&&console.log(`✅ API Response: ${null==(s=e.config.method)?void 0:s.toUpperCase()} ${e.config.url}`,{status:e.status,responseTime:`${r}ms`,data:e.data}),e.metadata={...e.config.metadata,responseTime:r,status:e.status,timestamp:(new Date).toISOString()},e},async e=>{var t,s,n,r,a,i,o,l,c,d,u,h;const m=e.config,p=null==(t=null==m?void 0:m.metadata)?void 0:t.requestTime,f=p?Date.now()-p:0;if("development"===process.env.NODE_ENV&&console.error(`❌ API Error: ${null==(s=null==m?void 0:m.method)?void 0:s.toUpperCase()} ${null==m?void 0:m.url}`,{status:null==(n=e.response)?void 0:n.status,responseTime:`${f}ms`,message:e.message,data:null==(r=e.response)?void 0:r.data}),401===(null==(a=e.response)?void 0:a.status)&&!m._retry){m._retry=!0;try{const e=await wp();if(e&&m.headers){m.headers.Authorization=`Bearer ${e}`;return(await Promise.resolve().then(()=>Dp)).default.request(m)}}catch(y){console.error("[Token Refresh Failed]",y),xp(),window.dispatchEvent(new CustomEvent("auth:logout",{detail:{reason:"token_refresh_failed"}}))}}const g=((e,t)=>Cp.handleApiError(e,t))(e,{component:"API",action:`${null==(i=null==m?void 0:m.method)?void 0:i.toUpperCase()} ${null==m?void 0:m.url}`});return 401!==(null==(o=e.response)?void 0:o.status)&&403!==(null==(l=e.response)?void 0:l.status)||!(null==(c=null==m?void 0:m.headers)?void 0:c.api_key)||(console.warn("[API Key Invalid] Clearing stored API key"),Gt.clearApiKey(),window.dispatchEvent(new CustomEvent("api:key_invalid",{detail:{error:g,url:null==m?void 0:m.url}}))),401===(null==(d=e.response)?void 0:d.status)?window.dispatchEvent(new CustomEvent("auth:unauthorized",{detail:{error:g,url:null==m?void 0:m.url}})):403===(null==(u=e.response)?void 0:u.status)?window.dispatchEvent(new CustomEvent("auth:forbidden",{detail:{error:g,url:null==m?void 0:m.url}})):(null==(h=e.response)?void 0:h.status)>=500?window.dispatchEvent(new CustomEvent("api:server_error",{detail:{error:g,url:null==m?void 0:m.url}})):e.response||window.dispatchEvent(new CustomEvent("api:network_error",{detail:{error:g,url:null==m?void 0:m.url}})),Promise.reject(g)});Rp.defaults.transformRequest=[e=>e&&"object"==typeof e?Object.keys(e).reduce((t,s)=>(t[s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)]=e[s],t),{}):e,...Wm.defaults.transformRequest],Rp.defaults.transformResponse=[e=>e&&"object"==typeof e?Object.keys(e).reduce((t,s)=>(t[s.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())]=e[s],t),{}):e,...Wm.defaults.transformResponse];const Mp={get:(e,t)=>Rp.get(e,t),post:(e,t,s)=>Rp.post(e,t,s),put:(e,t,s)=>Rp.put(e,t,s),patch:(e,t,s)=>Rp.patch(e,t,s),delete:(e,t)=>Rp.delete(e,t),updateProfile:async e=>(await Rp.patch("/profile",e)).data,initiateWorkflow:async e=>(await Rp.post("/workflow/initiate",e)).data,createCall:async e=>(await Rp.post("/calls",e)).data,updateCall:async(e,t)=>(await Rp.patch(`/calls/${e}`,t)).data,deleteCall:async e=>{await Rp.delete(`/calls/${e}`)},searchCarriers:async e=>(await Rp.get("/carriers/search",{params:e})).data,bulkUpdateCalls:async(e,t)=>(await Rp.patch("/calls/bulk",{ids:e,data:t})).data,getWorkflowList:async(e=1,t=10)=>(await Rp.get("/workflow/list",{params:{page:e,page_size:t}})).data.data,deleteWorkflow:async e=>(await Mp.delete(`/workflow/${e}`)).data,getWorkflowStatus:async e=>(await Mp.get(`/workflow/status/${e}`)).data.data,enqueueCallQueue:async e=>(await Mp.post("/agents/livekit/queue/enqueue",{queue:e})).data,getQueueStatus:async e=>(await Mp.get(`/agents/livekit/queue/${e}/status`)).data},Dp=Object.freeze(Object.defineProperty({__proto__:null,api:Mp,default:Rp},Symbol.toStringTag,{value:"Module"}));function $p(e){return{id:e.id,tenantId:e.tenant_id,createdBy:e.created_by,shipperEmail:e.shipper_email,shipperName:e.shipper_name,shipperCompanyName:e.shipper_company_name,origin:e.origin,destination:e.destination,pickupTimestamp:e.pickup_timestamp,deliveryTimestamp:e.delivery_timestamp,loadType:e.load_type,modeOfService:e.mode_of_service,equipmentType:e.equipment_type,grossWeight:e.gross_weight,numberOfPallets:e.number_of_pallets,emailMessageId:e.email_message_id,emailConversationId:e.email_conversation_id,emailSubject:e.email_subject,senderEmail:e.sender_email,senderName:e.sender_name,receiverEmail:e.receiver_email,receivedDatetime:e.received_datetime,status:e.status,isDuplicate:e.is_duplicate,duplicateOf:e.duplicate_of,notes:e.notes,createdAt:e.created_at,updatedAt:e.updated_at}}class Op{static async getLeads(e={}){var t,s,n;try{const t={};e.page&&(t.page=e.page),e.size&&(t.size=e.size),e.search&&(t.search=e.search),e.status&&(t.status=e.status),e.date_filter&&(t.date_filter=e.date_filter);const s=(await Mp.get("/crm/public/leads/me",{params:t})).data;return{success:s.success,leads:s.leads.map($p),count:s.count,page:s.page,size:s.size}}catch(r){if(console.error("EmailLeadsService.getLeads error:",r),401===(null==(t=r.response)?void 0:t.status))throw new Error("Unauthorized. Please login again.");if(null==(n=null==(s=r.response)?void 0:s.data)?void 0:n.detail)throw new Error(r.response.data.detail);throw new Error("Failed to fetch email leads. Please try again.")}}static async getLeadById(e){var t;try{return $p((await Mp.get(`/crm/public/leads/${e}`)).data.lead)}catch(s){if(console.error("EmailLeadsService.getLeadById error:",s),404===(null==(t=s.response)?void 0:t.status))throw new Error("Lead not found.");throw new Error("Failed to fetch lead details.")}}}function Fp(e){return{id:e.id,tenantId:e.tenant_id,createdBy:e.created_by,messageId:e.message_id,conversationId:e.conversation_id,conversationIndex:e.conversation_index,senderEmail:e.sender_email,receiverEmail:e.receiver_email,subject:e.subject,receivedDatetime:e.received_datetime,bodyHtml:e.body_html,bodyText:e.body_text,category:e.category,classificationConfidence:e.classification_confidence,status:e.status,userId:e.user_id,metadata:e.metadata,referencedLeadId:e.referenced_lead_id,processedAt:e.processed_at,createdAt:e.created_at,updatedAt:e.updated_at}}class zp{static async getLeadEmails(e){var t,s,n,r;try{const t=(await Mp.get(`/crm/public/leads/emails/${e}`)).data;return{success:t.success,emails:t.emails.map(Fp),count:t.count}}catch(a){if(console.error("EmailConversationService.getLeadEmails error:",a),401===(null==(t=a.response)?void 0:t.status))throw new Error("Unauthorized. Please login again.");if(404===(null==(s=a.response)?void 0:s.status))throw new Error("Lead emails not found.");if(null==(r=null==(n=a.response)?void 0:n.data)?void 0:r.detail)throw new Error(a.response.data.detail);throw new Error("Failed to fetch lead emails. Please try again.")}}static async sendEmailReply(e,t,s,n){var r,a,i;try{const r={to:e.map(e=>({email:e})),conversation_id:t,subject:s,body_html:n},a=(await Mp.post("/crm/agents/email/send",r)).data;return{success:a.success,reply:a.reply,email:Fp(a.email)}}catch(o){if(console.error("EmailConversationService.sendEmailReply error:",o),401===(null==(r=o.response)?void 0:r.status))throw new Error("Unauthorized. Please login again.");if(null==(i=null==(a=o.response)?void 0:a.data)?void 0:i.detail)throw new Error(o.response.data.detail);throw new Error("Failed to send email. Please try again.")}}}const Lp={leads:[],totalCount:0,currentPage:1,pageSize:10,isLoading:!1,isPolling:!1,error:null,searchQuery:"",statusFilter:"",dateFilter:"all",newLeadsCount:0,hasNewLeads:!1,lastFetchedLeadIds:new Set,showNewLeadsAlert:!1,pollingIntervalId:null,isPollingEnabled:!1},Ip=Iu()(_u((e,t)=>({...Lp,fetchLeads:async s=>{const n=t();e({isLoading:!0,error:null});try{const t={page:(null==s?void 0:s.page)??n.currentPage,size:(null==s?void 0:s.size)??n.pageSize,search:(null==s?void 0:s.search)??(n.searchQuery||void 0),status:(null==s?void 0:s.status)??(n.statusFilter||void 0),date_filter:(null==s?void 0:s.date_filter)??("all"!==n.dateFilter?n.dateFilter:void 0)},r=await Op.getLeads(t),a=new Set(r.leads.map(e=>e.id));e({leads:r.leads,totalCount:r.count,currentPage:r.page,isLoading:!1,lastFetchedLeadIds:a})}catch(r){e({isLoading:!1,error:r.message||"Failed to fetch leads"})}},setPage:s=>{e({currentPage:s}),t().fetchLeads({page:s})},setPageSize:s=>{e({pageSize:s,currentPage:1}),t().fetchLeads({size:s,page:1})},setSearchQuery:t=>{e({searchQuery:t,currentPage:1})},setStatusFilter:s=>{e({statusFilter:s,currentPage:1}),t().fetchLeads({status:s,page:1})},setDateFilter:s=>{e({dateFilter:s,currentPage:1}),t().fetchLeads({date_filter:"all"!==s?s:void 0,page:1})},startPolling:()=>{if(t().pollingIntervalId)return;console.log("[EmailLeadsStore] Starting polling...");const s=setInterval(()=>{t().pollForNewLeads()},6e4);e({pollingIntervalId:s,isPollingEnabled:!0})},stopPolling:()=>{const s=t();s.pollingIntervalId&&(console.log("[EmailLeadsStore] Stopping polling..."),clearInterval(s.pollingIntervalId),e({pollingIntervalId:null,isPollingEnabled:!1}))},pollForNewLeads:async()=>{const s=t();if(s.isPolling||s.isLoading)return;const n=s.lastFetchedLeadIds.size>0;e({isPolling:!0});try{console.log("[EmailLeadsStore] Polling for new leads...");const t=await Op.getLeads({page:1,size:s.pageSize,search:s.searchQuery||void 0,status:s.statusFilter||void 0,date_filter:"all"!==s.dateFilter?s.dateFilter:void 0}),r=t.leads.map(e=>e.id),a=s.lastFetchedLeadIds,i=r.filter(e=>!a.has(e));i.length>0&&n?(console.log(`[EmailLeadsStore] Found ${i.length} new leads!`),e({newLeadsCount:i.length,hasNewLeads:!0,showNewLeadsAlert:!0,leads:t.leads,totalCount:t.count,lastFetchedLeadIds:new Set(r),isPolling:!1})):e({lastFetchedLeadIds:new Set(r),isPolling:!1})}catch(r){console.error("[EmailLeadsStore] Polling error:",r),e({isPolling:!1})}},clearNewLeadsNotification:()=>{e({newLeadsCount:0,hasNewLeads:!1,showNewLeadsAlert:!1})},acknowledgeNewLeads:()=>{e({showNewLeadsAlert:!1})},reset:()=>{const s=t();s.pollingIntervalId&&clearInterval(s.pollingIntervalId),e({...Lp,lastFetchedLeadIds:new Set})}})));function _p({position:e="bottom-right",margin:t}){const{openWidget:s,theme:n,isOpen:r,isAuthenticated:a}=ns(),{hasNewLeads:i,newLeadsCount:o,startPolling:l,stopPolling:c,clearNewLeadsNotification:d}=Ip();Oe.useEffect(()=>{if(a)return l(),()=>c()},[l,c,a]);return $e.jsx("div",{className:(()=>{switch(e){case"bottom-right":default:return"fixed bottom-6 right-6 z-50";case"bottom-left":return"fixed bottom-6 left-6 z-50";case"top-right":return"fixed top-6 right-6 z-50";case"top-left":return"fixed top-6 left-6 z-50"}})(),style:{margin:t||void 0},children:$e.jsxs("div",{className:"relative",children:[$e.jsxs(Ou,{onClick:()=>{console.log("WidgetBubble: Button clicked!"),s(),i&&d()},size:"lg",className:"widget-bubble-button h-16 w-16 rounded-full shadow-lg hover:shadow-xl transition-shadow duration-200 bg-pangents-gradient",style:{backgroundColor:n.primaryColor,fontFamily:n.fontFamily},children:[n.bubbleIcon?$e.jsx("img",{src:n.bubbleIcon,alt:"Chat icon",className:"h-16 w-16 object-contain"}):$e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 47 47",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",children:[$e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M23.5058 3.63059e-06C12.2974 -0.00618902 2.64601 7.91029 0.455364 18.9069C-1.73528 29.9035 4.14513 40.9165 14.4996 45.2094V23.0524L17.8315 18.762V46.3055C19.6877 46.767 21.5932 47.0002 23.5058 47C24.0838 47.0001 24.6543 46.9725 25.221 46.9307V14.4716L28.553 18.762V46.4539C30.5249 46.0214 32.4323 45.3345 34.2273 44.4105V8.89938L37.5593 13.1898V42.3372C45.6702 36.2805 48.9913 25.7075 45.8012 16.0983C42.6111 6.48908 33.6272 0.00428384 23.5059 0.00510346L23.5058 3.63059e-06Z",fill:"url(#paint0_linear_192_413)"}),$e.jsx("defs",{children:$e.jsxs("linearGradient",{id:"paint0_linear_192_413",x1:"-18.3065",y1:"-10.34",x2:"-17.2725",y2:"72.427",gradientUnits:"userSpaceOnUse",children:[$e.jsx("stop",{stopColor:"white"}),$e.jsx("stop",{offset:"0.6",stopColor:"white",stopOpacity:"0.968627"}),$e.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.101961"})]})})]}),$e.jsx("span",{className:"sr-only",children:"Open chat"})]}),i&&!r&&$e.jsx(pd.div,{initial:{scale:0},animate:{scale:1},className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs font-bold min-w-[20px] h-5 px-1.5 rounded-full flex items-center justify-center shadow-lg",children:o>99?"99+":o})]})})}
|
|
9
|
+
"use strict";var e,t,s,n,r,a,i,o,l,c,d,u,h,m,p,f,g,y,x,v,b,w,S,j,k,N,E,C,T,P,A,R,M,D,$,O,F,z,L,I,_,V,B,q,U,W,H,K,Y,Q,G,J,X,Z,ee,te,se,ne,re,ae,ie,oe,le,ce,de,ue,he,me,pe,fe,ge,ye,xe,ve,be,we,Se,je,ke,Ne=Object.defineProperty,Ee=e=>{throw TypeError(e)},Ce=(e,t,s)=>((e,t,s)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s),Te=(e,t,s)=>t.has(e)||Ee("Cannot "+s),Pe=(e,t,s)=>(Te(e,t,"read from private field"),s?s.call(e):t.get(e)),Ae=(e,t,s)=>t.has(e)?Ee("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Re=(e,t,s,n)=>(Te(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s),Me=(e,t,s)=>(Te(e,t,"access private method"),s),De=(e,t,s,n)=>({set _(n){Re(e,t,n,s)},get _(){return Pe(e,t,n)}});const $e=require("react/jsx-runtime"),Oe=require("react"),Fe=require("react-dom");function ze(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const s in e)if("default"!==s){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}return t.default=e,Object.freeze(t)}const Le=ze(Oe);var Ie=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_e={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ve=new(s=class{constructor(){Ae(this,e,_e),Ae(this,t,!1)}setTimeoutProvider(s){"production"!==process.env.NODE_ENV&&Pe(this,t)&&s!==Pe(this,e)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:Pe(this,e),provider:s}),Re(this,e,s),"production"!==process.env.NODE_ENV&&Re(this,t,!1)}setTimeout(s,n){return"production"!==process.env.NODE_ENV&&Re(this,t,!0),Pe(this,e).setTimeout(s,n)}clearTimeout(t){Pe(this,e).clearTimeout(t)}setInterval(s,n){return"production"!==process.env.NODE_ENV&&Re(this,t,!0),Pe(this,e).setInterval(s,n)}clearInterval(t){Pe(this,e).clearInterval(t)}},e=new WeakMap,t=new WeakMap,s);var Be="undefined"==typeof window||"Deno"in globalThis;function qe(){}function Ue(e){return"number"==typeof e&&e>=0&&e!==1/0}function We(e,t){return Math.max(e+(t||0)-Date.now(),0)}function He(e,t){return"function"==typeof e?e(t):e}function Ke(e,t){return"function"==typeof e?e(t):e}function Ye(e,t){const{type:s="all",exact:n,fetchStatus:r,predicate:a,queryKey:i,stale:o}=e;if(i)if(n){if(t.queryHash!==Ge(i,t.options))return!1}else if(!Xe(t.queryKey,i))return!1;if("all"!==s){const e=t.isActive();if("active"===s&&!e)return!1;if("inactive"===s&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&((!r||r===t.state.fetchStatus)&&!(a&&!a(t)))}function Qe(e,t){const{exact:s,status:n,predicate:r,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(Je(t.options.mutationKey)!==Je(a))return!1}else if(!Xe(t.options.mutationKey,a))return!1}return(!n||t.state.status===n)&&!(r&&!r(t))}function Ge(e,t){return((null==t?void 0:t.queryKeyHashFn)||Je)(e)}function Je(e){return JSON.stringify(e,(e,t)=>nt(t)?Object.keys(t).sort().reduce((e,s)=>(e[s]=t[s],e),{}):t)}function Xe(e,t){return e===t||typeof e==typeof t&&(!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(s=>Xe(e[s],t[s])))}var Ze=Object.prototype.hasOwnProperty;function et(e,t){if(e===t)return e;const s=st(e)&&st(t);if(!(s||nt(e)&&nt(t)))return t;const n=(s?e:Object.keys(e)).length,r=s?t:Object.keys(t),a=r.length,i=s?new Array(a):{};let o=0;for(let l=0;l<a;l++){const a=s?l:r[l],c=e[a],d=t[a];if(c===d){i[a]=c,(s?l<n:Ze.call(e,a))&&o++;continue}if(null===c||null===d||"object"!=typeof c||"object"!=typeof d){i[a]=d;continue}const u=et(c,d);i[a]=u,u===c&&o++}return n===a&&o===n?e:i}function tt(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function st(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function nt(e){if(!rt(e))return!1;const t=e.constructor;if(void 0===t)return!0;const s=t.prototype;return!!rt(s)&&(!!s.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype)}function rt(e){return"[object Object]"===Object.prototype.toString.call(e)}function at(e,t,s){if("function"==typeof s.structuralSharing)return s.structuralSharing(e,t);if(!1!==s.structuralSharing){if("production"!==process.env.NODE_ENV)try{return et(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`),n}return et(e,t)}return t}function it(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function ot(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var lt=Symbol();function ct(e,t){return"production"!==process.env.NODE_ENV&&e.queryFn===lt&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(null==t?void 0:t.initialPromise)?()=>t.initialPromise:e.queryFn&&e.queryFn!==lt?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function dt(e,t){return"function"==typeof e?e(...t):!!e}var ut=new(i=class extends Ie{constructor(){super(),Ae(this,n),Ae(this,r),Ae(this,a),Re(this,a,e=>{if(!Be&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){Pe(this,r)||this.setEventListener(Pe(this,a))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Pe(this,r))||e.call(this),Re(this,r,void 0))}setEventListener(e){var t;Re(this,a,e),null==(t=Pe(this,r))||t.call(this),Re(this,r,e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){Pe(this,n)!==e&&(Re(this,n,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return"boolean"==typeof Pe(this,n)?Pe(this,n):"hidden"!==(null==(e=globalThis.document)?void 0:e.visibilityState)}},n=new WeakMap,r=new WeakMap,a=new WeakMap,i);function ht(){let e,t;const s=new Promise((s,n)=>{e=s,t=n});function n(e){Object.assign(s,e),delete s.resolve,delete s.reject}return s.status="pending",s.catch(()=>{}),s.resolve=t=>{n({status:"fulfilled",value:t}),e(t)},s.reject=e=>{n({status:"rejected",reason:e}),t(e)},s}var mt=function(e){setTimeout(e,0)};var pt=function(){let e=[],t=0,s=e=>{e()},n=e=>{e()},r=mt;const a=n=>{t?e.push(n):r(()=>{s(n)})};return{batch:a=>{let i;t++;try{i=a()}finally{t--,t||(()=>{const t=e;e=[],t.length&&r(()=>{n(()=>{t.forEach(e=>{s(e)})})})})()}return i},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{s=e},setBatchNotifyFunction:e=>{n=e},setScheduler:e=>{r=e}}}(),ft=new(d=class extends Ie{constructor(){super(),Ae(this,o,!0),Ae(this,l),Ae(this,c),Re(this,c,e=>{if(!Be&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}})}onSubscribe(){Pe(this,l)||this.setEventListener(Pe(this,c))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Pe(this,l))||e.call(this),Re(this,l,void 0))}setEventListener(e){var t;Re(this,c,e),null==(t=Pe(this,l))||t.call(this),Re(this,l,e(this.setOnline.bind(this)))}setOnline(e){Pe(this,o)!==e&&(Re(this,o,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return Pe(this,o)}},o=new WeakMap,l=new WeakMap,c=new WeakMap,d);function gt(e){return Math.min(1e3*2**e,3e4)}function yt(e){return"online"!==(e??"online")||ft.isOnline()}var xt=class extends Error{constructor(e){super("CancelledError"),this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent}};function vt(e){let t,s=!1,n=0;const r=ht(),a=()=>"pending"!==r.status,i=()=>ut.isFocused()&&("always"===e.networkMode||ft.isOnline())&&e.canRun(),o=()=>yt(e.networkMode)&&e.canRun(),l=e=>{a()||(null==t||t(),r.resolve(e))},c=e=>{a()||(null==t||t(),r.reject(e))},d=()=>new Promise(s=>{var n;t=e=>{(a()||i())&&s(e)},null==(n=e.onPause)||n.call(e)}).then(()=>{var s;t=void 0,a()||null==(s=e.onContinue)||s.call(e)}),u=()=>{if(a())return;let t;const r=0===n?e.initialPromise:void 0;try{t=r??e.fn()}catch(o){t=Promise.reject(o)}Promise.resolve(t).then(l).catch(t=>{var r;if(a())return;const o=e.retry??(Be?0:3),l=e.retryDelay??gt,h="function"==typeof l?l(n,t):l,m=!0===o||"number"==typeof o&&n<o||"function"==typeof o&&o(n,t);var p;!s&&m?(n++,null==(r=e.onFail)||r.call(e,n,t),(p=h,new Promise(e=>{Ve.setTimeout(e,p)})).then(()=>i()?void 0:d()).then(()=>{s?c(t):u()})):c(t)})};return{promise:r,status:()=>r.status,cancel:t=>{var s;if(!a()){const n=new xt(t);c(n),null==(s=e.onCancel)||s.call(e,n)}},continue:()=>(null==t||t(),r),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:o,start:()=>(o()?u():d().then(u),r)}}var bt=(h=class{constructor(){Ae(this,u)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ue(this.gcTime)&&Re(this,u,Ve.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Be?1/0:3e5))}clearGcTimeout(){Pe(this,u)&&(Ve.clearTimeout(Pe(this,u)),Re(this,u,void 0))}},u=new WeakMap,h),wt=(S=class extends bt{constructor(e){super(),Ae(this,b),Ae(this,m),Ae(this,p),Ae(this,f),Ae(this,g),Ae(this,y),Ae(this,x),Ae(this,v),Re(this,v,!1),Re(this,x,e.defaultOptions),this.setOptions(e.options),this.observers=[],Re(this,g,e.client),Re(this,f,Pe(this,g).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Re(this,m,jt(this.options)),this.state=e.state??Pe(this,m),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return null==(e=Pe(this,y))?void 0:e.promise}setOptions(e){if(this.options={...Pe(this,x),...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=jt(this.options);void 0!==e.data&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),Re(this,m,e))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||Pe(this,f).remove(this)}setData(e,t){const s=at(this.state.data,e,this.options);return Me(this,b,w).call(this,{data:s,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt,manual:null==t?void 0:t.manual}),s}setState(e,t){Me(this,b,w).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var t,s;const n=null==(t=Pe(this,y))?void 0:t.promise;return null==(s=Pe(this,y))||s.cancel(e),n?n.then(qe).catch(qe):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Pe(this,m))}isActive(){return this.observers.some(e=>!1!==Ke(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===lt||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===He(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!We(this.state.dataUpdatedAt,e))}onFocus(){var e;const t=this.observers.find(e=>e.shouldFetchOnWindowFocus());null==t||t.refetch({cancelRefetch:!1}),null==(e=Pe(this,y))||e.continue()}onOnline(){var e;const t=this.observers.find(e=>e.shouldFetchOnReconnect());null==t||t.refetch({cancelRefetch:!1}),null==(e=Pe(this,y))||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Pe(this,f).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(Pe(this,y)&&(Pe(this,v)?Pe(this,y).cancel({revert:!0}):Pe(this,y).cancelRetry()),this.scheduleGc()),Pe(this,f).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Me(this,b,w).call(this,{type:"invalidate"})}async fetch(e,t){var s,n,r,a,i,o,l,c,d,u,h,m;if("idle"!==this.state.fetchStatus&&"rejected"!==(null==(s=Pe(this,y))?void 0:s.status()))if(void 0!==this.state.data&&(null==t?void 0:t.cancelRefetch))this.cancel({silent:!0});else if(Pe(this,y))return Pe(this,y).continueRetry(),Pe(this,y).promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}"production"!==process.env.NODE_ENV&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const x=new AbortController,S=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(Re(this,v,!0),x.signal)})},j=()=>{const e=ct(this.options,t),s=(()=>{const e={client:Pe(this,g),queryKey:this.queryKey,meta:this.meta};return S(e),e})();return Re(this,v,!1),this.options.persister?this.options.persister(e,s,this):e(s)},k=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:Pe(this,g),state:this.state,fetchFn:j};return S(e),e})();null==(n=this.options.behavior)||n.onFetch(k,this),Re(this,p,this.state),"idle"!==this.state.fetchStatus&&this.state.fetchMeta===(null==(r=k.fetchOptions)?void 0:r.meta)||Me(this,b,w).call(this,{type:"fetch",meta:null==(a=k.fetchOptions)?void 0:a.meta}),Re(this,y,vt({initialPromise:null==t?void 0:t.initialPromise,fn:k.fetchFn,onCancel:e=>{e instanceof xt&&e.revert&&this.setState({...Pe(this,p),fetchStatus:"idle"}),x.abort()},onFail:(e,t)=>{Me(this,b,w).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,b,w).call(this,{type:"pause"})},onContinue:()=>{Me(this,b,w).call(this,{type:"continue"})},retry:k.options.retry,retryDelay:k.options.retryDelay,networkMode:k.options.networkMode,canRun:()=>!0}));try{const e=await Pe(this,y).start();if(void 0===e)throw"production"!==process.env.NODE_ENV&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(e),null==(o=(i=Pe(this,f).config).onSuccess)||o.call(i,e,this),null==(c=(l=Pe(this,f).config).onSettled)||c.call(l,e,this.state.error,this),e}catch(N){if(N instanceof xt){if(N.silent)return Pe(this,y).promise;if(N.revert){if(void 0===this.state.data)throw N;return this.state.data}}throw Me(this,b,w).call(this,{type:"error",error:N}),null==(u=(d=Pe(this,f).config).onError)||u.call(d,N,this),null==(m=(h=Pe(this,f).config).onSettled)||m.call(h,this.state.data,N,this),N}finally{this.scheduleGc()}}},m=new WeakMap,p=new WeakMap,f=new WeakMap,g=new WeakMap,y=new WeakMap,x=new WeakMap,v=new WeakMap,b=new WeakSet,w=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...St(t.data,this.options),fetchMeta:e.meta??null};case"success":const s={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Re(this,p,e.manual?s:void 0),s;case"error":const n=e.error;return{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),pt.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),Pe(this,f).notify({query:this,type:"updated",action:e})})},S);function St(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:yt(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function jt(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,s=void 0!==t,n=s?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var kt=(Y=class extends Ie{constructor(e,t){super(),Ae(this,L),Ae(this,j),Ae(this,k),Ae(this,N),Ae(this,E),Ae(this,C),Ae(this,T),Ae(this,P),Ae(this,A),Ae(this,R),Ae(this,M),Ae(this,D),Ae(this,$),Ae(this,O),Ae(this,F),Ae(this,z,new Set),this.options=t,Re(this,j,e),Re(this,A,null),Re(this,P,ht()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(Pe(this,k).addObserver(this),Nt(Pe(this,k),this.options)?Me(this,L,I).call(this):this.updateResult(),Me(this,L,q).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Et(Pe(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Et(Pe(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Me(this,L,U).call(this),Me(this,L,W).call(this),Pe(this,k).removeObserver(this)}setOptions(e){const t=this.options,s=Pe(this,k);if(this.options=Pe(this,j).defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof Ke(this.options.enabled,Pe(this,k)))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Me(this,L,H).call(this),Pe(this,k).setOptions(this.options),t._defaulted&&!tt(this.options,t)&&Pe(this,j).getQueryCache().notify({type:"observerOptionsUpdated",query:Pe(this,k),observer:this});const n=this.hasListeners();n&&Ct(Pe(this,k),s,this.options,t)&&Me(this,L,I).call(this),this.updateResult(),!n||Pe(this,k)===s&&Ke(this.options.enabled,Pe(this,k))===Ke(t.enabled,Pe(this,k))&&He(this.options.staleTime,Pe(this,k))===He(t.staleTime,Pe(this,k))||Me(this,L,_).call(this);const r=Me(this,L,V).call(this);!n||Pe(this,k)===s&&Ke(this.options.enabled,Pe(this,k))===Ke(t.enabled,Pe(this,k))&&r===Pe(this,F)||Me(this,L,B).call(this,r)}getOptimisticResult(e){const t=Pe(this,j).getQueryCache().build(Pe(this,j),e),s=this.createResult(t,e);return function(e,t){if(!tt(e.getCurrentResult(),t))return!0;return!1}(this,s)&&(Re(this,E,s),Re(this,T,this.options),Re(this,C,Pe(this,k).state)),s}getCurrentResult(){return Pe(this,E)}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),null==t||t(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==Pe(this,P).status||Pe(this,P).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,s))})}trackProp(e){Pe(this,z).add(e)}getCurrentQuery(){return Pe(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=Pe(this,j).defaultQueryOptions(e),s=Pe(this,j).getQueryCache().build(Pe(this,j),t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return Me(this,L,I).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Pe(this,E)))}createResult(e,t){var s;const n=Pe(this,k),r=this.options,a=Pe(this,E),i=Pe(this,C),o=Pe(this,T),l=e!==n?e.state:Pe(this,N),{state:c}=e;let d,u={...c},h=!1;if(t._optimisticResults){const s=this.hasListeners(),a=!s&&Nt(e,t),i=s&&Ct(e,n,t,r);(a||i)&&(u={...u,...St(c.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:m,errorUpdatedAt:p,status:f}=u;d=u.data;let g=!1;if(void 0!==t.placeholderData&&void 0===d&&"pending"===f){let e;(null==a?void 0:a.isPlaceholderData)&&t.placeholderData===(null==o?void 0:o.placeholderData)?(e=a.data,g=!0):e="function"==typeof t.placeholderData?t.placeholderData(null==(s=Pe(this,D))?void 0:s.state.data,Pe(this,D)):t.placeholderData,void 0!==e&&(f="success",d=at(null==a?void 0:a.data,e,t),h=!0)}if(t.select&&void 0!==d&&!g)if(a&&d===(null==i?void 0:i.data)&&t.select===Pe(this,R))d=Pe(this,M);else try{Re(this,R,t.select),d=t.select(d),d=at(null==a?void 0:a.data,d,t),Re(this,M,d),Re(this,A,null)}catch(j){Re(this,A,j)}Pe(this,A)&&(m=Pe(this,A),d=Pe(this,M),p=Date.now(),f="error");const y="fetching"===u.fetchStatus,x="pending"===f,v="error"===f,b=x&&y,w=void 0!==d,S={status:f,fetchStatus:u.fetchStatus,isPending:x,isSuccess:"success"===f,isError:v,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:u.dataUpdatedAt,error:m,errorUpdatedAt:p,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:v&&!w,isPaused:"paused"===u.fetchStatus,isPlaceholderData:h,isRefetchError:v&&w,isStale:Tt(e,t),refetch:this.refetch,promise:Pe(this,P),isEnabled:!1!==Ke(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===S.status?e.reject(S.error):void 0!==S.data&&e.resolve(S.data)},s=()=>{const e=Re(this,P,S.promise=ht());t(e)},r=Pe(this,P);switch(r.status){case"pending":e.queryHash===n.queryHash&&t(r);break;case"fulfilled":"error"!==S.status&&S.data===r.value||s();break;case"rejected":"error"===S.status&&S.error===r.reason||s()}}return S}updateResult(){const e=Pe(this,E),t=this.createResult(Pe(this,k),this.options);if(Re(this,C,Pe(this,k).state),Re(this,T,this.options),void 0!==Pe(this,C).data&&Re(this,D,Pe(this,k)),tt(t,e))return;Re(this,E,t);Me(this,L,K).call(this,{listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!Pe(this,z).size)return!0;const n=new Set(s??Pe(this,z));return this.options.throwOnError&&n.add("error"),Object.keys(Pe(this,E)).some(t=>{const s=t;return Pe(this,E)[s]!==e[s]&&n.has(s)})})()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Me(this,L,q).call(this)}},j=new WeakMap,k=new WeakMap,N=new WeakMap,E=new WeakMap,C=new WeakMap,T=new WeakMap,P=new WeakMap,A=new WeakMap,R=new WeakMap,M=new WeakMap,D=new WeakMap,$=new WeakMap,O=new WeakMap,F=new WeakMap,z=new WeakMap,L=new WeakSet,I=function(e){Me(this,L,H).call(this);let t=Pe(this,k).fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(qe)),t},_=function(){Me(this,L,U).call(this);const e=He(this.options.staleTime,Pe(this,k));if(Be||Pe(this,E).isStale||!Ue(e))return;const t=We(Pe(this,E).dataUpdatedAt,e)+1;Re(this,$,Ve.setTimeout(()=>{Pe(this,E).isStale||this.updateResult()},t))},V=function(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(Pe(this,k)):this.options.refetchInterval)??!1},B=function(e){Me(this,L,W).call(this),Re(this,F,e),!Be&&!1!==Ke(this.options.enabled,Pe(this,k))&&Ue(Pe(this,F))&&0!==Pe(this,F)&&Re(this,O,Ve.setInterval(()=>{(this.options.refetchIntervalInBackground||ut.isFocused())&&Me(this,L,I).call(this)},Pe(this,F)))},q=function(){Me(this,L,_).call(this),Me(this,L,B).call(this,Me(this,L,V).call(this))},U=function(){Pe(this,$)&&(Ve.clearTimeout(Pe(this,$)),Re(this,$,void 0))},W=function(){Pe(this,O)&&(Ve.clearInterval(Pe(this,O)),Re(this,O,void 0))},H=function(){const e=Pe(this,j).getQueryCache().build(Pe(this,j),this.options);if(e===Pe(this,k))return;const t=Pe(this,k);Re(this,k,e),Re(this,N,e.state),this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))},K=function(e){pt.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(Pe(this,E))}),Pe(this,j).getQueryCache().notify({query:Pe(this,k),type:"observerResultsUpdated"})})},Y);function Nt(e,t){return function(e,t){return!1!==Ke(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&Et(e,t,t.refetchOnMount)}function Et(e,t,s){if(!1!==Ke(t.enabled,e)&&"static"!==He(t.staleTime,e)){const n="function"==typeof s?s(e):s;return"always"===n||!1!==n&&Tt(e,t)}return!1}function Ct(e,t,s,n){return(e!==t||!1===Ke(n.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&Tt(e,s)}function Tt(e,t){return!1!==Ke(t.enabled,e)&&e.isStaleByTime(He(t.staleTime,e))}function Pt(e){return{onFetch:(t,s)=>{var n,r,a,i,o;const l=t.options,c=null==(a=null==(r=null==(n=t.fetchOptions)?void 0:n.meta)?void 0:r.fetchMore)?void 0:a.direction,d=(null==(i=t.state.data)?void 0:i.pages)||[],u=(null==(o=t.state.data)?void 0:o.pageParams)||[];let h={pages:[],pageParams:[]},m=0;const p=async()=>{let s=!1;const n=ct(t.options,t.fetchOptions),r=async(e,r,a)=>{if(s)return Promise.reject();if(null==r&&e.pages.length)return Promise.resolve(e);const i=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:a?"backward":"forward",meta:t.options.meta};var n;return n=e,Object.defineProperty(n,"signal",{enumerable:!0,get:()=>(t.signal.aborted?s=!0:t.signal.addEventListener("abort",()=>{s=!0}),t.signal)}),e})(),o=await n(i),{maxPages:l}=t.options,c=a?ot:it;return{pages:c(e.pages,o,l),pageParams:c(e.pageParams,r,l)}};if(c&&d.length){const e="backward"===c,t={pages:d,pageParams:u},s=(e?Rt:At)(l,t);h=await r(t,s,e)}else{const t=e??d.length;do{const e=0===m?u[0]??l.initialPageParam:At(l,h);if(m>0&&null==e)break;h=await r(h,e),m++}while(m<t)}return h};t.options.persister?t.fetchFn=()=>{var e,n;return null==(n=(e=t.options).persister)?void 0:n.call(e,p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=p}}}function At(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function Rt(e,{pages:t,pageParams:s}){var n;return t.length>0?null==(n=e.getPreviousPageParam)?void 0:n.call(e,t[0],t,s[0],s):void 0}var Mt=(te=class extends bt{constructor(e){super(),Ae(this,Z),Ae(this,Q),Ae(this,G),Ae(this,J),Ae(this,X),Re(this,Q,e.client),this.mutationId=e.mutationId,Re(this,J,e.mutationCache),Re(this,G,[]),this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Pe(this,G).includes(e)||(Pe(this,G).push(e),this.clearGcTimeout(),Pe(this,J).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Re(this,G,Pe(this,G).filter(t=>t!==e)),this.scheduleGc(),Pe(this,J).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Pe(this,G).length||("pending"===this.state.status?this.scheduleGc():Pe(this,J).remove(this))}continue(){var e;return(null==(e=Pe(this,X))?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var t,s,n,r,a,i,o,l,c,d,u,h,m,p,f,g,y,x,v,b;const w=()=>{Me(this,Z,ee).call(this,{type:"continue"})},S={client:Pe(this,Q),meta:this.options.meta,mutationKey:this.options.mutationKey};Re(this,X,vt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,S):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{Me(this,Z,ee).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,Z,ee).call(this,{type:"pause"})},onContinue:w,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Pe(this,J).canRun(this)}));const j="pending"===this.state.status,k=!Pe(this,X).canStart();try{if(j)w();else{Me(this,Z,ee).call(this,{type:"pending",variables:e,isPaused:k}),await(null==(s=(t=Pe(this,J).config).onMutate)?void 0:s.call(t,e,this,S));const a=await(null==(r=(n=this.options).onMutate)?void 0:r.call(n,e,S));a!==this.state.context&&Me(this,Z,ee).call(this,{type:"pending",context:a,variables:e,isPaused:k})}const m=await Pe(this,X).start();return await(null==(i=(a=Pe(this,J).config).onSuccess)?void 0:i.call(a,m,e,this.state.context,this,S)),await(null==(l=(o=this.options).onSuccess)?void 0:l.call(o,m,e,this.state.context,S)),await(null==(d=(c=Pe(this,J).config).onSettled)?void 0:d.call(c,m,null,this.state.variables,this.state.context,this,S)),await(null==(h=(u=this.options).onSettled)?void 0:h.call(u,m,null,e,this.state.context,S)),Me(this,Z,ee).call(this,{type:"success",data:m}),m}catch(N){try{throw await(null==(p=(m=Pe(this,J).config).onError)?void 0:p.call(m,N,e,this.state.context,this,S)),await(null==(g=(f=this.options).onError)?void 0:g.call(f,N,e,this.state.context,S)),await(null==(x=(y=Pe(this,J).config).onSettled)?void 0:x.call(y,void 0,N,this.state.variables,this.state.context,this,S)),await(null==(b=(v=this.options).onSettled)?void 0:b.call(v,void 0,N,e,this.state.context,S)),N}finally{Me(this,Z,ee).call(this,{type:"error",error:N})}}finally{Pe(this,J).runNext(this)}}},Q=new WeakMap,G=new WeakMap,J=new WeakMap,X=new WeakMap,Z=new WeakSet,ee=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),pt.batch(()=>{Pe(this,G).forEach(t=>{t.onMutationUpdate(e)}),Pe(this,J).notify({mutation:this,type:"updated",action:e})})},te);var Dt=(ae=class extends Ie{constructor(e={}){super(),Ae(this,se),Ae(this,ne),Ae(this,re),this.config=e,Re(this,se,new Set),Re(this,ne,new Map),Re(this,re,0)}build(e,t,s){const n=new Mt({client:e,mutationCache:this,mutationId:++De(this,re)._,options:e.defaultMutationOptions(t),state:s});return this.add(n),n}add(e){Pe(this,se).add(e);const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t);s?s.push(e):Pe(this,ne).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Pe(this,se).delete(e)){const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t);if(s)if(s.length>1){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}else s[0]===e&&Pe(this,ne).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=$t(e);if("string"==typeof t){const s=Pe(this,ne).get(t),n=null==s?void 0:s.find(e=>"pending"===e.state.status);return!n||n===e}return!0}runNext(e){var t;const s=$t(e);if("string"==typeof s){const n=null==(t=Pe(this,ne).get(s))?void 0:t.find(t=>t!==e&&t.state.isPaused);return(null==n?void 0:n.continue())??Promise.resolve()}return Promise.resolve()}clear(){pt.batch(()=>{Pe(this,se).forEach(e=>{this.notify({type:"removed",mutation:e})}),Pe(this,se).clear(),Pe(this,ne).clear()})}getAll(){return Array.from(Pe(this,se))}find(e){const t={exact:!0,...e};return this.getAll().find(e=>Qe(t,e))}findAll(e={}){return this.getAll().filter(t=>Qe(e,t))}notify(e){pt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(e=>e.state.isPaused);return pt.batch(()=>Promise.all(e.map(e=>e.continue().catch(qe))))}},se=new WeakMap,ne=new WeakMap,re=new WeakMap,ae);function $t(e){var t;return null==(t=e.options.scope)?void 0:t.id}var Ot=(me=class extends Ie{constructor(e,t){super(),Ae(this,de),Ae(this,ie),Ae(this,oe),Ae(this,le),Ae(this,ce),Re(this,ie,e),this.setOptions(t),this.bindMethods(),Me(this,de,ue).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const s=this.options;this.options=Pe(this,ie).defaultMutationOptions(e),tt(this.options,s)||Pe(this,ie).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Pe(this,le),observer:this}),(null==s?void 0:s.mutationKey)&&this.options.mutationKey&&Je(s.mutationKey)!==Je(this.options.mutationKey)?this.reset():"pending"===(null==(t=Pe(this,le))?void 0:t.state.status)&&Pe(this,le).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||null==(e=Pe(this,le))||e.removeObserver(this)}onMutationUpdate(e){Me(this,de,ue).call(this),Me(this,de,he).call(this,e)}getCurrentResult(){return Pe(this,oe)}reset(){var e;null==(e=Pe(this,le))||e.removeObserver(this),Re(this,le,void 0),Me(this,de,ue).call(this),Me(this,de,he).call(this)}mutate(e,t){var s;return Re(this,ce,t),null==(s=Pe(this,le))||s.removeObserver(this),Re(this,le,Pe(this,ie).getMutationCache().build(Pe(this,ie),this.options)),Pe(this,le).addObserver(this),Pe(this,le).execute(e)}},ie=new WeakMap,oe=new WeakMap,le=new WeakMap,ce=new WeakMap,de=new WeakSet,ue=function(){var e;const t=(null==(e=Pe(this,le))?void 0:e.state)??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};Re(this,oe,{...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset})},he=function(e){pt.batch(()=>{var t,s,n,r,a,i,o,l;if(Pe(this,ce)&&this.hasListeners()){const c=Pe(this,oe).variables,d=Pe(this,oe).context,u={client:Pe(this,ie),meta:this.options.meta,mutationKey:this.options.mutationKey};"success"===(null==e?void 0:e.type)?(null==(s=(t=Pe(this,ce)).onSuccess)||s.call(t,e.data,c,d,u),null==(r=(n=Pe(this,ce)).onSettled)||r.call(n,e.data,null,c,d,u)):"error"===(null==e?void 0:e.type)&&(null==(i=(a=Pe(this,ce)).onError)||i.call(a,e.error,c,d,u),null==(l=(o=Pe(this,ce)).onSettled)||l.call(o,void 0,e.error,c,d,u))}this.listeners.forEach(e=>{e(Pe(this,oe))})})},me),Ft=(fe=class extends Ie{constructor(e={}){super(),Ae(this,pe),this.config=e,Re(this,pe,new Map)}build(e,t,s){const n=t.queryKey,r=t.queryHash??Ge(n,t);let a=this.get(r);return a||(a=new wt({client:e,queryKey:n,queryHash:r,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(n)}),this.add(a)),a}add(e){Pe(this,pe).has(e.queryHash)||(Pe(this,pe).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=Pe(this,pe).get(e.queryHash);t&&(e.destroy(),t===e&&Pe(this,pe).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){pt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Pe(this,pe).get(e)}getAll(){return[...Pe(this,pe).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(e=>Ye(t,e))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ye(e,t)):t}notify(e){pt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){pt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){pt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},pe=new WeakMap,fe),zt=(ke=class{constructor(e={}){Ae(this,ge),Ae(this,ye),Ae(this,xe),Ae(this,ve),Ae(this,be),Ae(this,we),Ae(this,Se),Ae(this,je),Re(this,ge,e.queryCache||new Ft),Re(this,ye,e.mutationCache||new Dt),Re(this,xe,e.defaultOptions||{}),Re(this,ve,new Map),Re(this,be,new Map),Re(this,we,0)}mount(){De(this,we)._++,1===Pe(this,we)&&(Re(this,Se,ut.subscribe(async e=>{e&&(await this.resumePausedMutations(),Pe(this,ge).onFocus())})),Re(this,je,ft.subscribe(async e=>{e&&(await this.resumePausedMutations(),Pe(this,ge).onOnline())})))}unmount(){var e,t;De(this,we)._--,0===Pe(this,we)&&(null==(e=Pe(this,Se))||e.call(this),Re(this,Se,void 0),null==(t=Pe(this,je))||t.call(this),Re(this,je,void 0))}isFetching(e){return Pe(this,ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Pe(this,ye).findAll({...e,status:"pending"}).length}getQueryData(e){var t;const s=this.defaultQueryOptions({queryKey:e});return null==(t=Pe(this,ge).get(s.queryHash))?void 0:t.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=Pe(this,ge).build(this,t),n=s.state.data;return void 0===n?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(He(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return Pe(this,ge).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),r=Pe(this,ge).get(n.queryHash),a=function(e,t){return"function"==typeof e?e(t):e}(t,null==r?void 0:r.state.data);if(void 0!==a)return Pe(this,ge).build(this,n).setData(a,{...s,manual:!0})}setQueriesData(e,t,s){return pt.batch(()=>Pe(this,ge).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,s)]))}getQueryState(e){var t;const s=this.defaultQueryOptions({queryKey:e});return null==(t=Pe(this,ge).get(s.queryHash))?void 0:t.state}removeQueries(e){const t=Pe(this,ge);pt.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const s=Pe(this,ge);return pt.batch(()=>(s.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=pt.batch(()=>Pe(this,ge).findAll(e).map(e=>e.cancel(s)));return Promise.all(n).then(qe).catch(qe)}invalidateQueries(e,t={}){return pt.batch(()=>(Pe(this,ge).findAll(e).forEach(e=>{e.invalidate()}),"none"===(null==e?void 0:e.refetchType)?Promise.resolve():this.refetchQueries({...e,type:(null==e?void 0:e.refetchType)??(null==e?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=pt.batch(()=>Pe(this,ge).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,s);return s.throwOnError||(t=t.catch(qe)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(n).then(qe)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const s=Pe(this,ge).build(this,t);return s.isStaleByTime(He(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(qe).catch(qe)}fetchInfiniteQuery(e){return e.behavior=Pt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(qe).catch(qe)}ensureInfiniteQueryData(e){return e.behavior=Pt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ft.isOnline()?Pe(this,ye).resumePausedMutations():Promise.resolve()}getQueryCache(){return Pe(this,ge)}getMutationCache(){return Pe(this,ye)}getDefaultOptions(){return Pe(this,xe)}setDefaultOptions(e){Re(this,xe,e)}setQueryDefaults(e,t){Pe(this,ve).set(Je(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Pe(this,ve).values()],s={};return t.forEach(t=>{Xe(e,t.queryKey)&&Object.assign(s,t.defaultOptions)}),s}setMutationDefaults(e,t){Pe(this,be).set(Je(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Pe(this,be).values()],s={};return t.forEach(t=>{Xe(e,t.mutationKey)&&Object.assign(s,t.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...Pe(this,xe).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ge(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===lt&&(t.enabled=!1),t}defaultMutationOptions(e){return(null==e?void 0:e._defaulted)?e:{...Pe(this,xe).mutations,...(null==e?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Pe(this,ge).clear(),Pe(this,ye).clear()}},ge=new WeakMap,ye=new WeakMap,xe=new WeakMap,ve=new WeakMap,be=new WeakMap,we=new WeakMap,Se=new WeakMap,je=new WeakMap,ke),Lt=Le.createContext(void 0),It=e=>{const t=Le.useContext(Lt);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},_t=({client:e,children:t})=>(Le.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),$e.jsx(Lt.Provider,{value:e,children:t})),Vt=Le.createContext(!1);Vt.Provider;var Bt=Le.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),qt=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ut(e,t,s){var n,r,a,i,o;if("production"!==process.env.NODE_ENV&&("object"!=typeof e||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const l=Le.useContext(Vt),c=Le.useContext(Bt),d=It(),u=d.defaultQueryOptions(e);null==(r=null==(n=d.getDefaultOptions().queries)?void 0:n._experimental_beforeQuery)||r.call(n,u),"production"!==process.env.NODE_ENV&&(u.queryFn||console.error(`[${u.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),u._optimisticResults=l?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,s=e=>"static"===e?e:Math.max(e??t,t),n=e.staleTime;e.staleTime="function"==typeof n?(...e)=>s(n(...e)):s(n),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(u),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(u,c),(e=>{Le.useEffect(()=>{e.clearReset()},[e])})(c);const h=!d.getQueryCache().get(u.queryHash),[m]=Le.useState(()=>new t(d,u)),p=m.getOptimisticResult(u),f=!l&&!1!==e.subscribed;if(Le.useSyncExternalStore(Le.useCallback(e=>{const t=f?m.subscribe(pt.batchCalls(e)):qe;return m.updateResult(),t},[m,f]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),Le.useEffect(()=>{m.setOptions(u)},[u,m]),((e,t)=>(null==e?void 0:e.suspense)&&t.isPending)(u,p))throw qt(u,m,c);if((({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(r&&void 0===e.data||dt(s,[e.error,n])))({result:p,errorResetBoundary:c,throwOnError:u.throwOnError,query:d.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw p.error;if(null==(i=null==(a=d.getDefaultOptions().queries)?void 0:a._experimental_afterQuery)||i.call(a,u,p),u.experimental_prefetchInRender&&!Be&&((e,t)=>e.isLoading&&e.isFetching&&!t)(p,l)){const e=h?qt(u,m,c):null==(o=d.getQueryCache().get(u.queryHash))?void 0:o.promise;null==e||e.catch(qe).finally(()=>{m.updateResult()})}return u.notifyOnChangeProps?p:m.trackResult(p)}function Wt(e,t){const s=It(),[n]=Le.useState(()=>new Ot(s,e));Le.useEffect(()=>{n.setOptions(e)},[n,e]);const r=Le.useSyncExternalStore(Le.useCallback(e=>n.subscribe(pt.batchCalls(e)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=Le.useCallback((e,t)=>{n.mutate(e,t).catch(qe)},[n]);if(r.error&&dt(n.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}const Ht=[{id:"session-1",title:"General Inquiry",messages:[{id:"1",content:"Hello! How can I help you today?",sender:"bot",timestamp:new Date(Date.now()-3e5)},{id:"2",content:"Hi there! I have a question about your services.",sender:"user",timestamp:new Date(Date.now()-24e4)},{id:"3",content:"I'd be happy to help! What would you like to know?",sender:"bot",timestamp:new Date(Date.now()-18e4)}],createdAt:new Date(Date.now()-864e5),updatedAt:new Date(Date.now()-18e4)},{id:"session-2",title:"Product Support",messages:[{id:"4",content:"I need help with product installation.",sender:"user",timestamp:new Date(Date.now()-1728e5)},{id:"5",content:"Sure! Let me guide you through the installation process.",sender:"bot",timestamp:new Date(Date.now()-17274e4)}],createdAt:new Date(Date.now()-1728e5),updatedAt:new Date(Date.now()-17274e4)}],Kt=["That's a great question! Let me help you with that.","I understand your concern. Here's what I can suggest...","Thanks for reaching out! I'm here to assist you.","Let me provide you with some helpful information.","I'd be happy to clarify that for you.","That's an interesting point. Here's my perspective...","I can definitely help you with that request.","Thanks for your patience. Here's what you need to know..."],Yt={SESSIONS:"chatbot-sessions",THEME:"chatbot-theme",CURRENT_SESSION:"chatbot-current-session",AUTH:"chatbot-auth",API_KEY:"chatbot-api-key",CURRENT_ROUTE:"chatbot-current-route"},Qt=e=>({...e,createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),messages:e.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}))}),Gt={getAuth(){try{const e=localStorage.getItem(Yt.AUTH);return e?JSON.parse(e):null}catch(e){return console.error("Failed to get auth data:",e),null}},saveAuth(e){try{localStorage.setItem(Yt.AUTH,JSON.stringify(e))}catch(t){console.error("Failed to save auth data:",t)}},clearAuth(){try{localStorage.removeItem(Yt.AUTH)}catch(e){console.error("Failed to clear auth data:",e)}},getApiKey(){try{return localStorage.getItem(Yt.API_KEY)}catch(e){return console.error("Failed to get API key:",e),null}},saveApiKey(e){try{localStorage.setItem(Yt.API_KEY,e)}catch(t){console.error("Failed to save API key:",t)}},clearApiKey(){try{localStorage.removeItem(Yt.API_KEY)}catch(e){console.error("Failed to clear API key:",e)}},getSessions(){try{const e=localStorage.getItem(Yt.SESSIONS);if(!e)return[];return JSON.parse(e).map(Qt)}catch(e){return console.error("Failed to get sessions:",e),[]}},saveSessions(e){try{localStorage.setItem(Yt.SESSIONS,JSON.stringify(e))}catch(t){console.error("Failed to save sessions:",t)}},getCurrentSession(){try{const e=localStorage.getItem(Yt.CURRENT_SESSION);if(!e)return null;const t=JSON.parse(e);return Qt(t)}catch(e){return console.error("Failed to get current session:",e),null}},saveCurrentSession(e){try{e?localStorage.setItem(Yt.CURRENT_SESSION,JSON.stringify(e)):localStorage.removeItem(Yt.CURRENT_SESSION)}catch(t){console.error("Failed to save current session:",t)}},getTheme(){try{const e=localStorage.getItem(Yt.THEME);return e?JSON.parse(e):null}catch{return null}},saveTheme(e){try{localStorage.setItem(Yt.THEME,JSON.stringify(e))}catch(t){console.error("Failed to save theme:",t)}},getCurrentRoute(){try{return localStorage.getItem(Yt.CURRENT_ROUTE)}catch(e){return console.error("Failed to get current route:",e),null}},saveCurrentRoute(e){try{localStorage.setItem(Yt.CURRENT_ROUTE,e)}catch(t){console.error("Failed to save current route:",t)}},clearAll(){try{Object.values(Yt).forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Failed to clear storage:",e)}}};function Jt(e){e=e.replace("#","");const t=parseInt(e.substr(0,2),16)/255,s=parseInt(e.substr(2,2),16)/255,n=parseInt(e.substr(4,2),16)/255,r=Math.max(t,s,n),a=Math.min(t,s,n);let i=0,o=0;const l=(r+a)/2;if(r!==a){const e=r-a;switch(o=l>.5?e/(2-r-a):e/(r+a),r){case t:i=(s-n)/e+(s<n?6:0);break;case s:i=(n-t)/e+2;break;case n:i=(t-s)/e+4}i/=6}return`${Math.round(360*i)} ${Math.round(100*o)}% ${Math.round(100*l)}%`}const Xt={primaryColor:"#b07e48",headerBg:"#1f2937",headerText:"#ffffff",userBubble:"#3b82f6",botBubble:"#f3f4f6",fontFamily:"Inter, system-ui, sans-serif"},Zt={isOpen:!1,currentSession:null,sessions:[],isLoading:!1,error:null,currentScreen:"chat",theme:Xt,isAuthenticated:!1,user:null,authLoading:!1};function es(e,t){var s;switch(console.log("ChatReducer: Action received:",t.type),console.log("ChatReducer: Current state:",e),t.type){case"OPEN_WIDGET":console.log("ChatReducer: Processing OPEN_WIDGET");const n={...e,isOpen:!0};return console.log("ChatReducer: New state after OPEN_WIDGET:",n),n;case"CLOSE_WIDGET":return{...e,isOpen:!1};case"SET_SCREEN":return{...e,currentScreen:t.payload};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"SET_AUTH_LOADING":return{...e,authLoading:t.payload};case"SET_AUTHENTICATED":return{...e,isAuthenticated:!0,user:t.payload,authLoading:!1};case"LOGOUT":return{...e,isAuthenticated:!1,user:null,currentSession:null,sessions:[],currentScreen:"chat"};case"ADD_MESSAGE":if(!e.currentSession)return e;const r={...e.currentSession,messages:[...e.currentSession.messages,t.payload],updatedAt:new Date},a=e.sessions.map(e=>e.id===r.id?r:e);return{...e,currentSession:r,sessions:a};case"CREATE_SESSION":return{...e,currentSession:t.payload,sessions:[t.payload,...e.sessions]};case"LOAD_SESSION":return{...e,currentSession:t.payload};case"UPDATE_SESSIONS":return{...e,sessions:t.payload};case"DELETE_SESSION":const i=e.sessions.filter(e=>e.id!==t.payload),o=(null==(s=e.currentSession)?void 0:s.id)===t.payload?null:e.currentSession;return{...e,sessions:i,currentSession:o};case"UPDATE_THEME":return{...e,theme:{...e.theme,...t.payload}};case"CLEAR_DATA":return{...Zt,theme:e.theme};default:return console.log("ChatReducer: Unknown action type:",t),e}}const ts=Oe.createContext(void 0);function ss({children:e,initialTheme:t,apiKey:s,tenantId:n,email:r}){const[a,i]=Oe.useReducer(es,Zt),o=Oe.useRef({});Oe.useEffect(()=>{const e=Gt.getAuth(),s=Gt.getSessions(),n=Gt.getCurrentSession(),r=Gt.getTheme();e&&e.email&&(i({type:"SET_AUTHENTICATED",payload:e}),s.length>0?i({type:"UPDATE_SESSIONS",payload:s}):i({type:"UPDATE_SESSIONS",payload:Ht}),n&&i({type:"LOAD_SESSION",payload:n})),r?i({type:"UPDATE_THEME",payload:r}):t&&i({type:"UPDATE_THEME",payload:t})},[]),Oe.useEffect(()=>{t&&i({type:"UPDATE_THEME",payload:t})},[t]),Oe.useEffect(()=>{a.isAuthenticated&&Gt.saveSessions(a.sessions)},[a.sessions,a.isAuthenticated]),Oe.useEffect(()=>{a.isAuthenticated&&Gt.saveCurrentSession(a.currentSession)},[a.currentSession,a.isAuthenticated]),Oe.useEffect(()=>{Gt.saveTheme(a.theme),function(e){const t=document.documentElement;if(e.primaryColor){const s=Jt(e.primaryColor);t.style.setProperty("--primary",s);const n=parseInt(s.split(" ")[2])>50?"0 0% 98%":"0 0% 9%";t.style.setProperty("--primary-foreground",n)}if(e.userBubble){const s=Jt(e.userBubble);t.style.setProperty("--user-bubble",s)}if(e.botBubble){const s=Jt(e.botBubble);t.style.setProperty("--bot-bubble",s)}}(a.theme)},[a.theme]),Oe.useEffect(()=>{a.user&&Gt.saveAuth(a.user)},[a.user]);const l=e=>i({type:"SET_SCREEN",payload:e}),c=async e=>{if(!e.trim())return;if(!a.currentSession)return d(),void setTimeout(()=>c(e),100);const t={id:`msg-${Date.now()}-user`,content:e.trim(),sender:"user",timestamp:new Date};i({type:"ADD_MESSAGE",payload:t}),i({type:"SET_LOADING",payload:!0}),setTimeout(()=>{const e={id:`msg-${Date.now()}-bot`,content:Kt[Math.floor(Math.random()*Kt.length)],sender:"bot",timestamp:new Date};i({type:"ADD_MESSAGE",payload:e}),i({type:"SET_LOADING",payload:!1})},1e3+2e3*Math.random())},d=()=>{const e={id:`session-${Date.now()}`,title:"New Conversation",messages:[],createdAt:new Date,updatedAt:new Date};i({type:"CREATE_SESSION",payload:e})};Oe.useEffect(()=>{const e=Gt.getApiKey();s&&s!==e&&Gt.saveApiKey(s),!s&&e&&Gt.clearApiKey();const t=Gt.getAuth(),a=null==t?void 0:t.email;r&&r!==a&&(Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null)),n&&o.current.tenantId!==n&&(Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null)),o.current={apiKey:s,tenantId:n,email:r}},[s,n,r]);const u={...a,openWidget:()=>{console.log("ChatContext: openWidget called"),console.log("ChatContext: Current state before dispatch:",a),i({type:"OPEN_WIDGET"}),console.log("ChatContext: OPEN_WIDGET dispatched")},closeWidget:()=>i({type:"CLOSE_WIDGET"}),setCurrentScreen:l,authenticate:async(e,t)=>{i({type:"SET_AUTH_LOADING",payload:!0});try{if(await new Promise(e=>setTimeout(e,1500)),e&&6===t.length){const t=`token_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return i({type:"SET_AUTHENTICATED",payload:{email:e,token:t}}),!0}return!1}catch(s){return i({type:"SET_AUTH_LOADING",payload:!1}),!1}},login:e=>{const t=`token_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;i({type:"SET_AUTHENTICATED",payload:{email:e,token:t}})},logout:()=>{Promise.resolve().then(()=>kp).then(({clearTokens:e,clearAutoRefresh:t})=>{t(),e()}),Gt.clearAuth(),Gt.saveSessions([]),Gt.saveCurrentSession(null),i({type:"LOGOUT"})},sendMessage:c,createNewSession:d,loadSession:e=>{const t=a.sessions.find(t=>t.id===e);t&&(i({type:"LOAD_SESSION",payload:t}),l("chat"))},deleteSession:e=>{i({type:"DELETE_SESSION",payload:e})},updateTheme:e=>{i({type:"UPDATE_THEME",payload:e})},resetTheme:()=>{i({type:"UPDATE_THEME",payload:Xt})},clearAllData:()=>{Gt.clearAll(),i({type:"CLEAR_DATA"})},apiKey:s,tenantId:n,email:r};return $e.jsx(ts.Provider,{value:u,children:e})}function ns(){const e=Oe.useContext(ts);if(void 0===e)throw new Error("useChatContext must be used within a ChatProvider");return e}const rs=Oe.createContext({});function as(e){const t=Oe.useRef(null);return null===t.current&&(t.current=e()),t.current}const is="undefined"!=typeof window,os=is?Oe.useLayoutEffect:Oe.useEffect,ls=Oe.createContext(null);function cs(e,t){-1===e.indexOf(t)&&e.push(t)}function ds(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}const us=(e,t,s)=>s>t?t:s<e?e:s;function hs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let ms=()=>{},ps=()=>{};"production"!==process.env.NODE_ENV&&(ms=(e,t,s)=>{e||"undefined"==typeof console||console.warn(hs(t,s))},ps=(e,t,s)=>{if(!e)throw new Error(hs(t,s))});const fs={},gs=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ys(e){return"object"==typeof e&&null!==e}const xs=e=>/^0[^.\s]+$/u.test(e);function vs(e){let t;return()=>(void 0===t&&(t=e()),t)}const bs=e=>e,ws=(e,t)=>s=>t(e(s)),Ss=(...e)=>e.reduce(ws),js=(e,t,s)=>{const n=t-e;return 0===n?1:(s-e)/n};class ks{constructor(){this.subscriptions=[]}add(e){return cs(this.subscriptions,e),()=>ds(this.subscriptions,e)}notify(e,t,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](e,t,s);else for(let r=0;r<n;r++){const n=this.subscriptions[r];n&&n(e,t,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ns=e=>1e3*e,Es=e=>e/1e3;function Cs(e,t){return t?e*(1e3/t):0}const Ts=new Set;function Ps(e,t,s){e||Ts.has(t)||(console.warn(hs(t,s)),Ts.add(t))}const As=(e,t,s)=>(((1-3*s+3*t)*e+(3*s-6*t))*e+3*t)*e;function Rs(e,t,s,n){if(e===t&&s===n)return bs;const r=t=>function(e,t,s,n,r){let a,i,o=0;do{i=t+(s-t)/2,a=As(i,n,r)-e,a>0?s=i:t=i}while(Math.abs(a)>1e-7&&++o<12);return i}(t,0,1,e,s);return e=>0===e||1===e?e:As(r(e),t,n)}const Ms=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ds=e=>t=>1-e(1-t),$s=Rs(.33,1.53,.69,.99),Os=Ds($s),Fs=Ms(Os),zs=e=>(e*=2)<1?.5*Os(e):.5*(2-Math.pow(2,-10*(e-1))),Ls=e=>1-Math.sin(Math.acos(e)),Is=Ds(Ls),_s=Ms(Ls),Vs=Rs(.42,0,1,1),Bs=Rs(0,0,.58,1),qs=Rs(.42,0,.58,1),Us=e=>Array.isArray(e)&&"number"==typeof e[0],Ws={linear:bs,easeIn:Vs,easeInOut:qs,easeOut:Bs,circIn:Ls,circInOut:_s,circOut:Is,backIn:Os,backInOut:Fs,backOut:$s,anticipate:zs},Hs=e=>{if(Us(e)){ps(4===e.length,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,s,n,r]=e;return Rs(t,s,n,r)}return"string"==typeof e?(ps(void 0!==Ws[e],`Invalid easing type '${e}'`,"invalid-easing-type"),Ws[e]):e},Ks=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ys(e,t){let s=!1,n=!0;const r={delta:0,timestamp:0,isProcessing:!1},a=()=>s=!0,i=Ks.reduce((e,t)=>(e[t]=function(e){let t=new Set,s=new Set,n=!1,r=!1;const a=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function o(t){a.has(t)&&(l.schedule(t),e()),t(i)}const l={schedule:(e,r=!1,i=!1)=>{const o=i&&n?t:s;return r&&a.add(e),o.has(e)||o.add(e),e},cancel:e=>{s.delete(e),a.delete(e)},process:e=>{i=e,n?r=!0:(n=!0,[t,s]=[s,t],t.forEach(o),t.clear(),n=!1,r&&(r=!1,l.process(e)))}};return l}(a),e),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:h,render:m,postRender:p}=i,f=()=>{const a=fs.useManualTiming?r.timestamp:performance.now();s=!1,fs.useManualTiming||(r.delta=n?1e3/60:Math.max(Math.min(a-r.timestamp,40),1)),r.timestamp=a,r.isProcessing=!0,o.process(r),l.process(r),c.process(r),d.process(r),u.process(r),h.process(r),m.process(r),p.process(r),r.isProcessing=!1,s&&t&&(n=!1,e(f))};return{schedule:Ks.reduce((t,a)=>{const o=i[a];return t[a]=(t,a=!1,i=!1)=>(s||(s=!0,n=!0,r.isProcessing||e(f)),o.schedule(t,a,i)),t},{}),cancel:e=>{for(let t=0;t<Ks.length;t++)i[Ks[t]].cancel(e)},state:r,steps:i}}const{schedule:Qs,cancel:Gs,state:Js,steps:Xs}=Ys("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:bs,!0);let Zs;function en(){Zs=void 0}const tn={now:()=>(void 0===Zs&&tn.set(Js.isProcessing||fs.useManualTiming?Js.timestamp:performance.now()),Zs),set:e=>{Zs=e,queueMicrotask(en)}},sn=e=>t=>"string"==typeof t&&t.startsWith(e),nn=sn("--"),rn=sn("var(--"),an=e=>!!rn(e)&&on.test(e.split("/*")[0].trim()),on=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ln={test:e=>"number"==typeof e,parse:parseFloat,transform:e=>e},cn={...ln,transform:e=>us(0,1,e)},dn={...ln,default:1},un=e=>Math.round(1e5*e)/1e5,hn=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const mn=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,pn=(e,t)=>s=>Boolean("string"==typeof s&&mn.test(s)&&s.startsWith(e)||t&&!function(e){return null==e}(s)&&Object.prototype.hasOwnProperty.call(s,t)),fn=(e,t,s)=>n=>{if("string"!=typeof n)return n;const[r,a,i,o]=n.match(hn);return{[e]:parseFloat(r),[t]:parseFloat(a),[s]:parseFloat(i),alpha:void 0!==o?parseFloat(o):1}},gn={...ln,transform:e=>Math.round((e=>us(0,255,e))(e))},yn={test:pn("rgb","red"),parse:fn("red","green","blue"),transform:({red:e,green:t,blue:s,alpha:n=1})=>"rgba("+gn.transform(e)+", "+gn.transform(t)+", "+gn.transform(s)+", "+un(cn.transform(n))+")"};const xn={test:pn("#"),parse:function(e){let t="",s="",n="",r="";return e.length>5?(t=e.substring(1,3),s=e.substring(3,5),n=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),s=e.substring(2,3),n=e.substring(3,4),r=e.substring(4,5),t+=t,s+=s,n+=n,r+=r),{red:parseInt(t,16),green:parseInt(s,16),blue:parseInt(n,16),alpha:r?parseInt(r,16)/255:1}},transform:yn.transform},vn=e=>({test:t=>"string"==typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>`${t}${e}`}),bn=vn("deg"),wn=vn("%"),Sn=vn("px"),jn=vn("vh"),kn=vn("vw"),Nn=(()=>({...wn,parse:e=>wn.parse(e)/100,transform:e=>wn.transform(100*e)}))(),En={test:pn("hsl","hue"),parse:fn("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:s,alpha:n=1})=>"hsla("+Math.round(e)+", "+wn.transform(un(t))+", "+wn.transform(un(s))+", "+un(cn.transform(n))+")"},Cn={test:e=>yn.test(e)||xn.test(e)||En.test(e),parse:e=>yn.test(e)?yn.parse(e):En.test(e)?En.parse(e):xn.parse(e),transform:e=>"string"==typeof e?e:e.hasOwnProperty("red")?yn.transform(e):En.transform(e),getAnimatableNone:e=>{const t=Cn.parse(e);return t.alpha=0,Cn.transform(t)}},Tn=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const Pn="number",An="color",Rn=/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 Mn(e){const t=e.toString(),s=[],n={color:[],number:[],var:[]},r=[];let a=0;const i=t.replace(Rn,e=>(Cn.test(e)?(n.color.push(a),r.push(An),s.push(Cn.parse(e))):e.startsWith("var(")?(n.var.push(a),r.push("var"),s.push(e)):(n.number.push(a),r.push(Pn),s.push(parseFloat(e))),++a,"${}")).split("${}");return{values:s,split:i,indexes:n,types:r}}function Dn(e){return Mn(e).values}function $n(e){const{split:t,types:s}=Mn(e),n=t.length;return e=>{let r="";for(let a=0;a<n;a++)if(r+=t[a],void 0!==e[a]){const t=s[a];r+=t===Pn?un(e[a]):t===An?Cn.transform(e[a]):e[a]}return r}}const On=e=>"number"==typeof e?0:Cn.test(e)?Cn.getAnimatableNone(e):e;const Fn={test:function(e){var t,s;return isNaN(e)&&"string"==typeof e&&((null==(t=e.match(hn))?void 0:t.length)||0)+((null==(s=e.match(Tn))?void 0:s.length)||0)>0},parse:Dn,createTransformer:$n,getAnimatableNone:function(e){const t=Dn(e);return $n(e)(t.map(On))}};function zn(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+(t-e)*(2/3-s)*6:e}function Ln(e,t){return s=>s>0?t:e}const In=(e,t,s)=>e+(t-e)*s,_n=(e,t,s)=>{const n=e*e,r=s*(t*t-n)+n;return r<0?0:Math.sqrt(r)},Vn=[xn,yn,En];function Bn(e){const t=(s=e,Vn.find(e=>e.test(s)));var s;if(ms(Boolean(t),`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!Boolean(t))return!1;let n=t.parse(e);return t===En&&(n=function({hue:e,saturation:t,lightness:s,alpha:n}){e/=360,s/=100;let r=0,a=0,i=0;if(t/=100){const n=s<.5?s*(1+t):s+t-s*t,o=2*s-n;r=zn(o,n,e+1/3),a=zn(o,n,e),i=zn(o,n,e-1/3)}else r=a=i=s;return{red:Math.round(255*r),green:Math.round(255*a),blue:Math.round(255*i),alpha:n}}(n)),n}const qn=(e,t)=>{const s=Bn(e),n=Bn(t);if(!s||!n)return Ln(e,t);const r={...s};return e=>(r.red=_n(s.red,n.red,e),r.green=_n(s.green,n.green,e),r.blue=_n(s.blue,n.blue,e),r.alpha=In(s.alpha,n.alpha,e),yn.transform(r))},Un=new Set(["none","hidden"]);function Wn(e,t){return s=>In(e,t,s)}function Hn(e){return"number"==typeof e?Wn:"string"==typeof e?an(e)?Ln:Cn.test(e)?qn:Qn:Array.isArray(e)?Kn:"object"==typeof e?Cn.test(e)?qn:Yn:Ln}function Kn(e,t){const s=[...e],n=s.length,r=e.map((e,s)=>Hn(e)(e,t[s]));return e=>{for(let t=0;t<n;t++)s[t]=r[t](e);return s}}function Yn(e,t){const s={...e,...t},n={};for(const r in s)void 0!==e[r]&&void 0!==t[r]&&(n[r]=Hn(e[r])(e[r],t[r]));return e=>{for(const t in n)s[t]=n[t](e);return s}}const Qn=(e,t)=>{const s=Fn.createTransformer(t),n=Mn(e),r=Mn(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?Un.has(e)&&!r.values.length||Un.has(t)&&!n.values.length?function(e,t){return Un.has(e)?s=>s<=0?e:t:s=>s>=1?t:e}(e,t):Ss(Kn(function(e,t){const s=[],n={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const a=t.types[r],i=e.indexes[a][n[a]],o=e.values[i]??0;s[r]=o,n[a]++}return s}(n,r),r.values),s):(ms(!0,`Complex values '${e}' and '${t}' 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"),Ln(e,t))};function Gn(e,t,s){if("number"==typeof e&&"number"==typeof t&&"number"==typeof s)return In(e,t,s);return Hn(e)(e,t)}const Jn=e=>{const t=({timestamp:t})=>e(t);return{start:(e=!0)=>Qs.update(t,e),stop:()=>Gs(t),now:()=>Js.isProcessing?Js.timestamp:tn.now()}},Xn=(e,t,s=10)=>{let n="";const r=Math.max(Math.round(t/s),2);for(let a=0;a<r;a++)n+=Math.round(1e4*e(a/(r-1)))/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},Zn=2e4;function er(e){let t=0;let s=e.next(t);for(;!s.done&&t<Zn;)t+=50,s=e.next(t);return t>=Zn?1/0:t}function tr(e,t,s){const n=Math.max(t-5,0);return Cs(s-e(n),t-n)}const sr=100,nr=10,rr=1,ar=0,ir=800,or=.3,lr=.3,cr={granular:.01,default:2},dr={granular:.005,default:.5},ur=.01,hr=10,mr=.05,pr=1,fr=.001;function gr({duration:e=ir,bounce:t=or,velocity:s=ar,mass:n=rr}){let r,a;ms(e<=Ns(hr),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=us(mr,pr,i),e=us(ur,hr,Es(e)),i<1?(r=t=>{const n=t*i,r=n*e,a=n-s,o=xr(t,i),l=Math.exp(-r);return fr-a/o*l},a=t=>{const n=t*i*e,a=n*s+s,o=Math.pow(i,2)*Math.pow(t,2)*e,l=Math.exp(-n),c=xr(Math.pow(t,2),i);return(-r(t)+fr>0?-1:1)*((a-o)*l)/c}):(r=t=>Math.exp(-t*e)*((t-s)*e+1)-.001,a=t=>Math.exp(-t*e)*(e*e*(s-t)));const o=function(e,t,s){let n=s;for(let r=1;r<yr;r++)n-=e(n)/t(n);return n}(r,a,5/e);if(e=Ns(e),isNaN(o))return{stiffness:sr,damping:nr,duration:e};{const t=Math.pow(o,2)*n;return{stiffness:t,damping:2*i*Math.sqrt(n*t),duration:e}}}const yr=12;function xr(e,t){return e*Math.sqrt(1-t*t)}const vr=["duration","bounce"],br=["stiffness","damping","mass"];function wr(e,t){return t.some(t=>void 0!==e[t])}function Sr(e=lr,t=or){const s="object"!=typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:n,restDelta:r}=s;const a=s.keyframes[0],i=s.keyframes[s.keyframes.length-1],o={done:!1,value:a},{stiffness:l,damping:c,mass:d,duration:u,velocity:h,isResolvedFromDuration:m}=function(e){let t={velocity:ar,stiffness:sr,damping:nr,mass:rr,isResolvedFromDuration:!1,...e};if(!wr(e,br)&&wr(e,vr))if(e.visualDuration){const s=e.visualDuration,n=2*Math.PI/(1.2*s),r=n*n,a=2*us(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:rr,stiffness:r,damping:a}}else{const s=gr(e);t={...t,...s,mass:rr},t.isResolvedFromDuration=!0}return t}({...s,velocity:-Es(s.velocity||0)}),p=h||0,f=c/(2*Math.sqrt(l*d)),g=i-a,y=Es(Math.sqrt(l/d)),x=Math.abs(g)<5;let v;if(n||(n=x?cr.granular:cr.default),r||(r=x?dr.granular:dr.default),f<1){const e=xr(y,f);v=t=>{const s=Math.exp(-f*y*t);return i-s*((p+f*y*g)/e*Math.sin(e*t)+g*Math.cos(e*t))}}else if(1===f)v=e=>i-Math.exp(-y*e)*(g+(p+y*g)*e);else{const e=y*Math.sqrt(f*f-1);v=t=>{const s=Math.exp(-f*y*t),n=Math.min(e*t,300);return i-s*((p+f*y*g)*Math.sinh(n)+e*g*Math.cosh(n))/e}}const b={calculatedDuration:m&&u||null,next:e=>{const t=v(e);if(m)o.done=e>=u;else{let s=0===e?p:0;f<1&&(s=0===e?Ns(p):tr(v,e,t));const a=Math.abs(s)<=n,l=Math.abs(i-t)<=r;o.done=a&&l}return o.value=o.done?i:t,o},toString:()=>{const e=Math.min(er(b),Zn),t=Xn(t=>b.next(e*t).value,e,30);return e+"ms "+t},toTransition:()=>{}};return b}function jr({keyframes:e,velocity:t=0,power:s=.8,timeConstant:n=325,bounceDamping:r=10,bounceStiffness:a=500,modifyTarget:i,min:o,max:l,restDelta:c=.5,restSpeed:d}){const u=e[0],h={done:!1,value:u},m=e=>void 0===o?l:void 0===l||Math.abs(o-e)<Math.abs(l-e)?o:l;let p=s*t;const f=u+p,g=void 0===i?f:i(f);g!==f&&(p=g-u);const y=e=>-p*Math.exp(-e/n),x=e=>g+y(e),v=e=>{const t=y(e),s=x(e);h.done=Math.abs(t)<=c,h.value=h.done?g:s};let b,w;const S=e=>{var t;(t=h.value,void 0!==o&&t<o||void 0!==l&&t>l)&&(b=e,w=Sr({keyframes:[h.value,m(h.value)],velocity:tr(x,e,h.value),damping:r,stiffness:a,restDelta:c,restSpeed:d}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return w||void 0!==b||(t=!0,v(e),S(e)),void 0!==b&&e>=b?w.next(e-b):(!t&&v(e),h)}}}function kr(e,t,{clamp:s=!0,ease:n,mixer:r}={}){const a=e.length;if(ps(a===t.length,"Both input and output ranges must be the same length","range-length"),1===a)return()=>t[0];if(2===a&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=function(e,t,s){const n=[],r=s||fs.mix||Gn,a=e.length-1;for(let i=0;i<a;i++){let s=r(e[i],e[i+1]);if(t){const e=Array.isArray(t)?t[i]||bs:t;s=Ss(e,s)}n.push(s)}return n}(t,n,r),l=o.length,c=s=>{if(i&&s<e[0])return t[0];let n=0;if(l>1)for(;n<e.length-2&&!(s<e[n+1]);n++);const r=js(e[n],e[n+1],s);return o[n](r)};return s?t=>c(us(e[0],e[a-1],t)):c}function Nr(e){const t=[0];return function(e,t){const s=e[e.length-1];for(let n=1;n<=t;n++){const r=js(0,t,n);e.push(In(s,1,r))}}(t,e.length-1),t}function Er({duration:e=300,keyframes:t,times:s,ease:n="easeInOut"}){const r=(e=>Array.isArray(e)&&"number"!=typeof e[0])(n)?n.map(Hs):Hs(n),a={done:!1,value:t[0]},i=function(e,t){return e.map(e=>e*t)}(s&&s.length===t.length?s:Nr(t),e),o=kr(i,t,{ease:Array.isArray(r)?r:(l=t,c=r,l.map(()=>c||qs).splice(0,l.length-1))});var l,c;return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}Sr.applyToOptions=e=>{const t=function(e,t=100,s){const n=s({...e,keyframes:[0,t]}),r=Math.min(er(n),Zn);return{type:"keyframes",ease:e=>n.next(r*e).value/t,duration:Es(r)}}(e,100,Sr);return e.ease=t.ease,e.duration=Ns(t.duration),e.type="keyframes",e};const Cr=e=>null!==e;function Tr(e,{repeat:t,repeatType:s="loop"},n,r=1){const a=e.filter(Cr),i=r<0||t&&"loop"!==s&&t%2==1?0:a.length-1;return i&&void 0!==n?n:a[i]}const Pr={decay:jr,inertia:jr,tween:Er,keyframes:Er,spring:Sr};function Ar(e){"string"==typeof e.type&&(e.type=Pr[e.type])}class Rr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}const Mr=e=>e/100;class Dr extends Rr{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var e,t;const{motionValue:s}=this.options;s&&s.updatedAt!==tn.now()&&this.tick(tn.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),null==(t=(e=this.options).onStop)||t.call(e))},this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){const{options:e}=this;Ar(e);const{type:t=Er,repeat:s=0,repeatDelay:n=0,repeatType:r,velocity:a=0}=e;let{keyframes:i}=e;const o=t||Er;"production"!==process.env.NODE_ENV&&o!==Er&&ps(i.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${i}`,"spring-two-frames"),o!==Er&&"number"!=typeof i[0]&&(this.mixKeyframes=Ss(Mr,Gn(i[0],i[1])),i=[0,100]);const l=o({...e,keyframes:i});"mirror"===r&&(this.mirroredGenerator=o({...e,keyframes:[...i].reverse(),velocity:-a})),null===l.calculatedDuration&&(l.calculatedDuration=er(l));const{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+n,this.totalDuration=this.resolvedDuration*(s+1)-n,this.generator=l}updateTime(e){const t=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){const{generator:s,totalDuration:n,mixKeyframes:r,mirroredGenerator:a,resolvedDuration:i,calculatedDuration:o}=this;if(null===this.startTime)return s.next(0);const{delay:l=0,keyframes:c,repeat:d,repeatType:u,repeatDelay:h,type:m,onUpdate:p,finalKeyframe:f}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-n/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);const g=this.currentTime-l*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?g<0:g>n;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=n);let x=this.currentTime,v=s;if(d){const e=Math.min(this.currentTime,n)/i;let t=Math.floor(e),s=e%1;!s&&e>=1&&(s=1),1===s&&t--,t=Math.min(t,d+1);Boolean(t%2)&&("reverse"===u?(s=1-s,h&&(s-=h/i)):"mirror"===u&&(v=a)),x=us(0,1,s)*i}const b=y?{done:!1,value:c[0]}:v.next(x);r&&(b.value=r(b.value));let{done:w}=b;y||null===o||(w=this.playbackSpeed>=0?this.currentTime>=n:this.currentTime<=0);const S=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return S&&m!==jr&&(b.value=Tr(c,this.options,f,this.speed)),p&&p(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return Es(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Es(e)}get time(){return Es(this.currentTime)}set time(e){var t;e=Ns(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),null==(t=this.driver)||t.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(tn.now());const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=Es(this.currentTime))}play(){var e,t;if(this.isStopped)return;const{driver:s=Jn,startTime:n}=this.options;this.driver||(this.driver=s(e=>this.tick(e))),null==(t=(e=this.options).onPlay)||t.call(e);const r=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=r):null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(tn.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,t;this.notifyFinished(),this.teardown(),this.state="finished",null==(t=(e=this.options).onComplete)||t.call(e)}cancel(){var e,t;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),null==(t=(e=this.options).onCancel)||t.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var t;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),null==(t=this.driver)||t.stop(),e.observe(this)}}const $r=e=>180*e/Math.PI,Or=e=>{const t=$r(Math.atan2(e[1],e[0]));return zr(t)},Fr={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Or,rotateZ:Or,skewX:e=>$r(Math.atan(e[1])),skewY:e=>$r(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},zr=e=>((e%=360)<0&&(e+=360),e),Lr=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ir=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),_r={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Lr,scaleY:Ir,scale:e=>(Lr(e)+Ir(e))/2,rotateX:e=>zr($r(Math.atan2(e[6],e[5]))),rotateY:e=>zr($r(Math.atan2(-e[2],e[0]))),rotateZ:Or,rotate:Or,skewX:e=>$r(Math.atan(e[4])),skewY:e=>$r(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Vr(e){return e.includes("scale")?1:0}function Br(e,t){if(!e||"none"===e)return Vr(t);const s=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,r;if(s)n=_r,r=s;else{const t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Fr,r=t}if(!r)return Vr(t);const a=n[t],i=r[1].split(",").map(qr);return"function"==typeof a?a(i):i[a]}function qr(e){return parseFloat(e.trim())}const Ur=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Wr=(()=>new Set(Ur))(),Hr=e=>e===ln||e===Sn,Kr=new Set(["x","y","z"]),Yr=Ur.filter(e=>!Kr.has(e));const Qr={width:({x:e},{paddingLeft:t="0",paddingRight:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),height:({y:e},{paddingTop:t="0",paddingBottom:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Br(t,"x"),y:(e,{transform:t})=>Br(t,"y")};Qr.translateX=Qr.x,Qr.translateY=Qr.y;const Gr=new Set;let Jr=!1,Xr=!1,Zr=!1;function ea(){if(Xr){const e=Array.from(Gr).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),s=new Map;t.forEach(e=>{const t=function(e){const t=[];return Yr.forEach(s=>{const n=e.getValue(s);void 0!==n&&(t.push([s,n.get()]),n.set(s.startsWith("scale")?1:0))}),t}(e);t.length&&(s.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();const t=s.get(e);t&&t.forEach(([t,s])=>{var n;null==(n=e.getValue(t))||n.set(s)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}Xr=!1,Jr=!1,Gr.forEach(e=>e.complete(Zr)),Gr.clear()}function ta(){Gr.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Xr=!0)})}class sa{constructor(e,t,s,n,r,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=s,this.motionValue=n,this.element=r,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Gr.add(this),Jr||(Jr=!0,Qs.read(ta),Qs.resolveKeyframes(ea))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:s,motionValue:n}=this;if(null===e[0]){const r=null==n?void 0:n.get(),a=e[e.length-1];if(void 0!==r)e[0]=r;else if(s&&t){const n=s.readValue(t,a);null!=n&&(e[0]=n)}void 0===e[0]&&(e[0]=a),n&&void 0===r&&n.set(e[0])}!function(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Gr.delete(this)}cancel(){"scheduled"===this.state&&(Gr.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}const na=vs(()=>void 0!==window.ScrollTimeline),ra={};function aa(e,t){const s=vs(e);return()=>ra[t]??s()}const ia=aa(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),oa=([e,t,s,n])=>`cubic-bezier(${e}, ${t}, ${s}, ${n})`,la={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:oa([0,.65,.55,1]),circOut:oa([.55,0,1,.45]),backIn:oa([.31,.01,.66,-.59]),backOut:oa([.33,1.53,.69,.99])};function ca(e,t){return e?"function"==typeof e?ia()?Xn(e,t):"ease-out":Us(e)?oa(e):Array.isArray(e)?e.map(e=>ca(e,t)||la.easeOut):la[e]:void 0}function da(e,t,s,{delay:n=0,duration:r=300,repeat:a=0,repeatType:i="loop",ease:o="easeOut",times:l}={},c=void 0){const d={[t]:s};l&&(d.offset=l);const u=ca(o,r);Array.isArray(u)&&(d.easing=u);const h={delay:n,duration:r,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:a+1,direction:"reverse"===i?"alternate":"normal"};c&&(h.pseudoElement=c);return e.animate(d,h)}function ua(e){return"function"==typeof e&&"applyToOptions"in e}class ha extends Rr{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:t,name:s,keyframes:n,pseudoElement:r,allowFlatten:a=!1,finalKeyframe:i,onComplete:o}=e;this.isPseudoElement=Boolean(r),this.allowFlatten=a,this.options=e,ps("string"!=typeof e.type,'Mini animate() doesn\'t support "type" as a string.',"mini-spring");const l=function({type:e,...t}){return ua(e)&&ia()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}(e);this.animation=da(t,s,n,l,r),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const e=Tr(n,this.options,i,this.speed);this.updateMotionValue?this.updateMotionValue(e):function(e,t,s){(e=>e.startsWith("--"))(t)?e.style.setProperty(t,s):e.style[t]=s}(t,s,e),this.animation.cancel()}null==o||o(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,t;null==(t=(e=this.animation).finish)||t.call(e)}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,t;this.isPseudoElement||null==(t=(e=this.animation).commitStyles)||t.call(e)}get duration(){var e,t;const s=(null==(t=null==(e=this.animation.effect)?void 0:e.getComputedTiming)?void 0:t.call(e).duration)||0;return Es(Number(s))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Es(e)}get time(){return Es(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ns(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:t}){var s;return this.allowFlatten&&(null==(s=this.animation.effect)||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&na()?(this.animation.timeline=e,bs):t(this)}}const ma={anticipate:zs,backInOut:Fs,circInOut:_s};function pa(e){"string"==typeof e.ease&&e.ease in ma&&(e.ease=ma[e.ease])}class fa extends ha{constructor(e){pa(e),Ar(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:t,onUpdate:s,onComplete:n,element:r,...a}=this.options;if(!t)return;if(void 0!==e)return void t.set(e);const i=new Dr({...a,autoplay:!1}),o=Ns(this.finishedTime??this.time);t.setWithVelocity(i.sample(o-10).value,i.sample(o).value,10),i.stop()}}const ga=(e,t)=>"zIndex"!==t&&(!("number"!=typeof e&&!Array.isArray(e))||!("string"!=typeof e||!Fn.test(e)&&"0"!==e||e.startsWith("url(")));function ya(e){e.duration=0,e.type="keyframes"}const xa=new Set(["opacity","clipPath","filter","transform"]),va=vs(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class ba extends Rr{constructor({autoplay:e=!0,delay:t=0,type:s="keyframes",repeat:n=0,repeatDelay:r=0,repeatType:a="loop",keyframes:i,name:o,motionValue:l,element:c,...d}){var u;super(),this.stop=()=>{var e,t;this._animation&&(this._animation.stop(),null==(e=this.stopTimeline)||e.call(this)),null==(t=this.keyframeResolver)||t.cancel()},this.createdAt=tn.now();const h={autoplay:e,delay:t,type:s,repeat:n,repeatDelay:r,repeatType:a,name:o,motionValue:l,element:c,...d},m=(null==c?void 0:c.KeyframeResolver)||sa;this.keyframeResolver=new m(i,(e,t,s)=>this.onKeyframesResolved(e,t,h,!s),o,l,c),null==(u=this.keyframeResolver)||u.scheduleResolve()}onKeyframesResolved(e,t,s,n){this.keyframeResolver=void 0;const{name:r,type:a,velocity:i,delay:o,isHandoff:l,onUpdate:c}=s;this.resolvedAt=tn.now(),function(e,t,s,n){const r=e[0];if(null===r)return!1;if("display"===t||"visibility"===t)return!0;const a=e[e.length-1],i=ga(r,t),o=ga(a,t);return ms(i===o,`You are trying to animate ${t} from "${r}" to "${a}". "${i?a:r}" is not an animatable value.`,"value-not-animatable"),!(!i||!o)&&(function(e){const t=e[0];if(1===e.length)return!0;for(let s=0;s<e.length;s++)if(e[s]!==t)return!0}(e)||("spring"===s||ua(s))&&n)}(e,r,a,i)||(!fs.instantAnimations&&o||null==c||c(Tr(e,s,t)),e[0]=e[e.length-1],ya(s),s.repeat=0);const d={startTime:n?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...s,keyframes:e},u=!l&&function(e){var t;const{motionValue:s,name:n,repeatDelay:r,repeatType:a,damping:i,type:o}=e;if(!((null==(t=null==s?void 0:s.owner)?void 0:t.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=s.owner.getProps();return va()&&n&&xa.has(n)&&("transform"!==n||!c)&&!l&&!r&&"mirror"!==a&&0!==i&&"inertia"!==o}(d)?new fa({...d,element:d.motionValue.owner.current}):new Dr(d);u.finished.then(()=>this.notifyFinished()).catch(bs),this.pendingTimeline&&(this.stopTimeline=u.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=u}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||(null==(e=this.keyframeResolver)||e.resume(),Zr=!0,ta(),ea(),Zr=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),null==(e=this.keyframeResolver)||e.cancel()}}const wa=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Sa(e,t,s=1){ps(s<=4,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[n,r]=function(e){const t=wa.exec(e);if(!t)return[,];const[,s,n,r]=t;return[`--${s??n}`,r]}(e);if(!n)return;const a=window.getComputedStyle(t).getPropertyValue(n);if(a){const e=a.trim();return gs(e)?parseFloat(e):e}return an(r)?Sa(r,t,s+1):r}function ja(e,t){return(null==e?void 0:e[t])??(null==e?void 0:e.default)??e}const ka=new Set(["width","height","top","left","right","bottom",...Ur]),Na=e=>t=>t.test(e),Ea=[ln,Sn,wn,bn,kn,jn,{test:e=>"auto"===e,parse:e=>e}],Ca=e=>Ea.find(Na(e));function Ta(e){return"number"==typeof e?0===e:null===e||("none"===e||"0"===e||xs(e))}const Pa=new Set(["brightness","contrast","saturate","opacity"]);function Aa(e){const[t,s]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;const[n]=s.match(hn)||[];if(!n)return e;const r=s.replace(n,"");let a=Pa.has(t)?1:0;return n!==s&&(a*=100),t+"("+a+r+")"}const Ra=/\b([a-z-]*)\(.*?\)/gu,Ma={...Fn,getAnimatableNone:e=>{const t=e.match(Ra);return t?t.map(Aa).join(" "):e}},Da={...ln,transform:Math.round},$a={borderWidth:Sn,borderTopWidth:Sn,borderRightWidth:Sn,borderBottomWidth:Sn,borderLeftWidth:Sn,borderRadius:Sn,radius:Sn,borderTopLeftRadius:Sn,borderTopRightRadius:Sn,borderBottomRightRadius:Sn,borderBottomLeftRadius:Sn,width:Sn,maxWidth:Sn,height:Sn,maxHeight:Sn,top:Sn,right:Sn,bottom:Sn,left:Sn,padding:Sn,paddingTop:Sn,paddingRight:Sn,paddingBottom:Sn,paddingLeft:Sn,margin:Sn,marginTop:Sn,marginRight:Sn,marginBottom:Sn,marginLeft:Sn,backgroundPositionX:Sn,backgroundPositionY:Sn,...{rotate:bn,rotateX:bn,rotateY:bn,rotateZ:bn,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:bn,skewX:bn,skewY:bn,distance:Sn,translateX:Sn,translateY:Sn,translateZ:Sn,x:Sn,y:Sn,z:Sn,perspective:Sn,transformPerspective:Sn,opacity:cn,originX:Nn,originY:Nn,originZ:Sn},zIndex:Da,fillOpacity:cn,strokeOpacity:cn,numOctaves:Da},Oa={...$a,color:Cn,backgroundColor:Cn,outlineColor:Cn,fill:Cn,stroke:Cn,borderColor:Cn,borderTopColor:Cn,borderRightColor:Cn,borderBottomColor:Cn,borderLeftColor:Cn,filter:Ma,WebkitFilter:Ma},Fa=e=>Oa[e];function za(e,t){let s=Fa(e);return s!==Ma&&(s=Fn),s.getAnimatableNone?s.getAnimatableNone(t):void 0}const La=new Set(["auto","none","0"]);class Ia extends sa{constructor(e,t,s,n,r){super(e,t,s,n,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:s}=this;if(!t||!t.current)return;super.readKeyframes();for(let o=0;o<e.length;o++){let s=e[o];if("string"==typeof s&&(s=s.trim(),an(s))){const n=Sa(s,t.current);void 0!==n&&(e[o]=n),o===e.length-1&&(this.finalKeyframe=s)}}if(this.resolveNoneKeyframes(),!ka.has(s)||2!==e.length)return;const[n,r]=e,a=Ca(n),i=Ca(r);if(a!==i)if(Hr(a)&&Hr(i))for(let o=0;o<e.length;o++){const t=e[o];"string"==typeof t&&(e[o]=parseFloat(t))}else Qr[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,s=[];for(let n=0;n<e.length;n++)(null===e[n]||Ta(e[n]))&&s.push(n);s.length&&function(e,t,s){let n,r=0;for(;r<e.length&&!n;){const t=e[r];"string"==typeof t&&!La.has(t)&&Mn(t).values.length&&(n=e[r]),r++}if(n&&s)for(const a of t)e[a]=za(s,n)}(e,s,t)}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:s}=this;if(!e||!e.current)return;"height"===s&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Qr[s](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;const n=t[t.length-1];void 0!==n&&e.getValue(s,n).jump(n,!1)}measureEndState(){var e;const{element:t,name:s,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const r=t.getValue(s);r&&r.jump(this.measuredOrigin,!1);const a=n.length-1,i=n[a];n[a]=Qr[s](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),(null==(e=this.removedTransforms)?void 0:e.length)&&this.removedTransforms.forEach(([e,s])=>{t.getValue(e).set(s)}),this.resolveNoneKeyframes()}}const _a=(e,t)=>t&&"number"==typeof e?t.transform(e):e;function Va(e){return ys(e)&&"offsetHeight"in e}class Ba{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{var t;const s=tn.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(null==(t=this.events.change)||t.notify(this.current),this.dependents))for(const n of this.dependents)n.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=tn.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return"production"!==process.env.NODE_ENV&&Ps(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new ks);const s=this.events[e].add(t);return"change"===e?()=>{s(),Qs.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,s){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;null==(e=this.events.change)||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=tn.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return Cs(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),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 e,t;null==(e=this.dependents)||e.clear(),null==(t=this.events.destroy)||t.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function qa(e,t){return new Ba(e,t)}const{schedule:Ua}=Ys(queueMicrotask,!1),Wa={x:!1,y:!1};function Ha(){return Wa.x||Wa.y}function Ka(e,t){const s=function(e,t,s){if(e instanceof EventTarget)return[e];if("string"==typeof e){let t=document;const n=(null==s?void 0:s[e])??t.querySelectorAll(e);return n?Array.from(n):[]}return Array.from(e)}(e),n=new AbortController;return[s,{passive:!0,...t,signal:n.signal},()=>n.abort()]}function Ya(e){return!("touch"===e.pointerType||Ha())}const Qa=(e,t)=>!!t&&(e===t||Qa(e,t.parentElement)),Ga=e=>"mouse"===e.pointerType?"number"!=typeof e.button||e.button<=0:!1!==e.isPrimary,Ja=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const Xa=new WeakSet;function Za(e){return t=>{"Enter"===t.key&&e(t)}}function ei(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function ti(e){return Ga(e)&&!Ha()}function si(e,t,s={}){const[n,r,a]=Ka(e,s),i=e=>{const n=e.currentTarget;if(!ti(e))return;Xa.add(n);const a=t(n,e),i=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",l),Xa.has(n)&&Xa.delete(n),ti(e)&&"function"==typeof a&&a(e,{success:t})},o=e=>{i(e,n===window||n===document||s.useGlobalTarget||Qa(n,e.target))},l=e=>{i(e,!1)};window.addEventListener("pointerup",o,r),window.addEventListener("pointercancel",l,r)};return n.forEach(e=>{var t;(s.useGlobalTarget?window:e).addEventListener("pointerdown",i,r),Va(e)&&(e.addEventListener("focus",e=>((e,t)=>{const s=e.currentTarget;if(!s)return;const n=Za(()=>{if(Xa.has(s))return;ei(s,"down");const e=Za(()=>{ei(s,"up")});s.addEventListener("keyup",e,t),s.addEventListener("blur",()=>ei(s,"cancel"),t)});s.addEventListener("keydown",n,t),s.addEventListener("blur",()=>s.removeEventListener("keydown",n),t)})(e,r)),t=e,Ja.has(t.tagName)||-1!==t.tabIndex||e.hasAttribute("tabindex")||(e.tabIndex=0))}),a}function ni(e){return ys(e)&&"ownerSVGElement"in e}const ri=e=>Boolean(e&&e.getVelocity),ai=[...Ea,Cn,Fn],ii=Oe.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function oi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function li(...e){return Le.useCallback(function(...e){return t=>{let s=!1;const n=e.map(e=>{const n=oi(e,t);return s||"function"!=typeof n||(s=!0),n});if(s)return()=>{for(let t=0;t<n.length;t++){const s=n[t];"function"==typeof s?s():oi(e[t],null)}}}}(...e),e)}class ci extends Le.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const e=t.offsetParent,s=Va(e)&&e.offsetWidth||0,n=this.props.sizeRef.current;n.height=t.offsetHeight||0,n.width=t.offsetWidth||0,n.top=t.offsetTop,n.left=t.offsetLeft,n.right=s-n.width-n.left}return null}componentDidUpdate(){}render(){return this.props.children}}function di({children:e,isPresent:t,anchorX:s,root:n}){const r=Oe.useId(),a=Oe.useRef(null),i=Oe.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:o}=Oe.useContext(ii),l=li(a,null==e?void 0:e.ref);return Oe.useInsertionEffect(()=>{const{width:e,height:l,top:c,left:d,right:u}=i.current;if(t||!a.current||!e||!l)return;const h="left"===s?`left: ${d}`:`right: ${u}`;a.current.dataset.motionPopId=r;const m=document.createElement("style");o&&(m.nonce=o);const p=n??document.head;return p.appendChild(m),m.sheet&&m.sheet.insertRule(`\n [data-motion-pop-id="${r}"] {\n position: absolute !important;\n width: ${e}px !important;\n height: ${l}px !important;\n ${h}px !important;\n top: ${c}px !important;\n }\n `),()=>{p.contains(m)&&p.removeChild(m)}},[t]),$e.jsx(ci,{isPresent:t,childRef:a,sizeRef:i,children:Le.cloneElement(e,{ref:l})})}const ui=({children:e,initial:t,isPresent:s,onExitComplete:n,custom:r,presenceAffectsLayout:a,mode:i,anchorX:o,root:l})=>{const c=as(hi),d=Oe.useId();let u=!0,h=Oe.useMemo(()=>(u=!1,{id:d,initial:t,isPresent:s,custom:r,onExitComplete:e=>{c.set(e,!0);for(const t of c.values())if(!t)return;n&&n()},register:e=>(c.set(e,!1),()=>c.delete(e))}),[s,c,n]);return a&&u&&(h={...h}),Oe.useMemo(()=>{c.forEach((e,t)=>c.set(t,!1))},[s]),Le.useEffect(()=>{!s&&!c.size&&n&&n()},[s]),"popLayout"===i&&(e=$e.jsx(di,{isPresent:s,anchorX:o,root:l,children:e})),$e.jsx(ls.Provider,{value:h,children:e})};function hi(){return new Map}function mi(e=!0){const t=Oe.useContext(ls);if(null===t)return[!0,null];const{isPresent:s,onExitComplete:n,register:r}=t,a=Oe.useId();Oe.useEffect(()=>{if(e)return r(a)},[e]);const i=Oe.useCallback(()=>e&&n&&n(a),[a,n,e]);return!s&&n?[!1,i]:[!0]}const pi=e=>e.key||"";function fi(e){const t=[];return Oe.Children.forEach(e,e=>{Oe.isValidElement(e)&&t.push(e)}),t}const gi=({children:e,custom:t,initial:s=!0,onExitComplete:n,presenceAffectsLayout:r=!0,mode:a="sync",propagate:i=!1,anchorX:o="left",root:l})=>{const[c,d]=mi(i),u=Oe.useMemo(()=>fi(e),[e]),h=i&&!c?[]:u.map(pi),m=Oe.useRef(!0),p=Oe.useRef(u),f=as(()=>new Map),[g,y]=Oe.useState(u),[x,v]=Oe.useState(u);os(()=>{m.current=!1,p.current=u;for(let e=0;e<x.length;e++){const t=pi(x[e]);h.includes(t)?f.delete(t):!0!==f.get(t)&&f.set(t,!1)}},[x,h.length,h.join("-")]);const b=[];if(u!==g){let e=[...u];for(let t=0;t<x.length;t++){const s=x[t],n=pi(s);h.includes(n)||(e.splice(t,0,s),b.push(s))}return"wait"===a&&b.length&&(e=b),v(fi(e)),y(u),null}"production"!==process.env.NODE_ENV&&"wait"===a&&x.length>1&&console.warn('You\'re attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.');const{forceRender:w}=Oe.useContext(rs);return $e.jsx($e.Fragment,{children:x.map(e=>{const g=pi(e),y=!(i&&!c)&&(u===x||h.includes(g));return $e.jsx(ui,{isPresent:y,initial:!(m.current&&!s)&&void 0,custom:t,presenceAffectsLayout:r,mode:a,root:l,onExitComplete:y?void 0:()=>{if(!f.has(g))return;f.set(g,!0);let e=!0;f.forEach(t=>{t||(e=!1)}),e&&(null==w||w(),v(p.current),i&&(null==d||d()),n&&n())},anchorX:o,children:e},g)})})},yi=Oe.createContext({strict:!1}),xi={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"]},vi={};for(const zv in xi)vi[zv]={isEnabled:e=>xi[zv].some(t=>!!e[t])};const bi=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","ignoreStrict","viewport"]);function wi(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||bi.has(e)}let Si=e=>!wi(e);try{"function"==typeof(ji=require("@emotion/is-prop-valid").default)&&(Si=e=>e.startsWith("on")?!wi(e):ji(e))}catch{}var ji;const ki=Oe.createContext({});function Ni(e){return null!==e&&"object"==typeof e&&"function"==typeof e.start}function Ei(e){return"string"==typeof e||Array.isArray(e)}const Ci=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ti=["initial",...Ci];function Pi(e){return Ni(e.animate)||Ti.some(t=>Ei(e[t]))}function Ai(e){return Boolean(Pi(e)||e.variants)}function Ri(e){const{initial:t,animate:s}=function(e,t){if(Pi(e)){const{initial:t,animate:s}=e;return{initial:!1===t||Ei(t)?t:void 0,animate:Ei(s)?s:void 0}}return!1!==e.inherit?t:{}}(e,Oe.useContext(ki));return Oe.useMemo(()=>({initial:t,animate:s}),[Mi(t),Mi(s)])}function Mi(e){return Array.isArray(e)?e.join(" "):e}const Di={};function $i(e,{layout:t,layoutId:s}){return Wr.has(e)||e.startsWith("origin")||(t||void 0!==s)&&(!!Di[e]||"opacity"===e)}const Oi={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Fi=Ur.length;function zi(e,t,s){const{style:n,vars:r,transformOrigin:a}=e;let i=!1,o=!1;for(const l in t){const e=t[l];if(Wr.has(l))i=!0;else if(nn(l))r[l]=e;else{const t=_a(e,$a[l]);l.startsWith("origin")?(o=!0,a[l]=t):n[l]=t}}if(t.transform||(i||s?n.transform=function(e,t,s){let n="",r=!0;for(let a=0;a<Fi;a++){const i=Ur[a],o=e[i];if(void 0===o)continue;let l=!0;if(l="number"==typeof o?o===(i.startsWith("scale")?1:0):0===parseFloat(o),!l||s){const e=_a(o,$a[i]);l||(r=!1,n+=`${Oi[i]||i}(${e}) `),s&&(t[i]=e)}}return n=n.trim(),s?n=s(t,r?"":n):r&&(n="none"),n}(t,e.transform,s):n.transform&&(n.transform="none")),o){const{originX:e="50%",originY:t="50%",originZ:s=0}=a;n.transformOrigin=`${e} ${t} ${s}`}}const Li=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ii(e,t,s){for(const n in t)ri(t[n])||$i(n,s)||(e[n]=t[n])}function _i(e,t){const s={};return Ii(s,e.style||{},e),Object.assign(s,function({transformTemplate:e},t){return Oe.useMemo(()=>{const s={style:{},transform:{},transformOrigin:{},vars:{}};return zi(s,t,e),Object.assign({},s.vars,s.style)},[t])}(e,t)),s}function Vi(e,t){const s={},n=_i(e,t);return e.drag&&!1!==e.dragListener&&(s.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=!0===e.drag?"none":"pan-"+("x"===e.drag?"y":"x")),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=n,s}const Bi={offset:"stroke-dashoffset",array:"stroke-dasharray"},qi={offset:"strokeDashoffset",array:"strokeDasharray"};function Ui(e,{attrX:t,attrY:s,attrScale:n,pathLength:r,pathSpacing:a=1,pathOffset:i=0,...o},l,c,d){if(zi(e,o,c),l)return void(e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox));e.attrs=e.style,e.style={};const{attrs:u,style:h}=e;u.transform&&(h.transform=u.transform,delete u.transform),(h.transform||u.transformOrigin)&&(h.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),h.transform&&(h.transformBox=(null==d?void 0:d.transformBox)??"fill-box",delete u.transformBox),void 0!==t&&(u.x=t),void 0!==s&&(u.y=s),void 0!==n&&(u.scale=n),void 0!==r&&function(e,t,s=1,n=0,r=!0){e.pathLength=1;const a=r?Bi:qi;e[a.offset]=Sn.transform(-n);const i=Sn.transform(t),o=Sn.transform(s);e[a.array]=`${i} ${o}`}(u,r,a,i,!1)}const Wi=()=>({style:{},transform:{},transformOrigin:{},vars:{},attrs:{}}),Hi=e=>"string"==typeof e&&"svg"===e.toLowerCase();function Ki(e,t,s,n){const r=Oe.useMemo(()=>{const s={style:{},transform:{},transformOrigin:{},vars:{},attrs:{}};return Ui(s,t,Hi(n),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const t={};Ii(t,e.style,e),r.style={...t,...r.style}}return r}const Yi=["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 Qi(e){return"string"==typeof e&&!e.includes("-")&&!!(Yi.indexOf(e)>-1||/[A-Z]/u.test(e))}function Gi(e,t,s,{latestValues:n},r,a=!1){const i=(Qi(e)?Ki:Vi)(t,n,r,e),o=function(e,t,s){const n={};for(const r in e)"values"===r&&"object"==typeof e.values||(Si(r)||!0===s&&wi(r)||!t&&!wi(r)||e.draggable&&r.startsWith("onDrag"))&&(n[r]=e[r]);return n}(t,"string"==typeof e,a),l=e!==Oe.Fragment?{...o,...i,ref:s}:{},{children:c}=t,d=Oe.useMemo(()=>ri(c)?c.get():c,[c]);return Oe.createElement(e,{...l,children:d})}function Ji(e){const t=[{},{}];return null==e||e.values.forEach((e,s)=>{t[0][s]=e.get(),t[1][s]=e.getVelocity()}),t}function Xi(e,t,s,n){if("function"==typeof t){const[r,a]=Ji(n);t=t(void 0!==s?s:e.custom,r,a)}if("string"==typeof t&&(t=e.variants&&e.variants[t]),"function"==typeof t){const[r,a]=Ji(n);t=t(void 0!==s?s:e.custom,r,a)}return t}function Zi(e){return ri(e)?e.get():e}function eo(e,t,s,n){const r={},a=n(e,{});for(const h in a)r[h]=Zi(a[h]);let{initial:i,animate:o}=e;const l=Pi(e),c=Ai(e);t&&c&&!l&&!1!==e.inherit&&(void 0===i&&(i=t.initial),void 0===o&&(o=t.animate));let d=!!s&&!1===s.initial;d=d||!1===i;const u=d?o:i;if(u&&"boolean"!=typeof u&&!Ni(u)){const t=Array.isArray(u)?u:[u];for(let s=0;s<t.length;s++){const n=Xi(e,t[s]);if(n){const{transitionEnd:e,transition:t,...s}=n;for(const n in s){let e=s[n];if(Array.isArray(e)){e=e[d?e.length-1:0]}null!==e&&(r[n]=e)}for(const n in e)r[n]=e[n]}}}return r}const to=e=>(t,s)=>{const n=Oe.useContext(ki),r=Oe.useContext(ls),a=()=>function({scrapeMotionValuesFromProps:e,createRenderState:t},s,n,r){return{latestValues:eo(s,n,r,e),renderState:t()}}(e,t,n,r);return s?a():as(a)};function so(e,t,s){var n;const{style:r}=e,a={};for(const i in r)(ri(r[i])||t.style&&ri(t.style[i])||$i(i,e)||void 0!==(null==(n=null==s?void 0:s.getValue(i))?void 0:n.liveStyle))&&(a[i]=r[i]);return a}const no=to({scrapeMotionValuesFromProps:so,createRenderState:Li});function ro(e,t,s){const n=so(e,t,s);for(const r in e)if(ri(e[r])||ri(t[r])){n[-1!==Ur.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]}return n}const ao=to({scrapeMotionValuesFromProps:ro,createRenderState:Wi}),io=Symbol.for("motionComponentSymbol");function oo(e){return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}function lo(e,t,s){return Oe.useCallback(n=>{n&&e.onMount&&e.onMount(n),t&&(n?t.mount(n):t.unmount()),s&&("function"==typeof s?s(n):oo(s)&&(s.current=n))},[t])}const co=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uo="data-"+co("framerAppearId"),ho=Oe.createContext({});function mo(e,t,s,n,r){var a,i;const{visualElement:o}=Oe.useContext(ki),l=Oe.useContext(yi),c=Oe.useContext(ls),d=Oe.useContext(ii).reducedMotion,u=Oe.useRef(null);n=n||l.renderer,!u.current&&n&&(u.current=n(e,{visualState:t,parent:o,props:s,presenceContext:c,blockInitialAnimation:!!c&&!1===c.initial,reducedMotionConfig:d}));const h=u.current,m=Oe.useContext(ho);!h||h.projection||!r||"html"!==h.type&&"svg"!==h.type||function(e,t,s,n){const{layoutId:r,layout:a,drag:i,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutCrossfade:d}=t;e.projection=new s(e.latestValues,t["data-framer-portal-id"]?void 0:po(e.parent)),e.projection.setOptions({layoutId:r,layout:a,alwaysMeasureLayout:Boolean(i)||o&&oo(o),visualElement:e,animationType:"string"==typeof a?a:"both",initialPromotionConfig:n,crossfade:d,layoutScroll:l,layoutRoot:c})}(u.current,s,r,m);const p=Oe.useRef(!1);Oe.useInsertionEffect(()=>{h&&p.current&&h.update(s,c)});const f=s[uo],g=Oe.useRef(Boolean(f)&&!(null==(a=window.MotionHandoffIsComplete)?void 0:a.call(window,f))&&(null==(i=window.MotionHasOptimisedAnimation)?void 0:i.call(window,f)));return os(()=>{h&&(p.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),g.current&&h.animationState&&h.animationState.animateChanges())}),Oe.useEffect(()=>{h&&(!g.current&&h.animationState&&h.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var e;null==(e=window.MotionHandoffMarkAsComplete)||e.call(window,f)}),g.current=!1),h.enteringChildren=void 0)}),h}function po(e){if(e)return!1!==e.options.allowProjection?e.projection:po(e.parent)}function fo(e,{forwardMotionProps:t=!1}={},s,n){s&&function(e){for(const t in e)vi[t]={...vi[t],...e[t]}}(s);const r=Qi(e)?ao:no;function a(a,i){let o;const l={...Oe.useContext(ii),...a,layoutId:go(a)},{isStatic:c}=l,d=Ri(a),u=r(a,c);if(!c&&is){!function(e,t){const s=Oe.useContext(yi).strict;if("production"!==process.env.NODE_ENV&&t&&s){const t="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?ms(!1,t,"lazy-strict-mode"):ps(!1,t,"lazy-strict-mode")}}(l,s);const t=function(e){const{drag:t,layout:s}=vi;if(!t&&!s)return{};const n={...t,...s};return{MeasureLayout:(null==t?void 0:t.isEnabled(e))||(null==s?void 0:s.isEnabled(e))?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}(l);o=t.MeasureLayout,d.visualElement=mo(e,u,l,n,t.ProjectionNode)}return $e.jsxs(ki.Provider,{value:d,children:[o&&d.visualElement?$e.jsx(o,{visualElement:d.visualElement,...l}):null,Gi(e,a,lo(u,d.visualElement,i),u,c,t)]})}a.displayName=`motion.${"string"==typeof e?e:`create(${e.displayName??e.name??""})`}`;const i=Oe.forwardRef(a);return i[io]=e,i}function go({layoutId:e}){const t=Oe.useContext(rs).id;return t&&void 0!==e?t+"-"+e:e}function yo(e,t){if("undefined"==typeof Proxy)return fo;const s=new Map,n=(s,n)=>fo(s,n,e,t);return new Proxy((e,t)=>("production"!==process.env.NODE_ENV&&Ps(!1,"motion() is deprecated. Use motion.create() instead."),n(e,t)),{get:(r,a)=>"create"===a?n:(s.has(a)||s.set(a,fo(a,void 0,e,t)),s.get(a))})}function xo({top:e,left:t,right:s,bottom:n}){return{x:{min:t,max:s},y:{min:e,max:n}}}function vo(e){return void 0===e||1===e}function bo({scale:e,scaleX:t,scaleY:s}){return!vo(e)||!vo(t)||!vo(s)}function wo(e){return bo(e)||So(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function So(e){return jo(e.x)||jo(e.y)}function jo(e){return e&&"0%"!==e}function ko(e,t,s){return s+t*(e-s)}function No(e,t,s,n,r){return void 0!==r&&(e=ko(e,r,n)),ko(e,s,n)+t}function Eo(e,t=0,s=1,n,r){e.min=No(e.min,t,s,n,r),e.max=No(e.max,t,s,n,r)}function Co(e,{x:t,y:s}){Eo(e.x,t.translate,t.scale,t.originPoint),Eo(e.y,s.translate,s.scale,s.originPoint)}const To=.999999999999,Po=1.0000000000001;function Ao(e,t){e.min=e.min+t,e.max=e.max+t}function Ro(e,t,s,n,r=.5){Eo(e,t,s,In(e.min,e.max,r),n)}function Mo(e,t){Ro(e.x,t.x,t.scaleX,t.scale,t.originX),Ro(e.y,t.y,t.scaleY,t.scale,t.originY)}function Do(e,t){return xo(function(e,t){if(!t)return e;const s=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:s.y,left:s.x,bottom:n.y,right:n.x}}(e.getBoundingClientRect(),t))}const $o=()=>({x:{min:0,max:0},y:{min:0,max:0}}),Oo={current:null},Fo={current:!1};const zo=new WeakMap;const Lo=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Io{scrapeMotionValuesFromProps(e,t,s){return{}}constructor({parent:e,props:t,presenceContext:s,reducedMotionConfig:n,blockInitialAnimation:r,visualState:a},i={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=sa,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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 e=tn.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Qs.render(this.render,!1,!0))};const{latestValues:o,renderState:l}=a;this.latestValues=o,this.baseTarget={...o},this.initialValues=t.initial?{...o}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=n,this.options=i,this.blockInitialAnimation=Boolean(r),this.isControllingVariants=Pi(t),this.isVariantNode=Ai(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(const u in d){const e=d[u];void 0!==o[u]&&ri(e)&&e.set(o[u])}}mount(e){var t;this.current=e,zo.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),Fo.current||function(){if(Fo.current=!0,is)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Oo.current=e.matches;e.addEventListener("change",t),t()}else Oo.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||Oo.current),"production"!==process.env.NODE_ENV&&Ps(!0!==this.shouldReduceMotion,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),null==(t=this.parent)||t.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Gs(this.notifyUpdate),Gs(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),null==(e=this.parent)||e.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Wr.has(e);s&&this.onBindTransform&&this.onBindTransform();const n=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&Qs.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{n(),r&&r(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in vi){const t=vi[e];if(!t)continue;const{isEnabled:s,Feature:n}=t;if(!this.features[e]&&n&&s(this.props)&&(this.features[e]=new n(this)),this.features[e]){const t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let s=0;s<Lo.length;s++){const t=Lo[s];this.propEventSubscriptions[t]&&(this.propEventSubscriptions[t](),delete this.propEventSubscriptions[t]);const n=e["on"+t];n&&(this.propEventSubscriptions[t]=this.on(t,n))}this.prevMotionValues=function(e,t,s){for(const n in t){const r=t[n],a=s[n];if(ri(r))e.addValue(n,r);else if(ri(a))e.addValue(n,qa(r,{owner:e}));else if(a!==r)if(e.hasValue(n)){const t=e.getValue(n);!0===t.liveStyle?t.jump(r):t.hasAnimated||t.set(r)}else{const t=e.getStaticValue(n);e.addValue(n,qa(void 0!==t?t:r,{owner:e}))}}for(const n in s)void 0===t[n]&&e.removeValue(n);return t}(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){const s=this.values.get(e);t!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return void 0===s&&void 0!==t&&(s=qa(null===t?void 0:t,{owner:this}),this.addValue(e,s)),s}readValue(e,t){let s=void 0===this.latestValues[e]&&this.current?this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];var n;return null!=s&&("string"==typeof s&&(gs(s)||xs(s))?s=parseFloat(s):(n=s,!ai.find(Na(n))&&Fn.test(t)&&(s=za(e,t))),this.setBaseTarget(e,ri(s)?s.get():s)),ri(s)?s.get():s}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:s}=this.props;let n;if("string"==typeof s||"object"==typeof s){const r=Xi(this.props,s,null==(t=this.presenceContext)?void 0:t.custom);r&&(n=r[e])}if(s&&void 0!==n)return n;const r=this.getBaseTargetFromProps(this.props,e);return void 0===r||ri(r)?void 0!==this.initialValues[e]&&void 0===n?void 0:this.baseTarget[e]:r}on(e,t){return this.events[e]||(this.events[e]=new ks),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Ua.render(this.render)}}class _o extends Io{constructor(){super(...arguments),this.KeyframeResolver=Ia}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:s}){delete t[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;ri(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent=`${e}`)}))}}function Vo(e,{style:t,vars:s},n,r){const a=e.style;let i;for(i in t)a[i]=t[i];for(i in null==r||r.applyProjectionStyles(a,n),s)a.setProperty(i,s[i])}class Bo extends _o{constructor(){super(...arguments),this.type="html",this.renderInstance=Vo}readValueFromInstance(e,t){var s,n;if(Wr.has(t))return(null==(s=this.projection)?void 0:s.isProjecting)?Vr(t):((e,t)=>{const{transform:s="none"}=getComputedStyle(e);return Br(s,t)})(e,t);{const s=(n=e,window.getComputedStyle(n)),r=(nn(t)?s.getPropertyValue(t):s[t])||0;return"string"==typeof r?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Do(e,t)}build(e,t,s){zi(e,t,s.transformTemplate)}scrapeMotionValuesFromProps(e,t,s){return so(e,t,s)}}const qo=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"]);class Uo extends _o{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=$o}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Wr.has(t)){const e=Fa(t);return e&&e.default||0}return t=qo.has(t)?t:co(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,s){return ro(e,t,s)}build(e,t,s){Ui(e,t,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,t,s,n){!function(e,t,s,n){Vo(e,t,void 0,n);for(const r in t.attrs)e.setAttribute(qo.has(r)?r:co(r),t.attrs[r])}(e,t,0,n)}mount(e){this.isSVGTag=Hi(e.tagName),super.mount(e)}}const Wo=(e,t)=>Qi(e)?new Uo(t):new Bo(t,{allowProjection:e!==Oe.Fragment});function Ho(e,t,s){const n=e.getProps();return Xi(n,t,void 0!==s?s:n.custom,e)}const Ko=e=>Array.isArray(e);function Yo(e,t,s){e.hasValue(t)?e.getValue(t).set(s):e.addValue(t,qa(s))}function Qo(e){return Ko(e)?e[e.length-1]||0:e}function Go(e,t){const s=e.getValue("willChange");if(n=s,Boolean(ri(n)&&n.add))return s.add(t);if(!s&&fs.WillChange){const s=new fs.WillChange("auto");e.addValue("willChange",s),s.add(t)}var n}function Jo(e){return e.props[uo]}const Xo=e=>null!==e;const Zo={type:"spring",stiffness:500,damping:25,restSpeed:10},el={type:"keyframes",duration:.8},tl={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},sl=(e,{keyframes:t})=>t.length>2?el:Wr.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===t[1]?2*Math.sqrt(550):30,restSpeed:10}:Zo:tl;const nl=(e,t,s,n={},r,a)=>i=>{const o=ja(n,e)||{},l=o.delay||n.delay||0;let{elapsed:c=0}=n;c-=Ns(l);const d={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:t.getVelocity(),...o,delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{i(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:a?void 0:r};(function({when:e,delay:t,delayChildren:s,staggerChildren:n,staggerDirection:r,repeat:a,repeatType:i,repeatDelay:o,from:l,elapsed:c,...d}){return!!Object.keys(d).length})(o)||Object.assign(d,sl(e,d)),d.duration&&(d.duration=Ns(d.duration)),d.repeatDelay&&(d.repeatDelay=Ns(d.repeatDelay)),void 0!==d.from&&(d.keyframes[0]=d.from);let u=!1;if((!1===d.type||0===d.duration&&!d.repeatDelay)&&(ya(d),0===d.delay&&(u=!0)),(fs.instantAnimations||fs.skipAnimations)&&(u=!0,ya(d),d.delay=0),d.allowFlatten=!o.type&&!o.ease,u&&!a&&void 0!==t.get()){const e=function(e,{repeat:t,repeatType:s="loop"}){const n=e.filter(Xo);return n[t&&"loop"!==s&&t%2==1?0:n.length-1]}(d.keyframes,o);if(void 0!==e)return void Qs.update(()=>{d.onUpdate(e),d.onComplete()})}return o.isSync?new Dr(d):new ba(d)};function rl({protectedKeys:e,needsAnimating:t},s){const n=e.hasOwnProperty(s)&&!0!==t[s];return t[s]=!1,n}function al(e,t,{delay:s=0,transitionOverride:n,type:r}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:i,...o}=t;n&&(a=n);const l=[],c=r&&e.animationState&&e.animationState.getState()[r];for(const d in o){const t=e.getValue(d,e.latestValues[d]??null),n=o[d];if(void 0===n||c&&rl(c,d))continue;const r={delay:s,...ja(a||{},d)},i=t.get();if(void 0!==i&&!t.isAnimating&&!Array.isArray(n)&&n===i&&!r.velocity)continue;let u=!1;if(window.MotionHandoffAnimation){const t=Jo(e);if(t){const e=window.MotionHandoffAnimation(t,d,Qs);null!==e&&(r.startTime=e,u=!0)}}Go(e,d),t.start(nl(d,t,n,e.shouldReduceMotion&&ka.has(d)?{type:!1}:r,e,u));const h=t.animation;h&&l.push(h)}return i&&Promise.all(l).then(()=>{Qs.update(()=>{i&&function(e,t){const s=Ho(e,t);let{transitionEnd:n={},transition:r={},...a}=s||{};a={...a,...n};for(const i in a)Yo(e,i,Qo(a[i]))}(e,i)})}),l}function il(e,t,s,n=0,r=1){const a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),i=e.size,o=(i-1)*n;return"function"==typeof s?s(a,i):1===r?a*n:o-a*n}function ol(e,t,s={}){var n;const r=Ho(e,t,"exit"===s.type?null==(n=e.presenceContext)?void 0:n.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=r||{};s.transitionOverride&&(a=s.transitionOverride);const i=r?()=>Promise.all(al(e,r,s)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(n=0)=>{const{delayChildren:r=0,staggerChildren:i,staggerDirection:o}=a;return function(e,t,s=0,n=0,r=0,a=1,i){const o=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),o.push(ol(l,t,{...i,delay:s+("function"==typeof n?0:n)+il(e.variantChildren,l,n,r,a)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(o)}(e,t,n,r,i,o,s)}:()=>Promise.resolve(),{when:l}=a;if(l){const[e,t]="beforeChildren"===l?[i,o]:[o,i];return e().then(()=>t())}return Promise.all([i(),o(s.delay)])}function ll(e,t){if(!Array.isArray(t))return!1;const s=t.length;if(s!==e.length)return!1;for(let n=0;n<s;n++)if(t[n]!==e[n])return!1;return!0}const cl=Ti.length;function dl(e){if(!e)return;if(!e.isControllingVariants){const t=e.parent&&dl(e.parent)||{};return void 0!==e.props.initial&&(t.initial=e.props.initial),t}const t={};for(let s=0;s<cl;s++){const n=Ti[s],r=e.props[n];(Ei(r)||!1===r)&&(t[n]=r)}return t}const ul=[...Ci].reverse(),hl=Ci.length;function ml(e){return t=>Promise.all(t.map(({animation:t,options:s})=>function(e,t,s={}){let n;if(e.notify("AnimationStart",t),Array.isArray(t)){const r=t.map(t=>ol(e,t,s));n=Promise.all(r)}else if("string"==typeof t)n=ol(e,t,s);else{const r="function"==typeof t?Ho(e,t,s.custom):t;n=Promise.all(al(e,r,s))}return n.then(()=>{e.notify("AnimationComplete",t)})}(e,t,s)))}function pl(e){let t=ml(e),s=yl(),n=!0;const r=t=>(s,n)=>{var r;const a=Ho(e,n,"exit"===t?null==(r=e.presenceContext)?void 0:r.custom:void 0);if(a){const{transition:e,transitionEnd:t,...n}=a;s={...s,...n,...t}}return s};function a(a){const{props:i}=e,o=dl(e.parent)||{},l=[],c=new Set;let d={},u=1/0;for(let t=0;t<hl;t++){const h=ul[t],m=s[h],p=void 0!==i[h]?i[h]:o[h],f=Ei(p),g=h===a?m.isActive:null;!1===g&&(u=t);let y=p===o[h]&&p!==i[h]&&f;if(y&&n&&e.manuallyAnimateOnMount&&(y=!1),m.protectedKeys={...d},!m.isActive&&null===g||!p&&!m.prevProp||Ni(p)||"boolean"==typeof p)continue;const x=fl(m.prevProp,p);let v=x||h===a&&m.isActive&&!y&&f||t>u&&f,b=!1;const w=Array.isArray(p)?p:[p];let S=w.reduce(r(h),{});!1===g&&(S={});const{prevResolvedValues:j={}}=m,k={...j,...S},N=t=>{v=!0,c.has(t)&&(b=!0,c.delete(t)),m.needsAnimating[t]=!0;const s=e.getValue(t);s&&(s.liveStyle=!1)};for(const e in k){const t=S[e],s=j[e];if(d.hasOwnProperty(e))continue;let n=!1;n=Ko(t)&&Ko(s)?!ll(t,s):t!==s,n?null!=t?N(e):c.add(e):void 0!==t&&c.has(e)?N(e):m.protectedKeys[e]=!0}m.prevProp=p,m.prevResolvedValues=S,m.isActive&&(d={...d,...S}),n&&e.blockInitialAnimation&&(v=!1);const E=y&&x;v&&(!E||b)&&l.push(...w.map(t=>{const s={type:h};if("string"==typeof t&&n&&!E&&e.manuallyAnimateOnMount&&e.parent){const{parent:n}=e,r=Ho(n,t);if(n.enteringChildren&&r){const{delayChildren:t}=r.transition||{};s.delay=il(n.enteringChildren,e,t)}}return{animation:t,options:s}}))}if(c.size){const t={};if("boolean"!=typeof i.initial){const s=Ho(e,Array.isArray(i.initial)?i.initial[0]:i.initial);s&&s.transition&&(t.transition=s.transition)}c.forEach(s=>{const n=e.getBaseTarget(s),r=e.getValue(s);r&&(r.liveStyle=!0),t[s]=n??null}),l.push({animation:t})}let h=Boolean(l.length);return!n||!1!==i.initial&&i.initial!==i.animate||e.manuallyAnimateOnMount||(h=!1),n=!1,h?t(l):Promise.resolve()}return{animateChanges:a,setActive:function(t,n){var r;if(s[t].isActive===n)return Promise.resolve();null==(r=e.variantChildren)||r.forEach(e=>{var s;return null==(s=e.animationState)?void 0:s.setActive(t,n)}),s[t].isActive=n;const i=a(t);for(const e in s)s[e].protectedKeys={};return i},setAnimateFunction:function(s){t=s(e)},getState:()=>s,reset:()=>{s=yl()}}}function fl(e,t){return"string"==typeof t?t!==e:!!Array.isArray(t)&&!ll(t,e)}function gl(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function yl(){return{animate:gl(!0),whileInView:gl(),whileHover:gl(),whileTap:gl(),whileDrag:gl(),whileFocus:gl(),exit:gl()}}class xl{constructor(e){this.isMounted=!1,this.node=e}update(){}}let vl=0;const bl={animation:{Feature:class extends xl{constructor(e){super(e),e.animationState||(e.animationState=pl(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Ni(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),null==(e=this.unmountControls)||e.call(this)}}},exit:{Feature:class extends xl{constructor(){super(...arguments),this.id=vl++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const n=this.node.animationState.setActive("exit",!e);t&&!e&&n.then(()=>{t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wl(e,t,s,n={passive:!0}){return e.addEventListener(t,s,n),()=>e.removeEventListener(t,s)}function Sl(e){return{point:{x:e.pageX,y:e.pageY}}}function jl(e,t,s,n){return wl(e,t,(e=>t=>Ga(t)&&e(t,Sl(t)))(s),n)}function kl(e){return e.max-e.min}function Nl(e,t,s,n=.5){e.origin=n,e.originPoint=In(t.min,t.max,e.origin),e.scale=kl(s)/kl(t),e.translate=In(s.min,s.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function El(e,t,s,n){Nl(e.x,t.x,s.x,n?n.originX:void 0),Nl(e.y,t.y,s.y,n?n.originY:void 0)}function Cl(e,t,s){e.min=s.min+t.min,e.max=e.min+kl(t)}function Tl(e,t,s){e.min=t.min-s.min,e.max=e.min+kl(t)}function Pl(e,t,s){Tl(e.x,t.x,s.x),Tl(e.y,t.y,s.y)}function Al(e){return[e("x"),e("y")]}const Rl=({current:e})=>e?e.ownerDocument.defaultView:null,Ml=(e,t)=>Math.abs(e-t);class Dl{constructor(e,t,{transformPagePoint:s,contextWindow:n=window,dragSnapToOrigin:r=!1,distanceThreshold:a=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const e=Fl(this.lastMoveEventInfo,this.history),t=null!==this.startEvent,s=function(e,t){const s=Ml(e.x,t.x),n=Ml(e.y,t.y);return Math.sqrt(s**2+n**2)}(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!s)return;const{point:n}=e,{timestamp:r}=Js;this.history.push({...n,timestamp:r});const{onStart:a,onMove:i}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),i&&i(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=$l(t,this.transformPagePoint),Qs.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();const{onEnd:s,onSessionEnd:n,resumeAnimation:r}=this.handlers;if(this.dragSnapToOrigin&&r&&r(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const a=Fl("pointercancel"===e.type?this.lastMoveEventInfo:$l(t,this.transformPagePoint),this.history);this.startEvent&&s&&s(e,a),n&&n(e,a)},!Ga(e))return;this.dragSnapToOrigin=r,this.handlers=t,this.transformPagePoint=s,this.distanceThreshold=a,this.contextWindow=n||window;const i=$l(Sl(e),this.transformPagePoint),{point:o}=i,{timestamp:l}=Js;this.history=[{...o,timestamp:l}];const{onSessionStart:c}=t;c&&c(e,Fl(i,this.history)),this.removeListeners=Ss(jl(this.contextWindow,"pointermove",this.handlePointerMove),jl(this.contextWindow,"pointerup",this.handlePointerUp),jl(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Gs(this.updatePoint)}}function $l(e,t){return t?{point:t(e.point)}:e}function Ol(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Fl({point:e},t){return{point:e,delta:Ol(e,Ll(t)),offset:Ol(e,zl(t)),velocity:Il(t,.1)}}function zl(e){return e[0]}function Ll(e){return e[e.length-1]}function Il(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const r=Ll(e);for(;s>=0&&(n=e[s],!(r.timestamp-n.timestamp>Ns(t)));)s--;if(!n)return{x:0,y:0};const a=Es(r.timestamp-n.timestamp);if(0===a)return{x:0,y:0};const i={x:(r.x-n.x)/a,y:(r.y-n.y)/a};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function _l(e,t,s){return{min:void 0!==t?e.min+t:void 0,max:void 0!==s?e.max+s-(e.max-e.min):void 0}}function Vl(e,t){let s=t.min-e.min,n=t.max-e.max;return t.max-t.min<e.max-e.min&&([s,n]=[n,s]),{min:s,max:n}}const Bl=.35;function ql(e,t,s){return{min:Ul(e,t),max:Ul(e,s)}}function Ul(e,t){return"number"==typeof e?e:e[t]||0}const Wl=new WeakMap;class Hl{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:s}={}){const{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;const{dragSnapToOrigin:r}=this.getProps();this.panSession=new Dl(e,{onSessionStart:e=>{const{dragSnapToOrigin:s}=this.getProps();s?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(Sl(e).point)},onStart:(e,t)=>{const{drag:s,dragPropagation:n,onDragStart:r}=this.getProps();if(s&&!n&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(a=s)||"y"===a?Wa[a]?null:(Wa[a]=!0,()=>{Wa[a]=!1}):Wa.x||Wa.y?null:(Wa.x=Wa.y=!0,()=>{Wa.x=Wa.y=!1}),!this.openDragLock))return;var a;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Al(e=>{let t=this.getAxisMotionValue(e).get()||0;if(wn.test(t)){const{projection:s}=this.visualElement;if(s&&s.layout){const n=s.layout.layoutBox[e];if(n){t=kl(n)*(parseFloat(t)/100)}}}this.originPoint[e]=t}),r&&Qs.postRender(()=>r(e,t)),Go(this.visualElement,"transform");const{animationState:i}=this.visualElement;i&&i.setActive("whileDrag",!0)},onMove:(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;const{dragPropagation:s,dragDirectionLock:n,onDirectionLock:r,onDrag:a}=this.getProps();if(!s&&!this.openDragLock)return;const{offset:i}=t;if(n&&null===this.currentDirection)return this.currentDirection=function(e,t=10){let s=null;Math.abs(e.y)>t?s="y":Math.abs(e.x)>t&&(s="x");return s}(i),void(null!==this.currentDirection&&r&&r(this.currentDirection));this.updateAxis("x",t.point,i),this.updateAxis("y",t.point,i),this.visualElement.render(),a&&a(e,t)},onSessionEnd:(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},resumeAnimation:()=>Al(e=>{var t;return"paused"===this.getAnimationState(e)&&(null==(t=this.getAxisMotionValue(e).animation)?void 0:t.play())})},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:r,distanceThreshold:s,contextWindow:Rl(this.visualElement)})}stop(e,t){const s=e||this.latestPointerEvent,n=t||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!n||!s)return;const{velocity:a}=n;this.startAnimation(a);const{onDragEnd:i}=this.getProps();i&&Qs.postRender(()=>i(s,n))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,s){const{drag:n}=this.getProps();if(!s||!Kl(e,n,this.currentDirection))return;const r=this.getAxisMotionValue(e);let a=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(a=function(e,{min:t,max:s},n){return void 0!==t&&e<t?e=n?In(t,e,n.min):Math.max(e,t):void 0!==s&&e>s&&(e=n?In(s,e,n.max):Math.min(e,s)),e}(a,this.constraints[e],this.elastic[e])),r.set(a)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:s}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null==(e=this.visualElement.projection)?void 0:e.layout,r=this.constraints;t&&oo(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!n)&&function(e,{top:t,left:s,bottom:n,right:r}){return{x:_l(e.x,s,r),y:_l(e.y,t,n)}}(n.layoutBox,t),this.elastic=function(e=Bl){return!1===e?e=0:!0===e&&(e=Bl),{x:ql(e,"left","right"),y:ql(e,"top","bottom")}}(s),r!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&Al(e=>{!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=function(e,t){const s={};return void 0!==t.min&&(s.min=t.min-e.min),void 0!==t.max&&(s.max=t.max-e.min),s}(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!oo(e))return!1;const s=e.current;ps(null!==s,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:n}=this.visualElement;if(!n||!n.layout)return!1;const r=function(e,t,s){const n=Do(e,s),{scroll:r}=t;return r&&(Ao(n.x,r.offset.x),Ao(n.y,r.offset.y)),n}(s,n.root,this.visualElement.getTransformPagePoint());let a=function(e,t){return{x:Vl(e.x,t.x),y:Vl(e.y,t.y)}}(n.layout.layoutBox,r);if(t){const e=t(function({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}(a));this.hasMutatedConstraints=!!e,e&&(a=xo(e))}return a}startAnimation(e){const{drag:t,dragMomentum:s,dragElastic:n,dragTransition:r,dragSnapToOrigin:a,onDragTransitionEnd:i}=this.getProps(),o=this.constraints||{},l=Al(i=>{if(!Kl(i,t,this.currentDirection))return;let l=o&&o[i]||{};a&&(l={min:0,max:0});const c=n?200:1e6,d=n?40:1e7,u={type:"inertia",velocity:s?e[i]:0,bounceStiffness:c,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...r,...l};return this.startAxisValueAnimation(i,u)});return Promise.all(l).then(i)}startAxisValueAnimation(e,t){const s=this.getAxisMotionValue(e);return Go(this.visualElement,e),s.start(nl(e,s,0,t,this.visualElement,!1))}stopAnimation(){Al(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Al(e=>{var t;return null==(t=this.getAxisMotionValue(e).animation)?void 0:t.pause()})}getAnimationState(e){var t;return null==(t=this.getAxisMotionValue(e).animation)?void 0:t.state}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),n=s[t];return n||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){Al(t=>{const{drag:s}=this.getProps();if(!Kl(t,s,this.currentDirection))return;const{projection:n}=this.visualElement,r=this.getAxisMotionValue(t);if(n&&n.layout){const{min:s,max:a}=n.layout.layoutBox[t];r.set(e[t]-In(s,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:s}=this.visualElement;if(!oo(t)||!s||!this.constraints)return;this.stopAnimation();const n={x:0,y:0};Al(e=>{const t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){const s=t.get();n[e]=function(e,t){let s=.5;const n=kl(e),r=kl(t);return r>n?s=js(t.min,t.max-n,e.min):n>r&&(s=js(e.min,e.max-r,t.min)),us(0,1,s)}({min:s,max:s},this.constraints[e])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Al(t=>{if(!Kl(t,e,null))return;const s=this.getAxisMotionValue(t),{min:r,max:a}=this.constraints[t];s.set(In(r,a,n[t]))})}addListeners(){if(!this.visualElement.current)return;Wl.set(this.visualElement,this);const e=jl(this.visualElement.current,"pointerdown",e=>{const{drag:t,dragListener:s=!0}=this.getProps();t&&s&&this.start(e)}),t=()=>{const{dragConstraints:e}=this.getProps();oo(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,n=s.addEventListener("measure",t);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Qs.read(t);const r=wl(window,"resize",()=>this.scalePositionWithinConstraints()),a=s.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Al(t=>{const s=this.getAxisMotionValue(t);s&&(this.originPoint[t]+=e[t].translate,s.set(s.get()+e[t].translate))}),this.visualElement.render())});return()=>{r(),e(),n(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:s=!1,dragPropagation:n=!1,dragConstraints:r=!1,dragElastic:a=Bl,dragMomentum:i=!0}=e;return{...e,drag:t,dragDirectionLock:s,dragPropagation:n,dragConstraints:r,dragElastic:a,dragMomentum:i}}}function Kl(e,t,s){return!(!0!==t&&t!==e||null!==s&&s!==e)}const Yl=e=>(t,s)=>{e&&Qs.postRender(()=>e(t,s))};const Ql={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Gl(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Jl={correct:(e,t)=>{if(!t.target)return e;if("string"==typeof e){if(!Sn.test(e))return e;e=parseFloat(e)}return`${Gl(e,t.target.x)}% ${Gl(e,t.target.y)}%`}},Xl={correct:(e,{treeScale:t,projectionDelta:s})=>{const n=e,r=Fn.parse(e);if(r.length>5)return n;const a=Fn.createTransformer(e),i="number"!=typeof r[0]?1:0,o=s.x.scale*t.x,l=s.y.scale*t.y;r[0+i]/=o,r[1+i]/=l;const c=In(o,l,.5);return"number"==typeof r[2+i]&&(r[2+i]/=c),"number"==typeof r[3+i]&&(r[3+i]/=c),a(r)}};let Zl=!1;class ec extends Oe.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s,layoutId:n}=this.props,{projection:r}=e;!function(e){for(const t in e)Di[t]=e[t],nn(t)&&(Di[t].isCSSVariable=!0)}(sc),r&&(t.group&&t.group.add(r),s&&s.register&&n&&s.register(r),Zl&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Ql.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:s,drag:n,isPresent:r}=this.props,{projection:a}=s;return a?(a.isPresent=r,Zl=!0,n||e.layoutDependency!==t||void 0===t||e.isPresent!==r?a.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?a.promote():a.relegate()||Qs.postRender(()=>{const e=a.getStack();e&&e.members.length||this.safeToRemove()})),null):null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Ua.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:s}=this.props,{projection:n}=e;Zl=!0,n&&(n.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(n),s&&s.deregister&&s.deregister(n))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function tc(e){const[t,s]=mi(),n=Oe.useContext(rs);return $e.jsx(ec,{...e,layoutGroup:n,switchLayoutGroup:Oe.useContext(ho),isPresent:t,safeToRemove:s})}const sc={borderRadius:{...Jl,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Jl,borderTopRightRadius:Jl,borderBottomLeftRadius:Jl,borderBottomRightRadius:Jl,boxShadow:Xl};const nc=(e,t)=>e.depth-t.depth;class rc{constructor(){this.children=[],this.isDirty=!1}add(e){cs(this.children,e),this.isDirty=!0}remove(e){ds(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(nc),this.isDirty=!1,this.children.forEach(e)}}const ac=["TopLeft","TopRight","BottomLeft","BottomRight"],ic=ac.length,oc=e=>"string"==typeof e?parseFloat(e):e,lc=e=>"number"==typeof e||Sn.test(e);function cc(e,t){return void 0!==e[t]?e[t]:e.borderRadius}const dc=hc(0,.5,Is),uc=hc(.5,.95,bs);function hc(e,t,s){return n=>n<e?0:n>t?1:s(js(e,t,n))}function mc(e,t){e.min=t.min,e.max=t.max}function pc(e,t){mc(e.x,t.x),mc(e.y,t.y)}function fc(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function gc(e,t,s,n,r){return e=ko(e-=t,1/s,n),void 0!==r&&(e=ko(e,1/r,n)),e}function yc(e,t,[s,n,r],a,i){!function(e,t=0,s=1,n=.5,r,a=e,i=e){wn.test(t)&&(t=parseFloat(t),t=In(i.min,i.max,t/100)-i.min);if("number"!=typeof t)return;let o=In(a.min,a.max,n);e===a&&(o-=t),e.min=gc(e.min,t,s,o,r),e.max=gc(e.max,t,s,o,r)}(e,t[s],t[n],t[r],t.scale,a,i)}const xc=["x","scaleX","originX"],vc=["y","scaleY","originY"];function bc(e,t,s,n){yc(e.x,t,xc,s?s.x:void 0,n?n.x:void 0),yc(e.y,t,vc,s?s.y:void 0,n?n.y:void 0)}function wc(e){return 0===e.translate&&1===e.scale}function Sc(e){return wc(e.x)&&wc(e.y)}function jc(e,t){return e.min===t.min&&e.max===t.max}function kc(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Nc(e,t){return kc(e.x,t.x)&&kc(e.y,t.y)}function Ec(e){return kl(e.x)/kl(e.y)}function Cc(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Tc{constructor(){this.members=[]}add(e){cs(this.members,e),e.scheduleRender()}remove(e){if(ds(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){const t=this.members.findIndex(t=>e===t);if(0===t)return!1;let s;for(let n=t;n>=0;n--){const e=this.members[n];if(!1!==e.isPresent){s=e;break}}return!!s&&(this.promote(s),!0)}promote(e,t){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,t&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:n}=e.options;!1===n&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:s}=e;t.onExitComplete&&t.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const Pc=["","X","Y","Z"];let Ac=0;function Rc(e,t,s,n){const{latestValues:r}=t;r[e]&&(s[e]=r[e],t.setStaticValue(e,0),n&&(n[e]=0))}function Mc(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const s=Jo(t);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:t,layoutId:n}=e.options;window.MotionCancelOptimisedAnimation(s,"transform",Qs,!(t||n))}const{parent:n}=e;n&&!n.hasCheckedOptimisedAppear&&Mc(n)}function Dc({attachResizeListener:e,defaultParent:t,measureScroll:s,checkIsScrollRoot:n,resetTransform:r}){return class{constructor(e={},s=(null==t?void 0:t())){this.id=Ac++,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.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(Fc),this.nodes.forEach(qc),this.nodes.forEach(Uc),this.nodes.forEach(zc)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let t=0;t<this.path.length;t++)this.path[t].shouldResetTransform=!0;this.root===this&&(this.nodes=new rc)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ks),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){const s=this.eventHandlers.get(e);s&&s.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;var s;this.isSVG=ni(t)&&!(ni(s=t)&&"svg"===s.tagName),this.instance=t;const{layoutId:n,layout:r,visualElement:a}=this.options;if(a&&!a.current&&a.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let s,n=0;const r=()=>this.root.updateBlockedByResize=!1;Qs.read(()=>{n=window.innerWidth}),e(t,()=>{const e=window.innerWidth;e!==n&&(n=e,this.root.updateBlockedByResize=!0,s&&s(),s=function(e,t){const s=tn.now(),n=({timestamp:r})=>{const a=r-s;a>=t&&(Gs(n),e(a-t))};return Qs.setup(n,!0),()=>Gs(n)}(r,250),Ql.hasAnimatedSinceResize&&(Ql.hasAnimatedSinceResize=!1,this.nodes.forEach(Bc)))})}n&&this.root.registerSharedNode(n,this),!1!==this.options.animate&&a&&(n||r)&&this.addEventListener("didUpdate",({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:s,layout:n})=>{if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const r=this.options.transition||a.getDefaultTransition()||Gc,{onLayoutAnimationStart:i,onLayoutAnimationComplete:o}=a.getProps(),l=!this.targetLayout||!Nc(this.targetLayout,n),c=!t&&s;if(this.options.layoutRoot||this.resumeFrom||c||t&&(l||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const t={...ja(r,"layout"),onPlay:i,onComplete:o};(a.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,c)}else t||Bc(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=n})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Gs(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(Wc),this.animationId++)}getTransformTemplate(){const{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Mc(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let r=0;r<this.path.length;r++){const e=this.path[r];e.shouldResetTransform=!0,e.updateScroll("snapshot"),e.options.layoutRoot&&e.willUpdate(!1)}const{layoutId:t,layout:s}=this.options;if(void 0===t&&!s)return;const n=this.getTransformTemplate();this.prevTransformTemplateValue=n?n(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){this.updateScheduled=!1;if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(Ic);if(this.animationId<=this.animationCommitId)return void this.nodes.forEach(_c);this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Vc),this.nodes.forEach($c),this.nodes.forEach(Oc)):this.nodes.forEach(_c),this.clearAllSnapshots();const e=tn.now();Js.delta=us(0,1e3/60,e-Js.timestamp),Js.timestamp=e,Js.isProcessing=!0,Xs.update.process(Js),Xs.preRender.process(Js),Xs.render.process(Js),Js.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ua.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Lc),this.sharedNodes.forEach(Hc)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Qs.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Qs.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||kl(this.snapshot.measuredBox.x)||kl(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance)return;if(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let s=0;s<this.path.length;s++){this.path[s].updateScroll()}const e=this.layout;this.layout=this.measure(!1),this.layoutCorrected={x:{min:0,max:0},y:{min:0,max:0}},this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:t}=this.options;t&&t.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e="measure"){let t=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){const t=n(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:s(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!r)return;const e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Sc(this.projectionDelta),s=this.getTransformTemplate(),n=s?s(this.latestValues,""):void 0,a=n!==this.prevTransformTemplateValue;e&&this.instance&&(t||wo(this.latestValues)||a)&&(r(this.instance,n),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){const t=this.measurePageBox();let s=this.removeElementScroll(t);var n;return e&&(s=this.removeTransform(s)),Zc((n=s).x),Zc(n.y),{animationId:this.root.animationId,measuredBox:t,layoutBox:s,latestValues:{},source:this.id}}measurePageBox(){var e;const{visualElement:t}=this.options;if(!t)return{x:{min:0,max:0},y:{min:0,max:0}};const s=t.measureViewportBox();if(!((null==(e=this.scroll)?void 0:e.wasRoot)||this.path.some(td))){const{scroll:e}=this.root;e&&(Ao(s.x,e.offset.x),Ao(s.y,e.offset.y))}return s}removeElementScroll(e){var t;const s={x:{min:0,max:0},y:{min:0,max:0}};if(pc(s,e),null==(t=this.scroll)?void 0:t.wasRoot)return s;for(let n=0;n<this.path.length;n++){const t=this.path[n],{scroll:r,options:a}=t;t!==this.root&&r&&a.layoutScroll&&(r.wasRoot&&pc(s,e),Ao(s.x,r.offset.x),Ao(s.y,r.offset.y))}return s}applyTransform(e,t=!1){const s={x:{min:0,max:0},y:{min:0,max:0}};pc(s,e);for(let n=0;n<this.path.length;n++){const e=this.path[n];!t&&e.options.layoutScroll&&e.scroll&&e!==e.root&&Mo(s,{x:-e.scroll.offset.x,y:-e.scroll.offset.y}),wo(e.latestValues)&&Mo(s,e.latestValues)}return wo(this.latestValues)&&Mo(s,this.latestValues),s}removeTransform(e){const t={x:{min:0,max:0},y:{min:0,max:0}};pc(t,e);for(let s=0;s<this.path.length;s++){const e=this.path[s];if(!e.instance)continue;if(!wo(e.latestValues))continue;bo(e.latestValues)&&e.updateSnapshot();const n=$o();pc(n,e.measurePageBox()),bc(t,e.latestValues,e.snapshot?e.snapshot.layoutBox:void 0,n)}return wo(this.latestValues)&&bc(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:void 0===e.crossfade||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Js.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){var t;const s=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=s.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=s.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=s.isSharedProjectionDirty);const n=Boolean(this.resumingFrom)||this!==s;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||(null==(t=this.parent)?void 0:t.isProjectionDirty)||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:r,layoutId:a}=this.options;if(this.layout&&(r||a)){if(this.resolvedRelativeTargetAt=Js.timestamp,!this.targetDelta&&!this.relativeTarget){const e=this.getClosestProjectingParent();e&&e.layout&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pl(this.relativeTargetOrigin,this.layout.layoutBox,e.layout.layoutBox),pc(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}var i,o,l;if(this.relativeTarget||this.targetDelta)if(this.target||(this.target={x:{min:0,max:0},y:{min:0,max:0}},this.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}}),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),i=this.target,o=this.relativeTarget,l=this.relativeParent.target,Cl(i.x,o.x,l.x),Cl(i.y,o.y,l.y)):this.targetDelta?(Boolean(this.resumingFrom)?this.target=this.applyTransform(this.layout.layoutBox):pc(this.target,this.layout.layoutBox),Co(this.target,this.targetDelta)):pc(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const e=this.getClosestProjectingParent();e&&Boolean(e.resumingFrom)===Boolean(this.resumingFrom)&&!e.options.layoutScroll&&e.target&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Pl(this.relativeTargetOrigin,this.target,e.target),pc(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(this.parent&&!bo(this.parent.latestValues)&&!So(this.parent.latestValues))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var e;const t=this.getLead(),s=Boolean(this.resumingFrom)||this!==t;let n=!0;if((this.isProjectionDirty||(null==(e=this.parent)?void 0:e.isProjectionDirty))&&(n=!1),s&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Js.timestamp&&(n=!1),n)return;const{layout:r,layoutId:a}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!r&&!a)return;pc(this.layoutCorrected,this.layout.layoutBox);const i=this.treeScale.x,o=this.treeScale.y;!function(e,t,s,n=!1){const r=s.length;if(!r)return;let a,i;t.x=t.y=1;for(let o=0;o<r;o++){a=s[o],i=a.projectionDelta;const{visualElement:r}=a.options;r&&r.props.style&&"contents"===r.props.style.display||(n&&a.options.layoutScroll&&a.scroll&&a!==a.root&&Mo(e,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Co(e,i)),n&&wo(a.latestValues)&&Mo(e,a.latestValues))}t.x<Po&&t.x>To&&(t.x=1),t.y<Po&&t.y>To&&(t.y=1)}(this.layoutCorrected,this.treeScale,this.path,s),!t.layout||t.target||1===this.treeScale.x&&1===this.treeScale.y||(t.target=t.layout.layoutBox,t.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}});const{target:l}=t;l?(this.projectionDelta&&this.prevProjectionDelta?(fc(this.prevProjectionDelta.x,this.projectionDelta.x),fc(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),El(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===i&&this.treeScale.y===o&&Cc(this.projectionDelta.x,this.prevProjectionDelta.x)&&Cc(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l))):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){var t;if(null==(t=this.options.visualElement)||t.scheduleRender(),e){const e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDeltaWithTransform={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}}setAnimationOrigin(e,t=!1){const s=this.snapshot,n=s?s.latestValues:{},r={...this.latestValues},a={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;const i={x:{min:0,max:0},y:{min:0,max:0}},o=(s?s.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),c=!l||l.members.length<=1,d=Boolean(o&&!c&&!0===this.options.crossfade&&!this.path.some(Qc));let u;this.animationProgress=0,this.mixTargetDelta=t=>{const s=t/1e3;var l,h,m,p,f,g;Kc(a.x,e.x,s),Kc(a.y,e.y,s),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pl(i,this.layout.layoutBox,this.relativeParent.layout.layoutBox),m=this.relativeTarget,p=this.relativeTargetOrigin,f=i,g=s,Yc(m.x,p.x,f.x,g),Yc(m.y,p.y,f.y,g),u&&(l=this.relativeTarget,h=u,jc(l.x,h.x)&&jc(l.y,h.y))&&(this.isProjectionDirty=!1),u||(u={x:{min:0,max:0},y:{min:0,max:0}}),pc(u,this.relativeTarget)),o&&(this.animationValues=r,function(e,t,s,n,r,a){r?(e.opacity=In(0,s.opacity??1,dc(n)),e.opacityExit=In(t.opacity??1,0,uc(n))):a&&(e.opacity=In(t.opacity??1,s.opacity??1,n));for(let i=0;i<ic;i++){const r=`border${ac[i]}Radius`;let a=cc(t,r),o=cc(s,r);void 0===a&&void 0===o||(a||(a=0),o||(o=0),0===a||0===o||lc(a)===lc(o)?(e[r]=Math.max(In(oc(a),oc(o),n),0),(wn.test(o)||wn.test(a))&&(e[r]+="%")):e[r]=o)}(t.rotate||s.rotate)&&(e.rotate=In(t.rotate||0,s.rotate||0,n))}(r,n,this.latestValues,s,d,c)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=s},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){var t,s,n;this.notifyListeners("animationStart"),null==(t=this.currentAnimation)||t.stop(),null==(n=null==(s=this.resumingFrom)?void 0:s.currentAnimation)||n.stop(),this.pendingAnimation&&(Gs(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Qs.update(()=>{Ql.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=qa(0)),this.currentAnimation=function(e,t,s){const n=ri(e)?e:qa(e);return n.start(nl("",n,t,s)),n.animation}(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{},onComplete:()=>{e.onComplete&&e.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 e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const e=this.getLead();let{targetWithTransforms:t,target:s,layout:n,latestValues:r}=e;if(t&&s&&n){if(this!==e&&this.layout&&n&&ed(this.options.animationType,this.layout.layoutBox,n.layoutBox)){s=this.target||{x:{min:0,max:0},y:{min:0,max:0}};const t=kl(this.layout.layoutBox.x);s.x.min=e.target.x.min,s.x.max=s.x.min+t;const n=kl(this.layout.layoutBox.y);s.y.min=e.target.y.min,s.y.max=s.y.min+n}pc(t,s),Mo(t,r),El(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Tc);this.sharedNodes.get(e).add(t);const s=t.options.initialPromotionConfig;t.promote({transition:s?s.transition:void 0,preserveFollowOpacity:s&&s.shouldPreserveFollowOpacity?s.shouldPreserveFollowOpacity(t):void 0})}isLead(){const e=this.getStack();return!e||e.lead===this}getLead(){var e;const{layoutId:t}=this.options;return t&&(null==(e=this.getStack())?void 0:e.lead)||this}getPrevLead(){var e;const{layoutId:t}=this.options;return t?null==(e=this.getStack())?void 0:e.prevLead:void 0}getStack(){const{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:s}={}){const n=this.getStack();n&&n.promote(this,s),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){const e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){const{visualElement:e}=this.options;if(!e)return;let t=!1;const{latestValues:s}=e;if((s.z||s.rotate||s.rotateX||s.rotateY||s.rotateZ||s.skewX||s.skewY)&&(t=!0),!t)return;const n={};s.z&&Rc("z",e,n,this.animationValues);for(let r=0;r<Pc.length;r++)Rc(`rotate${Pc[r]}`,e,n,this.animationValues),Rc(`skew${Pc[r]}`,e,n,this.animationValues);e.render();for(const r in n)e.setStaticValue(r,n[r]),this.animationValues&&(this.animationValues[r]=n[r]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible)return void(e.visibility="hidden");const s=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,e.visibility="",e.opacity="",e.pointerEvents=Zi(null==t?void 0:t.pointerEvents)||"",void(e.transform=s?s(this.latestValues,""):"none");const n=this.getLead();if(!this.projectionDelta||!this.layout||!n.target)return this.options.layoutId&&(e.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,e.pointerEvents=Zi(null==t?void 0:t.pointerEvents)||""),void(this.hasProjected&&!wo(this.latestValues)&&(e.transform=s?s({},""):"none",this.hasProjected=!1));e.visibility="";const r=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=function(e,t,s){let n="";const r=e.x.translate/t.x,a=e.y.translate/t.y,i=(null==s?void 0:s.z)||0;if((r||a||i)&&(n=`translate3d(${r}px, ${a}px, ${i}px) `),1===t.x&&1===t.y||(n+=`scale(${1/t.x}, ${1/t.y}) `),s){const{transformPerspective:e,rotate:t,rotateX:r,rotateY:a,skewX:i,skewY:o}=s;e&&(n=`perspective(${e}px) ${n}`),t&&(n+=`rotate(${t}deg) `),r&&(n+=`rotateX(${r}deg) `),a&&(n+=`rotateY(${a}deg) `),i&&(n+=`skewX(${i}deg) `),o&&(n+=`skewY(${o}deg) `)}const o=e.x.scale*t.x,l=e.y.scale*t.y;return 1===o&&1===l||(n+=`scale(${o}, ${l})`),n||"none"}(this.projectionDeltaWithTransform,this.treeScale,r);s&&(a=s(r,a)),e.transform=a;const{x:i,y:o}=this.projectionDelta;e.transformOrigin=`${100*i.origin}% ${100*o.origin}% 0`,n.animationValues?e.opacity=n===this?r.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:r.opacityExit:e.opacity=n===this?void 0!==r.opacity?r.opacity:"":void 0!==r.opacityExit?r.opacityExit:0;for(const l in Di){if(void 0===r[l])continue;const{correct:t,applyTo:s,isCSSVariable:i}=Di[l],o="none"===a?r[l]:t(r[l],n);if(s){const t=s.length;for(let n=0;n<t;n++)e[s[n]]=o}else i?this.options.visualElement.renderState.vars[l]=o:e[l]=o}this.options.layoutId&&(e.pointerEvents=n===this?Zi(null==t?void 0:t.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>{var t;return null==(t=e.currentAnimation)?void 0:t.stop()}),this.root.nodes.forEach(Ic),this.root.sharedNodes.clear()}}}function $c(e){e.updateLayout()}function Oc(e){var t;const s=(null==(t=e.resumeFrom)?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&s&&e.hasListeners("didUpdate")){const{layoutBox:t,measuredBox:n}=e.layout,{animationType:r}=e.options,a=s.source!==e.layout.source;"size"===r?Al(e=>{const n=a?s.measuredBox[e]:s.layoutBox[e],r=kl(n);n.min=t[e].min,n.max=n.min+r}):ed(r,s.layoutBox,t)&&Al(n=>{const r=a?s.measuredBox[n]:s.layoutBox[n],i=kl(t[n]);r.max=r.min+i,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[n].max=e.relativeTarget[n].min+i)});const i={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};El(i,t,s.layoutBox);const o={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};a?El(o,e.applyTransform(n,!0),s.measuredBox):El(o,t,s.layoutBox);const l=!Sc(i);let c=!1;if(!e.resumeFrom){const n=e.getClosestProjectingParent();if(n&&!n.resumeFrom){const{snapshot:r,layout:a}=n;if(r&&a){const i={x:{min:0,max:0},y:{min:0,max:0}};Pl(i,s.layoutBox,r.layoutBox);const o={x:{min:0,max:0},y:{min:0,max:0}};Pl(o,t,a.layoutBox),Nc(i,o)||(c=!0),n.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=i,e.relativeParent=n)}}}e.notifyListeners("didUpdate",{layout:t,snapshot:s,delta:o,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Fc(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=Boolean(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function zc(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Lc(e){e.clearSnapshot()}function Ic(e){e.clearMeasurements()}function _c(e){e.isLayoutDirty=!1}function Vc(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Bc(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function qc(e){e.resolveTargetDelta()}function Uc(e){e.calcProjection()}function Wc(e){e.resetSkewAndRotation()}function Hc(e){e.removeLeadSnapshot()}function Kc(e,t,s){e.translate=In(t.translate,0,s),e.scale=In(t.scale,1,s),e.origin=t.origin,e.originPoint=t.originPoint}function Yc(e,t,s,n){e.min=In(t.min,s.min,n),e.max=In(t.max,s.max,n)}function Qc(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}const Gc={duration:.45,ease:[.4,0,.1,1]},Jc=e=>"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Xc=Jc("applewebkit/")&&!Jc("chrome/")?Math.round:bs;function Zc(e){e.min=Xc(e.min),e.max=Xc(e.max)}function ed(e,t,s){return"position"===e||"preserve-aspect"===e&&(n=Ec(t),r=Ec(s),a=.2,!(Math.abs(n-r)<=a));var n,r,a}function td(e){var t;return e!==e.root&&(null==(t=e.scroll)?void 0:t.wasRoot)}const sd=Dc({attachResizeListener:(e,t)=>wl(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),nd={current:void 0},rd=Dc({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!nd.current){const e=new sd({});e.mount(window),e.setOptions({layoutScroll:!0}),nd.current=e}return nd.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>Boolean("fixed"===window.getComputedStyle(e).position)}),ad={pan:{Feature:class extends xl{constructor(){super(...arguments),this.removePointerDownListener=bs}onPointerDown(e){this.session=new Dl(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Rl(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:s,onPanEnd:n}=this.node.getProps();return{onSessionStart:Yl(e),onStart:Yl(t),onMove:s,onEnd:(e,t)=>{delete this.session,n&&Qs.postRender(()=>n(e,t))}}}mount(){this.removePointerDownListener=jl(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends xl{constructor(e){super(e),this.removeGroupControls=bs,this.removeListeners=bs,this.controls=new Hl(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||bs}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:rd,MeasureLayout:tc}};function id(e,t,s){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover","Start"===s);const r=n["onHover"+s];r&&Qs.postRender(()=>r(t,Sl(t)))}function od(e,t,s){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap","Start"===s);const r=n["onTap"+("End"===s?"":s)];r&&Qs.postRender(()=>r(t,Sl(t)))}const ld=new WeakMap,cd=new WeakMap,dd=e=>{const t=ld.get(e.target);t&&t(e)},ud=e=>{e.forEach(dd)};function hd(e,t,s){const n=function({root:e,...t}){const s=e||document;cd.has(s)||cd.set(s,{});const n=cd.get(s),r=JSON.stringify(t);return n[r]||(n[r]=new IntersectionObserver(ud,{root:e,...t})),n[r]}(t);return ld.set(e,s),n.observe(e),()=>{ld.delete(e),n.unobserve(e)}}const md={some:0,all:1};const pd=yo({...bl,...{inView:{Feature:class extends xl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:s,amount:n="some",once:r}=e,a={root:t?t.current:void 0,rootMargin:s,threshold:"number"==typeof n?n:md[n]};return hd(this.node.current,a,e=>{const{isIntersecting:t}=e;if(this.isInView===t)return;if(this.isInView=t,r&&!t&&this.hasEnteredView)return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);const{onViewportEnter:s,onViewportLeave:n}=this.node.getProps(),a=t?s:n;a&&a(e)})}mount(){this.startObserver()}update(){if("undefined"==typeof IntersectionObserver)return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(function({viewport:e={}},{viewport:t={}}={}){return s=>e[s]!==t[s]}(e,t))&&this.startObserver()}unmount(){}}},tap:{Feature:class extends xl{mount(){const{current:e}=this.node;e&&(this.unmount=si(e,(e,t)=>(od(this.node,t,"Start"),(e,{success:t})=>od(this.node,e,t?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends xl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&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=Ss(wl(this.node.current,"focus",()=>this.onFocus()),wl(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends xl{mount(){const{current:e}=this.node;e&&(this.unmount=function(e,t,s={}){const[n,r,a]=Ka(e,s),i=e=>{if(!Ya(e))return;const{target:s}=e,n=t(s,e);if("function"!=typeof n||!s)return;const a=e=>{Ya(e)&&(n(e),s.removeEventListener("pointerleave",a))};s.addEventListener("pointerleave",a,r)};return n.forEach(e=>{e.addEventListener("pointerenter",i,r)}),a}(e,(e,t)=>(id(this.node,t,"Start"),e=>id(this.node,e,"End"))))}unmount(){}}}},...ad,...{layout:{ProjectionNode:rd,MeasureLayout:tc}}},Wo);function fd(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function gd(e){const t=xd(e),s=Le.forwardRef((e,s)=>{const{children:n,...r}=e,a=Le.Children.toArray(n),i=a.find(bd);if(i){const e=i.props.children,n=a.map(t=>t===i?Le.Children.count(e)>1?Le.Children.only(null):Le.isValidElement(e)?e.props.children:null:t);return $e.jsx(t,{...r,ref:s,children:Le.isValidElement(e)?Le.cloneElement(e,void 0,n):null})}return $e.jsx(t,{...r,ref:s,children:n})});return s.displayName=`${e}.Slot`,s}var yd=gd("Slot");function xd(e){const t=Le.forwardRef((e,t)=>{const{children:s,...n}=e;if(Le.isValidElement(s)){const e=function(e){var t,s;let n=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=n&&"isReactWarning"in n&&n.isReactWarning;if(r)return e.ref;if(n=null==(s=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(s),r=function(e,t){const s={...t};for(const n in t){const r=e[n],a=t[n];/^on[A-Z]/.test(n)?r&&a?s[n]=(...e)=>{const t=a(...e);return r(...e),t}:r&&(s[n]=r):"style"===n?s[n]={...r,...a}:"className"===n&&(s[n]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}(n,s.props);return s.type!==Le.Fragment&&(r.ref=t?function(...e){return t=>{let s=!1;const n=e.map(e=>{const n=fd(e,t);return s||"function"!=typeof n||(s=!0),n});if(s)return()=>{for(let t=0;t<n.length;t++){const s=n[t];"function"==typeof s?s():fd(e[t],null)}}}}(t,e):e),Le.cloneElement(s,r)}return Le.Children.count(s)>1?Le.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vd=Symbol("radix.slottable");function bd(e){return Le.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===vd}function wd(e){var t,s,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=wd(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Sd(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=wd(e))&&(n&&(n+=" "),n+=t);return n}const jd=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,kd=Sd,Nd=e=>{const t=Pd(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:e=>{const s=e.split("-");return""===s[0]&&1!==s.length&&s.shift(),Ed(s,t)||Td(e)},getConflictingClassGroupIds:(e,t)=>{const r=s[e]||[];return t&&n[e]?[...r,...n[e]]:r}}},Ed=(e,t)=>{var s;if(0===e.length)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?Ed(e.slice(1),r):void 0;if(a)return a;if(0===t.validators.length)return;const i=e.join("-");return null==(s=t.validators.find(({validator:e})=>e(i)))?void 0:s.classGroupId},Cd=/^\[(.+)\]$/,Td=e=>{if(Cd.test(e)){const t=Cd.exec(e)[1],s=null==t?void 0:t.substring(0,t.indexOf(":"));if(s)return"arbitrary.."+s}},Pd=e=>{const{theme:t,classGroups:s}=e,n={nextPart:new Map,validators:[]};for(const r in s)Ad(s[r],n,r,t);return n},Ad=(e,t,s,n)=>{e.forEach(e=>{if("string"==typeof e){return void((""===e?t:Rd(t,e)).classGroupId=s)}if("function"==typeof e)return Md(e)?void Ad(e(n),t,s,n):void t.validators.push({validator:e,classGroupId:s});Object.entries(e).forEach(([e,r])=>{Ad(r,Rd(t,e),s,n)})})},Rd=(e,t)=>{let s=e;return t.split("-").forEach(e=>{s.nextPart.has(e)||s.nextPart.set(e,{nextPart:new Map,validators:[]}),s=s.nextPart.get(e)}),s},Md=e=>e.isThemeGetter,Dd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=new Map,n=new Map;const r=(r,a)=>{s.set(r,a),t++,t>e&&(t=0,n=s,s=new Map)};return{get(e){let t=s.get(e);return void 0!==t?t:void 0!==(t=n.get(e))?(r(e,t),t):void 0},set(e,t){s.has(e)?s.set(e,t):r(e,t)}}},$d=e=>{const{prefix:t,experimentalParseClassName:s}=e;let n=e=>{const t=[];let s,n=0,r=0,a=0;for(let l=0;l<e.length;l++){let i=e[l];if(0===n&&0===r){if(":"===i){t.push(e.slice(a,l)),a=l+1;continue}if("/"===i){s=l;continue}}"["===i?n++:"]"===i?n--:"("===i?r++:")"===i&&r--}const i=0===t.length?e:e.substring(a),o=Od(i);return{modifiers:t,hasImportantModifier:o!==i,baseClassName:o,maybePostfixModifierPosition:s&&s>a?s-a:void 0}};if(t){const e=t+":",s=n;n=t=>t.startsWith(e)?s(t.substring(e.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:t,maybePostfixModifierPosition:void 0}}if(s){const e=n;n=t=>s({className:t,parseClassName:e})}return n},Od=e=>e.endsWith("!")?e.substring(0,e.length-1):e.startsWith("!")?e.substring(1):e,Fd=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(e=>[e,!0]));return e=>{if(e.length<=1)return e;const s=[];let n=[];return e.forEach(e=>{"["===e[0]||t[e]?(s.push(...n.sort(),e),n=[]):n.push(e)}),s.push(...n.sort()),s}},zd=/\s+/;function Ld(){let e,t,s=0,n="";for(;s<arguments.length;)(e=arguments[s++])&&(t=Id(e))&&(n&&(n+=" "),n+=t);return n}const Id=e=>{if("string"==typeof e)return e;let t,s="";for(let n=0;n<e.length;n++)e[n]&&(t=Id(e[n]))&&(s&&(s+=" "),s+=t);return s};function _d(e,...t){let s,n,r,a=function(o){const l=t.reduce((e,t)=>t(e),e());return s=(e=>({cache:Dd(e.cacheSize),parseClassName:$d(e),sortModifiers:Fd(e),...Nd(e)}))(l),n=s.cache.get,r=s.cache.set,a=i,i(o)};function i(e){const t=n(e);if(t)return t;const a=((e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:r,sortModifiers:a}=t,i=[],o=e.trim().split(zd);let l="";for(let c=o.length-1;c>=0;c-=1){const e=o[c],{isExternal:t,modifiers:d,hasImportantModifier:u,baseClassName:h,maybePostfixModifierPosition:m}=s(e);if(t){l=e+(l.length>0?" "+l:l);continue}let p=!!m,f=n(p?h.substring(0,m):h);if(!f){if(!p){l=e+(l.length>0?" "+l:l);continue}if(f=n(h),!f){l=e+(l.length>0?" "+l:l);continue}p=!1}const g=a(d).join(":"),y=u?g+"!":g,x=y+f;if(i.includes(x))continue;i.push(x);const v=r(f,p);for(let s=0;s<v.length;++s){const e=v[s];i.push(y+e)}l=e+(l.length>0?" "+l:l)}return l})(e,s);return r(e,a),a}return function(){return a(Ld.apply(null,arguments))}}const Vd=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},Bd=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,qd=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ud=/^\d+\/\d+$/,Wd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hd=/\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$/,Kd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Yd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Gd=e=>Ud.test(e),Jd=e=>!!e&&!Number.isNaN(Number(e)),Xd=e=>!!e&&Number.isInteger(Number(e)),Zd=e=>e.endsWith("%")&&Jd(e.slice(0,-1)),eu=e=>Wd.test(e),tu=()=>!0,su=e=>Hd.test(e)&&!Kd.test(e),nu=()=>!1,ru=e=>Yd.test(e),au=e=>Qd.test(e),iu=e=>!lu(e)&&!pu(e),ou=e=>wu(e,Nu,nu),lu=e=>Bd.test(e),cu=e=>wu(e,Eu,su),du=e=>wu(e,Cu,Jd),uu=e=>wu(e,ju,nu),hu=e=>wu(e,ku,au),mu=e=>wu(e,Pu,ru),pu=e=>qd.test(e),fu=e=>Su(e,Eu),gu=e=>Su(e,Tu),yu=e=>Su(e,ju),xu=e=>Su(e,Nu),vu=e=>Su(e,ku),bu=e=>Su(e,Pu,!0),wu=(e,t,s)=>{const n=Bd.exec(e);return!!n&&(n[1]?t(n[1]):s(n[2]))},Su=(e,t,s=!1)=>{const n=qd.exec(e);return!!n&&(n[1]?t(n[1]):s)},ju=e=>"position"===e||"percentage"===e,ku=e=>"image"===e||"url"===e,Nu=e=>"length"===e||"size"===e||"bg-size"===e,Eu=e=>"length"===e,Cu=e=>"number"===e,Tu=e=>"family-name"===e,Pu=e=>"shadow"===e,Au=_d(()=>{const e=Vd("color"),t=Vd("font"),s=Vd("text"),n=Vd("font-weight"),r=Vd("tracking"),a=Vd("leading"),i=Vd("breakpoint"),o=Vd("container"),l=Vd("spacing"),c=Vd("radius"),d=Vd("shadow"),u=Vd("inset-shadow"),h=Vd("text-shadow"),m=Vd("drop-shadow"),p=Vd("blur"),f=Vd("perspective"),g=Vd("aspect"),y=Vd("ease"),x=Vd("animate"),v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",pu,lu],b=()=>[pu,lu,l],w=()=>[Gd,"full","auto",...b()],S=()=>[Xd,"none","subgrid",pu,lu],j=()=>["auto",{span:["full",Xd,pu,lu]},Xd,pu,lu],k=()=>[Xd,"auto",pu,lu],N=()=>["auto","min","max","fr",pu,lu],E=()=>["auto",...b()],C=()=>[Gd,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],T=()=>[e,pu,lu],P=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",yu,uu,{position:[pu,lu]}],A=()=>["auto","cover","contain",xu,ou,{size:[pu,lu]}],R=()=>[Zd,fu,cu],M=()=>["","none","full",c,pu,lu],D=()=>["",Jd,fu,cu],$=()=>[Jd,Zd,yu,uu],O=()=>["","none",p,pu,lu],F=()=>["none",Jd,pu,lu],z=()=>["none",Jd,pu,lu],L=()=>[Jd,pu,lu],I=()=>[Gd,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[eu],breakpoint:[eu],color:[tu],container:[eu],"drop-shadow":[eu],ease:["in","out","in-out"],font:[iu],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[eu],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[eu],shadow:[eu],spacing:["px",Jd],text:[eu],"text-shadow":[eu],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Gd,lu,pu,g]}],container:["container"],columns:[{columns:[Jd,lu,pu,o]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"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"],sr:["sr-only","not-sr-only"],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:v()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{start:w()}],end:[{end:w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:["visible","invisible","collapse"],z:[{z:[Xd,"auto",pu,lu]}],basis:[{basis:[Gd,"full","auto",o,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Jd,Gd,"auto","initial","none",lu]}],grow:[{grow:["",Jd,pu,lu]}],shrink:[{shrink:["",Jd,pu,lu]}],order:[{order:[Xd,"first","last","none",pu,lu]}],"grid-cols":[{"grid-cols":S()}],"col-start-end":[{col:j()}],"col-start":[{"col-start":k()}],"col-end":[{"col-end":k()}],"grid-rows":[{"grid-rows":S()}],"row-start-end":[{row:j()}],"row-start":[{"row-start":k()}],"row-end":[{"row-end":k()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":N()}],"auto-rows":[{"auto-rows":N()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:E()}],mx:[{mx:E()}],my:[{my:E()}],ms:[{ms:E()}],me:[{me:E()}],mt:[{mt:E()}],mr:[{mr:E()}],mb:[{mb:E()}],ml:[{ml:E()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:C()}],w:[{w:[o,"screen",...C()]}],"min-w":[{"min-w":[o,"screen","none",...C()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[i]},...C()]}],h:[{h:["screen","lh",...C()]}],"min-h":[{"min-h":["screen","lh","none",...C()]}],"max-h":[{"max-h":["screen","lh",...C()]}],"font-size":[{text:["base",s,fu,cu]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,pu,du]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Zd,lu]}],"font-family":[{font:[gu,lu,t]}],"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:[r,pu,lu]}],"line-clamp":[{"line-clamp":[Jd,"none",pu,du]}],leading:[{leading:[a,...b()]}],"list-image":[{"list-image":["none",pu,lu]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pu,lu]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Jd,"from-font","auto",pu,cu]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[Jd,"auto",pu,lu]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pu,lu]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pu,lu]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:P()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:A()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Xd,pu,lu],radial:["",pu,lu],conic:[Xd,pu,lu]},vu,hu]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:M()}],"rounded-s":[{"rounded-s":M()}],"rounded-e":[{"rounded-e":M()}],"rounded-t":[{"rounded-t":M()}],"rounded-r":[{"rounded-r":M()}],"rounded-b":[{"rounded-b":M()}],"rounded-l":[{"rounded-l":M()}],"rounded-ss":[{"rounded-ss":M()}],"rounded-se":[{"rounded-se":M()}],"rounded-ee":[{"rounded-ee":M()}],"rounded-es":[{"rounded-es":M()}],"rounded-tl":[{"rounded-tl":M()}],"rounded-tr":[{"rounded-tr":M()}],"rounded-br":[{"rounded-br":M()}],"rounded-bl":[{"rounded-bl":M()}],"border-w":[{border:D()}],"border-w-x":[{"border-x":D()}],"border-w-y":[{"border-y":D()}],"border-w-s":[{"border-s":D()}],"border-w-e":[{"border-e":D()}],"border-w-t":[{"border-t":D()}],"border-w-r":[{"border-r":D()}],"border-w-b":[{"border-b":D()}],"border-w-l":[{"border-l":D()}],"divide-x":[{"divide-x":D()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":D()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Jd,pu,lu]}],"outline-w":[{outline:["",Jd,fu,cu]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","none",d,bu,mu]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",u,bu,mu]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[Jd,cu]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":D()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",h,bu,mu]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[Jd,pu,lu]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Jd]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[pu,lu]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[Jd]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:P()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:A()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pu,lu]}],filter:[{filter:["","none",pu,lu]}],blur:[{blur:O()}],brightness:[{brightness:[Jd,pu,lu]}],contrast:[{contrast:[Jd,pu,lu]}],"drop-shadow":[{"drop-shadow":["","none",m,bu,mu]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",Jd,pu,lu]}],"hue-rotate":[{"hue-rotate":[Jd,pu,lu]}],invert:[{invert:["",Jd,pu,lu]}],saturate:[{saturate:[Jd,pu,lu]}],sepia:[{sepia:["",Jd,pu,lu]}],"backdrop-filter":[{"backdrop-filter":["","none",pu,lu]}],"backdrop-blur":[{"backdrop-blur":O()}],"backdrop-brightness":[{"backdrop-brightness":[Jd,pu,lu]}],"backdrop-contrast":[{"backdrop-contrast":[Jd,pu,lu]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Jd,pu,lu]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Jd,pu,lu]}],"backdrop-invert":[{"backdrop-invert":["",Jd,pu,lu]}],"backdrop-opacity":[{"backdrop-opacity":[Jd,pu,lu]}],"backdrop-saturate":[{"backdrop-saturate":[Jd,pu,lu]}],"backdrop-sepia":[{"backdrop-sepia":["",Jd,pu,lu]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pu,lu]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Jd,"initial",pu,lu]}],ease:[{ease:["linear","initial",y,pu,lu]}],delay:[{delay:[Jd,pu,lu]}],animate:[{animate:["none",x,pu,lu]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[f,pu,lu]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:F()}],"rotate-x":[{"rotate-x":F()}],"rotate-y":[{"rotate-y":F()}],"rotate-z":[{"rotate-z":F()}],scale:[{scale:z()}],"scale-x":[{"scale-x":z()}],"scale-y":[{"scale-y":z()}],"scale-z":[{"scale-z":z()}],"scale-3d":["scale-3d"],skew:[{skew:L()}],"skew-x":[{"skew-x":L()}],"skew-y":[{"skew-y":L()}],transform:[{transform:[pu,lu,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:I()}],"translate-x":[{"translate-x":I()}],"translate-y":[{"translate-y":I()}],"translate-z":[{"translate-z":I()}],"translate-none":["translate-none"],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],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",pu,lu]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"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",pu,lu]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[Jd,fu,cu,du]}],stroke:[{stroke:["none",...T()]}],"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-x","border-w-y","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-x","border-color-y","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"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Ru(...e){return Au(Sd(e))}const Mu=(Du="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",$u={variants:{variant:{default:"text-white shadow",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/95",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/90",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline active:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}},e=>{var t;if(null==(null==$u?void 0:$u.variants))return kd(Du,null==e?void 0:e.class,null==e?void 0:e.className);const{variants:s,defaultVariants:n}=$u,r=Object.keys(s).map(t=>{const r=null==e?void 0:e[t],a=null==n?void 0:n[t];if(null===r)return null;const i=jd(r)||jd(a);return s[t][i]}),a=e&&Object.entries(e).reduce((e,t)=>{let[s,n]=t;return void 0===n||(e[s]=n),e},{}),i=null==$u||null===(t=$u.compoundVariants)||void 0===t?void 0:t.reduce((e,t)=>{let{class:s,className:r,...i}=t;return Object.entries(i).every(e=>{let[t,s]=e;return Array.isArray(s)?s.includes({...n,...a}[t]):{...n,...a}[t]===s})?[...e,s,r]:e},[]);return kd(Du,r,i,null==e?void 0:e.class,null==e?void 0:e.className)});var Du,$u;const Ou=Le.forwardRef(({className:e,variant:t,size:s,asChild:n=!1,textColor:r,style:a,disabled:i,...o},l)=>{const{theme:c}=ns(),d=n?yd:"button",u=(e,t)=>`rgba(${parseInt(e.slice(1,3),16)}, ${parseInt(e.slice(3,5),16)}, ${parseInt(e.slice(5,7),16)}, ${t})`,h=(()=>{if("default"!==t||!(null==c?void 0:c.primaryColor))return{};const e=c.primaryColor;return{backgroundColor:i?u(e,.5):e,"--hover-bg":u(e,.9),"--active-bg":u(e,.95)}})();return $e.jsx(d,{className:Ru(Mu({variant:t,size:s,className:e}),"default"===t&&(null==c?void 0:c.primaryColor)&&"hover:[background-color:var(--hover-bg)] active:[background-color:var(--active-bg)]"),style:{...h,...r&&{color:r},...a},disabled:i,ref:l,...o})});Ou.displayName="Button";const Fu=e=>{let t;const s=new Set,n=(e,n)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=n?n:"object"!=typeof r||null===r)?r:Object.assign({},t,r),s.forEach(s=>s(t,e))}},r=()=>t,a={setState:n,getState:r,getInitialState:()=>i,subscribe:e=>(s.add(e),()=>s.delete(e))},i=t=e(n,r,a);return a},zu=e=>e;const Lu=e=>{const t=(e=>e?Fu(e):Fu)(e),s=e=>function(e,t=zu){const s=Oe.useSyncExternalStore(e.subscribe,Oe.useCallback(()=>t(e.getState()),[e,t]),Oe.useCallback(()=>t(e.getInitialState()),[e,t]));return Oe.useDebugValue(s),s}(t,e);return Object.assign(s,t),s},Iu=e=>e?Lu(e):Lu,_u=e=>(t,s,n)=>{const r=n.subscribe;n.subscribe=(e,t,s)=>{let a=e;if(t){const r=(null==s?void 0:s.equalityFn)||Object.is;let i=e(n.getState());a=s=>{const n=e(s);if(!r(i,n)){const e=i;t(i=n,e)}},(null==s?void 0:s.fireImmediately)&&t(i,i)}return r(a)};return e(t,s,n)};function Vu(e,t){return function(){return e.apply(t,arguments)}}const{toString:Bu}=Object.prototype,{getPrototypeOf:qu}=Object,{iterator:Uu,toStringTag:Wu}=Symbol,Hu=(e=>t=>{const s=Bu.call(t);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ku=e=>(e=e.toLowerCase(),t=>Hu(t)===e),Yu=e=>t=>typeof t===e,{isArray:Qu}=Array,Gu=Yu("undefined");function Ju(e){return null!==e&&!Gu(e)&&null!==e.constructor&&!Gu(e.constructor)&&eh(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Xu=Ku("ArrayBuffer");const Zu=Yu("string"),eh=Yu("function"),th=Yu("number"),sh=e=>null!==e&&"object"==typeof e,nh=e=>{if("object"!==Hu(e))return!1;const t=qu(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Wu in e||Uu in e)},rh=Ku("Date"),ah=Ku("File"),ih=Ku("Blob"),oh=Ku("FileList"),lh=Ku("URLSearchParams"),[ch,dh,uh,hh]=["ReadableStream","Request","Response","Headers"].map(Ku);function mh(e,t,{allOwnKeys:s=!1}={}){if(null==e)return;let n,r;if("object"!=typeof e&&(e=[e]),Qu(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{if(Ju(e))return;const r=s?Object.getOwnPropertyNames(e):Object.keys(e),a=r.length;let i;for(n=0;n<a;n++)i=r[n],t.call(null,e[i],i,e)}}function ph(e,t){if(Ju(e))return null;t=t.toLowerCase();const s=Object.keys(e);let n,r=s.length;for(;r-- >0;)if(n=s[r],t===n.toLowerCase())return n;return null}const fh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,gh=e=>!Gu(e)&&e!==fh;const yh=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&qu(Uint8Array)),xh=Ku("HTMLFormElement"),vh=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),bh=Ku("RegExp"),wh=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),n={};mh(s,(s,r)=>{let a;!1!==(a=t(s,r,e))&&(n[r]=a||s)}),Object.defineProperties(e,n)};const Sh=Ku("AsyncFunction"),jh=(kh="function"==typeof setImmediate,Nh=eh(fh.postMessage),kh?setImmediate:Nh?(Eh=`axios@${Math.random()}`,Ch=[],fh.addEventListener("message",({source:e,data:t})=>{e===fh&&t===Eh&&Ch.length&&Ch.shift()()},!1),e=>{Ch.push(e),fh.postMessage(Eh,"*")}):e=>setTimeout(e));var kh,Nh,Eh,Ch;const Th="undefined"!=typeof queueMicrotask?queueMicrotask.bind(fh):"undefined"!=typeof process&&process.nextTick||jh,Ph={isArray:Qu,isArrayBuffer:Xu,isBuffer:Ju,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||eh(e.append)&&("formdata"===(t=Hu(e))||"object"===t&&eh(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Xu(e.buffer),t},isString:Zu,isNumber:th,isBoolean:e=>!0===e||!1===e,isObject:sh,isPlainObject:nh,isEmptyObject:e=>{if(!sh(e)||Ju(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(t){return!1}},isReadableStream:ch,isRequest:dh,isResponse:uh,isHeaders:hh,isUndefined:Gu,isDate:rh,isFile:ah,isBlob:ih,isRegExp:bh,isFunction:eh,isStream:e=>sh(e)&&eh(e.pipe),isURLSearchParams:lh,isTypedArray:yh,isFileList:oh,forEach:mh,merge:function e(){const{caseless:t,skipUndefined:s}=gh(this)&&this||{},n={},r=(r,a)=>{const i=t&&ph(n,a)||a;nh(n[i])&&nh(r)?n[i]=e(n[i],r):nh(r)?n[i]=e({},r):Qu(r)?n[i]=r.slice():s&&Gu(r)||(n[i]=r)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&mh(arguments[a],r);return n},extend:(e,t,s,{allOwnKeys:n}={})=>(mh(t,(t,n)=>{s&&eh(t)?e[n]=Vu(t,s):e[n]=t},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,s,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),s&&Object.assign(e.prototype,s)},toFlatObject:(e,t,s,n)=>{let r,a,i;const o={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),a=r.length;a-- >0;)i=r[a],n&&!n(i,e,t)||o[i]||(t[i]=e[i],o[i]=!0);e=!1!==s&&qu(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},kindOf:Hu,kindOfTest:Ku,endsWith:(e,t,s)=>{e=String(e),(void 0===s||s>e.length)&&(s=e.length),s-=t.length;const n=e.indexOf(t,s);return-1!==n&&n===s},toArray:e=>{if(!e)return null;if(Qu(e))return e;let t=e.length;if(!th(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},forEachEntry:(e,t)=>{const s=(e&&e[Uu]).call(e);let n;for(;(n=s.next())&&!n.done;){const s=n.value;t.call(e,s[0],s[1])}},matchAll:(e,t)=>{let s;const n=[];for(;null!==(s=e.exec(t));)n.push(s);return n},isHTMLForm:xh,hasOwnProperty:vh,hasOwnProp:vh,reduceDescriptors:wh,freezeMethods:e=>{wh(e,(t,s)=>{if(eh(e)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const n=e[s];eh(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))})},toObjectSet:(e,t)=>{const s={},n=e=>{e.forEach(e=>{s[e]=!0})};return Qu(e)?n(e):n(String(e).split(t)),s},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,s){return t.toUpperCase()+s}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:ph,global:fh,isContextDefined:gh,isSpecCompliantForm:function(e){return!!(e&&eh(e.append)&&"FormData"===e[Wu]&&e[Uu])},toJSONObject:e=>{const t=new Array(10),s=(e,n)=>{if(sh(e)){if(t.indexOf(e)>=0)return;if(Ju(e))return e;if(!("toJSON"in e)){t[n]=e;const r=Qu(e)?[]:{};return mh(e,(e,t)=>{const a=s(e,n+1);!Gu(a)&&(r[t]=a)}),t[n]=void 0,r}}return e};return s(e,0)},isAsyncFn:Sh,isThenable:e=>e&&(sh(e)||eh(e))&&eh(e.then)&&eh(e.catch),setImmediate:jh,asap:Th,isIterable:e=>null!=e&&eh(e[Uu])};function Ah(e,t,s,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),s&&(this.config=s),n&&(this.request=n),r&&(this.response=r,this.status=r.status?r.status:null)}Ph.inherits(Ah,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Ph.toJSONObject(this.config),code:this.code,status:this.status}}});const Rh=Ah.prototype,Mh={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Mh[e]={value:e}}),Object.defineProperties(Ah,Mh),Object.defineProperty(Rh,"isAxiosError",{value:!0}),Ah.from=(e,t,s,n,r,a)=>{const i=Object.create(Rh);Ph.toFlatObject(e,i,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const o=e&&e.message?e.message:"Error",l=null==t&&e?e.code:t;return Ah.call(i,o,l,s,n,r),e&&null==i.cause&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",a&&Object.assign(i,a),i};function Dh(e){return Ph.isPlainObject(e)||Ph.isArray(e)}function $h(e){return Ph.endsWith(e,"[]")?e.slice(0,-2):e}function Oh(e,t,s){return e?e.concat(t).map(function(e,t){return e=$h(e),!s&&t?"["+e+"]":e}).join(s?".":""):t}const Fh=Ph.toFlatObject(Ph,{},null,function(e){return/^is[A-Z]/.test(e)});function zh(e,t,s){if(!Ph.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(s=Ph.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Ph.isUndefined(t[e])})).metaTokens,r=s.visitor||c,a=s.dots,i=s.indexes,o=(s.Blob||"undefined"!=typeof Blob&&Blob)&&Ph.isSpecCompliantForm(t);if(!Ph.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Ph.isDate(e))return e.toISOString();if(Ph.isBoolean(e))return e.toString();if(!o&&Ph.isBlob(e))throw new Ah("Blob is not supported. Use a Buffer instead.");return Ph.isArrayBuffer(e)||Ph.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function c(e,s,r){let o=e;if(e&&!r&&"object"==typeof e)if(Ph.endsWith(s,"{}"))s=n?s:s.slice(0,-2),e=JSON.stringify(e);else if(Ph.isArray(e)&&function(e){return Ph.isArray(e)&&!e.some(Dh)}(e)||(Ph.isFileList(e)||Ph.endsWith(s,"[]"))&&(o=Ph.toArray(e)))return s=$h(s),o.forEach(function(e,n){!Ph.isUndefined(e)&&null!==e&&t.append(!0===i?Oh([s],n,a):null===i?s:s+"[]",l(e))}),!1;return!!Dh(e)||(t.append(Oh(r,s,a),l(e)),!1)}const d=[],u=Object.assign(Fh,{defaultVisitor:c,convertValue:l,isVisitable:Dh});if(!Ph.isObject(e))throw new TypeError("data must be an object");return function e(s,n){if(!Ph.isUndefined(s)){if(-1!==d.indexOf(s))throw Error("Circular reference detected in "+n.join("."));d.push(s),Ph.forEach(s,function(s,a){!0===(!(Ph.isUndefined(s)||null===s)&&r.call(t,s,Ph.isString(a)?a.trim():a,n,u))&&e(s,n?n.concat(a):[a])}),d.pop()}}(e),t}function Lh(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ih(e,t){this._pairs=[],e&&zh(e,this,t)}const _h=Ih.prototype;function Vh(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Bh(e,t,s){if(!t)return e;const n=s&&s.encode||Vh;Ph.isFunction(s)&&(s={serialize:s});const r=s&&s.serialize;let a;if(a=r?r(t,s):Ph.isURLSearchParams(t)?t.toString():new Ih(t,s).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}_h.append=function(e,t){this._pairs.push([e,t])},_h.toString=function(e){const t=e?function(t){return e.call(this,t,Lh)}:Lh;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class qh{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Ph.forEach(this.handlers,function(t){null!==t&&e(t)})}}const Uh={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wh={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ih,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},Hh="undefined"!=typeof window&&"undefined"!=typeof document,Kh="object"==typeof navigator&&navigator||void 0,Yh=Hh&&(!Kh||["ReactNative","NativeScript","NS"].indexOf(Kh.product)<0),Qh="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Gh=Hh&&window.location.href||"http://localhost",Jh={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Hh,hasStandardBrowserEnv:Yh,hasStandardBrowserWebWorkerEnv:Qh,navigator:Kh,origin:Gh},Symbol.toStringTag,{value:"Module"})),...Wh};function Xh(e){function t(e,s,n,r){let a=e[r++];if("__proto__"===a)return!0;const i=Number.isFinite(+a),o=r>=e.length;if(a=!a&&Ph.isArray(n)?n.length:a,o)return Ph.hasOwnProp(n,a)?n[a]=[n[a],s]:n[a]=s,!i;n[a]&&Ph.isObject(n[a])||(n[a]=[]);return t(e,s,n[a],r)&&Ph.isArray(n[a])&&(n[a]=function(e){const t={},s=Object.keys(e);let n;const r=s.length;let a;for(n=0;n<r;n++)a=s[n],t[a]=e[a];return t}(n[a])),!i}if(Ph.isFormData(e)&&Ph.isFunction(e.entries)){const s={};return Ph.forEachEntry(e,(e,n)=>{t(function(e){return Ph.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,s,0)}),s}return null}const Zh={transitional:Uh,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",n=s.indexOf("application/json")>-1,r=Ph.isObject(e);r&&Ph.isHTMLForm(e)&&(e=new FormData(e));if(Ph.isFormData(e))return n?JSON.stringify(Xh(e)):e;if(Ph.isArrayBuffer(e)||Ph.isBuffer(e)||Ph.isStream(e)||Ph.isFile(e)||Ph.isBlob(e)||Ph.isReadableStream(e))return e;if(Ph.isArrayBufferView(e))return e.buffer;if(Ph.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(r){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return zh(e,new Jh.classes.URLSearchParams,{visitor:function(e,t,s,n){return Jh.isNode&&Ph.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((a=Ph.isFileList(e))||s.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return zh(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),function(e,t,s){if(Ph.isString(e))try{return(t||JSON.parse)(e),Ph.trim(e)}catch(n){if("SyntaxError"!==n.name)throw n}return(s||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Zh.transitional,s=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Ph.isResponse(e)||Ph.isReadableStream(e))return e;if(e&&Ph.isString(e)&&(s&&!this.responseType||n)){const s=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(r){if(s){if("SyntaxError"===r.name)throw Ah.from(r,Ah.ERR_BAD_RESPONSE,this,null,this.response);throw r}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Jh.classes.FormData,Blob:Jh.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Ph.forEach(["delete","get","head","post","put","patch"],e=>{Zh.headers[e]={}});const em=Ph.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tm=Symbol("internals");function sm(e){return e&&String(e).trim().toLowerCase()}function nm(e){return!1===e||null==e?e:Ph.isArray(e)?e.map(nm):String(e)}function rm(e,t,s,n,r){return Ph.isFunction(n)?n.call(this,t,s):(r&&(t=s),Ph.isString(t)?Ph.isString(n)?-1!==t.indexOf(n):Ph.isRegExp(n)?n.test(t):void 0:void 0)}let am=class{constructor(e){e&&this.set(e)}set(e,t,s){const n=this;function r(e,t,s){const r=sm(t);if(!r)throw new Error("header name must be a non-empty string");const a=Ph.findKey(n,r);(!a||void 0===n[a]||!0===s||void 0===s&&!1!==n[a])&&(n[a||t]=nm(e))}const a=(e,t)=>Ph.forEach(e,(e,s)=>r(e,s,t));if(Ph.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(Ph.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))a((e=>{const t={};let s,n,r;return e&&e.split("\n").forEach(function(e){r=e.indexOf(":"),s=e.substring(0,r).trim().toLowerCase(),n=e.substring(r+1).trim(),!s||t[s]&&em[s]||("set-cookie"===s?t[s]?t[s].push(n):t[s]=[n]:t[s]=t[s]?t[s]+", "+n:n)}),t})(e),t);else if(Ph.isObject(e)&&Ph.isIterable(e)){let s,n,r={};for(const t of e){if(!Ph.isArray(t))throw TypeError("Object iterator must return a key-value pair");r[n=t[0]]=(s=r[n])?Ph.isArray(s)?[...s,t[1]]:[s,t[1]]:t[1]}a(r,t)}else null!=e&&r(t,e,s);return this}get(e,t){if(e=sm(e)){const s=Ph.findKey(this,e);if(s){const e=this[s];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=s.exec(e);)t[n[1]]=n[2];return t}(e);if(Ph.isFunction(t))return t.call(this,e,s);if(Ph.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=sm(e)){const s=Ph.findKey(this,e);return!(!s||void 0===this[s]||t&&!rm(0,this[s],s,t))}return!1}delete(e,t){const s=this;let n=!1;function r(e){if(e=sm(e)){const r=Ph.findKey(s,e);!r||t&&!rm(0,s[r],r,t)||(delete s[r],n=!0)}}return Ph.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let s=t.length,n=!1;for(;s--;){const r=t[s];e&&!rm(0,this[r],r,e,!0)||(delete this[r],n=!0)}return n}normalize(e){const t=this,s={};return Ph.forEach(this,(n,r)=>{const a=Ph.findKey(s,r);if(a)return t[a]=nm(n),void delete t[r];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}(r):String(r).trim();i!==r&&delete t[r],t[i]=nm(n),s[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Ph.forEach(this,(s,n)=>{null!=s&&!1!==s&&(t[n]=e&&Ph.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(e=>s.set(e)),s}static accessor(e){const t=(this[tm]=this[tm]={accessors:{}}).accessors,s=this.prototype;function n(e){const n=sm(e);t[n]||(!function(e,t){const s=Ph.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+s,{value:function(e,s,r){return this[n].call(this,t,e,s,r)},configurable:!0})})}(s,e),t[n]=!0)}return Ph.isArray(e)?e.forEach(n):n(e),this}};function im(e,t){const s=this||Zh,n=t||s,r=am.from(n.headers);let a=n.data;return Ph.forEach(e,function(e){a=e.call(s,a,r.normalize(),t?t.status:void 0)}),r.normalize(),a}function om(e){return!(!e||!e.__CANCEL__)}function lm(e,t,s){Ah.call(this,null==e?"canceled":e,Ah.ERR_CANCELED,t,s),this.name="CanceledError"}function cm(e,t,s){const n=s.config.validateStatus;s.status&&n&&!n(s.status)?t(new Ah("Request failed with status code "+s.status,[Ah.ERR_BAD_REQUEST,Ah.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}am.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ph.reduceDescriptors(am.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[s]=e}}}),Ph.freezeMethods(am),Ph.inherits(lm,Ah,{__CANCEL__:!0});const dm=(e,t,s=3)=>{let n=0;const r=function(e,t){e=e||10;const s=new Array(e),n=new Array(e);let r,a=0,i=0;return t=void 0!==t?t:1e3,function(o){const l=Date.now(),c=n[i];r||(r=l),s[a]=o,n[a]=l;let d=i,u=0;for(;d!==a;)u+=s[d++],d%=e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),l-r<t)return;const h=c&&l-c;return h?Math.round(1e3*u/h):void 0}}(50,250);return function(e,t){let s,n,r=0,a=1e3/t;const i=(t,a=Date.now())=>{r=a,s=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),o=t-r;o>=a?i(e,t):(s=e,n||(n=setTimeout(()=>{n=null,i(s)},a-o)))},()=>s&&i(s)]}(s=>{const a=s.loaded,i=s.lengthComputable?s.total:void 0,o=a-n,l=r(o);n=a;e({loaded:a,total:i,progress:i?a/i:void 0,bytes:o,rate:l||void 0,estimated:l&&i&&a<=i?(i-a)/l:void 0,event:s,lengthComputable:null!=i,[t?"download":"upload"]:!0})},s)},um=(e,t)=>{const s=null!=e;return[n=>t[0]({lengthComputable:s,total:e,loaded:n}),t[1]]},hm=e=>(...t)=>Ph.asap(()=>e(...t)),mm=Jh.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,Jh.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(Jh.origin),Jh.navigator&&/(msie|trident)/i.test(Jh.navigator.userAgent)):()=>!0,pm=Jh.hasStandardBrowserEnv?{write(e,t,s,n,r,a){const i=[e+"="+encodeURIComponent(t)];Ph.isNumber(s)&&i.push("expires="+new Date(s).toGMTString()),Ph.isString(n)&&i.push("path="+n),Ph.isString(r)&&i.push("domain="+r),!0===a&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function fm(e,t,s){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==s)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const gm=e=>e instanceof am?{...e}:e;function ym(e,t){t=t||{};const s={};function n(e,t,s,n){return Ph.isPlainObject(e)&&Ph.isPlainObject(t)?Ph.merge.call({caseless:n},e,t):Ph.isPlainObject(t)?Ph.merge({},t):Ph.isArray(t)?t.slice():t}function r(e,t,s,r){return Ph.isUndefined(t)?Ph.isUndefined(e)?void 0:n(void 0,e,0,r):n(e,t,0,r)}function a(e,t){if(!Ph.isUndefined(t))return n(void 0,t)}function i(e,t){return Ph.isUndefined(t)?Ph.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(s,r,a){return a in t?n(s,r):a in e?n(void 0,s):void 0}const l={url:a,method:a,data:a,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:o,headers:(e,t,s)=>r(gm(e),gm(t),0,!0)};return Ph.forEach(Object.keys({...e,...t}),function(n){const a=l[n]||r,i=a(e[n],t[n],n);Ph.isUndefined(i)&&a!==o||(s[n]=i)}),s}const xm=e=>{const t=ym({},e);let{data:s,withXSRFToken:n,xsrfHeaderName:r,xsrfCookieName:a,headers:i,auth:o}=t;if(t.headers=i=am.from(i),t.url=Bh(fm(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&i.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Ph.isFormData(s))if(Jh.hasStandardBrowserEnv||Jh.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Ph.isFunction(s.getHeaders)){const e=s.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,s])=>{t.includes(e.toLowerCase())&&i.set(e,s)})}if(Jh.hasStandardBrowserEnv&&(n&&Ph.isFunction(n)&&(n=n(t)),n||!1!==n&&mm(t.url))){const e=r&&a&&pm.read(a);e&&i.set(r,e)}return t},vm="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,s){const n=xm(e);let r=n.data;const a=am.from(n.headers).normalize();let i,o,l,c,d,{responseType:u,onUploadProgress:h,onDownloadProgress:m}=n;function p(){c&&c(),d&&d(),n.cancelToken&&n.cancelToken.unsubscribe(i),n.signal&&n.signal.removeEventListener("abort",i)}let f=new XMLHttpRequest;function g(){if(!f)return;const n=am.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());cm(function(e){t(e),p()},function(e){s(e),p()},{data:u&&"text"!==u&&"json"!==u?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:n,config:e,request:f}),f=null}f.open(n.method.toUpperCase(),n.url,!0),f.timeout=n.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(s(new Ah("Request aborted",Ah.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const n=new Ah(t&&t.message?t.message:"Network Error",Ah.ERR_NETWORK,e,f);n.event=t||null,s(n),f=null},f.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||Uh;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),s(new Ah(t,r.clarifyTimeoutError?Ah.ETIMEDOUT:Ah.ECONNABORTED,e,f)),f=null},void 0===r&&a.setContentType(null),"setRequestHeader"in f&&Ph.forEach(a.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Ph.isUndefined(n.withCredentials)||(f.withCredentials=!!n.withCredentials),u&&"json"!==u&&(f.responseType=n.responseType),m&&([l,d]=dm(m,!0),f.addEventListener("progress",l)),h&&f.upload&&([o,c]=dm(h),f.upload.addEventListener("progress",o),f.upload.addEventListener("loadend",c)),(n.cancelToken||n.signal)&&(i=t=>{f&&(s(!t||t.type?new lm(null,e,f):t),f.abort(),f=null)},n.cancelToken&&n.cancelToken.subscribe(i),n.signal&&(n.signal.aborted?i():n.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);y&&-1===Jh.protocols.indexOf(y)?s(new Ah("Unsupported protocol "+y+":",Ah.ERR_BAD_REQUEST,e)):f.send(r||null)})},bm=(e,t)=>{const{length:s}=e=e?e.filter(Boolean):[];if(t||s){let s,n=new AbortController;const r=function(e){if(!s){s=!0,i();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Ah?t:new lm(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,r(new Ah(`timeout ${t} of ms exceeded`,Ah.ETIMEDOUT))},t);const i=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)}),e=null)};e.forEach(e=>e.addEventListener("abort",r));const{signal:o}=n;return o.unsubscribe=()=>Ph.asap(i),o}},wm=function*(e,t){let s=e.byteLength;if(s<t)return void(yield e);let n,r=0;for(;r<s;)n=r+t,yield e.slice(r,n),r=n},Sm=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{await t.cancel()}},jm=(e,t,s,n)=>{const r=async function*(e,t){for await(const s of Sm(e))yield*wm(s,t)}(e,t);let a,i=0,o=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await r.next();if(t)return o(),void e.close();let a=n.byteLength;if(s){let e=i+=a;s(e)}e.enqueue(new Uint8Array(n))}catch(t){throw o(t),t}},cancel:e=>(o(e),r.return())},{highWaterMark:2})},{isFunction:km}=Ph,Nm=(({Request:e,Response:t})=>({Request:e,Response:t}))(Ph.global),{ReadableStream:Em,TextEncoder:Cm}=Ph.global,Tm=(e,...t)=>{try{return!!e(...t)}catch(s){return!1}},Pm=e=>{e=Ph.merge.call({skipUndefined:!0},Nm,e);const{fetch:t,Request:s,Response:n}=e,r=t?km(t):"function"==typeof fetch,a=km(s),i=km(n);if(!r)return!1;const o=r&&km(Em),l=r&&("function"==typeof Cm?(e=>t=>e.encode(t))(new Cm):async e=>new Uint8Array(await new s(e).arrayBuffer())),c=a&&o&&Tm(()=>{let e=!1;const t=new s(Jh.origin,{body:new Em,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),d=i&&o&&Tm(()=>Ph.isReadableStream(new n("").body)),u={stream:d&&(e=>e.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!u[e]&&(u[e]=(t,s)=>{let n=t&&t[e];if(n)return n.call(t);throw new Ah(`Response type '${e}' is not supported`,Ah.ERR_NOT_SUPPORT,s)})});const h=async(e,t)=>{const n=Ph.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Ph.isBlob(e))return e.size;if(Ph.isSpecCompliantForm(e)){const t=new s(Jh.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Ph.isArrayBufferView(e)||Ph.isArrayBuffer(e)?e.byteLength:(Ph.isURLSearchParams(e)&&(e+=""),Ph.isString(e)?(await l(e)).byteLength:void 0)})(t):n};return async e=>{let{url:r,method:i,data:o,signal:l,cancelToken:m,timeout:p,onDownloadProgress:f,onUploadProgress:g,responseType:y,headers:x,withCredentials:v="same-origin",fetchOptions:b}=xm(e),w=t||fetch;y=y?(y+"").toLowerCase():"text";let S=bm([l,m&&m.toAbortSignal()],p),j=null;const k=S&&S.unsubscribe&&(()=>{S.unsubscribe()});let N;try{if(g&&c&&"get"!==i&&"head"!==i&&0!==(N=await h(x,o))){let e,t=new s(r,{method:"POST",body:o,duplex:"half"});if(Ph.isFormData(o)&&(e=t.headers.get("content-type"))&&x.setContentType(e),t.body){const[e,s]=um(N,dm(hm(g)));o=jm(t.body,65536,e,s)}}Ph.isString(v)||(v=v?"include":"omit");const t=a&&"credentials"in s.prototype,l={...b,signal:S,method:i.toUpperCase(),headers:x.normalize().toJSON(),body:o,duplex:"half",credentials:t?v:void 0};j=a&&new s(r,l);let m=await(a?w(j,b):w(r,l));const p=d&&("stream"===y||"response"===y);if(d&&(f||p&&k)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=m[t]});const t=Ph.toFiniteNumber(m.headers.get("content-length")),[s,r]=f&&um(t,dm(hm(f),!0))||[];m=new n(jm(m.body,65536,s,()=>{r&&r(),k&&k()}),e)}y=y||"text";let E=await u[Ph.findKey(u,y)||"text"](m,e);return!p&&k&&k(),await new Promise((t,s)=>{cm(t,s,{data:E,headers:am.from(m.headers),status:m.status,statusText:m.statusText,config:e,request:j})})}catch(E){if(k&&k(),E&&"TypeError"===E.name&&/Load failed|fetch/i.test(E.message))throw Object.assign(new Ah("Network Error",Ah.ERR_NETWORK,e,j),{cause:E.cause||E});throw Ah.from(E,E&&E.code,e,j)}}},Am=new Map,Rm=e=>{let t=e?e.env:{};const{fetch:s,Request:n,Response:r}=t,a=[n,r,s];let i,o,l=a.length,c=Am;for(;l--;)i=a[l],o=c.get(i),void 0===o&&c.set(i,o=l?new Map:Pm(t)),c=o;return o};Rm();const Mm={http:null,xhr:vm,fetch:{get:Rm}};Ph.forEach(Mm,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(s){}Object.defineProperty(e,"adapterName",{value:t})}});const Dm=e=>`- ${e}`,$m=e=>Ph.isFunction(e)||null===e||!1===e,Om=(e,t)=>{e=Ph.isArray(e)?e:[e];const{length:s}=e;let n,r;const a={};for(let i=0;i<s;i++){let s;if(n=e[i],r=n,!$m(n)&&(r=Mm[(s=String(n)).toLowerCase()],void 0===r))throw new Ah(`Unknown adapter '${s}'`);if(r&&(Ph.isFunction(r)||(r=r.get(t))))break;a[s||"#"+i]=r}if(!r){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Ah("There is no suitable adapter to dispatch the request "+(s?e.length>1?"since :\n"+e.map(Dm).join("\n"):" "+Dm(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Fm(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lm(null,e)}function zm(e){Fm(e),e.headers=am.from(e.headers),e.data=im.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Om(e.adapter||Zh.adapter,e)(e).then(function(t){return Fm(e),t.data=im.call(e,e.transformResponse,t),t.headers=am.from(t.headers),t},function(t){return om(t)||(Fm(e),t&&t.response&&(t.response.data=im.call(e,e.transformResponse,t.response),t.response.headers=am.from(t.response.headers))),Promise.reject(t)})}const Lm="1.12.2",Im={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Im[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const _m={};Im.transitional=function(e,t,s){function n(e,t){return"[Axios v"+Lm+"] Transitional option '"+e+"'"+t+(s?". "+s:"")}return(s,r,a)=>{if(!1===e)throw new Ah(n(r," has been removed"+(t?" in "+t:"")),Ah.ERR_DEPRECATED);return t&&!_m[r]&&(_m[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(s,r,a)}},Im.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};const Vm={assertOptions:function(e,t,s){if("object"!=typeof e)throw new Ah("options must be an object",Ah.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;for(;r-- >0;){const a=n[r],i=t[a];if(i){const t=e[a],s=void 0===t||i(t,a,e);if(!0!==s)throw new Ah("option "+a+" must be "+s,Ah.ERR_BAD_OPTION_VALUE);continue}if(!0!==s)throw new Ah("Unknown option "+a,Ah.ERR_BAD_OPTION)}},validators:Im},Bm=Vm.validators;let qm=class{constructor(e){this.defaults=e||{},this.interceptors={request:new qh,response:new qh}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{s.stack?t&&!String(s.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(s.stack+="\n"+t):s.stack=t}catch(n){}}throw s}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ym(this.defaults,t);const{transitional:s,paramsSerializer:n,headers:r}=t;void 0!==s&&Vm.assertOptions(s,{silentJSONParsing:Bm.transitional(Bm.boolean),forcedJSONParsing:Bm.transitional(Bm.boolean),clarifyTimeoutError:Bm.transitional(Bm.boolean)},!1),null!=n&&(Ph.isFunction(n)?t.paramsSerializer={serialize:n}:Vm.assertOptions(n,{encode:Bm.function,serialize:Bm.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Vm.assertOptions(t,{baseUrl:Bm.spelling("baseURL"),withXsrfToken:Bm.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=r&&Ph.merge(r.common,r[t.method]);r&&Ph.forEach(["delete","get","head","post","put","patch","common"],e=>{delete r[e]}),t.headers=am.concat(a,r);const i=[];let o=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,i.unshift(e.fulfilled,e.rejected))});const l=[];let c;this.interceptors.response.forEach(function(e){l.push(e.fulfilled,e.rejected)});let d,u=0;if(!o){const e=[zm.bind(this),void 0];for(e.unshift(...i),e.push(...l),d=e.length,c=Promise.resolve(t);u<d;)c=c.then(e[u++],e[u++]);return c}d=i.length;let h=t;for(;u<d;){const e=i[u++],t=i[u++];try{h=e(h)}catch(m){t.call(this,m);break}}try{c=zm.call(this,h)}catch(m){return Promise.reject(m)}for(u=0,d=l.length;u<d;)c=c.then(l[u++],l[u++]);return c}getUri(e){return Bh(fm((e=ym(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Ph.forEach(["delete","get","head","options"],function(e){qm.prototype[e]=function(t,s){return this.request(ym(s||{},{method:e,url:t,data:(s||{}).data}))}}),Ph.forEach(["post","put","patch"],function(e){function t(t){return function(s,n,r){return this.request(ym(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:n}))}}qm.prototype[e]=t(),qm.prototype[e+"Form"]=t(!0)});const Um={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Um).forEach(([e,t])=>{Um[t]=e});const Wm=function e(t){const s=new qm(t),n=Vu(qm.prototype.request,s);return Ph.extend(n,qm.prototype,s,{allOwnKeys:!0}),Ph.extend(n,s,null,{allOwnKeys:!0}),n.create=function(s){return e(ym(t,s))},n}(Zh);Wm.Axios=qm,Wm.CanceledError=lm,Wm.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const s=this;this.promise.then(e=>{if(!s._listeners)return;let t=s._listeners.length;for(;t-- >0;)s._listeners[t](e);s._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{s.subscribe(e),t=e}).then(e);return n.cancel=function(){s.unsubscribe(t)},n},e(function(e,n,r){s.reason||(s.reason=new lm(e,n,r),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},Wm.isCancel=om,Wm.VERSION=Lm,Wm.toFormData=zh,Wm.AxiosError=Ah,Wm.Cancel=Wm.CanceledError,Wm.all=function(e){return Promise.all(e)},Wm.spread=function(e){return function(t){return e.apply(null,t)}},Wm.isAxiosError=function(e){return Ph.isObject(e)&&!0===e.isAxiosError},Wm.mergeConfig=ym,Wm.AxiosHeaders=am,Wm.formToJSON=e=>Xh(Ph.isHTMLForm(e)?new FormData(e):e),Wm.getAdapter=Om,Wm.HttpStatusCode=Um,Wm.default=Wm;const{Axios:Hm,AxiosError:Km,CanceledError:Ym,isCancel:Qm,CancelToken:Gm,VERSION:Jm,all:Xm,Cancel:Zm,isAxiosError:ep,spread:tp,toFormData:sp,AxiosHeaders:np,HttpStatusCode:rp,formToJSON:ap,getAdapter:ip,mergeConfig:op}=Wm;class lp extends Error{}function cp(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,(e,t)=>{let s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(t)}catch(s){return atob(t)}}function dp(e,t){if("string"!=typeof e)throw new lp("Invalid token specified: must be a string");t||(t={});const s=!0===t.header?0:1,n=e.split(".")[s];if("string"!=typeof n)throw new lp(`Invalid token specified: missing part #${s+1}`);let r;try{r=cp(n)}catch(a){throw new lp(`Invalid token specified: invalid base64 for part #${s+1} (${a.message})`)}try{return JSON.parse(r)}catch(a){throw new lp(`Invalid token specified: invalid json for part #${s+1} (${a.message})`)}}lp.prototype.name="InvalidTokenError";const up="pangents_bearer_token",hp="pangents_refresh_token",mp="pangents_token_expiry",pp=()=>{try{return localStorage.getItem(up)}catch(e){return console.error("[Token Storage] Failed to get access token:",e),null}},fp=()=>{try{return localStorage.getItem(hp)}catch(e){return console.error("[Token Storage] Failed to get refresh token:",e),null}},gp=(e,t)=>{try{localStorage.setItem(up,e),t&&localStorage.setItem(hp,t);const s=dp(e);localStorage.setItem(mp,s.exp.toString()),console.log("[Token Storage] Tokens stored successfully")}catch(s){console.error("[Token Storage] Failed to store tokens:",s)}},yp=e=>{try{localStorage.setItem(up,e);const t=dp(e);localStorage.setItem(mp,t.exp.toString()),console.log("[Token Storage] Bearer token stored successfully")}catch(t){console.error("[Token Storage] Failed to store bearer token:",t),localStorage.setItem(up,e)}},xp=()=>{try{localStorage.removeItem(up),localStorage.removeItem(hp),localStorage.removeItem(mp),console.log("[Token Storage] Tokens cleared successfully")}catch(e){console.error("[Token Storage] Failed to clear tokens:",e)}},vp=e=>{try{const t=e||pp();if(!t)return!0;const s=dp(t),n=Date.now()/1e3;return s.exp<n+300}catch(t){return console.error("[Token Validation] Failed to check token expiry:",t),!0}},bp=()=>{try{const e=localStorage.getItem(mp);return e?parseInt(e,10):null}catch(e){return console.error("[Token Storage] Failed to get token expiry:",e),null}},wp=async()=>{try{const e=fp();if(!e)throw new Error("No refresh token available");if(vp(e))throw new Error("Refresh token is expired");const{api:t}=await Promise.resolve().then(()=>Dp),s=await t.post("/auth/refresh",{refreshToken:e}),{accessToken:n,refreshToken:r}=s.data;if(n&&r)return gp(n,r),console.log("[Token Refresh] Tokens refreshed successfully"),n;throw new Error("Invalid refresh response")}catch(e){return console.error("[Token Refresh] Failed to refresh tokens:",e),xp(),null}};let Sp=null;const jp=()=>{const e=()=>{const t=bp();if(!t)return;const s=t-Date.now()/1e3,n=Math.max(0,1e3*(s-600));Sp&&clearTimeout(Sp),Sp=setTimeout(async()=>{console.log("[Auto Refresh] Attempting to refresh tokens");await wp()?e():window.dispatchEvent(new CustomEvent("auth:logout",{detail:{reason:"auto_refresh_failed"}}))},n),console.log(`[Auto Refresh] Scheduled for ${new Date(Date.now()+n).toISOString()}`)};e()},kp=Object.freeze(Object.defineProperty({__proto__:null,clearAutoRefresh:()=>{Sp&&(clearTimeout(Sp),Sp=null,console.log("[Auto Refresh] Cleared refresh timer"))},clearTokens:xp,getAccessToken:pp,getRefreshToken:fp,getTokenExpiry:bp,isTokenExpired:vp,refreshAccessToken:wp,setBearerToken:yp,setTokens:gp,setupAutoRefresh:jp},Symbol.toStringTag,{value:"Module"}));class Np{constructor(){Ce(this,"failures",0),Ce(this,"lastFailureTime",0),Ce(this,"state","closed"),Ce(this,"failureThreshold",5),Ce(this,"recoveryTimeout",6e4),Ce(this,"halfOpenMaxCalls",3),Ce(this,"halfOpenCalls",0)}canExecute(){const e=Date.now();switch(this.state){case"closed":return!0;case"open":return e-this.lastFailureTime>=this.recoveryTimeout&&(this.state="half-open",this.halfOpenCalls=0,!0);case"half-open":return this.halfOpenCalls<this.halfOpenMaxCalls;default:return!1}}onSuccess(){this.failures=0,this.state="closed",this.halfOpenCalls=0}onFailure(){this.failures++,this.lastFailureTime=Date.now(),"half-open"===this.state?(this.state="open",this.halfOpenCalls=0):this.failures>=this.failureThreshold&&(this.state="open")}getState(){return this.state}}class Ep{constructor(){Ce(this,"requests",[]),Ce(this,"maxRequests",10),Ce(this,"windowMs",6e4)}canMakeRequest(){const e=Date.now();return this.requests=this.requests.filter(t=>e-t<this.windowMs),this.requests.length<this.maxRequests}recordRequest(){this.requests.push(Date.now())}getRemainingRequests(){const e=Date.now();return this.requests=this.requests.filter(t=>e-t<this.windowMs),Math.max(0,this.maxRequests-this.requests.length)}}const Cp=new class{constructor(){Ce(this,"errorQueue",[]),Ce(this,"isOnline",navigator.onLine),Ce(this,"maxQueueSize",50),Ce(this,"retryAttempts",2),Ce(this,"retryDelay",2e3),Ce(this,"circuitBreaker",new Np),Ce(this,"rateLimiter",new Ep),Ce(this,"reportingEnabled",!0),Ce(this,"duplicateErrorCache",new Map),Ce(this,"duplicateTimeWindow",3e4),this.setupEventListeners()}setupEventListeners(){window.addEventListener("online",()=>{this.isOnline=!0,this.flushErrorQueue()}),window.addEventListener("offline",()=>{this.isOnline=!1}),window.addEventListener("error",e=>{this.handleJavaScriptError(e.error,{component:"Global",action:"Runtime Error"})}),window.addEventListener("unhandledrejection",e=>{this.handleJavaScriptError(new Error(e.reason),{component:"Global",action:"Unhandled Promise Rejection"})})}async validateApiKeyBeforeRequest(e){return e?!(!e.startsWith("pangents_wk_")||e.length<20)||(console.warn("[Enhanced Error Handler] Invalid API key format"),!1):(console.warn("[Enhanced Error Handler] No API key provided for validation"),!1)}generateErrorFingerprint(e,t){return`${e.message}-${e.status}-${t.component}-${t.action}`}isDuplicateError(e){const t=Date.now(),s=this.duplicateErrorCache.get(e);if(s&&t-s<this.duplicateTimeWindow)return!0;this.duplicateErrorCache.set(e,t);for(const[n,r]of this.duplicateErrorCache.entries())t-r>this.duplicateTimeWindow&&this.duplicateErrorCache.delete(n);return!1}handleApiError(e,t){var s,n,r,a,i;const o={message:e.message||"An unexpected error occurred",status:e.status||(null==(s=e.response)?void 0:s.status)||0,code:e.code||(null==(r=null==(n=e.response)?void 0:n.data)?void 0:r.code),details:(null==(i=null==(a=e.response)?void 0:a.data)?void 0:i.details)||e.details,timestamp:(new Date).toISOString()},l={component:(null==t?void 0:t.component)||"Unknown",action:(null==t?void 0:t.action)||"Unknown",userId:null==t?void 0:t.userId,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href,apiKey:(null==t?void 0:t.apiKey)?t.apiKey.substring(0,20)+"...":void 0},c=this.determineSeverity(o),d={error:o,context:l,stack:e.stack,severity:c},u=this.generateErrorFingerprint(o,l);return this.isDuplicateError(u)?(console.log("[Enhanced Error Handler] Duplicate error detected, skipping report"),o):(this.reportError(d),this.showUserNotification(o,c),o)}handleJavaScriptError(e,t){const s={error:{message:e.message,status:0,code:"JAVASCRIPT_ERROR",details:{name:e.name},timestamp:(new Date).toISOString()},context:{component:(null==t?void 0:t.component)||"JavaScript",action:(null==t?void 0:t.action)||"Runtime",userId:null==t?void 0:t.userId,timestamp:(new Date).toISOString(),userAgent:navigator.userAgent,url:window.location.href},stack:e.stack,severity:"medium"};this.reportError(s)}determineSeverity(e){return e.status>=500||"NETWORK_ERROR"===e.code?"critical":401===e.status||403===e.status||429===e.status?"high":e.status>=400&&e.status<500?"medium":"low"}async reportError(e){try{if(!this.reportingEnabled)return void console.log("[Enhanced Error Handler] Error reporting is disabled");if(!this.circuitBreaker.canExecute())return void console.warn("[Enhanced Error Handler] Circuit breaker is open, skipping error report");if(!this.rateLimiter.canMakeRequest())return void console.warn("[Enhanced Error Handler] Rate limit exceeded, skipping error report");if(this.errorQueue.push(e),this.errorQueue.length>this.maxQueueSize){const e=this.errorQueue.shift();console.warn("[Enhanced Error Handler] Queue full, removed oldest error:",null==e?void 0:e.error.message)}this.isOnline&&await this.flushErrorQueue()}catch(t){console.error("[Enhanced Error Handler] Failed to report error:",t)}}async flushErrorQueue(){var e,t,s,n;if(0===this.errorQueue.length)return;if(!this.circuitBreaker.canExecute())return void console.warn("[Enhanced Error Handler] Circuit breaker prevents error reporting");const r=[...this.errorQueue];this.errorQueue=[];for(let i=1;i<=this.retryAttempts;i++)try{const s=null==(t=null==(e=r[0])?void 0:e.context)?void 0:t.apiKey;if(!(await this.validateApiKeyBeforeRequest(s)))return console.warn("[Enhanced Error Handler] Invalid API key, skipping error report"),void this.circuitBreaker.onFailure();if(!this.rateLimiter.canMakeRequest())return console.warn("[Enhanced Error Handler] Rate limit exceeded during flush"),void this.errorQueue.unshift(...r);this.rateLimiter.recordRequest();const{api:n}=await Promise.resolve().then(()=>Dp);return await n.post("/errors/report",{errors:r,clientInfo:{userAgent:navigator.userAgent,timestamp:(new Date).toISOString(),url:window.location.href,circuitBreakerState:this.circuitBreaker.getState(),remainingRateLimit:this.rateLimiter.getRemainingRequests()}},{timeout:15e3}),console.log(`[Enhanced Error Handler] Successfully reported ${r.length} errors`),void this.circuitBreaker.onSuccess()}catch(a){if(console.warn(`[Enhanced Error Handler] Failed to send errors (attempt ${i}):`,a),401===(null==(s=a.response)?void 0:s.status)||403===(null==(n=a.response)?void 0:n.status))return console.error("[Enhanced Error Handler] Authentication error, stopping retries"),void this.circuitBreaker.onFailure();if(i===this.retryAttempts){this.circuitBreaker.onFailure();const e=r.filter(e=>"critical"===e.severity);e.length>0&&(this.errorQueue.unshift(...e),console.error(`[Enhanced Error Handler] Re-queued ${e.length} critical errors`)),console.error("[Enhanced Error Handler] All retry attempts failed")}else await new Promise(e=>setTimeout(e,this.retryDelay*Math.pow(2,i-1)))}}showUserNotification(e,t){const s=this.getUserFriendlyMessage(e);window.dispatchEvent(new CustomEvent("error:notification",{detail:{message:s,severity:t,error:e,timestamp:(new Date).toISOString(),canRetry:this.canRetryError(e)}}))}canRetryError(e){return 401!==e.status&&403!==e.status&&!(e.status>=400&&e.status<500&&429!==e.status)}getUserFriendlyMessage(e){switch(e.status){case 400:return"Please check your input and try again.";case 401:return"Invalid API key. Please check your credentials.";case 403:return"Access denied. Please check your API key permissions.";case 404:return"The requested resource was not found.";case 422:return"Please check your data and try again.";case 429:return"Too many requests. Please wait a moment and try again.";case 500:return"A server error occurred. Our team has been notified.";case 503:return"The service is temporarily unavailable. Please try again later.";default:return"NETWORK_ERROR"===e.code?"Network connection error. Please check your internet connection.":e.message||"An unexpected error occurred."}}enableReporting(){this.reportingEnabled=!0,console.log("[Enhanced Error Handler] Error reporting enabled")}disableReporting(){this.reportingEnabled=!1,console.log("[Enhanced Error Handler] Error reporting disabled")}getQueueSize(){return this.errorQueue.length}getCircuitBreakerState(){return this.circuitBreaker.getState()}getRemainingRateLimit(){return this.rateLimiter.getRemainingRequests()}clearQueue(){this.errorQueue=[],console.log("[Enhanced Error Handler] Error queue cleared")}async forceFlush(){await this.flushErrorQueue()}};const Tp=new class{formatResponse(e){return e&&"object"==typeof e&&"success"in e?e:{success:!0,data:e,message:"Request completed successfully",status:200,timestamp:(new Date).toISOString()}}formatPaginatedResponse(e,t){const s=t.totalPages||Math.ceil(t.total/t.limit);return{success:!0,data:e,pagination:{page:t.page,limit:t.limit,total:t.total,totalPages:s,hasNext:t.page<s,hasPrev:t.page>1},message:"Request completed successfully",status:200,timestamp:(new Date).toISOString()}}formatErrorResponse(e){return{success:!1,data:null,error:{message:e.message||"An error occurred",status:e.status||500,code:e.code,details:e.details,timestamp:(new Date).toISOString()},message:e.message||"Request failed",status:e.status||500,timestamp:(new Date).toISOString()}}transformResponseData(e){if(null==e)return e;if(Array.isArray(e))return e.map(e=>this.transformResponseData(e));if("object"==typeof e&&e.constructor===Object){const t={};for(const[s,n]of Object.entries(e)){t[this.toCamelCase(s)]=this.transformResponseData(n)}return t}return e}transformRequestData(e){if(null==e)return e;if(Array.isArray(e))return e.map(e=>this.transformRequestData(e));if("object"==typeof e&&e.constructor===Object){const t={};for(const[s,n]of Object.entries(e)){t[this.toSnakeCase(s)]=this.transformRequestData(n)}return t}return e}toCamelCase(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}toSnakeCase(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}validateResponse(e){return"object"==typeof e&&null!==e&&"boolean"==typeof e.success&&"data"in e&&"message"in e&&"timestamp"in e}validatePaginatedResponse(e){return this.validateResponse(e)&&"pagination"in e&&"object"==typeof e.pagination&&null!==e.pagination&&"page"in e.pagination&&"limit"in e.pagination&&"total"in e.pagination&&"number"==typeof e.pagination.page&&"number"==typeof e.pagination.limit&&"number"==typeof e.pagination.total}extractData(e){var t;if(!e.success)throw new Error((null==(t=e.error)?void 0:t.message)||"Request failed");return e.data}extractPaginatedData(e){var t;if(!e.success)throw new Error((null==(t=e.error)?void 0:t.message)||"Request failed");return{data:e.data,pagination:e.pagination}}mergeResponses(e){const t=e.filter(e=>e.success),s=e.filter(e=>!e.success);return s.length>0?{success:!1,data:null,status:400,error:{message:`${s.length} out of ${e.length} requests failed`,status:400,code:"BATCH_PARTIAL_FAILURE",details:{successful:t.length,failed:s.length,errors:s.map(e=>e.error)},timestamp:(new Date).toISOString()},message:"Batch operation partially failed",timestamp:(new Date).toISOString()}:{success:!0,data:t.map(e=>e.data),status:200,message:`All ${e.length} requests completed successfully`,timestamp:(new Date).toISOString()}}createResponseWithMetadata(e,t={}){return{...this.formatResponse(e),metadata:t}}formatFileUploadResponse(e,t){return this.formatResponse({filename:t.filename||e.name,originalName:e.name,size:e.size,mimeType:e.type,url:t.url,id:t.id})}formatSearchResponse(e,t,s){return{...this.formatPaginatedResponse(e,s),filters:t}}},Pp=e=>Tp.transformRequestData(e),Ap=e=>{var t;return(e=>Tp.validateResponse(e))(e.data)||(e.data=(t=e.data,Tp.formatResponse(t))),e},Rp=Wm.create({baseURL:"https://dev.backend.pangents.deepfrog.ai/",timeout:1e4,headers:{"Content-Type":"application/json",Accept:"application/json"}});Rp.interceptors.request.use(e=>{var t,s;e=(e=>(e.data&&(e.data=Pp(e.data)),e.params&&(e.params=Pp(e.params)),e))(e);const n=pp();n&&e.headers&&(e.headers.Authorization=`Bearer ${n}`);const r=Gt.getApiKey();return r&&e.headers&&(e.headers.api_key=r,e.headers.request_origin="tenant"),e.metadata={...e.metadata,requestTime:Date.now(),url:e.url,method:null==(t=e.method)?void 0:t.toUpperCase()},"development"===process.env.NODE_ENV&&console.log(`🚀 API Request: ${null==(s=e.method)?void 0:s.toUpperCase()} ${e.url}`,{headers:e.headers,data:e.data,params:e.params}),e}),Rp.interceptors.response.use(e=>{var t,s;const n=null==(t=(e=Ap(e)).config.metadata)?void 0:t.requestTime,r=n?Date.now()-n:0;return"development"===process.env.NODE_ENV&&console.log(`✅ API Response: ${null==(s=e.config.method)?void 0:s.toUpperCase()} ${e.config.url}`,{status:e.status,responseTime:`${r}ms`,data:e.data}),e.metadata={...e.config.metadata,responseTime:r,status:e.status,timestamp:(new Date).toISOString()},e},async e=>{var t,s,n,r,a,i,o,l,c,d,u,h;const m=e.config,p=null==(t=null==m?void 0:m.metadata)?void 0:t.requestTime,f=p?Date.now()-p:0;if("development"===process.env.NODE_ENV&&console.error(`❌ API Error: ${null==(s=null==m?void 0:m.method)?void 0:s.toUpperCase()} ${null==m?void 0:m.url}`,{status:null==(n=e.response)?void 0:n.status,responseTime:`${f}ms`,message:e.message,data:null==(r=e.response)?void 0:r.data}),401===(null==(a=e.response)?void 0:a.status)&&!m._retry){m._retry=!0;try{const e=await wp();if(e&&m.headers){m.headers.Authorization=`Bearer ${e}`;return(await Promise.resolve().then(()=>Dp)).default.request(m)}}catch(y){console.error("[Token Refresh Failed]",y),xp(),window.dispatchEvent(new CustomEvent("auth:logout",{detail:{reason:"token_refresh_failed"}}))}}const g=((e,t)=>Cp.handleApiError(e,t))(e,{component:"API",action:`${null==(i=null==m?void 0:m.method)?void 0:i.toUpperCase()} ${null==m?void 0:m.url}`});return 401!==(null==(o=e.response)?void 0:o.status)&&403!==(null==(l=e.response)?void 0:l.status)||!(null==(c=null==m?void 0:m.headers)?void 0:c.api_key)||(console.warn("[API Key Invalid] Clearing stored API key"),Gt.clearApiKey(),window.dispatchEvent(new CustomEvent("api:key_invalid",{detail:{error:g,url:null==m?void 0:m.url}}))),401===(null==(d=e.response)?void 0:d.status)?window.dispatchEvent(new CustomEvent("auth:unauthorized",{detail:{error:g,url:null==m?void 0:m.url}})):403===(null==(u=e.response)?void 0:u.status)?window.dispatchEvent(new CustomEvent("auth:forbidden",{detail:{error:g,url:null==m?void 0:m.url}})):(null==(h=e.response)?void 0:h.status)>=500?window.dispatchEvent(new CustomEvent("api:server_error",{detail:{error:g,url:null==m?void 0:m.url}})):e.response||window.dispatchEvent(new CustomEvent("api:network_error",{detail:{error:g,url:null==m?void 0:m.url}})),Promise.reject(g)});Rp.defaults.transformRequest=[e=>e&&"object"==typeof e?Object.keys(e).reduce((t,s)=>(t[s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)]=e[s],t),{}):e,...Wm.defaults.transformRequest],Rp.defaults.transformResponse=[e=>e&&"object"==typeof e?Object.keys(e).reduce((t,s)=>(t[s.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())]=e[s],t),{}):e,...Wm.defaults.transformResponse];const Mp={get:(e,t)=>Rp.get(e,t),post:(e,t,s)=>Rp.post(e,t,s),put:(e,t,s)=>Rp.put(e,t,s),patch:(e,t,s)=>Rp.patch(e,t,s),delete:(e,t)=>Rp.delete(e,t),updateProfile:async e=>(await Rp.patch("/profile",e)).data,initiateWorkflow:async e=>(await Rp.post("/workflow/initiate",e)).data,createCall:async e=>(await Rp.post("/calls",e)).data,updateCall:async(e,t)=>(await Rp.patch(`/calls/${e}`,t)).data,deleteCall:async e=>{await Rp.delete(`/calls/${e}`)},searchCarriers:async e=>(await Rp.get("/carriers/search",{params:e})).data,bulkUpdateCalls:async(e,t)=>(await Rp.patch("/calls/bulk",{ids:e,data:t})).data,getWorkflowList:async(e=1,t=10)=>(await Rp.get("/workflow/list",{params:{page:e,page_size:t}})).data.data,deleteWorkflow:async e=>(await Mp.delete(`/workflow/${e}`)).data,getWorkflowStatus:async e=>(await Mp.get(`/workflow/status/${e}`)).data.data,enqueueCallQueue:async e=>(await Mp.post("/agents/livekit/queue/enqueue",{queue:e})).data,getQueueStatus:async e=>(await Mp.get(`/agents/livekit/queue/${e}/status`)).data},Dp=Object.freeze(Object.defineProperty({__proto__:null,api:Mp,default:Rp},Symbol.toStringTag,{value:"Module"}));function $p(e){return{id:e.id,tenantId:e.tenant_id,createdBy:e.created_by,shipperEmail:e.shipper_email,shipperName:e.shipper_name,shipperCompanyName:e.shipper_company_name,origin:e.origin,destination:e.destination,pickupTimestamp:e.pickup_timestamp,deliveryTimestamp:e.delivery_timestamp,loadType:e.load_type,modeOfService:e.mode_of_service,equipmentType:e.equipment_type,grossWeight:e.gross_weight,numberOfPallets:e.number_of_pallets,emailMessageId:e.email_message_id,emailConversationId:e.email_conversation_id,emailSubject:e.email_subject,senderEmail:e.sender_email,senderName:e.sender_name,receiverEmail:e.receiver_email,receivedDatetime:e.received_datetime,status:e.status,isDuplicate:e.is_duplicate,duplicateOf:e.duplicate_of,notes:e.notes,createdAt:e.created_at,updatedAt:e.updated_at}}class Op{static async getLeads(e={}){var t,s,n;try{const t={};e.page&&(t.page=e.page),e.size&&(t.size=e.size),e.search&&(t.search=e.search),e.status&&(t.status=e.status),e.date_filter&&(t.date_filter=e.date_filter);const s=(await Mp.get("/crm/public/leads/me",{params:t})).data;return{success:s.success,leads:s.leads.map($p),count:s.count,page:s.page,size:s.size}}catch(r){if(console.error("EmailLeadsService.getLeads error:",r),401===(null==(t=r.response)?void 0:t.status))throw new Error("Unauthorized. Please login again.");if(null==(n=null==(s=r.response)?void 0:s.data)?void 0:n.detail)throw new Error(r.response.data.detail);throw new Error("Failed to fetch email leads. Please try again.")}}static async getLeadById(e){var t;try{return $p((await Mp.get(`/crm/public/leads/${e}`)).data.lead)}catch(s){if(console.error("EmailLeadsService.getLeadById error:",s),404===(null==(t=s.response)?void 0:t.status))throw new Error("Lead not found.");throw new Error("Failed to fetch lead details.")}}}function Fp(e){return{id:e.id,tenantId:e.tenant_id,createdBy:e.created_by,messageId:e.message_id,conversationId:e.conversation_id,conversationIndex:e.conversation_index,senderEmail:e.sender_email,receiverEmail:e.receiver_email,subject:e.subject,receivedDatetime:e.received_datetime,bodyHtml:e.body_html,bodyText:e.body_text,category:e.category,classificationConfidence:e.classification_confidence,status:e.status,userId:e.user_id,metadata:e.metadata,referencedLeadId:e.referenced_lead_id,processedAt:e.processed_at,createdAt:e.created_at,updatedAt:e.updated_at}}class zp{static async getLeadEmails(e){var t,s,n,r;try{const t=(await Mp.get(`/crm/public/leads/emails/${e}`)).data;return{success:t.success,emails:t.emails.map(Fp),count:t.count}}catch(a){if(console.error("EmailConversationService.getLeadEmails error:",a),401===(null==(t=a.response)?void 0:t.status))throw new Error("Unauthorized. Please login again.");if(404===(null==(s=a.response)?void 0:s.status))throw new Error("Lead emails not found.");if(null==(r=null==(n=a.response)?void 0:n.data)?void 0:r.detail)throw new Error(a.response.data.detail);throw new Error("Failed to fetch lead emails. Please try again.")}}static async sendEmailReply(e,t,s,n){var r,a,i;try{const r={to:e.map(e=>({email:e})),conversation_id:t,subject:s,body_html:n},a=(await Mp.post("/crm/agents/email/send",r)).data;return{success:a.success,reply:a.reply,email:Fp(a.email)}}catch(o){if(console.error("EmailConversationService.sendEmailReply error:",o),401===(null==(r=o.response)?void 0:r.status))throw new Error("Unauthorized. Please login again.");if(null==(i=null==(a=o.response)?void 0:a.data)?void 0:i.detail)throw new Error(o.response.data.detail);throw new Error("Failed to send email. Please try again.")}}}const Lp={leads:[],totalCount:0,currentPage:1,pageSize:10,isLoading:!1,isPolling:!1,error:null,searchQuery:"",statusFilter:"",dateFilter:"all",newLeadsCount:0,hasNewLeads:!1,lastFetchedLeadIds:new Set,showNewLeadsAlert:!1,pollingIntervalId:null,isPollingEnabled:!1},Ip=Iu()(_u((e,t)=>({...Lp,fetchLeads:async s=>{const n=t();e({isLoading:!0,error:null});try{const t={page:(null==s?void 0:s.page)??n.currentPage,size:(null==s?void 0:s.size)??n.pageSize,search:(null==s?void 0:s.search)??(n.searchQuery||void 0),status:(null==s?void 0:s.status)??(n.statusFilter||void 0),date_filter:(null==s?void 0:s.date_filter)??("all"!==n.dateFilter?n.dateFilter:void 0)},r=await Op.getLeads(t),a=new Set(r.leads.map(e=>e.id));e({leads:r.leads,totalCount:r.count,currentPage:r.page,isLoading:!1,lastFetchedLeadIds:a})}catch(r){e({isLoading:!1,error:r.message||"Failed to fetch leads"})}},setPage:s=>{e({currentPage:s}),t().fetchLeads({page:s})},setPageSize:s=>{e({pageSize:s,currentPage:1}),t().fetchLeads({size:s,page:1})},setSearchQuery:t=>{e({searchQuery:t,currentPage:1})},setStatusFilter:s=>{e({statusFilter:s,currentPage:1}),t().fetchLeads({status:s,page:1})},setDateFilter:s=>{e({dateFilter:s,currentPage:1}),t().fetchLeads({date_filter:"all"!==s?s:void 0,page:1})},startPolling:()=>{if(t().pollingIntervalId)return;console.log("[EmailLeadsStore] Starting polling...");const s=setInterval(()=>{t().pollForNewLeads()},6e4);e({pollingIntervalId:s,isPollingEnabled:!0})},stopPolling:()=>{const s=t();s.pollingIntervalId&&(console.log("[EmailLeadsStore] Stopping polling..."),clearInterval(s.pollingIntervalId),e({pollingIntervalId:null,isPollingEnabled:!1}))},pollForNewLeads:async()=>{const s=t();if(s.isPolling||s.isLoading)return;const n=s.lastFetchedLeadIds.size>0;e({isPolling:!0});try{console.log("[EmailLeadsStore] Polling for new leads...");const t=await Op.getLeads({page:1,size:s.pageSize,search:s.searchQuery||void 0,status:s.statusFilter||void 0,date_filter:"all"!==s.dateFilter?s.dateFilter:void 0}),r=t.leads.map(e=>e.id),a=s.lastFetchedLeadIds,i=r.filter(e=>!a.has(e));i.length>0&&n?(console.log(`[EmailLeadsStore] Found ${i.length} new leads!`),e({newLeadsCount:i.length,hasNewLeads:!0,showNewLeadsAlert:!0,leads:t.leads,totalCount:t.count,lastFetchedLeadIds:new Set(r),isPolling:!1})):e({lastFetchedLeadIds:new Set(r),isPolling:!1})}catch(r){console.error("[EmailLeadsStore] Polling error:",r),e({isPolling:!1})}},clearNewLeadsNotification:()=>{e({newLeadsCount:0,hasNewLeads:!1,showNewLeadsAlert:!1})},acknowledgeNewLeads:()=>{e({showNewLeadsAlert:!1})},reset:()=>{const s=t();s.pollingIntervalId&&clearInterval(s.pollingIntervalId),e({...Lp,lastFetchedLeadIds:new Set})}})));function _p({position:e="bottom-right",margin:t,zIndex:s}){const{openWidget:n,theme:r,isOpen:a,isAuthenticated:i}=ns(),{hasNewLeads:o,newLeadsCount:l,startPolling:c,stopPolling:d,clearNewLeadsNotification:u}=Ip();Oe.useEffect(()=>{if(i)return c(),()=>d()},[c,d,i]);return $e.jsx("div",{className:(()=>{switch(e){case"bottom-right":default:return"fixed bottom-6 right-6 z-50";case"bottom-left":return"fixed bottom-6 left-6 z-50";case"top-right":return"fixed top-6 right-6 z-50";case"top-left":return"fixed top-6 left-6 z-50"}})(),style:{margin:t||void 0,zIndex:s||void 0},children:$e.jsxs("div",{className:"relative",children:[$e.jsxs(Ou,{onClick:()=>{console.log("WidgetBubble: Button clicked!"),n(),o&&u()},size:"lg",className:"widget-bubble-button h-16 w-16 rounded-full shadow-lg hover:shadow-xl transition-shadow duration-200 bg-pangents-gradient",style:{backgroundColor:r.primaryColor,fontFamily:r.fontFamily},children:[r.bubbleIcon?$e.jsx("img",{src:r.bubbleIcon,alt:"Chat icon",className:"h-16 w-16 object-contain"}):$e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 47 47",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",children:[$e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M23.5058 3.63059e-06C12.2974 -0.00618902 2.64601 7.91029 0.455364 18.9069C-1.73528 29.9035 4.14513 40.9165 14.4996 45.2094V23.0524L17.8315 18.762V46.3055C19.6877 46.767 21.5932 47.0002 23.5058 47C24.0838 47.0001 24.6543 46.9725 25.221 46.9307V14.4716L28.553 18.762V46.4539C30.5249 46.0214 32.4323 45.3345 34.2273 44.4105V8.89938L37.5593 13.1898V42.3372C45.6702 36.2805 48.9913 25.7075 45.8012 16.0983C42.6111 6.48908 33.6272 0.00428384 23.5059 0.00510346L23.5058 3.63059e-06Z",fill:"url(#paint0_linear_192_413)"}),$e.jsx("defs",{children:$e.jsxs("linearGradient",{id:"paint0_linear_192_413",x1:"-18.3065",y1:"-10.34",x2:"-17.2725",y2:"72.427",gradientUnits:"userSpaceOnUse",children:[$e.jsx("stop",{stopColor:"white"}),$e.jsx("stop",{offset:"0.6",stopColor:"white",stopOpacity:"0.968627"}),$e.jsx("stop",{offset:"1",stopColor:"white",stopOpacity:"0.101961"})]})})]}),$e.jsx("span",{className:"sr-only",children:"Open chat"})]}),o&&!a&&$e.jsx(pd.div,{initial:{scale:0},animate:{scale:1},className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs font-bold min-w-[20px] h-5 px-1.5 rounded-full flex items-center justify-center shadow-lg",children:l>99?"99+":l})]})})}
|
|
10
10
|
/**
|
|
11
11
|
* @license lucide-react v0.511.0 - ISC
|
|
12
12
|
*
|
|
@@ -42,5 +42,5 @@ var Up={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
|
|
|
42
42
|
*
|
|
43
43
|
* @license MIT
|
|
44
44
|
*/
|
|
45
|
-
function Wf(e={}){let t,{initialEntries:s=["/"],initialIndex:n,v5Compat:r=!1}=e;t=s.map((e,t)=>d(e,"string"==typeof e?null:e.state,0===t?"default":void 0));let a=l(null==n?t.length-1:n),i="POP",o=null;function l(e){return Math.min(Math.max(e,0),t.length-1)}function c(){return t[a]}function d(e,s=null,n){let r=function(e,t,s=null,n){let r={pathname:"string"==typeof e?e:e.pathname,search:"",hash:"",..."string"==typeof t?Gf(t):t,state:s,key:t&&t.key||n||Yf()};return r}(t?c().pathname:"/",e,s,n);return Kf("/"===r.pathname.charAt(0),`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function u(e){return"string"==typeof e?e:Qf(e)}return{get index(){return a},get action(){return i},get location(){return c()},createHref:u,createURL:e=>new URL(u(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?Gf(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(e,s){i="PUSH";let n=d(e,s);a+=1,t.splice(a,t.length,n),r&&o&&o({action:i,location:n,delta:1})},replace(e,s){i="REPLACE";let n=d(e,s);t[a]=n,r&&o&&o({action:i,location:n,delta:0})},go(e){i="POP";let s=l(a+e),n=t[s];a=s,o&&o({action:i,location:n,delta:e})},listen:e=>(o=e,()=>{o=null})}}function Hf(e,t){if(!1===e||null==e)throw new Error(t)}function Kf(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(s){}}}function Yf(){return Math.random().toString(36).substring(2,10)}function Qf({pathname:e="/",search:t="",hash:s=""}){return t&&"?"!==t&&(e+="?"===t.charAt(0)?t:"?"+t),s&&"#"!==s&&(e+="#"===s.charAt(0)?s:"#"+s),e}function Gf(e){let t={};if(e){let s=e.indexOf("#");s>=0&&(t.hash=e.substring(s),e=e.substring(0,s));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function Jf(e,t,s="/"){return function(e,t,s,n){let r="string"==typeof t?Gf(t):t,a=ug(r.pathname||"/",s);if(null==a)return null;let i=Xf(e);!function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let s=e.length===t.length&&e.slice(0,-1).every((e,s)=>e===t[s]);return s?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(i);let o=null;for(let l=0;null==o&&l<i.length;++l){let e=dg(a);o=lg(i[l],e,n)}return o}(e,t,s,!1)}function Xf(e,t=[],s=[],n="",r=!1){let a=(e,a,i=r,o)=>{let l={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};if(l.relativePath.startsWith("/")){if(!l.relativePath.startsWith(n)&&i)return;Hf(l.relativePath.startsWith(n),`Absolute route path "${l.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(n.length)}let c=fg([n,l.relativePath]),d=s.concat(l);e.children&&e.children.length>0&&(Hf(!0!==e.index,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Xf(e.children,t,d,c,i)),(null!=e.path||e.index)&&t.push({path:c,score:og(c,e.index),routesMeta:d})};return e.forEach((e,t)=>{var s;if(""!==e.path&&(null==(s=e.path)?void 0:s.includes("?")))for(let n of Zf(e.path))a(e,t,!0,n);else a(e,t)}),t}function Zf(e){let t=e.split("/");if(0===t.length)return[];let[s,...n]=t,r=s.endsWith("?"),a=s.replace(/\?$/,"");if(0===n.length)return r?[a,""]:[a];let i=Zf(n.join("/")),o=[];return o.push(...i.map(e=>""===e?a:[a,e].join("/"))),r&&o.push(...i),o.map(t=>e.startsWith("/")&&""===t?"/":t)}var eg=/^:[\w-]+$/,tg=3,sg=2,ng=1,rg=10,ag=-2,ig=e=>"*"===e;function og(e,t){let s=e.split("/"),n=s.length;return s.some(ig)&&(n+=ag),t&&(n+=sg),s.filter(e=>!ig(e)).reduce((e,t)=>e+(eg.test(t)?tg:""===t?ng:rg),n)}function lg(e,t,s=!1){let{routesMeta:n}=e,r={},a="/",i=[];for(let o=0;o<n.length;++o){let e=n[o],l=o===n.length-1,c="/"===a?t:t.slice(a.length)||"/",d=cg({path:e.relativePath,caseSensitive:e.caseSensitive,end:l},c),u=e.route;if(!d&&l&&s&&!n[n.length-1].route.index&&(d=cg({path:e.relativePath,caseSensitive:e.caseSensitive,end:!1},c)),!d)return null;Object.assign(r,d.params),i.push({params:r,pathname:fg([a,d.pathname]),pathnameBase:gg(fg([a,d.pathnameBase])),route:u}),"/"!==d.pathnameBase&&(a=fg([a,d.pathnameBase]))}return i}function cg(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[s,n]=function(e,t=!1,s=!0){Kf("*"===e||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,s)=>(n.push({paramName:t,isOptional:null!=s}),s?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");e.endsWith("*")?(n.push({paramName:"*"}),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?r+="\\/*$":""!==e&&"/"!==e&&(r+="(?:(?=\\/|$))");let a=new RegExp(r,t?void 0:"i");return[a,n]}(e.path,e.caseSensitive,e.end),r=t.match(s);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:n.reduce((e,{paramName:t,isOptional:s},n)=>{if("*"===t){let e=o[n]||"";i=a.slice(0,a.length-e.length).replace(/(.)\/+$/,"$1")}const r=o[n];return e[t]=s&&!r?void 0:(r||"").replace(/%2F/g,"/"),e},{}),pathname:a,pathnameBase:i,pattern:e}}function dg(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return Kf(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ug(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let s=t.endsWith("/")?t.length-1:t.length,n=e.charAt(s);return n&&"/"!==n?null:e.slice(s)||"/"}function hg(e,t,s,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function mg(e){let t=function(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}(e);return t.map((e,s)=>s===t.length-1?e.pathname:e.pathnameBase)}function pg(e,t,s,n=!1){let r;"string"==typeof e?r=Gf(e):(r={...e},Hf(!r.pathname||!r.pathname.includes("?"),hg("?","pathname","search",r)),Hf(!r.pathname||!r.pathname.includes("#"),hg("#","pathname","hash",r)),Hf(!r.search||!r.search.includes("#"),hg("#","search","hash",r)));let a,i=""===e||""===r.pathname,o=i?"/":r.pathname;if(null==o)a=s;else{let e=t.length-1;if(!n&&o.startsWith("..")){let t=o.split("/");for(;".."===t[0];)t.shift(),e-=1;r.pathname=t.join("/")}a=e>=0?t[e]:"/"}let l=function(e,t="/"){let{pathname:s,search:n="",hash:r=""}="string"==typeof e?Gf(e):e,a=s?s.startsWith("/")?s:function(e,t){let s=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?s.length>1&&s.pop():"."!==e&&s.push(e)}),s.length>1?s.join("/"):"/"}(s,t):t;return{pathname:a,search:yg(n),hash:xg(r)}}(r,a),c=o&&"/"!==o&&o.endsWith("/"),d=(i||"."===o)&&s.endsWith("/");return l.pathname.endsWith("/")||!c&&!d||(l.pathname+="/"),l}var fg=e=>e.join("/").replace(/\/\/+/g,"/"),gg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),yg=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",xg=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var vg=["POST","PUT","PATCH","DELETE"];new Set(vg);var bg=["GET",...vg];new Set(bg);var wg=Le.createContext(null);wg.displayName="DataRouter";var Sg=Le.createContext(null);Sg.displayName="DataRouterState",Le.createContext(!1);var jg=Le.createContext({isTransitioning:!1});jg.displayName="ViewTransition",Le.createContext(new Map).displayName="Fetchers",Le.createContext(null).displayName="Await";var kg=Le.createContext(null);kg.displayName="Navigation";var Ng=Le.createContext(null);Ng.displayName="Location";var Eg=Le.createContext({outlet:null,matches:[],isDataRoute:!1});Eg.displayName="Route";var Cg=Le.createContext(null);function Tg(){return null!=Le.useContext(Ng)}function Pg(){return Hf(Tg(),"useLocation() may be used only in the context of a <Router> component."),Le.useContext(Ng).location}Cg.displayName="RouteError";var Ag="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Rg(e){Le.useContext(kg).static||Le.useLayoutEffect(e)}function Mg(){let{isDataRoute:e}=Le.useContext(Eg);return e?function(){let{router:e}=function(e){let t=Le.useContext(wg);return Hf(t,_g(e)),t}("useNavigate"),t=Vg("useNavigate"),s=Le.useRef(!1);return Rg(()=>{s.current=!0}),Le.useCallback(async(n,r={})=>{Kf(s.current,Ag),s.current&&("number"==typeof n?e.navigate(n):await e.navigate(n,{fromRouteId:t,...r}))},[e,t])}():function(){Hf(Tg(),"useNavigate() may be used only in the context of a <Router> component.");let e=Le.useContext(wg),{basename:t,navigator:s}=Le.useContext(kg),{matches:n}=Le.useContext(Eg),{pathname:r}=Pg(),a=JSON.stringify(mg(n)),i=Le.useRef(!1);return Rg(()=>{i.current=!0}),Le.useCallback((n,o={})=>{if(Kf(i.current,Ag),!i.current)return;if("number"==typeof n)return void s.go(n);let l=pg(n,JSON.parse(a),r,"path"===o.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:fg([t,l.pathname])),(o.replace?s.replace:s.push)(l,o.state,o)},[t,s,a,r,e])}()}function Dg(){let{matches:e}=Le.useContext(Eg),t=e[e.length-1];return t?t.params:{}}function $g(e,{relative:t}={}){let{matches:s}=Le.useContext(Eg),{pathname:n}=Pg(),r=JSON.stringify(mg(s));return Le.useMemo(()=>pg(e,JSON.parse(r),n,"path"===t),[e,r,n,t])}function Og(e,t,s,n,r){var a;Hf(Tg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=Le.useContext(kg),{matches:o}=Le.useContext(Eg),l=o[o.length-1],c=l?l.params:{},d=l?l.pathname:"/",u=l?l.pathnameBase:"/",h=l&&l.route;{let e=h&&h.path||"";qg(d,!h||e.endsWith("*")||e.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.\n\nPlease change the parent <Route path="${e}"> to <Route path="${"/"===e?"*":`${e}/*`}">.`)}let m,p=Pg();if(t){let e="string"==typeof t?Gf(t):t;Hf("/"===u||(null==(a=e.pathname)?void 0:a.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),m=e}else m=p;let f=m.pathname||"/",g=f;if("/"!==u){let e=u.replace(/^\//,"").split("/");g="/"+f.replace(/^\//,"").split("/").slice(e.length).join("/")}let y=Jf(e,{pathname:g});Kf(h||null!=y,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Kf(null==y||void 0!==y[y.length-1].route.element||void 0!==y[y.length-1].route.Component||void 0!==y[y.length-1].route.lazy,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=function(e,t=[],s=null,n=null){if(null==e){if(!s)return null;if(s.errors)e=s.matches;else{if(0!==t.length||s.initialized||!(s.matches.length>0))return null;e=s.matches}}let r=e,a=null==s?void 0:s.errors;if(null!=a){let e=r.findIndex(e=>e.route.id&&void 0!==(null==a?void 0:a[e.route.id]));Hf(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),r=r.slice(0,Math.min(r.length,e+1))}let i=!1,o=-1;if(s)for(let l=0;l<r.length;l++){let e=r[l];if((e.route.HydrateFallback||e.route.hydrateFallbackElement)&&(o=l),e.route.id){let{loaderData:t,errors:n}=s,a=e.route.loader&&!t.hasOwnProperty(e.route.id)&&(!n||void 0===n[e.route.id]);if(e.route.lazy||a){i=!0,r=o>=0?r.slice(0,o+1):[r[0]];break}}}return r.reduceRight((e,l,c)=>{let d,u=!1,h=null,m=null;s&&(d=a&&l.route.id?a[l.route.id]:void 0,h=l.route.errorElement||zg,i&&(o<0&&0===c?(qg("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),u=!0,m=null):o===c&&(u=!0,m=l.route.hydrateFallbackElement||null)));let p=t.concat(r.slice(0,c+1)),f=()=>{let t;return t=d?h:u?m:l.route.Component?Le.createElement(l.route.Component,null):l.route.element?l.route.element:e,Le.createElement(Ig,{match:l,routeContext:{outlet:e,matches:p,isDataRoute:null!=s},children:t})};return s&&(l.route.ErrorBoundary||l.route.errorElement||0===c)?Le.createElement(Lg,{location:s.location,revalidation:s.revalidation,component:h,error:d,children:f(),routeContext:{outlet:null,matches:p,isDataRoute:!0},unstable_onError:n}):f()},null)}(y&&y.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:fg([u,i.encodeLocation?i.encodeLocation(e.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?u:fg([u,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),o,s,n,r);return t&&x?Le.createElement(Ng.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function Fg(){let e=function(){var e;let t=Le.useContext(Cg),s=function(e){let t=Le.useContext(Sg);return Hf(t,_g(e)),t}("useRouteError"),n=Vg("useRouteError");if(void 0!==t)return t;return null==(e=s.errors)?void 0:e[n]}(),t=function(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Le.createElement(Le.Fragment,null,Le.createElement("p",null,"💿 Hey developer 👋"),Le.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Le.createElement("code",{style:a},"ErrorBoundary")," or"," ",Le.createElement("code",{style:a},"errorElement")," prop on your route.")),Le.createElement(Le.Fragment,null,Le.createElement("h2",null,"Unexpected Application Error!"),Le.createElement("h3",{style:{fontStyle:"italic"}},t),s?Le.createElement("pre",{style:r},s):null,i)}Le.createContext(null);var zg=Le.createElement(Fg,null),Lg=class extends Le.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return void 0!==this.state.error?Le.createElement(Eg.Provider,{value:this.props.routeContext},Le.createElement(Cg.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ig({routeContext:e,match:t,children:s}){let n=Le.useContext(wg);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),Le.createElement(Eg.Provider,{value:e},s)}function _g(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Vg(e){let t=function(e){let t=Le.useContext(Eg);return Hf(t,_g(e)),t}(e),s=t.matches[t.matches.length-1];return Hf(s.route.id,`${e} can only be used on routes that contain a unique "id"`),s.route.id}var Bg={};function qg(e,t,s){t||Bg[e]||(Bg[e]=!0,Kf(!1,s))}function Ug({basename:e,children:t,initialEntries:s,initialIndex:n}){let r=Le.useRef();null==r.current&&(r.current=Wf({initialEntries:s,initialIndex:n,v5Compat:!0}));let a=r.current,[i,o]=Le.useState({action:a.action,location:a.location}),l=Le.useCallback(e=>{Le.startTransition(()=>o(e))},[o]);return Le.useLayoutEffect(()=>a.listen(l),[a,l]),Le.createElement(Kg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a})}function Wg({to:e,replace:t,state:s,relative:n}){Hf(Tg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=Le.useContext(kg);Kf(!r,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=Le.useContext(Eg),{pathname:i}=Pg(),o=Mg(),l=pg(e,mg(a),i,"path"===n),c=JSON.stringify(l);return Le.useEffect(()=>{o(JSON.parse(c),{replace:t,state:s,relative:n})},[o,c,n,t,s]),null}function Hg(e){Hf(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Kg({basename:e="/",children:t=null,location:s,navigationType:n="POP",navigator:r,static:a=!1}){Hf(!Tg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),o=Le.useMemo(()=>({basename:i,navigator:r,static:a,future:{}}),[i,r,a]);"string"==typeof s&&(s=Gf(s));let{pathname:l="/",search:c="",hash:d="",state:u=null,key:h="default"}=s,m=Le.useMemo(()=>{let e=ug(l,i);return null==e?null:{location:{pathname:e,search:c,hash:d,state:u,key:h},navigationType:n}},[i,l,c,d,u,h,n]);return Kf(null!=m,`<Router basename="${i}"> is not able to match the URL "${l}${c}${d}" because it does not start with the basename, so the <Router> won't render anything.`),null==m?null:Le.createElement(kg.Provider,{value:o},Le.createElement(Ng.Provider,{children:t,value:m}))}function Yg({children:e,location:t}){return Og(Qg(e),t)}function Qg(e,t=[]){let s=[];return Le.Children.forEach(e,(e,n)=>{if(!Le.isValidElement(e))return;let r=[...t,n];if(e.type===Le.Fragment)return void s.push.apply(s,Qg(e.props.children,r));Hf(e.type===Hg,`[${"string"==typeof e.type?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Hf(!e.props.index||!e.props.children,"An index route cannot have child routes.");let a={id:e.props.id||r.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:!0===e.props.hasErrorBoundary||null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Qg(e.props.children,r)),s.push(a)}),s}Le.memo(function({routes:e,future:t,state:s,unstable_onError:n}){return Og(e,void 0,s,n,t)});var Gg="get",Jg="application/x-www-form-urlencoded";function Xg(e){return null!=e&&"string"==typeof e.tagName}var Zg=null;var ey=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ty(e){return null==e||ey.has(e)?e:(Kf(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Jg}"`),null)}function sy(e,t){let s,n,r,a,i;if(Xg(o=e)&&"form"===o.tagName.toLowerCase()){let i=e.getAttribute("action");n=i?ug(i,t):null,s=e.getAttribute("method")||Gg,r=ty(e.getAttribute("enctype"))||Jg,a=new FormData(e)}else if(function(e){return Xg(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Xg(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let o=e.getAttribute("formaction")||i.getAttribute("action");if(n=o?ug(o,t):null,s=e.getAttribute("formmethod")||i.getAttribute("method")||Gg,r=ty(e.getAttribute("formenctype"))||ty(i.getAttribute("enctype"))||Jg,a=new FormData(i,e),!function(){if(null===Zg)try{new FormData(document.createElement("form"),0),Zg=!1}catch(e){Zg=!0}return Zg}()){let{name:t,type:s,value:n}=e;if("image"===s){let e=t?`${t}.`:"";a.append(`${e}x`,"0"),a.append(`${e}y`,"0")}else t&&a.append(t,n)}}else{if(Xg(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Gg,n=null,r=Jg,i=e}var o;return a&&"text/plain"===r&&(i=a,a=void 0),{action:n,method:s.toLowerCase(),encType:r,formData:a,body:i}}function ny(e,t){if(!1===e||null==e)throw new Error(t)}function ry(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"==typeof e.imageSrcSet&&"string"==typeof e.imageSizes:"string"==typeof e.rel&&"string"==typeof e.href)}async function ay(e,t,s){return function(e,t){let s=new Set;return new Set(t),e.reduce((e,t)=>{let n=JSON.stringify(function(e){let t={},s=Object.keys(e).sort();for(let n of s)t[n]=e[n];return t}(t));return s.has(n)||(s.add(n),e.push({key:n,link:t})),e},[])}((await Promise.all(e.map(async e=>{let n=t.routes[e.route.id];if(n){let e=await async function(e,t){if(e.id in t)return t[e.id];try{let s=await import(e.module);return t[e.id]=s,s}catch(s){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}(n,s);return e.links?e.links():[]}return[]}))).flat(1).filter(ry).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?{...e,rel:"prefetch",as:"style"}:{...e,rel:"prefetch"}))}function iy(e,t,s,n,r,a){let i=(e,t)=>!s[t]||e.route.id!==s[t].route.id,o=(e,t)=>{var n;return s[t].pathname!==e.pathname||(null==(n=s[t].route.path)?void 0:n.endsWith("*"))&&s[t].params["*"]!==e.params["*"]};return"assets"===a?t.filter((e,t)=>i(e,t)||o(e,t)):"data"===a?t.filter((t,a)=>{var l;let c=n.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(i(t,a)||o(t,a))return!0;if(t.route.shouldRevalidate){let n=t.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:(null==(l=s[0])?void 0:l.params)||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"==typeof n)return n}return!0}):[]}function oy(e,t,{includeHydrateFallback:s}={}){return n=e.map(e=>{let n=t.routes[e.route.id];if(!n)return[];let r=[n.module];return n.clientActionModule&&(r=r.concat(n.clientActionModule)),n.clientLoaderModule&&(r=r.concat(n.clientLoaderModule)),s&&n.hydrateFallbackModule&&(r=r.concat(n.hydrateFallbackModule)),n.imports&&(r=r.concat(n.imports)),r}).flat(1),[...new Set(n)];var n}function ly(){let e=Le.useContext(wg);return ny(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var cy=Le.createContext(void 0);function dy(){let e=Le.useContext(cy);return ny(e,"You must render this element inside a <HydratedRouter> element"),e}function uy(e,t){return s=>{e&&e(s),s.defaultPrevented||t(s)}}function hy({page:e,...t}){let{router:s}=ly(),n=Le.useMemo(()=>Jf(s.routes,e,s.basename),[s.routes,e,s.basename]);return n?Le.createElement(my,{page:e,matches:n,...t}):null}function my({page:e,matches:t,...s}){let n=Pg(),{manifest:r,routeModules:a}=dy(),{basename:i}=ly(),{loaderData:o,matches:l}=function(){let e=Le.useContext(Sg);return ny(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}(),c=Le.useMemo(()=>iy(e,t,l,r,n,"data"),[e,t,l,r,n]),d=Le.useMemo(()=>iy(e,t,l,r,n,"assets"),[e,t,l,r,n]),u=Le.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let s=new Set,l=!1;if(t.forEach(e=>{var t;let n=r.routes[e.route.id];n&&n.hasLoader&&(!c.some(t=>t.route.id===e.route.id)&&e.route.id in o&&(null==(t=a[e.route.id])?void 0:t.shouldRevalidate)||n.hasClientLoader?l=!0:s.add(e.route.id))}),0===s.size)return[];let d=function(e,t,s){let n="string"==typeof e?new URL(e,"undefined"==typeof window?"server://singlefetch/":window.location.origin):e;return"/"===n.pathname?n.pathname=`_root.${s}`:t&&"/"===ug(n.pathname,t)?n.pathname=`${t.replace(/\/$/,"")}/_root.${s}`:n.pathname=`${n.pathname.replace(/\/$/,"")}.${s}`,n}(e,i,"data");return l&&s.size>0&&d.searchParams.set("_routes",t.filter(e=>s.has(e.route.id)).map(e=>e.route.id).join(",")),[d.pathname+d.search]},[i,o,n,r,c,t,e,a]),h=Le.useMemo(()=>oy(d,r),[d,r]),m=function(e){let{manifest:t,routeModules:s}=dy(),[n,r]=Le.useState([]);return Le.useEffect(()=>{let n=!1;return ay(e,t,s).then(e=>{n||r(e)}),()=>{n=!0}},[e,t,s]),n}(d);return Le.createElement(Le.Fragment,null,u.map(e=>Le.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...s})),h.map(e=>Le.createElement("link",{key:e,rel:"modulepreload",href:e,...s})),m.map(({key:e,link:t})=>Le.createElement("link",{key:e,nonce:s.nonce,...t})))}function py(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}cy.displayName="FrameworkContext";var fy="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;try{fy&&(window.__reactRouterVersion="7.9.4")}catch(Fv){}var gy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yy=Le.forwardRef(function({onClick:e,discover:t="render",prefetch:s="none",relative:n,reloadDocument:r,replace:a,state:i,target:o,to:l,preventScrollReset:c,viewTransition:d,...u},h){let m,{basename:p}=Le.useContext(kg),f="string"==typeof l&&gy.test(l),g=!1;if("string"==typeof l&&f&&(m=l,fy))try{let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l),s=ug(t.pathname,p);t.origin===e.origin&&null!=s?l=s+t.search+t.hash:g=!0}catch(Fv){Kf(!1,`<Link to="${l}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let y=function(e,{relative:t}={}){Hf(Tg(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:n}=Le.useContext(kg),{hash:r,pathname:a,search:i}=$g(e,{relative:t}),o=a;return"/"!==s&&(o="/"===a?s:fg([s,a])),n.createHref({pathname:o,search:i,hash:r})}(l,{relative:n}),[x,v,b]=function(e,t){let s=Le.useContext(cy),[n,r]=Le.useState(!1),[a,i]=Le.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:u}=t,h=Le.useRef(null);Le.useEffect(()=>{if("render"===e&&i(!0),"viewport"===e){let e=new IntersectionObserver(e=>{e.forEach(e=>{i(e.isIntersecting)})},{threshold:.5});return h.current&&e.observe(h.current),()=>{e.disconnect()}}},[e]),Le.useEffect(()=>{if(n){let e=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(e)}}},[n]);let m=()=>{r(!0)},p=()=>{r(!1),i(!1)};return s?"intent"!==e?[a,h,{}]:[a,h,{onFocus:uy(o,m),onBlur:uy(l,p),onMouseEnter:uy(c,m),onMouseLeave:uy(d,p),onTouchStart:uy(u,m)}]:[!1,h,{}]}(s,u),w=function(e,{target:t,replace:s,state:n,preventScrollReset:r,relative:a,viewTransition:i}={}){let o=Mg(),l=Pg(),c=$g(e,{relative:a});return Le.useCallback(d=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(d,t)){d.preventDefault();let t=void 0!==s?s:Qf(l)===Qf(c);o(e,{replace:t,state:n,preventScrollReset:r,relative:a,viewTransition:i})}},[l,o,c,s,n,t,e,r,a,i])}(l,{replace:a,state:i,target:o,preventScrollReset:c,relative:n,viewTransition:d});let S=Le.createElement("a",{...u,...b,href:m||y,onClick:g||r?e:function(t){e&&e(t),t.defaultPrevented||w(t)},ref:py(h,v),target:o,"data-discover":f||"render"!==t?void 0:"true"});return x&&!f?Le.createElement(Le.Fragment,null,S,Le.createElement(hy,{page:y})):S});function xy(e){let t=Le.useContext(wg);return Hf(t,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(e)),t}yy.displayName="Link",Le.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:s="",end:n=!1,style:r,to:a,viewTransition:i,children:o,...l},c){let d=$g(a,{relative:l.relative}),u=Pg(),h=Le.useContext(Sg),{navigator:m,basename:p}=Le.useContext(kg),f=null!=h&&function(e,{relative:t}={}){let s=Le.useContext(jg);Hf(null!=s,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=xy("useViewTransitionState"),r=$g(e,{relative:t});if(!s.isTransitioning)return!1;let a=ug(s.currentLocation.pathname,n)||s.currentLocation.pathname,i=ug(s.nextLocation.pathname,n)||s.nextLocation.pathname;return null!=cg(r.pathname,i)||null!=cg(r.pathname,a)}(d)&&!0===i,g=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,y=u.pathname,x=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;t||(y=y.toLowerCase(),x=x?x.toLowerCase():null,g=g.toLowerCase()),x&&p&&(x=ug(x,p)||x);const v="/"!==g&&g.endsWith("/")?g.length-1:g.length;let b,w=y===g||!n&&y.startsWith(g)&&"/"===y.charAt(v),S=null!=x&&(x===g||!n&&x.startsWith(g)&&"/"===x.charAt(g.length)),j={isActive:w,isPending:S,isTransitioning:f},k=w?e:void 0;b="function"==typeof s?s(j):[s,w?"active":null,S?"pending":null,f?"transitioning":null].filter(Boolean).join(" ");let N="function"==typeof r?r(j):r;return Le.createElement(yy,{...l,"aria-current":k,className:b,ref:c,style:N,to:a,viewTransition:i},"function"==typeof o?o(j):o)}).displayName="NavLink",Le.forwardRef(({discover:e="render",fetcherKey:t,navigate:s,reloadDocument:n,replace:r,state:a,method:i=Gg,action:o,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:u,...h},m)=>{let p=function(){let{router:e}=xy("useSubmit"),{basename:t}=Le.useContext(kg),s=Vg("useRouteId");return Le.useCallback(async(n,r={})=>{let{action:a,method:i,encType:o,formData:l,body:c}=sy(n,t);if(!1===r.navigate){let t=r.fetcherKey||by();await e.fetch(t,s,r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||i,formEncType:r.encType||o,flushSync:r.flushSync})}else await e.navigate(r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||i,formEncType:r.encType||o,replace:r.replace,state:r.state,fromRouteId:s,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,t,s])}(),f=function(e,{relative:t}={}){let{basename:s}=Le.useContext(kg),n=Le.useContext(Eg);Hf(n,"useFormAction must be used inside a RouteContext");let[r]=n.matches.slice(-1),a={...$g(e||".",{relative:t})},i=Pg();if(null==e){a.search=i.search;let e=new URLSearchParams(a.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let s=e.toString();a.search=s?`?${s}`:""}}e&&"."!==e||!r.route.index||(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index");"/"!==s&&(a.pathname="/"===a.pathname?s:fg([s,a.pathname]));return Qf(a)}(o,{relative:c}),g="get"===i.toLowerCase()?"get":"post",y="string"==typeof o&&gy.test(o);return Le.createElement("form",{ref:m,method:g,action:f,onSubmit:n?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,o=(null==n?void 0:n.getAttribute("formmethod"))||i;p(n||e.currentTarget,{fetcherKey:t,method:o,navigate:s,replace:r,state:a,relative:c,preventScrollReset:d,viewTransition:u})},...h,"data-discover":y||"render"!==e?void 0:"true"})}).displayName="Form";var vy=0,by=()=>`__${String(++vy)}__`;function wy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const Sy=Array(12).fill(0),jy=({visible:e,className:t})=>Oe.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},Oe.createElement("div",{className:"sonner-spinner"},Sy.map((e,t)=>Oe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),ky=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ny=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ey=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Cy=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ty=Oe.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"},Oe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Oe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let Py=1;const Ay=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:s,...n}=e,r="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:Py++,a=this.toasts.find(e=>e.id===r),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),a?this.toasts=this.toasts.map(t=>t.id===r?(this.publish({...t,...e,id:r,title:s}),{...t,...e,id:r,dismissible:i,title:s}):t):this.addToast({title:s,...n,dismissible:i,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;void 0!==t.loading&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const n=Promise.resolve(e instanceof Function?e():e);let r,a=void 0!==s;const i=n.then(async e=>{r=["resolve",e];if(Oe.isValidElement(e))a=!1,this.create({id:s,type:"default",message:e});else if(Ry(e)&&!e.ok){a=!1;const n="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,r="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}else if(e instanceof Error){a=!1;const n="function"==typeof t.error?await t.error(e):t.error,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}else if(void 0!==t.success){a=!1;const n="function"==typeof t.success?await t.success(e):t.success,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"success",description:r,...i})}}).catch(async e=>{if(r=["reject",e],void 0!==t.error){a=!1;const n="function"==typeof t.error?await t.error(e):t.error,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),null==t.finally||t.finally.call(t)}),o=()=>new Promise((e,t)=>i.then(()=>"reject"===r[0]?t(r[1]):e(r[1])).catch(t));return"string"!=typeof s&&"number"!=typeof s?{unwrap:o}:Object.assign(s,{unwrap:o})},this.custom=(e,t)=>{const s=(null==t?void 0:t.id)||Py++;return this.create({jsx:e(s),id:s,...t}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ry=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,My=(e,t)=>{const s=(null==t?void 0:t.id)||Py++;return Ay.addToast({title:e,...t,id:s}),s},Dy=Object.assign(My,{success:Ay.success,info:Ay.info,warning:Ay.warning,error:Ay.error,custom:Ay.custom,message:Ay.message,promise:Ay.promise,dismiss:Ay.dismiss,loading:Ay.loading},{getHistory:()=>Ay.toasts,getToasts:()=>Ay.getActiveToasts()});function $y(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[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%)}[data-sonner-toaster][dir=rtl],html[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%)}[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:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[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);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[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 rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [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)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [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;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [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);background:var(--normal-bg);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-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[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}[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}[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,0)) translateX(var(--swipe-amount-x,0));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{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{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{from{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-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--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-sonner-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-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-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, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--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-sonner-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-sonner-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]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[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]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[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]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[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]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[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:first-child{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)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{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%)}");const Oy=3,Fy=14;function zy(...e){return e.filter(Boolean).join(" ")}const Ly=e=>{var t,s,n,r,a,i,o,l,c;const{invert:d,toast:u,unstyled:h,interacting:m,setHeights:p,visibleToasts:f,heights:g,index:y,toasts:x,expanded:v,removeToast:b,defaultRichColors:w,closeButton:S,style:j,cancelButtonStyle:k,actionButtonStyle:N,className:E="",descriptionClassName:C="",duration:T,position:P,gap:A,expandByDefault:R,classNames:M,icons:D,closeButtonAriaLabel:$="Close toast"}=e,[O,F]=Oe.useState(null),[z,L]=Oe.useState(null),[I,_]=Oe.useState(!1),[V,B]=Oe.useState(!1),[q,U]=Oe.useState(!1),[W,H]=Oe.useState(!1),[K,Y]=Oe.useState(!1),[Q,G]=Oe.useState(0),[J,X]=Oe.useState(0),Z=Oe.useRef(u.duration||T||4e3),ee=Oe.useRef(null),te=Oe.useRef(null),se=0===y,ne=y+1<=f,re=u.type,ae=!1!==u.dismissible,ie=u.className||"",oe=u.descriptionClassName||"",le=Oe.useMemo(()=>g.findIndex(e=>e.toastId===u.id)||0,[g,u.id]),ce=Oe.useMemo(()=>{var e;return null!=(e=u.closeButton)?e:S},[u.closeButton,S]),de=Oe.useMemo(()=>u.duration||T||4e3,[u.duration,T]),ue=Oe.useRef(0),he=Oe.useRef(0),me=Oe.useRef(0),pe=Oe.useRef(null),[fe,ge]=P.split("-"),ye=Oe.useMemo(()=>g.reduce((e,t,s)=>s>=le?e:e+t.height,0),[g,le]),xe=(()=>{const[e,t]=Oe.useState(document.hidden);return Oe.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),ve=u.invert||d,be="loading"===re;he.current=Oe.useMemo(()=>le*A+ye,[le,ye]),Oe.useEffect(()=>{Z.current=de},[de]),Oe.useEffect(()=>{_(!0)},[]),Oe.useEffect(()=>{const e=te.current;if(e){const t=e.getBoundingClientRect().height;return X(t),p(e=>[{toastId:u.id,height:t,position:u.position},...e]),()=>p(e=>e.filter(e=>e.toastId!==u.id))}},[p,u.id]),Oe.useLayoutEffect(()=>{if(!I)return;const e=te.current,t=e.style.height;e.style.height="auto";const s=e.getBoundingClientRect().height;e.style.height=t,X(s),p(e=>e.find(e=>e.toastId===u.id)?e.map(e=>e.toastId===u.id?{...e,height:s}:e):[{toastId:u.id,height:s,position:u.position},...e])},[I,u.title,u.description,p,u.id,u.jsx,u.action,u.cancel]);const we=Oe.useCallback(()=>{B(!0),G(he.current),p(e=>e.filter(e=>e.toastId!==u.id)),setTimeout(()=>{b(u)},200)},[u,b,p,he]);Oe.useEffect(()=>{if(u.promise&&"loading"===re||u.duration===1/0||"loading"===u.type)return;let e;return v||m||xe?(()=>{if(me.current<ue.current){const e=(new Date).getTime()-ue.current;Z.current=Z.current-e}me.current=(new Date).getTime()})():Z.current!==1/0&&(ue.current=(new Date).getTime(),e=setTimeout(()=>{null==u.onAutoClose||u.onAutoClose.call(u,u),we()},Z.current)),()=>clearTimeout(e)},[v,m,u,re,xe,we]),Oe.useEffect(()=>{u.delete&&(we(),null==u.onDismiss||u.onDismiss.call(u,u))},[we,u.delete]);const Se=u.icon||(null==D?void 0:D[re])||(e=>{switch(e){case"success":return ky;case"info":return Ey;case"warning":return Ny;case"error":return Cy;default:return null}})(re);var je,ke,Ne,Ee;return Oe.createElement("li",{tabIndex:0,ref:te,className:zy(E,ie,null==M?void 0:M.toast,null==u||null==(t=u.classNames)?void 0:t.toast,null==M?void 0:M.default,null==M?void 0:M[re],null==u||null==(s=u.classNames)?void 0:s[re]),"data-sonner-toast":"","data-rich-colors":null!=(je=u.richColors)?je:w,"data-styled":!Boolean(u.jsx||u.unstyled||h),"data-mounted":I,"data-promise":Boolean(u.promise),"data-swiped":K,"data-removed":V,"data-visible":ne,"data-y-position":fe,"data-x-position":ge,"data-index":y,"data-front":se,"data-swiping":q,"data-dismissible":ae,"data-type":re,"data-invert":ve,"data-swipe-out":W,"data-swipe-direction":z,"data-expanded":Boolean(v||R&&I),"data-testid":u.testId,style:{"--index":y,"--toasts-before":y,"--z-index":x.length-y,"--offset":`${V?Q:he.current}px`,"--initial-height":R?"auto":`${J}px`,...j,...u.style},onDragEnd:()=>{U(!1),F(null),pe.current=null},onPointerDown:e=>{2!==e.button&&!be&&ae&&(ee.current=new Date,G(he.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(U(!0),pe.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,s;if(W||!ae)return;pe.current=null;const n=Number((null==(e=te.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),r=Number((null==(t=te.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(s=ee.current)?void 0:s.getTime()),i="x"===O?n:r,o=Math.abs(i)/a;if(Math.abs(i)>=45||o>.11)return G(he.current),null==u.onDismiss||u.onDismiss.call(u,u),L("x"===O?n>0?"right":"left":r>0?"down":"up"),we(),void H(!0);var l,c;null==(l=te.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(c=te.current)||c.style.setProperty("--swipe-amount-y","0px"),Y(!1),U(!1),F(null)},onPointerMove:t=>{var s,n,r;if(!pe.current||!ae)return;if((null==(s=window.getSelection())?void 0:s.toString().length)>0)return;const a=t.clientY-pe.current.y,i=t.clientX-pe.current.x;var o;const l=null!=(o=e.swipeDirections)?o:function(e){const[t,s]=e.split("-"),n=[];return t&&n.push(t),s&&n.push(s),n}(P);!O&&(Math.abs(i)>1||Math.abs(a)>1)&&F(Math.abs(i)>Math.abs(a)?"x":"y");let c={x:0,y:0};const d=e=>1/(1.5+Math.abs(e)/20);if("y"===O){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)c.y=a;else{const e=a*d(a);c.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===O&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&i<0||l.includes("right")&&i>0)c.x=i;else{const e=i*d(i);c.x=Math.abs(e)<Math.abs(i)?e:i}(Math.abs(c.x)>0||Math.abs(c.y)>0)&&Y(!0),null==(n=te.current)||n.style.setProperty("--swipe-amount-x",`${c.x}px`),null==(r=te.current)||r.style.setProperty("--swipe-amount-y",`${c.y}px`)}},ce&&!u.jsx&&"loading"!==re?Oe.createElement("button",{"aria-label":$,"data-disabled":be,"data-close-button":!0,onClick:be||!ae?()=>{}:()=>{we(),null==u.onDismiss||u.onDismiss.call(u,u)},className:zy(null==M?void 0:M.closeButton,null==u||null==(n=u.classNames)?void 0:n.closeButton)},null!=(ke=null==D?void 0:D.close)?ke:Ty):null,(re||u.icon||u.promise)&&null!==u.icon&&(null!==(null==D?void 0:D[re])||u.icon)?Oe.createElement("div",{"data-icon":"",className:zy(null==M?void 0:M.icon,null==u||null==(r=u.classNames)?void 0:r.icon)},u.promise||"loading"===u.type&&!u.icon?u.icon||((null==D?void 0:D.loading)?Oe.createElement("div",{className:zy(null==M?void 0:M.loader,null==u||null==(Ee=u.classNames)?void 0:Ee.loader,"sonner-loader"),"data-visible":"loading"===re},D.loading):Oe.createElement(jy,{className:zy(null==M?void 0:M.loader,null==u||null==(Ne=u.classNames)?void 0:Ne.loader),visible:"loading"===re})):null,"loading"!==u.type?Se:null):null,Oe.createElement("div",{"data-content":"",className:zy(null==M?void 0:M.content,null==u||null==(a=u.classNames)?void 0:a.content)},Oe.createElement("div",{"data-title":"",className:zy(null==M?void 0:M.title,null==u||null==(i=u.classNames)?void 0:i.title)},u.jsx?u.jsx:"function"==typeof u.title?u.title():u.title),u.description?Oe.createElement("div",{"data-description":"",className:zy(C,oe,null==M?void 0:M.description,null==u||null==(o=u.classNames)?void 0:o.description)},"function"==typeof u.description?u.description():u.description):null),Oe.isValidElement(u.cancel)?u.cancel:u.cancel&&$y(u.cancel)?Oe.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||k,onClick:e=>{$y(u.cancel)&&ae&&(null==u.cancel.onClick||u.cancel.onClick.call(u.cancel,e),we())},className:zy(null==M?void 0:M.cancelButton,null==u||null==(l=u.classNames)?void 0:l.cancelButton)},u.cancel.label):null,Oe.isValidElement(u.action)?u.action:u.action&&$y(u.action)?Oe.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||N,onClick:e=>{$y(u.action)&&(null==u.action.onClick||u.action.onClick.call(u.action,e),e.defaultPrevented||we())},className:zy(null==M?void 0:M.actionButton,null==u||null==(c=u.classNames)?void 0:c.actionButton)},u.action.label):null)};function Iy(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function _y(e,t){const s={};return[e,t].forEach((e,t)=>{const n=1===t,r=n?"--mobile-offset":"--offset",a=n?"16px":"24px";function i(e){["top","right","bottom","left"].forEach(t=>{s[`${r}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?s[`${r}-${t}`]=a:s[`${r}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),s}const Vy=Oe.forwardRef(function(e,t){const{id:s,invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:u="light",richColors:h,duration:m,style:p,visibleToasts:f=Oy,toastOptions:g,dir:y=Iy(),gap:x=Fy,icons:v,containerAriaLabel:b="Notifications"}=e,[w,S]=Oe.useState([]),j=Oe.useMemo(()=>s?w.filter(e=>e.toasterId===s):w.filter(e=>!e.toasterId),[w,s]),k=Oe.useMemo(()=>Array.from(new Set([r].concat(j.filter(e=>e.position).map(e=>e.position)))),[j,r]),[N,E]=Oe.useState([]),[C,T]=Oe.useState(!1),[P,A]=Oe.useState(!1),[R,M]=Oe.useState("system"!==u?u:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=Oe.useRef(null),$=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),O=Oe.useRef(null),F=Oe.useRef(!1),z=Oe.useCallback(e=>{S(t=>{var s;return(null==(s=t.find(t=>t.id===e.id))?void 0:s.delete)||Ay.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return Oe.useEffect(()=>Ay.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{Fe.flushSync(()=>{S(t=>{const s=t.findIndex(t=>t.id===e.id);return-1!==s?[...t.slice(0,s),{...t[s],...e},...t.slice(s+1)]:[e,...t]})})})}),[w]),Oe.useEffect(()=>{if("system"!==u)return void M(u);if("system"===u&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{M(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{M(e?"dark":"light")}catch(Fv){console.error(Fv)}})}},[u]),Oe.useEffect(()=>{w.length<=1&&T(!1)},[w]),Oe.useEffect(()=>{const e=e=>{var t;var s;a.every(t=>e[t]||e.code===t)&&(T(!0),null==(s=D.current)||s.focus());"Escape"!==e.code||document.activeElement!==D.current&&!(null==(t=D.current)?void 0:t.contains(document.activeElement))||T(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),Oe.useEffect(()=>{if(D.current)return()=>{O.current&&(O.current.focus({preventScroll:!0}),O.current=null,F.current=!1)}},[D.current]),Oe.createElement("section",{ref:t,"aria-label":`${b} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((t,s)=>{var r;const[a,u]=t.split("-");return j.length?Oe.createElement("ol",{key:t,dir:"auto"===y?Iy():y,tabIndex:-1,ref:D,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":u,style:{"--front-toast-height":`${(null==(r=N[0])?void 0:r.height)||0}px`,"--width":"356px","--gap":`${x}px`,...p,..._y(c,d)},onBlur:e=>{F.current&&!e.currentTarget.contains(e.relatedTarget)&&(F.current=!1,O.current&&(O.current.focus({preventScroll:!0}),O.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||F.current||(F.current=!0,O.current=e.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{P||T(!1)},onDragEnd:()=>T(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||A(!0)},onPointerUp:()=>A(!1)},j.filter(e=>!e.position&&0===s||e.position===t).map((s,r)=>{var a,l;return Oe.createElement(Ly,{key:s.id,icons:v,index:r,toast:s,defaultRichColors:h,duration:null!=(a=null==g?void 0:g.duration)?a:m,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:n,visibleToasts:f,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:o,interacting:P,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:z,toasts:j.filter(e=>e.position==s.position),heights:N.filter(e=>e.position==s.position),setHeights:E,expandByDefault:i,gap:x,expanded:C,swipeDirections:e.swipeDirections})})):null}))}),By=Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("rounded-xl border bg-card text-card-foreground shadow",e),...t}));By.displayName="Card";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("flex flex-col space-y-1.5 p-6",e),...t})).displayName="CardHeader";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("font-semibold leading-none tracking-tight",e),...t})).displayName="CardTitle";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("text-sm text-muted-foreground",e),...t})).displayName="CardDescription";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("p-6 pt-0",e),...t})).displayName="CardContent";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter";const qy=Le.forwardRef(({className:e,type:t,...s},n)=>$e.jsx("input",{type:t,className:Ru("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors 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-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...s}));qy.displayName="Input";const Uy=["Dry Van","Refrigerated","Flatbed","Step Deck","Lowboy","Tanker","Container","Other"];function Wy({onSearch:e,theme:t,isLoading:s=!1}){const[n,r]=Oe.useState({origin:"Los Angeles, CA",destination:"New York, NY",pickupEarliest:(()=>{const e=new Date;return e.setDate(e.getDate()+1),e.toISOString().split("T")[0]})(),pickupHours:"09:00",dropoffHours:"17:00",equipmentType:"Dry Van",length:"53",weight:"40000",volume:"2000"}),[a,i]=Oe.useState({}),{width:o,containerRef:l}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),c=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",formPadding:"p-3",spacing:"space-y-3",titleSize:"text-base",subtitleSize:"text-xs",iconSize:"w-5 h-5",iconSizeSmall:"h-3 w-3",labelSize:"text-xs",buttonSize:"text-xs px-3 py-2",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-1"}}:e<450?{containerPadding:"p-3",headerPadding:"p-4",formPadding:"p-4",spacing:"space-y-4",titleSize:"text-lg",subtitleSize:"text-sm",iconSize:"w-6 h-6",iconSizeSmall:"h-3 w-3",labelSize:"text-xs",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",maxWidth:"max-w-none",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-2"}}:e<600?{containerPadding:"p-4",headerPadding:"p-5",formPadding:"p-5",spacing:"space-y-5",titleSize:"text-xl",subtitleSize:"text-sm",iconSize:"w-8 h-8",iconSizeSmall:"h-3.5 w-3.5",labelSize:"text-sm",buttonSize:"text-sm px-6 py-2.5",buttonIconSize:"h-4 w-4",maxWidth:"max-w-2xl",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-2"}}:{containerPadding:"p-6",headerPadding:"p-6",formPadding:"p-6",spacing:"space-y-6",titleSize:"text-2xl",subtitleSize:"text-base",iconSize:"w-10 h-10",iconSizeSmall:"h-4 w-4",labelSize:"text-sm",buttonSize:"px-8 py-3",buttonIconSize:"h-5 w-5",maxWidth:"max-w-4xl",gridCols:{location:"grid-cols-1 md:grid-cols-2",datetime:"grid-cols-1 md:grid-cols-3",equipment:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"}})(o),d=(e,t)=>{r(s=>({...s,[e]:t})),a[e]&&i(t=>({...t,[e]:""}))};return $e.jsx(pd.div,{ref:l,initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`${c.maxWidth} mx-auto ${c.containerPadding}`,children:$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("div",{className:`${c.headerPadding} border-b`,children:[$e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[$e.jsx("div",{className:`${c.iconSize} rounded-full flex items-center justify-center`,style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(Pf,{className:`${c.iconSizeSmall}`,style:{color:t.primaryColor}})}),$e.jsx("h2",{className:`${c.titleSize} font-bold`,style:{fontFamily:t.fontFamily,color:t.primaryColor},children:"Search Carriers"})]}),$e.jsx("p",{className:`text-gray-600 ${c.subtitleSize}`,style:{fontFamily:t.fontFamily},children:"Find the best carriers for your shipment needs"})]}),$e.jsxs("form",{onSubmit:t=>{t.preventDefault(),(()=>{const e={};return n.origin.trim()||(e.origin="Origin is required"),n.destination.trim()||(e.destination="Destination is required"),n.pickupEarliest||(e.pickupEarliest="Pickup date is required"),n.pickupHours||(e.pickupHours="Pickup time is required"),n.dropoffHours||(e.dropoffHours="Drop-off time is required"),n.length.trim()||(e.length="Length is required"),n.weight.trim()||(e.weight="Weight is required"),i(e),0===Object.keys(e).length})()&&e(n)},className:`${c.formPadding} ${c.spacing}`,children:[$e.jsxs("div",{className:`grid ${c.gridCols.location} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(xf,{className:`${c.iconSizeSmall} inline mr-1`}),"Origin"]}),$e.jsx(qy,{value:n.origin,onChange:e=>d("origin",e.target.value),placeholder:"Enter pickup location",className:a.origin?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.origin&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.origin})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(xf,{className:`${c.iconSizeSmall} inline mr-1`}),"Destination"]}),$e.jsx(qy,{value:n.destination,onChange:e=>d("destination",e.target.value),placeholder:"Enter delivery location",className:a.destination?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.destination&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.destination})]})]}),$e.jsxs("div",{className:`grid ${c.gridCols.datetime} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Jp,{className:`${c.iconSizeSmall} inline mr-1`}),"Pickup Earliest"]}),$e.jsx(qy,{type:"date",value:n.pickupEarliest,onChange:e=>d("pickupEarliest",e.target.value),className:a.pickupEarliest?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.pickupEarliest&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.pickupEarliest})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(af,{className:`${c.iconSizeSmall} inline mr-1`}),"Pickup Hours"]}),$e.jsx(qy,{type:"time",value:n.pickupHours,onChange:e=>d("pickupHours",e.target.value),className:a.pickupHours?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.pickupHours&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.pickupHours})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(af,{className:`${c.iconSizeSmall} inline mr-1`}),"Drop-off Hours"]}),$e.jsx(qy,{type:"time",value:n.dropoffHours,onChange:e=>d("dropoffHours",e.target.value),className:a.dropoffHours?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.dropoffHours&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.dropoffHours})]})]}),$e.jsxs("div",{className:`grid ${c.gridCols.equipment} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(If,{className:`${c.iconSizeSmall} inline mr-1`}),"Equipment Type"]}),$e.jsx("select",{value:n.equipmentType,onChange:e=>d("equipmentType",e.target.value),className:`w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${c.labelSize}`,style:{fontFamily:t.fontFamily},children:Uy.map(e=>$e.jsx("option",{value:e,children:e},e))})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(kf,{className:`${c.iconSizeSmall} inline mr-1`}),"Length (ft)"]}),$e.jsx(qy,{type:"number",value:n.length,onChange:e=>d("length",e.target.value),placeholder:"e.g., 48",className:a.length?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.length&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.length})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Vf,{className:`${c.iconSizeSmall} inline mr-1`}),"Weight (lbs)"]}),$e.jsx(qy,{type:"number",value:n.weight,onChange:e=>d("weight",e.target.value),placeholder:"e.g., 40000",className:a.weight?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.weight&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.weight})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Gp,{className:`${c.iconSizeSmall} inline mr-1`}),"Volume (cu ft)"]}),$e.jsx(qy,{type:"number",value:n.volume||"",onChange:e=>d("volume",e.target.value),placeholder:"e.g., 2000",className:a.volume?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.volume&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.volume})]})]}),$e.jsx("div",{className:"flex justify-center pt-4",children:$e.jsx(Ou,{type:"submit",size:"lg",disabled:s,className:`${c.buttonSize} text-white font-semibold rounded-lg hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed`,style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:s?$e.jsxs($e.Fragment,{children:[$e.jsx(ff,{className:`${c.buttonIconSize} mr-2 animate-spin`}),"Searching..."]}):$e.jsxs($e.Fragment,{children:[$e.jsx(Pf,{className:`${c.buttonIconSize} mr-2`}),"Search Carriers"]})})})]})]})})}const Hy=async e=>{try{const t=(e=>{const t=`${e.pickupEarliest}T${e.pickupHours}:00`,s=`${e.pickupEarliest}T${e.dropoffHours}:00`;return{origin:e.origin,destination:e.destination,cargo_type:e.equipmentType,weight:parseFloat(e.weight)||0,volume:parseFloat(e.volume||"0")||0,pickup_date:t,delivery_date:s,max_results:10}})(e);return await Mp.initiateWorkflow(t)}catch(t){throw console.error("Error initiating carrier search:",t),t}},Ky=e=>({id:e.workflow_id,title:`${e.input_params.origin} → ${e.input_params.destination}`,origin:e.input_params.origin,destination:e.input_params.destination,cargoType:e.input_params.cargo_type,weight:e.input_params.weight,volume:e.input_params.volume,pickupDate:e.input_params.pickup_date,deliveryDate:e.input_params.delivery_date,status:e.status,totalCarriers:e.total_carriers,createdAt:new Date(e.created_at),completedAt:e.completed_at?new Date(e.completed_at):null,workflowId:e.workflow_id}),Yy=e=>"completed"===e,Qy=new zt({defaultOptions:{queries:{staleTime:3e5,gcTime:6e5,retry:(e,t)=>!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500)&&e<3,retryDelay:e=>Math.min(1e3*2**e,3e4),refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!0},mutations:{retry:(e,t)=>!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500)&&e<1,retryDelay:1e3}}}),Gy={carriers:{all:()=>["carriers"],lists:()=>[...Gy.carriers.all(),"list"],list:e=>[...Gy.carriers.lists(),e],details:()=>[...Gy.carriers.all(),"detail"],detail:e=>[...Gy.carriers.details(),e],search:e=>[...Gy.carriers.all(),"search",e]}},Jy=e=>{console.error("[Query Error]",e),window.dispatchEvent(new CustomEvent("query:error",{detail:{message:e.message||"An error occurred",status:e.status||0,data:e.data||null}}))},Xy=()=>({fetchWorkflowPage:async e=>{const t=await(async(e=1,t=10)=>{try{return await Mp.getWorkflowList(e,t)}catch(s){throw console.error("Error fetching workflow list:",s),s}})(e,10);return{data:t.workflows.map(Ky),hasMore:10===t.workflows.length,total:t.total_count}}}),Zy=e=>{const t=It();return Wt({mutationFn:async e=>await(async e=>{try{return await Mp.deleteWorkflow(e)}catch(t){throw console.error("Error deleting workflow:",t),t}})(e),...e,onSuccess:(s,n,r,a)=>{var i;t.invalidateQueries({queryKey:["workflows"]}),null==(i=null==e?void 0:e.onSuccess)||i.call(e,s,n,r,a)},onError:(t,s,n,r)=>{var a;Jy(t),null==(a=null==e?void 0:e.onError)||a.call(e,t,s,n,r)}})},ex=(e,t)=>function(e){return Ut(e,kt)}({queryKey:["workflow-status",e],queryFn:async()=>await Mp.getWorkflowStatus(e),enabled:!!e,staleTime:3e4,...t});function tx(){const{theme:e,isAuthenticated:t}=ns();Mg();const s=(e=>{const t=It();return Wt({mutationFn:async e=>await Hy(e),...e,onSuccess:(s,n,r,a)=>{var i;t.invalidateQueries({queryKey:Gy.carriers.all()}),null==(i=null==e?void 0:e.onSuccess)||i.call(e,s,n,r,a)},onError:(t,s,n,r)=>{var a;Jy(t),null==(a=null==e?void 0:e.onError)||a.call(e,t,s,n,r)}})})({onSuccess:e=>{Dy.success("Workflow Intialted Successfully!",{description:`Workflow ID: ${e.data.workflow_id} and estimated completed time: ${e.data.estimated_completion_time}`,duration:4e3})},onError:e=>{console.error("Carrier search failed:",e),Dy.error("Failed to search carriers",{description:e.message||"Please check your connection and try again.",duration:5e3})}});return t?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(Wy,{onSearch:e=>{const t=(e=>{var t,s,n;const r=[];return(null==(t=e.origin)?void 0:t.trim())||r.push("Origin is required"),(null==(s=e.destination)?void 0:s.trim())||r.push("Destination is required"),e.pickupEarliest||r.push("Pickup date is required"),e.pickupHours||r.push("Pickup time is required"),e.dropoffHours||r.push("Delivery time is required"),e.equipmentType||r.push("Equipment type is required"),(null==(n=e.weight)?void 0:n.trim())?isNaN(parseFloat(e.weight))?r.push("Weight must be a valid number"):parseFloat(e.weight)<=0&&r.push("Weight must be greater than 0"):r.push("Weight is required"),e.volume&&e.volume.trim()&&(isNaN(parseFloat(e.volume))?r.push("Volume must be a valid number"):parseFloat(e.volume)<0&&r.push("Volume must be 0 or greater")),r})(e);t.length>0?Dy.error("Please fix the following errors:",{description:t.join(", "),duration:5e3}):s.mutate(e)},theme:e,isLoading:s.isPending})})}):$e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsx("div",{className:"text-center",children:$e.jsx("p",{className:"text-gray-600",style:{fontFamily:e.fontFamily},children:"Please authenticate to start using the carrier search."})})})}function sx({carrier:e,isSelected:t,onSelect:s,onCallCarrier:n,theme:r}){const{width:a,containerRef:i}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),o=(e=>e<400?{padding:"p-3",spacing:"gap-2",titleSize:"text-base",textSize:"text-xs",priceSize:"text-lg",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",layout:"mobile",checkboxSize:"h-3 w-3",marginBottom:"mb-1"}:e<600?{padding:"p-3.5",spacing:"gap-2.5",titleSize:"text-lg",textSize:"text-sm",priceSize:"text-xl",iconSize:"h-3.5 w-3.5",buttonSize:"text-sm px-3 py-1.5",buttonIconSize:"h-3.5 w-3.5",layout:"tablet",checkboxSize:"h-3.5 w-3.5",marginBottom:"mb-1.5"}:{padding:"p-4",spacing:"gap-3",titleSize:"text-lg",textSize:"text-sm",priceSize:"text-2xl",iconSize:"h-4 w-4",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",layout:"desktop",checkboxSize:"h-4 w-4",marginBottom:"mb-2"})(a),l=()=>{s(e.id)},c=t=>{t.stopPropagation(),n(e.id)};return $e.jsxs(pd.div,{ref:i,initial:{opacity:0,y:20},animate:{opacity:1,y:0},whileHover:{y:-2},className:`bg-white rounded-lg border-2 ${o.padding} cursor-pointer transition-all duration-200 ${t?"border-blue-500 shadow-lg":"border-gray-200 hover:border-gray-300 hover:shadow-md"}`,onClick:l,children:["mobile"===o.layout?$e.jsxs("div",{className:"space-y-2",children:[$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("input",{type:"checkbox",checked:t,onChange:l,className:`${o.checkboxSize} rounded border-gray-300 text-blue-600 focus:ring-blue-500`,style:{accentColor:r.primaryColor}}),$e.jsx("h3",{className:`font-semibold ${o.titleSize}`,style:{fontFamily:r.fontFamily},children:e.name})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx($f,{className:`${o.iconSize} fill-yellow-400 text-yellow-400`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,children:e.rating.toFixed(1)})]})]}),$e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-xs",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(xf,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:e.location||e.source||"Available"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:e.equipment})]})]}),(e.dotNumber||e.capacity)&&$e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-xs",children:[e.dotNumber&&$e.jsxs("div",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:["DOT: ",e.dotNumber]}),e.capacity&&$e.jsxs("div",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:["Fleet: ",e.capacity]})]}),(e.vettingResult||e.matchScore)&&$e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.vettingResult&&$e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium "+("ACCEPT"===e.vettingResult?"bg-green-100 text-green-800":"REJECT"===e.vettingResult?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"),children:e.vettingResult}),e.matchScore&&$e.jsxs("span",{className:"text-gray-600",style:{fontFamily:r.fontFamily},children:["Match: ",(100*e.matchScore).toFixed(0),"%"]})]}),$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:e.responseTime||e.estimatedTime||"< 2 hours"})]}),$e.jsxs("span",{className:`${o.priceSize} font-bold`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:["$",e.price.toLocaleString()]})]}),$e.jsxs(Ou,{onClick:c,className:`w-full ${o.buttonSize} text-white font-medium hover:opacity-90 transition-opacity`,style:{backgroundColor:r.primaryColor,fontFamily:r.fontFamily},children:[$e.jsx(Nf,{className:`${o.buttonIconSize} mr-1`}),"Call Carrier"]})]}):$e.jsxs("div",{className:"flex items-start justify-between",children:[$e.jsxs("div",{className:`flex items-start ${o.spacing} flex-1`,children:[$e.jsx("input",{type:"checkbox",checked:t,onChange:l,className:`mt-1 ${o.checkboxSize} rounded border-gray-300 text-blue-600 focus:ring-blue-500`,style:{accentColor:r.primaryColor}}),$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:`flex items-center gap-2 ${o.marginBottom}`,children:[$e.jsx("h3",{className:`font-semibold ${o.titleSize}`,style:{fontFamily:r.fontFamily},children:e.name}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx($f,{className:`${o.iconSize} fill-yellow-400 text-yellow-400`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,children:e.rating.toFixed(1)})]})]}),$e.jsxs("div",{className:`flex items-center gap-1 ${o.marginBottom}`,children:[$e.jsx(xf,{className:`${o.iconSize} text-gray-500`}),$e.jsxs("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:["Source: ",e.source]})]}),$e.jsxs("div",{className:`flex items-center gap-1 ${o.marginBottom}`,children:[$e.jsx(If,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:e.equipment})]}),$e.jsxs("div",{className:"flex items-center gap-1 mb-3",children:[$e.jsx(af,{className:`${o.iconSize} text-gray-500`}),$e.jsxs("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:["Est. Time: ",e.estimatedTime]})]}),$e.jsx("div",{className:"mb-3",children:$e.jsxs("span",{className:`${o.priceSize} font-bold`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:["$",e.price.toLocaleString()]})})]})]}),$e.jsxs(Ou,{onClick:c,className:`ml-4 ${o.buttonSize} text-white font-medium hover:opacity-90 transition-opacity`,style:{backgroundColor:r.primaryColor,fontFamily:r.fontFamily},children:[$e.jsx(Nf,{className:`${o.buttonIconSize} mr-1`}),"Call Carrier"]})]}),t&&$e.jsx(pd.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},className:"mt-3 p-2 rounded-md",style:{backgroundColor:r.primaryColor+"10"},children:$e.jsx("p",{className:`${o.textSize} text-center`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:"✓ Selected for bulk action"})})]})}const nx=e=>{switch(e){case"waiting":return"text-yellow-600 bg-yellow-50 border-yellow-200";case"in-progress":return"text-blue-600 bg-blue-50 border-blue-200";case"completed":return"text-green-600 bg-green-50 border-green-200";case"failed":return"text-red-600 bg-red-50 border-red-200";default:return"text-gray-600 bg-gray-50 border-gray-200"}},rx=e=>{switch(e){case"pending":default:return"text-gray-600 bg-gray-50 border-gray-200";case"negotiating":return"text-orange-600 bg-orange-50 border-orange-200";case"agreed":return"text-green-600 bg-green-50 border-green-200";case"declined":return"text-red-600 bg-red-50 border-red-200"}};function ax({item:e,onViewDetails:t,theme:s}){(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[])})();const n=Math.min(e.callDuration/e.maxDuration*100,100),r=t;return $e.jsxs(pd.div,{onClick:()=>{t&&t(e.id)},whileHover:{y:-2,scale:1.01},transition:{duration:.2},className:"rounded-2xl border border-gray-200 bg-white shadow-sm p-3 \n hover:shadow-md transition-all duration-200 "+(r?"cursor-pointer hover:border-blue-300":""),children:[$e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[$e.jsx("h3",{className:"font-semibold text-sm text-gray-800 truncate",style:{fontFamily:s.fontFamily},children:e.carrierName}),$e.jsx("div",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${nx(e.callStatus)}`,children:$e.jsx("span",{className:"capitalize",children:e.callStatus.replace("-"," ")})})]}),$e.jsxs("div",{className:"flex items-center justify-between mb-2 text-xs text-gray-600",children:[$e.jsx("span",{children:e.contactInfo}),$e.jsxs("span",{className:"font-medium text-gray-500",children:[e.callDuration,"m / ",e.maxDuration,"m"]})]}),$e.jsx("div",{className:"w-full h-1.5 bg-gray-200 rounded-full overflow-hidden mb-2",children:$e.jsx(pd.div,{className:"h-1.5 rounded-full",style:{backgroundColor:n>80?"#ef4444":n>60?"#f59e0b":s.primaryColor,width:`${n}%`},initial:{width:0},animate:{width:`${n}%`},transition:{duration:.6,ease:"easeOut"}})}),$e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[$e.jsxs("div",{className:"flex items-center gap-1.5",children:[$e.jsx("div",{className:`px-2 py-0.5 rounded-full border font-medium ${rx(e.dealStatus)}`,children:e.dealStatus}),e.agreedRate&&$e.jsxs("div",{className:"flex items-center gap-0.5 text-green-600",children:[$e.jsx(of,{className:"w-3 h-3"}),$e.jsxs("span",{className:"font-semibold",children:["$",e.agreedRate.toLocaleString()]})]})]}),$e.jsxs("div",{className:"flex items-center gap-1.5",children:["in-progress"===e.callStatus&&$e.jsx(pd.div,{animate:{scale:[1,1.3,1]},transition:{duration:1,repeat:1/0},className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),"agreed"===e.dealStatus&&$e.jsx(pd.div,{initial:{scale:0},animate:{scale:1},className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),$e.jsxs("span",{className:"text-gray-400",children:["#",e.id.slice(-4)]})]})]}),e.notes&&$e.jsx("div",{className:"mt-2 bg-gray-50 border border-gray-100 rounded-lg p-2",children:$e.jsxs("p",{className:"text-xs text-gray-600 leading-tight",children:[$e.jsx("span",{className:"font-medium",children:"Note:"})," ",e.notes]})})]})}function ix({searchResults:e,callQueueItems:t,searchMetadata:s,onBack:n,onCallCarrier:r,onBulkCall:a,onViewCallDetails:i,theme:o}){const[l,c]=Oe.useState("results"),[d,u]=Oe.useState([]),{width:h,containerRef:m}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),p=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",contentPadding:"p-3",spacing:"gap-2",titleSize:"text-base",subtitleSize:"text-xs",textSize:"text-xs",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:"grid-cols-1",metadataGrid:"grid-cols-1",tabPadding:"px-2 py-1.5",tabTextSize:"text-xs",headerLayout:"mobile"}:e<450?{containerPadding:"p-3",headerPadding:"p-4",contentPadding:"p-4",spacing:"gap-3",titleSize:"text-lg",subtitleSize:"text-xs",textSize:"text-xs",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:"grid-cols-1",metadataGrid:"grid-cols-1",tabPadding:"px-3 py-2",tabTextSize:"text-xs",headerLayout:"mobile"}:e<600?{containerPadding:"p-4",headerPadding:"p-5",contentPadding:"p-5",spacing:"gap-4",titleSize:"text-xl",subtitleSize:"text-sm",textSize:"text-sm",iconSize:"h-4 w-4",buttonSize:"text-sm px-3 py-1.5",buttonIconSize:"h-4 w-4",maxWidth:"max-w-4xl",gridCols:"grid-cols-1",metadataGrid:"grid-cols-2",tabPadding:"px-4 py-2.5",tabTextSize:"text-sm",headerLayout:"tablet"}:{containerPadding:"p-6",headerPadding:"p-6",contentPadding:"p-6",spacing:"gap-4",titleSize:"text-2xl",subtitleSize:"text-sm",textSize:"text-sm",iconSize:"h-4 w-4",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",maxWidth:"max-w-6xl",gridCols:"grid-cols-1 lg:grid-cols-2",metadataGrid:"grid-cols-2 md:grid-cols-4",tabPadding:"px-6 py-3",tabTextSize:"text-sm",headerLayout:"desktop"})(h),[f,g]=Oe.useState(null),[y,x]=Oe.useState([]),[v,b]=Oe.useState(null),w=Oe.useRef(null),S=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=async()=>{if(f)try{const e=await Mp.getQueueStatus(f);b(e.status);const t=(e=>{const t=Array.isArray(e.items)?e.items:[],s=e.currentItem||e.current_item;return t.map(e=>{const t=e.status,n="completed"===t?"completed":"dispatched"===t?"in-progress":"failed"===t?"failed":"waiting";return{id:e.callLogId||e.call_log_id||`${Date.now()}_${Math.random()}`,carrierName:e.carrierName||e.carrier_name||"Unknown Carrier",callDuration:"in-progress"===n?2:"completed"===n?3:0,maxDuration:15,callStatus:n,dealStatus:"pending",agreedRate:null,contactInfo:`${e.contactName||e.contact_name||"Contact"} • ${e.contactPhone||e.contact_phone||""}`,notes:!s||s.callLogId!==e.callLogId&&s.call_log_id!==e.call_log_id?void 0:"Currently being called"}})})(e);x(t),"completed"===e.status&&w.current&&(window.clearInterval(w.current),w.current=null)}catch(Fv){Dy.error("Failed to fetch queue status",{description:(null==Fv?void 0:Fv.message)||"Unexpected error"}),w.current&&(window.clearInterval(w.current),w.current=null)}};Oe.useEffect(()=>("queue"===l&&f&&!w.current&&(w.current=window.setInterval(j,3e3),j()),"queue"!==l&&w.current&&(window.clearInterval(w.current),w.current=null),()=>{w.current&&(window.clearInterval(w.current),w.current=null)}),[l,f]);const k=d.length;return $e.jsxs("div",{ref:m,className:`${p.maxWidth} mx-auto ${p.containerPadding}`,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border mb-6",children:[$e.jsx("div",{className:`${p.headerPadding} border-b`,children:"mobile"===p.headerLayout?$e.jsxs("div",{className:"space-y-3",children:[$e.jsxs(Ou,{onClick:n,variant:"outline",size:"sm",className:`flex items-center ${p.spacing} ${p.buttonSize}`,style:{fontFamily:o.fontFamily},children:[$e.jsx(Kp,{className:p.iconSize}),"Back to Search"]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`${p.titleSize} font-bold`,style:{fontFamily:o.fontFamily,color:o.primaryColor},children:"Search Results"}),$e.jsxs("p",{className:`text-gray-600 ${p.subtitleSize}`,style:{fontFamily:o.fontFamily},children:[s.searchCriteria.origin," → ",s.searchCriteria.destination]})]}),$e.jsxs("div",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:[$e.jsxs("p",{children:["ID: ",s.searchId.slice(-8)]}),$e.jsx("p",{children:s.timestamp.toLocaleString()})]})]}):$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:`flex items-center ${p.spacing}`,children:[$e.jsxs(Ou,{onClick:n,variant:"outline",size:"sm",className:`flex items-center gap-2 ${p.buttonSize}`,style:{fontFamily:o.fontFamily},children:[$e.jsx(Kp,{className:p.iconSize}),"Back to Search"]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`${p.titleSize} font-bold`,style:{fontFamily:o.fontFamily,color:o.primaryColor},children:"Search Results"}),$e.jsxs("p",{className:`text-gray-600 ${p.subtitleSize}`,style:{fontFamily:o.fontFamily},children:[s.searchCriteria.origin," → ",s.searchCriteria.destination]})]})]}),$e.jsxs("div",{className:"text-right",children:[$e.jsxs("p",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:["Search ID: ",s.searchId.slice(-8)]}),$e.jsx("p",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:s.timestamp.toLocaleString()})]})]})}),$e.jsx("div",{className:"p-4 bg-gray-50",children:$e.jsxs("div",{className:`grid ${p.metadataGrid} gap-4 ${p.textSize}`,children:[$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Equipment:"}),$e.jsx("span",{className:"ml-1 font-medium",children:s.searchCriteria.equipmentType})]}),$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Weight:"}),$e.jsxs("span",{className:"ml-1 font-medium",children:[s.searchCriteria.weight," lbs"]})]}),s.searchCriteria.volume&&$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Volume:"}),$e.jsxs("span",{className:"ml-1 font-medium",children:[s.searchCriteria.volume," cu ft"]})]}),$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Pickup:"}),$e.jsx("span",{className:"ml-1 font-medium",children:s.searchCriteria.pickupDate})]})]})})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsx("div",{className:"border-b",children:$e.jsxs("nav",{className:"flex",children:[$e.jsxs("button",{onClick:()=>c("results"),className:`${p.tabPadding} ${p.tabTextSize} font-medium border-b-2 transition-colors ${"results"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,style:{fontFamily:o.fontFamily,..."results"===l&&{borderBottomColor:o.primaryColor,color:o.primaryColor}},children:[$e.jsx(Pf,{className:`${p.iconSize} inline mr-2`}),"Results (",e.length,")"]}),$e.jsxs("button",{onClick:()=>c("queue"),className:`${p.tabPadding} ${p.tabTextSize} font-medium border-b-2 transition-colors ${"queue"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,style:{fontFamily:o.fontFamily,..."queue"===l&&{borderBottomColor:o.primaryColor,color:o.primaryColor}},children:[$e.jsx(Nf,{className:`${p.iconSize} inline mr-2`}),"Call Queue (",t.length,")"]})]})}),$e.jsx("div",{className:p.contentPadding,children:$e.jsxs(gi,{mode:"wait",children:["results"===l&&$e.jsxs(pd.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},children:[$e.jsxs("div",{className:"flex items-center justify-between mb-6 "+("mobile"===p.headerLayout?"flex-col gap-3":""),children:[$e.jsxs("div",{className:`flex items-center ${p.spacing} ${"mobile"===p.headerLayout?"w-full justify-between":""}`,children:[$e.jsx("h3",{className:("text-lg"===p.titleSize?"text-base":"text-lg")+" font-semibold",style:{fontFamily:o.fontFamily},children:"Available Carriers"}),k>0&&$e.jsxs("span",{className:`px-2 py-1 bg-blue-100 text-blue-800 rounded-full ${p.textSize}`,style:{fontFamily:o.fontFamily},children:[k," selected"]})]}),k>0&&$e.jsxs(Ou,{onClick:async()=>{if(0===d.length)return;const t=e.filter(e=>d.includes(e.id)),n=s.searchCriteria.origin,r=s.searchCriteria.destination,a=s.searchCriteria.volume?`${s.searchCriteria.volume} loads per month`:"Unknown volume",i=t.map(e=>{var t,s;const i="number"==typeof e.price?e.price:0,o=i?`$${(.95*i).toFixed(2)}`:"$0.00",l=i?`$${i.toFixed(2)}`:"$0.00",c=i?`$${(1.1*i).toFixed(2)}`:"$0.00",d=i?`$${(1.02*i).toFixed(2)}`:"$0.00";return{contact_phone:(null==(t=e.contactInfo)?void 0:t.phone)||"",contact_name:(null==(s=e.contactInfo)?void 0:s.contact_person)||e.name,carrier_name:e.name,route:`${n} to ${r}`,volume:a,target_rate:o,market_rate:l,max_rate:c,initiate_call:!0,source:n,destination:r,expected_price:d}});try{const e=await Mp.enqueueCallQueue(i),t=e.queueId||e.queue_id,s=e.status;t?(g(t),b(s||"pending"),Dy.success("Call queue triggered",{description:`Queue ID: ${String(t).slice(-8)}`}),c("queue")):Dy.error("Failed to trigger call queue",{description:"No queue ID returned"})}catch(Fv){Dy.error("Failed to trigger call queue",{description:(null==Fv?void 0:Fv.message)||"Unexpected error"})}finally{u([])}},className:`${p.buttonSize} text-white font-medium hover:opacity-90 transition-opacity ${"mobile"===p.headerLayout?"w-full":""}`,style:{backgroundColor:o.primaryColor,fontFamily:o.fontFamily},children:[$e.jsx(_f,{className:`${p.buttonIconSize} mr-2`}),"Call Selected (",k,")"]})]}),$e.jsx("div",{className:`grid ${p.gridCols} gap-4`,children:e.map(e=>$e.jsx(sx,{carrier:e,isSelected:d.includes(e.id),onSelect:S,onCallCarrier:r,theme:o},e.id))}),0===e.length&&$e.jsxs("div",{className:"text-center py-12",children:[$e.jsx(Pf,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),$e.jsx("p",{className:`text-gray-600 ${p.textSize}`,style:{fontFamily:o.fontFamily},children:"No carriers found for your search criteria."})]})]},"results"),"queue"===l&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[$e.jsxs("div",{className:"flex items-center justify-between mb-6 "+("mobile"===p.headerLayout?"flex-col gap-3":""),children:[$e.jsx("h3",{className:("text-lg"===p.titleSize?"text-base":"text-lg")+" font-semibold",style:{fontFamily:o.fontFamily},children:"Call Queue"}),$e.jsxs("div",{className:`flex items-center ${p.spacing} ${p.textSize} text-gray-600 ${"mobile"===p.headerLayout?"flex-col gap-1":""}`,children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:p.iconSize}),$e.jsxs("span",{children:["In Progress: ",(y.length?y:t).filter(e=>"in-progress"===e.callStatus).length]})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(nf,{className:p.iconSize}),$e.jsxs("span",{children:["Completed: ",(y.length?y:t).filter(e=>"completed"===e.callStatus).length]})]})]})]}),$e.jsx("div",{className:`grid ${p.gridCols} gap-4`,children:(y.length?y:t).map(e=>$e.jsx(ax,{item:e,onViewDetails:i,theme:o},e.id))}),0===(y.length?y:t).length&&$e.jsxs("div",{className:"text-center py-12",children:[$e.jsx(Nf,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),$e.jsx("p",{className:`text-gray-600 ${p.textSize}`,style:{fontFamily:o.fontFamily},children:"No calls in queue. Start calling carriers to see them here."})]})]},"queue")]})})]})]})}const ox=[{id:"carrier-001",name:"Swift Transportation",source:"DAT Load Board",rating:4.8,price:2850,estimatedTime:"2-3 days",equipment:"Dry Van",isSelected:!1},{id:"carrier-002",name:"J.B. Hunt Transport",source:"Truckstop.com",rating:4.6,price:3200,estimatedTime:"1-2 days",equipment:"Refrigerated",isSelected:!1},{id:"carrier-003",name:"Schneider National",source:"123Loadboard",rating:4.7,price:2950,estimatedTime:"2-3 days",equipment:"Dry Van",isSelected:!1},{id:"carrier-004",name:"Werner Enterprises",source:"Direct Contact",rating:4.5,price:2750,estimatedTime:"3-4 days",equipment:"Flatbed",isSelected:!1},{id:"carrier-005",name:"Prime Inc.",source:"DAT Load Board",rating:4.9,price:3100,estimatedTime:"2 days",equipment:"Refrigerated",isSelected:!1}],lx=[{id:"call-001",carrierName:"Swift Transportation",callDuration:15,maxDuration:30,callStatus:"in-progress",dealStatus:"negotiating",agreedRate:null,contactInfo:"John Smith - (555) 123-4567",notes:"Discussing pickup time flexibility"},{id:"call-002",carrierName:"Prime Inc.",callDuration:25,maxDuration:30,callStatus:"completed",dealStatus:"agreed",agreedRate:3100,contactInfo:"Sarah Johnson - (555) 987-6543",notes:"Rate agreed, waiting for confirmation email"},{id:"call-003",carrierName:"Werner Enterprises",callDuration:8,maxDuration:30,callStatus:"waiting",dealStatus:"pending",agreedRate:null,contactInfo:"Mike Davis - (555) 456-7890"},{id:"call-004",carrierName:"Schneider National",callDuration:30,maxDuration:30,callStatus:"failed",dealStatus:"declined",agreedRate:null,contactInfo:"Lisa Brown - (555) 321-0987",notes:"Could not reach carrier, voicemail left"}];function cx(){const{theme:e}=ns(),t=Pg(),s=Mg(),n=t.state,{data:r,isLoading:a,error:i}=ex((null==n?void 0:n.workflowId)||""),[o,l]=Oe.useState((null==n?void 0:n.searchResults)||[]),[c,d]=Oe.useState((null==n?void 0:n.searchMetadata)||null),[u,h]=Oe.useState(lx);Oe.useEffect(()=>{if(r&&(null==n?void 0:n.isFromHistory)){const e=r.carriers.map((e,t)=>({id:e.carrier_id,name:e.carrier_name,price:2500+100*t,rating:Math.min(5,Math.max(1,5*e.vetting_details.overall_score)),responseTime:"< 2 hours",equipment:e.type_of_load,location:"Available",capacity:e.fleet_size.toString(),experience:`${e.years_in_business} years`,dotNumber:e.dot_number,contactInfo:e.contact_info,matchScore:e.match_score,vettingResult:e.vetting_result,vettingDetails:e.vetting_details,rfmScore:e.rfm_score})),t={searchId:r.workflow_id,timestamp:new Date(r.created_at),searchCriteria:{origin:r.input_details.origin,destination:r.input_details.destination,pickupDate:r.input_details.pickup_date,deliveryDate:r.input_details.delivery_date,equipmentType:r.input_details.cargo_type,weight:r.input_details.weight,volume:r.input_details.volume},totalResults:r.total_carriers_found,processingTime:r.processing_time_seconds,status:r.status};l(e),d(t)}},[r,null==n?void 0:n.isFromHistory]),Oe.useEffect(()=>{a||(null==n?void 0:n.workflowId)||(null==n?void 0:n.searchResults)&&(null==n?void 0:n.searchMetadata)||s("/search",{replace:!0})},[n,s,a]);const m=e=>{const t=o.find(t=>t.id===e);if(t){const e={id:"call-"+Date.now(),carrierName:t.name,callDuration:0,maxDuration:30,callStatus:"waiting",dealStatus:"pending",agreedRate:null,contactInfo:"Contact info not available",notes:`Called from search results - Rate: $${t.price}`};h(t=>[e,...t]),setTimeout(()=>{h(t=>t.map(t=>t.id===e.id?{...t,callStatus:"in-progress"}:t))},1e3)}};return a&&(null==n?void 0:n.isFromHistory)?$e.jsxs("div",{className:"flex flex-col h-full items-center justify-center",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mb-4"}),$e.jsx("p",{className:"text-gray-600",children:"Loading workflow results..."})]}):i&&(null==n?void 0:n.isFromHistory)?$e.jsxs("div",{className:"flex flex-col h-full items-center justify-center",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"text-red-500 mb-4",children:$e.jsx("p",{children:"Failed to load workflow results"})}),$e.jsx("button",{onClick:()=>s("/search"),className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Back to Search"})]}):c?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(ix,{searchResults:o,callQueueItems:u,searchMetadata:c,onBack:()=>{s(-1)},onCallCarrier:m,onBulkCall:e=>{e.forEach((e,t)=>{setTimeout(()=>m(e),500*t)})},onViewCallDetails:e=>{s(`/call-details/${e}`,{state:{callQueueItems:u,searchResults:o,searchMetadata:c}})},theme:e})})}):null}const dx=e=>{const t=Math.floor(e/3600),s=Math.floor(e%3600/60),n=e%60;return t>0?`${t}:${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${s}:${n.toString().padStart(2,"0")}`},ux=e=>{switch(e){case"excellent":return"text-green-600 bg-green-100";case"good":return"text-blue-600 bg-blue-100";case"fair":return"text-yellow-600 bg-yellow-100";case"poor":return"text-red-600 bg-red-100";default:return"text-gray-600 bg-gray-100"}},hx=e=>{switch(e){case"positive":return"text-green-600";case"negative":return"text-red-600";default:return"text-gray-600"}},mx=e=>{switch(e){case"positive":return $e.jsx(zf,{className:"w-4 h-4"});case"negative":return $e.jsx(Ff,{className:"w-4 h-4"});default:return $e.jsx(bf,{className:"w-4 h-4"})}};function px({callDetails:e,onBack:t,theme:s}){var n;const{width:r,containerRef:a}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),i=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",cardPadding:"p-3",gridCols:"grid-cols-1",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},spacing:"space-y-2",buttonSize:"px-2 py-1 text-xs",iconSize:"w-3 h-3",maxWidth:"max-w-full",headerLayout:"stacked"}:e<450?{containerPadding:"p-3",headerPadding:"p-3",cardPadding:"p-3",gridCols:"grid-cols-1",textSize:{title:"text-base",subtitle:"text-sm",body:"text-xs",caption:"text-xs"},spacing:"space-y-2",buttonSize:"px-2 py-1 text-xs",iconSize:"w-3 h-3",maxWidth:"max-w-full",tabPadding:"px-2 py-1",sectionSpacing:"space-y-2",metricGrid:"grid-cols-2",transcriptHeight:"max-h-48"}:e<600?{containerPadding:"p-3",headerPadding:"p-4",cardPadding:"p-4",gridCols:"grid-cols-1",textSize:{title:"text-lg",subtitle:"text-base",body:"text-sm",caption:"text-xs"},spacing:"space-y-3",buttonSize:"px-3 py-2 text-sm",iconSize:"w-4 h-4",maxWidth:"max-w-full",tabPadding:"px-3 py-2",sectionSpacing:"space-y-3",metricGrid:"grid-cols-2",transcriptHeight:"max-h-64"}:{containerPadding:"p-4",headerPadding:"p-5",cardPadding:"p-5",gridCols:"grid-cols-1 md:grid-cols-2",textSize:{title:"text-xl",subtitle:"text-lg",body:"text-base",caption:"text-sm"},spacing:"space-y-4",buttonSize:"px-4 py-2 text-base",iconSize:"w-5 h-5",maxWidth:"max-w-full",tabPadding:"px-4 py-2",sectionSpacing:"space-y-4",metricGrid:"grid-cols-3",transcriptHeight:"max-h-80"})(r),[o,l]=Oe.useState("metadata"),[c,d]=Oe.useState(new Set(["overview"])),[u,h]=Oe.useState(""),[m,p]=Oe.useState(!1),[f,g]=Oe.useState(null),y=e=>{const t=new Set(c);t.has(e)?t.delete(e):t.add(e),d(t)},x=(null==(n=e.transcription)?void 0:n.fullTranscript.filter(e=>e.text.toLowerCase().includes(u.toLowerCase())))||[],v=async t=>{p(!0);try{await new Promise(e=>setTimeout(e,1e3));const s={callId:e.callId,timestamp:e.timestamp,duration:e.duration,participants:e.participants,..."transcript"===t&&{transcription:e.transcription}},n=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.href=r,a.download=`call-${e.callId}-${t}.${"pdf"===t?"pdf":"json"}`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}catch(s){g("Failed to download file")}finally{p(!1)}};return $e.jsxs("div",{ref:a,className:`${i.maxWidth} mx-auto ${i.containerPadding}`,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border mb-6",children:[$e.jsx("div",{className:`${i.headerPadding} border-b`,children:$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center space-x-4",children:[$e.jsxs("button",{onClick:t,className:`flex items-center space-x-2 text-gray-600 hover:text-gray-800 ${i.buttonSize}`,children:[$e.jsx(Kp,{className:i.iconSize}),$e.jsx("span",{children:"Back"})]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`font-bold text-gray-900 ${i.textSize.title}`,children:"Call Details"}),$e.jsxs("p",{className:`text-gray-600 ${i.textSize.caption}`,children:["Call ID: ",e.callId]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsxs("button",{onClick:()=>v("json"),disabled:m,className:`flex items-center space-x-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 ${i.buttonSize}`,children:[$e.jsx(lf,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:"Export"})]}),$e.jsxs("button",{className:`flex items-center space-x-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 ${i.buttonSize}`,children:[$e.jsx(Rf,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:"Share"})]})]})]})}),$e.jsx("div",{className:`${i.headerPadding} pt-0`,children:$e.jsx("div",{className:"flex space-x-1 bg-gray-100 rounded-lg p-1",children:[{id:"metadata",label:"Overview",icon:Nf},{id:"details",label:"Technical",icon:Sf},{id:"transcription",label:"Transcript",icon:df}].map(({id:e,label:t,icon:s})=>$e.jsxs("button",{onClick:()=>l(e),className:`flex items-center space-x-1 ${i.tabPadding} rounded-md transition-colors flex-1 justify-center ${i.textSize.body} ${o===e?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-800"}`,children:[$e.jsx(s,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:t}),$e.jsx("span",{className:"sm:hidden",children:t.charAt(0)})]},e))})})]}),f&&$e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-6",children:$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsx(sf,{className:"w-5 h-5 text-red-600"}),$e.jsx("span",{className:"text-red-800",children:f}),$e.jsx("button",{onClick:()=>g(null),className:"ml-auto text-red-600 hover:text-red-800",children:$e.jsx(rf,{className:"w-4 h-4"})})]})}),$e.jsxs(pd.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:i.spacing,children:["metadata"===o&&$e.jsx(fx,{callDetails:e,config:i,expandedSections:c,toggleSection:y}),"details"===o&&$e.jsx(gx,{callDetails:e,config:i,expandedSections:c,toggleSection:y}),"transcription"===o&&$e.jsx(yx,{callDetails:e,config:i,searchTerm:u,setSearchTerm:h,filteredTranscript:x,onDownload:v,isLoading:m})]},o)]})}function fx({callDetails:e,config:t,expandedSections:s,toggleSection:n}){return $e.jsxs("div",{className:t.spacing,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("overview"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Call Overview"}),s.has("overview")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("overview")&&$e.jsxs("div",{className:`${t.cardPadding} pt-0 border-t`,children:[$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(af,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Duration"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:dx(e.duration)})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Nf,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Direction"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.direction})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx("div",{className:"w-3 h-3 rounded-full "+("completed"===e.status?"bg-green-500":"failed"===e.status?"bg-red-500":"in-progress"===e.status?"bg-blue-500":"bg-yellow-500")}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Status"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.status.replace("-"," ")})]})]})]}),$e.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg",children:[$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Started: ",e.timestamp.toLocaleString()]}),e.result.outcome&&$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption} mt-1`,children:["Outcome: ",$e.jsx("span",{className:"capitalize",children:e.result.outcome})]})]})]})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("participants"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsxs("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:["Participants (",e.participants.length,")"]}),s.has("participants")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("participants")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t space-y-3`,children:e.participants.map(e=>$e.jsxs("div",{className:"flex items-center space-x-3 p-3 bg-gray-50 rounded-lg",children:[$e.jsx(_f,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{className:"flex-1",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.name}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.role," • ",e.company||"Unknown Company"]}),e.phoneNumber&&$e.jsx("p",{className:`text-gray-500 ${t.textSize.caption}`,children:e.phoneNumber})]}),$e.jsx("div",{className:"px-2 py-1 rounded-full text-xs "+("caller"===e.role?"bg-blue-100 text-blue-800":"receiver"===e.role?"bg-green-100 text-green-800":"bg-purple-100 text-purple-800"),children:e.role})]},e.id))})]}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Call Quality"}),$e.jsxs("div",{className:"flex items-center space-x-4 mb-4",children:[$e.jsx("div",{className:"flex items-center space-x-2",children:[1,2,3,4,5].map(t=>$e.jsx($f,{className:"w-5 h-5 "+(t<=e.quality.overallScore?"text-yellow-400 fill-current":"text-gray-300")},t))}),$e.jsxs("span",{className:`font-medium ${t.textSize.body}`,children:[e.quality.overallScore,"/5"]}),$e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ux(e.quality.audioQuality)}`,children:e.quality.audioQuality})]}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Signal Strength"}),$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsx("div",{className:"flex-1 bg-gray-200 rounded-full h-2",children:$e.jsx("div",{className:"bg-green-500 h-2 rounded-full",style:{width:`${e.quality.signalStrength}%`}})}),$e.jsxs("span",{className:`${t.textSize.caption} font-medium`,children:[e.quality.signalStrength,"%"]})]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Latency"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.quality.latency,"ms"]})]})]})]})})]})}function gx({callDetails:e,config:t,expandedSections:s,toggleSection:n}){return $e.jsxs("div",{className:t.spacing,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("network"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Network Information"}),s.has("network")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("network")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t`,children:$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(qf,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Connection"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.network.connectionType})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Df,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Bandwidth"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.network.bandwidth," kbps"]})]})]}),$e.jsxs("div",{className:"col-span-full",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body} mb-2`,children:"Location"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.network.location.city,", ",e.network.location.state,", ",e.network.location.country]}),$e.jsxs("p",{className:`text-gray-500 ${t.textSize.caption} mt-1`,children:["IP: ",e.network.ipAddress," • Provider: ",e.network.provider]})]})]})})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("device"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Device Information"}),s.has("device")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("device")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t`,children:$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Sf,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Browser"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.device.browser," ",e.device.browserVersion]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx("div",{className:`${t.iconSize} bg-gray-200 rounded flex items-center justify-center`,children:$e.jsx("span",{className:"text-xs font-bold",children:"OS"})}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Operating System"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.device.operatingSystem," ",e.device.osVersion]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(hf,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Audio Devices"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Mic: ",e.device.microphone]}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Speaker: ",e.device.speaker]})]})]})]})})]}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Codec & Technical Parameters"}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Audio Codec"}),$e.jsx("p",{className:`font-medium ${t.textSize.body}`,children:e.codec.audioCodec})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Bitrate"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.codec.bitrate," kbps"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Sample Rate"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.codec.sampleRate," Hz"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Channels"}),$e.jsx("p",{className:`font-medium ${t.textSize.body}`,children:e.codec.channels})]})]}),$e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[$e.jsx("h3",{className:`font-medium text-gray-900 ${t.textSize.body} mb-2`,children:"Performance Metrics"}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"RTP Packets Sent"}),$e.jsx("p",{className:"font-medium",children:e.technicalParams.rtpPackets.sent.toLocaleString()})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"RTP Packets Lost"}),$e.jsx("p",{className:"font-medium",children:e.technicalParams.rtpPackets.lost.toLocaleString()})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"CPU Usage"}),$e.jsxs("p",{className:"font-medium",children:[e.technicalParams.cpu.usage,"%"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"Memory Used"}),$e.jsxs("p",{className:"font-medium",children:[e.technicalParams.memory.used," MB"]})]})]})]})]})})]})}function yx({callDetails:e,config:t,searchTerm:s,setSearchTerm:n,filteredTranscript:r,onDownload:a,isLoading:i}){return e.transcription?$e.jsxs("div",{className:t.spacing,children:[$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Call Transcription"}),$e.jsxs("button",{onClick:()=>a("transcript"),disabled:i,className:`flex items-center space-x-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 ${t.buttonSize}`,children:[$e.jsx(lf,{className:t.iconSize}),$e.jsx("span",{children:"Download"})]})]}),$e.jsxs("div",{className:"relative mb-4",children:[$e.jsx(Pf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),$e.jsx("input",{type:"text",placeholder:"Search transcript...",value:s,onChange:e=>n(e.target.value),className:`w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t.textSize.body}`})]}),$e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsxs("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:[e.transcription.confidence,"%"]}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Confidence"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.transcription.speakers.length}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Speakers"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.transcription.fullTranscript.length}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Segments"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body} capitalize`,children:e.transcription.language}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Language"})]})]})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Sentiment Analysis"}),$e.jsxs("div",{className:"flex items-center space-x-4 mb-4",children:[$e.jsxs("div",{className:`flex items-center space-x-2 ${hx(e.transcription.sentimentAnalysis.overall)}`,children:[mx(e.transcription.sentimentAnalysis.overall),$e.jsx("span",{className:`font-medium capitalize ${t.textSize.body}`,children:e.transcription.sentimentAnalysis.overall})]}),$e.jsxs("div",{className:"px-3 py-1 rounded-full text-xs font-medium "+(e.transcription.sentimentAnalysis.score>.3?"bg-green-100 text-green-800":e.transcription.sentimentAnalysis.score<-.3?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"),children:["Score: ",e.transcription.sentimentAnalysis.score.toFixed(2)]})]}),$e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2",children:Object.entries(e.transcription.sentimentAnalysis.emotions).map(([e,s])=>$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mb-1",children:$e.jsx("div",{className:"bg-blue-500 h-2 rounded-full",style:{width:100*s+"%"}})}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e})]},e))})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Key Phrases"}),$e.jsx("div",{className:"flex flex-wrap gap-2",children:e.transcription.keyPhrases.slice(0,10).map((e,t)=>$e.jsxs("span",{className:"px-3 py-1 rounded-full text-xs font-medium "+(e.importance>7?"bg-red-100 text-red-800":e.importance>5?"bg-yellow-100 text-yellow-800":"bg-blue-100 text-blue-800"),children:[e.phrase," (",e.frequency,")"]},t))})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Full Transcript"}),$e.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:(s?r:e.transcription.fullTranscript).map(n=>{const r=e.transcription.speakers.find(e=>e.id===n.speakerId);return $e.jsxs("div",{className:"flex space-x-3 p-3 hover:bg-gray-50 rounded-lg",children:[$e.jsx("div",{className:"flex-shrink-0",children:$e.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center",children:$e.jsx("span",{className:"text-xs font-medium text-blue-800",children:(null==r?void 0:r.name.charAt(0))||"U"})})}),$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[$e.jsx("span",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:(null==r?void 0:r.name)||"Unknown"}),$e.jsx("span",{className:`text-gray-500 ${t.textSize.caption}`,children:(a=n.timestamp,`${Math.floor(a/60)}:${Math.floor(a%60).toString().padStart(2,"0")}`)}),n.sentiment&&$e.jsx("span",{className:`${hx(n.sentiment)} ${t.textSize.caption}`,children:mx(n.sentiment)})]}),$e.jsx("p",{className:`text-gray-700 ${t.textSize.body}`,children:s?n.text.split(new RegExp(`(${s})`,"gi")).map((e,t)=>e.toLowerCase()===s.toLowerCase()?$e.jsx("mark",{className:"bg-yellow-200",children:e},t):e):n.text}),$e.jsx("div",{className:"flex items-center space-x-2 mt-1",children:$e.jsxs("span",{className:`text-gray-500 ${t.textSize.caption}`,children:["Confidence: ",n.confidence,"%"]})})]})]},n.id);var a})}),s&&0===r.length&&$e.jsxs("div",{className:"text-center py-8",children:[$e.jsx(Pf,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.body}`,children:['No results found for "',s,'"']})]})]})})]}):$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border p-8 text-center",children:[$e.jsx(df,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),$e.jsx("h3",{className:`font-medium text-gray-900 ${t.textSize.subtitle} mb-2`,children:"No Transcription Available"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,children:"Transcription is not available for this call."})]})}const xx=(e,t)=>{const s=Math.floor(1800*Math.random())+300,n=new Date(Date.now()-864e5*Math.random()),r=[{id:"participant-1",name:"John Smith",role:"caller",phoneNumber:"+1 (555) 123-4567",email:"john.smith@logistics.com",company:"Logistics Solutions Inc.",joinTime:n,leaveTime:new Date(n.getTime()+1e3*s)},{id:"participant-2",name:t.split(" ")[0]+" Representative",role:"receiver",phoneNumber:"+1 (555) 987-6543",email:`contact@${t.toLowerCase().replace(/\s+/g,"")}.com`,company:t,joinTime:new Date(n.getTime()+15e3),leaveTime:new Date(n.getTime()+1e3*s)}],a={overallScore:Math.floor(2*Math.random())+4,signalStrength:Math.floor(20*Math.random())+80,latency:Math.floor(50*Math.random())+20,jitter:Math.floor(10*Math.random())+2,packetLoss:2*Math.random(),audioQuality:["excellent","good","fair"][Math.floor(3*Math.random())],connectionStability:["stable","unstable"][Math.floor(2*Math.random())]},i={ipAddress:`192.168.${Math.floor(255*Math.random())}.${Math.floor(255*Math.random())}`,connectionType:["wifi","ethernet","cellular"][Math.floor(3*Math.random())],bandwidth:Math.floor(500*Math.random())+100,provider:["Verizon","AT&T","Comcast","Spectrum"][Math.floor(4*Math.random())],location:{city:["New York","Los Angeles","Chicago","Houston","Phoenix"][Math.floor(5*Math.random())],state:["NY","CA","IL","TX","AZ"][Math.floor(5*Math.random())],country:"United States"}},o={browser:["Chrome","Firefox","Safari","Edge"][Math.floor(4*Math.random())],browserVersion:`${Math.floor(20*Math.random())+90}.0.${Math.floor(10*Math.random())}.${Math.floor(100*Math.random())}`,operatingSystem:["Windows","macOS","Linux"][Math.floor(3*Math.random())],osVersion:["11","10.15","20.04"][Math.floor(3*Math.random())],microphone:["Built-in Microphone","USB Headset","Bluetooth Headset"][Math.floor(3*Math.random())],speaker:["Built-in Speakers","USB Headset","Bluetooth Headset"][Math.floor(3*Math.random())],camera:Math.random()>.5?"Built-in Camera":void 0,deviceType:["desktop","mobile","tablet"][Math.floor(3*Math.random())]},l={audioCodec:["Opus","G.722","G.711"][Math.floor(3*Math.random())],bitrate:Math.floor(64*Math.random())+32,sampleRate:[8e3,16e3,48e3][Math.floor(3*Math.random())],channels:Math.random()>.5?2:1,compression:["Lossless","Lossy"][Math.floor(2*Math.random())]},c={rtpPackets:{sent:Math.floor(1e4*Math.random())+5e3,received:Math.floor(1e4*Math.random())+5e3,lost:Math.floor(100*Math.random())+10},bandwidth:{upload:Math.floor(100*Math.random())+50,download:Math.floor(200*Math.random())+100},cpu:{usage:Math.floor(30*Math.random())+10,temperature:Math.floor(20*Math.random())+45},memory:{used:Math.floor(2048*Math.random())+512,available:Math.floor(4096*Math.random())+2048}},d={id:`transcript-${e}`,fullTranscript:[{id:"segment-1",speakerId:"participant-1",text:`Hello, this is John from Logistics Solutions. I'm calling about a shipment from ${["Chicago","New York","Los Angeles"][Math.floor(3*Math.random())]} to ${["Miami","Seattle","Denver"][Math.floor(3*Math.random())]}.`,timestamp:5,duration:8,confidence:95,sentiment:"neutral"},{id:"segment-2",speakerId:"participant-2",text:`Hi John, thanks for calling ${t}. I'd be happy to help you with that shipment. Can you tell me more about the cargo details?`,timestamp:15,duration:6,confidence:92,sentiment:"positive"},{id:"segment-3",speakerId:"participant-1",text:`Sure! We have ${Math.floor(20*Math.random())+5} pallets of ${["electronics","automotive parts","consumer goods","machinery"][Math.floor(4*Math.random())]}, total weight around ${Math.floor(3e4*Math.random())+1e4} pounds. We need it delivered by ${new Date(Date.now()+6048e5*Math.random()).toLocaleDateString()}.`,timestamp:23,duration:12,confidence:88,sentiment:"neutral"},{id:"segment-4",speakerId:"participant-2",text:`That sounds manageable. For that route and timeline, we can offer a rate of $${(2e3*Math.random()+1500).toFixed(2)} for the full load. Does that work within your budget?`,timestamp:38,duration:9,confidence:94,sentiment:"positive"},{id:"segment-5",speakerId:"participant-1",text:`That's a bit higher than we were hoping for. Our budget is closer to $${(1500*Math.random()+1200).toFixed(2)}. Is there any flexibility on the pricing?`,timestamp:50,duration:8,confidence:90,sentiment:"negative"},{id:"segment-6",speakerId:"participant-2",text:`I understand your budget constraints. Let me check with my manager... Okay, I can do $${(1800*Math.random()+1400).toFixed(2)} as our best offer. That includes full insurance coverage.`,timestamp:62,duration:11,confidence:87,sentiment:"neutral"},{id:"segment-7",speakerId:"participant-1",text:"That works better for us. Let's move forward with that rate. What's the next step to book this shipment?",timestamp:76,duration:7,confidence:93,sentiment:"positive"},{id:"segment-8",speakerId:"participant-2",text:`Excellent! I'll send you a booking confirmation within the next hour. You'll receive pickup instructions and our driver's contact information. Thank you for choosing ${t}!`,timestamp:85,duration:10,confidence:96,sentiment:"positive"}],speakers:[{id:"participant-1",name:"John Smith",voiceProfile:{pitch:120,tone:"professional",accent:"American Midwest"},speakingTime:Math.floor(.45*s),wordCount:245},{id:"participant-2",name:t.split(" ")[0]+" Representative",voiceProfile:{pitch:140,tone:"friendly",accent:"American South"},speakingTime:Math.floor(.55*s),wordCount:198}],sentimentAnalysis:{overall:"positive",score:.65,emotions:{joy:.3,anger:.1,fear:.05,sadness:.02,surprise:.15},trends:[{timestamp:0,sentiment:"neutral",score:0},{timestamp:20,sentiment:"positive",score:.3},{timestamp:50,sentiment:"negative",score:-.2},{timestamp:70,sentiment:"positive",score:.6},{timestamp:90,sentiment:"positive",score:.8}]},keyPhrases:[{phrase:"shipment",frequency:8,importance:9,category:"business",timestamps:[5,15,23,76]},{phrase:"rate",frequency:6,importance:8,category:"business",timestamps:[38,50,62]},{phrase:"budget",frequency:4,importance:7,category:"business",timestamps:[50,62]},{phrase:"insurance",frequency:2,importance:6,category:"business",timestamps:[62]},{phrase:"delivery",frequency:3,importance:7,category:"business",timestamps:[23,76]},{phrase:"pallets",frequency:2,importance:5,category:"technical",timestamps:[23]},{phrase:"thank you",frequency:2,importance:4,category:"emotional",timestamps:[15,85]}],summary:`Successful negotiation call between John Smith from Logistics Solutions and ${t} representative. Discussed shipment details, negotiated pricing from initial quote to agreed rate, and finalized booking. Call resulted in confirmed shipment booking with insurance coverage.`,confidence:91,language:"English"},u={recordingUrl:`https://recordings.example.com/calls/${e}.mp3`,recordingSize:Math.floor(5e7*Math.random())+1e7,callCost:5*Math.random()+2,region:"US-East",serverLocation:"Virginia, USA",encryption:!0,compliance:{gdpr:!0,hipaa:!1,sox:!0}},h={outcome:Math.random()>.2?"successful":"failed",reason:Math.random()>.2?"Agreement reached on pricing and terms":"Unable to meet budget requirements",followUpRequired:Math.random()>.7,nextAction:Math.random()>.7?"Send booking confirmation":void 0,dealValue:3e3*Math.random()+1e3,agreementReached:Math.random()>.2};return{id:`call-details-${e}`,callId:e,timestamp:n,duration:s,participants:r,direction:Math.random()>.5?"outbound":"inbound",status:"completed",result:h,quality:a,network:i,device:o,codec:l,technicalParams:c,transcription:d,metadata:u}};function vx(){const{theme:e}=ns(),{callId:t}=Dg(),s=Pg(),n=Mg(),r=s.state,[a,i]=Oe.useState(null);Oe.useEffect(()=>{var e;if(!t)return void n("/search",{replace:!0});const s=null==(e=null==r?void 0:r.callQueueItems)?void 0:e.find(e=>e.id===t);if(s){const e=xx(t,s.carrierName);i(e)}else{const e=xx(t,"Unknown Carrier");i(e)}},[t,r,n]);return a?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(px,{callDetails:a,onBack:()=>{(null==r?void 0:r.fromCallLogs)?n("/call-logs"):(null==r?void 0:r.searchResults)&&(null==r?void 0:r.searchMetadata)?n("/results",{state:r}):n("/search")},theme:e})})}):$e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsx("div",{className:"text-center",children:$e.jsx("p",{className:"text-gray-600",style:{fontFamily:e.fontFamily},children:"Loading call details..."})})})}xx("call-1","Swift Transport"),xx("call-2","Reliable Freight"),xx("call-3","Express Logistics");const bx=({isOpen:e,onClose:t,onConfirm:s,title:n,message:r,confirmText:a="Confirm",cancelText:i="Cancel",isLoading:o=!1,variant:l="danger",containedMode:c=!1})=>{if(!e)return null;const d=(()=>{switch(l){case"danger":default:return{icon:"text-red-500",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",iconBg:"bg-red-100"};case"warning":return{icon:"text-yellow-500",confirmButton:"bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500",iconBg:"bg-yellow-100"};case"info":return{icon:"text-blue-500",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",iconBg:"bg-blue-100"}}})(),u=c?"absolute inset-0 z-50 overflow-y-auto":"fixed inset-0 z-50 overflow-y-auto",h=c?"absolute inset-0 bg-black bg-opacity-50 transition-opacity":"fixed inset-0 bg-black bg-opacity-50 transition-opacity";return $e.jsxs("div",{className:u,children:[$e.jsx("div",{className:h,onClick:t}),$e.jsx("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:$e.jsxs("div",{className:"relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg",children:[$e.jsx("div",{className:"bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4",children:$e.jsxs("div",{className:"sm:flex sm:items-start",children:[$e.jsx("div",{className:`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${d.iconBg} sm:mx-0 sm:h-10 sm:w-10`,children:$e.jsx(Lf,{className:`h-6 w-6 ${d.icon}`})}),$e.jsxs("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left flex-1",children:[$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsx("h3",{className:"text-base font-semibold leading-6 text-gray-900",children:n}),$e.jsxs("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:t,children:[$e.jsx("span",{className:"sr-only",children:"Close"}),$e.jsx(Uf,{className:"h-6 w-6"})]})]}),$e.jsx("div",{className:"mt-2",children:$e.jsx("p",{className:"text-sm text-gray-500",children:r})})]})]})}),$e.jsxs("div",{className:"bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6",children:[$e.jsx("button",{type:"button",className:`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm sm:ml-3 sm:w-auto ${d.confirmButton} focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,onClick:s,disabled:o,children:o?$e.jsxs($e.Fragment,{children:[$e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[$e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),$e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Processing..."]}):a}),$e.jsx("button",{type:"button",className:"mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto",onClick:t,disabled:o,children:i})]})]})})]})};function wx({fetchData:e,pageSize:t=10,initialData:s=[],enabled:n=!0,dependencies:r=[]}){const[a,i]=Oe.useState(s),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(null),[u,h]=Oe.useState(!0),[m,p]=Oe.useState(0),[f,g]=Oe.useState(0),y=Oe.useRef(!1),x=Oe.useCallback(async()=>{if(n&&!o&&u&&!y.current){y.current=!0,l(!0),d(null);try{const s=m+1,n=await e(s,t);i(e=>[...e,...n.data]),h(n.hasMore),p(s),void 0!==n.total&&g(n.total)}catch(s){d(s instanceof Error?s.message:"Failed to load data")}finally{l(!1),y.current=!1}}},[n,u,m,e,t]),v=Oe.useCallback(async()=>{if(n){i([]),p(0),h(!0),d(null),g(0),y.current=!1,l(!0);try{const s=await e(1,t);i(s.data),h(s.hasMore),p(1),void 0!==s.total&&g(s.total)}catch(s){d(s instanceof Error?s.message:"Failed to load data")}finally{l(!1)}}},[n,e,t]);return Oe.useEffect(()=>{r.length>0&&v()},r),Oe.useEffect(()=>{n&&0===a.length&&0===m&&!o&&x()},[n,a.length,m,o]),{data:a,loading:o,error:c,hasMore:u,loadMore:x,refresh:v,total:f,currentPage:m}}function Sx(e,t,s,n=100){const r=Oe.useRef(null);return Oe.useEffect(()=>{const a=r.current;if(!a||!t||s)return;const i=new IntersectionObserver(t=>{t[0].isIntersecting&&e()},{rootMargin:`${n}px`,threshold:.1});return i.observe(a),()=>{i.disconnect()}},[e,t,s,n]),r}function jx({item:e,onView:t,onDelete:s,theme:n,config:r}){var a;const i="searchFormData"in e,o=e.title,l=i?e.searchFormData.origin:e.origin,c=i?e.searchFormData.destination:e.destination,d=i?e.searchFormData.equipmentType:e.cargoType,u=i?e.searchFormData.pickupEarliest:null==(a=e.pickupDate)?void 0:a.split("T")[0],h=i?e.resultsCount:e.totalCarriers,m=i?e.timestamp:e.createdAt,p=i?"completed":e.status,f=Yy(p);return $e.jsx(pd.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},whileHover:{scale:1.01},transition:{duration:.2},children:$e.jsx(By,{className:`${r.cardPadding} ${r.cardHeight} transition-all duration-200 hover:shadow-md border`,style:{fontFamily:n.fontFamily},children:$e.jsxs("div",{className:"flex items-start justify-between",children:[$e.jsxs("div",{className:"flex-1 min-w-0",children:[$e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[$e.jsx(Pf,{className:`${r.iconSize} text-gray-500 flex-shrink-0`}),$e.jsx("h3",{className:`font-medium ${r.textSize.title} truncate`,children:o}),!f&&$e.jsx("div",{className:"flex items-center gap-1",children:$e.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-yellow-100 text-yellow-800",children:p})})]}),$e.jsxs("div",{className:`${r.spacing} mb-3`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(xf,{className:`${r.iconSize} text-gray-400`}),$e.jsxs("span",{className:`text-gray-600 ${r.textSize.body} truncate`,children:[l," → ",c]})]}),$e.jsxs("div",{className:"flex items-center gap-4",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:`${r.iconSize} text-gray-400`}),$e.jsx("span",{className:`text-gray-600 ${r.textSize.caption}`,children:d})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:`${r.iconSize} text-gray-400`}),$e.jsx("span",{className:`text-gray-600 ${r.textSize.caption}`,children:u})]})]})]}),$e.jsxs("div",{className:"flex items-center gap-4 text-gray-500",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:`${r.iconSize}`}),$e.jsx("span",{className:r.textSize.caption,children:m.toLocaleDateString()})]}),$e.jsxs("span",{className:r.textSize.caption,children:[h," result",1!==h?"s":""]})]})]}),$e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:e=>{e.stopPropagation(),s()},className:`${r.buttonSize} p-1 text-gray-400 hover:text-red-500`,children:[$e.jsx(Of,{className:r.iconSize}),$e.jsx("span",{className:"sr-only",children:"Delete search"})]}),$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:t,className:`${r.buttonSize} text-blue-600 hover:text-blue-800 hover:bg-blue-50`,disabled:!f,children:[f?$e.jsx(cf,{className:r.iconSize}):$e.jsx(ff,{className:`${r.iconSize} animate-spin`}),$e.jsx("span",{className:"hidden sm:inline ml-1",children:f?"View":"Processing"})]})]})]})})})}function kx({theme:e,config:t}){return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:e.primaryColor+"20"},children:$e.jsx(Pf,{className:"h-8 w-8",style:{color:e.primaryColor}})}),$e.jsx("h3",{className:`${t.textSize.title} font-semibold mb-2`,style:{fontFamily:e.fontFamily},children:"No search history"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,style:{fontFamily:e.fontFamily},children:"Your carrier searches will appear here."})]})})}function Nx({config:e}){return $e.jsx("div",{className:"flex justify-center py-4",children:$e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})})}function Ex(){const{theme:e}=ns(),t=Mg(),{width:s,containerRef:n}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),r=(e=>e<380?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-xs",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[110px]",maxCardsVisible:2.8}:e<450?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[120px]",maxCardsVisible:2.5}:e<600?{containerPadding:"p-3",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[130px]",maxCardsVisible:2.2}:{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-2 text-sm",headerPadding:"p-4",cardHeight:"min-h-[140px]",maxCardsVisible:2})(s),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(""),[u,h]=Oe.useState(""),[m,p]=Oe.useState({isOpen:!1,workflowId:null,workflowName:""}),{fetchWorkflowPage:f}=Xy(),g=Zy({onSuccess:()=>{p({isOpen:!1,workflowId:null,workflowName:""}),j()},onError:e=>{console.error("Failed to delete workflow:",e)}}),y=Oe.useCallback((e,t)=>f(e),[f]),{data:x,loading:v,error:b,hasMore:w,loadMore:S,refresh:j}=wx({fetchData:y,pageSize:10,enabled:!0,dependencies:[c,u]}),k=Sx(S,w,v),N=async e=>{var s,n,r;if(Yy(e.status))try{const s=e.workflow_id||e.id;t("/results",{state:{workflowId:s,isFromHistory:!0}})}catch(a){console.error("Error viewing workflow:",a);const i={origin:e.origin,destination:e.destination,pickupEarliest:(null==(s=e.pickupDate)?void 0:s.split("T")[0])||"",pickupHours:"08:00",dropoffHours:"17:00",equipmentType:e.cargoType,length:"48",weight:(null==(n=e.weight)?void 0:n.toString())||"40000",volume:(null==(r=e.volume)?void 0:r.toString())||"2000"},{results:o,metadata:l}=(e=>{const t=ox.filter(t=>"Dry Van"===e.equipmentType||"Dry Van"!==t.equipment||Math.random()>.3).map(e=>({...e,price:e.price+Math.floor(500*Math.random())-250,isSelected:!1}));return{results:t,metadata:{searchId:"search-"+Date.now(),timestamp:new Date,totalResults:t.length,searchCriteria:{origin:e.origin,destination:e.destination,pickupDate:e.pickupEarliest,equipmentType:e.equipmentType,weight:parseInt(e.weight)||4e4,volume:parseInt(e.volume||"2000")}}}})(i);t("/results",{state:{searchResults:o,searchMetadata:l,searchFormData:i}})}};return $e.jsxs("div",{ref:n,className:"flex flex-col h-full relative",style:{fontFamily:e.fontFamily},children:[$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>i(!a),className:`w-full ${r.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Pf,{className:r.iconSize}),$e.jsx("span",{className:`${r.textSize.body} font-medium`,children:"Search History"})]}),a?$e.jsx(tf,{className:r.iconSize}):$e.jsx(Xp,{className:r.iconSize})]}),a&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:r.containerPadding,children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${r.iconSize} text-gray-400`}),$e.jsx("input",{type:"text",placeholder:"Search your history...",value:c,onChange:e=>d(e.target.value),className:`w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${r.textSize.body}`}),c&&$e.jsx("button",{onClick:()=>d(""),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",children:$e.jsx(Uf,{className:r.iconSize})})]})})})]}),$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>l(!o),className:`w-full ${r.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(uf,{className:r.iconSize}),$e.jsx("span",{className:`${r.textSize.body} font-medium`,children:"Filters"}),u&&$e.jsx("span",{className:`${r.textSize.caption} bg-blue-100 text-blue-800 px-2 py-1 rounded-full`,children:u})]}),o?$e.jsx(tf,{className:r.iconSize}):$e.jsx(Xp,{className:r.iconSize})]}),o&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:r.containerPadding,children:$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>h(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>h("Dry Van"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Dry Van"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Dry Van"}),$e.jsx("button",{onClick:()=>h("Refrigerated"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Refrigerated"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Refrigerated"}),$e.jsx("button",{onClick:()=>h("Flatbed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Flatbed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Flatbed"})]})})})]}),$e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[b&&$e.jsx("div",{className:"p-4",children:$e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[$e.jsxs("p",{className:"text-red-800 text-sm",children:["Failed to load search history: ",b]}),$e.jsx(Ou,{onClick:j,className:"mt-2 text-sm bg-red-600 text-white hover:bg-red-700",children:"Retry"})]})}),b||0!==x.length||v?$e.jsxs("div",{className:`${r.containerPadding} ${r.spacing}`,children:[x.map(t=>$e.jsx(jx,{item:t,onView:()=>N(t),onDelete:()=>(e=>{p({isOpen:!0,workflowId:e.workflow_id||e.id,workflowName:e.workflow_name||`${e.origin} → ${e.destination}`})})(t),theme:e,config:r},t.id)),v&&$e.jsx(Nx,{config:r}),w&&$e.jsx("div",{ref:k,className:"h-4"}),!w&&x.length>0&&$e.jsx("div",{className:"text-center py-4",children:$e.jsx("p",{className:`text-gray-500 ${r.textSize.caption}`,children:"No more search history to load"})})]}):$e.jsx(kx,{theme:e,config:r})]}),$e.jsx(bx,{isOpen:m.isOpen,onClose:()=>{p({isOpen:!1,workflowId:null,workflowName:""})},onConfirm:()=>{m.workflowId&&g.mutate(m.workflowId)},title:"Delete Workflow",message:`Are you sure you want to delete "${m.workflowName}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",isLoading:g.isPending,variant:"danger",containedMode:!0})]})}function Cx({theme:e,config:t}){return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:e.primaryColor+"20"},children:$e.jsx(Nf,{className:"h-8 w-8",style:{color:e.primaryColor}})}),$e.jsx("h3",{className:`${t.textSize.title} font-semibold mb-2`,style:{fontFamily:e.fontFamily},children:"No call logs found"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,style:{fontFamily:e.fontFamily},children:"Try adjusting your filters or search terms."})]})})}function Tx({config:e}){return $e.jsx("div",{className:"flex justify-center py-4",children:$e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})})}function Px(){const{theme:e}=ns(),{width:t,containerRef:s}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),n=(e=>e<380?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-xs",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",filterPadding:"p-2",inputSize:"text-xs"}:e<450?{containerPadding:"p-3",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",filterPadding:"p-2",inputSize:"text-xs"}:e<600?{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-1 text-xs",headerPadding:"p-4",filterPadding:"p-3",inputSize:"text-sm"}:{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-2 text-sm",headerPadding:"p-4",filterPadding:"p-4",inputSize:"text-sm"})(t),r=Mg(),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(""),[u,h]=Oe.useState(""),[m,p]=Oe.useState(""),[f,g]=Oe.useState({search:c,status:u,carrier:"",dealStatus:m,dateRange:{start:"",end:""}});Oe.useEffect(()=>{g(e=>({...e,search:c,status:u,dealStatus:m}))},[c,u,m]);const y=Oe.useCallback((e,t)=>((e,t,s)=>new Promise(n=>{setTimeout(()=>{const r=[],a=(e-1)*t,i=["Swift Transportation","J.B. Hunt","Schneider","Werner Enterprises","C.R. England"],o=["New York, NY","Los Angeles, CA","Chicago, IL","Houston, TX","Phoenix, AZ"],l=["Miami, FL","Seattle, WA","Denver, CO","Atlanta, GA","Boston, MA"],c=["waiting","in-progress","completed","failed"],d=["pending","negotiating","agreed","declined"];for(let e=0;e<t;e++){const t=a+e;if(t>=100)break;const n=i[t%i.length],u=o[t%o.length],h=l[t%l.length],m=c[t%c.length],p=d[t%d.length];if(s.search&&!n.toLowerCase().includes(s.search.toLowerCase())&&!u.toLowerCase().includes(s.search.toLowerCase())&&!h.toLowerCase().includes(s.search.toLowerCase()))continue;if(s.status&&m!==s.status)continue;if(s.carrier&&!n.toLowerCase().includes(s.carrier.toLowerCase()))continue;if(s.dealStatus&&p!==s.dealStatus)continue;const f=new Date(Date.now()-30*Math.random()*24*60*60*1e3);s.dateRange.start&&f<new Date(s.dateRange.start)||s.dateRange.end&&f>new Date(s.dateRange.end)||r.push({id:`call-${t+1}`,carrierName:n,callDuration:Math.floor(30*Math.random())+5,maxDuration:45,callStatus:m,dealStatus:p,agreedRate:"agreed"===p?Math.floor(3e3*Math.random())+1500:null,contactInfo:`+1-555-${String(Math.floor(9e3*Math.random())+1e3)}`,notes:`Call notes for ${n}`})}n({data:r,hasMore:a+t<100,total:100})},300)}))(e,t,f),[f]),{data:x,loading:v,error:b,hasMore:w,loadMore:S,refresh:j}=wx({fetchData:y,pageSize:10,enabled:!0,dependencies:[f]}),k=Sx(S,w,v);return $e.jsxs("div",{ref:s,className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:[$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>i(!a),className:`w-full ${n.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Pf,{className:n.iconSize}),$e.jsx("span",{className:`${n.textSize.body} font-medium`,children:"Search Calls"})]}),a?$e.jsx(tf,{className:n.iconSize}):$e.jsx(Xp,{className:n.iconSize})]}),a&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:n.containerPadding,children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${n.iconSize} text-gray-400`}),$e.jsx("input",{type:"text",placeholder:"Search calls, carriers, locations...",value:c,onChange:e=>d(e.target.value),className:`w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${n.textSize.body}`}),c&&$e.jsx("button",{onClick:()=>d(""),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",children:$e.jsx(Uf,{className:n.iconSize})})]})})})]}),$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>l(!o),className:`w-full ${n.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(uf,{className:n.iconSize}),$e.jsx("span",{className:`${n.textSize.body} font-medium`,children:"Filters"}),(u||m)&&$e.jsx("span",{className:`${n.textSize.caption} bg-blue-100 text-blue-800 px-2 py-1 rounded-full`,children:u||m})]}),o?$e.jsx(tf,{className:n.iconSize}):$e.jsx(Xp,{className:n.iconSize})]}),o&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:n.containerPadding,children:$e.jsxs("div",{className:"space-y-3",children:[$e.jsxs("div",{children:[$e.jsx("label",{className:`block ${n.textSize.caption} font-medium text-gray-700 mb-2`,children:"Call Status"}),$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>h(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>h("waiting"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("waiting"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Waiting"}),$e.jsx("button",{onClick:()=>h("in-progress"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("in-progress"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"In Progress"}),$e.jsx("button",{onClick:()=>h("completed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("completed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Completed"}),$e.jsx("button",{onClick:()=>h("failed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("failed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Failed"})]})]}),$e.jsxs("div",{children:[$e.jsx("label",{className:`block ${n.textSize.caption} font-medium text-gray-700 mb-2`,children:"Deal Status"}),$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>p(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>p("pending"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("pending"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Pending"}),$e.jsx("button",{onClick:()=>p("negotiating"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("negotiating"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Negotiating"}),$e.jsx("button",{onClick:()=>p("agreed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("agreed"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Agreed"}),$e.jsx("button",{onClick:()=>p("declined"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("declined"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Declined"})]})]})]})})})]}),$e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[b&&$e.jsx("div",{className:"p-4",children:$e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[$e.jsxs("p",{className:"text-red-800 text-sm",children:["Failed to load call logs: ",b]}),$e.jsx(Ou,{onClick:j,className:"mt-2 text-sm bg-red-600 text-white hover:bg-red-700",children:"Retry"})]})}),b||0!==x.length||v?$e.jsxs("div",{className:`${n.containerPadding} ${n.spacing}`,children:[x.map(t=>$e.jsx(ax,{item:t,onViewDetails:()=>{return e=t.id,void r(`/call-logs/${e}`,{state:{callQueueItems:x,fromCallLogs:!0}});var e},theme:e},t.id)),v&&$e.jsx(Tx,{config:n}),$e.jsx("div",{ref:k,className:"h-4"})]}):$e.jsx(Cx,{theme:e,config:n})]})]})}const Ax={currentLead:null,emails:[],isLoading:!1,error:null,isSending:!1,sendError:null},Rx=Iu((e,t)=>({...Ax,setCurrentLead:t=>{e({currentLead:t})},fetchLeadEmails:async t=>{e({isLoading:!0,error:null});try{const s=[...(await zp.getLeadEmails(t)).emails].sort((e,t)=>new Date(e.receivedDatetime).getTime()-new Date(t.receivedDatetime).getTime());e({emails:s,isLoading:!1,error:null})}catch(s){console.error("Failed to fetch lead emails:",s),e({isLoading:!1,error:s.message||"Failed to fetch emails",emails:[]})}},sendReply:async(s,n,r,a)=>{e({isSending:!0,sendError:null});try{const i=await zp.sendEmailReply(s,n,r,a);if(i.success){const s=t().emails;return e({emails:[...s,i.email],isSending:!1,sendError:null}),!0}return e({isSending:!1,sendError:"Failed to send email"}),!1}catch(i){return console.error("Failed to send email:",i),e({isSending:!1,sendError:i.message||"Failed to send email"}),!1}},clearError:()=>{e({error:null,sendError:null})},reset:()=>{e(Ax)}}));var Mx,Dx={exports:{}};const $x=wy((Mx||(Mx=1,Dx.exports=function(){var e=1e3,t=6e4,s=36e5,n="millisecond",r="second",a="minute",i="hour",o="day",l="week",c="month",d="quarter",u="year",h="date",m="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],s=e%100;return"["+e+(t[(s-20)%10]||t[s]||t[0])+"]"}},y=function(e,t,s){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(s)+e},x={s:y,z:function(e){var t=-e.utcOffset(),s=Math.abs(t),n=Math.floor(s/60),r=s%60;return(t<=0?"+":"-")+y(n,2,"0")+":"+y(r,2,"0")},m:function e(t,s){if(t.date()<s.date())return-e(s,t);var n=12*(s.year()-t.year())+(s.month()-t.month()),r=t.clone().add(n,c),a=s-r<0,i=t.clone().add(n+(a?-1:1),c);return+(-(n+(s-r)/(a?r-i:i-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:u,w:l,d:o,D:h,h:i,m:a,s:r,ms:n,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},v="en",b={};b[v]=g;var w="$isDayjsObject",S=function(e){return e instanceof E||!(!e||!e[w])},j=function e(t,s,n){var r;if(!t)return v;if("string"==typeof t){var a=t.toLowerCase();b[a]&&(r=a),s&&(b[a]=s,r=a);var i=t.split("-");if(!r&&i.length>1)return e(i[0])}else{var o=t.name;b[o]=t,r=o}return!n&&r&&(v=r),r||!n&&v},k=function(e,t){if(S(e))return e.clone();var s="object"==typeof t?t:{};return s.date=e,s.args=arguments,new E(s)},N=x;N.l=j,N.i=S,N.w=function(e,t){return k(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=j(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=g.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,s=e.utc;if(null===t)return new Date(NaN);if(N.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(p);if(n){var r=n[2]-1||0,a=(n[7]||"0").substring(0,3);return s?new Date(Date.UTC(n[1],r,n[3]||1,n[4]||0,n[5]||0,n[6]||0,a)):new Date(n[1],r,n[3]||1,n[4]||0,n[5]||0,n[6]||0,a)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return N},y.isValid=function(){return!(this.$d.toString()===m)},y.isSame=function(e,t){var s=k(e);return this.startOf(t)<=s&&s<=this.endOf(t)},y.isAfter=function(e,t){return k(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<k(e)},y.$g=function(e,t,s){return N.u(e)?this[t]:this.set(s,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var s=this,n=!!N.u(t)||t,d=N.p(e),m=function(e,t){var r=N.w(s.$u?Date.UTC(s.$y,t,e):new Date(s.$y,t,e),s);return n?r:r.endOf(o)},p=function(e,t){return N.w(s.toDate()[e].apply(s.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(t)),s)},f=this.$W,g=this.$M,y=this.$D,x="set"+(this.$u?"UTC":"");switch(d){case u:return n?m(1,0):m(31,11);case c:return n?m(1,g):m(0,g+1);case l:var v=this.$locale().weekStart||0,b=(f<v?f+7:f)-v;return m(n?y-b:y+(6-b),g);case o:case h:return p(x+"Hours",0);case i:return p(x+"Minutes",1);case a:return p(x+"Seconds",2);case r:return p(x+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var s,l=N.p(e),d="set"+(this.$u?"UTC":""),m=(s={},s[o]=d+"Date",s[h]=d+"Date",s[c]=d+"Month",s[u]=d+"FullYear",s[i]=d+"Hours",s[a]=d+"Minutes",s[r]=d+"Seconds",s[n]=d+"Milliseconds",s)[l],p=l===o?this.$D+(t-this.$W):t;if(l===c||l===u){var f=this.clone().set(h,1);f.$d[m](p),f.init(),this.$d=f.set(h,Math.min(this.$D,f.daysInMonth())).$d}else m&&this.$d[m](p);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[N.p(e)]()},y.add=function(n,d){var h,m=this;n=Number(n);var p=N.p(d),f=function(e){var t=k(m);return N.w(t.date(t.date()+Math.round(e*n)),m)};if(p===c)return this.set(c,this.$M+n);if(p===u)return this.set(u,this.$y+n);if(p===o)return f(1);if(p===l)return f(7);var g=(h={},h[a]=t,h[i]=s,h[r]=e,h)[p]||1,y=this.$d.getTime()+n*g;return N.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,s=this.$locale();if(!this.isValid())return s.invalidDate||m;var n=e||"YYYY-MM-DDTHH:mm:ssZ",r=N.z(this),a=this.$H,i=this.$m,o=this.$M,l=s.weekdays,c=s.months,d=s.meridiem,u=function(e,s,r,a){return e&&(e[s]||e(t,n))||r[s].slice(0,a)},h=function(e){return N.s(a%12||12,e,"0")},p=d||function(e,t,s){var n=e<12?"AM":"PM";return s?n.toLowerCase():n};return n.replace(f,function(e,n){return n||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return N.s(t.$y,4,"0");case"M":return o+1;case"MM":return N.s(o+1,2,"0");case"MMM":return u(s.monthsShort,o,c,3);case"MMMM":return u(c,o);case"D":return t.$D;case"DD":return N.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return u(s.weekdaysMin,t.$W,l,2);case"ddd":return u(s.weekdaysShort,t.$W,l,3);case"dddd":return l[t.$W];case"H":return String(a);case"HH":return N.s(a,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return p(a,i,!0);case"A":return p(a,i,!1);case"m":return String(i);case"mm":return N.s(i,2,"0");case"s":return String(t.$s);case"ss":return N.s(t.$s,2,"0");case"SSS":return N.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(n,h,m){var p,f=this,g=N.p(h),y=k(n),x=(y.utcOffset()-this.utcOffset())*t,v=this-y,b=function(){return N.m(f,y)};switch(g){case u:p=b()/12;break;case c:p=b();break;case d:p=b()/3;break;case l:p=(v-x)/6048e5;break;case o:p=(v-x)/864e5;break;case i:p=v/s;break;case a:p=v/t;break;case r:p=v/e;break;default:p=v}return m?p:N.a(p)},y.daysInMonth=function(){return this.endOf(c).$D},y.$locale=function(){return b[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var s=this.clone(),n=j(e,t,!0);return n&&(s.$L=n),s},y.clone=function(){return N.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),C=E.prototype;return k.prototype=C,[["$ms",n],["$s",r],["$m",a],["$H",i],["$W",o],["$M",c],["$y",u],["$D",h]].forEach(function(e){C[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),k.extend=function(e,t){return e.$i||(e(t,E,k),e.$i=!0),k},k.locale=j,k.isDayjs=S,k.unix=function(e){return k(1e3*e)},k.en=b[v],k.Ls=b,k.p={},k}()),Dx.exports)),Ox={new:"bg-green-500 text-white",qualified:"bg-blue-500 text-white",contacted:"bg-yellow-500 text-white",rejected:"bg-red-500 text-white"};function Fx({item:e,onViewClick:t,theme:s}){const n=s.primaryColor||"#1e40af",r=e.pickupTimestamp?$x(e.pickupTimestamp).format("MMM DD, YYYY"):"-",a=e.deliveryTimestamp?$x(e.deliveryTimestamp).format("MMM DD, YYYY"):"-";return $e.jsxs(pd.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"bg-white rounded-lg border-l-4 shadow-sm overflow-hidden cursor-pointer hover:shadow-md transition-shadow",style:{borderLeftColor:n},onClick:t,children:[$e.jsxs("div",{className:"px-4 py-3",children:[$e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[$e.jsxs("div",{className:"flex items-center gap-3",children:[$e.jsx("span",{className:"text-base font-semibold",style:{color:n},children:e.shipperName||"Unknown Shipper"}),e.shipperCompanyName&&$e.jsxs("span",{className:"text-xs text-gray-500",children:["(",e.shipperCompanyName,")"]})]}),$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("span",{className:`text-xs px-2 py-1 rounded font-medium capitalize ${Ox[e.status]}`,children:e.status}),e.isDuplicate&&$e.jsx("span",{className:"text-xs px-2 py-1 rounded font-medium bg-orange-100 text-orange-700",children:"Duplicate"})]})]}),$e.jsx("p",{className:"text-sm text-gray-700 mb-3 line-clamp-1",children:e.emailSubject}),$e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-y-2 text-xs text-gray-600",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 text-green-500"}),$e.jsx("span",{className:"truncate",title:e.origin,children:e.origin})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 rotate-180 text-red-500"}),$e.jsx("span",{className:"truncate",title:e.destination,children:e.destination})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:r})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:a})]}),e.loadType&&$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(kf,{className:"w-3 h-3"}),$e.jsx("span",{children:e.loadType})]}),e.modeOfService&&$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:"w-3 h-3"}),$e.jsx("span",{children:e.modeOfService})]})]}),(e.grossWeight||e.numberOfPallets)&&$e.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-gray-500",children:[e.grossWeight&&$e.jsxs("span",{children:["Weight: ",e.grossWeight.toLocaleString()," lbs"]}),e.numberOfPallets&&$e.jsxs("span",{children:["Pallets: ",e.numberOfPallets]})]})]}),$e.jsxs("div",{className:"flex justify-between items-center px-4 pb-3",children:[$e.jsx("span",{className:"text-xs text-gray-400",children:$x(e.createdAt).format("MMM DD, YYYY h:mm A")}),$e.jsxs("button",{onClick:e=>{e.stopPropagation(),t()},className:"flex items-center gap-2 px-3 py-1.5 rounded text-white text-xs font-medium",style:{backgroundColor:n},children:[$e.jsx(yf,{className:"w-3.5 h-3.5"}),$e.jsx("span",{children:"View Details"})]})]})]})}function zx({label:e,active:t,onClick:s,onRemove:n,primaryColor:r}){return $e.jsxs("button",{onClick:s,className:"px-3 py-1.5 rounded text-xs font-medium border transition-colors flex items-center gap-1 "+(t?"text-white border-transparent":"text-gray-700 border-gray-300 bg-white hover:bg-gray-50"),style:t?{backgroundColor:r}:void 0,children:[e,t&&n&&$e.jsx(Uf,{className:"w-3 h-3 ml-1",onClick:e=>{e.stopPropagation(),n()}})]})}function Lx({currentPage:e,totalPages:t,onPageChange:s,primaryColor:n}){const r=[];if(t<=5)for(let a=1;a<=t;a++)r.push(a);else{r.push(1),e>3&&r.push(-1);const s=Math.max(2,e-1),n=Math.min(t-1,e+1);for(let e=s;e<=n;e++)r.push(e);e<t-2&&r.push(-1),r.push(t)}return $e.jsxs("div",{className:"flex items-center justify-center gap-1 py-3",children:[$e.jsx("button",{onClick:()=>s(e-1),disabled:1===e,className:"p-1 rounded hover:bg-gray-100 disabled:opacity-50",children:$e.jsx(Zp,{className:"w-4 h-4"})}),r.map((t,r)=>-1===t?$e.jsx("span",{className:"px-2 text-gray-400",children:".."},`ellipsis-${r}`):$e.jsx("button",{onClick:()=>s(t),className:"w-7 h-7 rounded text-xs font-medium "+(e===t?"text-white":"text-gray-700 hover:bg-gray-100"),style:e===t?{backgroundColor:n}:void 0,children:t},t)),$e.jsx("button",{onClick:()=>s(e+1),disabled:e===t,className:"p-1 rounded hover:bg-gray-100 disabled:opacity-50",children:$e.jsx(ef,{className:"w-4 h-4"})})]})}function Ix({count:e,onDismiss:t,onRefresh:s,primaryColor:n}){return $e.jsxs(pd.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"mx-4 mb-3 p-3 rounded-lg flex items-center justify-between",style:{backgroundColor:`${n}15`,border:`1px solid ${n}40`},children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Qp,{className:"w-4 h-4",style:{color:n}}),$e.jsxs("span",{className:"text-sm font-medium",style:{color:n},children:[e," new email lead",e>1?"s":""," received!"]})]}),$e.jsx("div",{className:"flex items-center gap-2",children:$e.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 rounded",children:$e.jsx(Uf,{className:"w-4 h-4 text-gray-500"})})})]})}function _x(){const{theme:e,isOpen:t}=ns(),s=Mg(),[n,r]=Oe.useState(""),{leads:a,totalCount:i,currentPage:o,pageSize:l,isLoading:c,error:d,dateFilter:u,hasNewLeads:h,newLeadsCount:m,showNewLeadsAlert:p,fetchLeads:f,setPage:g,setSearchQuery:y,setDateFilter:x,startPolling:v,stopPolling:b,clearNewLeadsNotification:w,acknowledgeNewLeads:S}=Ip(),{setCurrentLead:j}=Rx(),k=Oe.useCallback(e=>{j(e),s(`/email-leads/${e.id}`)},[s,j]),N=((e,t=300)=>{const[s,n]=Oe.useState(e);return Oe.useEffect(()=>{const s=setTimeout(()=>n(e),t);return()=>clearTimeout(s)},[e,t]),s})(n,500);Oe.useEffect(()=>{f()},[]),Oe.useEffect(()=>{y(N),""!==N&&f({search:N,page:1})},[N]),Oe.useEffect(()=>(v(),()=>b()),[]);const E=Math.ceil(i/l),C=e.primaryColor||"#1e40af",T=Oe.useCallback(e=>{x(e)},[x]),P=Oe.useCallback(()=>{w(),f({page:1})},[w,f]);return $e.jsxs("div",{className:"flex flex-col h-full bg-white",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 border-b",children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),$e.jsx("input",{type:"text",placeholder:"Search by subject, shipper, origin, destination...",value:n,onChange:e=>r(e.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2",style:{"--tw-ring-color":C},onFocus:e=>e.currentTarget.style.boxShadow=`0 0 0 2px ${C}40`,onBlur:e=>e.currentTarget.style.boxShadow=""})]})}),$e.jsx("div",{className:"px-4 py-3 border-b flex gap-2 overflow-x-auto",children:[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"all",label:"All"}].map(e=>$e.jsx(zx,{label:e.label,active:u===e.id,onClick:()=>T(e.id),onRemove:u===e.id&&"all"!==e.id?()=>T("all"):void 0,primaryColor:C},e.id))}),$e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between ",children:[$e.jsxs("h2",{className:"text-base font-semibold text-gray-900",children:["Load Requests ",i>0&&$e.jsxs("span",{className:"text-gray-500 font-normal",children:["(",i,")"]})]}),c&&$e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"})]}),$e.jsx(gi,{children:p&&t&&$e.jsx(Ix,{count:m,onDismiss:S,onRefresh:P,primaryColor:C})}),d&&$e.jsxs("div",{className:"mx-4 mb-3 p-3 bg-red-50 border border-red-200 rounded-lg",children:[$e.jsx("p",{className:"text-sm text-red-600",children:d}),$e.jsx("button",{onClick:()=>f(),className:"mt-2 text-xs text-red-700 underline",children:"Try again"})]}),$e.jsx("div",{className:"flex-1 overflow-hidden relative",children:c||0!==a.length?$e.jsx("div",{className:"h-full overflow-y-auto px-4 space-y-3 pb-8",children:$e.jsx(gi,{initial:!1,children:a.map(t=>$e.jsx(Fx,{item:t,theme:e,onViewClick:()=>k(t)},t.id))})}):$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500 p-8 text-center",children:[$e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4",children:$e.jsx(yf,{className:"h-8 w-8 text-gray-400"})}),$e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-1",children:"No email leads found"}),$e.jsx("p",{className:"text-sm",children:"Try adjusting your filters or search terms"})]})}),a.length>0&&E>1&&$e.jsx(Lx,{currentPage:o,totalPages:E,onPageChange:g,primaryColor:C})]})}const Vx={new:"bg-green-500 text-white",qualified:"bg-blue-500 text-white",contacted:"bg-yellow-500 text-white",rejected:"bg-red-500 text-white"};function Bx(e){return e?$x(e).format("MMM DD, YYYY"):"-"}function qx({lead:e,theme:t}){const s=t.primaryColor||"#1e40af";return console.log("Lead",e),$e.jsx("div",{className:"bg-white rounded-lg border-l-4 shadow-sm overflow-hidden",style:{borderLeftColor:s},children:$e.jsxs("div",{className:"px-4 py-3",children:[$e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[$e.jsxs("div",{className:"flex items-center gap-3",children:[$e.jsx("span",{className:"text-base font-semibold",style:{color:s},children:e.shipperName||"Unknown Shipper"}),$e.jsx(yf,{className:"w-4 h-4 text-gray-400"})]}),$e.jsx("div",{className:"flex items-center gap-2",children:$e.jsx("span",{className:`text-xs px-2 py-1 rounded font-medium ${Vx[e.status]}`,children:e.status.charAt(0).toUpperCase()+e.status.slice(1)})})]}),$e.jsxs("div",{className:"grid grid-cols-3 gap-y-2 text-xs text-gray-600",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3"}),$e.jsx("span",{className:"truncate",children:e.origin||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 rotate-90"}),$e.jsx("span",{className:"truncate",children:e.destination||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:Bx(e.pickupTimestamp)})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:Bx(e.deliveryTimestamp)})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:"w-3 h-3"}),$e.jsx("span",{children:e.modeOfService||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(kf,{className:"w-3 h-3"}),$e.jsx("span",{children:e.loadType||"-"})]})]})]})})}function Ux({activeTab:e,onTabChange:t,theme:s}){const n=s.primaryColor||"#1e40af",r=s.headerBg||"#1f2937";return $e.jsxs("div",{className:"grid grid-cols-2",children:[$e.jsxs("button",{onClick:()=>t("shipper"),className:"px-5 py-3 flex items-center justify-center gap-2",style:"shipper"===e?{backgroundColor:`${n}15`,color:n,borderBottom:`2px solid ${n}`}:{backgroundColor:"#f9fafb",color:"#4b5563"},children:[$e.jsx(yf,{className:"w-4 h-4"}),$e.jsx("span",{className:"text-sm font-medium",children:"Shipper Email"})]}),$e.jsxs("button",{onClick:()=>t("carrier"),className:"px-5 py-3 flex items-center justify-center gap-2",style:"carrier"===e?{backgroundColor:r,color:"#ffffff"}:{backgroundColor:"#f9fafb",color:"#4b5563"},children:[$e.jsx(yf,{className:"w-4 h-4"}),$e.jsx("span",{className:"text-sm font-medium",children:"Carrier Email"})]})]})}function Wx({emails:e,lead:t,theme:s,isLoading:n,error:r,onSendReply:a,isSending:i}){var o,l;const c=s.primaryColor||"#1e40af",[d,u]=Oe.useState(""),[h,m]=Oe.useState(!1);return n?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(ff,{className:"w-8 h-8 animate-spin text-gray-400 mb-3"}),$e.jsx("p",{className:"text-sm text-gray-500",children:"Loading emails..."})]}):r?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(sf,{className:"w-8 h-8 text-red-400 mb-3"}),$e.jsx("p",{className:"text-sm text-red-500",children:r})]}):0===e.length?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(yf,{className:"w-12 h-12 text-gray-300 mb-3"}),$e.jsx("p",{className:"text-sm text-gray-500",children:"No emails found"})]}):$e.jsxs("div",{className:"flex flex-col h-full",children:[$e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[$e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[$e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${c}15`},children:$e.jsx(yf,{className:"w-5 h-5",style:{color:c}})}),$e.jsxs("div",{className:"flex-1",children:[$e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:(null==(o=e[0])?void 0:o.subject)||"No Subject"}),$e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[t.shipperName," • ",t.origin," → ",t.destination]})]})]}),$e.jsx("div",{className:"space-y-4",children:e.map((e,t)=>{var s,n,r;const a="outgoing"===(null==(s=e.metadata)?void 0:s.direction),i=(null==(r=null==(n=e.senderEmail)?void 0:n.split("@")[0])?void 0:r.slice(0,2).toUpperCase())||"U";return $e.jsxs(pd.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1*t},className:"rounded-lg border "+(a?"border-blue-200 bg-blue-50":"border-gray-200 bg-white"),children:[$e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100 flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:a?"#3b82f6":c},children:i}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-sm font-medium text-gray-900",children:e.senderEmail}),$e.jsxs("p",{className:"text-xs text-gray-500",children:["To: ",e.receiverEmail]})]})]}),$e.jsx("span",{className:"text-xs text-gray-400",children:(o=e.receivedDatetime,$x(o).format("MMM DD, YYYY h:mm A"))})]}),$e.jsx("div",{className:"px-4 py-3",children:e.bodyHtml?$e.jsx("div",{className:"text-sm text-gray-700 prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.bodyHtml}}):$e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:e.bodyText})})]},e.id);var o})})]}),$e.jsx("div",{className:"flex-shrink-0 border-t bg-white",children:$e.jsxs("div",{className:"mx-4 my-3 rounded-lg border border-gray-200 overflow-hidden",children:[$e.jsx(gi,{children:h&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},children:$e.jsxs("div",{className:"p-4 space-y-3",children:[$e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:["Replying to: ",null==(l=e[e.length-1])?void 0:l.senderEmail]}),$e.jsx("textarea",{value:d,onChange:e=>u(e.target.value),placeholder:"Type your reply...",className:"w-full p-3 border border-gray-200 rounded-lg resize-none text-sm min-h-[120px] focus:outline-none focus:ring-2 focus:ring-blue-500"}),$e.jsxs("div",{className:"flex gap-2",children:[$e.jsxs("button",{onClick:async()=>{if(!d.trim())return;const e=`<p>${d.replace(/\n/g,"<br/>")}</p>`;await a(e),u(""),m(!1)},disabled:!d.trim()||i,className:"px-4 py-2 rounded text-white text-sm font-medium disabled:opacity-50 flex items-center gap-2",style:{backgroundColor:c},children:[i&&$e.jsx(ff,{className:"w-4 h-4 animate-spin"}),i?"Sending...":"Send"]}),$e.jsx("button",{onClick:()=>{u(""),m(!1)},className:"px-4 py-2 rounded text-gray-600 text-sm font-medium border border-gray-200 hover:bg-gray-50",children:"Cancel"})]})]})})}),!h&&$e.jsx("div",{className:"px-4 py-3 bg-gray-50 flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>m(!h),className:"flex items-center gap-2 text-sm font-medium text-white px-3 py-1.5 rounded",style:{backgroundColor:c},children:[$e.jsx(Tf,{className:"w-4 h-4"}),$e.jsx("span",{children:"Reply"})]})})]})})]})}function Hx({theme:e}){const t=e.primaryColor||"#1e40af";return $e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:`${t}15`},children:$e.jsx(yf,{className:"w-8 h-8",style:{color:t}})}),$e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Feature Coming Soon"}),$e.jsx("p",{className:"text-sm text-gray-500 text-center max-w-xs",children:"Carrier email integration is currently under development. Stay tuned for updates!"})]})}function Kx(){const{theme:e}=ns(),{leadId:t}=Dg(),s=Mg(),[n,r]=Oe.useState("shipper"),{currentLead:a,emails:i,isLoading:o,error:l,isSending:c,fetchLeadEmails:d,sendReply:u,reset:h}=Rx();Oe.useEffect(()=>(t&&d(t),()=>{}),[t,d]);return a||o?$e.jsxs("div",{className:"flex flex-col h-full bg-gray-50",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 bg-white border-b flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>s("/email-leads"),className:"flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900",children:[$e.jsx(Kp,{className:"w-4 h-4"}),$e.jsx("span",{children:"Back"})]})}),$e.jsxs("div",{className:"p-4",children:[a&&$e.jsx(qx,{lead:a,theme:e}),$e.jsx("div",{className:"mt-3 bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden",children:$e.jsx(Ux,{activeTab:n,onTabChange:r,theme:e})})]}),$e.jsx("div",{className:"flex-1 overflow-hidden mx-4 mb-4 bg-white rounded-lg border border-gray-200 shadow-sm",children:"shipper"===n?$e.jsx(Wx,{emails:i,lead:a,theme:e,isLoading:o,error:l,onSendReply:async e=>{var t,s,n;if(!i.length||!a)return;const r=null==(t=i[0])?void 0:t.conversationId,o=a.shipperEmail||(null==(s=i[0])?void 0:s.senderEmail),l=(null==(n=i[0])?void 0:n.subject)||"No Subject",c=l.startsWith("Re: ")?l:`Re: ${l}`;r&&o&&await u([o],r,c,e)},isSending:c}):$e.jsx(Hx,{theme:e})})]}):$e.jsxs("div",{className:"flex flex-col h-full bg-gray-50",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 bg-white border-b flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>s(-1),className:"flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900",children:[$e.jsx(Kp,{className:"w-4 h-4"}),$e.jsx("span",{children:"Back"})]})}),$e.jsx("div",{className:"flex-1 flex items-center justify-center",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx(sf,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),$e.jsx("p",{className:"text-gray-500",children:"Lead data not found. Please go back and try again."})]})})]})}class Yx{static async getEmailsClassifiedTodayCount(){return(await Mp.get("/crm/emails/me/metric/clasified_today_count")).data}static async getLeadsTodayCount(){return(await Mp.get("/crm/leads/me/leads/count_today")).data}static async getLeadsTillDateCount(){return(await Mp.get("/crm/leads/me/leads/count_till_date")).data}static async getDashboardStats(){const[e,t,s]=await Promise.all([this.getEmailsClassifiedTodayCount(),this.getLeadsTodayCount(),this.getLeadsTillDateCount()]);return{emailsClassifiedToday:e.count??0,leadsToday:t.count??0,leadsTillDate:s.count??0}}}function Qx({title:e,value:t,borderColor:s,iconBg:n,iconColor:r,valueColor:a}){return $e.jsxs("div",{className:"bg-white rounded-lg p-3 border-l-4 shadow-sm",style:{borderLeftColor:s},children:[$e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[$e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:n},children:$e.jsx(Af,{className:"w-3 h-3",style:{color:r}})}),$e.jsx("span",{className:"text-xs text-gray-600 leading-tight",children:e})]}),$e.jsx("div",{className:"border-t border-gray-100 pt-2",children:$e.jsx("span",{className:"text-xl font-bold",style:{color:a||s},children:t})})]})}function Gx({primaryColor:e}){const t=(()=>{const e=[];for(let t=0;t<35;t++){const t=Math.random();e.push(t)}return e})();return $e.jsx("div",{className:"grid grid-cols-7 gap-1",children:t.map((t,s)=>$e.jsx("div",{className:"w-4 h-4 rounded-sm",style:{backgroundColor:t>.7?e:t>.4?`${e}99`:t>.2?`${e}44`:"#e5e7eb"}},s))})}function Jx(){var e;const{theme:t,user:s}=ns();Mg();const[n,r]=Oe.useState(null),[a,i]=Oe.useState(!1),o=(new Date).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),l=t.primaryColor||"#1e40af",c=(null==(e=null==s?void 0:s.email)?void 0:e.split("@")[0])||"User",d=c.charAt(0).toUpperCase()+c.slice(1);return Oe.useEffect(()=>{let e=!0;return i(!0),Yx.getDashboardStats().then(t=>{e&&r(t)}).catch(()=>{e&&r({emailsClassifiedToday:0,leadsToday:0,leadsTillDate:0})}).finally(()=>{e&&i(!1)}),()=>{e=!1}},[]),$e.jsxs("div",{className:"flex flex-col h-full bg-white overflow-y-auto",style:{fontFamily:t.fontFamily},children:[$e.jsxs("div",{className:"px-5 py-4",children:[$e.jsxs("h1",{className:"text-lg text-gray-800",children:["Hello ",$e.jsx("span",{className:"font-semibold",children:d}),","]}),$e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mt-1",children:"Let's check new email for today"}),$e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:o})]}),$e.jsx("div",{className:"px-5 pb-6 space-y-5",children:$e.jsxs("div",{children:[$e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-3",children:"Email Leads Agents"}),$e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[$e.jsx(Qx,{title:"Leads Till Date",value:(null==n?void 0:n.leadsTillDate)??"—",borderColor:l,iconBg:`${l}15`,iconColor:l,valueColor:l}),$e.jsx(Qx,{title:"Leads Today",value:n?`${n.leadsToday}`:"—",borderColor:"#ef4444",iconBg:"#fef2f2",iconColor:"#ef4444",valueColor:"#ef4444"}),$e.jsx(Qx,{title:"Emails Classified Today",value:(null==n?void 0:n.emailsClassifiedToday)??"—",borderColor:"#ef4444",iconBg:"#fef2f2",iconColor:"#ef4444",valueColor:"#ef4444"})]}),$e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[$e.jsx(Qx,{title:"Quotes Won",value:"—",borderColor:"#22c55e",iconBg:"#f0fdf4",iconColor:"#22c55e",valueColor:"#22c55e"}),$e.jsx("div",{style:{borderLeftColor:l},className:"bg-white col-span-2 rounded-lg p-3 border border-gray-100 shadow-sm border-l-4",children:$e.jsxs("div",{className:"flex items-start gap-3",children:[$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[$e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:`${l}15`},children:$e.jsx(zf,{className:"w-3 h-3",style:{color:l}})}),$e.jsx("span",{className:"text-xs text-gray-600",children:"Conversions this month"})]}),$e.jsx("div",{className:"mt-2",children:$e.jsx("span",{className:"text-xl font-bold",style:{color:l},children:"—"})})]}),$e.jsx("div",{className:"flex-shrink-0",children:$e.jsx(Gx,{primaryColor:l})})]})})]}),$e.jsx("div",{className:"grid grid-cols-2 gap-3",children:$e.jsx(Qx,{title:"Time Saved",value:"—",borderColor:l,iconBg:`${l}15`,iconColor:l,valueColor:l})})]})})]})}function Xx(){return $e.jsxs(Yg,{children:[$e.jsx(Hg,{path:"/",element:$e.jsx(Jx,{})}),$e.jsx(Hg,{path:"/search",element:$e.jsx(tx,{})}),$e.jsx(Hg,{path:"/results",element:$e.jsx(cx,{})}),$e.jsx(Hg,{path:"/call-details/:callId",element:$e.jsx(vx,{})}),$e.jsx(Hg,{path:"/call-logs/:callId",element:$e.jsx(vx,{})}),$e.jsx(Hg,{path:"/history",element:$e.jsx(Ex,{})}),$e.jsx(Hg,{path:"/call-logs",element:$e.jsx(Px,{})}),$e.jsx(Hg,{path:"/email-leads",element:$e.jsx(_x,{})}),$e.jsx(Hg,{path:"/email-leads/:leadId",element:$e.jsx(Kx,{})}),$e.jsx(Hg,{path:"*",element:$e.jsx(Wg,{to:"/",replace:!0})})]})}class Zx extends Oe.Component{constructor(e){super(e),Ce(this,"handleReset",()=>{this.setState({hasError:!1,error:void 0})}),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught an error:",e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:$e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:$e.jsxs(By,{className:"p-6 max-w-md w-full text-center",children:[$e.jsx("div",{className:"flex justify-center mb-4",children:$e.jsx(Lf,{className:"h-12 w-12 text-red-500"})}),$e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Something went wrong"}),$e.jsx("p",{className:"text-gray-600 mb-4 text-sm",children:"An error occurred while loading this page. Please try again."}),$e.jsxs("div",{className:"space-y-2",children:[$e.jsx(Ou,{onClick:this.handleReset,className:"w-full",children:"Try Again"}),$e.jsx(Ou,{variant:"outline",onClick:()=>window.location.reload(),className:"w-full",children:"Reload Page"})]}),"development"===process.env.NODE_ENV&&this.state.error&&$e.jsxs("details",{className:"mt-4 text-left",children:[$e.jsx("summary",{className:"cursor-pointer text-sm text-gray-500",children:"Error Details"}),$e.jsx("pre",{className:"mt-2 text-xs bg-gray-100 p-2 rounded overflow-auto",children:this.state.error.stack})]})]})}):this.props.children}}class ev{static async login2FA(e,t){var s,n,r;try{return(await Mp.post("/workspace/users/tenant/application/2_fa_auth",{email:e,tenant_id:t})).data}catch(a){if(console.log("Login 2FA Error:",a),404===(null==(s=a.response)?void 0:s.status))throw new Error("User not found");if(null==(r=null==(n=a.response)?void 0:n.data)?void 0:r.detail)throw new Error(a.response.data.detail);throw new Error("Failed to send OTP. Please try again.")}}static async verifyOTP(e,t,s){var n,r,a,i;try{const n=await Mp.post("/workspace/users/tenant/application/otp_validate",{email:e,tenant_id:t,otp:s});return console.log("Verify OTP Response:",n.data),n.data}catch(o){if(400===(null==(n=o.response)?void 0:n.status)||401===(null==(r=o.response)?void 0:r.status))throw new Error("Invalid or expired OTP");if(null==(i=null==(a=o.response)?void 0:a.data)?void 0:i.detail)throw new Error(o.response.data.detail);throw new Error("Failed to verify OTP. Please try again.")}}}function tv(){const{theme:e}=ns();return $e.jsx("div",{className:"flex-shrink-0 py-2 px-4 text-center",style:{fontFamily:e.fontFamily},children:$e.jsxs("p",{className:"text-xs text-right text-gray-500",children:["Powered by"," ",$e.jsx("span",{className:"font-medium",style:{color:e.primaryColor},children:"Pangents AI"})]})})}function sv({onAuthSuccess:e}){const{theme:t,tenantId:s,email:n}=ns(),[r,a]=Oe.useState({step:"email",email:n||"",otp:"",isLoading:!1,error:null,otpSent:!1,countdown:0}),i=Oe.useRef(null),o=Oe.useRef(null),l=Oe.useRef(null);Oe.useEffect(()=>{var e,t;"email"===r.step?null==(e=i.current)||e.focus():"otp"===r.step&&(null==(t=o.current)||t.focus())},[r.step]),Oe.useEffect(()=>(r.countdown>0&&(l.current=setTimeout(()=>{a(e=>({...e,countdown:e.countdown-1}))},1e3)),()=>{l.current&&clearTimeout(l.current)}),[r.countdown]);const c=async e=>{var t,n,i;if(e.preventDefault(),i=r.email,/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))if(a(e=>({...e,isLoading:!0,error:null})),s)try{await ev.login2FA(r.email,s);a(e=>({...e,step:"otp",isLoading:!1,otpSent:!0,countdown:60}))}catch(o){console.log("Login 2FA Error:",null==(t=o.response)?void 0:t.data);let e="Failed to send OTP. Please try again.";404===(null==(n=o.response)?void 0:n.status)?e="User not found. Please check your email address.":o.message&&(e=o.message),a(t=>({...t,isLoading:!1,error:e}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}));else a(e=>({...e,error:"Please enter a valid email address"}))},d=async t=>{var n,i;if(t.preventDefault(),i=r.otp,/^\d{6}$/.test(i))if(a(e=>({...e,isLoading:!0,error:null})),s)try{const t=await ev.verifyOTP(r.email,s,r.otp);console.log("Verify OTP Response:",t),yp(t.data.bearer),jp(),a(e=>({...e,step:"success",isLoading:!1})),setTimeout(()=>{e(r.email,t.data.bearer)},1500)}catch(o){let e="Invalid OTP. Please try again.";400===(null==(n=o.response)?void 0:n.status)?e="Invalid or expired OTP. Please try again.":o.message&&(e=o.message),a(t=>({...t,isLoading:!1,error:e}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}));else a(e=>({...e,error:"Please enter a valid 6-digit OTP"}))},u=async()=>{var e;if(!(r.countdown>0))if(a(e=>({...e,isLoading:!0,error:null})),s)try{await ev.login2FA(r.email,s);a(e=>({...e,isLoading:!1,countdown:60,error:null}))}catch(t){let s="Failed to resend OTP. Please try again.";404===(null==(e=t.response)?void 0:e.status)?s="User not found. Please check your email address.":t.message&&(s=t.message),a(e=>({...e,isLoading:!1,error:s}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}))},h=()=>{a(e=>({...e,step:"email",otp:"",error:null,otpSent:!1,countdown:0}))};return $e.jsxs("div",{className:"flex flex-col h-full w-full",style:{fontFamily:t.fontFamily},children:[$e.jsx("div",{className:"flex-1 flex items-center justify-center px-6 py-8 w-full",children:$e.jsxs("div",{className:"w-full max-w-md mx-auto",children:[$e.jsxs(gi,{mode:"wait",children:["email"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:"space-y-6",children:[$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(yf,{className:"h-8 w-8",style:{color:t.primaryColor}})}),$e.jsx("h2",{className:"text-xl font-semibold",style:{fontFamily:t.fontFamily,color:t.headerBg},children:"Welcome Back"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"Enter your email address to continue"})]}),$e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[$e.jsx("div",{children:$e.jsx(qy,{ref:i,type:"email",value:r.email,onChange:e=>a(t=>({...t,email:e.target.value,error:null})),placeholder:"Enter your email address",disabled:r.isLoading,className:"w-full",style:{fontFamily:t.fontFamily},"aria-label":"Email address"})}),$e.jsx(Ou,{type:"submit",disabled:!r.email||r.isLoading,className:"w-full flex items-center justify-center gap-2",style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:r.isLoading?$e.jsx(ff,{className:"h-4 w-4 animate-spin text-white"}):$e.jsxs($e.Fragment,{children:["Continue",$e.jsx(Yp,{className:"h-4 w-4"})]})})]})]},"email"),"otp"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:"space-y-6",children:[$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(Mf,{className:"h-8 w-8",style:{color:t.primaryColor}})}),$e.jsx("h2",{className:"text-xl font-semibold",style:{fontFamily:t.fontFamily,color:t.headerBg},children:"Verify Your Email"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"We've sent a 6-digit code to"}),$e.jsx("p",{className:"font-medium text-sm",style:{fontFamily:t.fontFamily,color:t.primaryColor},children:r.email})]}),$e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[$e.jsx("div",{children:$e.jsx(qy,{ref:o,type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:r.otp,onChange:e=>{const t=e.target.value.replace(/\D/g,"");a(e=>({...e,otp:t,error:null}))},placeholder:"Enter 6-digit code",disabled:r.isLoading,className:"w-full text-center text-lg tracking-widest",style:{fontFamily:t.fontFamily},"aria-label":"One-time password"})}),$e.jsx(Ou,{type:"submit",disabled:6!==r.otp.length||r.isLoading,className:"w-full flex items-center justify-center gap-2",style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:r.isLoading?$e.jsx(ff,{className:"h-4 w-4 animate-spin text-white"}):$e.jsxs($e.Fragment,{children:["Verify Code",$e.jsx(Yp,{className:"h-4 w-4"})]})})]}),$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("p",{className:"text-sm text-gray-600",style:{fontFamily:t.fontFamily},children:"Didn't receive the code?"}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:u,disabled:r.countdown>0||r.isLoading,style:{fontFamily:t.fontFamily},children:r.countdown>0?`Resend in ${r.countdown}s`:"Resend Code"}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:h,disabled:r.isLoading,style:{fontFamily:t.fontFamily},children:"Change Email"})]})]},"otp"),"success"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.5},className:"text-center space-y-6",children:[$e.jsx("div",{className:"w-20 h-20 rounded-full flex items-center justify-center mx-auto",style:{backgroundColor:"#10b98120"},children:$e.jsx(nf,{className:"h-10 w-10 text-green-500"})}),$e.jsxs("div",{className:"space-y-2",children:[$e.jsx("h2",{className:"text-xl font-semibold text-green-600",style:{fontFamily:t.fontFamily},children:"Authentication Successful!"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"Redirecting to dashboard..."})]}),$e.jsx("div",{className:"flex justify-center",children:$e.jsx(ff,{className:"h-6 w-6 animate-spin text-primary"})})]},"success")]}),$e.jsx(gi,{children:r.error&&$e.jsxs(pd.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg flex items-center gap-2",children:[$e.jsx(sf,{className:"h-4 w-4 text-red-500 flex-shrink-0"}),$e.jsx("p",{className:"text-sm text-red-700",style:{fontFamily:t.fontFamily},children:r.error})]})})]})}),$e.jsx(tv,{})]})}function nv({error:e,onRetry:t,isRetrying:s=!1,errorType:n="validation"}){const r="network"===n||"server"===n||"rate_limit"===n;return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:$e.jsxs("div",{className:"max-w-sm w-full text-center",children:[$e.jsx("div",{className:"flex justify-center mb-4",children:$e.jsx("div",{className:"p-3 rounded-full "+("rate_limit"===n?"bg-orange-100":"bg-red-100"),children:(()=>{switch(n){case"network":return $e.jsx(Bf,{className:"w-6 h-6 text-red-600"});case"rate_limit":return $e.jsx(Lf,{className:"w-6 h-6 text-orange-600"});default:return $e.jsx(Lf,{className:"w-6 h-6 text-red-600"})}})()})}),$e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:(()=>{switch(n){case"network":return"Connection Error";case"rate_limit":return"Rate Limit Exceeded";case"server":return"Server Error";default:return"Access Denied"}})()}),$e.jsx("p",{className:"text-gray-600 text-sm mb-4",children:e}),$e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 mb-4",children:[$e.jsxs("div",{className:"flex items-center justify-center mb-2",children:[$e.jsx(pf,{className:"w-4 h-4 text-gray-500 mr-2"}),$e.jsx("span",{className:"text-xs font-medium text-gray-700",children:"network"===n?"Connection Issue":"API Key Required"})]}),$e.jsx("p",{className:"text-xs text-gray-500",children:(()=>{switch(n){case"network":return"Unable to connect to the validation server. Please check your internet connection.";case"rate_limit":return"Too many validation requests. Please wait a moment before trying again.";case"server":return"The validation server is currently unavailable. Please try again later.";default:return"Please provide a valid Pangents API key to access the widget."}})()})]}),r&&t&&$e.jsx(Ou,{onClick:t,disabled:s,variant:"outline",size:"sm",className:"mb-4",children:s?$e.jsxs($e.Fragment,{children:[$e.jsx(Cf,{className:"w-4 h-4 mr-2 animate-spin"}),"Retrying..."]}):$e.jsxs($e.Fragment,{children:[$e.jsx(Cf,{className:"w-4 h-4 mr-2"}),"Try Again"]})}),$e.jsx("div",{className:"text-xs text-gray-400",children:$e.jsx("p",{children:"validation"===n?"Contact your administrator for API key access.":"If the problem persists, contact support."})})]})})}function rv(){return function(){if("undefined"==typeof window)return null;const e=new URLSearchParams(window.location.search);return e.get("apiKey")||e.get("api_key")}()||("undefined"!=typeof window&&(null==(e=window.PangentsConfig)?void 0:e.apiKey)?window.PangentsConfig.apiKey:null);var e}const av=(e,t,s,n)=>({message:e,status:t,code:s,details:n,timestamp:(new Date).toISOString()}),iv="/settings/applications/validate",ov="/workspace/users/tenant/application/auth",lv=9e5,cv="api_key_validation_",dv="pangents_bearer_token",uv=3,hv=1e3,mv=1e4,pv=10,fv=6e4,gv="api_key_validation_rate_limit";class yv{static sanitizeApiKey(e){if("string"!=typeof e)throw new Error("API key must be a string");const t=e.trim().replace(/[\x00-\x1F\x7F]/g,"");if(t.length<this.MIN_KEY_LENGTH||t.length>this.MAX_KEY_LENGTH)throw new Error(`API key length must be between ${this.MIN_KEY_LENGTH} and ${this.MAX_KEY_LENGTH} characters`);return t}static validateApiKeyFormat(e){return this.API_KEY_PATTERN.test(e)}static isValidApiKey(e){try{const t=this.sanitizeApiKey(e);return this.validateApiKeyFormat(t)?{isValid:!0}:{isValid:!1,error:"Invalid API key format. Expected format: pangents_wk_[alphanumeric characters]"}}catch(t){return{isValid:!1,error:t instanceof Error?t.message:"Invalid API key"}}}}Ce(yv,"API_KEY_PATTERN",/^[A-Za-z0-9_-]{32,64}$/),Ce(yv,"MAX_KEY_LENGTH",100),Ce(yv,"MIN_KEY_LENGTH",20);class xv{static getRequestHistory(){try{const e=localStorage.getItem(gv);return e?JSON.parse(e):[]}catch{return[]}}static setRequestHistory(e){try{localStorage.setItem(gv,JSON.stringify(e))}catch{}}static isRateLimited(){const e=Date.now();return this.getRequestHistory().filter(t=>e-t<fv).length>=pv}static recordRequest(){const e=Date.now(),t=[...this.getRequestHistory(),e].filter(t=>e-t<fv);this.setRequestHistory(t)}static getRemainingRequests(){const e=Date.now(),t=this.getRequestHistory().filter(t=>e-t<fv);return Math.max(0,pv-t.length)}static getResetTime(){const e=this.getRequestHistory();if(0===e.length)return 0;return Math.min(...e)+fv}}class vv{static getCacheKey(e){const t=btoa(e).replace(/[^a-zA-Z0-9]/g,"").substring(0,16);return`${cv}${t}`}static get(e){try{if(this.shouldClearCacheForApiKey(e))return this.clear(),null;const t=this.getCacheKey(e),s=localStorage.getItem(t);if(!s)return null;const n=JSON.parse(s);return Date.now()>n.expiresAt?(this.remove(e),null):n}catch{return null}}static shouldClearCacheForApiKey(e){try{const{apiKeyTracker:t}=require("../cache/ApiKeyTracker");return t.getCurrentApiKey()||t.initialize(e),t.hasApiKeyChanged(e)?(t.updateApiKey(e),!0):t.shouldClearCache()}catch(t){return console.warn("[ValidationCache] Failed to check API key alignment:",t),!1}}static set(e,t){try{const n=this.getCacheKey(e);localStorage.setItem(n,JSON.stringify(t));try{const{apiKeyTracker:e}=require("../cache/ApiKeyTracker");e.markCacheAligned()}catch(s){console.warn("[ValidationCache] Failed to mark cache as aligned:",s)}}catch{}}static remove(e){try{const t=this.getCacheKey(e);localStorage.removeItem(t)}catch{}}static clear(){try{Object.keys(localStorage).forEach(e=>{e.startsWith(cv)&&localStorage.removeItem(e)});try{const{apiKeyTracker:e}=require("../cache/ApiKeyTracker");e.markCacheAligned()}catch(e){console.warn("[ValidationCache] Failed to reset cache alignment:",e)}}catch{}}static getStats(){try{const e=Object.keys(localStorage).filter(e=>e.startsWith(cv));let t=0,s=0;const n=Date.now();return e.forEach(e=>{try{const r=localStorage.getItem(e);if(r){const e=JSON.parse(r);n>e.expiresAt?s++:t++}}catch{}}),{totalCached:e.length,validCached:t,expiredCached:s}}catch{return{totalCached:0,validCached:0,expiredCached:0}}}}class bv{static recordCacheHit(){this.metrics.cacheHits++,this.metrics.totalRequests++}static recordCacheMiss(){this.metrics.cacheMisses++}static recordValidationSuccess(e){this.metrics.validationSuccesses++,this.metrics.totalRequests++,this.updateAverageResponseTime(e),this.metrics.lastRequestTime=Date.now()}static recordValidationFailure(e){this.metrics.validationFailures++,this.metrics.totalRequests++,this.updateAverageResponseTime(e),this.metrics.lastRequestTime=Date.now()}static recordNetworkError(){this.metrics.networkErrors++,this.metrics.totalRequests++,this.metrics.lastRequestTime=Date.now()}static updateAverageResponseTime(e){const t=this.metrics.validationSuccesses+this.metrics.validationFailures;this.metrics.averageResponseTime=1===t?e:(this.metrics.averageResponseTime*(t-1)+e)/t}static getMetrics(){return{...this.metrics}}static getCacheHitRate(){const e=this.metrics.cacheHits+this.metrics.cacheMisses;return e>0?this.metrics.cacheHits/e:0}static getSuccessRate(){const e=this.metrics.validationSuccesses+this.metrics.validationFailures;return e>0?this.metrics.validationSuccesses/e:0}static reset(){this.metrics={totalRequests:0,cacheHits:0,cacheMisses:0,validationSuccesses:0,validationFailures:0,networkErrors:0,averageResponseTime:0,lastRequestTime:0}}}Ce(bv,"metrics",{totalRequests:0,cacheHits:0,cacheMisses:0,validationSuccesses:0,validationFailures:0,networkErrors:0,averageResponseTime:0,lastRequestTime:0});class wv{static async makeTenantAuthRequest(e,t,s,n=0){var r,a,i,o,l,c;const d=Date.now();try{const n=await Mp.post(ov,{email:t,tenant_id:s},{timeout:mv,headers:{"Content-Type":"application/json",api_key:e,request_origin:"tenant"},transformRequest:[e=>JSON.stringify(e)],transformResponse:[e=>"string"==typeof e?JSON.parse(e):e]}),r=Date.now()-d;return bv.recordValidationSuccess(r),n.data}catch(u){const h=Date.now()-d;if(401===(null==(r=u.response)?void 0:r.status))throw bv.recordValidationFailure(h),av("Invalid API key or credentials",401,"INVALID_API_KEY");if(403===(null==(a=u.response)?void 0:a.status))throw bv.recordValidationFailure(h),av("Access forbidden. Invalid tenant or email.",403,"FORBIDDEN");if(429===(null==(i=u.response)?void 0:i.status))throw bv.recordValidationFailure(h),av("Rate limit exceeded",429,"RATE_LIMIT_EXCEEDED");if(n<uv&&(!u.response||u.response.status>=500))return await new Promise(e=>setTimeout(e,hv*Math.pow(2,n))),this.makeTenantAuthRequest(e,t,s,n+1);throw bv.recordNetworkError(),av((null==(l=null==(o=u.response)?void 0:o.data)?void 0:l.detail)||"Network error occurred",(null==(c=u.response)?void 0:c.status)||0,"NETWORK_ERROR")}}static async makeValidationRequest(e,t,s=0){var n,r,a,i,o;const l=Date.now();try{const s=await Mp.post(iv,{api_key:e,tenant_id:t},{timeout:mv,headers:{"Content-Type":"application/json",api_key:e,request_origin:"tenant"}}),n=Date.now()-l;return bv.recordValidationSuccess(n),s.data}catch(c){const d=Date.now()-l;if(401===(null==(n=c.response)?void 0:n.status))throw bv.recordValidationFailure(d),av("Invalid API key",401,"INVALID_API_KEY");if(429===(null==(r=c.response)?void 0:r.status))throw bv.recordValidationFailure(d),av("Rate limit exceeded",429,"RATE_LIMIT_EXCEEDED");if(s<uv&&(!c.response||c.response.status>=500))return await new Promise(e=>setTimeout(e,hv*Math.pow(2,s))),this.makeValidationRequest(e,t,s+1);throw bv.recordNetworkError(),av((null==(i=null==(a=c.response)?void 0:a.data)?void 0:i.detail)||"Network error occurred",(null==(o=c.response)?void 0:o.status)||0,"NETWORK_ERROR")}}static saveBearerToken(e){try{localStorage.setItem(dv,e)}catch{}}static getBearerToken(){try{return localStorage.getItem(dv)}catch{return null}}static clearBearerToken(){try{localStorage.removeItem(dv)}catch{}}static saveAuthEmail(e){try{localStorage.setItem("pangents_auth_email",e)}catch{}}static getAuthEmail(){try{return localStorage.getItem("pangents_auth_email")}catch{return null}}static clearAuthEmail(){try{localStorage.removeItem("pangents_auth_email")}catch{}}static hasValidSession(){const e=this.getBearerToken(),t=this.getAuthEmail();return!(!e||!t)}static getExistingSession(){const e=this.getBearerToken(),t=this.getAuthEmail();return e&&t?{bearerToken:e,email:t}:null}static clearAllAuthData(){this.clearBearerToken(),this.clearAuthEmail(),this.clearCache()}static async validateWithTenantAuth(e,t,s){var n;const r=this.getExistingSession();if(r)return console.log("[ApiKeyValidation] Found existing session, using cached auth"),{isValid:!0,bearerToken:r.bearerToken,email:r.email,fromCache:!0};try{if(xv.isRateLimited()){const e=xv.getResetTime();return{isValid:!1,error:`Rate limit exceeded. Please try again in ${Math.ceil((e-Date.now())/1e3)} seconds.`}}xv.recordRequest();const r=await this.makeTenantAuthRequest(e,t,s);return console.log("[ApiKeyValidation] Auth response:",r),r.status&&(null==(n=r.data)?void 0:n.bearer)?(this.saveBearerToken(r.data.bearer),t&&this.saveAuthEmail(t),{isValid:!0,bearerToken:r.data.bearer,email:t,fromCache:!1}):{isValid:!1,error:"Authentication failed. No bearer token received."}}catch(a){const e=(null==a?void 0:a.message)||"Authentication request failed";return this.clearBearerToken(),{isValid:!1,error:e}}}static async validateApiKey(e,t){try{const s=yv.sanitizeApiKey(e),n=yv.isValidApiKey(s);if(!n.isValid)return{isValid:!1,error:n.error};if(xv.isRateLimited()){const e=xv.getResetTime();return{isValid:!1,error:`Rate limit exceeded. Please try again in ${Math.ceil((e-Date.now())/1e3)} seconds.`}}const r=vv.get(s);if(console.log("cached",r),r)return bv.recordCacheHit(),{isValid:r.isValid,response:r.response,error:r.error,fromCache:!0};bv.recordCacheMiss(),xv.recordRequest();const a=await this.makeValidationRequest(s,t),i=a.success&&a.data.valid,o=Date.now(),l={isValid:i,response:a.data,cachedAt:o,expiresAt:o+lv};return vv.set(s,l),{isValid:i,response:a.data,fromCache:!1}}catch(s){const t=(null==s?void 0:s.message)||"Validation request failed";console.log("Text Error",t);const n=Date.now(),r={isValid:!1,error:t,cachedAt:n,expiresAt:n+lv/3};try{const t=yv.sanitizeApiKey(e);vv.set(t,r)}catch{}return{isValid:!1,error:t}}}static clearCache(){vv.clear()}static getCacheStats(){return vv.getStats()}static getMetrics(){return{...bv.getMetrics(),cacheHitRate:bv.getCacheHitRate(),successRate:bv.getSuccessRate(),rateLimitInfo:{remainingRequests:xv.getRemainingRequests(),resetTime:xv.getResetTime(),isLimited:xv.isRateLimited()}}}static resetMetrics(){bv.reset()}static async prevalidateApiKey(e){try{await this.validateApiKey(e)}catch{}}static async validateMultipleApiKeys(e){return(await Promise.allSettled(e.map(async e=>({apiKey:e,...await this.validateApiKey(e)})))).map((t,s)=>"fulfilled"===t.status?t.value:{apiKey:e[s],isValid:!1,error:"Validation failed"})}}const Sv="pangents_current_api_key",jv="pangents_cache_api_key_alignment",kv=class e{constructor(){Ce(this,"currentApiKey",null),Ce(this,"listeners",new Set),Ce(this,"initialized",!1)}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){if(this.initialized)return;const t=this.getStoredApiKey(),s=t!==e;this.currentApiKey=e,this.storeApiKey(e);let n="initial_load";s&&null!==t?n="key_change":s||null===t||(n="page_reload"),(s||"initial_load"===n)&&this.notifyListeners({previousKey:t,currentKey:e,timestamp:Date.now(),reason:n}),this.initialized=!0}updateApiKey(e){const t=this.currentApiKey,s=t!==e;return s&&(this.currentApiKey=e,this.storeApiKey(e),this.notifyListeners({previousKey:t,currentKey:e,timestamp:Date.now(),reason:"key_change"})),s}getCurrentApiKey(){return this.currentApiKey}hasApiKeyChanged(e){return this.currentApiKey!==e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getCacheAlignment(){const e=this.getCacheAlignmentInfo(),t=e.apiKey===this.currentApiKey;return{currentApiKey:this.currentApiKey,cacheApiKey:e.apiKey,isAligned:t,lastUpdate:e.timestamp}}markCacheAligned(){this.setCacheAlignmentInfo({apiKey:this.currentApiKey,timestamp:Date.now()})}shouldClearCache(){const e=this.getCacheAlignment();return!e.isAligned&&null!==e.cacheApiKey}reset(){this.currentApiKey=null,this.initialized=!1,this.listeners.clear(),this.clearStoredData()}getStoredApiKey(){try{return localStorage.getItem(Sv)}catch(e){return console.warn("[ApiKeyTracker] Failed to get stored API key:",e),null}}storeApiKey(e){try{e?localStorage.setItem(Sv,e):localStorage.removeItem(Sv)}catch(t){console.warn("[ApiKeyTracker] Failed to store API key:",t)}}getCacheAlignmentInfo(){try{const e=localStorage.getItem(jv);if(e)return JSON.parse(e)}catch(e){console.warn("[ApiKeyTracker] Failed to get cache alignment info:",e)}return{apiKey:null,timestamp:0}}setCacheAlignmentInfo(e){try{localStorage.setItem(jv,JSON.stringify(e))}catch(t){console.warn("[ApiKeyTracker] Failed to set cache alignment info:",t)}}notifyListeners(e){this.listeners.forEach(t=>{try{t(e)}catch(s){console.error("[ApiKeyTracker] Error in listener:",s)}})}clearStoredData(){try{localStorage.removeItem(Sv),localStorage.removeItem(jv)}catch(e){console.warn("[ApiKeyTracker] Failed to clear stored data:",e)}}};Ce(kv,"instance",null);const Nv=kv.getInstance();function Ev(){const{closeWidget:e,theme:t,isAuthenticated:s,user:n,logout:r}=ns(),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1);return Oe.useEffect(()=>{const e=new CustomEvent("widget:aspect_ratio_lock",{detail:{locked:o}});window.dispatchEvent(e)},[o]),$e.jsxs("div",{className:"flex items-center justify-between p-3 sm:p-4 border-b relative overflow-hidden",style:{background:`\n linear-gradient(\n to right,\n ${t.primaryColor}ff 0%,\n ${t.primaryColor}f2 40%,\n ${t.primaryColor}cc 100%\n )\n `,color:t.headerText,fontFamily:t.fontFamily},children:[$e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:`\n linear-gradient(\n to right,\n transparent 0%,\n ${t.primaryColor}22 40%,\n ${t.primaryColor}55 50%,\n ${t.primaryColor}22 60%,\n transparent 100%\n )\n `,backgroundSize:"200% 100%",animation:"headerShimmer 2.4s ease-in-out infinite",mixBlendMode:"screen"}}),$e.jsxs("div",{className:"flex items-center gap-2",children:[t.headerLogo&&""!=t.headerLogo&&$e.jsx("img",{src:t.headerLogo,alt:"Logo",className:"h-6 w-6 object-contain",onError:e=>{e.currentTarget.style.display="none"}}),$e.jsx("div",{className:"flex flex-col",children:$e.jsx("h2",{id:"search-modal-title",className:"font-semibold",children:t.headerTitle||"Pangents AI"})})]}),$e.jsxs("div",{className:"flex items-center gap-2",children:[s&&$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:r,className:"h-8 px-2 text-xs hover:bg-white/10",style:{color:t.headerText},"aria-label":"Logout",children:$e.jsx(Ef,{className:"h-4 w-4"})}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:()=>{i(e=>{const t=!e;return window.dispatchEvent(new CustomEvent("widget:maximize_toggle",{detail:{maximized:t}})),t})},className:"h-8 w-8 p-0 hover:bg-white/10",style:{color:t.headerText},"aria-label":a?"Exit full-screen":"Enter full-screen",children:a?$e.jsx(wf,{className:"h-4 w-4"}):$e.jsx(vf,{className:"h-4 w-4"})}),$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:e,className:"h-8 w-8 p-0 hover:bg-white/10",style:{color:t.headerText},"aria-label":"Close search modal",children:[$e.jsx(Uf,{className:"h-4 w-4"}),$e.jsx("span",{className:"sr-only",children:"Close search"})]})]})]})}function Cv(){const e=Pg();return Oe.useEffect(()=>{e.pathname&&(Gt.saveCurrentRoute(e.pathname),console.log("[RouteTracker] Saved route:",e.pathname))},[e.pathname]),null}function Tv(){const e=Mg(),t=Pg(),{theme:s,user:n}=ns(),r=[{id:"Home",label:"Home",icon:mf,path:"/"},{id:"Email",label:"Email",icon:gf,path:"/email-leads"}],a=t.pathname,i=s.primaryColor||"#1e40af";return $e.jsxs("div",{className:"w-14 flex flex-col items-center py-4 h-full relative overflow-hidden",style:{fontFamily:s.fontFamily,background:`\n linear-gradient(\n to top,\n ${i}ff 0%,\n ${i}f2 40%,\n ${i}cc 100%\n )\n `},"aria-label":"Sidebar navigation",children:[$e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:`\n linear-gradient(\n to top,\n transparent 0%,\n ${i}22 40%,\n ${i}55 50%,\n ${i}22 60%,\n transparent 100%\n )\n `,backgroundSize:"100% 220%",animation:"sidebarShimmer 2.6s ease-in-out infinite",mixBlendMode:"screen"}}),$e.jsx("div",{className:"flex flex-col items-center gap-3 w-full px-2 relative z-10",children:r.map(t=>{const s=a===t.path||"/"!==t.path&&a.startsWith(t.path);return $e.jsx("button",{onClick:()=>e(t.path),title:t.label,"aria-label":t.label,className:`\n group relative flex items-center justify-center w-10 h-10 rounded-xl transition-all duration-200\n ${s?"bg-white shadow-md":"bg-white/20 hover:bg-white/40"}\n `,children:$e.jsx(t.icon,{className:"h-5 w-5 transition-transform duration-200 "+(s?"scale-105":"group-hover:scale-105"),style:{color:s?i:"white"}})},t.id)})})]})}function Pv(){const{isAuthenticated:e,setCurrentScreen:t,login:s,apiKey:n,tenantId:r}=ns(),[a,i]=Oe.useState({isValid:!1,isLoading:!0});Oe.useEffect(()=>{const e=n||rv();Nv.initialize(e);const t=Nv.subscribe(e=>{console.log("[WidgetPopup] API key change detected:",{reason:e.reason,hasChanged:e.previousKey!==e.currentKey,timestamp:new Date(e.timestamp).toISOString()}),("key_change"===e.reason||"page_reload"===e.reason&&e.previousKey!==e.currentKey)&&(console.log("[WidgetPopup] Clearing cache due to API key change"),wv.clearCache(),Gt.clearApiKey(),e.currentKey&&o(!0))}),s=()=>{console.log("[WidgetPopup] API key invalidated by server"),i({isValid:!1,isLoading:!1,error:"API key has been invalidated. Please check your credentials.",errorType:"validation"})};return window.addEventListener("api:key_invalid",s),()=>{t(),window.removeEventListener("api:key_invalid",s)}},[]);const o=async(e=!1)=>{var t,s,a,o,l;const c=n||rv();if(c){Nv.updateApiKey(c)&&!e&&(console.log("[WidgetPopup] API key changed, clearing cache"),wv.clearCache(),e=!0)}if(c)if(r)try{i(e=>({...e,isLoading:!0})),e&&(wv.clearCache(),wv.clearAllAuthData());const t=await wv.validateApiKey(c,r);t.isValid?(Gt.saveApiKey(c),console.log("[WidgetPopup] API key validated successfully")):(Gt.clearApiKey(),wv.clearAllAuthData()),i({isValid:t.isValid,isLoading:!1,error:t.isValid?void 0:t.error||"Invalid credentials. Access denied.",errorType:t.isValid?void 0:"validation"})}catch(d){console.error("API key validation failed:",d);let e="network",n="Connection failed. Please check your internet connection.";(null==(t=d.message)?void 0:t.includes("Rate limit"))?(e="rate_limit",n=d.message):(null==(s=d.message)?void 0:s.includes("Invalid API key"))||(null==(a=d.message)?void 0:a.includes("Invalid credentials"))?(e="validation",n="Invalid credentials. Access denied."):(null==(o=d.message)?void 0:o.includes("forbidden"))?(e="validation",n="Access forbidden. Invalid tenant or email."):(null==(l=d.response)?void 0:l.status)>=500&&(e="server",n="Server error. Please try again later."),i({isValid:!1,isLoading:!1,error:n,errorType:e})}else i({isValid:!1,isLoading:!1,error:"Tenant ID is required for authentication.",errorType:"validation"});else i({isValid:!1,isLoading:!1,error:"API key is required to access the Pangents chatbot widget.",errorType:"validation"})};Oe.useEffect(()=>{o()},[n,r]);const l=()=>{o(!0)};if(a.isLoading)return $e.jsxs("div",{className:"flex items-center justify-center p-8 w-full h-full",children:[$e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),$e.jsx("span",{className:"ml-3 text-sm text-gray-600",children:"Validating API key..."})]});if(!a.isValid)return $e.jsx(nv,{error:a.error,errorType:a.errorType,onRetry:l,isRetrying:a.isLoading});const c=(e,n)=>{s(e,n),t("chat")};return e?$e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[$e.jsx("div",{className:"flex-1 overflow-hidden",children:$e.jsx(Zx,{children:$e.jsx(Xx,{})})}),$e.jsx(tv,{})]}):$e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden w-full",children:$e.jsx(sv,{onAuthSuccess:c})})}function Av({position:e="bottom-right"}){const{isOpen:t,theme:s,closeWidget:n,isAuthenticated:r}=ns(),a="bottom-left"===e||"top-left"===e,i=Oe.useRef(null),[o,l]=Oe.useState(()=>({width:Math.min(.38*window.innerWidth,650),height:window.innerHeight})),c=Oe.useMemo(()=>{if(t){const e=Gt.getCurrentRoute();return console.log("[WidgetPopup] Loading initial route:",e||"/"),e||"/"}return"/"},[t]),[d,u]=Oe.useState(!1),[h,m]=Oe.useState(null),[p,f]=Oe.useState(!1),[g,y]=Oe.useState(!1),x=Oe.useRef(o.width/Math.max(o.height,1));Oe.useEffect(()=>{const e=e=>{const t=e.detail;t&&"boolean"==typeof t.locked&&f(t.locked)};return window.addEventListener("widget:aspect_ratio_lock",e),()=>window.removeEventListener("widget:aspect_ratio_lock",e)},[]),Oe.useEffect(()=>{const e=e=>{const t=e.detail;t&&"boolean"==typeof t.maximized&&y(t.maximized)};return window.addEventListener("widget:maximize_toggle",e),()=>window.removeEventListener("widget:maximize_toggle",e)},[]),Oe.useEffect(()=>{x.current=o.width/Math.max(o.height,1)},[o]);const v=Math.min(.95*window.innerWidth,950),b=window.innerHeight,w=(e,t)=>{t.preventDefault(),t.stopPropagation(),u(!0),m({x:t.clientX,y:t.clientY,width:o.width,height:o.height,edge:e})};return Oe.useEffect(()=>{const e=e=>{if(!d||!h)return;let t=0,s=0;h.edge.includes("right")&&(t=e.clientX-h.x),h.edge.includes("left")&&(t=h.x-e.clientX),h.edge.includes("bottom")&&(s=e.clientY-h.y),h.edge.includes("top")&&(s=h.y-e.clientY);let n=h.width+t,r=h.height+s;const a="left"===h.edge||"right"===h.edge;if(p&&!a){const e=x.current;Math.abs(t)>Math.abs(s)?r=n/e:n=r*e}a&&(r=h.height),n=Math.max(320,Math.min(v,n)),r=Math.max(400,Math.min(b,r)),l({width:n,height:r})},t=()=>{u(!1),m(null)};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[d,h,p]),Oe.useEffect(()=>{const e=()=>{l(e=>{const t=Math.min(.95*window.innerWidth,950),s=window.innerHeight;return e.width>t||e.height>s?{width:Math.min(e.width,t),height:Math.min(e.height,s)}:e})};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),console.log("WidgetPopup: Component rendered"),console.log("WidgetPopup: isOpen state:",t),console.log("WidgetPopup: isAuthenticated:",r),console.log("WidgetPopup: theme:",s),Oe.useEffect(()=>{const e=e=>{"Escape"===e.key&&t&&n()};if(t){document.addEventListener("keydown",e);const t=document.querySelector('[role="dialog"]');t&&t.focus()}return()=>{document.removeEventListener("keydown",e)}},[t,n]),$e.jsx(gi,{children:t&&$e.jsxs(pd.div,{className:"fixed inset-0 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[$e.jsx(pd.div,{className:"absolute inset-0 bg-black/10",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:n}),$e.jsx(pd.div,{ref:i,id:"pangents-widget-container",className:"fixed top-0 "+(a?"left-0":"right-0"),initial:{x:a?"-100%":"100%"},animate:{x:0},exit:{x:a?"-100%":"100%"},transition:{type:"spring",stiffness:300,damping:30},role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",tabIndex:-1,style:{width:g?`${window.innerWidth}px`:`${o.width}px`,height:g?`${window.innerHeight}px`:`${o.height}px`},children:$e.jsxs(By,{className:"h-full flex flex-col overflow-hidden shadow-2xl rounded-none",style:{fontFamily:s.fontFamily},children:[$e.jsxs(Ug,{initialEntries:[c],initialIndex:0,children:[$e.jsx(Cv,{}),$e.jsx(Ev,{}),$e.jsxs("div",{className:"flex flex-1 min-h-0",children:[r?$e.jsx(Tv,{}):null,$e.jsx(Pv,{})]})]},`router-${t}`),$e.jsx("div",{id:"widget-toast-container",style:{position:"absolute",top:"60px",left:"10px",right:"10px",zIndex:1e3,pointerEvents:"none"},children:$e.jsx(Vy,{position:"top-center",richColors:!0,closeButton:!0,expand:!1,visibleToasts:3,containerAriaLabel:"Notifications",toastOptions:{style:{marginTop:"0px",pointerEvents:"auto"},className:"widget-toast"}})}),$e.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[$e.jsx("div",{className:"absolute top-0 left-0 right-0 h-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top",role:"slider",onMouseDown:e=>w("top",e),style:{cursor:"ns-resize"}}),$e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom",role:"slider",onMouseDown:e=>w("bottom",e),style:{cursor:"ns-resize"}}),$e.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize left",role:"slider",onMouseDown:e=>w("left",e),style:{cursor:"ew-resize"}}),$e.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize right",role:"slider",onMouseDown:e=>w("right",e),style:{cursor:"ew-resize"}}),$e.jsx("div",{className:"absolute top-0 left-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top-left",role:"slider",onMouseDown:e=>w("top-left",e),style:{cursor:"nwse-resize"}}),$e.jsx("div",{className:"absolute top-0 right-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top-right",role:"slider",onMouseDown:e=>w("top-right",e),style:{cursor:"nesw-resize"}}),$e.jsx("div",{className:"absolute bottom-0 left-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom-left",role:"slider",onMouseDown:e=>w("bottom-left",e),style:{cursor:"nesw-resize"}}),$e.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom-right",role:"slider",onMouseDown:e=>w("bottom-right",e),style:{cursor:"nwse-resize"}})]})]})})]})})}function Rv({theme:e,className:t,position:s,margin:n,pangentsApiKey:r,tenantId:a,email:i}){return $e.jsx("div",{className:t?`pg-widget-root ${t}`:"pg-widget-root",children:$e.jsx(_t,{client:Qy,children:$e.jsxs(ss,{initialTheme:e,apiKey:r,tenantId:a,email:i,children:[$e.jsx(_p,{position:s,margin:n}),$e.jsx(Av,{position:s})]})})})}var Mv,Dv={};var $v=function(){if(Mv)return Dv;Mv=1;var e=Fe;if("production"===process.env.NODE_ENV)Dv.createRoot=e.createRoot,Dv.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Dv.createRoot=function(s,n){t.usingClientEntryPoint=!0;try{return e.createRoot(s,n)}finally{t.usingClientEntryPoint=!1}},Dv.hydrateRoot=function(s,n,r){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(s,n,r)}finally{t.usingClientEntryPoint=!1}}}return Dv}();const Ov=new class{constructor(){Ce(this,"container",null),Ce(this,"shadow",null),Ce(this,"mountEl",null),Ce(this,"root",null),Ce(this,"config",{})}init(e){const t={...e};if(this.container&&this.root){const e=JSON.stringify(this.config.theme)!==JSON.stringify(t.theme),s=this.config.position!==t.position,n=this.config.margin!==t.margin,r=this.config.zIndex!==t.zIndex;if(e&&!s&&!n&&!r)return this.config=t,void this.render();if(s||n||r)return this.config=t,this.createContainer(),void this.render()}this.config=t,this.createContainer(),this.render()}createContainer(){this.container&&this.destroy(),this.container=document.createElement("div"),this.container.id="pangents-chatbot-widget",this.container.style.zIndex=String(this.config.zIndex||9999),this.shadow=this.container.attachShadow({mode:"open"}),this.mountEl=document.createElement("div"),this.mountEl.id="pg-widget-mount";const e=window.__PANGENTS_WIDGET_CSS||"";if(e){const t=document.createElement("style");t.id="pangents-widget-styles",t.textContent=e,this.shadow.appendChild(t)}this.shadow.appendChild(this.mountEl),document.body.appendChild(this.container)}render(){this.mountEl&&(this.root||(this.root=$v.createRoot(this.mountEl)),this.root.render($e.jsx(Oe.StrictMode,{children:$e.jsx(Rv,{theme:this.config.theme,position:this.config.position,margin:this.config.margin,pangentsApiKey:this.config.pangentsApiKey,tenantId:this.config.tenantId,email:this.config.email},JSON.stringify(this.config.theme))})))}destroy(){this.root&&(this.root.unmount(),this.root=null),this.shadow=null,this.mountEl=null,this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}updateConfig(e){const t={...this.config,...e};JSON.stringify(this.config.theme),JSON.stringify(t.theme);const s=this.config.position!==t.position,n=this.config.margin!==t.margin,r=this.config.zIndex!==t.zIndex;this.config=t,s||n||r?(this.createContainer(),this.render()):this.render()}updateTheme(e){e&&(this.config={...this.config,theme:e},this.render())}};"undefined"!=typeof window&&(window.Chatbot=Ov),exports.Chatbot=Ov,exports.Widget=Rv;
|
|
46
|
-
//# sourceMappingURL=widget-embed-
|
|
45
|
+
function Wf(e={}){let t,{initialEntries:s=["/"],initialIndex:n,v5Compat:r=!1}=e;t=s.map((e,t)=>d(e,"string"==typeof e?null:e.state,0===t?"default":void 0));let a=l(null==n?t.length-1:n),i="POP",o=null;function l(e){return Math.min(Math.max(e,0),t.length-1)}function c(){return t[a]}function d(e,s=null,n){let r=function(e,t,s=null,n){let r={pathname:"string"==typeof e?e:e.pathname,search:"",hash:"",..."string"==typeof t?Gf(t):t,state:s,key:t&&t.key||n||Yf()};return r}(t?c().pathname:"/",e,s,n);return Kf("/"===r.pathname.charAt(0),`relative pathnames are not supported in memory history: ${JSON.stringify(e)}`),r}function u(e){return"string"==typeof e?e:Qf(e)}return{get index(){return a},get action(){return i},get location(){return c()},createHref:u,createURL:e=>new URL(u(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?Gf(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(e,s){i="PUSH";let n=d(e,s);a+=1,t.splice(a,t.length,n),r&&o&&o({action:i,location:n,delta:1})},replace(e,s){i="REPLACE";let n=d(e,s);t[a]=n,r&&o&&o({action:i,location:n,delta:0})},go(e){i="POP";let s=l(a+e),n=t[s];a=s,o&&o({action:i,location:n,delta:e})},listen:e=>(o=e,()=>{o=null})}}function Hf(e,t){if(!1===e||null==e)throw new Error(t)}function Kf(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(s){}}}function Yf(){return Math.random().toString(36).substring(2,10)}function Qf({pathname:e="/",search:t="",hash:s=""}){return t&&"?"!==t&&(e+="?"===t.charAt(0)?t:"?"+t),s&&"#"!==s&&(e+="#"===s.charAt(0)?s:"#"+s),e}function Gf(e){let t={};if(e){let s=e.indexOf("#");s>=0&&(t.hash=e.substring(s),e=e.substring(0,s));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function Jf(e,t,s="/"){return function(e,t,s,n){let r="string"==typeof t?Gf(t):t,a=ug(r.pathname||"/",s);if(null==a)return null;let i=Xf(e);!function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let s=e.length===t.length&&e.slice(0,-1).every((e,s)=>e===t[s]);return s?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(i);let o=null;for(let l=0;null==o&&l<i.length;++l){let e=dg(a);o=lg(i[l],e,n)}return o}(e,t,s,!1)}function Xf(e,t=[],s=[],n="",r=!1){let a=(e,a,i=r,o)=>{let l={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:a,route:e};if(l.relativePath.startsWith("/")){if(!l.relativePath.startsWith(n)&&i)return;Hf(l.relativePath.startsWith(n),`Absolute route path "${l.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(n.length)}let c=fg([n,l.relativePath]),d=s.concat(l);e.children&&e.children.length>0&&(Hf(!0!==e.index,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),Xf(e.children,t,d,c,i)),(null!=e.path||e.index)&&t.push({path:c,score:og(c,e.index),routesMeta:d})};return e.forEach((e,t)=>{var s;if(""!==e.path&&(null==(s=e.path)?void 0:s.includes("?")))for(let n of Zf(e.path))a(e,t,!0,n);else a(e,t)}),t}function Zf(e){let t=e.split("/");if(0===t.length)return[];let[s,...n]=t,r=s.endsWith("?"),a=s.replace(/\?$/,"");if(0===n.length)return r?[a,""]:[a];let i=Zf(n.join("/")),o=[];return o.push(...i.map(e=>""===e?a:[a,e].join("/"))),r&&o.push(...i),o.map(t=>e.startsWith("/")&&""===t?"/":t)}var eg=/^:[\w-]+$/,tg=3,sg=2,ng=1,rg=10,ag=-2,ig=e=>"*"===e;function og(e,t){let s=e.split("/"),n=s.length;return s.some(ig)&&(n+=ag),t&&(n+=sg),s.filter(e=>!ig(e)).reduce((e,t)=>e+(eg.test(t)?tg:""===t?ng:rg),n)}function lg(e,t,s=!1){let{routesMeta:n}=e,r={},a="/",i=[];for(let o=0;o<n.length;++o){let e=n[o],l=o===n.length-1,c="/"===a?t:t.slice(a.length)||"/",d=cg({path:e.relativePath,caseSensitive:e.caseSensitive,end:l},c),u=e.route;if(!d&&l&&s&&!n[n.length-1].route.index&&(d=cg({path:e.relativePath,caseSensitive:e.caseSensitive,end:!1},c)),!d)return null;Object.assign(r,d.params),i.push({params:r,pathname:fg([a,d.pathname]),pathnameBase:gg(fg([a,d.pathnameBase])),route:u}),"/"!==d.pathnameBase&&(a=fg([a,d.pathnameBase]))}return i}function cg(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[s,n]=function(e,t=!1,s=!0){Kf("*"===e||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,s)=>(n.push({paramName:t,isOptional:null!=s}),s?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");e.endsWith("*")?(n.push({paramName:"*"}),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?r+="\\/*$":""!==e&&"/"!==e&&(r+="(?:(?=\\/|$))");let a=new RegExp(r,t?void 0:"i");return[a,n]}(e.path,e.caseSensitive,e.end),r=t.match(s);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:n.reduce((e,{paramName:t,isOptional:s},n)=>{if("*"===t){let e=o[n]||"";i=a.slice(0,a.length-e.length).replace(/(.)\/+$/,"$1")}const r=o[n];return e[t]=s&&!r?void 0:(r||"").replace(/%2F/g,"/"),e},{}),pathname:a,pathnameBase:i,pattern:e}}function dg(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return Kf(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ug(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let s=t.endsWith("/")?t.length-1:t.length,n=e.charAt(s);return n&&"/"!==n?null:e.slice(s)||"/"}function hg(e,t,s,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function mg(e){let t=function(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}(e);return t.map((e,s)=>s===t.length-1?e.pathname:e.pathnameBase)}function pg(e,t,s,n=!1){let r;"string"==typeof e?r=Gf(e):(r={...e},Hf(!r.pathname||!r.pathname.includes("?"),hg("?","pathname","search",r)),Hf(!r.pathname||!r.pathname.includes("#"),hg("#","pathname","hash",r)),Hf(!r.search||!r.search.includes("#"),hg("#","search","hash",r)));let a,i=""===e||""===r.pathname,o=i?"/":r.pathname;if(null==o)a=s;else{let e=t.length-1;if(!n&&o.startsWith("..")){let t=o.split("/");for(;".."===t[0];)t.shift(),e-=1;r.pathname=t.join("/")}a=e>=0?t[e]:"/"}let l=function(e,t="/"){let{pathname:s,search:n="",hash:r=""}="string"==typeof e?Gf(e):e,a=s?s.startsWith("/")?s:function(e,t){let s=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?s.length>1&&s.pop():"."!==e&&s.push(e)}),s.length>1?s.join("/"):"/"}(s,t):t;return{pathname:a,search:yg(n),hash:xg(r)}}(r,a),c=o&&"/"!==o&&o.endsWith("/"),d=(i||"."===o)&&s.endsWith("/");return l.pathname.endsWith("/")||!c&&!d||(l.pathname+="/"),l}var fg=e=>e.join("/").replace(/\/\/+/g,"/"),gg=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),yg=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",xg=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var vg=["POST","PUT","PATCH","DELETE"];new Set(vg);var bg=["GET",...vg];new Set(bg);var wg=Le.createContext(null);wg.displayName="DataRouter";var Sg=Le.createContext(null);Sg.displayName="DataRouterState",Le.createContext(!1);var jg=Le.createContext({isTransitioning:!1});jg.displayName="ViewTransition",Le.createContext(new Map).displayName="Fetchers",Le.createContext(null).displayName="Await";var kg=Le.createContext(null);kg.displayName="Navigation";var Ng=Le.createContext(null);Ng.displayName="Location";var Eg=Le.createContext({outlet:null,matches:[],isDataRoute:!1});Eg.displayName="Route";var Cg=Le.createContext(null);function Tg(){return null!=Le.useContext(Ng)}function Pg(){return Hf(Tg(),"useLocation() may be used only in the context of a <Router> component."),Le.useContext(Ng).location}Cg.displayName="RouteError";var Ag="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Rg(e){Le.useContext(kg).static||Le.useLayoutEffect(e)}function Mg(){let{isDataRoute:e}=Le.useContext(Eg);return e?function(){let{router:e}=function(e){let t=Le.useContext(wg);return Hf(t,_g(e)),t}("useNavigate"),t=Vg("useNavigate"),s=Le.useRef(!1);return Rg(()=>{s.current=!0}),Le.useCallback(async(n,r={})=>{Kf(s.current,Ag),s.current&&("number"==typeof n?e.navigate(n):await e.navigate(n,{fromRouteId:t,...r}))},[e,t])}():function(){Hf(Tg(),"useNavigate() may be used only in the context of a <Router> component.");let e=Le.useContext(wg),{basename:t,navigator:s}=Le.useContext(kg),{matches:n}=Le.useContext(Eg),{pathname:r}=Pg(),a=JSON.stringify(mg(n)),i=Le.useRef(!1);return Rg(()=>{i.current=!0}),Le.useCallback((n,o={})=>{if(Kf(i.current,Ag),!i.current)return;if("number"==typeof n)return void s.go(n);let l=pg(n,JSON.parse(a),r,"path"===o.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:fg([t,l.pathname])),(o.replace?s.replace:s.push)(l,o.state,o)},[t,s,a,r,e])}()}function Dg(){let{matches:e}=Le.useContext(Eg),t=e[e.length-1];return t?t.params:{}}function $g(e,{relative:t}={}){let{matches:s}=Le.useContext(Eg),{pathname:n}=Pg(),r=JSON.stringify(mg(s));return Le.useMemo(()=>pg(e,JSON.parse(r),n,"path"===t),[e,r,n,t])}function Og(e,t,s,n,r){var a;Hf(Tg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=Le.useContext(kg),{matches:o}=Le.useContext(Eg),l=o[o.length-1],c=l?l.params:{},d=l?l.pathname:"/",u=l?l.pathnameBase:"/",h=l&&l.route;{let e=h&&h.path||"";qg(d,!h||e.endsWith("*")||e.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.\n\nPlease change the parent <Route path="${e}"> to <Route path="${"/"===e?"*":`${e}/*`}">.`)}let m,p=Pg();if(t){let e="string"==typeof t?Gf(t):t;Hf("/"===u||(null==(a=e.pathname)?void 0:a.startsWith(u)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${e.pathname}" was given in the \`location\` prop.`),m=e}else m=p;let f=m.pathname||"/",g=f;if("/"!==u){let e=u.replace(/^\//,"").split("/");g="/"+f.replace(/^\//,"").split("/").slice(e.length).join("/")}let y=Jf(e,{pathname:g});Kf(h||null!=y,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),Kf(null==y||void 0!==y[y.length-1].route.element||void 0!==y[y.length-1].route.Component||void 0!==y[y.length-1].route.lazy,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=function(e,t=[],s=null,n=null){if(null==e){if(!s)return null;if(s.errors)e=s.matches;else{if(0!==t.length||s.initialized||!(s.matches.length>0))return null;e=s.matches}}let r=e,a=null==s?void 0:s.errors;if(null!=a){let e=r.findIndex(e=>e.route.id&&void 0!==(null==a?void 0:a[e.route.id]));Hf(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),r=r.slice(0,Math.min(r.length,e+1))}let i=!1,o=-1;if(s)for(let l=0;l<r.length;l++){let e=r[l];if((e.route.HydrateFallback||e.route.hydrateFallbackElement)&&(o=l),e.route.id){let{loaderData:t,errors:n}=s,a=e.route.loader&&!t.hasOwnProperty(e.route.id)&&(!n||void 0===n[e.route.id]);if(e.route.lazy||a){i=!0,r=o>=0?r.slice(0,o+1):[r[0]];break}}}return r.reduceRight((e,l,c)=>{let d,u=!1,h=null,m=null;s&&(d=a&&l.route.id?a[l.route.id]:void 0,h=l.route.errorElement||zg,i&&(o<0&&0===c?(qg("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),u=!0,m=null):o===c&&(u=!0,m=l.route.hydrateFallbackElement||null)));let p=t.concat(r.slice(0,c+1)),f=()=>{let t;return t=d?h:u?m:l.route.Component?Le.createElement(l.route.Component,null):l.route.element?l.route.element:e,Le.createElement(Ig,{match:l,routeContext:{outlet:e,matches:p,isDataRoute:null!=s},children:t})};return s&&(l.route.ErrorBoundary||l.route.errorElement||0===c)?Le.createElement(Lg,{location:s.location,revalidation:s.revalidation,component:h,error:d,children:f(),routeContext:{outlet:null,matches:p,isDataRoute:!0},unstable_onError:n}):f()},null)}(y&&y.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:fg([u,i.encodeLocation?i.encodeLocation(e.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?u:fg([u,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),o,s,n,r);return t&&x?Le.createElement(Ng.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function Fg(){let e=function(){var e;let t=Le.useContext(Cg),s=function(e){let t=Le.useContext(Sg);return Hf(t,_g(e)),t}("useRouteError"),n=Vg("useRouteError");if(void 0!==t)return t;return null==(e=s.errors)?void 0:e[n]}(),t=function(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=Le.createElement(Le.Fragment,null,Le.createElement("p",null,"💿 Hey developer 👋"),Le.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",Le.createElement("code",{style:a},"ErrorBoundary")," or"," ",Le.createElement("code",{style:a},"errorElement")," prop on your route.")),Le.createElement(Le.Fragment,null,Le.createElement("h2",null,"Unexpected Application Error!"),Le.createElement("h3",{style:{fontStyle:"italic"}},t),s?Le.createElement("pre",{style:r},s):null,i)}Le.createContext(null);var zg=Le.createElement(Fg,null),Lg=class extends Le.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return void 0!==this.state.error?Le.createElement(Eg.Provider,{value:this.props.routeContext},Le.createElement(Cg.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ig({routeContext:e,match:t,children:s}){let n=Le.useContext(wg);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),Le.createElement(Eg.Provider,{value:e},s)}function _g(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Vg(e){let t=function(e){let t=Le.useContext(Eg);return Hf(t,_g(e)),t}(e),s=t.matches[t.matches.length-1];return Hf(s.route.id,`${e} can only be used on routes that contain a unique "id"`),s.route.id}var Bg={};function qg(e,t,s){t||Bg[e]||(Bg[e]=!0,Kf(!1,s))}function Ug({basename:e,children:t,initialEntries:s,initialIndex:n}){let r=Le.useRef();null==r.current&&(r.current=Wf({initialEntries:s,initialIndex:n,v5Compat:!0}));let a=r.current,[i,o]=Le.useState({action:a.action,location:a.location}),l=Le.useCallback(e=>{Le.startTransition(()=>o(e))},[o]);return Le.useLayoutEffect(()=>a.listen(l),[a,l]),Le.createElement(Kg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a})}function Wg({to:e,replace:t,state:s,relative:n}){Hf(Tg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:r}=Le.useContext(kg);Kf(!r,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=Le.useContext(Eg),{pathname:i}=Pg(),o=Mg(),l=pg(e,mg(a),i,"path"===n),c=JSON.stringify(l);return Le.useEffect(()=>{o(JSON.parse(c),{replace:t,state:s,relative:n})},[o,c,n,t,s]),null}function Hg(e){Hf(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Kg({basename:e="/",children:t=null,location:s,navigationType:n="POP",navigator:r,static:a=!1}){Hf(!Tg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),o=Le.useMemo(()=>({basename:i,navigator:r,static:a,future:{}}),[i,r,a]);"string"==typeof s&&(s=Gf(s));let{pathname:l="/",search:c="",hash:d="",state:u=null,key:h="default"}=s,m=Le.useMemo(()=>{let e=ug(l,i);return null==e?null:{location:{pathname:e,search:c,hash:d,state:u,key:h},navigationType:n}},[i,l,c,d,u,h,n]);return Kf(null!=m,`<Router basename="${i}"> is not able to match the URL "${l}${c}${d}" because it does not start with the basename, so the <Router> won't render anything.`),null==m?null:Le.createElement(kg.Provider,{value:o},Le.createElement(Ng.Provider,{children:t,value:m}))}function Yg({children:e,location:t}){return Og(Qg(e),t)}function Qg(e,t=[]){let s=[];return Le.Children.forEach(e,(e,n)=>{if(!Le.isValidElement(e))return;let r=[...t,n];if(e.type===Le.Fragment)return void s.push.apply(s,Qg(e.props.children,r));Hf(e.type===Hg,`[${"string"==typeof e.type?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Hf(!e.props.index||!e.props.children,"An index route cannot have child routes.");let a={id:e.props.id||r.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:!0===e.props.hasErrorBoundary||null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Qg(e.props.children,r)),s.push(a)}),s}Le.memo(function({routes:e,future:t,state:s,unstable_onError:n}){return Og(e,void 0,s,n,t)});var Gg="get",Jg="application/x-www-form-urlencoded";function Xg(e){return null!=e&&"string"==typeof e.tagName}var Zg=null;var ey=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ty(e){return null==e||ey.has(e)?e:(Kf(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Jg}"`),null)}function sy(e,t){let s,n,r,a,i;if(Xg(o=e)&&"form"===o.tagName.toLowerCase()){let i=e.getAttribute("action");n=i?ug(i,t):null,s=e.getAttribute("method")||Gg,r=ty(e.getAttribute("enctype"))||Jg,a=new FormData(e)}else if(function(e){return Xg(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Xg(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let o=e.getAttribute("formaction")||i.getAttribute("action");if(n=o?ug(o,t):null,s=e.getAttribute("formmethod")||i.getAttribute("method")||Gg,r=ty(e.getAttribute("formenctype"))||ty(i.getAttribute("enctype"))||Jg,a=new FormData(i,e),!function(){if(null===Zg)try{new FormData(document.createElement("form"),0),Zg=!1}catch(e){Zg=!0}return Zg}()){let{name:t,type:s,value:n}=e;if("image"===s){let e=t?`${t}.`:"";a.append(`${e}x`,"0"),a.append(`${e}y`,"0")}else t&&a.append(t,n)}}else{if(Xg(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Gg,n=null,r=Jg,i=e}var o;return a&&"text/plain"===r&&(i=a,a=void 0),{action:n,method:s.toLowerCase(),encType:r,formData:a,body:i}}function ny(e,t){if(!1===e||null==e)throw new Error(t)}function ry(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"==typeof e.imageSrcSet&&"string"==typeof e.imageSizes:"string"==typeof e.rel&&"string"==typeof e.href)}async function ay(e,t,s){return function(e,t){let s=new Set;return new Set(t),e.reduce((e,t)=>{let n=JSON.stringify(function(e){let t={},s=Object.keys(e).sort();for(let n of s)t[n]=e[n];return t}(t));return s.has(n)||(s.add(n),e.push({key:n,link:t})),e},[])}((await Promise.all(e.map(async e=>{let n=t.routes[e.route.id];if(n){let e=await async function(e,t){if(e.id in t)return t[e.id];try{let s=await import(e.module);return t[e.id]=s,s}catch(s){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}(n,s);return e.links?e.links():[]}return[]}))).flat(1).filter(ry).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?{...e,rel:"prefetch",as:"style"}:{...e,rel:"prefetch"}))}function iy(e,t,s,n,r,a){let i=(e,t)=>!s[t]||e.route.id!==s[t].route.id,o=(e,t)=>{var n;return s[t].pathname!==e.pathname||(null==(n=s[t].route.path)?void 0:n.endsWith("*"))&&s[t].params["*"]!==e.params["*"]};return"assets"===a?t.filter((e,t)=>i(e,t)||o(e,t)):"data"===a?t.filter((t,a)=>{var l;let c=n.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(i(t,a)||o(t,a))return!0;if(t.route.shouldRevalidate){let n=t.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:(null==(l=s[0])?void 0:l.params)||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"==typeof n)return n}return!0}):[]}function oy(e,t,{includeHydrateFallback:s}={}){return n=e.map(e=>{let n=t.routes[e.route.id];if(!n)return[];let r=[n.module];return n.clientActionModule&&(r=r.concat(n.clientActionModule)),n.clientLoaderModule&&(r=r.concat(n.clientLoaderModule)),s&&n.hydrateFallbackModule&&(r=r.concat(n.hydrateFallbackModule)),n.imports&&(r=r.concat(n.imports)),r}).flat(1),[...new Set(n)];var n}function ly(){let e=Le.useContext(wg);return ny(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var cy=Le.createContext(void 0);function dy(){let e=Le.useContext(cy);return ny(e,"You must render this element inside a <HydratedRouter> element"),e}function uy(e,t){return s=>{e&&e(s),s.defaultPrevented||t(s)}}function hy({page:e,...t}){let{router:s}=ly(),n=Le.useMemo(()=>Jf(s.routes,e,s.basename),[s.routes,e,s.basename]);return n?Le.createElement(my,{page:e,matches:n,...t}):null}function my({page:e,matches:t,...s}){let n=Pg(),{manifest:r,routeModules:a}=dy(),{basename:i}=ly(),{loaderData:o,matches:l}=function(){let e=Le.useContext(Sg);return ny(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}(),c=Le.useMemo(()=>iy(e,t,l,r,n,"data"),[e,t,l,r,n]),d=Le.useMemo(()=>iy(e,t,l,r,n,"assets"),[e,t,l,r,n]),u=Le.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let s=new Set,l=!1;if(t.forEach(e=>{var t;let n=r.routes[e.route.id];n&&n.hasLoader&&(!c.some(t=>t.route.id===e.route.id)&&e.route.id in o&&(null==(t=a[e.route.id])?void 0:t.shouldRevalidate)||n.hasClientLoader?l=!0:s.add(e.route.id))}),0===s.size)return[];let d=function(e,t,s){let n="string"==typeof e?new URL(e,"undefined"==typeof window?"server://singlefetch/":window.location.origin):e;return"/"===n.pathname?n.pathname=`_root.${s}`:t&&"/"===ug(n.pathname,t)?n.pathname=`${t.replace(/\/$/,"")}/_root.${s}`:n.pathname=`${n.pathname.replace(/\/$/,"")}.${s}`,n}(e,i,"data");return l&&s.size>0&&d.searchParams.set("_routes",t.filter(e=>s.has(e.route.id)).map(e=>e.route.id).join(",")),[d.pathname+d.search]},[i,o,n,r,c,t,e,a]),h=Le.useMemo(()=>oy(d,r),[d,r]),m=function(e){let{manifest:t,routeModules:s}=dy(),[n,r]=Le.useState([]);return Le.useEffect(()=>{let n=!1;return ay(e,t,s).then(e=>{n||r(e)}),()=>{n=!0}},[e,t,s]),n}(d);return Le.createElement(Le.Fragment,null,u.map(e=>Le.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...s})),h.map(e=>Le.createElement("link",{key:e,rel:"modulepreload",href:e,...s})),m.map(({key:e,link:t})=>Le.createElement("link",{key:e,nonce:s.nonce,...t})))}function py(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}cy.displayName="FrameworkContext";var fy="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;try{fy&&(window.__reactRouterVersion="7.9.4")}catch(Fv){}var gy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yy=Le.forwardRef(function({onClick:e,discover:t="render",prefetch:s="none",relative:n,reloadDocument:r,replace:a,state:i,target:o,to:l,preventScrollReset:c,viewTransition:d,...u},h){let m,{basename:p}=Le.useContext(kg),f="string"==typeof l&&gy.test(l),g=!1;if("string"==typeof l&&f&&(m=l,fy))try{let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l),s=ug(t.pathname,p);t.origin===e.origin&&null!=s?l=s+t.search+t.hash:g=!0}catch(Fv){Kf(!1,`<Link to="${l}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let y=function(e,{relative:t}={}){Hf(Tg(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:n}=Le.useContext(kg),{hash:r,pathname:a,search:i}=$g(e,{relative:t}),o=a;return"/"!==s&&(o="/"===a?s:fg([s,a])),n.createHref({pathname:o,search:i,hash:r})}(l,{relative:n}),[x,v,b]=function(e,t){let s=Le.useContext(cy),[n,r]=Le.useState(!1),[a,i]=Le.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:u}=t,h=Le.useRef(null);Le.useEffect(()=>{if("render"===e&&i(!0),"viewport"===e){let e=new IntersectionObserver(e=>{e.forEach(e=>{i(e.isIntersecting)})},{threshold:.5});return h.current&&e.observe(h.current),()=>{e.disconnect()}}},[e]),Le.useEffect(()=>{if(n){let e=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(e)}}},[n]);let m=()=>{r(!0)},p=()=>{r(!1),i(!1)};return s?"intent"!==e?[a,h,{}]:[a,h,{onFocus:uy(o,m),onBlur:uy(l,p),onMouseEnter:uy(c,m),onMouseLeave:uy(d,p),onTouchStart:uy(u,m)}]:[!1,h,{}]}(s,u),w=function(e,{target:t,replace:s,state:n,preventScrollReset:r,relative:a,viewTransition:i}={}){let o=Mg(),l=Pg(),c=$g(e,{relative:a});return Le.useCallback(d=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(d,t)){d.preventDefault();let t=void 0!==s?s:Qf(l)===Qf(c);o(e,{replace:t,state:n,preventScrollReset:r,relative:a,viewTransition:i})}},[l,o,c,s,n,t,e,r,a,i])}(l,{replace:a,state:i,target:o,preventScrollReset:c,relative:n,viewTransition:d});let S=Le.createElement("a",{...u,...b,href:m||y,onClick:g||r?e:function(t){e&&e(t),t.defaultPrevented||w(t)},ref:py(h,v),target:o,"data-discover":f||"render"!==t?void 0:"true"});return x&&!f?Le.createElement(Le.Fragment,null,S,Le.createElement(hy,{page:y})):S});function xy(e){let t=Le.useContext(wg);return Hf(t,function(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}(e)),t}yy.displayName="Link",Le.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:s="",end:n=!1,style:r,to:a,viewTransition:i,children:o,...l},c){let d=$g(a,{relative:l.relative}),u=Pg(),h=Le.useContext(Sg),{navigator:m,basename:p}=Le.useContext(kg),f=null!=h&&function(e,{relative:t}={}){let s=Le.useContext(jg);Hf(null!=s,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=xy("useViewTransitionState"),r=$g(e,{relative:t});if(!s.isTransitioning)return!1;let a=ug(s.currentLocation.pathname,n)||s.currentLocation.pathname,i=ug(s.nextLocation.pathname,n)||s.nextLocation.pathname;return null!=cg(r.pathname,i)||null!=cg(r.pathname,a)}(d)&&!0===i,g=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,y=u.pathname,x=h&&h.navigation&&h.navigation.location?h.navigation.location.pathname:null;t||(y=y.toLowerCase(),x=x?x.toLowerCase():null,g=g.toLowerCase()),x&&p&&(x=ug(x,p)||x);const v="/"!==g&&g.endsWith("/")?g.length-1:g.length;let b,w=y===g||!n&&y.startsWith(g)&&"/"===y.charAt(v),S=null!=x&&(x===g||!n&&x.startsWith(g)&&"/"===x.charAt(g.length)),j={isActive:w,isPending:S,isTransitioning:f},k=w?e:void 0;b="function"==typeof s?s(j):[s,w?"active":null,S?"pending":null,f?"transitioning":null].filter(Boolean).join(" ");let N="function"==typeof r?r(j):r;return Le.createElement(yy,{...l,"aria-current":k,className:b,ref:c,style:N,to:a,viewTransition:i},"function"==typeof o?o(j):o)}).displayName="NavLink",Le.forwardRef(({discover:e="render",fetcherKey:t,navigate:s,reloadDocument:n,replace:r,state:a,method:i=Gg,action:o,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:u,...h},m)=>{let p=function(){let{router:e}=xy("useSubmit"),{basename:t}=Le.useContext(kg),s=Vg("useRouteId");return Le.useCallback(async(n,r={})=>{let{action:a,method:i,encType:o,formData:l,body:c}=sy(n,t);if(!1===r.navigate){let t=r.fetcherKey||by();await e.fetch(t,s,r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||i,formEncType:r.encType||o,flushSync:r.flushSync})}else await e.navigate(r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||i,formEncType:r.encType||o,replace:r.replace,state:r.state,fromRouteId:s,flushSync:r.flushSync,viewTransition:r.viewTransition})},[e,t,s])}(),f=function(e,{relative:t}={}){let{basename:s}=Le.useContext(kg),n=Le.useContext(Eg);Hf(n,"useFormAction must be used inside a RouteContext");let[r]=n.matches.slice(-1),a={...$g(e||".",{relative:t})},i=Pg();if(null==e){a.search=i.search;let e=new URLSearchParams(a.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let s=e.toString();a.search=s?`?${s}`:""}}e&&"."!==e||!r.route.index||(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index");"/"!==s&&(a.pathname="/"===a.pathname?s:fg([s,a.pathname]));return Qf(a)}(o,{relative:c}),g="get"===i.toLowerCase()?"get":"post",y="string"==typeof o&&gy.test(o);return Le.createElement("form",{ref:m,method:g,action:f,onSubmit:n?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let n=e.nativeEvent.submitter,o=(null==n?void 0:n.getAttribute("formmethod"))||i;p(n||e.currentTarget,{fetcherKey:t,method:o,navigate:s,replace:r,state:a,relative:c,preventScrollReset:d,viewTransition:u})},...h,"data-discover":y||"render"!==e?void 0:"true"})}).displayName="Form";var vy=0,by=()=>`__${String(++vy)}__`;function wy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const Sy=Array(12).fill(0),jy=({visible:e,className:t})=>Oe.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},Oe.createElement("div",{className:"sonner-spinner"},Sy.map((e,t)=>Oe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),ky=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ny=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ey=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Cy=Oe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Oe.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"})),Ty=Oe.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"},Oe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Oe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let Py=1;const Ay=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:s,...n}=e,r="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:Py++,a=this.toasts.find(e=>e.id===r),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),a?this.toasts=this.toasts.map(t=>t.id===r?(this.publish({...t,...e,id:r,title:s}),{...t,...e,id:r,dismissible:i,title:s}):t):this.addToast({title:s,...n,dismissible:i,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;void 0!==t.loading&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const n=Promise.resolve(e instanceof Function?e():e);let r,a=void 0!==s;const i=n.then(async e=>{r=["resolve",e];if(Oe.isValidElement(e))a=!1,this.create({id:s,type:"default",message:e});else if(Ry(e)&&!e.ok){a=!1;const n="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,r="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}else if(e instanceof Error){a=!1;const n="function"==typeof t.error?await t.error(e):t.error,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}else if(void 0!==t.success){a=!1;const n="function"==typeof t.success?await t.success(e):t.success,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"success",description:r,...i})}}).catch(async e=>{if(r=["reject",e],void 0!==t.error){a=!1;const n="function"==typeof t.error?await t.error(e):t.error,r="function"==typeof t.description?await t.description(e):t.description,i="object"==typeof n&&!Oe.isValidElement(n)?n:{message:n};this.create({id:s,type:"error",description:r,...i})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),null==t.finally||t.finally.call(t)}),o=()=>new Promise((e,t)=>i.then(()=>"reject"===r[0]?t(r[1]):e(r[1])).catch(t));return"string"!=typeof s&&"number"!=typeof s?{unwrap:o}:Object.assign(s,{unwrap:o})},this.custom=(e,t)=>{const s=(null==t?void 0:t.id)||Py++;return this.create({jsx:e(s),id:s,...t}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ry=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,My=(e,t)=>{const s=(null==t?void 0:t.id)||Py++;return Ay.addToast({title:e,...t,id:s}),s},Dy=Object.assign(My,{success:Ay.success,info:Ay.info,warning:Ay.warning,error:Ay.error,custom:Ay.custom,message:Ay.message,promise:Ay.promise,dismiss:Ay.dismiss,loading:Ay.loading},{getHistory:()=>Ay.toasts,getToasts:()=>Ay.getActiveToasts()});function $y(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[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%)}[data-sonner-toaster][dir=rtl],html[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%)}[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:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[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);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[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 rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [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)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [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;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [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);background:var(--normal-bg);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-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[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}[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}[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,0)) translateX(var(--swipe-amount-x,0));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{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{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{from{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-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--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-sonner-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-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-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, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--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-sonner-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-sonner-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]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[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]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[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]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[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]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[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:first-child{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)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{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%)}");const Oy=3,Fy=14;function zy(...e){return e.filter(Boolean).join(" ")}const Ly=e=>{var t,s,n,r,a,i,o,l,c;const{invert:d,toast:u,unstyled:h,interacting:m,setHeights:p,visibleToasts:f,heights:g,index:y,toasts:x,expanded:v,removeToast:b,defaultRichColors:w,closeButton:S,style:j,cancelButtonStyle:k,actionButtonStyle:N,className:E="",descriptionClassName:C="",duration:T,position:P,gap:A,expandByDefault:R,classNames:M,icons:D,closeButtonAriaLabel:$="Close toast"}=e,[O,F]=Oe.useState(null),[z,L]=Oe.useState(null),[I,_]=Oe.useState(!1),[V,B]=Oe.useState(!1),[q,U]=Oe.useState(!1),[W,H]=Oe.useState(!1),[K,Y]=Oe.useState(!1),[Q,G]=Oe.useState(0),[J,X]=Oe.useState(0),Z=Oe.useRef(u.duration||T||4e3),ee=Oe.useRef(null),te=Oe.useRef(null),se=0===y,ne=y+1<=f,re=u.type,ae=!1!==u.dismissible,ie=u.className||"",oe=u.descriptionClassName||"",le=Oe.useMemo(()=>g.findIndex(e=>e.toastId===u.id)||0,[g,u.id]),ce=Oe.useMemo(()=>{var e;return null!=(e=u.closeButton)?e:S},[u.closeButton,S]),de=Oe.useMemo(()=>u.duration||T||4e3,[u.duration,T]),ue=Oe.useRef(0),he=Oe.useRef(0),me=Oe.useRef(0),pe=Oe.useRef(null),[fe,ge]=P.split("-"),ye=Oe.useMemo(()=>g.reduce((e,t,s)=>s>=le?e:e+t.height,0),[g,le]),xe=(()=>{const[e,t]=Oe.useState(document.hidden);return Oe.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),ve=u.invert||d,be="loading"===re;he.current=Oe.useMemo(()=>le*A+ye,[le,ye]),Oe.useEffect(()=>{Z.current=de},[de]),Oe.useEffect(()=>{_(!0)},[]),Oe.useEffect(()=>{const e=te.current;if(e){const t=e.getBoundingClientRect().height;return X(t),p(e=>[{toastId:u.id,height:t,position:u.position},...e]),()=>p(e=>e.filter(e=>e.toastId!==u.id))}},[p,u.id]),Oe.useLayoutEffect(()=>{if(!I)return;const e=te.current,t=e.style.height;e.style.height="auto";const s=e.getBoundingClientRect().height;e.style.height=t,X(s),p(e=>e.find(e=>e.toastId===u.id)?e.map(e=>e.toastId===u.id?{...e,height:s}:e):[{toastId:u.id,height:s,position:u.position},...e])},[I,u.title,u.description,p,u.id,u.jsx,u.action,u.cancel]);const we=Oe.useCallback(()=>{B(!0),G(he.current),p(e=>e.filter(e=>e.toastId!==u.id)),setTimeout(()=>{b(u)},200)},[u,b,p,he]);Oe.useEffect(()=>{if(u.promise&&"loading"===re||u.duration===1/0||"loading"===u.type)return;let e;return v||m||xe?(()=>{if(me.current<ue.current){const e=(new Date).getTime()-ue.current;Z.current=Z.current-e}me.current=(new Date).getTime()})():Z.current!==1/0&&(ue.current=(new Date).getTime(),e=setTimeout(()=>{null==u.onAutoClose||u.onAutoClose.call(u,u),we()},Z.current)),()=>clearTimeout(e)},[v,m,u,re,xe,we]),Oe.useEffect(()=>{u.delete&&(we(),null==u.onDismiss||u.onDismiss.call(u,u))},[we,u.delete]);const Se=u.icon||(null==D?void 0:D[re])||(e=>{switch(e){case"success":return ky;case"info":return Ey;case"warning":return Ny;case"error":return Cy;default:return null}})(re);var je,ke,Ne,Ee;return Oe.createElement("li",{tabIndex:0,ref:te,className:zy(E,ie,null==M?void 0:M.toast,null==u||null==(t=u.classNames)?void 0:t.toast,null==M?void 0:M.default,null==M?void 0:M[re],null==u||null==(s=u.classNames)?void 0:s[re]),"data-sonner-toast":"","data-rich-colors":null!=(je=u.richColors)?je:w,"data-styled":!Boolean(u.jsx||u.unstyled||h),"data-mounted":I,"data-promise":Boolean(u.promise),"data-swiped":K,"data-removed":V,"data-visible":ne,"data-y-position":fe,"data-x-position":ge,"data-index":y,"data-front":se,"data-swiping":q,"data-dismissible":ae,"data-type":re,"data-invert":ve,"data-swipe-out":W,"data-swipe-direction":z,"data-expanded":Boolean(v||R&&I),"data-testid":u.testId,style:{"--index":y,"--toasts-before":y,"--z-index":x.length-y,"--offset":`${V?Q:he.current}px`,"--initial-height":R?"auto":`${J}px`,...j,...u.style},onDragEnd:()=>{U(!1),F(null),pe.current=null},onPointerDown:e=>{2!==e.button&&!be&&ae&&(ee.current=new Date,G(he.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(U(!0),pe.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,s;if(W||!ae)return;pe.current=null;const n=Number((null==(e=te.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),r=Number((null==(t=te.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),a=(new Date).getTime()-(null==(s=ee.current)?void 0:s.getTime()),i="x"===O?n:r,o=Math.abs(i)/a;if(Math.abs(i)>=45||o>.11)return G(he.current),null==u.onDismiss||u.onDismiss.call(u,u),L("x"===O?n>0?"right":"left":r>0?"down":"up"),we(),void H(!0);var l,c;null==(l=te.current)||l.style.setProperty("--swipe-amount-x","0px"),null==(c=te.current)||c.style.setProperty("--swipe-amount-y","0px"),Y(!1),U(!1),F(null)},onPointerMove:t=>{var s,n,r;if(!pe.current||!ae)return;if((null==(s=window.getSelection())?void 0:s.toString().length)>0)return;const a=t.clientY-pe.current.y,i=t.clientX-pe.current.x;var o;const l=null!=(o=e.swipeDirections)?o:function(e){const[t,s]=e.split("-"),n=[];return t&&n.push(t),s&&n.push(s),n}(P);!O&&(Math.abs(i)>1||Math.abs(a)>1)&&F(Math.abs(i)>Math.abs(a)?"x":"y");let c={x:0,y:0};const d=e=>1/(1.5+Math.abs(e)/20);if("y"===O){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&a<0||l.includes("bottom")&&a>0)c.y=a;else{const e=a*d(a);c.y=Math.abs(e)<Math.abs(a)?e:a}}else if("x"===O&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&i<0||l.includes("right")&&i>0)c.x=i;else{const e=i*d(i);c.x=Math.abs(e)<Math.abs(i)?e:i}(Math.abs(c.x)>0||Math.abs(c.y)>0)&&Y(!0),null==(n=te.current)||n.style.setProperty("--swipe-amount-x",`${c.x}px`),null==(r=te.current)||r.style.setProperty("--swipe-amount-y",`${c.y}px`)}},ce&&!u.jsx&&"loading"!==re?Oe.createElement("button",{"aria-label":$,"data-disabled":be,"data-close-button":!0,onClick:be||!ae?()=>{}:()=>{we(),null==u.onDismiss||u.onDismiss.call(u,u)},className:zy(null==M?void 0:M.closeButton,null==u||null==(n=u.classNames)?void 0:n.closeButton)},null!=(ke=null==D?void 0:D.close)?ke:Ty):null,(re||u.icon||u.promise)&&null!==u.icon&&(null!==(null==D?void 0:D[re])||u.icon)?Oe.createElement("div",{"data-icon":"",className:zy(null==M?void 0:M.icon,null==u||null==(r=u.classNames)?void 0:r.icon)},u.promise||"loading"===u.type&&!u.icon?u.icon||((null==D?void 0:D.loading)?Oe.createElement("div",{className:zy(null==M?void 0:M.loader,null==u||null==(Ee=u.classNames)?void 0:Ee.loader,"sonner-loader"),"data-visible":"loading"===re},D.loading):Oe.createElement(jy,{className:zy(null==M?void 0:M.loader,null==u||null==(Ne=u.classNames)?void 0:Ne.loader),visible:"loading"===re})):null,"loading"!==u.type?Se:null):null,Oe.createElement("div",{"data-content":"",className:zy(null==M?void 0:M.content,null==u||null==(a=u.classNames)?void 0:a.content)},Oe.createElement("div",{"data-title":"",className:zy(null==M?void 0:M.title,null==u||null==(i=u.classNames)?void 0:i.title)},u.jsx?u.jsx:"function"==typeof u.title?u.title():u.title),u.description?Oe.createElement("div",{"data-description":"",className:zy(C,oe,null==M?void 0:M.description,null==u||null==(o=u.classNames)?void 0:o.description)},"function"==typeof u.description?u.description():u.description):null),Oe.isValidElement(u.cancel)?u.cancel:u.cancel&&$y(u.cancel)?Oe.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||k,onClick:e=>{$y(u.cancel)&&ae&&(null==u.cancel.onClick||u.cancel.onClick.call(u.cancel,e),we())},className:zy(null==M?void 0:M.cancelButton,null==u||null==(l=u.classNames)?void 0:l.cancelButton)},u.cancel.label):null,Oe.isValidElement(u.action)?u.action:u.action&&$y(u.action)?Oe.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||N,onClick:e=>{$y(u.action)&&(null==u.action.onClick||u.action.onClick.call(u.action,e),e.defaultPrevented||we())},className:zy(null==M?void 0:M.actionButton,null==u||null==(c=u.classNames)?void 0:c.actionButton)},u.action.label):null)};function Iy(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function _y(e,t){const s={};return[e,t].forEach((e,t)=>{const n=1===t,r=n?"--mobile-offset":"--offset",a=n?"16px":"24px";function i(e){["top","right","bottom","left"].forEach(t=>{s[`${r}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?s[`${r}-${t}`]=a:s[`${r}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),s}const Vy=Oe.forwardRef(function(e,t){const{id:s,invert:n,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:u="light",richColors:h,duration:m,style:p,visibleToasts:f=Oy,toastOptions:g,dir:y=Iy(),gap:x=Fy,icons:v,containerAriaLabel:b="Notifications"}=e,[w,S]=Oe.useState([]),j=Oe.useMemo(()=>s?w.filter(e=>e.toasterId===s):w.filter(e=>!e.toasterId),[w,s]),k=Oe.useMemo(()=>Array.from(new Set([r].concat(j.filter(e=>e.position).map(e=>e.position)))),[j,r]),[N,E]=Oe.useState([]),[C,T]=Oe.useState(!1),[P,A]=Oe.useState(!1),[R,M]=Oe.useState("system"!==u?u:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=Oe.useRef(null),$=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),O=Oe.useRef(null),F=Oe.useRef(!1),z=Oe.useCallback(e=>{S(t=>{var s;return(null==(s=t.find(t=>t.id===e.id))?void 0:s.delete)||Ay.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return Oe.useEffect(()=>Ay.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{Fe.flushSync(()=>{S(t=>{const s=t.findIndex(t=>t.id===e.id);return-1!==s?[...t.slice(0,s),{...t[s],...e},...t.slice(s+1)]:[e,...t]})})})}),[w]),Oe.useEffect(()=>{if("system"!==u)return void M(u);if("system"===u&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{M(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{M(e?"dark":"light")}catch(Fv){console.error(Fv)}})}},[u]),Oe.useEffect(()=>{w.length<=1&&T(!1)},[w]),Oe.useEffect(()=>{const e=e=>{var t;var s;a.every(t=>e[t]||e.code===t)&&(T(!0),null==(s=D.current)||s.focus());"Escape"!==e.code||document.activeElement!==D.current&&!(null==(t=D.current)?void 0:t.contains(document.activeElement))||T(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),Oe.useEffect(()=>{if(D.current)return()=>{O.current&&(O.current.focus({preventScroll:!0}),O.current=null,F.current=!1)}},[D.current]),Oe.createElement("section",{ref:t,"aria-label":`${b} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((t,s)=>{var r;const[a,u]=t.split("-");return j.length?Oe.createElement("ol",{key:t,dir:"auto"===y?Iy():y,tabIndex:-1,ref:D,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":a,"data-x-position":u,style:{"--front-toast-height":`${(null==(r=N[0])?void 0:r.height)||0}px`,"--width":"356px","--gap":`${x}px`,...p,..._y(c,d)},onBlur:e=>{F.current&&!e.currentTarget.contains(e.relatedTarget)&&(F.current=!1,O.current&&(O.current.focus({preventScroll:!0}),O.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||F.current||(F.current=!0,O.current=e.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{P||T(!1)},onDragEnd:()=>T(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||A(!0)},onPointerUp:()=>A(!1)},j.filter(e=>!e.position&&0===s||e.position===t).map((s,r)=>{var a,l;return Oe.createElement(Ly,{key:s.id,icons:v,index:r,toast:s,defaultRichColors:h,duration:null!=(a=null==g?void 0:g.duration)?a:m,className:null==g?void 0:g.className,descriptionClassName:null==g?void 0:g.descriptionClassName,invert:n,visibleToasts:f,closeButton:null!=(l=null==g?void 0:g.closeButton)?l:o,interacting:P,position:t,style:null==g?void 0:g.style,unstyled:null==g?void 0:g.unstyled,classNames:null==g?void 0:g.classNames,cancelButtonStyle:null==g?void 0:g.cancelButtonStyle,actionButtonStyle:null==g?void 0:g.actionButtonStyle,closeButtonAriaLabel:null==g?void 0:g.closeButtonAriaLabel,removeToast:z,toasts:j.filter(e=>e.position==s.position),heights:N.filter(e=>e.position==s.position),setHeights:E,expandByDefault:i,gap:x,expanded:C,swipeDirections:e.swipeDirections})})):null}))}),By=Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("rounded-xl border bg-card text-card-foreground shadow",e),...t}));By.displayName="Card";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("flex flex-col space-y-1.5 p-6",e),...t})).displayName="CardHeader";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("font-semibold leading-none tracking-tight",e),...t})).displayName="CardTitle";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("text-sm text-muted-foreground",e),...t})).displayName="CardDescription";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("p-6 pt-0",e),...t})).displayName="CardContent";Le.forwardRef(({className:e,...t},s)=>$e.jsx("div",{ref:s,className:Ru("flex items-center p-6 pt-0",e),...t})).displayName="CardFooter";const qy=Le.forwardRef(({className:e,type:t,...s},n)=>$e.jsx("input",{type:t,className:Ru("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors 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-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...s}));qy.displayName="Input";const Uy=["Dry Van","Refrigerated","Flatbed","Step Deck","Lowboy","Tanker","Container","Other"];function Wy({onSearch:e,theme:t,isLoading:s=!1}){const[n,r]=Oe.useState({origin:"Los Angeles, CA",destination:"New York, NY",pickupEarliest:(()=>{const e=new Date;return e.setDate(e.getDate()+1),e.toISOString().split("T")[0]})(),pickupHours:"09:00",dropoffHours:"17:00",equipmentType:"Dry Van",length:"53",weight:"40000",volume:"2000"}),[a,i]=Oe.useState({}),{width:o,containerRef:l}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),c=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",formPadding:"p-3",spacing:"space-y-3",titleSize:"text-base",subtitleSize:"text-xs",iconSize:"w-5 h-5",iconSizeSmall:"h-3 w-3",labelSize:"text-xs",buttonSize:"text-xs px-3 py-2",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-1"}}:e<450?{containerPadding:"p-3",headerPadding:"p-4",formPadding:"p-4",spacing:"space-y-4",titleSize:"text-lg",subtitleSize:"text-sm",iconSize:"w-6 h-6",iconSizeSmall:"h-3 w-3",labelSize:"text-xs",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",maxWidth:"max-w-none",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-2"}}:e<600?{containerPadding:"p-4",headerPadding:"p-5",formPadding:"p-5",spacing:"space-y-5",titleSize:"text-xl",subtitleSize:"text-sm",iconSize:"w-8 h-8",iconSizeSmall:"h-3.5 w-3.5",labelSize:"text-sm",buttonSize:"text-sm px-6 py-2.5",buttonIconSize:"h-4 w-4",maxWidth:"max-w-2xl",gridCols:{location:"grid-cols-1",datetime:"grid-cols-1",equipment:"grid-cols-2"}}:{containerPadding:"p-6",headerPadding:"p-6",formPadding:"p-6",spacing:"space-y-6",titleSize:"text-2xl",subtitleSize:"text-base",iconSize:"w-10 h-10",iconSizeSmall:"h-4 w-4",labelSize:"text-sm",buttonSize:"px-8 py-3",buttonIconSize:"h-5 w-5",maxWidth:"max-w-4xl",gridCols:{location:"grid-cols-1 md:grid-cols-2",datetime:"grid-cols-1 md:grid-cols-3",equipment:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"}})(o),d=(e,t)=>{r(s=>({...s,[e]:t})),a[e]&&i(t=>({...t,[e]:""}))};return $e.jsx(pd.div,{ref:l,initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`${c.maxWidth} mx-auto ${c.containerPadding}`,children:$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("div",{className:`${c.headerPadding} border-b`,children:[$e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[$e.jsx("div",{className:`${c.iconSize} rounded-full flex items-center justify-center`,style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(Pf,{className:`${c.iconSizeSmall}`,style:{color:t.primaryColor}})}),$e.jsx("h2",{className:`${c.titleSize} font-bold`,style:{fontFamily:t.fontFamily,color:t.primaryColor},children:"Search Carriers"})]}),$e.jsx("p",{className:`text-gray-600 ${c.subtitleSize}`,style:{fontFamily:t.fontFamily},children:"Find the best carriers for your shipment needs"})]}),$e.jsxs("form",{onSubmit:t=>{t.preventDefault(),(()=>{const e={};return n.origin.trim()||(e.origin="Origin is required"),n.destination.trim()||(e.destination="Destination is required"),n.pickupEarliest||(e.pickupEarliest="Pickup date is required"),n.pickupHours||(e.pickupHours="Pickup time is required"),n.dropoffHours||(e.dropoffHours="Drop-off time is required"),n.length.trim()||(e.length="Length is required"),n.weight.trim()||(e.weight="Weight is required"),i(e),0===Object.keys(e).length})()&&e(n)},className:`${c.formPadding} ${c.spacing}`,children:[$e.jsxs("div",{className:`grid ${c.gridCols.location} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(xf,{className:`${c.iconSizeSmall} inline mr-1`}),"Origin"]}),$e.jsx(qy,{value:n.origin,onChange:e=>d("origin",e.target.value),placeholder:"Enter pickup location",className:a.origin?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.origin&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.origin})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(xf,{className:`${c.iconSizeSmall} inline mr-1`}),"Destination"]}),$e.jsx(qy,{value:n.destination,onChange:e=>d("destination",e.target.value),placeholder:"Enter delivery location",className:a.destination?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.destination&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.destination})]})]}),$e.jsxs("div",{className:`grid ${c.gridCols.datetime} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Jp,{className:`${c.iconSizeSmall} inline mr-1`}),"Pickup Earliest"]}),$e.jsx(qy,{type:"date",value:n.pickupEarliest,onChange:e=>d("pickupEarliest",e.target.value),className:a.pickupEarliest?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.pickupEarliest&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.pickupEarliest})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(af,{className:`${c.iconSizeSmall} inline mr-1`}),"Pickup Hours"]}),$e.jsx(qy,{type:"time",value:n.pickupHours,onChange:e=>d("pickupHours",e.target.value),className:a.pickupHours?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.pickupHours&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.pickupHours})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(af,{className:`${c.iconSizeSmall} inline mr-1`}),"Drop-off Hours"]}),$e.jsx(qy,{type:"time",value:n.dropoffHours,onChange:e=>d("dropoffHours",e.target.value),className:a.dropoffHours?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.dropoffHours&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.dropoffHours})]})]}),$e.jsxs("div",{className:`grid ${c.gridCols.equipment} gap-4`,children:[$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(If,{className:`${c.iconSizeSmall} inline mr-1`}),"Equipment Type"]}),$e.jsx("select",{value:n.equipmentType,onChange:e=>d("equipmentType",e.target.value),className:`w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${c.labelSize}`,style:{fontFamily:t.fontFamily},children:Uy.map(e=>$e.jsx("option",{value:e,children:e},e))})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(kf,{className:`${c.iconSizeSmall} inline mr-1`}),"Length (ft)"]}),$e.jsx(qy,{type:"number",value:n.length,onChange:e=>d("length",e.target.value),placeholder:"e.g., 48",className:a.length?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.length&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.length})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Vf,{className:`${c.iconSizeSmall} inline mr-1`}),"Weight (lbs)"]}),$e.jsx(qy,{type:"number",value:n.weight,onChange:e=>d("weight",e.target.value),placeholder:"e.g., 40000",className:a.weight?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.weight&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.weight})]}),$e.jsxs("div",{children:[$e.jsxs("label",{className:`block ${c.labelSize} font-medium text-gray-700 mb-2`,style:{fontFamily:t.fontFamily},children:[$e.jsx(Gp,{className:`${c.iconSizeSmall} inline mr-1`}),"Volume (cu ft)"]}),$e.jsx(qy,{type:"number",value:n.volume||"",onChange:e=>d("volume",e.target.value),placeholder:"e.g., 2000",className:a.volume?"border-red-500":"",style:{fontFamily:t.fontFamily}}),a.volume&&$e.jsx("p",{className:"text-red-500 text-xs mt-1",children:a.volume})]})]}),$e.jsx("div",{className:"flex justify-center pt-4",children:$e.jsx(Ou,{type:"submit",size:"lg",disabled:s,className:`${c.buttonSize} text-white font-semibold rounded-lg hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed`,style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:s?$e.jsxs($e.Fragment,{children:[$e.jsx(ff,{className:`${c.buttonIconSize} mr-2 animate-spin`}),"Searching..."]}):$e.jsxs($e.Fragment,{children:[$e.jsx(Pf,{className:`${c.buttonIconSize} mr-2`}),"Search Carriers"]})})})]})]})})}const Hy=async e=>{try{const t=(e=>{const t=`${e.pickupEarliest}T${e.pickupHours}:00`,s=`${e.pickupEarliest}T${e.dropoffHours}:00`;return{origin:e.origin,destination:e.destination,cargo_type:e.equipmentType,weight:parseFloat(e.weight)||0,volume:parseFloat(e.volume||"0")||0,pickup_date:t,delivery_date:s,max_results:10}})(e);return await Mp.initiateWorkflow(t)}catch(t){throw console.error("Error initiating carrier search:",t),t}},Ky=e=>({id:e.workflow_id,title:`${e.input_params.origin} → ${e.input_params.destination}`,origin:e.input_params.origin,destination:e.input_params.destination,cargoType:e.input_params.cargo_type,weight:e.input_params.weight,volume:e.input_params.volume,pickupDate:e.input_params.pickup_date,deliveryDate:e.input_params.delivery_date,status:e.status,totalCarriers:e.total_carriers,createdAt:new Date(e.created_at),completedAt:e.completed_at?new Date(e.completed_at):null,workflowId:e.workflow_id}),Yy=e=>"completed"===e,Qy=new zt({defaultOptions:{queries:{staleTime:3e5,gcTime:6e5,retry:(e,t)=>!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500)&&e<3,retryDelay:e=>Math.min(1e3*2**e,3e4),refetchOnWindowFocus:!1,refetchOnReconnect:!0,refetchOnMount:!0},mutations:{retry:(e,t)=>!((null==t?void 0:t.status)>=400&&(null==t?void 0:t.status)<500)&&e<1,retryDelay:1e3}}}),Gy={carriers:{all:()=>["carriers"],lists:()=>[...Gy.carriers.all(),"list"],list:e=>[...Gy.carriers.lists(),e],details:()=>[...Gy.carriers.all(),"detail"],detail:e=>[...Gy.carriers.details(),e],search:e=>[...Gy.carriers.all(),"search",e]}},Jy=e=>{console.error("[Query Error]",e),window.dispatchEvent(new CustomEvent("query:error",{detail:{message:e.message||"An error occurred",status:e.status||0,data:e.data||null}}))},Xy=()=>({fetchWorkflowPage:async e=>{const t=await(async(e=1,t=10)=>{try{return await Mp.getWorkflowList(e,t)}catch(s){throw console.error("Error fetching workflow list:",s),s}})(e,10);return{data:t.workflows.map(Ky),hasMore:10===t.workflows.length,total:t.total_count}}}),Zy=e=>{const t=It();return Wt({mutationFn:async e=>await(async e=>{try{return await Mp.deleteWorkflow(e)}catch(t){throw console.error("Error deleting workflow:",t),t}})(e),...e,onSuccess:(s,n,r,a)=>{var i;t.invalidateQueries({queryKey:["workflows"]}),null==(i=null==e?void 0:e.onSuccess)||i.call(e,s,n,r,a)},onError:(t,s,n,r)=>{var a;Jy(t),null==(a=null==e?void 0:e.onError)||a.call(e,t,s,n,r)}})},ex=(e,t)=>function(e){return Ut(e,kt)}({queryKey:["workflow-status",e],queryFn:async()=>await Mp.getWorkflowStatus(e),enabled:!!e,staleTime:3e4,...t});function tx(){const{theme:e,isAuthenticated:t}=ns();Mg();const s=(e=>{const t=It();return Wt({mutationFn:async e=>await Hy(e),...e,onSuccess:(s,n,r,a)=>{var i;t.invalidateQueries({queryKey:Gy.carriers.all()}),null==(i=null==e?void 0:e.onSuccess)||i.call(e,s,n,r,a)},onError:(t,s,n,r)=>{var a;Jy(t),null==(a=null==e?void 0:e.onError)||a.call(e,t,s,n,r)}})})({onSuccess:e=>{Dy.success("Workflow Intialted Successfully!",{description:`Workflow ID: ${e.data.workflow_id} and estimated completed time: ${e.data.estimated_completion_time}`,duration:4e3})},onError:e=>{console.error("Carrier search failed:",e),Dy.error("Failed to search carriers",{description:e.message||"Please check your connection and try again.",duration:5e3})}});return t?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(Wy,{onSearch:e=>{const t=(e=>{var t,s,n;const r=[];return(null==(t=e.origin)?void 0:t.trim())||r.push("Origin is required"),(null==(s=e.destination)?void 0:s.trim())||r.push("Destination is required"),e.pickupEarliest||r.push("Pickup date is required"),e.pickupHours||r.push("Pickup time is required"),e.dropoffHours||r.push("Delivery time is required"),e.equipmentType||r.push("Equipment type is required"),(null==(n=e.weight)?void 0:n.trim())?isNaN(parseFloat(e.weight))?r.push("Weight must be a valid number"):parseFloat(e.weight)<=0&&r.push("Weight must be greater than 0"):r.push("Weight is required"),e.volume&&e.volume.trim()&&(isNaN(parseFloat(e.volume))?r.push("Volume must be a valid number"):parseFloat(e.volume)<0&&r.push("Volume must be 0 or greater")),r})(e);t.length>0?Dy.error("Please fix the following errors:",{description:t.join(", "),duration:5e3}):s.mutate(e)},theme:e,isLoading:s.isPending})})}):$e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsx("div",{className:"text-center",children:$e.jsx("p",{className:"text-gray-600",style:{fontFamily:e.fontFamily},children:"Please authenticate to start using the carrier search."})})})}function sx({carrier:e,isSelected:t,onSelect:s,onCallCarrier:n,theme:r}){const{width:a,containerRef:i}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),o=(e=>e<400?{padding:"p-3",spacing:"gap-2",titleSize:"text-base",textSize:"text-xs",priceSize:"text-lg",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",layout:"mobile",checkboxSize:"h-3 w-3",marginBottom:"mb-1"}:e<600?{padding:"p-3.5",spacing:"gap-2.5",titleSize:"text-lg",textSize:"text-sm",priceSize:"text-xl",iconSize:"h-3.5 w-3.5",buttonSize:"text-sm px-3 py-1.5",buttonIconSize:"h-3.5 w-3.5",layout:"tablet",checkboxSize:"h-3.5 w-3.5",marginBottom:"mb-1.5"}:{padding:"p-4",spacing:"gap-3",titleSize:"text-lg",textSize:"text-sm",priceSize:"text-2xl",iconSize:"h-4 w-4",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",layout:"desktop",checkboxSize:"h-4 w-4",marginBottom:"mb-2"})(a),l=()=>{s(e.id)},c=t=>{t.stopPropagation(),n(e.id)};return $e.jsxs(pd.div,{ref:i,initial:{opacity:0,y:20},animate:{opacity:1,y:0},whileHover:{y:-2},className:`bg-white rounded-lg border-2 ${o.padding} cursor-pointer transition-all duration-200 ${t?"border-blue-500 shadow-lg":"border-gray-200 hover:border-gray-300 hover:shadow-md"}`,onClick:l,children:["mobile"===o.layout?$e.jsxs("div",{className:"space-y-2",children:[$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("input",{type:"checkbox",checked:t,onChange:l,className:`${o.checkboxSize} rounded border-gray-300 text-blue-600 focus:ring-blue-500`,style:{accentColor:r.primaryColor}}),$e.jsx("h3",{className:`font-semibold ${o.titleSize}`,style:{fontFamily:r.fontFamily},children:e.name})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx($f,{className:`${o.iconSize} fill-yellow-400 text-yellow-400`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,children:e.rating.toFixed(1)})]})]}),$e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-xs",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(xf,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:e.location||e.source||"Available"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:e.equipment})]})]}),(e.dotNumber||e.capacity)&&$e.jsxs("div",{className:"grid grid-cols-2 gap-1 text-xs",children:[e.dotNumber&&$e.jsxs("div",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:["DOT: ",e.dotNumber]}),e.capacity&&$e.jsxs("div",{className:"text-gray-600 truncate",style:{fontFamily:r.fontFamily},children:["Fleet: ",e.capacity]})]}),(e.vettingResult||e.matchScore)&&$e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.vettingResult&&$e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-medium "+("ACCEPT"===e.vettingResult?"bg-green-100 text-green-800":"REJECT"===e.vettingResult?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"),children:e.vettingResult}),e.matchScore&&$e.jsxs("span",{className:"text-gray-600",style:{fontFamily:r.fontFamily},children:["Match: ",(100*e.matchScore).toFixed(0),"%"]})]}),$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:e.responseTime||e.estimatedTime||"< 2 hours"})]}),$e.jsxs("span",{className:`${o.priceSize} font-bold`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:["$",e.price.toLocaleString()]})]}),$e.jsxs(Ou,{onClick:c,className:`w-full ${o.buttonSize} text-white font-medium hover:opacity-90 transition-opacity`,style:{backgroundColor:r.primaryColor,fontFamily:r.fontFamily},children:[$e.jsx(Nf,{className:`${o.buttonIconSize} mr-1`}),"Call Carrier"]})]}):$e.jsxs("div",{className:"flex items-start justify-between",children:[$e.jsxs("div",{className:`flex items-start ${o.spacing} flex-1`,children:[$e.jsx("input",{type:"checkbox",checked:t,onChange:l,className:`mt-1 ${o.checkboxSize} rounded border-gray-300 text-blue-600 focus:ring-blue-500`,style:{accentColor:r.primaryColor}}),$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:`flex items-center gap-2 ${o.marginBottom}`,children:[$e.jsx("h3",{className:`font-semibold ${o.titleSize}`,style:{fontFamily:r.fontFamily},children:e.name}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx($f,{className:`${o.iconSize} fill-yellow-400 text-yellow-400`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,children:e.rating.toFixed(1)})]})]}),$e.jsxs("div",{className:`flex items-center gap-1 ${o.marginBottom}`,children:[$e.jsx(xf,{className:`${o.iconSize} text-gray-500`}),$e.jsxs("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:["Source: ",e.source]})]}),$e.jsxs("div",{className:`flex items-center gap-1 ${o.marginBottom}`,children:[$e.jsx(If,{className:`${o.iconSize} text-gray-500`}),$e.jsx("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:e.equipment})]}),$e.jsxs("div",{className:"flex items-center gap-1 mb-3",children:[$e.jsx(af,{className:`${o.iconSize} text-gray-500`}),$e.jsxs("span",{className:`${o.textSize} text-gray-600`,style:{fontFamily:r.fontFamily},children:["Est. Time: ",e.estimatedTime]})]}),$e.jsx("div",{className:"mb-3",children:$e.jsxs("span",{className:`${o.priceSize} font-bold`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:["$",e.price.toLocaleString()]})})]})]}),$e.jsxs(Ou,{onClick:c,className:`ml-4 ${o.buttonSize} text-white font-medium hover:opacity-90 transition-opacity`,style:{backgroundColor:r.primaryColor,fontFamily:r.fontFamily},children:[$e.jsx(Nf,{className:`${o.buttonIconSize} mr-1`}),"Call Carrier"]})]}),t&&$e.jsx(pd.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},className:"mt-3 p-2 rounded-md",style:{backgroundColor:r.primaryColor+"10"},children:$e.jsx("p",{className:`${o.textSize} text-center`,style:{fontFamily:r.fontFamily,color:r.primaryColor},children:"✓ Selected for bulk action"})})]})}const nx=e=>{switch(e){case"waiting":return"text-yellow-600 bg-yellow-50 border-yellow-200";case"in-progress":return"text-blue-600 bg-blue-50 border-blue-200";case"completed":return"text-green-600 bg-green-50 border-green-200";case"failed":return"text-red-600 bg-red-50 border-red-200";default:return"text-gray-600 bg-gray-50 border-gray-200"}},rx=e=>{switch(e){case"pending":default:return"text-gray-600 bg-gray-50 border-gray-200";case"negotiating":return"text-orange-600 bg-orange-50 border-orange-200";case"agreed":return"text-green-600 bg-green-50 border-green-200";case"declined":return"text-red-600 bg-red-50 border-red-200"}};function ax({item:e,onViewDetails:t,theme:s}){(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[])})();const n=Math.min(e.callDuration/e.maxDuration*100,100),r=t;return $e.jsxs(pd.div,{onClick:()=>{t&&t(e.id)},whileHover:{y:-2,scale:1.01},transition:{duration:.2},className:"rounded-2xl border border-gray-200 bg-white shadow-sm p-3 \n hover:shadow-md transition-all duration-200 "+(r?"cursor-pointer hover:border-blue-300":""),children:[$e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[$e.jsx("h3",{className:"font-semibold text-sm text-gray-800 truncate",style:{fontFamily:s.fontFamily},children:e.carrierName}),$e.jsx("div",{className:`flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs font-medium ${nx(e.callStatus)}`,children:$e.jsx("span",{className:"capitalize",children:e.callStatus.replace("-"," ")})})]}),$e.jsxs("div",{className:"flex items-center justify-between mb-2 text-xs text-gray-600",children:[$e.jsx("span",{children:e.contactInfo}),$e.jsxs("span",{className:"font-medium text-gray-500",children:[e.callDuration,"m / ",e.maxDuration,"m"]})]}),$e.jsx("div",{className:"w-full h-1.5 bg-gray-200 rounded-full overflow-hidden mb-2",children:$e.jsx(pd.div,{className:"h-1.5 rounded-full",style:{backgroundColor:n>80?"#ef4444":n>60?"#f59e0b":s.primaryColor,width:`${n}%`},initial:{width:0},animate:{width:`${n}%`},transition:{duration:.6,ease:"easeOut"}})}),$e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[$e.jsxs("div",{className:"flex items-center gap-1.5",children:[$e.jsx("div",{className:`px-2 py-0.5 rounded-full border font-medium ${rx(e.dealStatus)}`,children:e.dealStatus}),e.agreedRate&&$e.jsxs("div",{className:"flex items-center gap-0.5 text-green-600",children:[$e.jsx(of,{className:"w-3 h-3"}),$e.jsxs("span",{className:"font-semibold",children:["$",e.agreedRate.toLocaleString()]})]})]}),$e.jsxs("div",{className:"flex items-center gap-1.5",children:["in-progress"===e.callStatus&&$e.jsx(pd.div,{animate:{scale:[1,1.3,1]},transition:{duration:1,repeat:1/0},className:"w-1.5 h-1.5 bg-blue-500 rounded-full"}),"agreed"===e.dealStatus&&$e.jsx(pd.div,{initial:{scale:0},animate:{scale:1},className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),$e.jsxs("span",{className:"text-gray-400",children:["#",e.id.slice(-4)]})]})]}),e.notes&&$e.jsx("div",{className:"mt-2 bg-gray-50 border border-gray-100 rounded-lg p-2",children:$e.jsxs("p",{className:"text-xs text-gray-600 leading-tight",children:[$e.jsx("span",{className:"font-medium",children:"Note:"})," ",e.notes]})})]})}function ix({searchResults:e,callQueueItems:t,searchMetadata:s,onBack:n,onCallCarrier:r,onBulkCall:a,onViewCallDetails:i,theme:o}){const[l,c]=Oe.useState("results"),[d,u]=Oe.useState([]),{width:h,containerRef:m}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),p=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",contentPadding:"p-3",spacing:"gap-2",titleSize:"text-base",subtitleSize:"text-xs",textSize:"text-xs",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:"grid-cols-1",metadataGrid:"grid-cols-1",tabPadding:"px-2 py-1.5",tabTextSize:"text-xs",headerLayout:"mobile"}:e<450?{containerPadding:"p-3",headerPadding:"p-4",contentPadding:"p-4",spacing:"gap-3",titleSize:"text-lg",subtitleSize:"text-xs",textSize:"text-xs",iconSize:"h-3 w-3",buttonSize:"text-xs px-2 py-1",buttonIconSize:"h-3 w-3",maxWidth:"max-w-none",gridCols:"grid-cols-1",metadataGrid:"grid-cols-1",tabPadding:"px-3 py-2",tabTextSize:"text-xs",headerLayout:"mobile"}:e<600?{containerPadding:"p-4",headerPadding:"p-5",contentPadding:"p-5",spacing:"gap-4",titleSize:"text-xl",subtitleSize:"text-sm",textSize:"text-sm",iconSize:"h-4 w-4",buttonSize:"text-sm px-3 py-1.5",buttonIconSize:"h-4 w-4",maxWidth:"max-w-4xl",gridCols:"grid-cols-1",metadataGrid:"grid-cols-2",tabPadding:"px-4 py-2.5",tabTextSize:"text-sm",headerLayout:"tablet"}:{containerPadding:"p-6",headerPadding:"p-6",contentPadding:"p-6",spacing:"gap-4",titleSize:"text-2xl",subtitleSize:"text-sm",textSize:"text-sm",iconSize:"h-4 w-4",buttonSize:"text-sm px-4 py-2",buttonIconSize:"h-4 w-4",maxWidth:"max-w-6xl",gridCols:"grid-cols-1 lg:grid-cols-2",metadataGrid:"grid-cols-2 md:grid-cols-4",tabPadding:"px-6 py-3",tabTextSize:"text-sm",headerLayout:"desktop"})(h),[f,g]=Oe.useState(null),[y,x]=Oe.useState([]),[v,b]=Oe.useState(null),w=Oe.useRef(null),S=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},j=async()=>{if(f)try{const e=await Mp.getQueueStatus(f);b(e.status);const t=(e=>{const t=Array.isArray(e.items)?e.items:[],s=e.currentItem||e.current_item;return t.map(e=>{const t=e.status,n="completed"===t?"completed":"dispatched"===t?"in-progress":"failed"===t?"failed":"waiting";return{id:e.callLogId||e.call_log_id||`${Date.now()}_${Math.random()}`,carrierName:e.carrierName||e.carrier_name||"Unknown Carrier",callDuration:"in-progress"===n?2:"completed"===n?3:0,maxDuration:15,callStatus:n,dealStatus:"pending",agreedRate:null,contactInfo:`${e.contactName||e.contact_name||"Contact"} • ${e.contactPhone||e.contact_phone||""}`,notes:!s||s.callLogId!==e.callLogId&&s.call_log_id!==e.call_log_id?void 0:"Currently being called"}})})(e);x(t),"completed"===e.status&&w.current&&(window.clearInterval(w.current),w.current=null)}catch(Fv){Dy.error("Failed to fetch queue status",{description:(null==Fv?void 0:Fv.message)||"Unexpected error"}),w.current&&(window.clearInterval(w.current),w.current=null)}};Oe.useEffect(()=>("queue"===l&&f&&!w.current&&(w.current=window.setInterval(j,3e3),j()),"queue"!==l&&w.current&&(window.clearInterval(w.current),w.current=null),()=>{w.current&&(window.clearInterval(w.current),w.current=null)}),[l,f]);const k=d.length;return $e.jsxs("div",{ref:m,className:`${p.maxWidth} mx-auto ${p.containerPadding}`,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border mb-6",children:[$e.jsx("div",{className:`${p.headerPadding} border-b`,children:"mobile"===p.headerLayout?$e.jsxs("div",{className:"space-y-3",children:[$e.jsxs(Ou,{onClick:n,variant:"outline",size:"sm",className:`flex items-center ${p.spacing} ${p.buttonSize}`,style:{fontFamily:o.fontFamily},children:[$e.jsx(Kp,{className:p.iconSize}),"Back to Search"]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`${p.titleSize} font-bold`,style:{fontFamily:o.fontFamily,color:o.primaryColor},children:"Search Results"}),$e.jsxs("p",{className:`text-gray-600 ${p.subtitleSize}`,style:{fontFamily:o.fontFamily},children:[s.searchCriteria.origin," → ",s.searchCriteria.destination]})]}),$e.jsxs("div",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:[$e.jsxs("p",{children:["ID: ",s.searchId.slice(-8)]}),$e.jsx("p",{children:s.timestamp.toLocaleString()})]})]}):$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:`flex items-center ${p.spacing}`,children:[$e.jsxs(Ou,{onClick:n,variant:"outline",size:"sm",className:`flex items-center gap-2 ${p.buttonSize}`,style:{fontFamily:o.fontFamily},children:[$e.jsx(Kp,{className:p.iconSize}),"Back to Search"]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`${p.titleSize} font-bold`,style:{fontFamily:o.fontFamily,color:o.primaryColor},children:"Search Results"}),$e.jsxs("p",{className:`text-gray-600 ${p.subtitleSize}`,style:{fontFamily:o.fontFamily},children:[s.searchCriteria.origin," → ",s.searchCriteria.destination]})]})]}),$e.jsxs("div",{className:"text-right",children:[$e.jsxs("p",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:["Search ID: ",s.searchId.slice(-8)]}),$e.jsx("p",{className:`${p.textSize} text-gray-600`,style:{fontFamily:o.fontFamily},children:s.timestamp.toLocaleString()})]})]})}),$e.jsx("div",{className:"p-4 bg-gray-50",children:$e.jsxs("div",{className:`grid ${p.metadataGrid} gap-4 ${p.textSize}`,children:[$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Equipment:"}),$e.jsx("span",{className:"ml-1 font-medium",children:s.searchCriteria.equipmentType})]}),$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Weight:"}),$e.jsxs("span",{className:"ml-1 font-medium",children:[s.searchCriteria.weight," lbs"]})]}),s.searchCriteria.volume&&$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Volume:"}),$e.jsxs("span",{className:"ml-1 font-medium",children:[s.searchCriteria.volume," cu ft"]})]}),$e.jsxs("div",{children:[$e.jsx("span",{className:"text-gray-600",children:"Pickup:"}),$e.jsx("span",{className:"ml-1 font-medium",children:s.searchCriteria.pickupDate})]})]})})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsx("div",{className:"border-b",children:$e.jsxs("nav",{className:"flex",children:[$e.jsxs("button",{onClick:()=>c("results"),className:`${p.tabPadding} ${p.tabTextSize} font-medium border-b-2 transition-colors ${"results"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,style:{fontFamily:o.fontFamily,..."results"===l&&{borderBottomColor:o.primaryColor,color:o.primaryColor}},children:[$e.jsx(Pf,{className:`${p.iconSize} inline mr-2`}),"Results (",e.length,")"]}),$e.jsxs("button",{onClick:()=>c("queue"),className:`${p.tabPadding} ${p.tabTextSize} font-medium border-b-2 transition-colors ${"queue"===l?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700"}`,style:{fontFamily:o.fontFamily,..."queue"===l&&{borderBottomColor:o.primaryColor,color:o.primaryColor}},children:[$e.jsx(Nf,{className:`${p.iconSize} inline mr-2`}),"Call Queue (",t.length,")"]})]})}),$e.jsx("div",{className:p.contentPadding,children:$e.jsxs(gi,{mode:"wait",children:["results"===l&&$e.jsxs(pd.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},children:[$e.jsxs("div",{className:"flex items-center justify-between mb-6 "+("mobile"===p.headerLayout?"flex-col gap-3":""),children:[$e.jsxs("div",{className:`flex items-center ${p.spacing} ${"mobile"===p.headerLayout?"w-full justify-between":""}`,children:[$e.jsx("h3",{className:("text-lg"===p.titleSize?"text-base":"text-lg")+" font-semibold",style:{fontFamily:o.fontFamily},children:"Available Carriers"}),k>0&&$e.jsxs("span",{className:`px-2 py-1 bg-blue-100 text-blue-800 rounded-full ${p.textSize}`,style:{fontFamily:o.fontFamily},children:[k," selected"]})]}),k>0&&$e.jsxs(Ou,{onClick:async()=>{if(0===d.length)return;const t=e.filter(e=>d.includes(e.id)),n=s.searchCriteria.origin,r=s.searchCriteria.destination,a=s.searchCriteria.volume?`${s.searchCriteria.volume} loads per month`:"Unknown volume",i=t.map(e=>{var t,s;const i="number"==typeof e.price?e.price:0,o=i?`$${(.95*i).toFixed(2)}`:"$0.00",l=i?`$${i.toFixed(2)}`:"$0.00",c=i?`$${(1.1*i).toFixed(2)}`:"$0.00",d=i?`$${(1.02*i).toFixed(2)}`:"$0.00";return{contact_phone:(null==(t=e.contactInfo)?void 0:t.phone)||"",contact_name:(null==(s=e.contactInfo)?void 0:s.contact_person)||e.name,carrier_name:e.name,route:`${n} to ${r}`,volume:a,target_rate:o,market_rate:l,max_rate:c,initiate_call:!0,source:n,destination:r,expected_price:d}});try{const e=await Mp.enqueueCallQueue(i),t=e.queueId||e.queue_id,s=e.status;t?(g(t),b(s||"pending"),Dy.success("Call queue triggered",{description:`Queue ID: ${String(t).slice(-8)}`}),c("queue")):Dy.error("Failed to trigger call queue",{description:"No queue ID returned"})}catch(Fv){Dy.error("Failed to trigger call queue",{description:(null==Fv?void 0:Fv.message)||"Unexpected error"})}finally{u([])}},className:`${p.buttonSize} text-white font-medium hover:opacity-90 transition-opacity ${"mobile"===p.headerLayout?"w-full":""}`,style:{backgroundColor:o.primaryColor,fontFamily:o.fontFamily},children:[$e.jsx(_f,{className:`${p.buttonIconSize} mr-2`}),"Call Selected (",k,")"]})]}),$e.jsx("div",{className:`grid ${p.gridCols} gap-4`,children:e.map(e=>$e.jsx(sx,{carrier:e,isSelected:d.includes(e.id),onSelect:S,onCallCarrier:r,theme:o},e.id))}),0===e.length&&$e.jsxs("div",{className:"text-center py-12",children:[$e.jsx(Pf,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),$e.jsx("p",{className:`text-gray-600 ${p.textSize}`,style:{fontFamily:o.fontFamily},children:"No carriers found for your search criteria."})]})]},"results"),"queue"===l&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:[$e.jsxs("div",{className:"flex items-center justify-between mb-6 "+("mobile"===p.headerLayout?"flex-col gap-3":""),children:[$e.jsx("h3",{className:("text-lg"===p.titleSize?"text-base":"text-lg")+" font-semibold",style:{fontFamily:o.fontFamily},children:"Call Queue"}),$e.jsxs("div",{className:`flex items-center ${p.spacing} ${p.textSize} text-gray-600 ${"mobile"===p.headerLayout?"flex-col gap-1":""}`,children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:p.iconSize}),$e.jsxs("span",{children:["In Progress: ",(y.length?y:t).filter(e=>"in-progress"===e.callStatus).length]})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(nf,{className:p.iconSize}),$e.jsxs("span",{children:["Completed: ",(y.length?y:t).filter(e=>"completed"===e.callStatus).length]})]})]})]}),$e.jsx("div",{className:`grid ${p.gridCols} gap-4`,children:(y.length?y:t).map(e=>$e.jsx(ax,{item:e,onViewDetails:i,theme:o},e.id))}),0===(y.length?y:t).length&&$e.jsxs("div",{className:"text-center py-12",children:[$e.jsx(Nf,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),$e.jsx("p",{className:`text-gray-600 ${p.textSize}`,style:{fontFamily:o.fontFamily},children:"No calls in queue. Start calling carriers to see them here."})]})]},"queue")]})})]})]})}const ox=[{id:"carrier-001",name:"Swift Transportation",source:"DAT Load Board",rating:4.8,price:2850,estimatedTime:"2-3 days",equipment:"Dry Van",isSelected:!1},{id:"carrier-002",name:"J.B. Hunt Transport",source:"Truckstop.com",rating:4.6,price:3200,estimatedTime:"1-2 days",equipment:"Refrigerated",isSelected:!1},{id:"carrier-003",name:"Schneider National",source:"123Loadboard",rating:4.7,price:2950,estimatedTime:"2-3 days",equipment:"Dry Van",isSelected:!1},{id:"carrier-004",name:"Werner Enterprises",source:"Direct Contact",rating:4.5,price:2750,estimatedTime:"3-4 days",equipment:"Flatbed",isSelected:!1},{id:"carrier-005",name:"Prime Inc.",source:"DAT Load Board",rating:4.9,price:3100,estimatedTime:"2 days",equipment:"Refrigerated",isSelected:!1}],lx=[{id:"call-001",carrierName:"Swift Transportation",callDuration:15,maxDuration:30,callStatus:"in-progress",dealStatus:"negotiating",agreedRate:null,contactInfo:"John Smith - (555) 123-4567",notes:"Discussing pickup time flexibility"},{id:"call-002",carrierName:"Prime Inc.",callDuration:25,maxDuration:30,callStatus:"completed",dealStatus:"agreed",agreedRate:3100,contactInfo:"Sarah Johnson - (555) 987-6543",notes:"Rate agreed, waiting for confirmation email"},{id:"call-003",carrierName:"Werner Enterprises",callDuration:8,maxDuration:30,callStatus:"waiting",dealStatus:"pending",agreedRate:null,contactInfo:"Mike Davis - (555) 456-7890"},{id:"call-004",carrierName:"Schneider National",callDuration:30,maxDuration:30,callStatus:"failed",dealStatus:"declined",agreedRate:null,contactInfo:"Lisa Brown - (555) 321-0987",notes:"Could not reach carrier, voicemail left"}];function cx(){const{theme:e}=ns(),t=Pg(),s=Mg(),n=t.state,{data:r,isLoading:a,error:i}=ex((null==n?void 0:n.workflowId)||""),[o,l]=Oe.useState((null==n?void 0:n.searchResults)||[]),[c,d]=Oe.useState((null==n?void 0:n.searchMetadata)||null),[u,h]=Oe.useState(lx);Oe.useEffect(()=>{if(r&&(null==n?void 0:n.isFromHistory)){const e=r.carriers.map((e,t)=>({id:e.carrier_id,name:e.carrier_name,price:2500+100*t,rating:Math.min(5,Math.max(1,5*e.vetting_details.overall_score)),responseTime:"< 2 hours",equipment:e.type_of_load,location:"Available",capacity:e.fleet_size.toString(),experience:`${e.years_in_business} years`,dotNumber:e.dot_number,contactInfo:e.contact_info,matchScore:e.match_score,vettingResult:e.vetting_result,vettingDetails:e.vetting_details,rfmScore:e.rfm_score})),t={searchId:r.workflow_id,timestamp:new Date(r.created_at),searchCriteria:{origin:r.input_details.origin,destination:r.input_details.destination,pickupDate:r.input_details.pickup_date,deliveryDate:r.input_details.delivery_date,equipmentType:r.input_details.cargo_type,weight:r.input_details.weight,volume:r.input_details.volume},totalResults:r.total_carriers_found,processingTime:r.processing_time_seconds,status:r.status};l(e),d(t)}},[r,null==n?void 0:n.isFromHistory]),Oe.useEffect(()=>{a||(null==n?void 0:n.workflowId)||(null==n?void 0:n.searchResults)&&(null==n?void 0:n.searchMetadata)||s("/search",{replace:!0})},[n,s,a]);const m=e=>{const t=o.find(t=>t.id===e);if(t){const e={id:"call-"+Date.now(),carrierName:t.name,callDuration:0,maxDuration:30,callStatus:"waiting",dealStatus:"pending",agreedRate:null,contactInfo:"Contact info not available",notes:`Called from search results - Rate: $${t.price}`};h(t=>[e,...t]),setTimeout(()=>{h(t=>t.map(t=>t.id===e.id?{...t,callStatus:"in-progress"}:t))},1e3)}};return a&&(null==n?void 0:n.isFromHistory)?$e.jsxs("div",{className:"flex flex-col h-full items-center justify-center",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mb-4"}),$e.jsx("p",{className:"text-gray-600",children:"Loading workflow results..."})]}):i&&(null==n?void 0:n.isFromHistory)?$e.jsxs("div",{className:"flex flex-col h-full items-center justify-center",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"text-red-500 mb-4",children:$e.jsx("p",{children:"Failed to load workflow results"})}),$e.jsx("button",{onClick:()=>s("/search"),className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Back to Search"})]}):c?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(ix,{searchResults:o,callQueueItems:u,searchMetadata:c,onBack:()=>{s(-1)},onCallCarrier:m,onBulkCall:e=>{e.forEach((e,t)=>{setTimeout(()=>m(e),500*t)})},onViewCallDetails:e=>{s(`/call-details/${e}`,{state:{callQueueItems:u,searchResults:o,searchMetadata:c}})},theme:e})})}):null}const dx=e=>{const t=Math.floor(e/3600),s=Math.floor(e%3600/60),n=e%60;return t>0?`${t}:${s.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${s}:${n.toString().padStart(2,"0")}`},ux=e=>{switch(e){case"excellent":return"text-green-600 bg-green-100";case"good":return"text-blue-600 bg-blue-100";case"fair":return"text-yellow-600 bg-yellow-100";case"poor":return"text-red-600 bg-red-100";default:return"text-gray-600 bg-gray-100"}},hx=e=>{switch(e){case"positive":return"text-green-600";case"negative":return"text-red-600";default:return"text-gray-600"}},mx=e=>{switch(e){case"positive":return $e.jsx(zf,{className:"w-4 h-4"});case"negative":return $e.jsx(Ff,{className:"w-4 h-4"});default:return $e.jsx(bf,{className:"w-4 h-4"})}};function px({callDetails:e,onBack:t,theme:s}){var n;const{width:r,containerRef:a}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),i=(e=>e<380?{containerPadding:"p-2",headerPadding:"p-3",cardPadding:"p-3",gridCols:"grid-cols-1",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},spacing:"space-y-2",buttonSize:"px-2 py-1 text-xs",iconSize:"w-3 h-3",maxWidth:"max-w-full",headerLayout:"stacked"}:e<450?{containerPadding:"p-3",headerPadding:"p-3",cardPadding:"p-3",gridCols:"grid-cols-1",textSize:{title:"text-base",subtitle:"text-sm",body:"text-xs",caption:"text-xs"},spacing:"space-y-2",buttonSize:"px-2 py-1 text-xs",iconSize:"w-3 h-3",maxWidth:"max-w-full",tabPadding:"px-2 py-1",sectionSpacing:"space-y-2",metricGrid:"grid-cols-2",transcriptHeight:"max-h-48"}:e<600?{containerPadding:"p-3",headerPadding:"p-4",cardPadding:"p-4",gridCols:"grid-cols-1",textSize:{title:"text-lg",subtitle:"text-base",body:"text-sm",caption:"text-xs"},spacing:"space-y-3",buttonSize:"px-3 py-2 text-sm",iconSize:"w-4 h-4",maxWidth:"max-w-full",tabPadding:"px-3 py-2",sectionSpacing:"space-y-3",metricGrid:"grid-cols-2",transcriptHeight:"max-h-64"}:{containerPadding:"p-4",headerPadding:"p-5",cardPadding:"p-5",gridCols:"grid-cols-1 md:grid-cols-2",textSize:{title:"text-xl",subtitle:"text-lg",body:"text-base",caption:"text-sm"},spacing:"space-y-4",buttonSize:"px-4 py-2 text-base",iconSize:"w-5 h-5",maxWidth:"max-w-full",tabPadding:"px-4 py-2",sectionSpacing:"space-y-4",metricGrid:"grid-cols-3",transcriptHeight:"max-h-80"})(r),[o,l]=Oe.useState("metadata"),[c,d]=Oe.useState(new Set(["overview"])),[u,h]=Oe.useState(""),[m,p]=Oe.useState(!1),[f,g]=Oe.useState(null),y=e=>{const t=new Set(c);t.has(e)?t.delete(e):t.add(e),d(t)},x=(null==(n=e.transcription)?void 0:n.fullTranscript.filter(e=>e.text.toLowerCase().includes(u.toLowerCase())))||[],v=async t=>{p(!0);try{await new Promise(e=>setTimeout(e,1e3));const s={callId:e.callId,timestamp:e.timestamp,duration:e.duration,participants:e.participants,..."transcript"===t&&{transcription:e.transcription}},n=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.href=r,a.download=`call-${e.callId}-${t}.${"pdf"===t?"pdf":"json"}`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r)}catch(s){g("Failed to download file")}finally{p(!1)}};return $e.jsxs("div",{ref:a,className:`${i.maxWidth} mx-auto ${i.containerPadding}`,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border mb-6",children:[$e.jsx("div",{className:`${i.headerPadding} border-b`,children:$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center space-x-4",children:[$e.jsxs("button",{onClick:t,className:`flex items-center space-x-2 text-gray-600 hover:text-gray-800 ${i.buttonSize}`,children:[$e.jsx(Kp,{className:i.iconSize}),$e.jsx("span",{children:"Back"})]}),$e.jsxs("div",{children:[$e.jsx("h1",{className:`font-bold text-gray-900 ${i.textSize.title}`,children:"Call Details"}),$e.jsxs("p",{className:`text-gray-600 ${i.textSize.caption}`,children:["Call ID: ",e.callId]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsxs("button",{onClick:()=>v("json"),disabled:m,className:`flex items-center space-x-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 ${i.buttonSize}`,children:[$e.jsx(lf,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:"Export"})]}),$e.jsxs("button",{className:`flex items-center space-x-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 ${i.buttonSize}`,children:[$e.jsx(Rf,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:"Share"})]})]})]})}),$e.jsx("div",{className:`${i.headerPadding} pt-0`,children:$e.jsx("div",{className:"flex space-x-1 bg-gray-100 rounded-lg p-1",children:[{id:"metadata",label:"Overview",icon:Nf},{id:"details",label:"Technical",icon:Sf},{id:"transcription",label:"Transcript",icon:df}].map(({id:e,label:t,icon:s})=>$e.jsxs("button",{onClick:()=>l(e),className:`flex items-center space-x-1 ${i.tabPadding} rounded-md transition-colors flex-1 justify-center ${i.textSize.body} ${o===e?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-800"}`,children:[$e.jsx(s,{className:i.iconSize}),$e.jsx("span",{className:"hidden sm:inline",children:t}),$e.jsx("span",{className:"sm:hidden",children:t.charAt(0)})]},e))})})]}),f&&$e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-6",children:$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsx(sf,{className:"w-5 h-5 text-red-600"}),$e.jsx("span",{className:"text-red-800",children:f}),$e.jsx("button",{onClick:()=>g(null),className:"ml-auto text-red-600 hover:text-red-800",children:$e.jsx(rf,{className:"w-4 h-4"})})]})}),$e.jsxs(pd.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:i.spacing,children:["metadata"===o&&$e.jsx(fx,{callDetails:e,config:i,expandedSections:c,toggleSection:y}),"details"===o&&$e.jsx(gx,{callDetails:e,config:i,expandedSections:c,toggleSection:y}),"transcription"===o&&$e.jsx(yx,{callDetails:e,config:i,searchTerm:u,setSearchTerm:h,filteredTranscript:x,onDownload:v,isLoading:m})]},o)]})}function fx({callDetails:e,config:t,expandedSections:s,toggleSection:n}){return $e.jsxs("div",{className:t.spacing,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("overview"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Call Overview"}),s.has("overview")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("overview")&&$e.jsxs("div",{className:`${t.cardPadding} pt-0 border-t`,children:[$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(af,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Duration"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:dx(e.duration)})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Nf,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Direction"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.direction})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx("div",{className:"w-3 h-3 rounded-full "+("completed"===e.status?"bg-green-500":"failed"===e.status?"bg-red-500":"in-progress"===e.status?"bg-blue-500":"bg-yellow-500")}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Status"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.status.replace("-"," ")})]})]})]}),$e.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg",children:[$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Started: ",e.timestamp.toLocaleString()]}),e.result.outcome&&$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption} mt-1`,children:["Outcome: ",$e.jsx("span",{className:"capitalize",children:e.result.outcome})]})]})]})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("participants"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsxs("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:["Participants (",e.participants.length,")"]}),s.has("participants")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("participants")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t space-y-3`,children:e.participants.map(e=>$e.jsxs("div",{className:"flex items-center space-x-3 p-3 bg-gray-50 rounded-lg",children:[$e.jsx(_f,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{className:"flex-1",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.name}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.role," • ",e.company||"Unknown Company"]}),e.phoneNumber&&$e.jsx("p",{className:`text-gray-500 ${t.textSize.caption}`,children:e.phoneNumber})]}),$e.jsx("div",{className:"px-2 py-1 rounded-full text-xs "+("caller"===e.role?"bg-blue-100 text-blue-800":"receiver"===e.role?"bg-green-100 text-green-800":"bg-purple-100 text-purple-800"),children:e.role})]},e.id))})]}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Call Quality"}),$e.jsxs("div",{className:"flex items-center space-x-4 mb-4",children:[$e.jsx("div",{className:"flex items-center space-x-2",children:[1,2,3,4,5].map(t=>$e.jsx($f,{className:"w-5 h-5 "+(t<=e.quality.overallScore?"text-yellow-400 fill-current":"text-gray-300")},t))}),$e.jsxs("span",{className:`font-medium ${t.textSize.body}`,children:[e.quality.overallScore,"/5"]}),$e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium ${ux(e.quality.audioQuality)}`,children:e.quality.audioQuality})]}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Signal Strength"}),$e.jsxs("div",{className:"flex items-center space-x-2",children:[$e.jsx("div",{className:"flex-1 bg-gray-200 rounded-full h-2",children:$e.jsx("div",{className:"bg-green-500 h-2 rounded-full",style:{width:`${e.quality.signalStrength}%`}})}),$e.jsxs("span",{className:`${t.textSize.caption} font-medium`,children:[e.quality.signalStrength,"%"]})]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Latency"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.quality.latency,"ms"]})]})]})]})})]})}function gx({callDetails:e,config:t,expandedSections:s,toggleSection:n}){return $e.jsxs("div",{className:t.spacing,children:[$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("network"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Network Information"}),s.has("network")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("network")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t`,children:$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(qf,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Connection"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e.network.connectionType})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Df,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Bandwidth"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.network.bandwidth," kbps"]})]})]}),$e.jsxs("div",{className:"col-span-full",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body} mb-2`,children:"Location"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.network.location.city,", ",e.network.location.state,", ",e.network.location.country]}),$e.jsxs("p",{className:`text-gray-500 ${t.textSize.caption} mt-1`,children:["IP: ",e.network.ipAddress," • Provider: ",e.network.provider]})]})]})})]}),$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border",children:[$e.jsxs("button",{onClick:()=>n("device"),className:`w-full ${t.cardPadding} flex items-center justify-between text-left`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Device Information"}),s.has("device")?$e.jsx(tf,{className:t.iconSize}):$e.jsx(Xp,{className:t.iconSize})]}),s.has("device")&&$e.jsx("div",{className:`${t.cardPadding} pt-0 border-t`,children:$e.jsxs("div",{className:`grid ${t.gridCols} gap-4`,children:[$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(Sf,{className:`${t.iconSize} text-blue-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Browser"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.device.browser," ",e.device.browserVersion]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx("div",{className:`${t.iconSize} bg-gray-200 rounded flex items-center justify-center`,children:$e.jsx("span",{className:"text-xs font-bold",children:"OS"})}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Operating System"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:[e.device.operatingSystem," ",e.device.osVersion]})]})]}),$e.jsxs("div",{className:"flex items-center space-x-3",children:[$e.jsx(hf,{className:`${t.iconSize} text-green-600`}),$e.jsxs("div",{children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:"Audio Devices"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Mic: ",e.device.microphone]}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.caption}`,children:["Speaker: ",e.device.speaker]})]})]})]})})]}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Codec & Technical Parameters"}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-4",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Audio Codec"}),$e.jsx("p",{className:`font-medium ${t.textSize.body}`,children:e.codec.audioCodec})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Bitrate"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.codec.bitrate," kbps"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Sample Rate"}),$e.jsxs("p",{className:`font-medium ${t.textSize.body}`,children:[e.codec.sampleRate," Hz"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Channels"}),$e.jsx("p",{className:`font-medium ${t.textSize.body}`,children:e.codec.channels})]})]}),$e.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[$e.jsx("h3",{className:`font-medium text-gray-900 ${t.textSize.body} mb-2`,children:"Performance Metrics"}),$e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"RTP Packets Sent"}),$e.jsx("p",{className:"font-medium",children:e.technicalParams.rtpPackets.sent.toLocaleString()})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"RTP Packets Lost"}),$e.jsx("p",{className:"font-medium",children:e.technicalParams.rtpPackets.lost.toLocaleString()})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"CPU Usage"}),$e.jsxs("p",{className:"font-medium",children:[e.technicalParams.cpu.usage,"%"]})]}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-gray-600",children:"Memory Used"}),$e.jsxs("p",{className:"font-medium",children:[e.technicalParams.memory.used," MB"]})]})]})]})]})})]})}function yx({callDetails:e,config:t,searchTerm:s,setSearchTerm:n,filteredTranscript:r,onDownload:a,isLoading:i}){return e.transcription?$e.jsxs("div",{className:t.spacing,children:[$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[$e.jsx("h2",{className:`font-semibold text-gray-900 ${t.textSize.subtitle}`,children:"Call Transcription"}),$e.jsxs("button",{onClick:()=>a("transcript"),disabled:i,className:`flex items-center space-x-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 ${t.buttonSize}`,children:[$e.jsx(lf,{className:t.iconSize}),$e.jsx("span",{children:"Download"})]})]}),$e.jsxs("div",{className:"relative mb-4",children:[$e.jsx(Pf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),$e.jsx("input",{type:"text",placeholder:"Search transcript...",value:s,onChange:e=>n(e.target.value),className:`w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t.textSize.body}`})]}),$e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsxs("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:[e.transcription.confidence,"%"]}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Confidence"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.transcription.speakers.length}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Speakers"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:e.transcription.fullTranscript.length}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Segments"})]}),$e.jsxs("div",{className:"text-center p-3 bg-gray-50 rounded-lg",children:[$e.jsx("p",{className:`font-medium text-gray-900 ${t.textSize.body} capitalize`,children:e.transcription.language}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption}`,children:"Language"})]})]})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Sentiment Analysis"}),$e.jsxs("div",{className:"flex items-center space-x-4 mb-4",children:[$e.jsxs("div",{className:`flex items-center space-x-2 ${hx(e.transcription.sentimentAnalysis.overall)}`,children:[mx(e.transcription.sentimentAnalysis.overall),$e.jsx("span",{className:`font-medium capitalize ${t.textSize.body}`,children:e.transcription.sentimentAnalysis.overall})]}),$e.jsxs("div",{className:"px-3 py-1 rounded-full text-xs font-medium "+(e.transcription.sentimentAnalysis.score>.3?"bg-green-100 text-green-800":e.transcription.sentimentAnalysis.score<-.3?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"),children:["Score: ",e.transcription.sentimentAnalysis.score.toFixed(2)]})]}),$e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-2",children:Object.entries(e.transcription.sentimentAnalysis.emotions).map(([e,s])=>$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mb-1",children:$e.jsx("div",{className:"bg-blue-500 h-2 rounded-full",style:{width:100*s+"%"}})}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.caption} capitalize`,children:e})]},e))})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Key Phrases"}),$e.jsx("div",{className:"flex flex-wrap gap-2",children:e.transcription.keyPhrases.slice(0,10).map((e,t)=>$e.jsxs("span",{className:"px-3 py-1 rounded-full text-xs font-medium "+(e.importance>7?"bg-red-100 text-red-800":e.importance>5?"bg-yellow-100 text-yellow-800":"bg-blue-100 text-blue-800"),children:[e.phrase," (",e.frequency,")"]},t))})]})}),$e.jsx("div",{className:"bg-white rounded-lg shadow-lg border",children:$e.jsxs("div",{className:`${t.cardPadding}`,children:[$e.jsx("h3",{className:`font-semibold text-gray-900 ${t.textSize.subtitle} mb-4`,children:"Full Transcript"}),$e.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:(s?r:e.transcription.fullTranscript).map(n=>{const r=e.transcription.speakers.find(e=>e.id===n.speakerId);return $e.jsxs("div",{className:"flex space-x-3 p-3 hover:bg-gray-50 rounded-lg",children:[$e.jsx("div",{className:"flex-shrink-0",children:$e.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center",children:$e.jsx("span",{className:"text-xs font-medium text-blue-800",children:(null==r?void 0:r.name.charAt(0))||"U"})})}),$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:"flex items-center space-x-2 mb-1",children:[$e.jsx("span",{className:`font-medium text-gray-900 ${t.textSize.body}`,children:(null==r?void 0:r.name)||"Unknown"}),$e.jsx("span",{className:`text-gray-500 ${t.textSize.caption}`,children:(a=n.timestamp,`${Math.floor(a/60)}:${Math.floor(a%60).toString().padStart(2,"0")}`)}),n.sentiment&&$e.jsx("span",{className:`${hx(n.sentiment)} ${t.textSize.caption}`,children:mx(n.sentiment)})]}),$e.jsx("p",{className:`text-gray-700 ${t.textSize.body}`,children:s?n.text.split(new RegExp(`(${s})`,"gi")).map((e,t)=>e.toLowerCase()===s.toLowerCase()?$e.jsx("mark",{className:"bg-yellow-200",children:e},t):e):n.text}),$e.jsx("div",{className:"flex items-center space-x-2 mt-1",children:$e.jsxs("span",{className:`text-gray-500 ${t.textSize.caption}`,children:["Confidence: ",n.confidence,"%"]})})]})]},n.id);var a})}),s&&0===r.length&&$e.jsxs("div",{className:"text-center py-8",children:[$e.jsx(Pf,{className:"w-8 h-8 text-gray-400 mx-auto mb-2"}),$e.jsxs("p",{className:`text-gray-600 ${t.textSize.body}`,children:['No results found for "',s,'"']})]})]})})]}):$e.jsxs("div",{className:"bg-white rounded-lg shadow-lg border p-8 text-center",children:[$e.jsx(df,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),$e.jsx("h3",{className:`font-medium text-gray-900 ${t.textSize.subtitle} mb-2`,children:"No Transcription Available"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,children:"Transcription is not available for this call."})]})}const xx=(e,t)=>{const s=Math.floor(1800*Math.random())+300,n=new Date(Date.now()-864e5*Math.random()),r=[{id:"participant-1",name:"John Smith",role:"caller",phoneNumber:"+1 (555) 123-4567",email:"john.smith@logistics.com",company:"Logistics Solutions Inc.",joinTime:n,leaveTime:new Date(n.getTime()+1e3*s)},{id:"participant-2",name:t.split(" ")[0]+" Representative",role:"receiver",phoneNumber:"+1 (555) 987-6543",email:`contact@${t.toLowerCase().replace(/\s+/g,"")}.com`,company:t,joinTime:new Date(n.getTime()+15e3),leaveTime:new Date(n.getTime()+1e3*s)}],a={overallScore:Math.floor(2*Math.random())+4,signalStrength:Math.floor(20*Math.random())+80,latency:Math.floor(50*Math.random())+20,jitter:Math.floor(10*Math.random())+2,packetLoss:2*Math.random(),audioQuality:["excellent","good","fair"][Math.floor(3*Math.random())],connectionStability:["stable","unstable"][Math.floor(2*Math.random())]},i={ipAddress:`192.168.${Math.floor(255*Math.random())}.${Math.floor(255*Math.random())}`,connectionType:["wifi","ethernet","cellular"][Math.floor(3*Math.random())],bandwidth:Math.floor(500*Math.random())+100,provider:["Verizon","AT&T","Comcast","Spectrum"][Math.floor(4*Math.random())],location:{city:["New York","Los Angeles","Chicago","Houston","Phoenix"][Math.floor(5*Math.random())],state:["NY","CA","IL","TX","AZ"][Math.floor(5*Math.random())],country:"United States"}},o={browser:["Chrome","Firefox","Safari","Edge"][Math.floor(4*Math.random())],browserVersion:`${Math.floor(20*Math.random())+90}.0.${Math.floor(10*Math.random())}.${Math.floor(100*Math.random())}`,operatingSystem:["Windows","macOS","Linux"][Math.floor(3*Math.random())],osVersion:["11","10.15","20.04"][Math.floor(3*Math.random())],microphone:["Built-in Microphone","USB Headset","Bluetooth Headset"][Math.floor(3*Math.random())],speaker:["Built-in Speakers","USB Headset","Bluetooth Headset"][Math.floor(3*Math.random())],camera:Math.random()>.5?"Built-in Camera":void 0,deviceType:["desktop","mobile","tablet"][Math.floor(3*Math.random())]},l={audioCodec:["Opus","G.722","G.711"][Math.floor(3*Math.random())],bitrate:Math.floor(64*Math.random())+32,sampleRate:[8e3,16e3,48e3][Math.floor(3*Math.random())],channels:Math.random()>.5?2:1,compression:["Lossless","Lossy"][Math.floor(2*Math.random())]},c={rtpPackets:{sent:Math.floor(1e4*Math.random())+5e3,received:Math.floor(1e4*Math.random())+5e3,lost:Math.floor(100*Math.random())+10},bandwidth:{upload:Math.floor(100*Math.random())+50,download:Math.floor(200*Math.random())+100},cpu:{usage:Math.floor(30*Math.random())+10,temperature:Math.floor(20*Math.random())+45},memory:{used:Math.floor(2048*Math.random())+512,available:Math.floor(4096*Math.random())+2048}},d={id:`transcript-${e}`,fullTranscript:[{id:"segment-1",speakerId:"participant-1",text:`Hello, this is John from Logistics Solutions. I'm calling about a shipment from ${["Chicago","New York","Los Angeles"][Math.floor(3*Math.random())]} to ${["Miami","Seattle","Denver"][Math.floor(3*Math.random())]}.`,timestamp:5,duration:8,confidence:95,sentiment:"neutral"},{id:"segment-2",speakerId:"participant-2",text:`Hi John, thanks for calling ${t}. I'd be happy to help you with that shipment. Can you tell me more about the cargo details?`,timestamp:15,duration:6,confidence:92,sentiment:"positive"},{id:"segment-3",speakerId:"participant-1",text:`Sure! We have ${Math.floor(20*Math.random())+5} pallets of ${["electronics","automotive parts","consumer goods","machinery"][Math.floor(4*Math.random())]}, total weight around ${Math.floor(3e4*Math.random())+1e4} pounds. We need it delivered by ${new Date(Date.now()+6048e5*Math.random()).toLocaleDateString()}.`,timestamp:23,duration:12,confidence:88,sentiment:"neutral"},{id:"segment-4",speakerId:"participant-2",text:`That sounds manageable. For that route and timeline, we can offer a rate of $${(2e3*Math.random()+1500).toFixed(2)} for the full load. Does that work within your budget?`,timestamp:38,duration:9,confidence:94,sentiment:"positive"},{id:"segment-5",speakerId:"participant-1",text:`That's a bit higher than we were hoping for. Our budget is closer to $${(1500*Math.random()+1200).toFixed(2)}. Is there any flexibility on the pricing?`,timestamp:50,duration:8,confidence:90,sentiment:"negative"},{id:"segment-6",speakerId:"participant-2",text:`I understand your budget constraints. Let me check with my manager... Okay, I can do $${(1800*Math.random()+1400).toFixed(2)} as our best offer. That includes full insurance coverage.`,timestamp:62,duration:11,confidence:87,sentiment:"neutral"},{id:"segment-7",speakerId:"participant-1",text:"That works better for us. Let's move forward with that rate. What's the next step to book this shipment?",timestamp:76,duration:7,confidence:93,sentiment:"positive"},{id:"segment-8",speakerId:"participant-2",text:`Excellent! I'll send you a booking confirmation within the next hour. You'll receive pickup instructions and our driver's contact information. Thank you for choosing ${t}!`,timestamp:85,duration:10,confidence:96,sentiment:"positive"}],speakers:[{id:"participant-1",name:"John Smith",voiceProfile:{pitch:120,tone:"professional",accent:"American Midwest"},speakingTime:Math.floor(.45*s),wordCount:245},{id:"participant-2",name:t.split(" ")[0]+" Representative",voiceProfile:{pitch:140,tone:"friendly",accent:"American South"},speakingTime:Math.floor(.55*s),wordCount:198}],sentimentAnalysis:{overall:"positive",score:.65,emotions:{joy:.3,anger:.1,fear:.05,sadness:.02,surprise:.15},trends:[{timestamp:0,sentiment:"neutral",score:0},{timestamp:20,sentiment:"positive",score:.3},{timestamp:50,sentiment:"negative",score:-.2},{timestamp:70,sentiment:"positive",score:.6},{timestamp:90,sentiment:"positive",score:.8}]},keyPhrases:[{phrase:"shipment",frequency:8,importance:9,category:"business",timestamps:[5,15,23,76]},{phrase:"rate",frequency:6,importance:8,category:"business",timestamps:[38,50,62]},{phrase:"budget",frequency:4,importance:7,category:"business",timestamps:[50,62]},{phrase:"insurance",frequency:2,importance:6,category:"business",timestamps:[62]},{phrase:"delivery",frequency:3,importance:7,category:"business",timestamps:[23,76]},{phrase:"pallets",frequency:2,importance:5,category:"technical",timestamps:[23]},{phrase:"thank you",frequency:2,importance:4,category:"emotional",timestamps:[15,85]}],summary:`Successful negotiation call between John Smith from Logistics Solutions and ${t} representative. Discussed shipment details, negotiated pricing from initial quote to agreed rate, and finalized booking. Call resulted in confirmed shipment booking with insurance coverage.`,confidence:91,language:"English"},u={recordingUrl:`https://recordings.example.com/calls/${e}.mp3`,recordingSize:Math.floor(5e7*Math.random())+1e7,callCost:5*Math.random()+2,region:"US-East",serverLocation:"Virginia, USA",encryption:!0,compliance:{gdpr:!0,hipaa:!1,sox:!0}},h={outcome:Math.random()>.2?"successful":"failed",reason:Math.random()>.2?"Agreement reached on pricing and terms":"Unable to meet budget requirements",followUpRequired:Math.random()>.7,nextAction:Math.random()>.7?"Send booking confirmation":void 0,dealValue:3e3*Math.random()+1e3,agreementReached:Math.random()>.2};return{id:`call-details-${e}`,callId:e,timestamp:n,duration:s,participants:r,direction:Math.random()>.5?"outbound":"inbound",status:"completed",result:h,quality:a,network:i,device:o,codec:l,technicalParams:c,transcription:d,metadata:u}};function vx(){const{theme:e}=ns(),{callId:t}=Dg(),s=Pg(),n=Mg(),r=s.state,[a,i]=Oe.useState(null);Oe.useEffect(()=>{var e;if(!t)return void n("/search",{replace:!0});const s=null==(e=null==r?void 0:r.callQueueItems)?void 0:e.find(e=>e.id===t);if(s){const e=xx(t,s.carrierName);i(e)}else{const e=xx(t,"Unknown Carrier");i(e)}},[t,r,n]);return a?$e.jsx("div",{className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:$e.jsx("div",{className:"flex-1 overflow-y-auto",children:$e.jsx(px,{callDetails:a,onBack:()=>{(null==r?void 0:r.fromCallLogs)?n("/call-logs"):(null==r?void 0:r.searchResults)&&(null==r?void 0:r.searchMetadata)?n("/results",{state:r}):n("/search")},theme:e})})}):$e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsx("div",{className:"text-center",children:$e.jsx("p",{className:"text-gray-600",style:{fontFamily:e.fontFamily},children:"Loading call details..."})})})}xx("call-1","Swift Transport"),xx("call-2","Reliable Freight"),xx("call-3","Express Logistics");const bx=({isOpen:e,onClose:t,onConfirm:s,title:n,message:r,confirmText:a="Confirm",cancelText:i="Cancel",isLoading:o=!1,variant:l="danger",containedMode:c=!1})=>{if(!e)return null;const d=(()=>{switch(l){case"danger":default:return{icon:"text-red-500",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",iconBg:"bg-red-100"};case"warning":return{icon:"text-yellow-500",confirmButton:"bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500",iconBg:"bg-yellow-100"};case"info":return{icon:"text-blue-500",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",iconBg:"bg-blue-100"}}})(),u=c?"absolute inset-0 z-50 overflow-y-auto":"fixed inset-0 z-50 overflow-y-auto",h=c?"absolute inset-0 bg-black bg-opacity-50 transition-opacity":"fixed inset-0 bg-black bg-opacity-50 transition-opacity";return $e.jsxs("div",{className:u,children:[$e.jsx("div",{className:h,onClick:t}),$e.jsx("div",{className:"flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0",children:$e.jsxs("div",{className:"relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg",children:[$e.jsx("div",{className:"bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4",children:$e.jsxs("div",{className:"sm:flex sm:items-start",children:[$e.jsx("div",{className:`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${d.iconBg} sm:mx-0 sm:h-10 sm:w-10`,children:$e.jsx(Lf,{className:`h-6 w-6 ${d.icon}`})}),$e.jsxs("div",{className:"mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left flex-1",children:[$e.jsxs("div",{className:"flex items-center justify-between",children:[$e.jsx("h3",{className:"text-base font-semibold leading-6 text-gray-900",children:n}),$e.jsxs("button",{type:"button",className:"rounded-md bg-white text-gray-400 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:t,children:[$e.jsx("span",{className:"sr-only",children:"Close"}),$e.jsx(Uf,{className:"h-6 w-6"})]})]}),$e.jsx("div",{className:"mt-2",children:$e.jsx("p",{className:"text-sm text-gray-500",children:r})})]})]})}),$e.jsxs("div",{className:"bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6",children:[$e.jsx("button",{type:"button",className:`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm sm:ml-3 sm:w-auto ${d.confirmButton} focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,onClick:s,disabled:o,children:o?$e.jsxs($e.Fragment,{children:[$e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[$e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),$e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Processing..."]}):a}),$e.jsx("button",{type:"button",className:"mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto",onClick:t,disabled:o,children:i})]})]})})]})};function wx({fetchData:e,pageSize:t=10,initialData:s=[],enabled:n=!0,dependencies:r=[]}){const[a,i]=Oe.useState(s),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(null),[u,h]=Oe.useState(!0),[m,p]=Oe.useState(0),[f,g]=Oe.useState(0),y=Oe.useRef(!1),x=Oe.useCallback(async()=>{if(n&&!o&&u&&!y.current){y.current=!0,l(!0),d(null);try{const s=m+1,n=await e(s,t);i(e=>[...e,...n.data]),h(n.hasMore),p(s),void 0!==n.total&&g(n.total)}catch(s){d(s instanceof Error?s.message:"Failed to load data")}finally{l(!1),y.current=!1}}},[n,u,m,e,t]),v=Oe.useCallback(async()=>{if(n){i([]),p(0),h(!0),d(null),g(0),y.current=!1,l(!0);try{const s=await e(1,t);i(s.data),h(s.hasMore),p(1),void 0!==s.total&&g(s.total)}catch(s){d(s instanceof Error?s.message:"Failed to load data")}finally{l(!1)}}},[n,e,t]);return Oe.useEffect(()=>{r.length>0&&v()},r),Oe.useEffect(()=>{n&&0===a.length&&0===m&&!o&&x()},[n,a.length,m,o]),{data:a,loading:o,error:c,hasMore:u,loadMore:x,refresh:v,total:f,currentPage:m}}function Sx(e,t,s,n=100){const r=Oe.useRef(null);return Oe.useEffect(()=>{const a=r.current;if(!a||!t||s)return;const i=new IntersectionObserver(t=>{t[0].isIntersecting&&e()},{rootMargin:`${n}px`,threshold:.1});return i.observe(a),()=>{i.disconnect()}},[e,t,s,n]),r}function jx({item:e,onView:t,onDelete:s,theme:n,config:r}){var a;const i="searchFormData"in e,o=e.title,l=i?e.searchFormData.origin:e.origin,c=i?e.searchFormData.destination:e.destination,d=i?e.searchFormData.equipmentType:e.cargoType,u=i?e.searchFormData.pickupEarliest:null==(a=e.pickupDate)?void 0:a.split("T")[0],h=i?e.resultsCount:e.totalCarriers,m=i?e.timestamp:e.createdAt,p=i?"completed":e.status,f=Yy(p);return $e.jsx(pd.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},whileHover:{scale:1.01},transition:{duration:.2},children:$e.jsx(By,{className:`${r.cardPadding} ${r.cardHeight} transition-all duration-200 hover:shadow-md border`,style:{fontFamily:n.fontFamily},children:$e.jsxs("div",{className:"flex items-start justify-between",children:[$e.jsxs("div",{className:"flex-1 min-w-0",children:[$e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[$e.jsx(Pf,{className:`${r.iconSize} text-gray-500 flex-shrink-0`}),$e.jsx("h3",{className:`font-medium ${r.textSize.title} truncate`,children:o}),!f&&$e.jsx("div",{className:"flex items-center gap-1",children:$e.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-yellow-100 text-yellow-800",children:p})})]}),$e.jsxs("div",{className:`${r.spacing} mb-3`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(xf,{className:`${r.iconSize} text-gray-400`}),$e.jsxs("span",{className:`text-gray-600 ${r.textSize.body} truncate`,children:[l," → ",c]})]}),$e.jsxs("div",{className:"flex items-center gap-4",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:`${r.iconSize} text-gray-400`}),$e.jsx("span",{className:`text-gray-600 ${r.textSize.caption}`,children:d})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:`${r.iconSize} text-gray-400`}),$e.jsx("span",{className:`text-gray-600 ${r.textSize.caption}`,children:u})]})]})]}),$e.jsxs("div",{className:"flex items-center gap-4 text-gray-500",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(af,{className:`${r.iconSize}`}),$e.jsx("span",{className:r.textSize.caption,children:m.toLocaleDateString()})]}),$e.jsxs("span",{className:r.textSize.caption,children:[h," result",1!==h?"s":""]})]})]}),$e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:e=>{e.stopPropagation(),s()},className:`${r.buttonSize} p-1 text-gray-400 hover:text-red-500`,children:[$e.jsx(Of,{className:r.iconSize}),$e.jsx("span",{className:"sr-only",children:"Delete search"})]}),$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:t,className:`${r.buttonSize} text-blue-600 hover:text-blue-800 hover:bg-blue-50`,disabled:!f,children:[f?$e.jsx(cf,{className:r.iconSize}):$e.jsx(ff,{className:`${r.iconSize} animate-spin`}),$e.jsx("span",{className:"hidden sm:inline ml-1",children:f?"View":"Processing"})]})]})]})})})}function kx({theme:e,config:t}){return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:e.primaryColor+"20"},children:$e.jsx(Pf,{className:"h-8 w-8",style:{color:e.primaryColor}})}),$e.jsx("h3",{className:`${t.textSize.title} font-semibold mb-2`,style:{fontFamily:e.fontFamily},children:"No search history"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,style:{fontFamily:e.fontFamily},children:"Your carrier searches will appear here."})]})})}function Nx({config:e}){return $e.jsx("div",{className:"flex justify-center py-4",children:$e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})})}function Ex(){const{theme:e}=ns(),t=Mg(),{width:s,containerRef:n}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),r=(e=>e<380?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-xs",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[110px]",maxCardsVisible:2.8}:e<450?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[120px]",maxCardsVisible:2.5}:e<600?{containerPadding:"p-3",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-1 text-xs",headerPadding:"p-3",cardHeight:"min-h-[130px]",maxCardsVisible:2.2}:{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-2 text-sm",headerPadding:"p-4",cardHeight:"min-h-[140px]",maxCardsVisible:2})(s),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(""),[u,h]=Oe.useState(""),[m,p]=Oe.useState({isOpen:!1,workflowId:null,workflowName:""}),{fetchWorkflowPage:f}=Xy(),g=Zy({onSuccess:()=>{p({isOpen:!1,workflowId:null,workflowName:""}),j()},onError:e=>{console.error("Failed to delete workflow:",e)}}),y=Oe.useCallback((e,t)=>f(e),[f]),{data:x,loading:v,error:b,hasMore:w,loadMore:S,refresh:j}=wx({fetchData:y,pageSize:10,enabled:!0,dependencies:[c,u]}),k=Sx(S,w,v),N=async e=>{var s,n,r;if(Yy(e.status))try{const s=e.workflow_id||e.id;t("/results",{state:{workflowId:s,isFromHistory:!0}})}catch(a){console.error("Error viewing workflow:",a);const i={origin:e.origin,destination:e.destination,pickupEarliest:(null==(s=e.pickupDate)?void 0:s.split("T")[0])||"",pickupHours:"08:00",dropoffHours:"17:00",equipmentType:e.cargoType,length:"48",weight:(null==(n=e.weight)?void 0:n.toString())||"40000",volume:(null==(r=e.volume)?void 0:r.toString())||"2000"},{results:o,metadata:l}=(e=>{const t=ox.filter(t=>"Dry Van"===e.equipmentType||"Dry Van"!==t.equipment||Math.random()>.3).map(e=>({...e,price:e.price+Math.floor(500*Math.random())-250,isSelected:!1}));return{results:t,metadata:{searchId:"search-"+Date.now(),timestamp:new Date,totalResults:t.length,searchCriteria:{origin:e.origin,destination:e.destination,pickupDate:e.pickupEarliest,equipmentType:e.equipmentType,weight:parseInt(e.weight)||4e4,volume:parseInt(e.volume||"2000")}}}})(i);t("/results",{state:{searchResults:o,searchMetadata:l,searchFormData:i}})}};return $e.jsxs("div",{ref:n,className:"flex flex-col h-full relative",style:{fontFamily:e.fontFamily},children:[$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>i(!a),className:`w-full ${r.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Pf,{className:r.iconSize}),$e.jsx("span",{className:`${r.textSize.body} font-medium`,children:"Search History"})]}),a?$e.jsx(tf,{className:r.iconSize}):$e.jsx(Xp,{className:r.iconSize})]}),a&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:r.containerPadding,children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${r.iconSize} text-gray-400`}),$e.jsx("input",{type:"text",placeholder:"Search your history...",value:c,onChange:e=>d(e.target.value),className:`w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${r.textSize.body}`}),c&&$e.jsx("button",{onClick:()=>d(""),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",children:$e.jsx(Uf,{className:r.iconSize})})]})})})]}),$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>l(!o),className:`w-full ${r.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(uf,{className:r.iconSize}),$e.jsx("span",{className:`${r.textSize.body} font-medium`,children:"Filters"}),u&&$e.jsx("span",{className:`${r.textSize.caption} bg-blue-100 text-blue-800 px-2 py-1 rounded-full`,children:u})]}),o?$e.jsx(tf,{className:r.iconSize}):$e.jsx(Xp,{className:r.iconSize})]}),o&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:r.containerPadding,children:$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>h(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>h("Dry Van"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Dry Van"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Dry Van"}),$e.jsx("button",{onClick:()=>h("Refrigerated"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Refrigerated"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Refrigerated"}),$e.jsx("button",{onClick:()=>h("Flatbed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("Flatbed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Flatbed"})]})})})]}),$e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[b&&$e.jsx("div",{className:"p-4",children:$e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[$e.jsxs("p",{className:"text-red-800 text-sm",children:["Failed to load search history: ",b]}),$e.jsx(Ou,{onClick:j,className:"mt-2 text-sm bg-red-600 text-white hover:bg-red-700",children:"Retry"})]})}),b||0!==x.length||v?$e.jsxs("div",{className:`${r.containerPadding} ${r.spacing}`,children:[x.map(t=>$e.jsx(jx,{item:t,onView:()=>N(t),onDelete:()=>(e=>{p({isOpen:!0,workflowId:e.workflow_id||e.id,workflowName:e.workflow_name||`${e.origin} → ${e.destination}`})})(t),theme:e,config:r},t.id)),v&&$e.jsx(Nx,{config:r}),w&&$e.jsx("div",{ref:k,className:"h-4"}),!w&&x.length>0&&$e.jsx("div",{className:"text-center py-4",children:$e.jsx("p",{className:`text-gray-500 ${r.textSize.caption}`,children:"No more search history to load"})})]}):$e.jsx(kx,{theme:e,config:r})]}),$e.jsx(bx,{isOpen:m.isOpen,onClose:()=>{p({isOpen:!1,workflowId:null,workflowName:""})},onConfirm:()=>{m.workflowId&&g.mutate(m.workflowId)},title:"Delete Workflow",message:`Are you sure you want to delete "${m.workflowName}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",isLoading:g.isPending,variant:"danger",containedMode:!0})]})}function Cx({theme:e,config:t}){return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:e.primaryColor+"20"},children:$e.jsx(Nf,{className:"h-8 w-8",style:{color:e.primaryColor}})}),$e.jsx("h3",{className:`${t.textSize.title} font-semibold mb-2`,style:{fontFamily:e.fontFamily},children:"No call logs found"}),$e.jsx("p",{className:`text-gray-600 ${t.textSize.body}`,style:{fontFamily:e.fontFamily},children:"Try adjusting your filters or search terms."})]})})}function Tx({config:e}){return $e.jsx("div",{className:"flex justify-center py-4",children:$e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"})})}function Px(){const{theme:e}=ns(),{width:t,containerRef:s}=(()=>{const[e,t]=Oe.useState(0),s=Oe.useRef(null);return Oe.useEffect(()=>{const e=()=>{s.current&&t(s.current.offsetWidth)};e();const n=new ResizeObserver(e);return s.current&&n.observe(s.current),()=>n.disconnect()},[]),{width:e,containerRef:s}})(),n=(e=>e<380?{containerPadding:"p-2",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-xs",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",filterPadding:"p-2",inputSize:"text-xs"}:e<450?{containerPadding:"p-3",cardPadding:"p-3",spacing:"space-y-2",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-3 h-3",buttonSize:"px-2 py-1 text-xs",headerPadding:"p-3",filterPadding:"p-2",inputSize:"text-xs"}:e<600?{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-1 text-xs",headerPadding:"p-4",filterPadding:"p-3",inputSize:"text-sm"}:{containerPadding:"p-4",cardPadding:"p-4",spacing:"space-y-3",textSize:{title:"text-sm",subtitle:"text-xs",body:"text-xs",caption:"text-xs"},iconSize:"w-4 h-4",buttonSize:"px-3 py-2 text-sm",headerPadding:"p-4",filterPadding:"p-4",inputSize:"text-sm"})(t),r=Mg(),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1),[c,d]=Oe.useState(""),[u,h]=Oe.useState(""),[m,p]=Oe.useState(""),[f,g]=Oe.useState({search:c,status:u,carrier:"",dealStatus:m,dateRange:{start:"",end:""}});Oe.useEffect(()=>{g(e=>({...e,search:c,status:u,dealStatus:m}))},[c,u,m]);const y=Oe.useCallback((e,t)=>((e,t,s)=>new Promise(n=>{setTimeout(()=>{const r=[],a=(e-1)*t,i=["Swift Transportation","J.B. Hunt","Schneider","Werner Enterprises","C.R. England"],o=["New York, NY","Los Angeles, CA","Chicago, IL","Houston, TX","Phoenix, AZ"],l=["Miami, FL","Seattle, WA","Denver, CO","Atlanta, GA","Boston, MA"],c=["waiting","in-progress","completed","failed"],d=["pending","negotiating","agreed","declined"];for(let e=0;e<t;e++){const t=a+e;if(t>=100)break;const n=i[t%i.length],u=o[t%o.length],h=l[t%l.length],m=c[t%c.length],p=d[t%d.length];if(s.search&&!n.toLowerCase().includes(s.search.toLowerCase())&&!u.toLowerCase().includes(s.search.toLowerCase())&&!h.toLowerCase().includes(s.search.toLowerCase()))continue;if(s.status&&m!==s.status)continue;if(s.carrier&&!n.toLowerCase().includes(s.carrier.toLowerCase()))continue;if(s.dealStatus&&p!==s.dealStatus)continue;const f=new Date(Date.now()-30*Math.random()*24*60*60*1e3);s.dateRange.start&&f<new Date(s.dateRange.start)||s.dateRange.end&&f>new Date(s.dateRange.end)||r.push({id:`call-${t+1}`,carrierName:n,callDuration:Math.floor(30*Math.random())+5,maxDuration:45,callStatus:m,dealStatus:p,agreedRate:"agreed"===p?Math.floor(3e3*Math.random())+1500:null,contactInfo:`+1-555-${String(Math.floor(9e3*Math.random())+1e3)}`,notes:`Call notes for ${n}`})}n({data:r,hasMore:a+t<100,total:100})},300)}))(e,t,f),[f]),{data:x,loading:v,error:b,hasMore:w,loadMore:S,refresh:j}=wx({fetchData:y,pageSize:10,enabled:!0,dependencies:[f]}),k=Sx(S,w,v);return $e.jsxs("div",{ref:s,className:"flex flex-col h-full",style:{fontFamily:e.fontFamily},children:[$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>i(!a),className:`w-full ${n.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Pf,{className:n.iconSize}),$e.jsx("span",{className:`${n.textSize.body} font-medium`,children:"Search Calls"})]}),a?$e.jsx(tf,{className:n.iconSize}):$e.jsx(Xp,{className:n.iconSize})]}),a&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:n.containerPadding,children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 ${n.iconSize} text-gray-400`}),$e.jsx("input",{type:"text",placeholder:"Search calls, carriers, locations...",value:c,onChange:e=>d(e.target.value),className:`w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${n.textSize.body}`}),c&&$e.jsx("button",{onClick:()=>d(""),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",children:$e.jsx(Uf,{className:n.iconSize})})]})})})]}),$e.jsxs("div",{className:"border-b",children:[$e.jsxs("button",{onClick:()=>l(!o),className:`w-full ${n.headerPadding} flex items-center justify-between hover:bg-gray-50 transition-colors`,children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(uf,{className:n.iconSize}),$e.jsx("span",{className:`${n.textSize.body} font-medium`,children:"Filters"}),(u||m)&&$e.jsx("span",{className:`${n.textSize.caption} bg-blue-100 text-blue-800 px-2 py-1 rounded-full`,children:u||m})]}),o?$e.jsx(tf,{className:n.iconSize}):$e.jsx(Xp,{className:n.iconSize})]}),o&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:$e.jsx("div",{className:n.containerPadding,children:$e.jsxs("div",{className:"space-y-3",children:[$e.jsxs("div",{children:[$e.jsx("label",{className:`block ${n.textSize.caption} font-medium text-gray-700 mb-2`,children:"Call Status"}),$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>h(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>h("waiting"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("waiting"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Waiting"}),$e.jsx("button",{onClick:()=>h("in-progress"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("in-progress"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"In Progress"}),$e.jsx("button",{onClick:()=>h("completed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("completed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Completed"}),$e.jsx("button",{onClick:()=>h("failed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("failed"===u?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Failed"})]})]}),$e.jsxs("div",{children:[$e.jsx("label",{className:`block ${n.textSize.caption} font-medium text-gray-700 mb-2`,children:"Deal Status"}),$e.jsxs("div",{className:"flex flex-wrap gap-2",children:[$e.jsx("button",{onClick:()=>p(""),className:"px-3 py-1 rounded-full text-xs border transition-colors "+(""===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"All"}),$e.jsx("button",{onClick:()=>p("pending"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("pending"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Pending"}),$e.jsx("button",{onClick:()=>p("negotiating"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("negotiating"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Negotiating"}),$e.jsx("button",{onClick:()=>p("agreed"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("agreed"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Agreed"}),$e.jsx("button",{onClick:()=>p("declined"),className:"px-3 py-1 rounded-full text-xs border transition-colors "+("declined"===m?"bg-blue-500 text-white border-blue-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:"Declined"})]})]})]})})})]}),$e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[b&&$e.jsx("div",{className:"p-4",children:$e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[$e.jsxs("p",{className:"text-red-800 text-sm",children:["Failed to load call logs: ",b]}),$e.jsx(Ou,{onClick:j,className:"mt-2 text-sm bg-red-600 text-white hover:bg-red-700",children:"Retry"})]})}),b||0!==x.length||v?$e.jsxs("div",{className:`${n.containerPadding} ${n.spacing}`,children:[x.map(t=>$e.jsx(ax,{item:t,onViewDetails:()=>{return e=t.id,void r(`/call-logs/${e}`,{state:{callQueueItems:x,fromCallLogs:!0}});var e},theme:e},t.id)),v&&$e.jsx(Tx,{config:n}),$e.jsx("div",{ref:k,className:"h-4"})]}):$e.jsx(Cx,{theme:e,config:n})]})]})}const Ax={currentLead:null,emails:[],isLoading:!1,error:null,isSending:!1,sendError:null},Rx=Iu((e,t)=>({...Ax,setCurrentLead:t=>{e({currentLead:t})},fetchLeadEmails:async t=>{e({isLoading:!0,error:null});try{const s=[...(await zp.getLeadEmails(t)).emails].sort((e,t)=>new Date(e.receivedDatetime).getTime()-new Date(t.receivedDatetime).getTime());e({emails:s,isLoading:!1,error:null})}catch(s){console.error("Failed to fetch lead emails:",s),e({isLoading:!1,error:s.message||"Failed to fetch emails",emails:[]})}},sendReply:async(s,n,r,a)=>{e({isSending:!0,sendError:null});try{const i=await zp.sendEmailReply(s,n,r,a);if(i.success){const s=t().emails;return e({emails:[...s,i.email],isSending:!1,sendError:null}),!0}return e({isSending:!1,sendError:"Failed to send email"}),!1}catch(i){return console.error("Failed to send email:",i),e({isSending:!1,sendError:i.message||"Failed to send email"}),!1}},clearError:()=>{e({error:null,sendError:null})},reset:()=>{e(Ax)}}));var Mx,Dx={exports:{}};const $x=wy((Mx||(Mx=1,Dx.exports=function(){var e=1e3,t=6e4,s=36e5,n="millisecond",r="second",a="minute",i="hour",o="day",l="week",c="month",d="quarter",u="year",h="date",m="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],s=e%100;return"["+e+(t[(s-20)%10]||t[s]||t[0])+"]"}},y=function(e,t,s){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(s)+e},x={s:y,z:function(e){var t=-e.utcOffset(),s=Math.abs(t),n=Math.floor(s/60),r=s%60;return(t<=0?"+":"-")+y(n,2,"0")+":"+y(r,2,"0")},m:function e(t,s){if(t.date()<s.date())return-e(s,t);var n=12*(s.year()-t.year())+(s.month()-t.month()),r=t.clone().add(n,c),a=s-r<0,i=t.clone().add(n+(a?-1:1),c);return+(-(n+(s-r)/(a?r-i:i-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:u,w:l,d:o,D:h,h:i,m:a,s:r,ms:n,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},v="en",b={};b[v]=g;var w="$isDayjsObject",S=function(e){return e instanceof E||!(!e||!e[w])},j=function e(t,s,n){var r;if(!t)return v;if("string"==typeof t){var a=t.toLowerCase();b[a]&&(r=a),s&&(b[a]=s,r=a);var i=t.split("-");if(!r&&i.length>1)return e(i[0])}else{var o=t.name;b[o]=t,r=o}return!n&&r&&(v=r),r||!n&&v},k=function(e,t){if(S(e))return e.clone();var s="object"==typeof t?t:{};return s.date=e,s.args=arguments,new E(s)},N=x;N.l=j,N.i=S,N.w=function(e,t){return k(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=j(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=g.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,s=e.utc;if(null===t)return new Date(NaN);if(N.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(p);if(n){var r=n[2]-1||0,a=(n[7]||"0").substring(0,3);return s?new Date(Date.UTC(n[1],r,n[3]||1,n[4]||0,n[5]||0,n[6]||0,a)):new Date(n[1],r,n[3]||1,n[4]||0,n[5]||0,n[6]||0,a)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return N},y.isValid=function(){return!(this.$d.toString()===m)},y.isSame=function(e,t){var s=k(e);return this.startOf(t)<=s&&s<=this.endOf(t)},y.isAfter=function(e,t){return k(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<k(e)},y.$g=function(e,t,s){return N.u(e)?this[t]:this.set(s,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var s=this,n=!!N.u(t)||t,d=N.p(e),m=function(e,t){var r=N.w(s.$u?Date.UTC(s.$y,t,e):new Date(s.$y,t,e),s);return n?r:r.endOf(o)},p=function(e,t){return N.w(s.toDate()[e].apply(s.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(t)),s)},f=this.$W,g=this.$M,y=this.$D,x="set"+(this.$u?"UTC":"");switch(d){case u:return n?m(1,0):m(31,11);case c:return n?m(1,g):m(0,g+1);case l:var v=this.$locale().weekStart||0,b=(f<v?f+7:f)-v;return m(n?y-b:y+(6-b),g);case o:case h:return p(x+"Hours",0);case i:return p(x+"Minutes",1);case a:return p(x+"Seconds",2);case r:return p(x+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var s,l=N.p(e),d="set"+(this.$u?"UTC":""),m=(s={},s[o]=d+"Date",s[h]=d+"Date",s[c]=d+"Month",s[u]=d+"FullYear",s[i]=d+"Hours",s[a]=d+"Minutes",s[r]=d+"Seconds",s[n]=d+"Milliseconds",s)[l],p=l===o?this.$D+(t-this.$W):t;if(l===c||l===u){var f=this.clone().set(h,1);f.$d[m](p),f.init(),this.$d=f.set(h,Math.min(this.$D,f.daysInMonth())).$d}else m&&this.$d[m](p);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[N.p(e)]()},y.add=function(n,d){var h,m=this;n=Number(n);var p=N.p(d),f=function(e){var t=k(m);return N.w(t.date(t.date()+Math.round(e*n)),m)};if(p===c)return this.set(c,this.$M+n);if(p===u)return this.set(u,this.$y+n);if(p===o)return f(1);if(p===l)return f(7);var g=(h={},h[a]=t,h[i]=s,h[r]=e,h)[p]||1,y=this.$d.getTime()+n*g;return N.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,s=this.$locale();if(!this.isValid())return s.invalidDate||m;var n=e||"YYYY-MM-DDTHH:mm:ssZ",r=N.z(this),a=this.$H,i=this.$m,o=this.$M,l=s.weekdays,c=s.months,d=s.meridiem,u=function(e,s,r,a){return e&&(e[s]||e(t,n))||r[s].slice(0,a)},h=function(e){return N.s(a%12||12,e,"0")},p=d||function(e,t,s){var n=e<12?"AM":"PM";return s?n.toLowerCase():n};return n.replace(f,function(e,n){return n||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return N.s(t.$y,4,"0");case"M":return o+1;case"MM":return N.s(o+1,2,"0");case"MMM":return u(s.monthsShort,o,c,3);case"MMMM":return u(c,o);case"D":return t.$D;case"DD":return N.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return u(s.weekdaysMin,t.$W,l,2);case"ddd":return u(s.weekdaysShort,t.$W,l,3);case"dddd":return l[t.$W];case"H":return String(a);case"HH":return N.s(a,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return p(a,i,!0);case"A":return p(a,i,!1);case"m":return String(i);case"mm":return N.s(i,2,"0");case"s":return String(t.$s);case"ss":return N.s(t.$s,2,"0");case"SSS":return N.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(n,h,m){var p,f=this,g=N.p(h),y=k(n),x=(y.utcOffset()-this.utcOffset())*t,v=this-y,b=function(){return N.m(f,y)};switch(g){case u:p=b()/12;break;case c:p=b();break;case d:p=b()/3;break;case l:p=(v-x)/6048e5;break;case o:p=(v-x)/864e5;break;case i:p=v/s;break;case a:p=v/t;break;case r:p=v/e;break;default:p=v}return m?p:N.a(p)},y.daysInMonth=function(){return this.endOf(c).$D},y.$locale=function(){return b[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var s=this.clone(),n=j(e,t,!0);return n&&(s.$L=n),s},y.clone=function(){return N.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),C=E.prototype;return k.prototype=C,[["$ms",n],["$s",r],["$m",a],["$H",i],["$W",o],["$M",c],["$y",u],["$D",h]].forEach(function(e){C[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),k.extend=function(e,t){return e.$i||(e(t,E,k),e.$i=!0),k},k.locale=j,k.isDayjs=S,k.unix=function(e){return k(1e3*e)},k.en=b[v],k.Ls=b,k.p={},k}()),Dx.exports)),Ox={new:"bg-green-500 text-white",qualified:"bg-blue-500 text-white",contacted:"bg-yellow-500 text-white",rejected:"bg-red-500 text-white"};function Fx({item:e,onViewClick:t,theme:s}){const n=s.primaryColor||"#1e40af",r=e.pickupTimestamp?$x(e.pickupTimestamp).format("MMM DD, YYYY"):"-",a=e.deliveryTimestamp?$x(e.deliveryTimestamp).format("MMM DD, YYYY"):"-";return $e.jsxs(pd.div,{layout:!0,initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"bg-white rounded-lg border-l-4 shadow-sm overflow-hidden cursor-pointer hover:shadow-md transition-shadow",style:{borderLeftColor:n},onClick:t,children:[$e.jsxs("div",{className:"px-4 py-3",children:[$e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[$e.jsxs("div",{className:"flex items-center gap-3",children:[$e.jsx("span",{className:"text-base font-semibold",style:{color:n},children:e.shipperName||"Unknown Shipper"}),e.shipperCompanyName&&$e.jsxs("span",{className:"text-xs text-gray-500",children:["(",e.shipperCompanyName,")"]})]}),$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("span",{className:`text-xs px-2 py-1 rounded font-medium capitalize ${Ox[e.status]}`,children:e.status}),e.isDuplicate&&$e.jsx("span",{className:"text-xs px-2 py-1 rounded font-medium bg-orange-100 text-orange-700",children:"Duplicate"})]})]}),$e.jsx("p",{className:"text-sm text-gray-700 mb-3 line-clamp-1",children:e.emailSubject}),$e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-y-2 text-xs text-gray-600",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 text-green-500"}),$e.jsx("span",{className:"truncate",title:e.origin,children:e.origin})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 rotate-180 text-red-500"}),$e.jsx("span",{className:"truncate",title:e.destination,children:e.destination})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:r})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:a})]}),e.loadType&&$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(kf,{className:"w-3 h-3"}),$e.jsx("span",{children:e.loadType})]}),e.modeOfService&&$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:"w-3 h-3"}),$e.jsx("span",{children:e.modeOfService})]})]}),(e.grossWeight||e.numberOfPallets)&&$e.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-gray-500",children:[e.grossWeight&&$e.jsxs("span",{children:["Weight: ",e.grossWeight.toLocaleString()," lbs"]}),e.numberOfPallets&&$e.jsxs("span",{children:["Pallets: ",e.numberOfPallets]})]})]}),$e.jsxs("div",{className:"flex justify-between items-center px-4 pb-3",children:[$e.jsx("span",{className:"text-xs text-gray-400",children:$x(e.createdAt).format("MMM DD, YYYY h:mm A")}),$e.jsxs("button",{onClick:e=>{e.stopPropagation(),t()},className:"flex items-center gap-2 px-3 py-1.5 rounded text-white text-xs font-medium",style:{backgroundColor:n},children:[$e.jsx(yf,{className:"w-3.5 h-3.5"}),$e.jsx("span",{children:"View Details"})]})]})]})}function zx({label:e,active:t,onClick:s,onRemove:n,primaryColor:r}){return $e.jsxs("button",{onClick:s,className:"px-3 py-1.5 rounded text-xs font-medium border transition-colors flex items-center gap-1 "+(t?"text-white border-transparent":"text-gray-700 border-gray-300 bg-white hover:bg-gray-50"),style:t?{backgroundColor:r}:void 0,children:[e,t&&n&&$e.jsx(Uf,{className:"w-3 h-3 ml-1",onClick:e=>{e.stopPropagation(),n()}})]})}function Lx({currentPage:e,totalPages:t,onPageChange:s,primaryColor:n}){const r=[];if(t<=5)for(let a=1;a<=t;a++)r.push(a);else{r.push(1),e>3&&r.push(-1);const s=Math.max(2,e-1),n=Math.min(t-1,e+1);for(let e=s;e<=n;e++)r.push(e);e<t-2&&r.push(-1),r.push(t)}return $e.jsxs("div",{className:"flex items-center justify-center gap-1 py-3",children:[$e.jsx("button",{onClick:()=>s(e-1),disabled:1===e,className:"p-1 rounded hover:bg-gray-100 disabled:opacity-50",children:$e.jsx(Zp,{className:"w-4 h-4"})}),r.map((t,r)=>-1===t?$e.jsx("span",{className:"px-2 text-gray-400",children:".."},`ellipsis-${r}`):$e.jsx("button",{onClick:()=>s(t),className:"w-7 h-7 rounded text-xs font-medium "+(e===t?"text-white":"text-gray-700 hover:bg-gray-100"),style:e===t?{backgroundColor:n}:void 0,children:t},t)),$e.jsx("button",{onClick:()=>s(e+1),disabled:e===t,className:"p-1 rounded hover:bg-gray-100 disabled:opacity-50",children:$e.jsx(ef,{className:"w-4 h-4"})})]})}function Ix({count:e,onDismiss:t,onRefresh:s,primaryColor:n}){return $e.jsxs(pd.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"mx-4 mb-3 p-3 rounded-lg flex items-center justify-between",style:{backgroundColor:`${n}15`,border:`1px solid ${n}40`},children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx(Qp,{className:"w-4 h-4",style:{color:n}}),$e.jsxs("span",{className:"text-sm font-medium",style:{color:n},children:[e," new email lead",e>1?"s":""," received!"]})]}),$e.jsx("div",{className:"flex items-center gap-2",children:$e.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 rounded",children:$e.jsx(Uf,{className:"w-4 h-4 text-gray-500"})})})]})}function _x(){const{theme:e,isOpen:t}=ns(),s=Mg(),[n,r]=Oe.useState(""),{leads:a,totalCount:i,currentPage:o,pageSize:l,isLoading:c,error:d,dateFilter:u,hasNewLeads:h,newLeadsCount:m,showNewLeadsAlert:p,fetchLeads:f,setPage:g,setSearchQuery:y,setDateFilter:x,startPolling:v,stopPolling:b,clearNewLeadsNotification:w,acknowledgeNewLeads:S}=Ip(),{setCurrentLead:j}=Rx(),k=Oe.useCallback(e=>{j(e),s(`/email-leads/${e.id}`)},[s,j]),N=((e,t=300)=>{const[s,n]=Oe.useState(e);return Oe.useEffect(()=>{const s=setTimeout(()=>n(e),t);return()=>clearTimeout(s)},[e,t]),s})(n,500);Oe.useEffect(()=>{f()},[]),Oe.useEffect(()=>{y(N),""!==N&&f({search:N,page:1})},[N]),Oe.useEffect(()=>(v(),()=>b()),[]);const E=Math.ceil(i/l),C=e.primaryColor||"#1e40af",T=Oe.useCallback(e=>{x(e)},[x]),P=Oe.useCallback(()=>{w(),f({page:1})},[w,f]);return $e.jsxs("div",{className:"flex flex-col h-full bg-white",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 border-b",children:$e.jsxs("div",{className:"relative",children:[$e.jsx(Pf,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),$e.jsx("input",{type:"text",placeholder:"Search by subject, shipper, origin, destination...",value:n,onChange:e=>r(e.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2",style:{"--tw-ring-color":C},onFocus:e=>e.currentTarget.style.boxShadow=`0 0 0 2px ${C}40`,onBlur:e=>e.currentTarget.style.boxShadow=""})]})}),$e.jsx("div",{className:"px-4 py-3 border-b flex gap-2 overflow-x-auto",children:[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"all",label:"All"}].map(e=>$e.jsx(zx,{label:e.label,active:u===e.id,onClick:()=>T(e.id),onRemove:u===e.id&&"all"!==e.id?()=>T("all"):void 0,primaryColor:C},e.id))}),$e.jsxs("div",{className:"px-4 py-3 flex items-center justify-between ",children:[$e.jsxs("h2",{className:"text-base font-semibold text-gray-900",children:["Load Requests ",i>0&&$e.jsxs("span",{className:"text-gray-500 font-normal",children:["(",i,")"]})]}),c&&$e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"})]}),$e.jsx(gi,{children:p&&t&&$e.jsx(Ix,{count:m,onDismiss:S,onRefresh:P,primaryColor:C})}),d&&$e.jsxs("div",{className:"mx-4 mb-3 p-3 bg-red-50 border border-red-200 rounded-lg",children:[$e.jsx("p",{className:"text-sm text-red-600",children:d}),$e.jsx("button",{onClick:()=>f(),className:"mt-2 text-xs text-red-700 underline",children:"Try again"})]}),$e.jsx("div",{className:"flex-1 overflow-hidden relative",children:c||0!==a.length?$e.jsx("div",{className:"h-full overflow-y-auto px-4 space-y-3 pb-8",children:$e.jsx(gi,{initial:!1,children:a.map(t=>$e.jsx(Fx,{item:t,theme:e,onViewClick:()=>k(t)},t.id))})}):$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500 p-8 text-center",children:[$e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mb-4",children:$e.jsx(yf,{className:"h-8 w-8 text-gray-400"})}),$e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-1",children:"No email leads found"}),$e.jsx("p",{className:"text-sm",children:"Try adjusting your filters or search terms"})]})}),a.length>0&&E>1&&$e.jsx(Lx,{currentPage:o,totalPages:E,onPageChange:g,primaryColor:C})]})}const Vx={new:"bg-green-500 text-white",qualified:"bg-blue-500 text-white",contacted:"bg-yellow-500 text-white",rejected:"bg-red-500 text-white"};function Bx(e){return e?$x(e).format("MMM DD, YYYY"):"-"}function qx({lead:e,theme:t}){const s=t.primaryColor||"#1e40af";return console.log("Lead",e),$e.jsx("div",{className:"bg-white rounded-lg border-l-4 shadow-sm overflow-hidden",style:{borderLeftColor:s},children:$e.jsxs("div",{className:"px-4 py-3",children:[$e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[$e.jsxs("div",{className:"flex items-center gap-3",children:[$e.jsx("span",{className:"text-base font-semibold",style:{color:s},children:e.shipperName||"Unknown Shipper"}),$e.jsx(yf,{className:"w-4 h-4 text-gray-400"})]}),$e.jsx("div",{className:"flex items-center gap-2",children:$e.jsx("span",{className:`text-xs px-2 py-1 rounded font-medium ${Vx[e.status]}`,children:e.status.charAt(0).toUpperCase()+e.status.slice(1)})})]}),$e.jsxs("div",{className:"grid grid-cols-3 gap-y-2 text-xs text-gray-600",children:[$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3"}),$e.jsx("span",{className:"truncate",children:e.origin||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(jf,{className:"w-3 h-3 rotate-90"}),$e.jsx("span",{className:"truncate",children:e.destination||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:Bx(e.pickupTimestamp)})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(Jp,{className:"w-3 h-3"}),$e.jsx("span",{children:Bx(e.deliveryTimestamp)})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(If,{className:"w-3 h-3"}),$e.jsx("span",{children:e.modeOfService||"-"})]}),$e.jsxs("div",{className:"flex items-center gap-1",children:[$e.jsx(kf,{className:"w-3 h-3"}),$e.jsx("span",{children:e.loadType||"-"})]})]})]})})}function Ux({activeTab:e,onTabChange:t,theme:s}){const n=s.primaryColor||"#1e40af",r=s.headerBg||"#1f2937";return $e.jsxs("div",{className:"grid grid-cols-2",children:[$e.jsxs("button",{onClick:()=>t("shipper"),className:"px-5 py-3 flex items-center justify-center gap-2",style:"shipper"===e?{backgroundColor:`${n}15`,color:n,borderBottom:`2px solid ${n}`}:{backgroundColor:"#f9fafb",color:"#4b5563"},children:[$e.jsx(yf,{className:"w-4 h-4"}),$e.jsx("span",{className:"text-sm font-medium",children:"Shipper Email"})]}),$e.jsxs("button",{onClick:()=>t("carrier"),className:"px-5 py-3 flex items-center justify-center gap-2",style:"carrier"===e?{backgroundColor:r,color:"#ffffff"}:{backgroundColor:"#f9fafb",color:"#4b5563"},children:[$e.jsx(yf,{className:"w-4 h-4"}),$e.jsx("span",{className:"text-sm font-medium",children:"Carrier Email"})]})]})}function Wx({emails:e,lead:t,theme:s,isLoading:n,error:r,onSendReply:a,isSending:i}){var o,l;const c=s.primaryColor||"#1e40af",[d,u]=Oe.useState(""),[h,m]=Oe.useState(!1);return n?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(ff,{className:"w-8 h-8 animate-spin text-gray-400 mb-3"}),$e.jsx("p",{className:"text-sm text-gray-500",children:"Loading emails..."})]}):r?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(sf,{className:"w-8 h-8 text-red-400 mb-3"}),$e.jsx("p",{className:"text-sm text-red-500",children:r})]}):0===e.length?$e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx(yf,{className:"w-12 h-12 text-gray-300 mb-3"}),$e.jsx("p",{className:"text-sm text-gray-500",children:"No emails found"})]}):$e.jsxs("div",{className:"flex flex-col h-full",children:[$e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[$e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[$e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${c}15`},children:$e.jsx(yf,{className:"w-5 h-5",style:{color:c}})}),$e.jsxs("div",{className:"flex-1",children:[$e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:(null==(o=e[0])?void 0:o.subject)||"No Subject"}),$e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[t.shipperName," • ",t.origin," → ",t.destination]})]})]}),$e.jsx("div",{className:"space-y-4",children:e.map((e,t)=>{var s,n,r;const a="outgoing"===(null==(s=e.metadata)?void 0:s.direction),i=(null==(r=null==(n=e.senderEmail)?void 0:n.split("@")[0])?void 0:r.slice(0,2).toUpperCase())||"U";return $e.jsxs(pd.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1*t},className:"rounded-lg border "+(a?"border-blue-200 bg-blue-50":"border-gray-200 bg-white"),children:[$e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100 flex items-center justify-between",children:[$e.jsxs("div",{className:"flex items-center gap-2",children:[$e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-medium",style:{backgroundColor:a?"#3b82f6":c},children:i}),$e.jsxs("div",{children:[$e.jsx("p",{className:"text-sm font-medium text-gray-900",children:e.senderEmail}),$e.jsxs("p",{className:"text-xs text-gray-500",children:["To: ",e.receiverEmail]})]})]}),$e.jsx("span",{className:"text-xs text-gray-400",children:(o=e.receivedDatetime,$x(o).format("MMM DD, YYYY h:mm A"))})]}),$e.jsx("div",{className:"px-4 py-3",children:e.bodyHtml?$e.jsx("div",{className:"text-sm text-gray-700 prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.bodyHtml}}):$e.jsx("p",{className:"text-sm text-gray-700 whitespace-pre-wrap",children:e.bodyText})})]},e.id);var o})})]}),$e.jsx("div",{className:"flex-shrink-0 border-t bg-white",children:$e.jsxs("div",{className:"mx-4 my-3 rounded-lg border border-gray-200 overflow-hidden",children:[$e.jsx(gi,{children:h&&$e.jsx(pd.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},children:$e.jsxs("div",{className:"p-4 space-y-3",children:[$e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:["Replying to: ",null==(l=e[e.length-1])?void 0:l.senderEmail]}),$e.jsx("textarea",{value:d,onChange:e=>u(e.target.value),placeholder:"Type your reply...",className:"w-full p-3 border border-gray-200 rounded-lg resize-none text-sm min-h-[120px] focus:outline-none focus:ring-2 focus:ring-blue-500"}),$e.jsxs("div",{className:"flex gap-2",children:[$e.jsxs("button",{onClick:async()=>{if(!d.trim())return;const e=`<p>${d.replace(/\n/g,"<br/>")}</p>`;await a(e),u(""),m(!1)},disabled:!d.trim()||i,className:"px-4 py-2 rounded text-white text-sm font-medium disabled:opacity-50 flex items-center gap-2",style:{backgroundColor:c},children:[i&&$e.jsx(ff,{className:"w-4 h-4 animate-spin"}),i?"Sending...":"Send"]}),$e.jsx("button",{onClick:()=>{u(""),m(!1)},className:"px-4 py-2 rounded text-gray-600 text-sm font-medium border border-gray-200 hover:bg-gray-50",children:"Cancel"})]})]})})}),!h&&$e.jsx("div",{className:"px-4 py-3 bg-gray-50 flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>m(!h),className:"flex items-center gap-2 text-sm font-medium text-white px-3 py-1.5 rounded",style:{backgroundColor:c},children:[$e.jsx(Tf,{className:"w-4 h-4"}),$e.jsx("span",{children:"Reply"})]})})]})})]})}function Hx({theme:e}){const t=e.primaryColor||"#1e40af";return $e.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-12",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:`${t}15`},children:$e.jsx(yf,{className:"w-8 h-8",style:{color:t}})}),$e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Feature Coming Soon"}),$e.jsx("p",{className:"text-sm text-gray-500 text-center max-w-xs",children:"Carrier email integration is currently under development. Stay tuned for updates!"})]})}function Kx(){const{theme:e}=ns(),{leadId:t}=Dg(),s=Mg(),[n,r]=Oe.useState("shipper"),{currentLead:a,emails:i,isLoading:o,error:l,isSending:c,fetchLeadEmails:d,sendReply:u,reset:h}=Rx();Oe.useEffect(()=>(t&&d(t),()=>{}),[t,d]);return a||o?$e.jsxs("div",{className:"flex flex-col h-full bg-gray-50",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 bg-white border-b flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>s("/email-leads"),className:"flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900",children:[$e.jsx(Kp,{className:"w-4 h-4"}),$e.jsx("span",{children:"Back"})]})}),$e.jsxs("div",{className:"p-4",children:[a&&$e.jsx(qx,{lead:a,theme:e}),$e.jsx("div",{className:"mt-3 bg-white rounded-lg border border-gray-200 shadow-sm overflow-hidden",children:$e.jsx(Ux,{activeTab:n,onTabChange:r,theme:e})})]}),$e.jsx("div",{className:"flex-1 overflow-hidden mx-4 mb-4 bg-white rounded-lg border border-gray-200 shadow-sm",children:"shipper"===n?$e.jsx(Wx,{emails:i,lead:a,theme:e,isLoading:o,error:l,onSendReply:async e=>{var t,s,n;if(!i.length||!a)return;const r=null==(t=i[0])?void 0:t.conversationId,o=a.shipperEmail||(null==(s=i[0])?void 0:s.senderEmail),l=(null==(n=i[0])?void 0:n.subject)||"No Subject",c=l.startsWith("Re: ")?l:`Re: ${l}`;r&&o&&await u([o],r,c,e)},isSending:c}):$e.jsx(Hx,{theme:e})})]}):$e.jsxs("div",{className:"flex flex-col h-full bg-gray-50",style:{fontFamily:e.fontFamily},children:[$e.jsx("div",{className:"px-4 py-3 bg-white border-b flex items-center gap-3",children:$e.jsxs("button",{onClick:()=>s(-1),className:"flex items-center gap-1 text-sm text-gray-600 hover:text-gray-900",children:[$e.jsx(Kp,{className:"w-4 h-4"}),$e.jsx("span",{children:"Back"})]})}),$e.jsx("div",{className:"flex-1 flex items-center justify-center",children:$e.jsxs("div",{className:"text-center",children:[$e.jsx(sf,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),$e.jsx("p",{className:"text-gray-500",children:"Lead data not found. Please go back and try again."})]})})]})}class Yx{static async getEmailsClassifiedTodayCount(){return(await Mp.get("/crm/emails/me/metric/clasified_today_count")).data}static async getLeadsTodayCount(){return(await Mp.get("/crm/leads/me/leads/count_today")).data}static async getLeadsTillDateCount(){return(await Mp.get("/crm/leads/me/leads/count_till_date")).data}static async getDashboardStats(){const[e,t,s]=await Promise.all([this.getEmailsClassifiedTodayCount(),this.getLeadsTodayCount(),this.getLeadsTillDateCount()]);return{emailsClassifiedToday:e.count??0,leadsToday:t.count??0,leadsTillDate:s.count??0}}}function Qx({title:e,value:t,borderColor:s,iconBg:n,iconColor:r,valueColor:a}){return $e.jsxs("div",{className:"bg-white rounded-lg p-3 border-l-4 shadow-sm",style:{borderLeftColor:s},children:[$e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[$e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0",style:{backgroundColor:n},children:$e.jsx(Af,{className:"w-3 h-3",style:{color:r}})}),$e.jsx("span",{className:"text-xs text-gray-600 leading-tight",children:e})]}),$e.jsx("div",{className:"border-t border-gray-100 pt-2",children:$e.jsx("span",{className:"text-xl font-bold",style:{color:a||s},children:t})})]})}function Gx({primaryColor:e}){const t=(()=>{const e=[];for(let t=0;t<35;t++){const t=Math.random();e.push(t)}return e})();return $e.jsx("div",{className:"grid grid-cols-7 gap-1",children:t.map((t,s)=>$e.jsx("div",{className:"w-4 h-4 rounded-sm",style:{backgroundColor:t>.7?e:t>.4?`${e}99`:t>.2?`${e}44`:"#e5e7eb"}},s))})}function Jx(){var e;const{theme:t,user:s}=ns();Mg();const[n,r]=Oe.useState(null),[a,i]=Oe.useState(!1),o=(new Date).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}),l=t.primaryColor||"#1e40af",c=(null==(e=null==s?void 0:s.email)?void 0:e.split("@")[0])||"User",d=c.charAt(0).toUpperCase()+c.slice(1);return Oe.useEffect(()=>{let e=!0;return i(!0),Yx.getDashboardStats().then(t=>{e&&r(t)}).catch(()=>{e&&r({emailsClassifiedToday:0,leadsToday:0,leadsTillDate:0})}).finally(()=>{e&&i(!1)}),()=>{e=!1}},[]),$e.jsxs("div",{className:"flex flex-col h-full bg-white overflow-y-auto",style:{fontFamily:t.fontFamily},children:[$e.jsxs("div",{className:"px-5 py-4",children:[$e.jsxs("h1",{className:"text-lg text-gray-800",children:["Hello ",$e.jsx("span",{className:"font-semibold",children:d}),","]}),$e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mt-1",children:"Let's check new email for today"}),$e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:o})]}),$e.jsx("div",{className:"px-5 pb-6 space-y-5",children:$e.jsxs("div",{children:[$e.jsx("h3",{className:"text-base font-semibold text-gray-900 mb-3",children:"Email Leads Agents"}),$e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[$e.jsx(Qx,{title:"Leads Till Date",value:(null==n?void 0:n.leadsTillDate)??"—",borderColor:l,iconBg:`${l}15`,iconColor:l,valueColor:l}),$e.jsx(Qx,{title:"Leads Today",value:n?`${n.leadsToday}`:"—",borderColor:"#ef4444",iconBg:"#fef2f2",iconColor:"#ef4444",valueColor:"#ef4444"}),$e.jsx(Qx,{title:"Emails Classified Today",value:(null==n?void 0:n.emailsClassifiedToday)??"—",borderColor:"#ef4444",iconBg:"#fef2f2",iconColor:"#ef4444",valueColor:"#ef4444"})]}),$e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3",children:[$e.jsx(Qx,{title:"Quotes Won",value:"—",borderColor:"#22c55e",iconBg:"#f0fdf4",iconColor:"#22c55e",valueColor:"#22c55e"}),$e.jsx("div",{style:{borderLeftColor:l},className:"bg-white col-span-2 rounded-lg p-3 border border-gray-100 shadow-sm border-l-4",children:$e.jsxs("div",{className:"flex items-start gap-3",children:[$e.jsxs("div",{className:"flex-1",children:[$e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[$e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:`${l}15`},children:$e.jsx(zf,{className:"w-3 h-3",style:{color:l}})}),$e.jsx("span",{className:"text-xs text-gray-600",children:"Conversions this month"})]}),$e.jsx("div",{className:"mt-2",children:$e.jsx("span",{className:"text-xl font-bold",style:{color:l},children:"—"})})]}),$e.jsx("div",{className:"flex-shrink-0",children:$e.jsx(Gx,{primaryColor:l})})]})})]}),$e.jsx("div",{className:"grid grid-cols-2 gap-3",children:$e.jsx(Qx,{title:"Time Saved",value:"—",borderColor:l,iconBg:`${l}15`,iconColor:l,valueColor:l})})]})})]})}function Xx(){return $e.jsxs(Yg,{children:[$e.jsx(Hg,{path:"/",element:$e.jsx(Jx,{})}),$e.jsx(Hg,{path:"/search",element:$e.jsx(tx,{})}),$e.jsx(Hg,{path:"/results",element:$e.jsx(cx,{})}),$e.jsx(Hg,{path:"/call-details/:callId",element:$e.jsx(vx,{})}),$e.jsx(Hg,{path:"/call-logs/:callId",element:$e.jsx(vx,{})}),$e.jsx(Hg,{path:"/history",element:$e.jsx(Ex,{})}),$e.jsx(Hg,{path:"/call-logs",element:$e.jsx(Px,{})}),$e.jsx(Hg,{path:"/email-leads",element:$e.jsx(_x,{})}),$e.jsx(Hg,{path:"/email-leads/:leadId",element:$e.jsx(Kx,{})}),$e.jsx(Hg,{path:"*",element:$e.jsx(Wg,{to:"/",replace:!0})})]})}class Zx extends Oe.Component{constructor(e){super(e),Ce(this,"handleReset",()=>{this.setState({hasError:!1,error:void 0})}),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught an error:",e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:$e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:$e.jsxs(By,{className:"p-6 max-w-md w-full text-center",children:[$e.jsx("div",{className:"flex justify-center mb-4",children:$e.jsx(Lf,{className:"h-12 w-12 text-red-500"})}),$e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Something went wrong"}),$e.jsx("p",{className:"text-gray-600 mb-4 text-sm",children:"An error occurred while loading this page. Please try again."}),$e.jsxs("div",{className:"space-y-2",children:[$e.jsx(Ou,{onClick:this.handleReset,className:"w-full",children:"Try Again"}),$e.jsx(Ou,{variant:"outline",onClick:()=>window.location.reload(),className:"w-full",children:"Reload Page"})]}),"development"===process.env.NODE_ENV&&this.state.error&&$e.jsxs("details",{className:"mt-4 text-left",children:[$e.jsx("summary",{className:"cursor-pointer text-sm text-gray-500",children:"Error Details"}),$e.jsx("pre",{className:"mt-2 text-xs bg-gray-100 p-2 rounded overflow-auto",children:this.state.error.stack})]})]})}):this.props.children}}class ev{static async login2FA(e,t){var s,n,r;try{return(await Mp.post("/workspace/users/tenant/application/2_fa_auth",{email:e,tenant_id:t})).data}catch(a){if(console.log("Login 2FA Error:",a),404===(null==(s=a.response)?void 0:s.status))throw new Error("User not found");if(null==(r=null==(n=a.response)?void 0:n.data)?void 0:r.detail)throw new Error(a.response.data.detail);throw new Error("Failed to send OTP. Please try again.")}}static async verifyOTP(e,t,s){var n,r,a,i;try{const n=await Mp.post("/workspace/users/tenant/application/otp_validate",{email:e,tenant_id:t,otp:s});return console.log("Verify OTP Response:",n.data),n.data}catch(o){if(400===(null==(n=o.response)?void 0:n.status)||401===(null==(r=o.response)?void 0:r.status))throw new Error("Invalid or expired OTP");if(null==(i=null==(a=o.response)?void 0:a.data)?void 0:i.detail)throw new Error(o.response.data.detail);throw new Error("Failed to verify OTP. Please try again.")}}}function tv(){const{theme:e}=ns();return $e.jsx("div",{className:"flex-shrink-0 py-2 px-4 text-center",style:{fontFamily:e.fontFamily},children:$e.jsxs("p",{className:"text-xs text-right text-gray-500",children:["Powered by"," ",$e.jsx("span",{className:"font-medium",style:{color:e.primaryColor},children:"Pangents AI"})]})})}function sv({onAuthSuccess:e}){const{theme:t,tenantId:s,email:n}=ns(),[r,a]=Oe.useState({step:"email",email:n||"",otp:"",isLoading:!1,error:null,otpSent:!1,countdown:0}),i=Oe.useRef(null),o=Oe.useRef(null),l=Oe.useRef(null);Oe.useEffect(()=>{var e,t;"email"===r.step?null==(e=i.current)||e.focus():"otp"===r.step&&(null==(t=o.current)||t.focus())},[r.step]),Oe.useEffect(()=>(r.countdown>0&&(l.current=setTimeout(()=>{a(e=>({...e,countdown:e.countdown-1}))},1e3)),()=>{l.current&&clearTimeout(l.current)}),[r.countdown]);const c=async e=>{var t,n,i;if(e.preventDefault(),i=r.email,/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))if(a(e=>({...e,isLoading:!0,error:null})),s)try{await ev.login2FA(r.email,s);a(e=>({...e,step:"otp",isLoading:!1,otpSent:!0,countdown:60}))}catch(o){console.log("Login 2FA Error:",null==(t=o.response)?void 0:t.data);let e="Failed to send OTP. Please try again.";404===(null==(n=o.response)?void 0:n.status)?e="User not found. Please check your email address.":o.message&&(e=o.message),a(t=>({...t,isLoading:!1,error:e}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}));else a(e=>({...e,error:"Please enter a valid email address"}))},d=async t=>{var n,i;if(t.preventDefault(),i=r.otp,/^\d{6}$/.test(i))if(a(e=>({...e,isLoading:!0,error:null})),s)try{const t=await ev.verifyOTP(r.email,s,r.otp);console.log("Verify OTP Response:",t),yp(t.data.bearer),jp(),a(e=>({...e,step:"success",isLoading:!1})),setTimeout(()=>{e(r.email,t.data.bearer)},1500)}catch(o){let e="Invalid OTP. Please try again.";400===(null==(n=o.response)?void 0:n.status)?e="Invalid or expired OTP. Please try again.":o.message&&(e=o.message),a(t=>({...t,isLoading:!1,error:e}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}));else a(e=>({...e,error:"Please enter a valid 6-digit OTP"}))},u=async()=>{var e;if(!(r.countdown>0))if(a(e=>({...e,isLoading:!0,error:null})),s)try{await ev.login2FA(r.email,s);a(e=>({...e,isLoading:!1,countdown:60,error:null}))}catch(t){let s="Failed to resend OTP. Please try again.";404===(null==(e=t.response)?void 0:e.status)?s="User not found. Please check your email address.":t.message&&(s=t.message),a(e=>({...e,isLoading:!1,error:s}))}else a(e=>({...e,isLoading:!1,error:"Tenant ID is required"}))},h=()=>{a(e=>({...e,step:"email",otp:"",error:null,otpSent:!1,countdown:0}))};return $e.jsxs("div",{className:"flex flex-col h-full w-full",style:{fontFamily:t.fontFamily},children:[$e.jsx("div",{className:"flex-1 flex items-center justify-center px-6 py-8 w-full",children:$e.jsxs("div",{className:"w-full max-w-md mx-auto",children:[$e.jsxs(gi,{mode:"wait",children:["email"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:"space-y-6",children:[$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(yf,{className:"h-8 w-8",style:{color:t.primaryColor}})}),$e.jsx("h2",{className:"text-xl font-semibold",style:{fontFamily:t.fontFamily,color:t.headerBg},children:"Welcome Back"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"Enter your email address to continue"})]}),$e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[$e.jsx("div",{children:$e.jsx(qy,{ref:i,type:"email",value:r.email,onChange:e=>a(t=>({...t,email:e.target.value,error:null})),placeholder:"Enter your email address",disabled:r.isLoading,className:"w-full",style:{fontFamily:t.fontFamily},"aria-label":"Email address"})}),$e.jsx(Ou,{type:"submit",disabled:!r.email||r.isLoading,className:"w-full flex items-center justify-center gap-2",style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:r.isLoading?$e.jsx(ff,{className:"h-4 w-4 animate-spin text-white"}):$e.jsxs($e.Fragment,{children:["Continue",$e.jsx(Yp,{className:"h-4 w-4"})]})})]})]},"email"),"otp"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.3},className:"space-y-6",children:[$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{backgroundColor:t.primaryColor+"20"},children:$e.jsx(Mf,{className:"h-8 w-8",style:{color:t.primaryColor}})}),$e.jsx("h2",{className:"text-xl font-semibold",style:{fontFamily:t.fontFamily,color:t.headerBg},children:"Verify Your Email"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"We've sent a 6-digit code to"}),$e.jsx("p",{className:"font-medium text-sm",style:{fontFamily:t.fontFamily,color:t.primaryColor},children:r.email})]}),$e.jsxs("form",{onSubmit:d,className:"space-y-4",children:[$e.jsx("div",{children:$e.jsx(qy,{ref:o,type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:r.otp,onChange:e=>{const t=e.target.value.replace(/\D/g,"");a(e=>({...e,otp:t,error:null}))},placeholder:"Enter 6-digit code",disabled:r.isLoading,className:"w-full text-center text-lg tracking-widest",style:{fontFamily:t.fontFamily},"aria-label":"One-time password"})}),$e.jsx(Ou,{type:"submit",disabled:6!==r.otp.length||r.isLoading,className:"w-full flex items-center justify-center gap-2",style:{backgroundColor:t.primaryColor,fontFamily:t.fontFamily},children:r.isLoading?$e.jsx(ff,{className:"h-4 w-4 animate-spin text-white"}):$e.jsxs($e.Fragment,{children:["Verify Code",$e.jsx(Yp,{className:"h-4 w-4"})]})})]}),$e.jsxs("div",{className:"text-center space-y-2",children:[$e.jsx("p",{className:"text-sm text-gray-600",style:{fontFamily:t.fontFamily},children:"Didn't receive the code?"}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:u,disabled:r.countdown>0||r.isLoading,style:{fontFamily:t.fontFamily},children:r.countdown>0?`Resend in ${r.countdown}s`:"Resend Code"}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:h,disabled:r.isLoading,style:{fontFamily:t.fontFamily},children:"Change Email"})]})]},"otp"),"success"===r.step&&$e.jsxs(pd.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},transition:{duration:.5},className:"text-center space-y-6",children:[$e.jsx("div",{className:"w-20 h-20 rounded-full flex items-center justify-center mx-auto",style:{backgroundColor:"#10b98120"},children:$e.jsx(nf,{className:"h-10 w-10 text-green-500"})}),$e.jsxs("div",{className:"space-y-2",children:[$e.jsx("h2",{className:"text-xl font-semibold text-green-600",style:{fontFamily:t.fontFamily},children:"Authentication Successful!"}),$e.jsx("p",{className:"text-gray-600 text-sm",style:{fontFamily:t.fontFamily},children:"Redirecting to dashboard..."})]}),$e.jsx("div",{className:"flex justify-center",children:$e.jsx(ff,{className:"h-6 w-6 animate-spin text-primary"})})]},"success")]}),$e.jsx(gi,{children:r.error&&$e.jsxs(pd.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg flex items-center gap-2",children:[$e.jsx(sf,{className:"h-4 w-4 text-red-500 flex-shrink-0"}),$e.jsx("p",{className:"text-sm text-red-700",style:{fontFamily:t.fontFamily},children:r.error})]})})]})}),$e.jsx(tv,{})]})}function nv({error:e,onRetry:t,isRetrying:s=!1,errorType:n="validation"}){const r="network"===n||"server"===n||"rate_limit"===n;return $e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:$e.jsxs("div",{className:"max-w-sm w-full text-center",children:[$e.jsx("div",{className:"flex justify-center mb-4",children:$e.jsx("div",{className:"p-3 rounded-full "+("rate_limit"===n?"bg-orange-100":"bg-red-100"),children:(()=>{switch(n){case"network":return $e.jsx(Bf,{className:"w-6 h-6 text-red-600"});case"rate_limit":return $e.jsx(Lf,{className:"w-6 h-6 text-orange-600"});default:return $e.jsx(Lf,{className:"w-6 h-6 text-red-600"})}})()})}),$e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:(()=>{switch(n){case"network":return"Connection Error";case"rate_limit":return"Rate Limit Exceeded";case"server":return"Server Error";default:return"Access Denied"}})()}),$e.jsx("p",{className:"text-gray-600 text-sm mb-4",children:e}),$e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 mb-4",children:[$e.jsxs("div",{className:"flex items-center justify-center mb-2",children:[$e.jsx(pf,{className:"w-4 h-4 text-gray-500 mr-2"}),$e.jsx("span",{className:"text-xs font-medium text-gray-700",children:"network"===n?"Connection Issue":"API Key Required"})]}),$e.jsx("p",{className:"text-xs text-gray-500",children:(()=>{switch(n){case"network":return"Unable to connect to the validation server. Please check your internet connection.";case"rate_limit":return"Too many validation requests. Please wait a moment before trying again.";case"server":return"The validation server is currently unavailable. Please try again later.";default:return"Please provide a valid Pangents API key to access the widget."}})()})]}),r&&t&&$e.jsx(Ou,{onClick:t,disabled:s,variant:"outline",size:"sm",className:"mb-4",children:s?$e.jsxs($e.Fragment,{children:[$e.jsx(Cf,{className:"w-4 h-4 mr-2 animate-spin"}),"Retrying..."]}):$e.jsxs($e.Fragment,{children:[$e.jsx(Cf,{className:"w-4 h-4 mr-2"}),"Try Again"]})}),$e.jsx("div",{className:"text-xs text-gray-400",children:$e.jsx("p",{children:"validation"===n?"Contact your administrator for API key access.":"If the problem persists, contact support."})})]})})}function rv(){return function(){if("undefined"==typeof window)return null;const e=new URLSearchParams(window.location.search);return e.get("apiKey")||e.get("api_key")}()||("undefined"!=typeof window&&(null==(e=window.PangentsConfig)?void 0:e.apiKey)?window.PangentsConfig.apiKey:null);var e}const av=(e,t,s,n)=>({message:e,status:t,code:s,details:n,timestamp:(new Date).toISOString()}),iv="/settings/applications/validate",ov="/workspace/users/tenant/application/auth",lv=9e5,cv="api_key_validation_",dv="pangents_bearer_token",uv=3,hv=1e3,mv=1e4,pv=10,fv=6e4,gv="api_key_validation_rate_limit";class yv{static sanitizeApiKey(e){if("string"!=typeof e)throw new Error("API key must be a string");const t=e.trim().replace(/[\x00-\x1F\x7F]/g,"");if(t.length<this.MIN_KEY_LENGTH||t.length>this.MAX_KEY_LENGTH)throw new Error(`API key length must be between ${this.MIN_KEY_LENGTH} and ${this.MAX_KEY_LENGTH} characters`);return t}static validateApiKeyFormat(e){return this.API_KEY_PATTERN.test(e)}static isValidApiKey(e){try{const t=this.sanitizeApiKey(e);return this.validateApiKeyFormat(t)?{isValid:!0}:{isValid:!1,error:"Invalid API key format. Expected format: pangents_wk_[alphanumeric characters]"}}catch(t){return{isValid:!1,error:t instanceof Error?t.message:"Invalid API key"}}}}Ce(yv,"API_KEY_PATTERN",/^[A-Za-z0-9_-]{32,64}$/),Ce(yv,"MAX_KEY_LENGTH",100),Ce(yv,"MIN_KEY_LENGTH",20);class xv{static getRequestHistory(){try{const e=localStorage.getItem(gv);return e?JSON.parse(e):[]}catch{return[]}}static setRequestHistory(e){try{localStorage.setItem(gv,JSON.stringify(e))}catch{}}static isRateLimited(){const e=Date.now();return this.getRequestHistory().filter(t=>e-t<fv).length>=pv}static recordRequest(){const e=Date.now(),t=[...this.getRequestHistory(),e].filter(t=>e-t<fv);this.setRequestHistory(t)}static getRemainingRequests(){const e=Date.now(),t=this.getRequestHistory().filter(t=>e-t<fv);return Math.max(0,pv-t.length)}static getResetTime(){const e=this.getRequestHistory();if(0===e.length)return 0;return Math.min(...e)+fv}}class vv{static getCacheKey(e){const t=btoa(e).replace(/[^a-zA-Z0-9]/g,"").substring(0,16);return`${cv}${t}`}static get(e){try{if(this.shouldClearCacheForApiKey(e))return this.clear(),null;const t=this.getCacheKey(e),s=localStorage.getItem(t);if(!s)return null;const n=JSON.parse(s);return Date.now()>n.expiresAt?(this.remove(e),null):n}catch{return null}}static shouldClearCacheForApiKey(e){try{const{apiKeyTracker:t}=require("../cache/ApiKeyTracker");return t.getCurrentApiKey()||t.initialize(e),t.hasApiKeyChanged(e)?(t.updateApiKey(e),!0):t.shouldClearCache()}catch(t){return console.warn("[ValidationCache] Failed to check API key alignment:",t),!1}}static set(e,t){try{const n=this.getCacheKey(e);localStorage.setItem(n,JSON.stringify(t));try{const{apiKeyTracker:e}=require("../cache/ApiKeyTracker");e.markCacheAligned()}catch(s){console.warn("[ValidationCache] Failed to mark cache as aligned:",s)}}catch{}}static remove(e){try{const t=this.getCacheKey(e);localStorage.removeItem(t)}catch{}}static clear(){try{Object.keys(localStorage).forEach(e=>{e.startsWith(cv)&&localStorage.removeItem(e)});try{const{apiKeyTracker:e}=require("../cache/ApiKeyTracker");e.markCacheAligned()}catch(e){console.warn("[ValidationCache] Failed to reset cache alignment:",e)}}catch{}}static getStats(){try{const e=Object.keys(localStorage).filter(e=>e.startsWith(cv));let t=0,s=0;const n=Date.now();return e.forEach(e=>{try{const r=localStorage.getItem(e);if(r){const e=JSON.parse(r);n>e.expiresAt?s++:t++}}catch{}}),{totalCached:e.length,validCached:t,expiredCached:s}}catch{return{totalCached:0,validCached:0,expiredCached:0}}}}class bv{static recordCacheHit(){this.metrics.cacheHits++,this.metrics.totalRequests++}static recordCacheMiss(){this.metrics.cacheMisses++}static recordValidationSuccess(e){this.metrics.validationSuccesses++,this.metrics.totalRequests++,this.updateAverageResponseTime(e),this.metrics.lastRequestTime=Date.now()}static recordValidationFailure(e){this.metrics.validationFailures++,this.metrics.totalRequests++,this.updateAverageResponseTime(e),this.metrics.lastRequestTime=Date.now()}static recordNetworkError(){this.metrics.networkErrors++,this.metrics.totalRequests++,this.metrics.lastRequestTime=Date.now()}static updateAverageResponseTime(e){const t=this.metrics.validationSuccesses+this.metrics.validationFailures;this.metrics.averageResponseTime=1===t?e:(this.metrics.averageResponseTime*(t-1)+e)/t}static getMetrics(){return{...this.metrics}}static getCacheHitRate(){const e=this.metrics.cacheHits+this.metrics.cacheMisses;return e>0?this.metrics.cacheHits/e:0}static getSuccessRate(){const e=this.metrics.validationSuccesses+this.metrics.validationFailures;return e>0?this.metrics.validationSuccesses/e:0}static reset(){this.metrics={totalRequests:0,cacheHits:0,cacheMisses:0,validationSuccesses:0,validationFailures:0,networkErrors:0,averageResponseTime:0,lastRequestTime:0}}}Ce(bv,"metrics",{totalRequests:0,cacheHits:0,cacheMisses:0,validationSuccesses:0,validationFailures:0,networkErrors:0,averageResponseTime:0,lastRequestTime:0});class wv{static async makeTenantAuthRequest(e,t,s,n=0){var r,a,i,o,l,c;const d=Date.now();try{const n=await Mp.post(ov,{email:t,tenant_id:s},{timeout:mv,headers:{"Content-Type":"application/json",api_key:e,request_origin:"tenant"},transformRequest:[e=>JSON.stringify(e)],transformResponse:[e=>"string"==typeof e?JSON.parse(e):e]}),r=Date.now()-d;return bv.recordValidationSuccess(r),n.data}catch(u){const h=Date.now()-d;if(401===(null==(r=u.response)?void 0:r.status))throw bv.recordValidationFailure(h),av("Invalid API key or credentials",401,"INVALID_API_KEY");if(403===(null==(a=u.response)?void 0:a.status))throw bv.recordValidationFailure(h),av("Access forbidden. Invalid tenant or email.",403,"FORBIDDEN");if(429===(null==(i=u.response)?void 0:i.status))throw bv.recordValidationFailure(h),av("Rate limit exceeded",429,"RATE_LIMIT_EXCEEDED");if(n<uv&&(!u.response||u.response.status>=500))return await new Promise(e=>setTimeout(e,hv*Math.pow(2,n))),this.makeTenantAuthRequest(e,t,s,n+1);throw bv.recordNetworkError(),av((null==(l=null==(o=u.response)?void 0:o.data)?void 0:l.detail)||"Network error occurred",(null==(c=u.response)?void 0:c.status)||0,"NETWORK_ERROR")}}static async makeValidationRequest(e,t,s=0){var n,r,a,i,o;const l=Date.now();try{const s=await Mp.post(iv,{api_key:e,tenant_id:t},{timeout:mv,headers:{"Content-Type":"application/json",api_key:e,request_origin:"tenant"}}),n=Date.now()-l;return bv.recordValidationSuccess(n),s.data}catch(c){const d=Date.now()-l;if(401===(null==(n=c.response)?void 0:n.status))throw bv.recordValidationFailure(d),av("Invalid API key",401,"INVALID_API_KEY");if(429===(null==(r=c.response)?void 0:r.status))throw bv.recordValidationFailure(d),av("Rate limit exceeded",429,"RATE_LIMIT_EXCEEDED");if(s<uv&&(!c.response||c.response.status>=500))return await new Promise(e=>setTimeout(e,hv*Math.pow(2,s))),this.makeValidationRequest(e,t,s+1);throw bv.recordNetworkError(),av((null==(i=null==(a=c.response)?void 0:a.data)?void 0:i.detail)||"Network error occurred",(null==(o=c.response)?void 0:o.status)||0,"NETWORK_ERROR")}}static saveBearerToken(e){try{localStorage.setItem(dv,e)}catch{}}static getBearerToken(){try{return localStorage.getItem(dv)}catch{return null}}static clearBearerToken(){try{localStorage.removeItem(dv)}catch{}}static saveAuthEmail(e){try{localStorage.setItem("pangents_auth_email",e)}catch{}}static getAuthEmail(){try{return localStorage.getItem("pangents_auth_email")}catch{return null}}static clearAuthEmail(){try{localStorage.removeItem("pangents_auth_email")}catch{}}static hasValidSession(){const e=this.getBearerToken(),t=this.getAuthEmail();return!(!e||!t)}static getExistingSession(){const e=this.getBearerToken(),t=this.getAuthEmail();return e&&t?{bearerToken:e,email:t}:null}static clearAllAuthData(){this.clearBearerToken(),this.clearAuthEmail(),this.clearCache()}static async validateWithTenantAuth(e,t,s){var n;const r=this.getExistingSession();if(r)return console.log("[ApiKeyValidation] Found existing session, using cached auth"),{isValid:!0,bearerToken:r.bearerToken,email:r.email,fromCache:!0};try{if(xv.isRateLimited()){const e=xv.getResetTime();return{isValid:!1,error:`Rate limit exceeded. Please try again in ${Math.ceil((e-Date.now())/1e3)} seconds.`}}xv.recordRequest();const r=await this.makeTenantAuthRequest(e,t,s);return console.log("[ApiKeyValidation] Auth response:",r),r.status&&(null==(n=r.data)?void 0:n.bearer)?(this.saveBearerToken(r.data.bearer),t&&this.saveAuthEmail(t),{isValid:!0,bearerToken:r.data.bearer,email:t,fromCache:!1}):{isValid:!1,error:"Authentication failed. No bearer token received."}}catch(a){const e=(null==a?void 0:a.message)||"Authentication request failed";return this.clearBearerToken(),{isValid:!1,error:e}}}static async validateApiKey(e,t){try{const s=yv.sanitizeApiKey(e),n=yv.isValidApiKey(s);if(!n.isValid)return{isValid:!1,error:n.error};if(xv.isRateLimited()){const e=xv.getResetTime();return{isValid:!1,error:`Rate limit exceeded. Please try again in ${Math.ceil((e-Date.now())/1e3)} seconds.`}}const r=vv.get(s);if(console.log("cached",r),r)return bv.recordCacheHit(),{isValid:r.isValid,response:r.response,error:r.error,fromCache:!0};bv.recordCacheMiss(),xv.recordRequest();const a=await this.makeValidationRequest(s,t),i=a.success&&a.data.valid,o=Date.now(),l={isValid:i,response:a.data,cachedAt:o,expiresAt:o+lv};return vv.set(s,l),{isValid:i,response:a.data,fromCache:!1}}catch(s){const t=(null==s?void 0:s.message)||"Validation request failed";console.log("Text Error",t);const n=Date.now(),r={isValid:!1,error:t,cachedAt:n,expiresAt:n+lv/3};try{const t=yv.sanitizeApiKey(e);vv.set(t,r)}catch{}return{isValid:!1,error:t}}}static clearCache(){vv.clear()}static getCacheStats(){return vv.getStats()}static getMetrics(){return{...bv.getMetrics(),cacheHitRate:bv.getCacheHitRate(),successRate:bv.getSuccessRate(),rateLimitInfo:{remainingRequests:xv.getRemainingRequests(),resetTime:xv.getResetTime(),isLimited:xv.isRateLimited()}}}static resetMetrics(){bv.reset()}static async prevalidateApiKey(e){try{await this.validateApiKey(e)}catch{}}static async validateMultipleApiKeys(e){return(await Promise.allSettled(e.map(async e=>({apiKey:e,...await this.validateApiKey(e)})))).map((t,s)=>"fulfilled"===t.status?t.value:{apiKey:e[s],isValid:!1,error:"Validation failed"})}}const Sv="pangents_current_api_key",jv="pangents_cache_api_key_alignment",kv=class e{constructor(){Ce(this,"currentApiKey",null),Ce(this,"listeners",new Set),Ce(this,"initialized",!1)}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){if(this.initialized)return;const t=this.getStoredApiKey(),s=t!==e;this.currentApiKey=e,this.storeApiKey(e);let n="initial_load";s&&null!==t?n="key_change":s||null===t||(n="page_reload"),(s||"initial_load"===n)&&this.notifyListeners({previousKey:t,currentKey:e,timestamp:Date.now(),reason:n}),this.initialized=!0}updateApiKey(e){const t=this.currentApiKey,s=t!==e;return s&&(this.currentApiKey=e,this.storeApiKey(e),this.notifyListeners({previousKey:t,currentKey:e,timestamp:Date.now(),reason:"key_change"})),s}getCurrentApiKey(){return this.currentApiKey}hasApiKeyChanged(e){return this.currentApiKey!==e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}getCacheAlignment(){const e=this.getCacheAlignmentInfo(),t=e.apiKey===this.currentApiKey;return{currentApiKey:this.currentApiKey,cacheApiKey:e.apiKey,isAligned:t,lastUpdate:e.timestamp}}markCacheAligned(){this.setCacheAlignmentInfo({apiKey:this.currentApiKey,timestamp:Date.now()})}shouldClearCache(){const e=this.getCacheAlignment();return!e.isAligned&&null!==e.cacheApiKey}reset(){this.currentApiKey=null,this.initialized=!1,this.listeners.clear(),this.clearStoredData()}getStoredApiKey(){try{return localStorage.getItem(Sv)}catch(e){return console.warn("[ApiKeyTracker] Failed to get stored API key:",e),null}}storeApiKey(e){try{e?localStorage.setItem(Sv,e):localStorage.removeItem(Sv)}catch(t){console.warn("[ApiKeyTracker] Failed to store API key:",t)}}getCacheAlignmentInfo(){try{const e=localStorage.getItem(jv);if(e)return JSON.parse(e)}catch(e){console.warn("[ApiKeyTracker] Failed to get cache alignment info:",e)}return{apiKey:null,timestamp:0}}setCacheAlignmentInfo(e){try{localStorage.setItem(jv,JSON.stringify(e))}catch(t){console.warn("[ApiKeyTracker] Failed to set cache alignment info:",t)}}notifyListeners(e){this.listeners.forEach(t=>{try{t(e)}catch(s){console.error("[ApiKeyTracker] Error in listener:",s)}})}clearStoredData(){try{localStorage.removeItem(Sv),localStorage.removeItem(jv)}catch(e){console.warn("[ApiKeyTracker] Failed to clear stored data:",e)}}};Ce(kv,"instance",null);const Nv=kv.getInstance();function Ev(){const{closeWidget:e,theme:t,isAuthenticated:s,user:n,logout:r}=ns(),[a,i]=Oe.useState(!1),[o,l]=Oe.useState(!1);return Oe.useEffect(()=>{const e=new CustomEvent("widget:aspect_ratio_lock",{detail:{locked:o}});window.dispatchEvent(e)},[o]),$e.jsxs("div",{className:"flex items-center justify-between p-3 sm:p-4 border-b relative overflow-hidden",style:{background:`\n linear-gradient(\n to right,\n ${t.primaryColor}ff 0%,\n ${t.primaryColor}f2 40%,\n ${t.primaryColor}cc 100%\n )\n `,color:t.headerText,fontFamily:t.fontFamily},children:[$e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:`\n linear-gradient(\n to right,\n transparent 0%,\n ${t.primaryColor}22 40%,\n ${t.primaryColor}55 50%,\n ${t.primaryColor}22 60%,\n transparent 100%\n )\n `,backgroundSize:"200% 100%",animation:"headerShimmer 2.4s ease-in-out infinite",mixBlendMode:"screen"}}),$e.jsxs("div",{className:"flex items-center gap-2",children:[t.headerLogo&&""!=t.headerLogo&&$e.jsx("img",{src:t.headerLogo,alt:"Logo",className:"h-6 w-6 object-contain",onError:e=>{e.currentTarget.style.display="none"}}),$e.jsx("div",{className:"flex flex-col",children:$e.jsx("h2",{id:"search-modal-title",className:"font-semibold",children:t.headerTitle||"Pangents AI"})})]}),$e.jsxs("div",{className:"flex items-center gap-2",children:[s&&$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:r,className:"h-8 px-2 text-xs hover:bg-white/10",style:{color:t.headerText},"aria-label":"Logout",children:$e.jsx(Ef,{className:"h-4 w-4"})}),$e.jsx(Ou,{variant:"ghost",size:"sm",onClick:()=>{i(e=>{const t=!e;return window.dispatchEvent(new CustomEvent("widget:maximize_toggle",{detail:{maximized:t}})),t})},className:"h-8 w-8 p-0 hover:bg-white/10",style:{color:t.headerText},"aria-label":a?"Exit full-screen":"Enter full-screen",children:a?$e.jsx(wf,{className:"h-4 w-4"}):$e.jsx(vf,{className:"h-4 w-4"})}),$e.jsxs(Ou,{variant:"ghost",size:"sm",onClick:e,className:"h-8 w-8 p-0 hover:bg-white/10",style:{color:t.headerText},"aria-label":"Close search modal",children:[$e.jsx(Uf,{className:"h-4 w-4"}),$e.jsx("span",{className:"sr-only",children:"Close search"})]})]})]})}function Cv(){const e=Pg();return Oe.useEffect(()=>{e.pathname&&(Gt.saveCurrentRoute(e.pathname),console.log("[RouteTracker] Saved route:",e.pathname))},[e.pathname]),null}function Tv(){const e=Mg(),t=Pg(),{theme:s,user:n}=ns(),r=[{id:"Home",label:"Home",icon:mf,path:"/"},{id:"Email",label:"Email",icon:gf,path:"/email-leads"}],a=t.pathname,i=s.primaryColor||"#1e40af";return $e.jsxs("div",{className:"w-14 flex flex-col items-center py-4 h-full relative overflow-hidden",style:{fontFamily:s.fontFamily,background:`\n linear-gradient(\n to top,\n ${i}ff 0%,\n ${i}f2 40%,\n ${i}cc 100%\n )\n `},"aria-label":"Sidebar navigation",children:[$e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:`\n linear-gradient(\n to top,\n transparent 0%,\n ${i}22 40%,\n ${i}55 50%,\n ${i}22 60%,\n transparent 100%\n )\n `,backgroundSize:"100% 220%",animation:"sidebarShimmer 2.6s ease-in-out infinite",mixBlendMode:"screen"}}),$e.jsx("div",{className:"flex flex-col items-center gap-3 w-full px-2 relative z-10",children:r.map(t=>{const s=a===t.path||"/"!==t.path&&a.startsWith(t.path);return $e.jsx("button",{onClick:()=>e(t.path),title:t.label,"aria-label":t.label,className:`\n group relative flex items-center justify-center w-10 h-10 rounded-xl transition-all duration-200\n ${s?"bg-white shadow-md":"bg-white/20 hover:bg-white/40"}\n `,children:$e.jsx(t.icon,{className:"h-5 w-5 transition-transform duration-200 "+(s?"scale-105":"group-hover:scale-105"),style:{color:s?i:"white"}})},t.id)})})]})}function Pv(){const{isAuthenticated:e,setCurrentScreen:t,login:s,apiKey:n,tenantId:r}=ns(),[a,i]=Oe.useState({isValid:!1,isLoading:!0});Oe.useEffect(()=>{const e=n||rv();Nv.initialize(e);const t=Nv.subscribe(e=>{console.log("[WidgetPopup] API key change detected:",{reason:e.reason,hasChanged:e.previousKey!==e.currentKey,timestamp:new Date(e.timestamp).toISOString()}),("key_change"===e.reason||"page_reload"===e.reason&&e.previousKey!==e.currentKey)&&(console.log("[WidgetPopup] Clearing cache due to API key change"),wv.clearCache(),Gt.clearApiKey(),e.currentKey&&o(!0))}),s=()=>{console.log("[WidgetPopup] API key invalidated by server"),i({isValid:!1,isLoading:!1,error:"API key has been invalidated. Please check your credentials.",errorType:"validation"})};return window.addEventListener("api:key_invalid",s),()=>{t(),window.removeEventListener("api:key_invalid",s)}},[]);const o=async(e=!1)=>{var t,s,a,o,l;const c=n||rv();if(c){Nv.updateApiKey(c)&&!e&&(console.log("[WidgetPopup] API key changed, clearing cache"),wv.clearCache(),e=!0)}if(c)if(r)try{i(e=>({...e,isLoading:!0})),e&&(wv.clearCache(),wv.clearAllAuthData());const t=await wv.validateApiKey(c,r);t.isValid?(Gt.saveApiKey(c),console.log("[WidgetPopup] API key validated successfully")):(Gt.clearApiKey(),wv.clearAllAuthData()),i({isValid:t.isValid,isLoading:!1,error:t.isValid?void 0:t.error||"Invalid credentials. Access denied.",errorType:t.isValid?void 0:"validation"})}catch(d){console.error("API key validation failed:",d);let e="network",n="Connection failed. Please check your internet connection.";(null==(t=d.message)?void 0:t.includes("Rate limit"))?(e="rate_limit",n=d.message):(null==(s=d.message)?void 0:s.includes("Invalid API key"))||(null==(a=d.message)?void 0:a.includes("Invalid credentials"))?(e="validation",n="Invalid credentials. Access denied."):(null==(o=d.message)?void 0:o.includes("forbidden"))?(e="validation",n="Access forbidden. Invalid tenant or email."):(null==(l=d.response)?void 0:l.status)>=500&&(e="server",n="Server error. Please try again later."),i({isValid:!1,isLoading:!1,error:n,errorType:e})}else i({isValid:!1,isLoading:!1,error:"Tenant ID is required for authentication.",errorType:"validation"});else i({isValid:!1,isLoading:!1,error:"API key is required to access the Pangents chatbot widget.",errorType:"validation"})};Oe.useEffect(()=>{o()},[n,r]);const l=()=>{o(!0)};if(a.isLoading)return $e.jsxs("div",{className:"flex items-center justify-center p-8 w-full h-full",children:[$e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),$e.jsx("span",{className:"ml-3 text-sm text-gray-600",children:"Validating API key..."})]});if(!a.isValid)return $e.jsx(nv,{error:a.error,errorType:a.errorType,onRetry:l,isRetrying:a.isLoading});const c=(e,n)=>{s(e,n),t("chat")};return e?$e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[$e.jsx("div",{className:"flex-1 overflow-hidden",children:$e.jsx(Zx,{children:$e.jsx(Xx,{})})}),$e.jsx(tv,{})]}):$e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden w-full",children:$e.jsx(sv,{onAuthSuccess:c})})}function Av({position:e="bottom-right",zIndex:t}){const{isOpen:s,theme:n,closeWidget:r,isAuthenticated:a}=ns(),i="bottom-left"===e||"top-left"===e,o=Oe.useRef(null),[l,c]=Oe.useState(()=>({width:Math.min(.38*window.innerWidth,650),height:window.innerHeight})),d=Oe.useMemo(()=>{if(s){const e=Gt.getCurrentRoute();return console.log("[WidgetPopup] Loading initial route:",e||"/"),e||"/"}return"/"},[s]),[u,h]=Oe.useState(!1),[m,p]=Oe.useState(null),[f,g]=Oe.useState(!1),[y,x]=Oe.useState(!1),v=Oe.useRef(l.width/Math.max(l.height,1));Oe.useEffect(()=>{const e=e=>{const t=e.detail;t&&"boolean"==typeof t.locked&&g(t.locked)};return window.addEventListener("widget:aspect_ratio_lock",e),()=>window.removeEventListener("widget:aspect_ratio_lock",e)},[]),Oe.useEffect(()=>{const e=e=>{const t=e.detail;t&&"boolean"==typeof t.maximized&&x(t.maximized)};return window.addEventListener("widget:maximize_toggle",e),()=>window.removeEventListener("widget:maximize_toggle",e)},[]),Oe.useEffect(()=>{v.current=l.width/Math.max(l.height,1)},[l]);const b=Math.min(.95*window.innerWidth,950),w=window.innerHeight,S=(e,t)=>{t.preventDefault(),t.stopPropagation(),h(!0),p({x:t.clientX,y:t.clientY,width:l.width,height:l.height,edge:e})};return Oe.useEffect(()=>{const e=e=>{if(!u||!m)return;let t=0,s=0;m.edge.includes("right")&&(t=e.clientX-m.x),m.edge.includes("left")&&(t=m.x-e.clientX),m.edge.includes("bottom")&&(s=e.clientY-m.y),m.edge.includes("top")&&(s=m.y-e.clientY);let n=m.width+t,r=m.height+s;const a="left"===m.edge||"right"===m.edge;if(f&&!a){const e=v.current;Math.abs(t)>Math.abs(s)?r=n/e:n=r*e}a&&(r=m.height),n=Math.max(320,Math.min(b,n)),r=Math.max(400,Math.min(w,r)),c({width:n,height:r})},t=()=>{h(!1),p(null)};return window.addEventListener("mousemove",e),window.addEventListener("mouseup",t),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",t)}},[u,m,f]),Oe.useEffect(()=>{const e=()=>{c(e=>{const t=Math.min(.95*window.innerWidth,950),s=window.innerHeight;return e.width>t||e.height>s?{width:Math.min(e.width,t),height:Math.min(e.height,s)}:e})};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),console.log("WidgetPopup: Component rendered"),console.log("WidgetPopup: isOpen state:",s),console.log("WidgetPopup: isAuthenticated:",a),console.log("WidgetPopup: theme:",n),Oe.useEffect(()=>{const e=e=>{"Escape"===e.key&&s&&r()};if(s){document.addEventListener("keydown",e);const t=document.querySelector('[role="dialog"]');t&&t.focus()}return()=>{document.removeEventListener("keydown",e)}},[s,r]),$e.jsx(gi,{children:s&&$e.jsxs(pd.div,{className:"fixed inset-0 z-50",style:{zIndex:t??50},initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:[$e.jsx(pd.div,{className:"absolute inset-0 bg-black/10",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:r}),$e.jsx(pd.div,{ref:o,id:"pangents-widget-container",className:"fixed top-0 "+(i?"left-0":"right-0"),initial:{x:i?"-100%":"100%"},animate:{x:0},exit:{x:i?"-100%":"100%"},transition:{type:"spring",stiffness:300,damping:30},role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",tabIndex:-1,style:{width:y?`${window.innerWidth}px`:`${l.width}px`,height:y?`${window.innerHeight}px`:`${l.height}px`},children:$e.jsxs(By,{className:"h-full flex flex-col overflow-hidden shadow-2xl rounded-none",style:{fontFamily:n.fontFamily},children:[$e.jsxs(Ug,{initialEntries:[d],initialIndex:0,children:[$e.jsx(Cv,{}),$e.jsx(Ev,{}),$e.jsxs("div",{className:"flex flex-1 min-h-0",children:[a?$e.jsx(Tv,{}):null,$e.jsx(Pv,{})]})]},`router-${s}`),$e.jsx("div",{id:"widget-toast-container",style:{position:"absolute",top:"60px",left:"10px",right:"10px",zIndex:1e3,pointerEvents:"none"},children:$e.jsx(Vy,{position:"top-center",richColors:!0,closeButton:!0,expand:!1,visibleToasts:3,containerAriaLabel:"Notifications",toastOptions:{style:{marginTop:"0px",pointerEvents:"auto"},className:"widget-toast"}})}),$e.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[$e.jsx("div",{className:"absolute top-0 left-0 right-0 h-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top",role:"slider",onMouseDown:e=>S("top",e),style:{cursor:"ns-resize"}}),$e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom",role:"slider",onMouseDown:e=>S("bottom",e),style:{cursor:"ns-resize"}}),$e.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize left",role:"slider",onMouseDown:e=>S("left",e),style:{cursor:"ew-resize"}}),$e.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-3 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize right",role:"slider",onMouseDown:e=>S("right",e),style:{cursor:"ew-resize"}}),$e.jsx("div",{className:"absolute top-0 left-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top-left",role:"slider",onMouseDown:e=>S("top-left",e),style:{cursor:"nwse-resize"}}),$e.jsx("div",{className:"absolute top-0 right-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize top-right",role:"slider",onMouseDown:e=>S("top-right",e),style:{cursor:"nesw-resize"}}),$e.jsx("div",{className:"absolute bottom-0 left-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom-left",role:"slider",onMouseDown:e=>S("bottom-left",e),style:{cursor:"nesw-resize"}}),$e.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 pointer-events-auto focus:bg-blue-500/60","aria-label":"Resize bottom-right",role:"slider",onMouseDown:e=>S("bottom-right",e),style:{cursor:"nwse-resize"}})]})]})})]})})}function Rv({theme:e,className:t,position:s,margin:n,pangentsApiKey:r,tenantId:a,email:i,zIndex:o}){return Oe.useEffect(()=>{try{const e=window.__PANGENTS_WIDGET_CSS;if(e&&!document.getElementById("pangents-widget-styles")){const t=document.createElement("style");t.id="pangents-widget-styles",t.textContent=e,document.head.appendChild(t)}}catch{}},[]),$e.jsx("div",{className:t?`pg-widget-root ${t}`:"pg-widget-root",children:$e.jsx(_t,{client:Qy,children:$e.jsxs(ss,{initialTheme:e,apiKey:r,tenantId:a,email:i,children:[$e.jsx(_p,{position:s,margin:n,zIndex:o}),$e.jsx(Av,{position:s,zIndex:o})]})})})}var Mv,Dv={};var $v=function(){if(Mv)return Dv;Mv=1;var e=Fe;if("production"===process.env.NODE_ENV)Dv.createRoot=e.createRoot,Dv.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Dv.createRoot=function(s,n){t.usingClientEntryPoint=!0;try{return e.createRoot(s,n)}finally{t.usingClientEntryPoint=!1}},Dv.hydrateRoot=function(s,n,r){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(s,n,r)}finally{t.usingClientEntryPoint=!1}}}return Dv}();const Ov=new class{constructor(){Ce(this,"container",null),Ce(this,"shadow",null),Ce(this,"mountEl",null),Ce(this,"root",null),Ce(this,"config",{})}init(e){const t={...e};if(this.container&&this.root){const e=JSON.stringify(this.config.theme)!==JSON.stringify(t.theme),s=this.config.position!==t.position,n=this.config.margin!==t.margin,r=this.config.zIndex!==t.zIndex;if(e&&!s&&!n&&!r)return this.config=t,void this.render();if(s||n||r)return this.config=t,this.createContainer(),void this.render()}this.config=t,this.createContainer(),this.render()}createContainer(){this.container&&this.destroy(),this.container=document.createElement("div"),this.container.id="pangents-chatbot-widget",this.container.style.zIndex=String(this.config.zIndex||9999),this.shadow=this.container.attachShadow({mode:"open"}),this.mountEl=document.createElement("div"),this.mountEl.id="pg-widget-mount";const e=window.__PANGENTS_WIDGET_CSS||"";if(e){const t=document.createElement("style");t.id="pangents-widget-styles",t.textContent=e,this.shadow.appendChild(t)}this.shadow.appendChild(this.mountEl),document.body.appendChild(this.container)}render(){this.mountEl&&(this.root||(this.root=$v.createRoot(this.mountEl)),this.root.render($e.jsx(Oe.StrictMode,{children:$e.jsx(Rv,{theme:this.config.theme,position:this.config.position,margin:this.config.margin,pangentsApiKey:this.config.pangentsApiKey,tenantId:this.config.tenantId,email:this.config.email},JSON.stringify(this.config.theme))})))}destroy(){this.root&&(this.root.unmount(),this.root=null),this.shadow=null,this.mountEl=null,this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}updateConfig(e){const t={...this.config,...e};JSON.stringify(this.config.theme),JSON.stringify(t.theme);const s=this.config.position!==t.position,n=this.config.margin!==t.margin,r=this.config.zIndex!==t.zIndex;this.config=t,s||n||r?(this.createContainer(),this.render()):this.render()}updateTheme(e){e&&(this.config={...this.config,theme:e},this.render())}};"undefined"!=typeof window&&(window.Chatbot=Ov),exports.Chatbot=Ov,exports.Widget=Rv;
|
|
46
|
+
//# sourceMappingURL=widget-embed-BPoilyw_.cjs.js.map
|