teodor-new-chat-ui 4.3.444 → 4.3.446
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/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Yt,zr,nx,rx,Po,de){"use strict";var
|
|
1
|
+
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Yt,zr,nx,rx,Po,de){"use strict";var JI=Object.defineProperty;var ZI=(F,b,Yt)=>b in F?JI(F,b,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):F[b]=Yt;var ex=(F,b,Yt)=>ZI(F,typeof b!="symbol"?b+"":b,Yt);function Zl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=Zl(b),Hr=Zl(Po),Ql=120;function ox(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>Ql?`${n.slice(0,Ql-3)}…`:n:""}function hi(e){return ox(e.content)||""}function sx(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=hi(o);s&&t.set(r.checkpointId,s)}}return t}function ec(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const T of w)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),p&&t.set(p,C),p&&y){const T=hi(y);T&&r.set(p,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function tc(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function ix(e,t){return e?t.getCheckpoint(e)??null:null}function nc(e){return b.useMemo(()=>ec(e),[e])}function Pn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function mi(e){const t=Pn(e);if(t)return Pn(t.configurable)??t}function Mn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>ax(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function ax(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>lx(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=mi(e.config),i=Pn(e.parent_config??e.parentConfig),a=mi(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),p=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=Pn(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:rc(o,["step"])??0,source:Rn(o,["source"])??null},w=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:w,nextCursor:p,nextCursorNs:m,interrupt:fx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function lx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=cx(e);if(!t)return null;const n=dx(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function cx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&ux(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function ux(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function dx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function fx(e,t){return px(e,t)}function px(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var gi={exports:{}},Ur={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var sc;function hx(){if(sc)return Ur;sc=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return Ur.Fragment=n,Ur.jsx=i,Ur.jsxs=i,Ur}var Wr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var ic;function mx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var Q=v&&A[v]||A[g];return typeof Q=="function"?Q:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(A){{for(var Q=arguments.length,fe=new Array(Q>1?Q-1:0),Ie=1;Ie<Q;Ie++)fe[Ie-1]=arguments[Ie];S("error",A,fe)}}function S(A,Q,fe){{var Ie=y.ReactDebugCurrentFrame,Ye=Ie.getStackAddendum();Ye!==""&&(Q+="%s",fe=fe.concat([Ye]));var tt=fe.map(function(Ue){return String(Ue)});tt.unshift("Warning: "+Q),Function.prototype.apply.call(console[A],console,tt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,R;R=Symbol.for("react.module.reference");function L(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||j||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===R||A.getModuleId!==void 0))}function H(A,Q,fe){var Ie=A.displayName;if(Ie)return Ie;var Ye=Q.displayName||Q.name||"";return Ye!==""?fe+"("+Ye+")":fe}function B(A){return A.displayName||"Context"}function q(A){if(A==null)return null;if(typeof A.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var Q=A;return B(Q)+".Consumer";case i:var fe=A;return B(fe._context)+".Provider";case l:return H(A,A.render,"ForwardRef");case p:var Ie=A.displayName||null;return Ie!==null?Ie:q(A.type)||"Memo";case m:{var Ye=A,tt=Ye._payload,Ue=Ye._init;try{return q(Ue(tt))}catch{return null}}}return null}var N=Object.assign,z=0,$,M,P,I,V,J,_;function O(){}O.__reactDisabledLog=!0;function K(){{if(z===0){$=console.log,M=console.info,P=console.warn,I=console.error,V=console.group,J=console.groupCollapsed,_=console.groupEnd;var A={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}z++}}function Y(){{if(z--,z===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},A,{value:$}),info:N({},A,{value:M}),warn:N({},A,{value:P}),error:N({},A,{value:I}),group:N({},A,{value:V}),groupCollapsed:N({},A,{value:J}),groupEnd:N({},A,{value:_})})}z<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=y.ReactCurrentDispatcher,W;function D(A,Q,fe){{if(W===void 0)try{throw Error()}catch(Ye){var Ie=Ye.stack.trim().match(/\n( *(at )?)/);W=Ie&&Ie[1]||""}return`
|
|
18
18
|
`+W+A}}var X=!1,oe;{var G=typeof WeakMap=="function"?WeakMap:Map;oe=new G}function Z(A,Q){if(!A||X)return"";{var fe=oe.get(A);if(fe!==void 0)return fe}var Ie;X=!0;var Ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=ae.current,ae.current=null,K();try{if(Q){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(Gt){Ie=Gt}Reflect.construct(A,[],Ue)}else{try{Ue.call()}catch(Gt){Ie=Gt}A.call(Ue.prototype)}}else{try{throw Error()}catch(Gt){Ie=Gt}A()}}catch(Gt){if(Gt&&Ie&&typeof Gt.stack=="string"){for(var le=Gt.stack.split(`
|
|
19
19
|
`),Ce=Ie.stack.split(`
|
|
20
20
|
`),be=le.length-1,ze=Ce.length-1;be>=1&&ze>=0&&le[be]!==Ce[ze];)ze--;for(;be>=1&&ze>=0;be--,ze--)if(le[be]!==Ce[ze]){if(be!==1||ze!==1)do if(be--,ze--,ze<0||le[be]!==Ce[ze]){var At=`
|
|
21
|
-
`+le[be].replace(" at new "," at ");return A.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",A.displayName)),typeof A=="function"&&oe.set(A,At),At}while(be>=1&&ze>=0);break}}}finally{X=!1,ae.current=tt,Y(),Error.prepareStackTrace=Ye}var jt=A?A.displayName||A.name:"",
|
|
21
|
+
`+le[be].replace(" at new "," at ");return A.displayName&&At.includes("<anonymous>")&&(At=At.replace("<anonymous>",A.displayName)),typeof A=="function"&&oe.set(A,At),At}while(be>=1&&ze>=0);break}}}finally{X=!1,ae.current=tt,Y(),Error.prepareStackTrace=Ye}var jt=A?A.displayName||A.name:"",pr=jt?D(jt):"";return typeof A=="function"&&oe.set(A,pr),pr}function te(A,Q,fe){return Z(A,!1)}function se(A){var Q=A.prototype;return!!(Q&&Q.isReactComponent)}function ue(A,Q,fe){if(A==null)return"";if(typeof A=="function")return Z(A,se(A));if(typeof A=="string")return D(A);switch(A){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return te(A.render);case p:return ue(A.type,Q,fe);case m:{var Ie=A,Ye=Ie._payload,tt=Ie._init;try{return ue(tt(Ye),Q,fe)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,Me={},Oe=y.ReactDebugCurrentFrame;function Te(A){if(A){var Q=A._owner,fe=ue(A.type,A._source,Q?Q.type:null);Oe.setExtraStackFrame(fe)}else Oe.setExtraStackFrame(null)}function nt(A,Q,fe,Ie,Ye){{var tt=Function.call.bind(ge);for(var Ue in A)if(tt(A,Ue)){var le=void 0;try{if(typeof A[Ue]!="function"){var Ce=Error((Ie||"React class")+": "+fe+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ce.name="Invariant Violation",Ce}le=A[Ue](Q,Ue,Ie,fe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(be){le=be}le&&!(le instanceof Error)&&(Te(Ye),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",fe,Ue,typeof le),Te(null)),le instanceof Error&&!(le.message in Me)&&(Me[le.message]=!0,Te(Ye),w("Failed %s type: %s",fe,le.message),Te(null))}}}var pt=Array.isArray;function Tt(A){return pt(A)}function Ke(A){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,fe=Q&&A[Symbol.toStringTag]||A.constructor.name||"Object";return fe}}function Ge(A){try{return Ve(A),!1}catch{return!0}}function Ve(A){return""+A}function $e(A){if(Ge(A))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ke(A)),Ve(A)}var He=y.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},Dt,lt;function kt(A){if(ge.call(A,"ref")){var Q=Object.getOwnPropertyDescriptor(A,"ref").get;if(Q&&Q.isReactWarning)return!1}return A.ref!==void 0}function wt(A){if(ge.call(A,"key")){var Q=Object.getOwnPropertyDescriptor(A,"key").get;if(Q&&Q.isReactWarning)return!1}return A.key!==void 0}function gt(A,Q){typeof A.ref=="string"&&He.current}function ht(A,Q){{var fe=function(){Dt||(Dt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};fe.isReactWarning=!0,Object.defineProperty(A,"key",{get:fe,configurable:!0})}}function an(A,Q){{var fe=function(){lt||(lt=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",Q))};fe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:fe,configurable:!0})}}var dt=function(A,Q,fe,Ie,Ye,tt,Ue){var le={$$typeof:t,type:A,key:Q,ref:fe,props:Ue,_owner:tt};return le._store={},Object.defineProperty(le._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(le,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(le,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ye}),Object.freeze&&(Object.freeze(le.props),Object.freeze(le)),le};function ke(A,Q,fe,Ie,Ye){{var tt,Ue={},le=null,Ce=null;fe!==void 0&&($e(fe),le=""+fe),wt(Q)&&($e(Q.key),le=""+Q.key),kt(Q)&&(Ce=Q.ref,gt(Q,Ye));for(tt in Q)ge.call(Q,tt)&&!mt.hasOwnProperty(tt)&&(Ue[tt]=Q[tt]);if(A&&A.defaultProps){var be=A.defaultProps;for(tt in be)Ue[tt]===void 0&&(Ue[tt]=be[tt])}if(le||Ce){var ze=typeof A=="function"?A.displayName||A.name||"Unknown":A;le&&ht(Ue,ze),Ce&&an(Ue,ze)}return dt(A,le,Ce,Ye,Ie,He.current,Ue)}}var et=y.ReactCurrentOwner,Ae=y.ReactDebugCurrentFrame;function Le(A){if(A){var Q=A._owner,fe=ue(A.type,A._source,Q?Q.type:null);Ae.setExtraStackFrame(fe)}else Ae.setExtraStackFrame(null)}var Bt;Bt=!1;function re(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ye(){{if(et.current){var A=q(et.current.type);if(A)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+A+"`."}return""}}function rt(A){return""}var xe={};function Pe(A){{var Q=ye();if(!Q){var fe=typeof A=="string"?A:A.displayName||A.name;fe&&(Q=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+fe+">.")}return Q}}function Xe(A,Q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Pe(Q);if(xe[fe])return;xe[fe]=!0;var Ie="";A&&A._owner&&A._owner!==et.current&&(Ie=" It was passed a child from "+q(A._owner.type)+"."),Le(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ie),Le(null)}}function St(A,Q){{if(typeof A!="object")return;if(Tt(A))for(var fe=0;fe<A.length;fe++){var Ie=A[fe];re(Ie)&&Xe(Ie,Q)}else if(re(A))A._store&&(A._store.validated=!0);else if(A){var Ye=x(A);if(typeof Ye=="function"&&Ye!==A.entries)for(var tt=Ye.call(A),Ue;!(Ue=tt.next()).done;)re(Ue.value)&&Xe(Ue.value,Q)}}}function Et(A){{var Q=A.type;if(Q==null||typeof Q=="string")return;var fe;if(typeof Q=="function")fe=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===
|
|
25
|
+
Check the top-level render call using <`+fe+">.")}return Q}}function Xe(A,Q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Pe(Q);if(xe[fe])return;xe[fe]=!0;var Ie="";A&&A._owner&&A._owner!==et.current&&(Ie=" It was passed a child from "+q(A._owner.type)+"."),Le(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ie),Le(null)}}function St(A,Q){{if(typeof A!="object")return;if(Tt(A))for(var fe=0;fe<A.length;fe++){var Ie=A[fe];re(Ie)&&Xe(Ie,Q)}else if(re(A))A._store&&(A._store.validated=!0);else if(A){var Ye=x(A);if(typeof Ye=="function"&&Ye!==A.entries)for(var tt=Ye.call(A),Ue;!(Ue=tt.next()).done;)re(Ue.value)&&Xe(Ue.value,Q)}}}function Et(A){{var Q=A.type;if(Q==null||typeof Q=="string")return;var fe;if(typeof Q=="function")fe=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===p))fe=Q.propTypes;else return;if(fe){var Ie=q(Q);nt(fe,A.props,"prop",Ie,A)}else if(Q.PropTypes!==void 0&&!Bt){Bt=!0;var Ye=q(Q);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ye||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(A){{for(var Q=Object.keys(A.props),fe=0;fe<Q.length;fe++){var Ie=Q[fe];if(Ie!=="children"&&Ie!=="key"){Le(A),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Le(null);break}}A.ref!==null&&(Le(A),w("Invalid attribute `ref` supplied to `React.Fragment`."),Le(null))}}var zt={};function _e(A,Q,fe,Ie,Ye,tt){{var Ue=L(A);if(!Ue){var le="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(le+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ce=rt();Ce?le+=Ce:le+=ye();var be;A===null?be="null":Tt(A)?be="array":A!==void 0&&A.$$typeof===t?(be="<"+(q(A.type)||"Unknown")+" />",le=" Did you accidentally export a JSX literal instead of a component?"):be=typeof A,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",be,le)}var ze=ke(A,Q,fe,Ye,tt);if(ze==null)return ze;if(Ue){var At=Q.children;if(At!==void 0)if(Ie)if(Tt(At)){for(var jt=0;jt<At.length;jt++)St(At[jt],A);Object.freeze&&Object.freeze(At)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else St(At,A)}if(ge.call(Q,"key")){var pr=q(A),Gt=Object.keys(Q).filter(function(XI){return XI!=="key"}),Jl=Gt.length>0?"{key: someKey, "+Gt.join(": ..., ")+": ...}":"{key: someKey}";if(!zt[pr+Jl]){var YI=Gt.length>0?"{"+Gt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Xl,hr,GI,hr),zt[hr+Xl]=!0}}return A===r?Nt(ze):Et(ze),ze}}function ct(A,Q,fe){return _e(A,Q,fe,!0)}function Je(A,Q,fe){return _e(A,Q,fe,!1)}var ft=Je,ln=ct;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=ln}()),Wr}process.env.NODE_ENV==="production"?gi.exports=px():gi.exports=mx();var u=gi.exports;const gx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ic(e,t){return function(){return e.apply(t,arguments)}}const{toString:xx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Mo,toStringTag:ac}=Symbol,Ro=(e=>t=>{const n=xx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Oo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Oo("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=cn("ArrayBuffer");function vx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const bx=Oo("string"),Ht=Oo("function"),cc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",wx=e=>e===!0||e===!1,Do=e=>{if(Ro(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(Mo in e)},yx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Sx=cn("Date"),Cx=cn("File"),Tx=cn("Blob"),kx=cn("FileList"),Ex=e=>Kr(e)&&Ht(e.pipe),Ix=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Ro(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Nx=cn("URLSearchParams"),[Ax,jx,_x,Px]=["ReadableStream","Request","Response","Headers"].map(cn),Mx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function uc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!mr(e)&&e!==Jn;function vi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Rx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Ox=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Dx=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Lx=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$x=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Fx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!cc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Bx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),zx=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Hx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ux=cn("HTMLFormElement"),Wx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),fc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vx=cn("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Kx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Gx=()=>{},Yx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Xx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Mo])}const Jx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Zx=cn("AsyncFunction"),Qx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Jn.postMessage)),ev=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||pc,U={isArray:pr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ix,isArrayBufferView:vx,isString:bx,isNumber:cc,isBoolean:wx,isObject:Kr,isPlainObject:Do,isEmptyObject:yx,isReadableStream:Ax,isRequest:jx,isResponse:_x,isHeaders:Px,isUndefined:mr,isDate:Sx,isFile:Cx,isBlob:Tx,isRegExp:Vx,isFunction:Ht,isStream:Ex,isURLSearchParams:Nx,isTypedArray:Bx,isFileList:kx,forEach:qr,merge:vi,extend:Rx,trim:Mx,stripBOM:Ox,inherits:Dx,toFlatObject:Lx,kindOf:Ro,kindOfTest:cn,endsWith:$x,toArray:Fx,forEachEntry:zx,matchAll:Hx,isHTMLForm:Ux,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Kx,toObjectSet:qx,toCamelCase:Wx,noop:Gx,toFiniteNumber:Yx,findKey:uc,global:Jn,isContextDefined:dc,isSpecCompliantForm:Xx,toJSONObject:Jx,isAsyncFn:Zx,isThenable:Qx,setImmediate:pc,asap:ev,isIterable:e=>e!=null&&Ht(e[Mo])};function Me(e,t,n,r,o){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),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}U.inherits(Me,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:U.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Me.prototype,gc={};["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=>{gc[e]={value:e}}),Object.defineProperties(Me,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);U.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Me.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const tv=null;function bi(e){return U.isPlainObject(e)||U.isArray(e)}function xc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function vc(e,t,n){return e?e.concat(t).map(function(o,s){return o=xc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function nv(e){return U.isArray(e)&&!e.some(bi)}const rv=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!U.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(U.isDate(v))return v.toISOString();if(U.isBoolean(v))return v.toString();if(!l&&U.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(v)||U.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(U.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(U.isArray(v)&&nv(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(U.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return bi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(rv,{defaultVisitor:d,convertValue:c,isVisitable:bi});function f(v,g){if(!U.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),U.forEach(v,function(y,w){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function wi(e,t){this._pairs=[],e&&Lo(e,this,t)}const wc=wi.prototype;wc.append=function(t,n){this._pairs.push([t,n])},wc.toString=function(t){const n=t?function(r){return t.call(this,r,bc)}:bc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ov(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yc(e,t,n){if(!t)return e;const r=n&&n.encode||ov;U.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=U.isURLSearchParams(t)?t.toString():new wi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Sc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:wi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,iv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),av=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lv=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:iv,hasStandardBrowserWebWorkerEnv:av,navigator:Si,origin:lv},Symbol.toStringTag,{value:"Module"})),...sv};function cv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function uv(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dv(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Tc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&U.isArray(o)?o.length:i,l?(U.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!U.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&U.isArray(o[i])&&(o[i]=dv(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(uv(r),o,n,0)}),n}return null}function fv(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=U.isObject(t);if(s&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cv(t,this.formSerializer).toString();if((a=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),fv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Me.from(a,Me.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const hv=U.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"]),pv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(vv(o,i),r[a]=!0)}return U.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),U.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return U.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ec(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(gr,Me,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function bv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function wv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function yv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=wv(50,250);return yv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>U.asap(()=>e(...t)),Sv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Cv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];U.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),U.isString(r)&&i.push("path="+r),U.isString(o)&&i.push("domain="+o),s===!0&&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(){return null},remove(){}};function Tv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function kv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Tv(t);return e&&(r||n==!1)?kv(e,t):t}const _c=e=>e instanceof Ut?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return U.isPlainObject(c)&&U.isPlainObject(d)?U.merge.call({caseless:m},c,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function o(c,d,h,m){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!U.isUndefined(d))return r(void 0,d)}function i(c,d){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}const l={url:s,method:s,data:s,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:a,headers:(c,d,h)=>o(_c(c),_c(d),h,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);U.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Pc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=yc(jc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),U.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(U.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(_t.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&Sv(t.url))){const l=o&&s&&Cv.read(s);l&&i.set(o,l)}return t},Ev=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Ut.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Ic(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Me("Request aborted",Me.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Me(C,Me.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Me(k,C.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&U.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),U.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Fo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=bv(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Me("Unsupported protocol "+w+":",Me.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Iv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Me?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>U.asap(a),l}},Nv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Av=async function*(e,t){for await(const n of jv(e))yield*Nv(n,t)},jv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Mc=(e,t,n,r)=>{const o=Av(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Rc=64*1024,{isFunction:Bo}=U,_v=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Oc,TextEncoder:Dc}=U.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pv=e=>{e=U.merge.call({skipUndefined:!0},_v,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Oc),l=o&&(typeof Dc=="function"?(v=>g=>v.encode(g))(new Dc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Lc(()=>{let v=!1;const g=new n(_t.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>U.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(U.isBlob(v))return v.size;if(U.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(U.isArrayBufferView(v)||U.isArrayBuffer(v))return v.byteLength;if(U.isURLSearchParams(v)&&(v=v+""),U.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=U.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:M="same-origin",fetchOptions:L}=Pc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let B=Iv([w,S&&S.toAbortSignal()],k),q=null;const N=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let z;try{if(T&&c&&x!=="get"&&x!=="head"&&(z=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(U.isFormData(y)&&(_=J.headers.get("content-type"))&&j.setContentType(_),J.body){const[O,K]=Nc(z,Fo(Ac(T)));y=Mc(J.body,Rc,O,K)}}U.isString(M)||(M=M?"include":"omit");const $=s&&"credentials"in n.prototype,R={...L,signal:B,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:$?M:void 0};q=s&&new n(g,R);let P=await(s?H(q,L):H(g,R));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&N)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=P[Y]});const _=U.toFiniteNumber(P.headers.get("content-length")),[O,K]=C&&Nc(_,Fo(Ac(C),!0))||[];P=new r(Mc(P.body,Rc,O,()=>{K&&K(),N&&N()}),J)}E=E||"text";let V=await h[U.findKey(h,E)||"text"](P,v);return!I&&N&&N(),await new Promise((J,_)=>{Ic(J,_,{data:V,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:q})})}catch($){throw N&&N(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,q),{cause:$.cause||$}):Me.from($,$&&$.code,v,q)}}},Mv=new Map,$c=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Mv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Pv(t)),d=c;return c};$c();const ki={http:tv,xhr:Ev,fetch:{get:$c}};U.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Rv=e=>U.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=U.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Rv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&(U.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&U.merge(s.common,s[n.method]);s&&U.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),U.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Dv=class tx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new tx(function(o){t=o}),cancel:t}}};function Lv(e){return function(n){return e.apply(null,n)}}function $v(e){return U.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Wc(e){const t=new Qn(e),n=ic(Qn.prototype.request,t);return U.extend(n,Qn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Zn(e,o))},n}const xt=Wc(Gr);xt.Axios=Qn,xt.CanceledError=gr,xt.CancelToken=Dv,xt.isCancel=Ec,xt.VERSION=Hc,xt.toFormData=Lo,xt.AxiosError=Me,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Lv,xt.isAxiosError=$v,xt.mergeConfig=Zn,xt.AxiosHeaders=Ut,xt.formToJSON=e=>Tc(U.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=Bc.getAdapter,xt.HttpStatusCode=Ii,xt.default=xt;const{Axios:oN,AxiosError:sN,CanceledError:iN,isCancel:aN,CancelToken:lN,VERSION:cN,all:uN,Cancel:dN,isAxiosError:fN,spread:hN,toFormData:pN,AxiosHeaders:mN,HttpStatusCode:gN,formToJSON:xN,getAdapter:vN,mergeConfig:bN}=xt,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?bn(Vc):void 0;function bn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function qc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Gc(e){return Ni.add(e),()=>Ni.delete(e)}const Yc=3e4,Xc=9e4,Xt=xt.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Wo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return Lt(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return Lt(r)}}const On=new Ko,Fv=Ko,Bv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function zv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Hv(e){return await Jt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const eu=b.createContext(null);function tu({children:e,apiConfig:t}){const n=On;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(eu.Provider,{value:r,children:e})}async function nu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function ru(e=[]){const t=[],n=[];for(const r of e)try{const o=await nu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(eu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ou(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Uv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function su(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function iu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function au(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??iu(e);let l="",c=e.slice();if(s){const h=Wv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function lu(e){return e.replace(/\s+/g," ").trim()}function Wv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=lu(e),o=lu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Vv(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return Jr(e,r,s)}return e}function cu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Kv(e={}){const t=b.useMemo(()=>bn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[h,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),M=b.useRef(null),L=b.useRef(null),H=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),q=b.useCallback(R=>{o(R)},[]),N=b.useCallback(()=>{m(""),v(null),d(null),M.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),z=b.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=C.current)==null||R.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)},[]),$=b.useCallback((R,P,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),M.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""};const V=new AbortController;C.current=V;let J=null,_=null,O=!1;return j.current={threadId:R.threadId??null,headers:{}},(async()=>{var Y,ae,W,D,X,oe,G,Z,te,se,ue,ge,Re,Oe,Te,nt,ht,Tt;const K=Ke=>{var Ge;try{const Ve=JSON.parse(JSON.stringify(Ke));return(Ge=Ve==null?void 0:Ve.payload)!=null&&Ge.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map($e=>({...$e,data:$e!=null&&$e.data?`<base64 ${String($e.data).length} chars>`:$e==null?void 0:$e.data}))),Ve}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Le=window.__AUTH_TOKEN__,Bt=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let re=null;try{const rt=(ae=window.localStorage)==null?void 0:ae.getItem("chat-settings");rt&&(re=((W=JSON.parse(rt))==null?void 0:W.apiKey)||null)}catch{}const ye=Le||Bt||re||null;ye&&(Ke={Authorization:`Bearer ${ye}`})}}catch{}console.debug("[use-chat] POST",t+n,K(R));let Ge={};if(typeof window<"u")try{const Ae=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Ae&&(Ge={"X-Session-Id":Ae})}catch{}const Ve={...Ke,...Ge,...s.current},$e={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},He=await fetch(t+n,{method:"POST",headers:$e,body:JSON.stringify(R),signal:V.signal,credentials:i});if(j.current&&(j.current.headers=Ve),!He.ok||!He.body){const Ae=await He.text().catch(()=>"");console.debug("[use-chat] non-OK response",He.status,Ae==null?void 0:Ae.slice(0,500));const Le=`stream ${He.status}${Ae?": "+Ae:""}`;throw(X=I==null?void 0:I.onConnectionError)==null||X.call(I,Le),O=!0,J="error",_=Le,new Error(Le)}w(!0);const mt=He.body.getReader(),Dt=new TextDecoder;let lt="",kt=[];E.current=0,x(0);let wt=0,gt=null;const pt=()=>{if(kt.length){const Ae=kt.join("");kt=[],T.current&&m(Le=>Le+Ae)}gt=null},an=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(pt))};let dt=Date.now();const ke=setInterval(()=>{var Ae;if(Date.now()-dt>18e5){const Le="Stream idle timeout";d(Le),J="error",_=Le,V.abort(),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,Le)}},5e3),et=1024*1024;try{const Ae=He.headers.get("X-Thread-Id")||He.headers.get("x-thread-id"),Le=He.headers.get("X-Thread-Created")||He.headers.get("x-thread-created"),Bt=Ae??null,re=String(Le??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Bt}),(oe=I==null?void 0:I.onOpen)==null||oe.call(I,{threadId:Bt,created:re});;){const{value:ye,done:rt}=await mt.read();if(rt)break;lt+=Dt.decode(ye,{stream:!0}),lt.length>et&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=lt.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,Jl,pr,YI,pr),zt[pr+Jl]=!0}}return A===r?Nt(ze):Et(ze),ze}}function ct(A,Q,fe){return _e(A,Q,fe,!0)}function Je(A,Q,fe){return _e(A,Q,fe,!1)}var ft=Je,ln=ct;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=ln}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=mx();var u=gi.exports;const gx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:xx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Ro,toStringTag:lc}=Symbol,Mo=(e=>t=>{const n=xx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>Mo(t)===e),Oo=e=>t=>typeof t===e,{isArray:hr}=Array,mr=Oo("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=cn("ArrayBuffer");function vx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const bx=Oo("string"),Ht=Oo("function"),uc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",wx=e=>e===!0||e===!1,Do=e=>{if(Mo(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Ro in e)},yx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Sx=cn("Date"),Cx=cn("File"),Tx=cn("Blob"),kx=cn("FileList"),Ex=e=>Kr(e)&&Ht(e.pipe),Ix=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Nx=cn("URLSearchParams"),[Ax,jx,_x,Px]=["ReadableStream","Request","Response","Headers"].map(cn),Rx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function dc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Jn;function vi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):hr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Mx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),Ox=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Dx=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Lx=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},$x=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Fx=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Bx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),zx=(e,t)=>{const r=(e&&e[Ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Hx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ux=cn("HTMLFormElement"),Wx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),pc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vx=cn("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Kx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Gx=()=>{},Yx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Xx(e){return!!(e&&Ht(e.append)&&e[lc]==="FormData"&&e[Ro])}const Jx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Zx=cn("AsyncFunction"),Qx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Jn.postMessage)),ev=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||mc,U={isArray:hr,isArrayBuffer:cc,isBuffer:Vr,isFormData:Ix,isArrayBufferView:vx,isString:bx,isNumber:uc,isBoolean:wx,isObject:Kr,isPlainObject:Do,isEmptyObject:yx,isReadableStream:Ax,isRequest:jx,isResponse:_x,isHeaders:Px,isUndefined:mr,isDate:Sx,isFile:Cx,isBlob:Tx,isRegExp:Vx,isFunction:Ht,isStream:Ex,isURLSearchParams:Nx,isTypedArray:Bx,isFileList:kx,forEach:qr,merge:vi,extend:Mx,trim:Rx,stripBOM:Ox,inherits:Dx,toFlatObject:Lx,kindOf:Mo,kindOfTest:cn,endsWith:$x,toArray:Fx,forEachEntry:zx,matchAll:Hx,isHTMLForm:Ux,hasOwnProperty:pc,hasOwnProp:pc,reduceDescriptors:hc,freezeMethods:Kx,toObjectSet:qx,toCamelCase:Wx,noop:Gx,toFiniteNumber:Yx,findKey:dc,global:Jn,isContextDefined:fc,isSpecCompliantForm:Xx,toJSONObject:Jx,isAsyncFn:Zx,isThenable:Qx,setImmediate:mc,asap:ev,isIterable:e=>e!=null&&Ht(e[Ro])};function Re(e,t,n,r,o){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),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}U.inherits(Re,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:U.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Re.prototype,xc={};["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=>{xc[e]={value:e}}),Object.defineProperties(Re,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);U.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Re.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const tv=null;function bi(e){return U.isPlainObject(e)||U.isArray(e)}function vc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function bc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function nv(e){return U.isArray(e)&&!e.some(bi)}const rv=U.toFlatObject(U,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!U.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=U.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!U.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&U.isSpecCompliantForm(t);if(!U.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(U.isDate(v))return v.toISOString();if(U.isBoolean(v))return v.toString();if(!l&&U.isBlob(v))throw new Re("Blob is not supported. Use a Buffer instead.");return U.isArrayBuffer(v)||U.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(U.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(U.isArray(v)&&nv(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(U.isUndefined(S)||S===null)&&t.append(i===!0?bc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return bi(v)?!0:(t.append(bc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(rv,{defaultVisitor:d,convertValue:c,isVisitable:bi});function f(v,g){if(!U.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),U.forEach(v,function(y,w){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function wi(e,t){this._pairs=[],e&&Lo(e,this,t)}const yc=wi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ov(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||ov;U.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=U.isURLSearchParams(t)?t.toString():new wi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){U.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:wi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,iv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),av=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lv=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:iv,hasStandardBrowserWebWorkerEnv:av,navigator:Si,origin:lv},Symbol.toStringTag,{value:"Module"})),...sv};function cv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function uv(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dv(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function kc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&U.isArray(o)?o.length:i,l?(U.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!U.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&U.isArray(o[i])&&(o[i]=dv(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(uv(r),o,n,0)}),n}return null}function fv(e,t,n){if(U.isString(e))try{return(t||JSON.parse)(e),U.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=U.isObject(t);if(s&&U.isHTMLForm(t)&&(t=new FormData(t)),U.isFormData(t))return o?JSON.stringify(kc(t)):t;if(U.isArrayBuffer(t)||U.isBuffer(t)||U.isStream(t)||U.isFile(t)||U.isBlob(t)||U.isReadableStream(t))return t;if(U.isArrayBufferView(t))return t.buffer;if(U.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cv(t,this.formSerializer).toString();if((a=U.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),fv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(U.isResponse(t)||U.isReadableStream(t))return t;if(t&&U.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Re.from(a,Re.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};U.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const pv=U.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"]),hv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&pv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:U.isArray(e)?e.map($o):String(e)}function mv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const gv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ci(e,t,n,r,o){if(U.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!U.isString(t)){if(U.isString(r))return t.indexOf(r)!==-1;if(U.isRegExp(r))return r.test(t)}}function xv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function vv(e,t){const n=U.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Yr(l);if(!d)throw new Error("header name must be a non-empty string");const p=U.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=$o(a))}const i=(a,l)=>U.forEach(a,(c,d)=>s(c,d,l));if(U.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(U.isString(t)&&(t=t.trim())&&!gv(t))i(hv(t),n);else if(U.isObject(t)&&U.isIterable(t)){let a={},l,c;for(const d of t){if(!U.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?U.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Yr(t),t){const r=U.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return mv(o);if(U.isFunction(n))return n.call(this,o,r);if(U.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Yr(t),t){const r=U.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ci(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Yr(i),i){const a=U.findKey(r,i);a&&(!n||Ci(r,r[a],a,n))&&(delete r[a],o=!0)}}return U.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Ci(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return U.forEach(this,(o,s)=>{const i=U.findKey(r,s);if(i){n[i]=$o(o),delete n[s];return}const a=t?xv(s):String(s).trim();a!==s&&delete n[s],n[a]=$o(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return U.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&U.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(vv(o,i),r[a]=!0)}return U.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),U.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),U.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return U.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(gr,Re,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function bv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function wv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function yv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=wv(50,250);return yv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>U.asap(()=>e(...t)),Sv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Cv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];U.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),U.isString(r)&&i.push("path="+r),U.isString(o)&&i.push("domain="+o),s===!0&&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(){return null},remove(){}};function Tv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function kv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function _c(e,t,n){let r=!Tv(t);return e&&(r||n==!1)?kv(e,t):t}const Pc=e=>e instanceof Ut?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,p,m){return U.isPlainObject(c)&&U.isPlainObject(d)?U.merge.call({caseless:m},c,d):U.isPlainObject(d)?U.merge({},d):U.isArray(d)?d.slice():d}function o(c,d,p,m){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!U.isUndefined(d))return r(void 0,d)}function i(c,d){if(U.isUndefined(d)){if(!U.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,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:a,headers:(c,d,p)=>o(Pc(c),Pc(d),p,!0)};return U.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);U.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Rc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=Sc(_c(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),U.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(U.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(_t.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&Sv(t.url))){const l=o&&s&&Cv.read(s);l&&i.set(o,l)}return t},Ev=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Rc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Ut.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Re("Request aborted",Re.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Re(C,Re.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Re(k,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&U.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),U.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Fo(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=bv(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Re("Unsupported protocol "+w+":",Re.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Iv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Re?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>U.asap(a),l}},Nv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Av=async function*(e,t){for await(const n of jv(e))yield*Nv(n,t)},jv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Mc=(e,t,n,r)=>{const o=Av(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:Bo}=U,_v=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Dc,TextEncoder:Lc}=U.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pv=e=>{e=U.merge.call({skipUndefined:!0},_v,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(_t.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>U.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Re(`Response type '${v}' is not supported`,Re.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(U.isBlob(v))return v.size;if(U.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(U.isArrayBufferView(v)||U.isArrayBuffer(v))return v.byteLength;if(U.isURLSearchParams(v)&&(v=v+""),U.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=U.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:R="same-origin",fetchOptions:L}=Rc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let B=Iv([w,S&&S.toAbortSignal()],k),q=null;const N=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let z;try{if(T&&c&&x!=="get"&&x!=="head"&&(z=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(U.isFormData(y)&&(_=J.headers.get("content-type"))&&j.setContentType(_),J.body){const[O,K]=Ac(z,Fo(jc(T)));y=Mc(J.body,Oc,O,K)}}U.isString(R)||(R=R?"include":"omit");const $=s&&"credentials"in n.prototype,M={...L,signal:B,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:$?R:void 0};q=s&&new n(g,M);let P=await(s?H(q,L):H(g,M));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&N)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=P[Y]});const _=U.toFiniteNumber(P.headers.get("content-length")),[O,K]=C&&Ac(_,Fo(jc(C),!0))||[];P=new r(Mc(P.body,Oc,O,()=>{K&&K(),N&&N()}),J)}E=E||"text";let V=await p[U.findKey(p,E)||"text"](P,v);return!I&&N&&N(),await new Promise((J,_)=>{Nc(J,_,{data:V,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:q})})}catch($){throw N&&N(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,v,q),{cause:$.cause||$}):Re.from($,$&&$.code,v,q)}}},Rv=new Map,Fc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Rv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Pv(t)),d=c;return c};Fc();const ki={http:tv,xhr:Ev,fetch:{get:Fc}};U.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Mv=e=>U.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=U.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Mv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(U.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
+
`+i.map(Bc).join(`
|
|
34
|
+
`):" "+Bc(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ki};function Ei(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Hc(e){return Ei(e),e.headers=Ut.from(e.headers),e.data=Ti.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Gr.adapter,e)(e).then(function(r){return Ei(e),r.data=Ti.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Ic(r)||(Ei(e),r&&r.response&&(r.response.data=Ti.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",zo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{zo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};zo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},zo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Ov(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const Ho={assertOptions:Ov,validators:zo},vn=Ho.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&U.merge(s.common,s[n.method]);s&&U.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Zn(this.defaults,t);const n=_c(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),U.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Dv=class tx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new tx(function(o){t=o}),cancel:t}}};function Lv(e){return function(n){return e.apply(null,n)}}function $v(e){return U.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Vc(e){const t=new Qn(e),n=ac(Qn.prototype.request,t);return U.extend(n,Qn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Zn(e,o))},n}const xt=Vc(Gr);xt.Axios=Qn,xt.CanceledError=gr,xt.CancelToken=Dv,xt.isCancel=Ic,xt.VERSION=Uc,xt.toFormData=Lo,xt.AxiosError=Re,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Lv,xt.isAxiosError=$v,xt.mergeConfig=Zn,xt.AxiosHeaders=Ut,xt.formToJSON=e=>kc(U.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=zc.getAdapter,xt.HttpStatusCode=Ii,xt.default=xt;const{Axios:sN,AxiosError:iN,CanceledError:aN,isCancel:lN,CancelToken:cN,VERSION:uN,all:dN,Cancel:fN,isAxiosError:pN,spread:hN,toFormData:mN,AxiosHeaders:gN,HttpStatusCode:xN,formToJSON:vN,getAdapter:bN,mergeConfig:wN}=xt,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?bn(Kc):void 0;function bn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function Gc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Yc(e){return Ni.add(e),()=>Ni.delete(e)}const Xc=3e4,Jc=9e4,Xt=xt.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Wo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await Jt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return Lt(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Jt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Lt(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return Lt(r)}}const On=new Ko,Fv=Ko,Bv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function zv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Hv(e){return await Jt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=On;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(tu.Provider,{value:r,children:e})}async function ru(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Uv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function iu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function au(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function lu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??au(e);let l="",c=e.slice();if(s){const p=Wv(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function cu(e){return e.replace(/\s+/g," ").trim()}function Wv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=cu(e),o=cu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function Vv(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return Jr(e,r,s)}return e}function uu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Kv(e={}){const t=b.useMemo(()=>bn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[p,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),R=b.useRef(null),L=b.useRef(null),H=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),q=b.useCallback(M=>{o(M)},[]),N=b.useCallback(()=>{m(""),v(null),d(null),R.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),z=b.useCallback(()=>{var M;console.debug("[use-chat] stop() invoked - aborting stream"),(M=C.current)==null||M.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)},[]),$=b.useCallback((M,P,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,L.current=null,H.current=null,k(null),B.current={messageId:null,lastSeq:null,lastText:""};const V=new AbortController;C.current=V;let J=null,_=null,O=!1;return j.current={threadId:M.threadId??null,headers:{}},(async()=>{var Y,ae,W,D,X,oe,G,Z,te,se,ue,ge,Me,Oe,Te,nt,pt,Tt;const K=Ke=>{var Ge;try{const Ve=JSON.parse(JSON.stringify(Ke));return(Ge=Ve==null?void 0:Ve.payload)!=null&&Ge.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map($e=>({...$e,data:$e!=null&&$e.data?`<base64 ${String($e.data).length} chars>`:$e==null?void 0:$e.data}))),Ve}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Le=window.__AUTH_TOKEN__,Bt=((Y=window.localStorage)==null?void 0:Y.getItem("authToken"))||null;let re=null;try{const rt=(ae=window.localStorage)==null?void 0:ae.getItem("chat-settings");rt&&(re=((W=JSON.parse(rt))==null?void 0:W.apiKey)||null)}catch{}const ye=Le||Bt||re||null;ye&&(Ke={Authorization:`Bearer ${ye}`})}}catch{}console.debug("[use-chat] POST",t+n,K(M));let Ge={};if(typeof window<"u")try{const Ae=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Ae&&(Ge={"X-Session-Id":Ae})}catch{}const Ve={...Ke,...Ge,...s.current},$e={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},He=await fetch(t+n,{method:"POST",headers:$e,body:JSON.stringify(M),signal:V.signal,credentials:i});if(j.current&&(j.current.headers=Ve),!He.ok||!He.body){const Ae=await He.text().catch(()=>"");console.debug("[use-chat] non-OK response",He.status,Ae==null?void 0:Ae.slice(0,500));const Le=`stream ${He.status}${Ae?": "+Ae:""}`;throw(X=I==null?void 0:I.onConnectionError)==null||X.call(I,Le),O=!0,J="error",_=Le,new Error(Le)}w(!0);const mt=He.body.getReader(),Dt=new TextDecoder;let lt="",kt=[];E.current=0,x(0);let wt=0,gt=null;const ht=()=>{if(kt.length){const Ae=kt.join("");kt=[],T.current&&m(Le=>Le+Ae)}gt=null},an=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(ht))};let dt=Date.now();const ke=setInterval(()=>{var Ae;if(Date.now()-dt>18e5){const Le="Stream idle timeout";d(Le),J="error",_=Le,V.abort(),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,Le)}},5e3),et=1024*1024;try{const Ae=He.headers.get("X-Thread-Id")||He.headers.get("x-thread-id"),Le=He.headers.get("X-Thread-Created")||He.headers.get("x-thread-created"),Bt=Ae??null,re=String(Le??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Bt}),(oe=I==null?void 0:I.onOpen)==null||oe.call(I,{threadId:Bt,created:re});;){const{value:ye,done:rt}=await mt.read();if(rt)break;lt+=Dt.decode(ye,{stream:!0}),lt.length>et&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=lt.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const Pe=lt.slice(0,xe);lt=lt.slice(xe+2);const Xe=Pe.split(/\r?\n/),St=[];for(const Je of Xe)if(!(!Je||Je.startsWith(":"))&&Je.startsWith("data:")){const ft=Je.slice(5);St.push(ft.startsWith(" ")?ft.slice(1):ft)}const Et=St.join(`
|
|
38
|
-
`);if(!Et)continue;let Nt;try{Nt=JSON.parse(Et)}catch{console.debug("[use-chat] malformed SSE:",Et.slice(0,200));continue}const zt=ou(Nt)?Nt.data:Nt;if(!zt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const _e=zt;dt=Date.now();const ct=_e.seq;if(ct!==void 0){if(ct<=wt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:wt,type:_e.type});continue}wt>0&&ct>wt+1&&((G=I==null?void 0:I.onGap)==null||G.call(I,{from:wt,to:ct})),wt=ct,E.current=ct,x(ct)}if(_e.type==="message.start"&&_e.role==="assistant"){const Je=cu(_e.model);B.current={messageId:_e.id,lastSeq:ct??null,lastText:""},k({id:_e.id,role:"assistant",name:Je??void 0,model:_e.model,createdAt:new Date().toISOString(),content:[]})}if(_e.type==="checkpoint")M.current=_e.checkpointId??null,L.current=_e.checkpointNs??null,v(_e.checkpointId??null);else if(_e.type==="state_history"){H.current=_e;try{const ft=Rn(_e).latest;ft&&(M.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{P==null||P(_e)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",_e.type)}if(_e.type==="message.delta"){k(ft=>{const ln=B.current;if(!ft||ln.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:fe}=au(ft.content??[],_e.delta,{lastSeq:ln.lastSeq,lastText:ln.lastText},ct??null);return fe?(B.current={...ln,lastSeq:Q.lastSeq??ln.lastSeq,lastText:Q.lastText??ln.lastText},{...ft,content:A}):ft});const Je=_e.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Je&&e.autoAppendAssistant!==!1&&(kt.push(Je),an())}else if(_e.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Z=I==null?void 0:I.onHeartbeat)==null||Z.call(I,_e)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(gt!==null&&cancelAnimationFrame(gt),pt(),_e.type==="checkpoint")v(_e.checkpointId);else if(_e.type==="error"){const Je=_e;if(d(Je.message),J="error",_=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((te=Je.message)==null?void 0:te.includes("token"))||((se=Je.message)==null?void 0:se.includes("401"))||((ue=Je.message)==null?void 0:ue.includes("unauthorized"))||((ge=Je.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Re=I==null?void 0:I.onAuthError)==null||Re.call(I,Je.message)}catch(ln){console.warn("[use-chat] onAuthError handler failed",ln)}V.abort()}}}}pt(),J===null&&!V.signal.aborted&&(J="complete")}catch(Ae){if(Ae.name==="AbortError")J=J??"aborted";else{const Le=Ae.message||String(Ae);J="error",_=Le,d(Le),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,Le)}}finally{try{await mt.cancel()}catch{}finally{(Te=mt.releaseLock)==null||Te.call(mt)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(ke)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ge=Ke.message||String(Ke);J="error",_=Ge,d(Ge),(nt=I==null?void 0:I.onError)==null||nt.call(I,Ge),O||((ht=I==null?void 0:I.onConnectionError)==null||ht.call(I,Ge),O=!0)}}finally{const Ke=E.current,Ge=M.current,Ve=L.current,$e=H.current,He=J??(V.signal.aborted?"aborted":_?"error":"complete");try{(Tt=I==null?void 0:I.onClosed)==null||Tt.call(I,{reason:He,lastSeq:Ke,lastCheckpointId:Ge,lastCheckpointNs:Ve,lastStateHistory:$e,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var R;T.current=!1,(R=C.current)==null||R.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:z,clear:N,setToken:q}}const qv=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of qv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function Gv(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function uu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[h,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),M=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{M()},[M]),b.useEffect(()=>{r==null||r(a)},[a,r]);const L=b.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await j(),I.threadId}catch(I){const V=String(I);return n==null||n(V),null}},[e,n,j]),H=b.useCallback(async P=>{const I=s;i(J=>J.filter(_=>_.threadId!==P));const V=new AbortController;E.current.set(P,V);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(J){i(I);const _=String(J);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),B=b.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await j()}catch(V){n==null||n(String(V))}},[e,n,j]),q=b.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await M(),S("Shared successfully")}catch(V){const J=Gv(V);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,M]),N=b.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await M()}catch(V){const J=String(V);throw n==null||n(J),V}},[e,n,M]),z=b.useMemo(()=>({createThread:L,deleteThread:H,renameThread:B,refreshThreads:j,refreshSharedThreads:M,shareThread:q,unshareThread:N}),[L,H,B,j,M,q,N]),$=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(V=>{let J=!1;const _=V.map(O=>O.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return J?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...V])})},[]),R=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:z,addThreadFromEvent:$,shareInFlight:k,shareStatus:w,clearShareStatus:R}}const du=b.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(du.Provider,{value:w,children:e})}function xr(){const e=b.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Mi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Yv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Xv(e){const t=vr(e);return typeof e=="string"&&Yv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Mi(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Jv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ri(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Zv(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function Qv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function eb(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function tb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function nb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=eb(n),i=o?`data:${s};base64,${e}`:t,a=tb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function rb(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return nb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ob={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function sb(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Pi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Pi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function ib(e=[]){const[t,n]=b.useReducer(sb,{...ob,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return lb(e,t);if(t.type==="tool.progress")return cb(e,t);if(t.type==="tool.end")return ub(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:iu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Vv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Uv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Oi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Di(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Ri(r).toolCallId===t)return n}return-1}function ab(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function bu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function lb(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=xu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function cb(e,t){const n=Oi(t);if(!n)return e;const r=Di(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=bu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function ub(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=ab(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=bu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function wu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=b.useState(null),v=b.useMemo(()=>Rn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[M,L]=b.useState(!1),[H,B]=b.useState(null),q=b.useRef(o),N=b.useRef(null),z=b.useRef(null),$=b.useRef(null),R=b.useRef(null),P=b.useRef(null),I=b.useRef(new Map);b.useEffect(()=>{q.current=o},[o]);const V=b.useCallback(async G=>{var te,se;if(!G.threadId)return;const Z=G.threadId;(te=G.onStart)==null||te.call(G),G.setLoading(!0);try{await G.action(Z)}catch(ue){if(q.current===Z){const ge=String(ue);(se=G.handleError)==null||se.call(G,ge),r==null||r(ge)}throw ue}finally{G.setLoading(!1)}},[r]),J=b.useCallback(async(G,Z)=>{if(!G)return;const te=`${G}:${Z??"latest"}`,se=I.current.get(te);if(se)return se;const ue=V({threadId:G,setLoading:T,onStart:()=>B(null),handleError:ge=>B(ge),action:async ge=>{const Re=await e.getStateHistory({threadId:ge,checkpointId:Z??void 0});if(q.current!==ge){console.log(`[useThreadHistoryState] Thread changed during load (was ${ge}, now ${q.current}), discarding stale data`);return}const{checkpoints:Oe}=Rn(Re),Te=Oe.find(nt=>nt.messages&&nt.messages.length>0)??(Z?Oe.find(nt=>nt.checkpointId===Z):null)??Oe[0];t((Te==null?void 0:Te.messages)??[],{checkpointId:(Te==null?void 0:Te.checkpointId)??null,checkpointNs:(Te==null?void 0:Te.checkpointNs)??null}),m(Re),w(!!(Te!=null&&Te.nextCursor)),k((Te==null?void 0:Te.nextCursor)??null)}});I.current.set(te,ue);try{await ue}finally{I.current.delete(te)}return q.current===G&&(P.current=te),ue},[e,t,V]),_=b.useCallback(async(G,Z)=>{R.current=G;try{await J(G,Z)}finally{R.current===G&&(R.current=null)}},[J]),O=b.useCallback(G=>{z.current=G},[]),K=b.useCallback(G=>{$.current=G},[]),Y=b.useCallback(G=>{const Z=G.threadId??q.current;if(!Z||q.current&&q.current!==Z)return;const{checkpoints:te}=Rn(G);if(!te.length)return;const se=te.find(ge=>ge.messages&&ge.messages.length>0)??te.find(ge=>!!ge.checkpointId)??te[0],ue=$.current===Z;!c&&!ue&&t((se==null?void 0:se.messages)??[],{checkpointId:(se==null?void 0:se.checkpointId)??null,checkpointNs:(se==null?void 0:se.checkpointNs)??null}),m(G),w(!!(se!=null&&se.nextCursor)),k((se==null?void 0:se.nextCursor)??null),P.current=`${Z}:latest`,z.current=null,$.current===Z&&($.current=null)},[t,c]),ae=b.useCallback(async(G,Z)=>{const te=q.current;await V({threadId:te,setLoading:L,action:async se=>{const ue=await e.getStateHistory({threadId:se,checkpointId:G,checkpointNs:Z??void 0});if(q.current!==se){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${se}, now ${q.current}), discarding stale data`);return}const{checkpoints:ge}=Rn(ue),Re=ge.find(Oe=>Oe.checkpointId===G&&(Z?Oe.checkpointNs===Z:!0));if(!Re){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:G,checkpointNs:Z});return}m(ue),t(Re.messages??[],{checkpointId:Re.checkpointId??null,checkpointNs:Re.checkpointNs??null})}}).catch(()=>{})},[e,t,V]),W=b.useCallback((G,Z)=>{t(d(),{checkpointId:G??null,checkpointNs:Z??null})},[d,t]),D=b.useCallback(async()=>{q.current&&await _(q.current)},[_]),X=b.useCallback(async()=>{const G=q.current;!G||!S||await V({threadId:G,setLoading:j,action:async Z=>{const te=await e.getStateHistory({threadId:Z,checkpointId:S});if(q.current!==Z)return;const{checkpoints:se}=Rn(te);if(se.length>0){const ue=se[se.length-1];n((ue==null?void 0:ue.messages)??[]),w(!!(ue!=null&&ue.nextCursor)),k((ue==null?void 0:ue.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,V]);b.useEffect(()=>{if(!l||!o||C||c)return;if(z.current===o){z.current=null,N.current=o;return}if($.current===o){N.current=o;return}if(R.current===o){R.current=null,N.current=o;return}if(N.current===o)return;N.current=o;let G;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const Z=`${o}:latest`;P.current!==Z&&_(o,G)},[l,o,i,a,s,C,c,_]);const oe=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),L(!1),B(null),z.current=null,$.current=null,N.current=null,P.current=null,R.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:M,threadStateError:H,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:ae,loadOlderMessages:X,setCurrentCheckpointId:W,returnToLatest:D,handleStateHistoryEvent:Y,markSkipNextLoad:O,markStreamPendingThread:K,resetHistoryState:oe}}const yu=b.createContext(null),Su=b.createContext(null);function eo(){const e=b.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=b.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=ib(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:M,returnToLatest:L,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N}=wu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[z,$]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[R,P]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),N())},[l,d,N]);const I=b.useCallback(K=>$(()=>K),[]),V=b.useCallback(K=>P(()=>K),[]),J=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:z,navigateToCheckpoint:E,setCurrentCheckpointId:M,returnToLatest:L,loadThread:T,clearThread:z,respondToInterrupt:R,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,j,z,E,M,L,T,R,x.messagePreviews,H,B,q,N,m,f]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:V}),[I,V]);return u.jsx(Su.Provider,{value:O,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Mn(r,t)??null}function db(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function fb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function hb(e,t){const n=[...e].sort(fb);for(const r of n){if(r.messageId!==t)continue;const o=db(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Eu=b.createContext(null),Iu=b.createContext(!1);function pb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=b.useMemo(()=>bn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Kv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(mb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function mb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Cu(),M=b.useCallback(R=>{v(R),f.current!==R.threadId&&((R.created??!f.current)&&w(R.threadId),S(R.threadId),m(R.threadId))},[v,w,S,m,f]),L=b.useCallback(R=>{R.type==="thread_info"?M(R):R.type==="state_history"?y(R):R.type==="tool.end"?i==null||i(R):T(R)},[M,y,T,i]),H=b.useCallback(R=>{a(R,L,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,L,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const q=b.useCallback(async(R,P,I)=>{const V=f.current;if(!V)throw new Error("No active thread to handle interrupt");const J=P?I??!0:!1,_=B.current,O={threadId:V,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:J}};H(O)},[f,H]);b.useEffect(()=>{j(q)},[q,j]);const N=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(R){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",R)}},[t,k,m,l]);b.useEffect(()=>{E(N)},[N,E]);const z=b.useCallback(async(R,P)=>{let I=f.current;const V=(R==null?void 0:R.text)??"",J=(R==null?void 0:R.attachments)??[],_=(V==null?void 0:V.trim())??"",O={...(R==null?void 0:R.payload)??{}},K=Array.isArray(O.messages)?O.messages:void 0;K&&delete O.messages;const Y=!!(K&&K.length);if(!I&&!_&&J.length===0&&!Y)return;if(!I){const Oe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Te=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Oe}${Te}`,w(I),m(I)}const{contentParts:ae,filesInfo:W}=await ru(J),D=[...ae];_&&D.push({type:"text",text:V});const X=P==null?void 0:P.originalMessageId,oe=!!(P!=null&&P.edit&&X),G=!Y&&D.length>0;let Z=null;G&&(Z={id:oe?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},oe?C(Z,X):C(Z));const te=Y?K:Z?[Z]:[],se={...O,...W.length?{files_info:W}:{}};te.length?se.messages=te:"messages"in se||(se.messages=[]);let ue=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(oe&&X){const Oe=hb(x,X);ue=Oe.checkpointId,ge=Oe.checkpointNs??void 0}const Re={threadId:I,payload:se,checkpointId:ue,checkpointNs:ge,edit:!!(P!=null&&P.edit)};H(Re)},[g,f,w,C,H,x]),$=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:z,send:z,stop:l,setAuthToken:h}),[c,d,z,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=b.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function gb(){return b.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function xb(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Au(e){const t=b.useRef(e),n=b.useRef(e);return xb(t.current,e)||(t.current=e,n.current=e),n.current}function br({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(tu,{apiConfig:h,children:u.jsx(pb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function vb(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function ju(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=vb(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=On.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,On.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&On.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function bb(){const e=Ru(),t=Ou(),n=On.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(On.baseUrl,r,e.apiBaseUrl)}}function wb(e){On.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function ne(...e){return rx.twMerge(nx.clsx(e))}const yb=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:ne(yb({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Lu(e[o],null)}}}}function Fe(...e){return p.useCallback(Dn(...e),e)}function Sb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Cb(o,...t)]}function Cb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Tb=p[" useInsertionEffect ".trim().toString()]||It;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=kb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=Eb(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function kb({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Tb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Eb(e){return typeof e=="function"}var Ib=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Ib.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Fe(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Fe(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Nb=p.createContext(void 0);function Xo(e){const t=p.useContext(Nb);return e||t||"ltr"}function vt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ab(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var jb="DismissableLayer",Bi="dismissableLayer.update",_b="dismissableLayer.pointerDownOutside",Pb="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Fe(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Rb(E=>{const j=E.target,M=[...c.branches].some(L=>L.contains(j));!k||M||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Ob(E=>{const j=E.target;[...c.branches].some(L=>L.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Ab(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=jb;var Mb="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=Fe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Bu.displayName=Mb;function Rb(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(_b,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ob(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(Pb,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Db=yr,Lb=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},$b="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=vt(o),d=vt(s),h=p.useRef(null),m=Fe(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:$n(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||$n(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&$n(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||(Fb(Wb(Vu(a)),{select:!0}),document.activeElement===g&&$n(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||$n(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Bb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&$n(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&$n(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=$b;function Fb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($n(r,{select:t}),document.activeElement!==n)return}function Bb(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ku(e,t){for(const n of e)if(!zb(n,{upTo:t}))return n}function zb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Hb(e){return e instanceof HTMLInputElement&&"select"in e}function $n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Hb(e)&&t&&e.select()}}var qu=Ub();function Ub(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Wb(e){return e.filter(t=>t.tagName!=="A")}var Vb=p[" useId ".trim().toString()]||(()=>{}),Kb=0;function Pt(e){const[t,n]=p.useState(Vb());return It(()=>{n(r=>r??String(Kb++))},[e]),t?`radix-${t}`:""}const qb=["top","right","bottom","left"],Fn=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),Gb={left:"right",right:"left",bottom:"top",top:"bottom"},Yb={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,Fn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Xb=new Set(["top","bottom"]);function yn(e){return Xb.has(jn(e))?"y":"x"}function Gi(e){return Ki(yn(e))}function Jb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Zb(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Yb[t])}const Yu=["left","right"],Xu=["right","left"],Qb=["top","bottom"],ew=["bottom","top"];function tw(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Qb:ew;default:return[]}}function nw(e,t,n,r){const o=Sr(e);let s=tw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>Gb[t])}function rw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?rw(e):{top:e,right:e,bottom:e,left:e}}function ts(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Zu(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Gi(t),a=qi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ow=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const sw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,M=E/2-g[v]/2-1,L=Fn(h[y],M),H=Fn(h[w],M),B=L,q=E-g[v]-H,N=E/2-g[v]/2+j,z=Vi(B,N,q),$=!l.arrow&&Sr(o)!=null&&N!==z&&s.reference[v]/2-(N<B?L:H)-g[v]/2<0,R=$?N<B?N-B:N-q:0;return{[f]:m[f]+R,data:{[f]:z,centerOffset:N-z-R,...$&&{alignmentOffset:R}},reset:$}}}),iw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Zb(a)),T=v!=="none";!m&&T&&C.push(...nw(a,g,v,k));const E=[a,...C],j=await no(t,x),M=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(j[y]),h){const N=Jb(o,i,k);M.push(j[N[0]],j[N[1]])}if(L=[...L,{placement:o,overflows:M}],!M.every(N=>N<=0)){var H,B;const N=(((H=s.flip)==null?void 0:H.index)||0)+1,z=E[N];if(z&&(!(h==="alignment"?w!==yn(z):!1)||L.every(P=>yn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:N,overflows:L},reset:{placement:z}};let $=(B=L.filter(R=>R.overflows[0]<=0).sort((R,P)=>R.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!$)switch(f){case"bestFit":{var q;const R=(q=L.filter(P=>{if(T){const I=yn(P.placement);return I===w||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,V)=>I+V,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:q[0];R&&($=R);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return qb.some(t=>e[t]>=0)}const aw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function lw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Sr(n),l=yn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const cw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await lw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},uw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await no(t,l),h=yn(jn(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Vi(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Vi(w,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},dw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},h=yn(o),m=Ki(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=td.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},fw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await no(t,c),h=jn(o),m=Sr(o),f=yn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=Fn(g-d[x],w),C=Fn(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const L=Zt(d.left,0),H=Zt(d.right,0),B=Zt(d.top,0),q=Zt(d.bottom,0);f?j=v-2*(L!==0||H!==0?L+H:Zt(d.left,d.right)):E=g-2*(B!==0||q!==0?B+q:Zt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const M=await i.getDimensions(a.floating);return v!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Cr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Sn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function dn(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Cn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const hw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!hw.has(o)}const pw=new Set(["table","td","th"]);function mw(e){return pw.has(Cr(e))}const gw=[":popover-open",":modal"];function rs(e){return gw.some(t=>{try{return e.matches(t)}catch{return!1}})}const xw=["transform","translate","scale","rotate","perspective"],vw=["transform","translate","scale","rotate","perspective","filter"],bw=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=dn(e)?fn(e):e;return xw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||vw.some(r=>(n.willChange||"").includes(r))||bw.some(r=>(n.contain||"").includes(r))}function ww(e){let t=Bn(e);for(;Cn(t)&&!Tr(t);){if(Xi(t))return t;if(rs(t))return null;t=Bn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yw=new Set(["html","body","#document"]);function Tr(e){return yw.has(Cr(e))}function fn(e){return Qt(e).getComputedStyle(e)}function os(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Bn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||Sn(e);return rd(t)?t.host:t}function od(e){const t=Bn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Cn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Cn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return dn(e)?e:e.contextElement}function kr(e){const t=Qi(e);if(!Cn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Sw=wn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?Sw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=wn(1);t&&(r?dn(r)&&(i=kr(r)):i=kr(e));const a=Cw(s,n,r)?id(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&dn(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=fn(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:er(Sn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Tw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Sn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),h=Cn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=os(r)),Cn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):wn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function kw(e){return Array.from(e.getClientRects())}function Ew(e){const t=Sn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Iw(e,t){const n=Qt(e),r=Sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Nw=new Set(["absolute","fixed"]);function Aw(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Cn(e)?kr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function cd(e,t,n){let r;if(t==="viewport")r=Iw(e,n);else if(t==="document")r=Ew(Sn(e));else if(dn(t))r=Aw(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Bn(e);return n===t||!dn(n)||Tr(n)?!1:fn(n).position==="fixed"||ud(n,t)}function jw(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>dn(a)&&Cr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Bn(e):e;for(;dn(i)&&!Tr(i);){const a=fn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Nw.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Bn(i)}return t.set(e,r),r}function _w(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:jw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=Fn(h.right,c.right),c.bottom=Fn(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Pw(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Mw(e,t,n){const r=Cn(t),o=Sn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):wn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return fn(e).position==="static"}function dd(e,t){if(!Cn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Sn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Cn(e)){let o=Bn(e);for(;o&&!Tr(o);){if(dn(o)&&!ea(o))return o;o=Bn(o)}return n}let r=dd(e,t);for(;r&&mw(r)&&ea(r);)r=dd(r,t);return r&&Tr(r)&&ea(r)&&!Xi(r)?n:r||ww(e)||n}const Rw=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Mw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ow(e){return fn(e).direction==="rtl"}const Dw={convertOffsetParentRelativeRectToViewportRelativeRect:Tw,getDocumentElement:Sn,getClippingRect:_w,getOffsetParent:fd,getElementRects:Rw,getClientRects:kw,getDimensions:Pw,getScale:kr,isElement:dn,isRTL:Ow};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Lw(e,t){let n=null,r;const o=Sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Fn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function $w(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Lw(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!hd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Fw=cw,Bw=uw,zw=iw,Hw=fw,Uw=aw,pd=sw,Ww=dw,Vw=(e,t,n)=>{const r=new Map,o={platform:Dw,...n},s={...o.platform,_c:r};return ow(e,t,{...o,platform:s})};var Kw=typeof document<"u",qw=function(){},is=Kw?b.useLayoutEffect:qw;function as(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!as(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function Gw(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),M=l!=null,L=ta(l),H=ta(o),B=ta(c),q=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),Vw(T.current,E.current,P).then(I=>{const V={...I,isPositioned:B.current!==!1};N.current&&!as(j.current,V)&&(j.current=V,Hr.flushSync(()=>{h(V)}))})},[m,t,n,H,B]);is(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const N=p.useRef(!1);is(()=>(N.current=!0,()=>{N.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,q);q()}},[k,C,q,L,M]);const z=p.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),R=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),V=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+V+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:V}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:q,refs:z,elements:$,floatingStyles:R}),[d,q,z,$,R])}const Yw=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Xw=(e,t)=>({...Fw(e),options:[e,t]}),Jw=(e,t)=>({...Bw(e),options:[e,t]}),Zw=(e,t)=>({...Ww(e),options:[e,t]}),Qw=(e,t)=>({...zw(e),options:[e,t]}),ey=(e,t)=>({...Hw(e),options:[e,t]}),ty=(e,t)=>({...Uw(e),options:[e,t]}),ny=(e,t)=>({...Yw(e),options:[e,t]});var ry="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});xd.displayName=ry;var oy=xd;function vd(e){const[t,n]=p.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[bd,Er]=un(na),[sy,wd]=bd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(sy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(Sd,n),i=p.useRef(null),a=Fe(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[iy,ay]=bd(ra),Td=p.forwardRef((e,t)=>{var W,D,X,oe,G,Z;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=wd(ra,n),[y,w]=p.useState(null),S=Fe(t,te=>w(te)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,M=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],B=H.length>0,q={padding:L,boundary:H.filter(cy),altBoundary:B},{refs:N,floatingStyles:z,placement:$,isPositioned:R,middlewareData:P}=Gw({strategy:"fixed",placement:M,whileElementsMounted:(...te)=>$w(...te,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Xw({mainAxis:o+j,alignmentAxis:i}),l&&Jw({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Zw():void 0,...q}),l&&Qw({...q}),ey({...q,apply:({elements:te,rects:se,availableWidth:ue,availableHeight:ge})=>{const{width:Re,height:Oe}=se.reference,Te=te.floating.style;Te.setProperty("--radix-popper-available-width",`${ue}px`),Te.setProperty("--radix-popper-available-height",`${ge}px`),Te.setProperty("--radix-popper-anchor-width",`${Re}px`),Te.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),k&&ny({element:k,padding:a}),uy({arrowWidth:E,arrowHeight:j}),m&&ty({strategy:"referenceHidden",...q})]}),[I,V]=Id($),J=vt(v);It(()=>{R&&(J==null||J())},[R,J]);const _=(W=P.arrow)==null?void 0:W.x,O=(D=P.arrow)==null?void 0:D.y,K=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[Y,ae]=p.useState();return It(()=>{y&&ae(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:R?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(oe=P.transformOrigin)==null?void 0:oe.x,(G=P.transformOrigin)==null?void 0:G.y].join(" "),...((Z=P.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(iy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:O,shouldHideArrow:K,children:u.jsx(me.div,{"data-side":I,"data-align":V,...g,ref:S,style:{...g.style,animation:R?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ly={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=ay(kd,r),i=ly[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(oy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function cy(e){return e!==null}var uy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Id(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,dy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});so.displayName=dy;function fy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=hy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Fe(r.ref,py(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function hy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=fy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function py(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var la="rovingFocusGroup.onEntryFocus",my={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,gy]=Yo(io),[xy,Ad]=un(io,[gy]),[vy,by]=xy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));jd.displayName=io;var wy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=Fe(t,m),v=Xo(s),[g,x]=Ln({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=vt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(la,S),()=>j.removeEventListener(la,S)},[S]),u.jsx(vy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,j=>{const M=!C.current;if(j.target===j.currentTarget&&M&&!y){const L=new CustomEvent(la,my);if(j.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter($=>$.focusable),B=H.find($=>$.active),q=H.find($=>$.id===g),z=[B,q,...H].filter(Boolean).map($=>$.ref.current);Md(z,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=by(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Cy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Ty(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var yy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Sy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Cy(e,t,n){const r=Sy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return yy[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ty(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ky=jd,Ey=Pd,Iy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Ny=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ay=function(e,t,n,r){var o=Ny(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ua++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Ir=new WeakMap,Ir=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Iy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ay(r,o,n,"aria-hidden")):function(){return null}},Tn=function(){return Tn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Tn.apply(this,arguments)};function Od(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function jy(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ds="right-scroll-bar-position",fs="width-before-scroll-bar",_y="with-scroll-bars-hidden",Py="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function My(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ry=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Oy(e,t){var n=My(null,function(r){return e.forEach(function(o){return fa(o,r)})});return Ry(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Dy(e){return e}function Ly(e,t){t===void 0&&(t=Dy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function $y(e){e===void 0&&(e={});var t=Ly(null);return t.options=Tn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Tn({},n))};Ld.isSideCarExport=!0;function Fy(e,t){return e.useMedium(t),Ld}var $d=$y(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Oy([n,t]),E=Tn(Tn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Tn(Tn({},E),{ref:T})):p.createElement(w,Tn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var By=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=By();return t&&e.setAttribute("nonce",t),e}function Hy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Uy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Wy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zy())&&(Hy(t,n),Uy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Vy=function(){var e=Wy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Vy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ky={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},qy=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[pa(n),pa(r),pa(o)]},Gy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ky;var t=qy(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yy=Fd(),Nr="data-scroll-locked",Xy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
38
|
+
`);if(!Et)continue;let Nt;try{Nt=JSON.parse(Et)}catch{console.debug("[use-chat] malformed SSE:",Et.slice(0,200));continue}const zt=su(Nt)?Nt.data:Nt;if(!zt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const _e=zt;dt=Date.now();const ct=_e.seq;if(ct!==void 0){if(ct<=wt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ct,lastProcessedSeq:wt,type:_e.type});continue}wt>0&&ct>wt+1&&((G=I==null?void 0:I.onGap)==null||G.call(I,{from:wt,to:ct})),wt=ct,E.current=ct,x(ct)}if(_e.type==="message.start"&&_e.role==="assistant"){const Je=uu(_e.model);B.current={messageId:_e.id,lastSeq:ct??null,lastText:""},k({id:_e.id,role:"assistant",name:Je??void 0,model:_e.model,createdAt:new Date().toISOString(),content:[]})}if(_e.type==="checkpoint")R.current=_e.checkpointId??null,L.current=_e.checkpointNs??null,v(_e.checkpointId??null);else if(_e.type==="state_history"){H.current=_e;try{const ft=Mn(_e).latest;ft&&(R.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{P==null||P(_e)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",_e.type)}if(_e.type==="message.delta"){k(ft=>{const ln=B.current;if(!ft||ln.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:fe}=lu(ft.content??[],_e.delta,{lastSeq:ln.lastSeq,lastText:ln.lastText},ct??null);return fe?(B.current={...ln,lastSeq:Q.lastSeq??ln.lastSeq,lastText:Q.lastText??ln.lastText},{...ft,content:A}):ft});const Je=_e.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Je&&e.autoAppendAssistant!==!1&&(kt.push(Je),an())}else if(_e.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Z=I==null?void 0:I.onHeartbeat)==null||Z.call(I,_e)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(gt!==null&&cancelAnimationFrame(gt),ht(),_e.type==="checkpoint")v(_e.checkpointId);else if(_e.type==="error"){const Je=_e;if(d(Je.message),J="error",_=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((te=Je.message)==null?void 0:te.includes("token"))||((se=Je.message)==null?void 0:se.includes("401"))||((ue=Je.message)==null?void 0:ue.includes("unauthorized"))||((ge=Je.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Me=I==null?void 0:I.onAuthError)==null||Me.call(I,Je.message)}catch(ln){console.warn("[use-chat] onAuthError handler failed",ln)}V.abort()}}}}ht(),J===null&&!V.signal.aborted&&(J="complete")}catch(Ae){if(Ae.name==="AbortError")J=J??"aborted";else{const Le=Ae.message||String(Ae);J="error",_=Le,d(Le),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,Le)}}finally{try{await mt.cancel()}catch{}finally{(Te=mt.releaseLock)==null||Te.call(mt)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(ke)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const Ge=Ke.message||String(Ke);J="error",_=Ge,d(Ge),(nt=I==null?void 0:I.onError)==null||nt.call(I,Ge),O||((pt=I==null?void 0:I.onConnectionError)==null||pt.call(I,Ge),O=!0)}}finally{const Ke=E.current,Ge=R.current,Ve=L.current,$e=H.current,He=J??(V.signal.aborted?"aborted":_?"error":"complete");try{(Tt=I==null?void 0:I.onClosed)==null||Tt.call(I,{reason:He,lastSeq:Ke,lastCheckpointId:Ge,lastCheckpointNs:Ve,lastStateHistory:$e,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var M;T.current=!1,(M=C.current)==null||M.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:z,clear:N,setToken:q}}const qv=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of qv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function Gv(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function du({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[p,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),R=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{R()},[R]),b.useEffect(()=>{r==null||r(a)},[a,r]);const L=b.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await j(),I.threadId}catch(I){const V=String(I);return n==null||n(V),null}},[e,n,j]),H=b.useCallback(async P=>{const I=s;i(J=>J.filter(_=>_.threadId!==P));const V=new AbortController;E.current.set(P,V);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(J){i(I);const _=String(J);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),B=b.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await j()}catch(V){n==null||n(String(V))}},[e,n,j]),q=b.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await R(),S("Shared successfully")}catch(V){const J=Gv(V);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,R]),N=b.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await R()}catch(V){const J=String(V);throw n==null||n(J),V}},[e,n,R]),z=b.useMemo(()=>({createThread:L,deleteThread:H,renameThread:B,refreshThreads:j,refreshSharedThreads:R,shareThread:q,unshareThread:N}),[L,H,B,j,R,q,N]),$=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(V=>{let J=!1;const _=V.map(O=>O.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return J?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...V])})},[]),M=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:z,addThreadFromEvent:$,shareInFlight:k,shareStatus:w,clearShareStatus:M}}const fu=b.createContext(null);function pu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=du({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(fu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(fu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ri(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Yv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Xv(e){const t=vr(e);return typeof e=="string"&&Yv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ri(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Jv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Mi(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Zv(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function Qv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function mu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function eb(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function tb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function nb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=eb(n),i=o?`data:${s};base64,${e}`:t,a=tb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function rb(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return nb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function gu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ob={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function sb(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Pi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Pi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return xu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>xu(o,s),e):e}default:return e}}function ib(e=[]){const[t,n]=b.useReducer(sb,{...ob,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function xu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=uu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return lb(e,t);if(t.type==="tool.progress")return cb(e,t);if(t.type==="tool.end")return ub(e,t);if(t.type==="message.delta"){const s=e.assemblingId??iu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:au(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=lu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??iu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Vv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Mn(t),i=s.interrupt,a=s.latest,l=i===null?Uv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Oi(e){return e.call_id??e.id??null}function vu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function bu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Di(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Mi(r).toolCallId===t)return n}return-1}function ab(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function lb(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=vu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function cb(e,t){const n=Oi(t);if(!n)return e;const r=Di(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function ub(e,t){const n=Oi(t),r=vu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,bu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=ab(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=wu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function yu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=b.useState(null),v=b.useMemo(()=>Mn(p),[p]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[R,L]=b.useState(!1),[H,B]=b.useState(null),q=b.useRef(o),N=b.useRef(null),z=b.useRef(null),$=b.useRef(null),M=b.useRef(null),P=b.useRef(null),I=b.useRef(new Map);b.useEffect(()=>{q.current=o},[o]);const V=b.useCallback(async G=>{var te,se;if(!G.threadId)return;const Z=G.threadId;(te=G.onStart)==null||te.call(G),G.setLoading(!0);try{await G.action(Z)}catch(ue){if(q.current===Z){const ge=String(ue);(se=G.handleError)==null||se.call(G,ge),r==null||r(ge)}throw ue}finally{G.setLoading(!1)}},[r]),J=b.useCallback(async(G,Z)=>{if(!G)return;const te=`${G}:${Z??"latest"}`,se=I.current.get(te);if(se)return se;const ue=V({threadId:G,setLoading:T,onStart:()=>B(null),handleError:ge=>B(ge),action:async ge=>{const Me=await e.getStateHistory({threadId:ge,checkpointId:Z??void 0});if(q.current!==ge){console.log(`[useThreadHistoryState] Thread changed during load (was ${ge}, now ${q.current}), discarding stale data`);return}const{checkpoints:Oe}=Mn(Me),Te=Oe.find(nt=>nt.messages&&nt.messages.length>0)??(Z?Oe.find(nt=>nt.checkpointId===Z):null)??Oe[0];t((Te==null?void 0:Te.messages)??[],{checkpointId:(Te==null?void 0:Te.checkpointId)??null,checkpointNs:(Te==null?void 0:Te.checkpointNs)??null}),m(Me),w(!!(Te!=null&&Te.nextCursor)),k((Te==null?void 0:Te.nextCursor)??null)}});I.current.set(te,ue);try{await ue}finally{I.current.delete(te)}return q.current===G&&(P.current=te),ue},[e,t,V]),_=b.useCallback(async(G,Z)=>{M.current=G;try{await J(G,Z)}finally{M.current===G&&(M.current=null)}},[J]),O=b.useCallback(G=>{z.current=G},[]),K=b.useCallback(G=>{$.current=G},[]),Y=b.useCallback(G=>{const Z=G.threadId??q.current;if(!Z||q.current&&q.current!==Z)return;const{checkpoints:te}=Mn(G);if(!te.length)return;const se=te.find(ge=>ge.messages&&ge.messages.length>0)??te.find(ge=>!!ge.checkpointId)??te[0],ue=$.current===Z;!c&&!ue&&t((se==null?void 0:se.messages)??[],{checkpointId:(se==null?void 0:se.checkpointId)??null,checkpointNs:(se==null?void 0:se.checkpointNs)??null}),m(G),w(!!(se!=null&&se.nextCursor)),k((se==null?void 0:se.nextCursor)??null),P.current=`${Z}:latest`,z.current=null,$.current===Z&&($.current=null)},[t,c]),ae=b.useCallback(async(G,Z)=>{const te=q.current;await V({threadId:te,setLoading:L,action:async se=>{const ue=await e.getStateHistory({threadId:se,checkpointId:G,checkpointNs:Z??void 0});if(q.current!==se){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${se}, now ${q.current}), discarding stale data`);return}const{checkpoints:ge}=Mn(ue),Me=ge.find(Oe=>Oe.checkpointId===G&&(Z?Oe.checkpointNs===Z:!0));if(!Me){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:G,checkpointNs:Z});return}m(ue),t(Me.messages??[],{checkpointId:Me.checkpointId??null,checkpointNs:Me.checkpointNs??null})}}).catch(()=>{})},[e,t,V]),W=b.useCallback((G,Z)=>{t(d(),{checkpointId:G??null,checkpointNs:Z??null})},[d,t]),D=b.useCallback(async()=>{q.current&&await _(q.current)},[_]),X=b.useCallback(async()=>{const G=q.current;!G||!S||await V({threadId:G,setLoading:j,action:async Z=>{const te=await e.getStateHistory({threadId:Z,checkpointId:S});if(q.current!==Z)return;const{checkpoints:se}=Mn(te);if(se.length>0){const ue=se[se.length-1];n((ue==null?void 0:ue.messages)??[]),w(!!(ue!=null&&ue.nextCursor)),k((ue==null?void 0:ue.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,V]);b.useEffect(()=>{if(!l||!o||C||c)return;if(z.current===o){z.current=null,N.current=o;return}if($.current===o){N.current=o;return}if(M.current===o){M.current=null,N.current=o;return}if(N.current===o)return;N.current=o;let G;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const Z=`${o}:latest`;P.current!==Z&&_(o,G)},[l,o,i,a,s,C,c,_]);const oe=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),L(!1),B(null),z.current=null,$.current=null,N.current=null,P.current=null,M.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:H,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:ae,loadOlderMessages:X,setCurrentCheckpointId:W,returnToLatest:D,handleStateHistoryEvent:Y,markSkipNextLoad:O,markStreamPendingThread:K,resetHistoryState:oe}}const Su=b.createContext(null),Cu=b.createContext(null);function eo(){const e=b.useContext(Su);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Tu(){const e=b.useContext(Cu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ku({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:p,pushUser:m,onEvent:f}=ib(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N}=yu({api:a,seed:d,prepend:p,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[z,$]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[M,P]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),N())},[l,d,N]);const I=b.useCallback(K=>$(()=>K),[]),V=b.useCallback(K=>P(()=>K),[]),J=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:z,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:z,respondToInterrupt:M,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:B,markStreamPendingThread:q,resetHistoryState:N,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,j,z,E,R,L,T,M,x.messagePreviews,H,B,q,N,m,f]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:V}),[I,V]);return u.jsx(Cu.Provider,{value:O,children:u.jsx(Su.Provider,{value:_,children:e})})}function Eu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Rn(r,t)??null}function db(e){const t=Eu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Eu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function fb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function pb(e,t){const n=[...e].sort(fb);for(const r of n){if(r.messageId!==t)continue;const o=db(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Iu=b.createContext(null),Nu=b.createContext(!1);function hb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Xr(),m=b.useMemo(()=>bn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Kv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(pu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ku,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Nu.Provider,{value:!0,children:u.jsx(mb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function mb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Tu(),R=b.useCallback(M=>{v(M),f.current!==M.threadId&&((M.created??!f.current)&&w(M.threadId),S(M.threadId),m(M.threadId))},[v,w,S,m,f]),L=b.useCallback(M=>{M.type==="thread_info"?R(M):M.type==="state_history"?y(M):M.type==="tool.end"?i==null||i(M):T(M)},[R,y,T,i]),H=b.useCallback(M=>{a(M,L,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,L,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const q=b.useCallback(async(M,P,I)=>{const V=f.current;if(!V)throw new Error("No active thread to handle interrupt");const J=P?I??!0:!1,_=B.current,O={threadId:V,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:J}};H(O)},[f,H]);b.useEffect(()=>{j(q)},[q,j]);const N=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(M){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",M)}},[t,k,m,l]);b.useEffect(()=>{E(N)},[N,E]);const z=b.useCallback(async(M,P)=>{let I=f.current;const V=(M==null?void 0:M.text)??"",J=(M==null?void 0:M.attachments)??[],_=(V==null?void 0:V.trim())??"",O={...(M==null?void 0:M.payload)??{}},K=Array.isArray(O.messages)?O.messages:void 0;K&&delete O.messages;const Y=!!(K&&K.length);if(!I&&!_&&J.length===0&&!Y)return;if(!I){const Oe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Te=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Oe}${Te}`,w(I),m(I)}const{contentParts:ae,filesInfo:W}=await ou(J),D=[...ae];_&&D.push({type:"text",text:V});const X=P==null?void 0:P.originalMessageId,oe=!!(P!=null&&P.edit&&X),G=!Y&&D.length>0;let Z=null;G&&(Z={id:oe?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},oe?C(Z,X):C(Z));const te=Y?K:Z?[Z]:[],se={...O,...W.length?{files_info:W}:{}};te.length?se.messages=te:"messages"in se||(se.messages=[]);let ue=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(oe&&X){const Oe=pb(x,X);ue=Oe.checkpointId,ge=Oe.checkpointNs??void 0}const Me={threadId:I,payload:se,checkpointId:ue,checkpointNs:ge,edit:!!(P!=null&&P.edit)};H(Me)},[g,f,w,C,H,x]),$=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:z,send:z,stop:l,setAuthToken:p}),[c,d,z,l,p]);return u.jsx(Iu.Provider,{value:$,children:e})}function Li(){const e=b.useContext(Iu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function gb(){return b.useContext(Nu)}function Au(e){return typeof e=="object"&&e!==null}function xb(e,t){if(Object.is(e,t))return!0;if(!Au(e)||!Au(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function ju(e){const t=b.useRef(e),n=b.useRef(e);return xb(t.current,e)||(t.current=e,n.current=e),n.current}function br({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=ju(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(nu,{apiConfig:p,children:u.jsx(hb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function vb(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function _u(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=vb(t);if(n)return n}}function Pu(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ru(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function Mu(){const e={},t=_u(),n=Pu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ou(){const e=Mu(),t=On.getAuthToken(),n=_u();return{apiBaseUrl:Ru(e.baseUrl,On.baseUrl,n),apiKey:t||e.apiKey||Pu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Du(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Lu(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&On.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function bb(){const e=Ou(),t=Du(),n=On.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ru(On.baseUrl,r,e.apiBaseUrl)}}function wb(e){On.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Lu(e)}function ne(...e){return rx.twMerge(nx.clsx(e))}const yb=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qe=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:ne(yb({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function $u(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=$u(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():$u(e[o],null)}}}}function Fe(...e){return h.useCallback(Dn(...e),e)}function Sb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function un(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Cb(o,...t)]}function Cb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Tb=h[" useInsertionEffect ".trim().toString()]||It;function Ln({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=kb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Eb(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function kb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Tb(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Eb(e){return typeof e=="function"}var Ib=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Ib.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Fe(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Yt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Fe(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Nb=h.createContext(void 0);function Xo(e){const t=h.useContext(Nb);return e||t||"ltr"}function vt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Ab(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var jb="DismissableLayer",Bi="dismissableLayer.update",_b="dismissableLayer.pointerDownOutside",Pb="dismissableLayer.focusOutside",Fu,Bu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Bu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=Fe(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Mb(E=>{const j=E.target,R=[...c.branches].some(L=>L.contains(j));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Ob(E=>{const j=E.target;[...c.branches].some(L=>L.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Ab(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Fu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Hu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Fu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Hu())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=jb;var Rb="DismissableLayerBranch",zu=h.forwardRef((e,t)=>{const n=h.useContext(Bu),r=h.useRef(null),o=Fe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});zu.displayName=Rb;function Mb(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Uu(_b,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ob(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Uu(Pb,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Hu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Uu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Db=yr,Lb=zu,zi=0;function Hi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wu()),document.body.insertAdjacentElement("beforeend",e[1]??Wu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Wu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Vu={bubbles:!1,cancelable:!0},$b="FocusScope",Jo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=vt(o),d=vt(s),p=h.useRef(null),m=Fe(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:$n(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||$n(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&$n(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){Gu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Vu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||(Fb(Wb(Ku(a)),{select:!0}),document.activeElement===g&&$n(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Vu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||$n(g??document.body,{select:!0}),a.removeEventListener(Wi,d),Gu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Bb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&$n(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&$n(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=$b;function Fb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($n(r,{select:t}),document.activeElement!==n)return}function Bb(e){const t=Ku(e),n=qu(t,e),r=qu(t.reverse(),e);return[n,r]}function Ku(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qu(e,t){for(const n of e)if(!zb(n,{upTo:t}))return n}function zb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Hb(e){return e instanceof HTMLInputElement&&"select"in e}function $n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Hb(e)&&t&&e.select()}}var Gu=Ub();function Ub(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Yu(e,t),e.unshift(t)},remove(t){var n;e=Yu(e,t),(n=e[0])==null||n.resume()}}}function Yu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Wb(e){return e.filter(t=>t.tagName!=="A")}var Vb=h[" useId ".trim().toString()]||(()=>{}),Kb=0;function Pt(e){const[t,n]=h.useState(Vb());return It(()=>{n(r=>r??String(Kb++))},[e]),t?`radix-${t}`:""}const qb=["top","right","bottom","left"],Fn=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),Gb={left:"right",right:"left",bottom:"top",top:"bottom"},Yb={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,Fn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Xb=new Set(["top","bottom"]);function yn(e){return Xb.has(jn(e))?"y":"x"}function Gi(e){return Ki(yn(e))}function Jb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Zb(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Yb[t])}const Xu=["left","right"],Ju=["right","left"],Qb=["top","bottom"],ew=["bottom","top"];function tw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ju:Xu:t?Xu:Ju;case"left":case"right":return t?Qb:ew;default:return[]}}function nw(e,t,n,r){const o=Sr(e);let s=tw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>Gb[t])}function rw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Zu(e){return typeof e!="number"?rw(e):{top:e,right:e,bottom:e,left:e}}function ts(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Qu(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Gi(t),a=qi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ow=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Qu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,p=S??p,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:p}=Qu(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Zu(f),x=a[m?p==="floating"?"reference":"floating":p],y=ts(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const sw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=Zu(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,R=E/2-g[v]/2-1,L=Fn(p[y],R),H=Fn(p[w],R),B=L,q=E-g[v]-H,N=E/2-g[v]/2+j,z=Vi(B,N,q),$=!l.arrow&&Sr(o)!=null&&N!==z&&s.reference[v]/2-(N<B?L:H)-g[v]/2<0,M=$?N<B?N-B:N-q:0;return{[f]:m[f]+M,data:{[f]:z,centerOffset:N-z-M,...$&&{alignmentOffset:M}},reset:$}}}),iw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Zb(a)),T=v!=="none";!m&&T&&C.push(...nw(a,g,v,k));const E=[a,...C],j=await no(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(j[y]),p){const N=Jb(o,i,k);R.push(j[N[0]],j[N[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(N=>N<=0)){var H,B;const N=(((H=s.flip)==null?void 0:H.index)||0)+1,z=E[N];if(z&&(!(p==="alignment"?w!==yn(z):!1)||L.every(P=>yn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:N,overflows:L},reset:{placement:z}};let $=(B=L.filter(M=>M.overflows[0]<=0).sort((M,P)=>M.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!$)switch(f){case"bestFit":{var q;const M=(q=L.filter(P=>{if(T){const I=yn(P.placement);return I===w||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,V)=>I+V,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:q[0];M&&($=M);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function ed(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function td(e){return qb.some(t=>e[t]>=0)}const aw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=ed(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:td(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=ed(s,n.floating);return{data:{escapedOffsets:i,escaped:td(i)}}}default:return{}}}}},nd=new Set(["left","top"]);async function lw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Sr(n),l=yn(n)==="y",c=nd.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const cw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await lw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},uw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await no(t,l),p=yn(jn(o)),m=Ki(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Vi(w,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Vi(w,v,S)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},dw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=yn(o),m=Ki(p);let f=d[m],v=d[p];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=nd.has(jn(o)),C=s.reference[p]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[p])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[p]:v}}}},fw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await no(t,c),p=jn(o),m=Sr(o),f=yn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=Fn(g-d[x],w),C=Fn(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const L=Zt(d.left,0),H=Zt(d.right,0),B=Zt(d.top,0),q=Zt(d.bottom,0);f?j=v-2*(L!==0||H!==0?L+H:Zt(d.left,d.right)):E=g-2*(B!==0||q!==0?B+q:Zt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Cr(e){return rd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Sn(e){var t;return(t=(rd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function dn(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Cn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function od(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const pw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!pw.has(o)}const hw=new Set(["table","td","th"]);function mw(e){return hw.has(Cr(e))}const gw=[":popover-open",":modal"];function rs(e){return gw.some(t=>{try{return e.matches(t)}catch{return!1}})}const xw=["transform","translate","scale","rotate","perspective"],vw=["transform","translate","scale","rotate","perspective","filter"],bw=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=dn(e)?fn(e):e;return xw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||vw.some(r=>(n.willChange||"").includes(r))||bw.some(r=>(n.contain||"").includes(r))}function ww(e){let t=Bn(e);for(;Cn(t)&&!Tr(t);){if(Xi(t))return t;if(rs(t))return null;t=Bn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yw=new Set(["html","body","#document"]);function Tr(e){return yw.has(Cr(e))}function fn(e){return Qt(e).getComputedStyle(e)}function os(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Bn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||od(e)&&e.host||Sn(e);return od(t)?t.host:t}function sd(e){const t=Bn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Cn(t)&&ro(t)?t:sd(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=sd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function id(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Cn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return dn(e)?e:e.contextElement}function kr(e){const t=Qi(e);if(!Cn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=id(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Sw=wn(0);function ad(e){const t=Qt(e);return!Ji()||!t.visualViewport?Sw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=wn(1);t&&(r?dn(r)&&(i=kr(r)):i=kr(e));const a=Cw(s,n,r)?ad(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Qt(s),f=r&&dn(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=fn(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:p,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:er(Sn(e)).left+n}function ld(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Tw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Sn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),p=Cn(r);if((p||!p&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=os(r)),Cn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?ld(i,l):wn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function kw(e){return Array.from(e.getClientRects())}function Ew(e){const t=Sn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const cd=25;function Iw(e,t){const n=Qt(e),r=Sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=cd&&(s-=v)}else c<=cd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Nw=new Set(["absolute","fixed"]);function Aw(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Cn(e)?kr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function ud(e,t,n){let r;if(t==="viewport")r=Iw(e,n);else if(t==="document")r=Ew(Sn(e));else if(dn(t))r=Aw(t,n);else{const o=ad(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function dd(e,t){const n=Bn(e);return n===t||!dn(n)||Tr(n)?!1:fn(n).position==="fixed"||dd(n,t)}function jw(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>dn(a)&&Cr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Bn(e):e;for(;dn(i)&&!Tr(i);){const a=fn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Nw.has(o.position)||ro(i)&&!l&&dd(e,i))?r=r.filter(d=>d!==i):o=a,i=Bn(i)}return t.set(e,r),r}function _w(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:jw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=ud(t,d,o);return c.top=Zt(p.top,c.top),c.right=Fn(p.right,c.right),c.bottom=Fn(p.bottom,c.bottom),c.left=Zt(p.left,c.left),c},ud(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Pw(e){const{width:t,height:n}=id(e);return{width:t,height:n}}function Rw(e,t,n){const r=Cn(t),o=Sn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ld(o,a):wn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function ea(e){return fn(e).position==="static"}function fd(e,t){if(!Cn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Sn(e)===n&&(n=n.ownerDocument.body),n}function pd(e,t){const n=Qt(e);if(rs(e))return n;if(!Cn(e)){let o=Bn(e);for(;o&&!Tr(o);){if(dn(o)&&!ea(o))return o;o=Bn(o)}return n}let r=fd(e,t);for(;r&&mw(r)&&ea(r);)r=fd(r,t);return r&&Tr(r)&&ea(r)&&!Xi(r)?n:r||ww(e)||n}const Mw=async function(e){const t=this.getOffsetParent||pd,n=this.getDimensions,r=await n(e.floating);return{reference:Rw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ow(e){return fn(e).direction==="rtl"}const Dw={convertOffsetParentRelativeRectToViewportRelativeRect:Tw,getDocumentElement:Sn,getClippingRect:_w,getOffsetParent:pd,getElementRects:Mw,getClientRects:kw,getDimensions:Pw,getScale:kr,isElement:dn,isRTL:Ow};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Lw(e,t){let n=null,r;const o=Sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(p),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(p+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,Fn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function $w(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Lw(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!hd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Fw=cw,Bw=uw,zw=iw,Hw=fw,Uw=aw,md=sw,Ww=dw,Vw=(e,t,n)=>{const r=new Map,o={platform:Dw,...n},s={...o.platform,_c:r};return ow(e,t,{...o,platform:s})};var Kw=typeof document<"u",qw=function(){},is=Kw?b.useLayoutEffect:qw;function as(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!as(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xd(e,t){const n=gd(e);return Math.round(t*n)/n}function ta(e){const t=h.useRef(e);return is(()=>{t.current=e}),t}function Gw(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);as(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=h.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=h.useRef(null),E=h.useRef(null),j=h.useRef(d),R=l!=null,L=ta(l),H=ta(o),B=ta(c),q=h.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),Vw(T.current,E.current,P).then(I=>{const V={...I,isPositioned:B.current!==!1};N.current&&!as(j.current,V)&&(j.current=V,Hr.flushSync(()=>{p(V)}))})},[m,t,n,H,B]);is(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,p(P=>({...P,isPositioned:!1})))},[c]);const N=h.useRef(!1);is(()=>(N.current=!0,()=>{N.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,q);q()}},[k,C,q,L,R]);const z=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),$=h.useMemo(()=>({reference:k,floating:C}),[k,C]),M=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=xd($.floating,d.x),V=xd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+V+"px)",...gd($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:V}},[n,a,$.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:q,refs:z,elements:$,floatingStyles:M}),[d,q,z,$,M])}const Yw=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?md({element:r.current,padding:o}).fn(n):{}:r?md({element:r,padding:o}).fn(n):{}}}},Xw=(e,t)=>({...Fw(e),options:[e,t]}),Jw=(e,t)=>({...Bw(e),options:[e,t]}),Zw=(e,t)=>({...Ww(e),options:[e,t]}),Qw=(e,t)=>({...zw(e),options:[e,t]}),ey=(e,t)=>({...Hw(e),options:[e,t]}),ty=(e,t)=>({...Uw(e),options:[e,t]}),ny=(e,t)=>({...Yw(e),options:[e,t]});var ry="Arrow",vd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});vd.displayName=ry;var oy=vd;function bd(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[wd,Er]=un(na),[sy,yd]=wd(na),Sd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(sy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sd.displayName=na;var Cd="PopperAnchor",Td=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=yd(Cd,n),i=h.useRef(null),a=Fe(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Td.displayName=Cd;var ra="PopperContent",[iy,ay]=wd(ra),kd=h.forwardRef((e,t)=>{var W,D,X,oe,G,Z;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=yd(ra,n),[y,w]=h.useState(null),S=Fe(t,te=>w(te)),[k,C]=h.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],B=H.length>0,q={padding:L,boundary:H.filter(cy),altBoundary:B},{refs:N,floatingStyles:z,placement:$,isPositioned:M,middlewareData:P}=Gw({strategy:"fixed",placement:R,whileElementsMounted:(...te)=>$w(...te,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Xw({mainAxis:o+j,alignmentAxis:i}),l&&Jw({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Zw():void 0,...q}),l&&Qw({...q}),ey({...q,apply:({elements:te,rects:se,availableWidth:ue,availableHeight:ge})=>{const{width:Me,height:Oe}=se.reference,Te=te.floating.style;Te.setProperty("--radix-popper-available-width",`${ue}px`),Te.setProperty("--radix-popper-available-height",`${ge}px`),Te.setProperty("--radix-popper-anchor-width",`${Me}px`),Te.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),k&&ny({element:k,padding:a}),uy({arrowWidth:E,arrowHeight:j}),m&&ty({strategy:"referenceHidden",...q})]}),[I,V]=Nd($),J=vt(v);It(()=>{M&&(J==null||J())},[M,J]);const _=(W=P.arrow)==null?void 0:W.x,O=(D=P.arrow)==null?void 0:D.y,K=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[Y,ae]=h.useState();return It(()=>{y&&ae(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:M?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(oe=P.transformOrigin)==null?void 0:oe.x,(G=P.transformOrigin)==null?void 0:G.y].join(" "),...((Z=P.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(iy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:O,shouldHideArrow:K,children:u.jsx(me.div,{"data-side":I,"data-align":V,...g,ref:S,style:{...g.style,animation:M?void 0:"none"}})})})});kd.displayName=ra;var Ed="PopperArrow",ly={top:"bottom",right:"left",bottom:"top",left:"right"},Id=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=ay(Ed,r),i=ly[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(oy,{...o,ref:n,style:{...o.style,display:"block"}})})});Id.displayName=Ed;function cy(e){return e!==null}var uy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Nd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Nd(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=Sd,sa=Td,ia=kd,aa=Id,dy="Portal",so=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});so.displayName=dy;function fy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=py(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Fe(r.ref,hy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function py(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=fy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var la="rovingFocusGroup.onEntryFocus",my={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Ad,gy]=Yo(io),[xy,jd]=un(io,[gy]),[vy,by]=xy(io),_d=h.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));_d.displayName=io;var wy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Fe(t,m),v=Xo(s),[g,x]=Ln({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=h.useState(!1),S=vt(c),k=Ad(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(la,S),()=>j.removeEventListener(la,S)},[S]),u.jsx(vy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>x(j),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,j=>{const R=!C.current;if(j.target===j.currentTarget&&R&&!y){const L=new CustomEvent(la,my);if(j.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter($=>$.focusable),B=H.find($=>$.active),q=H.find($=>$.id===g),z=[B,q,...H].filter(Boolean).map($=>$.ref.current);Md(z,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),Pd="RovingFocusGroupItem",Rd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=by(Pd,n),p=d.currentTabStopId===c,m=Ad(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Cy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Ty(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Rd.displayName=Pd;var yy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Sy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Cy(e,t,n){const r=Sy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return yy[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ty(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ky=_d,Ey=Rd,Iy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,cs=new WeakMap,us={},ua=0,Od=function(e){return e&&(e.host||Od(e.parentNode))},Ny=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Od(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ay=function(e,t,n,r){var o=Ny(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ua++,function(){i.forEach(function(p){var m=Ir.get(p)-1,f=s.get(p)-1;Ir.set(p,m),s.set(p,f),m||(cs.has(p)||p.removeAttribute(r),cs.delete(p)),f||p.removeAttribute(n)}),ua--,ua||(Ir=new WeakMap,Ir=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Iy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ay(r,o,n,"aria-hidden")):function(){return null}},Tn=function(){return Tn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Tn.apply(this,arguments)};function Dd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function jy(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ds="right-scroll-bar-position",fs="width-before-scroll-bar",_y="with-scroll-bars-hidden",Py="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ry(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var My=typeof window<"u"?h.useLayoutEffect:h.useEffect,Ld=new WeakMap;function Oy(e,t){var n=Ry(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(function(){var r=Ld.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Ld.set(n,e)},[e]),n}function Dy(e){return e}function Ly(e,t){t===void 0&&(t=Dy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function $y(e){e===void 0&&(e={});var t=Ly(null);return t.options=Tn({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Dd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Tn({},n))};$d.isSideCarExport=!0;function Fy(e,t){return e.useMedium(t),$d}var Fd=$y(),pa=function(){},ps=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Dd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Oy([n,t]),E=Tn(Tn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:Fd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),Tn(Tn({},E),{ref:T})):h.createElement(w,Tn({},E,{className:l,ref:T}),a))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ps.classNames={fullWidth:fs,zeroRight:ds};var By=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=By();return t&&e.setAttribute("nonce",t),e}function Hy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Uy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Wy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zy())&&(Hy(t,n),Uy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Vy=function(){var e=Wy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=Vy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ky={left:0,top:0,right:0,gap:0},ha=function(e){return parseInt(e||"",10)||0},qy=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ha(n),ha(r),ha(o)]},Gy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ky;var t=qy(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Yy=Bd(),Nr="data-scroll-locked",Xy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(_y,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -73,27 +73,27 @@ React keys must be passed directly to JSX without using spread:
|
|
|
73
73
|
body[`).concat(Nr,`] {
|
|
74
74
|
`).concat(Py,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},
|
|
76
|
+
`)},zd=function(){var e=parseInt(document.body.getAttribute(Nr)||"0",10);return isFinite(e)?e:0},Jy=function(){h.useEffect(function(){return document.body.setAttribute(Nr,(zd()+1).toString()),function(){var e=zd()-1;e<=0?document.body.removeAttribute(Nr):document.body.setAttribute(Nr,e.toString())}},[])},Zy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Jy();var s=h.useMemo(function(){return Gy(o)},[o]);return h.createElement(Yy,{styles:Xy(s,!t,o,n?"":"!important")})},ma=!1;if(typeof window<"u")try{var hs=Object.defineProperty({},"passive",{get:function(){return ma=!0,!0}});window.addEventListener("test",hs,hs),window.removeEventListener("test",hs,hs)}catch{ma=!1}var Ar=ma?{passive:!1}:!1,Qy=function(e){return e.tagName==="TEXTAREA"},Hd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Qy(e)&&n[t]==="visible")},e0=function(e){return Hd(e,"overflowY")},t0=function(e){return Hd(e,"overflowX")},Ud=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Wd(e,r);if(o){var s=Vd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},n0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},r0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Wd=function(e,t){return e==="v"?e0(t):t0(t)},Vd=function(e,t){return e==="v"?n0(t):r0(t)},o0=function(e,t){return e==="h"&&t==="rtl"?-1:1},s0=function(e,t,n,r,o){var s=o0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=Vd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Wd(e,a)&&(p+=y,m+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ms=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kd=function(e){return[e.deltaX,e.deltaY]},qd=function(e){return e&&"current"in e?e.current:e},i0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},a0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},l0=0,jr=[];function c0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(l0++)[0],s=p.useState(Fd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=jy([e.lockRef.current],(e.shards||[]).map(Kd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Hd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Hd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var M=r.current||C;return s0(M,x,g,M==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&i0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Kd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:u0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Vd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:a0(o)}):null,f?p.createElement(Zy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function u0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const d0=Fy($d,c0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Tn({},e,{ref:t,sideCar:d0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],f0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],h0=[...f0,...qd],p0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},m0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,g0,x0]=Yo(ao),[tr,Gd]=un(ao,[x0,Er,Ad]),xs=Er(),Yd=Ad(),[v0,nr]=tr(ao),[b0,co]=tr(ao),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=vt(s),m=Xo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(v0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(b0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Xd.displayName=ao;var w0="MenuAnchor",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=w0;var va="MenuPortal",[y0,Jd]=tr(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(va,t);return u.jsx(y0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Zd.displayName=va;var nn="MenuContent",[S0,ba]=tr(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(C0,{...o,ref:t}):u.jsx(T0,{...o,ref:t})})})})}),C0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu),r=p.useRef(null),o=Fe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),T0=p.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu);return u.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),k0=Yt.createSlot("MenuContent.ScrollLock"),wa=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(nn,n),y=co(nn,n),w=xs(n),S=Yd(n),k=g0(n),[C,T]=p.useState(null),E=p.useRef(null),j=Fe(t,E,x.onContentChange),M=p.useRef(0),L=p.useRef(""),H=p.useRef(0),B=p.useRef(null),q=p.useRef("right"),N=p.useRef(0),z=v?gs:p.Fragment,$=v?{as:k0,allowPinchZoom:!0}:void 0,R=I=>{var W,D;const V=L.current+I,J=k().filter(X=>!X.disabled),_=document.activeElement,O=(W=J.find(X=>X.ref.current===_))==null?void 0:W.textValue,K=J.map(X=>X.textValue),Y=L0(K,V,O),ae=(D=J.find(X=>X.textValue===Y))==null?void 0:D.ref.current;(function X(oe){L.current=oe,window.clearTimeout(M.current),oe!==""&&(M.current=window.setTimeout(()=>X(""),1e3))})(V),ae&&setTimeout(()=>ae.focus())};p.useEffect(()=>()=>window.clearTimeout(M.current),[]),Hi();const P=p.useCallback(I=>{var J,_;return q.current===((J=B.current)==null?void 0:J.side)&&F0(I,(_=B.current)==null?void 0:_.area)},[]);return u.jsx(S0,{scope:n,searchRef:L,onItemEnter:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:p.useCallback(I=>{var V;P(I)||((V=E.current)==null||V.focus(),T(null))},[P]),onTriggerLeave:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:p.useCallback(I=>{B.current=I},[]),children:u.jsx(z,{...$,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var V;I.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(ky,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":xf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!_&&O&&R(I.key));const K=E.current;if(I.target!==K||!h0.includes(I.key))return;I.preventDefault();const ae=k().filter(W=>!W.disabled).map(W=>W.ref.current);qd.includes(I.key)&&ae.reverse(),O0(ae)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const V=I.target,J=N.current!==I.clientX;if(I.currentTarget.contains(V)&&J){const _=I.clientX>N.current?"right":"left";q.current=_,N.current=I.clientX}}))})})})})})})});Qd.displayName=nn;var E0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});ya.displayName=E0;var I0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});ef.displayName=I0;var vs="MenuItem",tf="menu.itemSelect",bs=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=ba(vs,e.__scopeMenu),l=Fe(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(tf,{bubbles:!0,cancelable:!0});h.addEventListener(tf,f=>r==null?void 0:r(f),{once:!0}),Fi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(nf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ga.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});bs.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ba(vs,n),a=Yd(n),l=p.useRef(null),c=Fe(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ey,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),N0="MenuCheckboxItem",rf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(cf,{scope:e.__scopeMenu,checked:n,children:u.jsx(bs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=N0;var of="MenuRadioGroup",[A0,j0]=tr(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return u.jsx(A0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=j0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(bs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,_0]=tr(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=_0(Sa,n);return u.jsx(Wt,{present:r||ws(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var P0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=P0;var M0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=M0;var R0="MenuSub",[wN,hf]=tr(R0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=ba(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||p0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});pf.displayName=uo;var mf="MenuSubContent",gf=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=Fe(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(wa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=m0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Ca(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function O0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function D0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function L0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=D0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function $0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function F0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var B0=Xd,z0=xa,H0=Zd,U0=Qd,W0=ya,V0=ef,K0=bs,q0=rf,G0=sf,Y0=lf,X0=uf,J0=df,Z0=ff,Q0=pf,eS=gf,ys="DropdownMenu",[tS,yN]=un(ys,[Gd]),$t=Gd(),[nS,vf]=tS(ys),bf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=p.useRef(null),[d,h]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(nS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(B0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};bf.displayName=ys;var wf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(wf,n),i=$t(n);return u.jsx(z0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Dn(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=wf;var rS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(H0,{...r,...n})};Sf.displayName=rS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=$t(n),i=p.useRef(!1);return u.jsx(U0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tf.displayName=Cf;var oS="DropdownMenuGroup",sS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(W0,{...o,...r,ref:t})});sS.displayName=oS;var iS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(V0,{...o,...r,ref:t})});kf.displayName=iS;var aS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(K0,{...o,...r,ref:t})});Ef.displayName=aS;var lS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(q0,{...o,...r,ref:t})});If.displayName=lS;var cS="DropdownMenuRadioGroup",uS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});uS.displayName=cS;var dS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=dS;var fS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});Af.displayName=fS;var hS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});jf.displayName=hS;var pS="DropdownMenuArrow",mS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});mS.displayName=pS;var gS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});_f.displayName=gS;var xS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Pf.displayName=xS;var vS=bf,bS=yf,wS=Sf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf;const Ss=vS,Cs=bS,yS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));yS.displayName=Bf.displayName;const SS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));SS.displayName=zf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(wS,{children:u.jsx(Mf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Mf.displayName;const zn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));zn.displayName=Of.displayName;const CS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($f,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));CS.displayName=Df.displayName;const TS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx($f,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));TS.displayName=Lf.displayName;const kS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Rf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));kS.displayName=Rf.displayName;const ES=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));ES.displayName=Ff.displayName;const Ta=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ta.displayName="Textarea";const IS=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=IS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,w]=b.useState(e),S=(x?i:y)??"",[k,C]=b.useTransition(),T=b.useRef(null),E=b.useRef(0),j=b.useRef(null),M=b.useRef("");b.useEffect(()=>{x||(w(e??""),j.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,H]=b.useState(null),B=b.useCallback(O=>O.length>s?`Message too long (${O.length}/${s} characters)`:null,[s]),q=b.useMemo(()=>v??B,[v,B]),N=b.useCallback(O=>{const K=q(O);return H(K),g==null||g(K),M.current=O,K},[q,g]),z=b.useCallback(()=>{const O=T.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);b.useEffect(()=>{z()},[z,S]),b.useEffect(()=>{if(!L)return;const O=(S??"").trim();M.current!==O&&N(O)},[S,L,N]);const $=b.useCallback((O,{fromUser:K})=>{x||w(O),K&&(a==null||a(O))},[x,a]),R=b.useCallback(async O=>{O&&O.preventDefault();const K=(S??"").trim();if(!K&&!f||N(K))return;const Y=++E.current;j.current={id:Y,shouldClear:!0},C(()=>{var ae,W,D;try{const X=l(K);X&&typeof X.then=="function"?X.then(()=>{var oe,G;((oe=j.current)==null?void 0:oe.id)===Y&&j.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((G=j.current)==null?void 0:G.id)===Y&&(j.current=null)}).catch(()=>{var oe;((oe=j.current)==null?void 0:oe.id)===Y&&(j.current=null)}):(((ae=j.current)==null?void 0:ae.id)===Y&&j.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=j.current)==null?void 0:W.id)===Y&&(j.current=null))}catch{((D=j.current)==null?void 0:D.id)===Y&&(j.current=null)}})},[S,l,f,x,a,N]),P=b.useCallback(O=>{const K=O.target.value;$(K,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&N(K.trim())},[$,N,L]),I=b.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),R()):O.key==="Escape"&&t&&(O.preventDefault(),c==null||c())},[R,t,c]),_=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:O=>void R(O),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:P,onKeyDown:I,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(de.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(de.Send,{size:16})})})]})})}const NS=b.memo(Hf),Ts=0,Hn=1,_r=2,Uf=4;function Wf(e){return()=>e}function AS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function jS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function _S(...e){return()=>{e.map(AS)}}function Pr(){}function ks(e,t){return t(e),e}function PS(e,t){return t(e)}function it(...e){return e}function Ze(e,t){return e(Hn,t)}function De(e,t){e(Ts,t)}function Ea(e){e(_r)}function bt(e){return e(Uf)}function ve(e,t){return Ze(e,jS(t,Ts))}function hn(e,t){const n=e(Hn,r=>{n(),t(r)});return n}function qf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Gf(e,t){return e===t}function at(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Vf(t,e)}function kn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=MS(...t);return(r,o)=>{switch(r){case _r:Ea(e);return;case Hn:return Ze(e,n(o))}}}function En(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Be(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function MS(...e){return t=>e.reduceRight(PS,t)}function RS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Hn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Pr);case _r:r(),n=null;return}}}function ie(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case Hn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(ie(t),n=>ve(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Hn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>ve(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:OS(),singleton:n}}const OS=()=>Symbol();function DS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function yt(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&De(t,n)})}),function(s,i){switch(s){case _r:{Ea(t);return}case Hn:return r===o&&i(n),Ze(t,i)}}}function Ee(e,t=Gf){return ee(e,at(t))}function Ia(...e){return function(t,n){switch(t){case _r:return;case Hn:return _S(...e.map(r=>Ze(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const LS={0:"debug",3:"error",1:"log",2:"warn"},$S=()=>typeof globalThis>"u"?window:globalThis,Un=qe(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=$S().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[LS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Na(e,t,n).callbackRef}function Na(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function FS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=BS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Yf("column-gap",getComputedStyle(d).columnGap,o):Yf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function BS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Yf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=qe(()=>{const e=We(),t=We(),n=ie(0),r=We(),o=ie(0),s=We(),i=We(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),h=We(),m=We(),f=ie(!1),v=ie(!1),g=ie(!1);return ve(ee(e,he(({scrollTop:x})=>x)),t),ve(ee(e,he(({scrollHeight:x})=>x)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Jf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===po}function mo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function pn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function tn(e,t,n){return ot(e)?eh(t,n,1):t===e.k?Ct(e,{k:t,v:n}):t<e.k?th(Ct(e,{l:tn(e.l,t,n)})):th(Ct(e,{r:tn(e.r,t,n)}))}function Mr(){return po}function Es(e,t,n){if(ot(e))return[];const r=pn(e,t)[0];return zS(ja(e,r,n))}function Aa(e,t){if(ot(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Qf(r);return Is(Ct(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(Ct(e,{l:Aa(r,t)})):Is(Ct(e,{r:Aa(o,t)}))}function sr(e){return ot(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function ja(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ja(s,t,n))),a}function Is(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(_a(t))return nh(Ct(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Ct(t.r,{l:Ct(t,{r:t.r.l}),lvl:n,r:Ct(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(Ct(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return Ct(o,{l:Ct(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(Ct(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Ct(e,t){return eh(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Zf(e){return ot(e.r)?e.l:Is(Ct(e,{r:Zf(e.r)}))}function _a(e){return ot(e)||e.lvl>e.r.lvl}function Qf(e){return ot(e.r)?[e.k,e.v]:Qf(e.r)}function eh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function th(e){return Pa(nh(e))}function nh(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Ct(t,{r:Ct(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Ct(n,{l:Ct(e,{r:n.l}),lvl:t+1}):e}function zS(e){return Jf(e,({k:t,v:n})=>({index:t,value:n}))}function rh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ma=qe(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function oh(e,t,n){return e[Ns(e,t,n)]}function Ns(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function HS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!ot(e.groupOffsetTree)}function Ra({index:e},t){return t===e?0:t<e?-1:1}function US(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function WS(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(JS(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Aa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function VS(e){return typeof e.groupIndex<"u"}function KS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oh(t,e,Ra),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ih(e,t,n){if(VS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function qS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ra).offset)),Jf(HS(e,t,n,KS),XS)}function GS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=WS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function YS(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ah(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ra),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const h=c-s,m=h*i+a+h*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function XS(e){return{index:e.index,value:e}}function JS(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const ZS={offsetHeight:"height",offsetWidth:"width"},In=qe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Mt(r,0),s=We(),i=We(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),h=ie((C,T)=>Wn(C,ZS[T])),m=ie(void 0),f=ie(0),v=US(),g=Mt(ee(n,Be(l,e,f),En(GS,v),at()),v),x=Mt(ee(l,at(),En((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ve(ee(l,Ne(C=>C.length>0),Be(g,f),he(([C,T,E])=>{const j=C.reduce((M,L,H)=>tn(M,L,xo(L,T.offsetTree,E)||H),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),ve(ee(r,Be(g),Ne(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ve(c,d);const y=Mt(ee(c,he(C=>C===void 0)),!0);ve(ee(d,Ne(C=>C!==void 0&&ot(bt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=en(ee(n,Be(g),En(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Ze(ee(a,En((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=bt(g);if(C>0)De(t,!0),De(s,C+ah(C,T));else if(C<0){const E=bt(x);E.length>0&&(C-=ah(-C,E)),De(i,C)}}),Ze(ee(a,Be(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=en(s);ve(ee(s,Be(g),he(([C,T])=>{const E=T.groupIndices.length>0,j=[],M=T.lastSize;if(E){const L=mo(T.sizeTree,0);let H=0,B=0;for(;H<C;){const N=T.groupIndices[B],z=T.groupIndices.length===B+1?1/0:T.groupIndices[B+1]-N-1;j.push({endIndex:N,size:L,startIndex:N}),j.push({endIndex:N+1+z-1,size:M,startIndex:N+1}),B++,H+=z+1}const q=sr(T.sizeTree);return H!==C&&q.shift(),q.reduce((N,{k:z,v:$})=>{let R=N.ranges;return N.prevSize!==0&&(R=[...N.ranges,{endIndex:z+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:z+C,prevSize:$,ranges:R}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((L,{k:H,v:B})=>({prevIndex:H+C,prevSize:B,ranges:[...L.ranges,{endIndex:H+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:M,ranges:[]}).ranges})),n);const k=en(ee(i,Be(g,f),he(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return ve(ee(i,Be(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let j=Mr();const M=bt(x);let L=0,H=0,B=0;for(;L<-C;){B=M[H];const q=M[H+1]-B-1;H++,L+=q+1}if(j=sr(T.sizeTree).reduce((q,{k:N,v:z})=>tn(q,Math.max(0,N+C),z),j),L!==-C){const q=mo(T.sizeTree,B);j=tn(j,0,q);const N=pn(T.sizeTree,-C+1)[1];j=tn(j,1,N)}return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((M,{k:L,v:H})=>tn(M,Math.max(0,L+C),H),Mr());return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Un,Ma),{singleton:!0});function QS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,he(QS)));return ve(ee(a,he(l=>l.totalCount)),n),ve(ee(a,he(l=>l.groupIndices)),e),ve(ee(yt(o,t,r),Ne(([l,c])=>As(c)),he(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(In,Ft)),Vn=qe(([{log:e}])=>{const t=ie(!1),n=en(ee(t,Ne(r=>r),at()));return Ze(t,r=>{r&&bt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},it(Un),{singleton:!0}),eC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ch(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!eC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=We(),v=We(),g=ie(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),De(l,!1)}return ve(ee(f,Be(n,h,r,g,a,i,m),Be(e,s,o),he(([[k,C,T,E,j,M,L,H],B,q,N])=>{const z=ch(k),{align:$,behavior:R,offset:P}=z,I=E-1,V=ih(z,C,I);let J=xo(V,C.offsetTree,B)+M;$==="end"?(J+=q+pn(C.sizeTree,V)[1]-T+N,V===I&&(J+=L)):$==="center"?J+=(q+pn(C.sizeTree,V)[1]-T+N)/2:J-=j,P&&(J+=P);const _=O=>{S(),O?(H("retrying to scroll to",{location:k},Vt.DEBUG),De(f,k)):(De(v,!0),H("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),R==="smooth"){let O=!1;w=Ze(t,K=>{O=O||K}),x=hn(d,()=>{_(O)})}else x=hn(ee(t,tC(150)),_);return y=setTimeout(()=>{S()},1200),De(l,!0),H("scrolling from index to",{behavior:R,index:V,top:J},Vt.DEBUG),{behavior:R,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},it(In,Ft,Un),{singleton:!0});function tC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ve(ee(i,Be(l),Ne(([d,h])=>!!h),kn(!1)),a),ve(ee(i,Be(l),Ne(([d,h])=>!!h),kn(!1)),c),Ze(ee(yt(t,i),Be(a,n,e,c),Ne(([[,d],h,{sizeTree:m},f,v])=>d&&(!ot(m)||ka(f))&&!h&&!v),Be(l)),([,d])=>{hn(o,()=>{De(c,!0)}),Da(4,()=>{hn(r,()=>{De(a,!0)}),De(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(In,Ft,vo,Vn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",nC="none",rC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},oC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=We(),c=We(),d=ie(4),h=ie(oC),m=Mt(ee(Ia(ee(Ee(o),rr(1),kn(!0)),ee(Ee(o),rr(1),kn(!1),qf(100))),at()),!1),f=Mt(ee(Ia(ee(n,kn(!0)),ee(n,kn(!1),qf(200))),at()),!1);ve(ee(yt(Ee(o),Ee(h)),he(([w,S])=>w<=S),at()),a),ve(ee(a,_n(50)),c);const v=en(ee(yt(r,Ee(s),Ee(t),Ee(e),Ee(d)),En((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const M=k+C-S>-j,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(M){let B,q;return k>w.state.scrollTop?(B="SCROLLED_DOWN",q=w.state.scrollTop-k):(B="SIZE_DECREASED",q=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:q,state:L}}let H;return L.scrollHeight>w.state.scrollHeight?H="SIZE_INCREASED":C<w.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},rC),at((w,S)=>w&&w.atBottom===S.atBottom))),g=Mt(ee(r,En((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(w=>w.changed),he(w=>w.jump)),0);ve(ee(v,he(w=>w.atBottom)),i),ve(ee(i,_n(50)),l);const x=ie(yo);ve(ee(r,he(({scrollTop:w})=>w),at(),En((w,S)=>bt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(w=>w.direction)),x),ve(ee(r,_n(50),kn(nC)),x);const y=ie(0);return ve(ee(m,Ne(w=>!w),kn(0)),y),ve(ee(o,_n(100),Be(m),Ne(([w,S])=>!!S),En(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Ft)),js="top",_s="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===wo&&t===js||n===yo&&t===_s?e:0:n===wo?t===js?e.main:e.reverse:t===_s?e.main:e.reverse}function hh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=ie(0),a=ie(0),l=ie(0),c=Mt(ee(yt(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),he(([d,h,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=dh;const j=hh(S,js),M=hh(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-j&&(E=wo),v<d-T+h+M&&(E=yo),E!==dh?[Math.max(k-m-fh(g,js,E)-j,0),k-T-y+h+fh(g,_s,E)+M]:null}),Ne(d=>d!=null),at(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Ft),{singleton:!0});function sC(e,t,n){if(As(t)){const r=sh(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Fa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ps(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:mh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:mh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function ph(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=La(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ps(c,[],a,o,n,r)}function mh(e,t,n){if(e.length===0)return[];if(!As(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=ie([]),x=ie(0),y=We();ve(s.topItemsIndexes,g);const w=Mt(ee(yt(f,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,E,,j,,,,,,,M])=>{const L=M&&M.length!==j;return T&&!E&&!L}),he(([,,[T,E],j,M,L,H,B,q,N,z])=>{const $=M,{offsetTree:R,sizeTree:P}=$,I=bt(x);if(j===0)return{...Fa,totalCount:j};if(T===0&&E===0)return I===0?{...Fa,totalCount:j}:ph(I,L,M,q,N,z||[]);if(ot(P))return I>0?null:Ps(sC(La(L,j),$,z),[],j,N,$,q);const V=[];if(B.length>0){const Y=B[0],ae=B[B.length-1];let W=0;for(const D of Es(P,Y,ae)){const X=D.value,oe=Math.max(D.start,Y),G=Math.min(D.end,ae);for(let Z=oe;Z<=G;Z++)V.push({data:z==null?void 0:z[Z],index:Z,offset:W,size:X}),W+=X}}if(!H)return Ps([],V,j,N,$,q);const J=B.length>0?B[B.length-1]+1:0,_=qS(R,T,E,J);if(_.length===0)return null;const O=j-1,K=ks([],Y=>{for(const ae of _){const W=ae.value;let D=W.offset,X=ae.start;const oe=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+N)/(oe+N));const Z=X-ae.start;D+=Z*oe+Z*N}X<J&&(D+=(J-X)*oe,X=J);const G=Math.min(ae.end,O);for(let Z=X;Z<=G&&!(D>=E);Z++)Y.push({data:z==null?void 0:z[Z],index:Z,offset:D,size:oe}),D+=oe+N}});return Ps(K,V,j,N,$,q)}),Ne(T=>T!==null),at()),Fa);ve(ee(e,Ne(ka),he(T=>T==null?void 0:T.length)),o),ve(ee(w,he(T=>T.topListHeight)),h),ve(h,a),ve(ee(w,he(T=>[T.top,T.bottom])),i),ve(ee(w,he(T=>T.items)),y);const S=en(ee(w,Ne(({items:T})=>T.length>0),Be(o,e),Ne(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),at(go),he(([T])=>T))),k=en(ee(w,_n(200),Ne(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),at())),C=en(ee(w,Ne(({items:T})=>T.length>0),he(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),at(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},it(In,lh,$a,bo,vo,So,Vn,Ma),{singleton:!0}),gh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Mt(ee(yt(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ve(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Ft,ir),{singleton:!0}),iC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Mt(ee(yt(n,e,t),Ne(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),_n(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Ft,gh),{singleton:!0}),xh=qe(()=>({context:ie(null)})),aC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,vh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return ve(ee(d,Be(t,l,n,s,o,r,a),Be(e),he(([[h,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=aC,done:E,...j}=h,M=ih(h,m,v-1),L=xo(M,m.offsetTree,S)+g+x,H=L+pn(m.sizeTree,M)[1],B=w+x,q=w+f-y,N=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:C,...j},viewportBottom:q,viewportTop:B});return N?E&&hn(ee(i,Ne(z=>!z),rr(bt(i)?1:2)),E):E&&E(),N}),Ne(h=>h!==null)),c),{scrollIntoView:d}},it(In,Ft,vo,ir,Un),{singleton:!0});function bh(e){return e?e==="smooth"?"smooth":"auto":!1}const lC=(e,t)=>typeof e=="function"?bh(e(t)):t&&bh(e),cC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=ie(!1),g=We();let x=null;function y(C){De(i,{align:"end",behavior:C,index:"LAST"})}Ze(ee(yt(ee(Ee(t),rr(1)),l),Be(Ee(v),s,a,h),he(([[C,T],E,j,M,L])=>{let H=T&&M,B="auto";return H&&(B=lC(E,j||L),H=H&&!!B),{followOutputBehavior:B,shouldFollow:H,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=hn(e,()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function w(C){const T=hn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(ee(yt(Ee(v),t,c),Ne(([C,,T])=>C&&T),En(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),Be(v,t)),([,C])=>{bt(a)&&w(C!==!1)}),Ze(g,()=>{w(bt(v)!==!1)}),Ze(yt(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=ie(null),k=We();return ve(Ia(ee(Ee(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ee(t))),k),Ze(ee(yt(ee(k,rr(1)),l),Be(Ee(S),a,h,m),he(([[C,T],E,j,M,L])=>T&&j&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:M}))),Ne(C=>!!C),_n(0)),C=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),De(f,C)}):x=hn(e,()=>{bt(d)("scrolling into view",{}),De(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},it(In,So,vo,bo,Vn,Un,Ft,xh,vh)),uC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(ee(a,Be(s),Ne(([,l])=>l!==0),Be(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>ph(l,c,d,h,m,f))),i),{}),it(In,bo,ir,Vn),{singleton:!0}),dC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Ze(ee(e,Be(r),Ne(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{hn(ee(n,rr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{De(t,o)})})}),{initialScrollTop:r}},it(Vn,Ft,ir),{singleton:!0}),wh=qe(([{scrollVelocity:e}])=>{const t=ie(!1),n=We(),r=ie(!1);return ve(ee(e,Be(r,t,n),Ne(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ze(ee(yt(t,e,n),Be(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=ie(!1),i=ie(void 0);return ve(ee(yt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(ee(t,Be(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Ft)),fC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=ie(void 0),h=ie(null),m=ie(null);return ve(a,h),ve(l,m),Ze(ee(c,Be(t,r,i,h,m,n)),([f,v,g,x,y,w,S])=>{const k=YS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ve(ee(d,Ne(ka),he(hC)),o),ve(ee(s,Be(d),Ne(([,f])=>f!==void 0),at(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(In,Ft,bo,Vn,Ba));function hC(e){return{align:"start",index:0,offset:e.scrollTop}}const pC=qe(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(ee(t,Ne(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ir));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const mC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),gC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(ee(l,Be(i),En(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const M=k+T;let L=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=M-S,L!==0&&(L+=j))),[L,C,E,M]},[0,[],0,0]),Ne(([y])=>y!==0),Be(r,a,n,o,f,v),Ne(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(De(t,{behavior:"auto",top:-y}),De(e,0)):(De(e,0),De(t,{behavior:"auto",top:-y}))}return Ze(ee(g,Be(e,s)),([y,w,S])=>{S&&mC()?De(e,w-y):x(-y)}),Ze(ee(yt(Mt(s,!1),e,v),Ne(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),_n(1)),x),ve(ee(h,he(y=>({top:-y}))),t),Ze(ee(c,Be(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=mo(k,0);let M=0,L=0;for(;M<y;){M++,E+=j;let H=w.length===L+1?1/0:w[L+1]-w[L]-1;M+H>y&&(E-=j,H=y-M+1),M+=H,E+=T(H),L++}return E}})),y=>{De(e,y),requestAnimationFrame(()=>{De(t,{top:y}),requestAnimationFrame(()=>{De(e,0),De(v,!1)})})}),{deviation:e}},it(Ft,So,ir,In,Un,Ma)),xC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it($a,uC,Vn,wh,gh,dC,iC,Ba,vh,Un,xh)),Sh=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},M])=>(ve(k.rangeChanged,M.scrollSeekRangeChanged),ve(ee(M.windowViewportRect,he(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...M,...g,sizes:l,...x}),it(In,bo,Ft,fC,cC,ir,vo,gC,pC,lh,xC));function vC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ms=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ch(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(x,y){x.propsReady&&De(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];De(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];De(S,y[w])}x.propsReady&&De(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];De(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=RS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ks(DS(e),E=>{l(E,S)})),[C]=b.useState(Kf(d,k));Ms(()=>{for(const E of i)E in S&&Ze(C[E],S[E]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Ms(()=>{l(k,S)}),b.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...vC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{De(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Ze(y,S),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Kf(bt,y));return Ms(()=>Ze(y,k=>{k!==w&&S(Wf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Ms(()=>Ze(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Th=b.createContext(void 0),kh=b.createContext(void 0),Eh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function za(e){return"self"in e}function bC(e){return"body"in e}function Ih(e,t,n,r=Pr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(bC(x)||za(x)){const w=za(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Po.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;za(f)?(x=Math.max(Wn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Wn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),uh(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Nh="sticky",Ua=yh(()=>{if(typeof document>"u")return Nh;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Nh});function Wa(e){return e}const wC=qe(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(Wa),o=ie("div"),s=ie(Pr),i=(a,l=null)=>Mt(ee(n,he(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),yC=qe(([e,t])=>({...e,...t}),it(Sh,wC)),SC=({height:e})=>u.jsx("div",{style:{height:e}}),CC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},TC={...Ah,display:"inline-block",height:"100%"},jh=b.memo(function({showTopList:e=!1}){const t=je("listState"),n=rn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),h=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=rn("gap"),g=je("horizontalDirection"),{callbackRef:x}=FS(n,m,h,e?Pr:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Va("deviation",N=>{y!==N&&w(N)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||SC,C=je("ListComponent"),T=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),M=je("isSeeking"),L=je("groupIndices").length>0,H=je("alignToBottom"),B=je("initialItemFinalLocationReached"),q=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Rt(S,c)}):u.jsx(C,{...Rt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:q,children:(e?t.topItems:t.items).map(N=>{const z=N.originalIndex,$=j(z+t.firstItemIndex,N.data,c);return M?b.createElement(k,{...Rt(k,c),height:N.size,index:N.index,key:$,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?b.createElement(E,{...Rt(E,c),"data-index":z,"data-item-index":N.index,"data-known-size":N.size,key:$,style:CC},d(N.index,c)):b.createElement(T,{...Rt(T,c),...NC(T,N.data),"data-index":z,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:$,style:g?TC:Ah},L?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),kC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},EC={outline:"none",overflowX:"auto",position:"relative"},Rs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),IC={position:Ua(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function NC(e,t){return{item:typeof e=="string"?void 0:t}}const AC=b.memo(function(){const e=je("HeaderComponent"),t=rn("headerHeight"),n=je("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),jC=b.memo(function(){const e=je("FooterComponent"),t=rn("footerHeight"),n=je("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function _h({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ih(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?EC:kC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Ph({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),h=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ih(a,c,l,v,m);return Eh(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...Rt(l,s),children:r})})}const _C=({children:e})=>{const t=b.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=b.useMemo(()=>Vf(n,l=>Wn(l,s?"width":"height")),[n,s]),a=or(i,!0,je("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Rs(o),children:e})},PC=({children:e})=>{const t=b.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=je("customScrollParent"),s=Xf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Rs(i),children:e})},MC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...IC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},RC=b.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?LC:DC,{...e,context:o,children:[n&&u.jsx(MC,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?PC:_C,{children:[u.jsx(AC,{}),u.jsx(jh,{}),u.jsx(jC,{})]})]})}),{Component:OC,useEmitter:Va,useEmitterValue:je,usePublisher:rn}=Ch(yC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},RC),DC=_h({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),LC=Ph({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),$C=OC;it(Sh,qe(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(Wa),a=ie(Pr),l=(c,d=null)=>Mt(ee(s,he(h=>h[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Ua();const Mh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},FC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Rh,floor:Os,max:Co,min:Ka,round:Oh}=Math;function Dh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function BC(e){return{...FC,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function zC(e,t){return e&&e.column===t.column&&e.row===t.row}const HC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=ie(0),E=ie(0),j=ie(Mh),M=ie({height:0,width:0}),L=ie({height:0,width:0}),H=We(),B=We(),q=ie(0),N=ie(null),z=ie({column:0,row:0}),$=We(),R=We(),P=ie(!1),I=ie(0),V=ie(!0),J=ie(!1),_=ie(!1);Ze(ee(v,Be(I),Ne(([D,X])=>!!X)),()=>{De(V,!1)}),Ze(ee(yt(v,V,L,M,I,J),Ne(([D,X,oe,G,,Z])=>D&&!X&&oe.height!==0&&G.height!==0&&!Z)),([,,,,D])=>{De(J,!0),Da(1,()=>{De(H,D)}),hn(ee(c),()=>{De(t,[0,0]),De(V,!0)})}),ve(ee(R,Ne(D=>D!=null&&D.scrollTop>0),kn(0)),E),Ze(ee(v,Be(R),Ne(([,D])=>D!=null)),([,D])=>{D&&(De(M,D.viewport),De(L,D.item),De(z,D.gap),D.scrollTop>0&&(De(P,!0),hn(ee(c,rr(1)),X=>{De(P,!1)}),De(l,{top:D.scrollTop})))}),ve(ee(M,he(({height:D})=>D)),h),ve(ee(yt(Ee(M,Ds),Ee(L,Ds),Ee(z,(D,X)=>D&&D.column===X.column&&D.row===X.row),Ee(c)),he(([D,X,oe,G])=>({gap:oe,item:X,scrollTop:G,viewport:D}))),$),ve(ee(yt(Ee(T),r,Ee(z,zC),Ee(L,Ds),Ee(M,Ds),Ee(N),Ee(E),Ee(P),Ee(V),Ee(I)),Ne(([,,,,,,,D])=>!D),he(([D,[X,oe],G,Z,te,se,ue,,ge,Re])=>{const{column:Oe,row:Te}=G,{height:nt,width:ht}=Z,{width:Tt}=te;if(ue===0&&(D===0||Tt===0))return Mh;if(ht===0){const kt=La(Re,D),wt=kt+Math.max(ue-1,0);return BC(Dh(kt,wt,se))}const Ke=Lh(Tt,ht,Oe);let Ge,Ve;ge?X===0&&oe===0&&ue>0?(Ge=0,Ve=ue-1):(Ge=Ke*Os((X+Te)/(nt+Te)),Ve=Ke*Rh((oe+Te)/(nt+Te))-1,Ve=Ka(D-1,Co(Ve,Ke-1)),Ge=Ka(Ve,Co(0,Ge))):(Ge=0,Ve=-1);const $e=Dh(Ge,Ve,se),{bottom:He,top:mt}=$h(te,G,Z,$e),Dt=Rh(D/Ke),lt=Dt*nt+(Dt-1)*Te-He;return{bottom:He,itemHeight:nt,items:$e,itemWidth:ht,offsetBottom:lt,offsetTop:mt,top:mt}})),j),ve(ee(N,Ne(D=>D!==null),he(D=>D.length)),T),ve(ee(yt(M,L,j,z),Ne(([D,X,{items:oe}])=>oe.length>0&&X.height!==0&&D.height!==0),he(([D,X,{items:oe},G])=>{const{bottom:Z,top:te}=$h(D,G,X,oe);return[te,Z]}),at(go)),t);const O=ie(!1);ve(ee(c,Be(O),he(([D,X])=>X||D!==0)),O);const K=en(ee(yt(j,T),Ne(([{items:D}])=>D.length>0),Be(O),Ne(([[D,X],oe])=>{const G=D.items[D.items.length-1].index===X-1;return(oe||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&G}),he(([[,D]])=>D-1),at())),Y=en(ee(Ee(j),Ne(({items:D})=>D.length>0&&D[0].index===0),kn(0),at())),ae=en(ee(Ee(j),Be(P),Ne(([{items:D},X])=>D.length>0&&!X),he(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),at(rh),_n(0)));ve(ae,f.scrollSeekRangeChanged),ve(ee(H,Be(M,L,T,z),he(([D,X,oe,G,Z])=>{const te=ch(D),{align:se,behavior:ue,offset:ge}=te;let Re=te.index;Re==="LAST"&&(Re=G-1),Re=Co(0,Re,Ka(G-1,Re));let Oe=qa(X,Z,oe,Re);return se==="end"?Oe=Oh(Oe-X.height+oe.height):se==="center"&&(Oe=Oh(Oe-X.height/2+oe.height/2)),ge&&(Oe+=ge),{behavior:ue,top:Oe}})),l);const W=Mt(ee(j,he(D=>D.offsetBottom+D.bottom)),0);return ve(ee(k,he(D=>({height:D.visibleHeight,width:D.visibleWidth}))),M),{customScrollParent:x,data:N,deviation:q,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:R,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:M,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:W,...m,endReached:K,propsReady:g,rangeChanged:ae,startReached:Y,stateChanged:$,stateRestoreInProgress:P,...C}},it($a,Ft,So,wh,Vn,Ba,Un));function Lh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function $h(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=qa(e,t,n,r[0].index);return{bottom:qa(e,t,n,r[r.length-1].index)+o,top:s}}function qa(e,t,n,r){const o=Lh(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const UC=qe(()=>{const e=ie(h=>`Item ${h}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(Wa),i=ie("div"),a=ie(Pr),l=(h,m=null)=>Mt(ee(t,he(f=>f[h]),at()),m),c=ie(!1),d=ie(!1);return ve(Ee(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),WC=qe(([e,t])=>({...e,...t}),it(HC,UC)),VC=b.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=on("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),h=on("itemDimensions"),m=on("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=on("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Bh("column-gap",getComputedStyle(y).columnGap,f),row:Bh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Eh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Rt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),KC=b.memo(function(){const e=ut("HeaderComponent"),t=on("headerHeight"),n=ut("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),qC=b.memo(function(){const e=ut("FooterComponent"),t=on("footerHeight"),n=ut("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),GC=({children:e})=>{const t=b.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=or(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Rs(!1),children:e})},YC=({children:e})=>{const t=b.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=ut("customScrollParent"),s=Xf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Rs(!1),children:e})},XC=b.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?ZC:JC,o=n||t?YC:GC,s=ut("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(KC,{}),u.jsx(VC,{}),u.jsx(qC,{})]})})}),{useEmitter:Fh,useEmitterValue:ut,usePublisher:on}=Ch(WC,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},XC),JC=_h({useEmitter:Fh,useEmitterValue:ut,usePublisher:on}),ZC=Ph({useEmitter:Fh,useEmitterValue:ut,usePublisher:on});function Bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const QC=zr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function zh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(QC({variant:t}),e),...n})}var Ls="Dialog",[Hh,CN]=un(Ls),[eT,mn]=Hh(Ls),Uh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(eT,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Uh.displayName=Ls;var Wh="DialogTrigger",Vh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Wh,n),s=Fe(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Vh.displayName=Wh;var Ga="DialogPortal",[tT,Kh]=Hh(Ga,{forceMount:void 0}),qh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=mn(Ga,t);return u.jsx(tT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};qh.displayName=Ga;var $s="DialogOverlay",Gh=p.forwardRef((e,t)=>{const n=Kh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(rT,{...o,ref:t})}):null});Gh.displayName=$s;var nT=Yt.createSlot("DialogOverlay.RemoveScroll"),rT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn($s,n);return u.jsx(gs,{as:nT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Yh=p.forwardRef((e,t)=>{const n=Kh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn(ar,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(oT,{...o,ref:t}):u.jsx(sT,{...o,ref:t})})});Yh.displayName=ar;var oT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(null),o=Fe(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Xh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),sT=p.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Xh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=mn(ar,n),l=p.useRef(null),c=Fe(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(iT,{titleId:a.titleId}),u.jsx(lT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Ya,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Jh.displayName=Ya;var Zh="DialogDescription",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Zh,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});Qh.displayName=Zh;var ep="DialogClose",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(ep,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});tp.displayName=ep;function Xa(e){return e?"open":"closed"}var np="DialogTitleWarning",[TN,rp]=Sb(np,{contentName:ar,titleName:Ya,docsSlug:"dialog"}),iT=({titleId:e})=>{const t=rp(np),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},l0=0,jr=[];function c0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(l0++)[0],s=h.useState(Bd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=jy([e.lockRef.current],(e.shards||[]).map(qd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Ud(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Ud(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return s0(R,x,g,R==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Kd(x):ms(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&i0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(qd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:u0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,Kd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:a0(o)}):null,f?h.createElement(Zy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function u0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const d0=Fy(Fd,c0);var gs=h.forwardRef(function(e,t){return h.createElement(ps,Tn({},e,{ref:t,sideCar:d0}))});gs.classNames=ps.classNames;var ga=["Enter"," "],f0=["ArrowDown","PageUp","Home"],Gd=["ArrowUp","PageDown","End"],p0=[...f0,...Gd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},m0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,g0,x0]=Yo(ao),[tr,Yd]=un(ao,[x0,Er,jd]),xs=Er(),Xd=jd(),[v0,nr]=tr(ao),[b0,co]=tr(ao),Jd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=vt(s),m=Xo(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(v0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(b0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Jd.displayName=ao;var w0="MenuAnchor",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=w0;var va="MenuPortal",[y0,Zd]=tr(va,{forceMount:void 0}),Qd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(va,t);return u.jsx(y0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Qd.displayName=va;var nn="MenuContent",[S0,ba]=tr(nn),ef=h.forwardRef((e,t)=>{const n=Zd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(C0,{...o,ref:t}):u.jsx(T0,{...o,ref:t})})})})}),C0=h.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu),r=h.useRef(null),o=Fe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),T0=h.forwardRef((e,t)=>{const n=nr(nn,e.__scopeMenu);return u.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),k0=Yt.createSlot("MenuContent.ScrollLock"),wa=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(nn,n),y=co(nn,n),w=xs(n),S=Xd(n),k=g0(n),[C,T]=h.useState(null),E=h.useRef(null),j=Fe(t,E,x.onContentChange),R=h.useRef(0),L=h.useRef(""),H=h.useRef(0),B=h.useRef(null),q=h.useRef("right"),N=h.useRef(0),z=v?gs:h.Fragment,$=v?{as:k0,allowPinchZoom:!0}:void 0,M=I=>{var W,D;const V=L.current+I,J=k().filter(X=>!X.disabled),_=document.activeElement,O=(W=J.find(X=>X.ref.current===_))==null?void 0:W.textValue,K=J.map(X=>X.textValue),Y=L0(K,V,O),ae=(D=J.find(X=>X.textValue===Y))==null?void 0:D.ref.current;(function X(oe){L.current=oe,window.clearTimeout(R.current),oe!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(V),ae&&setTimeout(()=>ae.focus())};h.useEffect(()=>()=>window.clearTimeout(R.current),[]),Hi();const P=h.useCallback(I=>{var J,_;return q.current===((J=B.current)==null?void 0:J.side)&&F0(I,(_=B.current)==null?void 0:_.area)},[]);return u.jsx(S0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:h.useCallback(I=>{var V;P(I)||((V=E.current)==null||V.focus(),T(null))},[P]),onTriggerLeave:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(I=>{B.current=I},[]),children:u.jsx(z,{...$,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var V;I.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(ky,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":vf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!_&&O&&M(I.key));const K=E.current;if(I.target!==K||!p0.includes(I.key))return;I.preventDefault();const ae=k().filter(W=>!W.disabled).map(W=>W.ref.current);Gd.includes(I.key)&&ae.reverse(),O0(ae)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),L.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const V=I.target,J=N.current!==I.clientX;if(I.currentTarget.contains(V)&&J){const _=I.clientX>N.current?"right":"left";q.current=_,N.current=I.clientX}}))})})})})})})});ef.displayName=nn;var E0="MenuGroup",ya=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});ya.displayName=E0;var I0="MenuLabel",tf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});tf.displayName=I0;var vs="MenuItem",nf="menu.itemSelect",bs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=co(vs,e.__scopeMenu),a=ba(vs,e.__scopeMenu),l=Fe(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(nf,{bubbles:!0,cancelable:!0});p.addEventListener(nf,f=>r==null?void 0:r(f),{once:!0}),Fi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(rf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ce(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||ga.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});bs.displayName=vs;var rf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ba(vs,n),a=Xd(n),l=h.useRef(null),c=Fe(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ey,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>p(!0)),onBlur:ce(e.onBlur,()=>p(!1))})})})}),N0="MenuCheckboxItem",of=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(uf,{scope:e.__scopeMenu,checked:n,children:u.jsx(bs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});of.displayName=N0;var sf="MenuRadioGroup",[A0,j0]=tr(sf,{value:void 0,onValueChange:()=>{}}),af=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return u.jsx(A0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});af.displayName=sf;var lf="MenuRadioItem",cf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=j0(lf,e.__scopeMenu),s=n===o.value;return u.jsx(uf,{scope:e.__scopeMenu,checked:s,children:u.jsx(bs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});cf.displayName=lf;var Sa="MenuItemIndicator",[uf,_0]=tr(Sa,{checked:!1}),df=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=_0(Sa,n);return u.jsx(Wt,{present:r||ws(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":Ca(s.checked)})})});df.displayName=Sa;var P0="MenuSeparator",ff=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ff.displayName=P0;var R0="MenuArrow",pf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});pf.displayName=R0;var M0="MenuSub",[yN,hf]=tr(M0),uo="MenuSubTrigger",mf=h.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=ba(uo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(rf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||h0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});mf.displayName=uo;var gf="MenuSubContent",xf=h.forwardRef((e,t)=>{const n=Zd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(gf,e.__scopeMenu),l=h.useRef(null),c=Fe(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(wa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=m0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});xf.displayName=gf;function vf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Ca(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function O0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function D0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function L0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=D0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function $0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function F0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return $0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var B0=Jd,z0=xa,H0=Qd,U0=ef,W0=ya,V0=tf,K0=bs,q0=of,G0=af,Y0=cf,X0=df,J0=ff,Z0=pf,Q0=mf,eS=xf,ys="DropdownMenu",[tS,SN]=un(ys,[Yd]),$t=Yd(),[nS,bf]=tS(ys),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=$t(t),c=h.useRef(null),[d,p]=Ln({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(nS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(B0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};wf.displayName=ys;var yf="DropdownMenuTrigger",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(yf,n),i=$t(n);return u.jsx(z0,{asChild:!0,...i,children:u.jsx(me.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Dn(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sf.displayName=yf;var rS="DropdownMenuPortal",Cf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=$t(t);return u.jsx(H0,{...r,...n})};Cf.displayName=rS;var Tf="DropdownMenuContent",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Tf,n),s=$t(n),i=h.useRef(!1);return u.jsx(U0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kf.displayName=Tf;var oS="DropdownMenuGroup",sS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(W0,{...o,...r,ref:t})});sS.displayName=oS;var iS="DropdownMenuLabel",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuItem",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuCheckboxItem",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(q0,{...o,...r,ref:t})});Nf.displayName=lS;var cS="DropdownMenuRadioGroup",uS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(G0,{...o,...r,ref:t})});uS.displayName=cS;var dS="DropdownMenuRadioItem",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuItemIndicator",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var pS="DropdownMenuSeparator",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(J0,{...o,...r,ref:t})});_f.displayName=pS;var hS="DropdownMenuArrow",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Z0,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuSubTrigger",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=gS;var xS="DropdownMenuSubContent",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=$t(n);return u.jsx(eS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Rf.displayName=xS;var vS=wf,bS=Sf,wS=Cf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf,Hf=Rf;const Ss=vS,Cs=bS,yS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));yS.displayName=zf.displayName;const SS=h.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));SS.displayName=Hf.displayName;const po=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(wS,{children:u.jsx(Mf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));po.displayName=Mf.displayName;const zn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));zn.displayName=Df.displayName;const CS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lf,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));CS.displayName=Lf.displayName;const TS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($f,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));TS.displayName=$f.displayName;const kS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));kS.displayName=Of.displayName;const ES=h.forwardRef(({className:e,...t},n)=>u.jsx(Bf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));ES.displayName=Bf.displayName;const Ta=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ta.displayName="Textarea";const IS=1e4;function Uf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=IS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,w]=b.useState(e),S=(x?i:y)??"",[k,C]=b.useTransition(),T=b.useRef(null),E=b.useRef(0),j=b.useRef(null),R=b.useRef("");b.useEffect(()=>{x||(w(e??""),j.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,H]=b.useState(null),B=b.useCallback(O=>O.length>s?`Message too long (${O.length}/${s} characters)`:null,[s]),q=b.useMemo(()=>v??B,[v,B]),N=b.useCallback(O=>{const K=q(O);return H(K),g==null||g(K),R.current=O,K},[q,g]),z=b.useCallback(()=>{const O=T.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);b.useEffect(()=>{z()},[z,S]),b.useEffect(()=>{if(!L)return;const O=(S??"").trim();R.current!==O&&N(O)},[S,L,N]);const $=b.useCallback((O,{fromUser:K})=>{x||w(O),K&&(a==null||a(O))},[x,a]),M=b.useCallback(async O=>{O&&O.preventDefault();const K=(S??"").trim();if(!K&&!f||N(K))return;const Y=++E.current;j.current={id:Y,shouldClear:!0},C(()=>{var ae,W,D;try{const X=l(K);X&&typeof X.then=="function"?X.then(()=>{var oe,G;((oe=j.current)==null?void 0:oe.id)===Y&&j.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((G=j.current)==null?void 0:G.id)===Y&&(j.current=null)}).catch(()=>{var oe;((oe=j.current)==null?void 0:oe.id)===Y&&(j.current=null)}):(((ae=j.current)==null?void 0:ae.id)===Y&&j.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=j.current)==null?void 0:W.id)===Y&&(j.current=null))}catch{((D=j.current)==null?void 0:D.id)===Y&&(j.current=null)}})},[S,l,f,x,a,N]),P=b.useCallback(O=>{const K=O.target.value;$(K,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&N(K.trim())},[$,N,L]),I=b.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),M()):O.key==="Escape"&&t&&(O.preventDefault(),c==null||c())},[M,t,c]),_=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:O=>void M(O),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:P,onKeyDown:I,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(de.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(de.Send,{size:16})})})]})})}const NS=b.memo(Uf),Ts=0,Hn=1,_r=2,Wf=4;function Vf(e){return()=>e}function AS(e){e()}function Kf(e,t){return n=>e(t(n))}function qf(e,t){return()=>e(t)}function jS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function _S(...e){return()=>{e.map(AS)}}function Pr(){}function ks(e,t){return t(e),e}function PS(e,t){return t(e)}function it(...e){return e}function Ze(e,t){return e(Hn,t)}function De(e,t){e(Ts,t)}function Ea(e){e(_r)}function bt(e){return e(Wf)}function ve(e,t){return Ze(e,jS(t,Ts))}function pn(e,t){const n=e(Hn,r=>{n(),t(r)});return n}function Gf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Yf(e,t){return e===t}function at(e=Yf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function pe(e){return t=>Kf(t,e)}function kn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=RS(...t);return(r,o)=>{switch(r){case _r:Ea(e);return;case Hn:return Ze(e,n(o))}}}function En(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Be(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function RS(...e){return t=>e.reduceRight(PS,t)}function MS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Hn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Pr);case _r:r(),n=null;return}}}function ie(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case Hn:{o(t);break}case Wf:return t}return n(r,o)}}function Rt(e,t){return ks(ie(t),n=>ve(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Hn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>ve(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:OS(),singleton:n}}const OS=()=>Symbol();function DS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function yt(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&De(t,n)})}),function(s,i){switch(s){case _r:{Ea(t);return}case Hn:return r===o&&i(n),Ze(t,i)}}}function Ee(e,t=Yf){return ee(e,at(t))}function Ia(...e){return function(t,n){switch(t){case _r:return;case Hn:return _S(...e.map(r=>Ze(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const LS={0:"debug",3:"error",1:"log",2:"warn"},$S=()=>typeof globalThis>"u"?window:globalThis,Un=qe(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=$S().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[LS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Na(e,t,n).callbackRef}function Na(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function FS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=BS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Xf("column-gap",getComputedStyle(d).columnGap,o):Xf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function BS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Xf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Jf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ft=qe(()=>{const e=We(),t=We(),n=ie(0),r=We(),o=ie(0),s=We(),i=We(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),p=We(),m=We(),f=ie(!1),v=ie(!1),g=ie(!1);return ve(ee(e,pe(({scrollTop:x})=>x)),t),ve(ee(e,pe(({scrollHeight:x})=>x)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),ho={lvl:0};function Zf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===ho}function mo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function hn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=hn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return hn(e.l,t,n)}function tn(e,t,n){return ot(e)?tp(t,n,1):t===e.k?Ct(e,{k:t,v:n}):t<e.k?np(Ct(e,{l:tn(e.l,t,n)})):np(Ct(e,{r:tn(e.r,t,n)}))}function Rr(){return ho}function Es(e,t,n){if(ot(e))return[];const r=hn(e,t)[0];return zS(ja(e,r,n))}function Aa(e,t){if(ot(e))return ho;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=ep(r);return Is(Ct(e,{k:s,l:Qf(r),v:i}))}}else return t<n?Is(Ct(e,{l:Aa(r,t)})):Is(Ct(e,{r:Aa(o,t)}))}function sr(e){return ot(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function ja(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ja(s,t,n))),a}function Is(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(_a(t))return rp(Ct(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return Ct(t.r,{l:Ct(t,{r:t.r.l}),lvl:n,r:Ct(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(Ct(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return Ct(o,{l:Ct(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(Ct(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Ct(e,t){return tp(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Qf(e){return ot(e.r)?e.l:Is(Ct(e,{r:Qf(e.r)}))}function _a(e){return ot(e)||e.lvl>e.r.lvl}function ep(e){return ot(e.r)?[e.k,e.v]:ep(e.r)}function tp(e,t,n,r=ho,o=ho){return{k:e,l:r,lvl:n,r:o,v:t}}function np(e){return Pa(rp(e))}function rp(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?Ct(t,{r:Ct(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?Ct(n,{l:Ct(e,{r:n.l}),lvl:t+1}):e}function zS(e){return Zf(e,({k:t,v:n})=>({index:t,value:n}))}function op(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ra=qe(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function sp(e,t,n){return e[Ns(e,t,n)]}function Ns(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function HS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!ot(e.groupOffsetTree)}function Ma({index:e},t){return t===e?0:t<e?-1:1}function US(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function WS(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(JS(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Aa(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function VS(e){return typeof e.groupIndex<"u"}function KS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=sp(t,e,Ma),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ip(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ap(e,t,n){if(VS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ip(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function qS(e,t,n,r=0){return r>0&&(t=Math.max(t,sp(e,r,Ma).offset)),Zf(HS(e,t,n,KS),XS)}function GS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=WS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,p,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function YS(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function lp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ma),a=o[l].offset;const c=hn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function XS(e){return{index:e.index,value:e}}function JS(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const ZS={offsetHeight:"height",offsetWidth:"width"},In=qe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Rt(r,0),s=We(),i=We(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),p=ie((C,T)=>Wn(C,ZS[T])),m=ie(void 0),f=ie(0),v=US(),g=Rt(ee(n,Be(l,e,f),En(GS,v),at()),v),x=Rt(ee(l,at(),En((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),pe(({prev:C})=>C)),[]);ve(ee(l,Ne(C=>C.length>0),Be(g,f),pe(([C,T,E])=>{const j=C.reduce((R,L,H)=>tn(R,L,xo(L,T.offsetTree,E)||H),Rr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),ve(ee(r,Be(g),Ne(([C,{lastIndex:T}])=>C<T),pe(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ve(c,d);const y=Rt(ee(c,pe(C=>C===void 0)),!0);ve(ee(d,Ne(C=>C!==void 0&&ot(bt(g).sizeTree)),pe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=en(ee(n,Be(g),En(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),pe(C=>C.changed)));Ze(ee(a,En((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),pe(C=>C.diff)),C=>{const{groupIndices:T}=bt(g);if(C>0)De(t,!0),De(s,C+lp(C,T));else if(C<0){const E=bt(x);E.length>0&&(C-=lp(-C,E)),De(i,C)}}),Ze(ee(a,Be(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=en(s);ve(ee(s,Be(g),pe(([C,T])=>{const E=T.groupIndices.length>0,j=[],R=T.lastSize;if(E){const L=mo(T.sizeTree,0);let H=0,B=0;for(;H<C;){const N=T.groupIndices[B],z=T.groupIndices.length===B+1?1/0:T.groupIndices[B+1]-N-1;j.push({endIndex:N,size:L,startIndex:N}),j.push({endIndex:N+1+z-1,size:R,startIndex:N+1}),B++,H+=z+1}const q=sr(T.sizeTree);return H!==C&&q.shift(),q.reduce((N,{k:z,v:$})=>{let M=N.ranges;return N.prevSize!==0&&(M=[...N.ranges,{endIndex:z+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:z+C,prevSize:$,ranges:M}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((L,{k:H,v:B})=>({prevIndex:H+C,prevSize:B,ranges:[...L.ranges,{endIndex:H+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=en(ee(i,Be(g,f),pe(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return ve(ee(i,Be(g,f),pe(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let j=Rr();const R=bt(x);let L=0,H=0,B=0;for(;L<-C;){B=R[H];const q=R[H+1]-B-1;H++,L+=q+1}if(j=sr(T.sizeTree).reduce((q,{k:N,v:z})=>tn(q,Math.max(0,N+C),z),j),L!==-C){const q=mo(T.sizeTree,B);j=tn(j,0,q);const N=hn(T.sizeTree,-C+1)[1];j=tn(j,1,N)}return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((R,{k:L,v:H})=>tn(R,Math.max(0,L+C),H),Rr());return{...T,sizeTree:j,...Oa(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(Un,Ra),{singleton:!0});function QS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const cp=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,pe(QS)));return ve(ee(a,pe(l=>l.totalCount)),n),ve(ee(a,pe(l=>l.groupIndices)),e),ve(ee(yt(o,t,r),Ne(([l,c])=>As(c)),pe(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),pe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(In,Ft)),Vn=qe(([{log:e}])=>{const t=ie(!1),n=en(ee(t,Ne(r=>r),at()));return Ze(t,r=>{r&&bt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},it(Un),{singleton:!0}),eC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function up(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!eC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=We(),v=We(),g=ie(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),De(l,!1)}return ve(ee(f,Be(n,p,r,g,a,i,m),Be(e,s,o),pe(([[k,C,T,E,j,R,L,H],B,q,N])=>{const z=up(k),{align:$,behavior:M,offset:P}=z,I=E-1,V=ap(z,C,I);let J=xo(V,C.offsetTree,B)+R;$==="end"?(J+=q+hn(C.sizeTree,V)[1]-T+N,V===I&&(J+=L)):$==="center"?J+=(q+hn(C.sizeTree,V)[1]-T+N)/2:J-=j,P&&(J+=P);const _=O=>{S(),O?(H("retrying to scroll to",{location:k},Vt.DEBUG),De(f,k)):(De(v,!0),H("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),M==="smooth"){let O=!1;w=Ze(t,K=>{O=O||K}),x=pn(d,()=>{_(O)})}else x=pn(ee(t,tC(150)),_);return y=setTimeout(()=>{S()},1200),De(l,!0),H("scrolling from index to",{behavior:M,index:V,top:J},Vt.DEBUG),{behavior:M,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},it(In,Ft,Un),{singleton:!0});function tC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ve(ee(i,Be(l),Ne(([d,p])=>!!p),kn(!1)),a),ve(ee(i,Be(l),Ne(([d,p])=>!!p),kn(!1)),c),Ze(ee(yt(t,i),Be(a,n,e,c),Ne(([[,d],p,{sizeTree:m},f,v])=>d&&(!ot(m)||ka(f))&&!p&&!v),Be(l)),([,d])=>{pn(o,()=>{De(c,!0)}),Da(4,()=>{pn(r,()=>{De(a,!0)}),De(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(In,Ft,vo,Vn),{singleton:!0});function dp(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",nC="none",rC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},oC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=We(),c=We(),d=ie(4),p=ie(oC),m=Rt(ee(Ia(ee(Ee(o),rr(1),kn(!0)),ee(Ee(o),rr(1),kn(!1),Gf(100))),at()),!1),f=Rt(ee(Ia(ee(n,kn(!0)),ee(n,kn(!1),Gf(200))),at()),!1);ve(ee(yt(Ee(o),Ee(p)),pe(([w,S])=>w<=S),at()),a),ve(ee(a,_n(50)),c);const v=en(ee(yt(r,Ee(s),Ee(t),Ee(e),Ee(d)),En((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const R=k+C-S>-j,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let B,q;return k>w.state.scrollTop?(B="SCROLLED_DOWN",q=w.state.scrollTop-k):(B="SIZE_DECREASED",q=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:q,state:L}}let H;return L.scrollHeight>w.state.scrollHeight?H="SIZE_INCREASED":C<w.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},rC),at((w,S)=>w&&w.atBottom===S.atBottom))),g=Rt(ee(r,En((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(dp(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(w=>w.changed),pe(w=>w.jump)),0);ve(ee(v,pe(w=>w.atBottom)),i),ve(ee(i,_n(50)),l);const x=ie(yo);ve(ee(r,pe(({scrollTop:w})=>w),at(),En((w,S)=>bt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),pe(w=>w.direction)),x),ve(ee(r,_n(50),kn(nC)),x);const y=ie(0);return ve(ee(m,Ne(w=>!w),kn(0)),y),ve(ee(o,_n(100),Be(m),Ne(([w,S])=>!!S),En(([w,S],[k])=>[S,k],[0,0]),pe(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Ft)),js="top",_s="bottom",fp="none";function pp(e,t,n){return typeof e=="number"?n===wo&&t===js||n===yo&&t===_s?e:0:n===wo?t===js?e.main:e.reverse:t===_s?e.main:e.reverse}function hp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=ie(0),a=ie(0),l=ie(0),c=Rt(ee(yt(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),pe(([d,p,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=fp;const j=hp(S,js),R=hp(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-j&&(E=wo),v<d-T+p+R&&(E=yo),E!==fp?[Math.max(k-m-pp(g,js,E)-j,0),k-T-y+p+pp(g,_s,E)+R]:null}),Ne(d=>d!=null),at(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Ft),{singleton:!0});function sC(e,t,n){if(As(t)){const r=ip(e,t);return[{index:hn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Fa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ps(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:gp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:gp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function mp(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=La(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ps(c,[],a,o,n,r)}function gp(e,t,n){if(e.length===0)return[];if(!As(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=ie([]),x=ie(0),y=We();ve(s.topItemsIndexes,g);const w=Rt(ee(yt(f,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,E,,j,,,,,,,R])=>{const L=R&&R.length!==j;return T&&!E&&!L}),pe(([,,[T,E],j,R,L,H,B,q,N,z])=>{const $=R,{offsetTree:M,sizeTree:P}=$,I=bt(x);if(j===0)return{...Fa,totalCount:j};if(T===0&&E===0)return I===0?{...Fa,totalCount:j}:mp(I,L,R,q,N,z||[]);if(ot(P))return I>0?null:Ps(sC(La(L,j),$,z),[],j,N,$,q);const V=[];if(B.length>0){const Y=B[0],ae=B[B.length-1];let W=0;for(const D of Es(P,Y,ae)){const X=D.value,oe=Math.max(D.start,Y),G=Math.min(D.end,ae);for(let Z=oe;Z<=G;Z++)V.push({data:z==null?void 0:z[Z],index:Z,offset:W,size:X}),W+=X}}if(!H)return Ps([],V,j,N,$,q);const J=B.length>0?B[B.length-1]+1:0,_=qS(M,T,E,J);if(_.length===0)return null;const O=j-1,K=ks([],Y=>{for(const ae of _){const W=ae.value;let D=W.offset,X=ae.start;const oe=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+N)/(oe+N));const Z=X-ae.start;D+=Z*oe+Z*N}X<J&&(D+=(J-X)*oe,X=J);const G=Math.min(ae.end,O);for(let Z=X;Z<=G&&!(D>=E);Z++)Y.push({data:z==null?void 0:z[Z],index:Z,offset:D,size:oe}),D+=oe+N}});return Ps(K,V,j,N,$,q)}),Ne(T=>T!==null),at()),Fa);ve(ee(e,Ne(ka),pe(T=>T==null?void 0:T.length)),o),ve(ee(w,pe(T=>T.topListHeight)),p),ve(p,a),ve(ee(w,pe(T=>[T.top,T.bottom])),i),ve(ee(w,pe(T=>T.items)),y);const S=en(ee(w,Ne(({items:T})=>T.length>0),Be(o,e),Ne(([{items:T},E])=>T[T.length-1].originalIndex===E-1),pe(([,T,E])=>[T-1,E]),at(go),pe(([T])=>T))),k=en(ee(w,_n(200),Ne(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),pe(({items:T})=>T[0].index),at())),C=en(ee(w,Ne(({items:T})=>T.length>0),pe(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),at(op)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},it(In,cp,$a,bo,vo,So,Vn,Ra),{singleton:!0}),xp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Rt(ee(yt(n,e,r,t,o),pe(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ve(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Ft,ir),{singleton:!0}),iC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Rt(ee(yt(n,e,t),Ne(([o])=>o),pe(([,o,s])=>Math.max(0,o-s)),_n(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Ft,xp),{singleton:!0}),vp=qe(()=>({context:ie(null)})),aC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,bp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return ve(ee(d,Be(t,l,n,s,o,r,a),Be(e),pe(([[p,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=aC,done:E,...j}=p,R=ap(p,m,v-1),L=xo(R,m.offsetTree,S)+g+x,H=L+hn(m.sizeTree,R)[1],B=w+x,q=w+f-y,N=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:C,...j},viewportBottom:q,viewportTop:B});return N?E&&pn(ee(i,Ne(z=>!z),rr(bt(i)?1:2)),E):E&&E(),N}),Ne(p=>p!==null)),c),{scrollIntoView:d}},it(In,Ft,vo,ir,Un),{singleton:!0});function wp(e){return e?e==="smooth"?"smooth":"auto":!1}const lC=(e,t)=>typeof e=="function"?wp(e(t)):t&&wp(e),cC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=ie(!1),g=We();let x=null;function y(C){De(i,{align:"end",behavior:C,index:"LAST"})}Ze(ee(yt(ee(Ee(t),rr(1)),l),Be(Ee(v),s,a,p),pe(([[C,T],E,j,R,L])=>{let H=T&&R,B="auto";return H&&(B=lC(E,j||L),H=H&&!!B),{followOutputBehavior:B,shouldFollow:H,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=pn(e,()=>{bt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function w(C){const T=pn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(ee(yt(Ee(v),t,c),Ne(([C,,T])=>C&&T),En(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),Be(v,t)),([,C])=>{bt(a)&&w(C!==!1)}),Ze(g,()=>{w(bt(v)!==!1)}),Ze(yt(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=ie(null),k=We();return ve(Ia(ee(Ee(r),pe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ee(t))),k),Ze(ee(yt(ee(k,rr(1)),l),Be(Ee(S),a,p,m),pe(([[C,T],E,j,R,L])=>T&&j&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:R}))),Ne(C=>!!C),_n(0)),C=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),De(f,C)}):x=pn(e,()=>{bt(d)("scrolling into view",{}),De(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},it(In,So,vo,bo,Vn,Un,Ft,vp,bp)),uC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(ee(a,Be(s),Ne(([,l])=>l!==0),Be(o,r,t,n,e),pe(([[,l],c,d,p,m,f=[]])=>mp(l,c,d,p,m,f))),i),{}),it(In,bo,ir,Vn),{singleton:!0}),dC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Ze(ee(e,Be(r),Ne(([,o])=>o!==0),pe(([,o])=>({top:o}))),o=>{pn(ee(n,rr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{De(t,o)})})}),{initialScrollTop:r}},it(Vn,Ft,ir),{singleton:!0}),yp=qe(([{scrollVelocity:e}])=>{const t=ie(!1),n=We(),r=ie(!1);return ve(ee(e,Be(r,t,n),Ne(([o,s])=>!!s),pe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Ze(ee(yt(t,e,n),Be(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=ie(!1),i=ie(void 0);return ve(ee(yt(n,r),pe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(ee(t,Be(r),pe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Ft)),fC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=ie(void 0),p=ie(null),m=ie(null);return ve(a,p),ve(l,m),Ze(ee(c,Be(t,r,i,p,m,n)),([f,v,g,x,y,w,S])=>{const k=YS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ve(ee(d,Ne(ka),pe(pC)),o),ve(ee(s,Be(d),Ne(([,f])=>f!==void 0),at(),pe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(In,Ft,bo,Vn,Ba));function pC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=qe(([{topItemsIndexes:e}])=>{const t=ie(0);return ve(ee(t,Ne(n=>n>=0),pe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ir));function Sp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const mC=Sp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),gC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(ee(l,Be(i),En(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const R=k+T;let L=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=R-S,L!==0&&(L+=j))),[L,C,E,R]},[0,[],0,0]),Ne(([y])=>y!==0),Be(r,a,n,o,f,v),Ne(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),pe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(De(t,{behavior:"auto",top:-y}),De(e,0)):(De(e,0),De(t,{behavior:"auto",top:-y}))}return Ze(ee(g,Be(e,s)),([y,w,S])=>{S&&mC()?De(e,w-y):x(-y)}),Ze(ee(yt(Rt(s,!1),e,v),Ne(([y,w,S])=>!y&&!S&&w!==0),pe(([y,w])=>w),_n(1)),x),ve(ee(p,pe(y=>({top:-y}))),t),Ze(ee(c,Be(m,d),pe(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=mo(k,0);let R=0,L=0;for(;R<y;){R++,E+=j;let H=w.length===L+1?1/0:w[L+1]-w[L]-1;R+H>y&&(E-=j,H=y-R+1),R+=H,E+=T(H),L++}return E}})),y=>{De(e,y),requestAnimationFrame(()=>{De(t,{top:y}),requestAnimationFrame(()=>{De(e,0),De(v,!1)})})}),{deviation:e}},it(Ft,So,ir,In,Un,Ra)),xC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it($a,uC,Vn,yp,xp,dC,iC,Ba,bp,Un,vp)),Cp=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},R])=>(ve(k.rangeChanged,R.scrollSeekRangeChanged),ve(ee(R.windowViewportRect,pe(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...R,...g,sizes:l,...x}),it(In,bo,Ft,fC,cC,ir,vo,gC,hC,cp,xC));function vC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Rs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Tp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(x,y){x.propsReady&&De(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];De(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];De(S,y[w])}x.propsReady&&De(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];De(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=MS(x[t.events[w]]),y),{})}const p=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ks(DS(e),E=>{l(E,S)})),[C]=b.useState(qf(d,k));Rs(()=>{for(const E of i)E in S&&Ze(C[E],S[E]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Rs(()=>{l(k,S)}),b.useImperativeHandle(y,Vf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...vC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{De(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Ze(y,S),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(qf(bt,y));return Rs(()=>Ze(y,k=>{k!==w&&S(Vf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Rs(()=>Ze(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const kp=b.createContext(void 0),Ep=b.createContext(void 0),Ip=typeof document<"u"?b.useLayoutEffect:b.useEffect;function za(e){return"self"in e}function bC(e){return"body"in e}function Np(e,t,n,r=Pr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(bC(x)||za(x)){const w=za(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Po.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;za(f)?(x=Math.max(Wn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Wn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),dp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Ap="sticky",Ua=Sp(()=>{if(typeof document>"u")return Ap;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Ap});function Wa(e){return e}const wC=qe(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie(Wa),o=ie("div"),s=ie(Pr),i=(a,l=null)=>Rt(ee(n,pe(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),yC=qe(([e,t])=>({...e,...t}),it(Cp,wC)),SC=({height:e})=>u.jsx("div",{style:{height:e}}),CC={overflowAnchor:"none",position:Ua(),zIndex:1},jp={overflowAnchor:"none"},TC={...jp,display:"inline-block",height:"100%"},_p=b.memo(function({showTopList:e=!1}){const t=je("listState"),n=rn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),p=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=rn("gap"),g=je("horizontalDirection"),{callbackRef:x}=FS(n,m,p,e?Pr:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Va("deviation",N=>{y!==N&&w(N)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||SC,C=je("ListComponent"),T=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),R=je("isSeeking"),L=je("groupIndices").length>0,H=je("alignToBottom"),B=je("initialItemFinalLocationReached"),q=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Mt(S,c)}):u.jsx(C,{...Mt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:q,children:(e?t.topItems:t.items).map(N=>{const z=N.originalIndex,$=j(z+t.firstItemIndex,N.data,c);return R?b.createElement(k,{...Mt(k,c),height:N.size,index:N.index,key:$,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?b.createElement(E,{...Mt(E,c),"data-index":z,"data-item-index":N.index,"data-known-size":N.size,key:$,style:CC},d(N.index,c)):b.createElement(T,{...Mt(T,c),...NC(T,N.data),"data-index":z,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:$,style:g?TC:jp},L?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),kC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},EC={outline:"none",overflowX:"auto",position:"relative"},Ms=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),IC={position:Ua(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function NC(e,t){return{item:typeof e=="string"?void 0:t}}const AC=b.memo(function(){const e=je("HeaderComponent"),t=rn("headerHeight"),n=je("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),jC=b.memo(function(){const e=je("FooterComponent"),t=rn("footerHeight"),n=je("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Pp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Np(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?EC:kC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Rp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Np(a,c,l,v,m);return Ip(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Mt(l,s),children:r})})}const _C=({children:e})=>{const t=b.useContext(kp),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=b.useMemo(()=>Kf(n,l=>Wn(l,s?"width":"height")),[n,s]),a=or(i,!0,je("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ms(o),children:e})},PC=({children:e})=>{const t=b.useContext(kp),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=je("customScrollParent"),s=Jf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Ms(i),children:e})},RC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...IC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},MC=b.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?LC:DC,{...e,context:o,children:[n&&u.jsx(RC,{children:u.jsx(_p,{showTopList:!0})}),u.jsxs(r||t?PC:_C,{children:[u.jsx(AC,{}),u.jsx(_p,{}),u.jsx(jC,{})]})]})}),{Component:OC,useEmitter:Va,useEmitterValue:je,usePublisher:rn}=Tp(yC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},MC),DC=Pp({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),LC=Rp({useEmitter:Va,useEmitterValue:je,usePublisher:rn}),$C=OC;it(Cp,qe(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie(Wa),a=ie(Pr),l=(c,d=null)=>Rt(ee(s,pe(p=>p[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Ua();const Mp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},FC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Op,floor:Os,max:Co,min:Ka,round:Dp}=Math;function Lp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function BC(e){return{...FC,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function zC(e,t){return e&&e.column===t.column&&e.row===t.row}const HC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=ie(0),E=ie(0),j=ie(Mp),R=ie({height:0,width:0}),L=ie({height:0,width:0}),H=We(),B=We(),q=ie(0),N=ie(null),z=ie({column:0,row:0}),$=We(),M=We(),P=ie(!1),I=ie(0),V=ie(!0),J=ie(!1),_=ie(!1);Ze(ee(v,Be(I),Ne(([D,X])=>!!X)),()=>{De(V,!1)}),Ze(ee(yt(v,V,L,R,I,J),Ne(([D,X,oe,G,,Z])=>D&&!X&&oe.height!==0&&G.height!==0&&!Z)),([,,,,D])=>{De(J,!0),Da(1,()=>{De(H,D)}),pn(ee(c),()=>{De(t,[0,0]),De(V,!0)})}),ve(ee(M,Ne(D=>D!=null&&D.scrollTop>0),kn(0)),E),Ze(ee(v,Be(M),Ne(([,D])=>D!=null)),([,D])=>{D&&(De(R,D.viewport),De(L,D.item),De(z,D.gap),D.scrollTop>0&&(De(P,!0),pn(ee(c,rr(1)),X=>{De(P,!1)}),De(l,{top:D.scrollTop})))}),ve(ee(R,pe(({height:D})=>D)),p),ve(ee(yt(Ee(R,Ds),Ee(L,Ds),Ee(z,(D,X)=>D&&D.column===X.column&&D.row===X.row),Ee(c)),pe(([D,X,oe,G])=>({gap:oe,item:X,scrollTop:G,viewport:D}))),$),ve(ee(yt(Ee(T),r,Ee(z,zC),Ee(L,Ds),Ee(R,Ds),Ee(N),Ee(E),Ee(P),Ee(V),Ee(I)),Ne(([,,,,,,,D])=>!D),pe(([D,[X,oe],G,Z,te,se,ue,,ge,Me])=>{const{column:Oe,row:Te}=G,{height:nt,width:pt}=Z,{width:Tt}=te;if(ue===0&&(D===0||Tt===0))return Mp;if(pt===0){const kt=La(Me,D),wt=kt+Math.max(ue-1,0);return BC(Lp(kt,wt,se))}const Ke=$p(Tt,pt,Oe);let Ge,Ve;ge?X===0&&oe===0&&ue>0?(Ge=0,Ve=ue-1):(Ge=Ke*Os((X+Te)/(nt+Te)),Ve=Ke*Op((oe+Te)/(nt+Te))-1,Ve=Ka(D-1,Co(Ve,Ke-1)),Ge=Ka(Ve,Co(0,Ge))):(Ge=0,Ve=-1);const $e=Lp(Ge,Ve,se),{bottom:He,top:mt}=Fp(te,G,Z,$e),Dt=Op(D/Ke),lt=Dt*nt+(Dt-1)*Te-He;return{bottom:He,itemHeight:nt,items:$e,itemWidth:pt,offsetBottom:lt,offsetTop:mt,top:mt}})),j),ve(ee(N,Ne(D=>D!==null),pe(D=>D.length)),T),ve(ee(yt(R,L,j,z),Ne(([D,X,{items:oe}])=>oe.length>0&&X.height!==0&&D.height!==0),pe(([D,X,{items:oe},G])=>{const{bottom:Z,top:te}=Fp(D,G,X,oe);return[te,Z]}),at(go)),t);const O=ie(!1);ve(ee(c,Be(O),pe(([D,X])=>X||D!==0)),O);const K=en(ee(yt(j,T),Ne(([{items:D}])=>D.length>0),Be(O),Ne(([[D,X],oe])=>{const G=D.items[D.items.length-1].index===X-1;return(oe||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&G}),pe(([[,D]])=>D-1),at())),Y=en(ee(Ee(j),Ne(({items:D})=>D.length>0&&D[0].index===0),kn(0),at())),ae=en(ee(Ee(j),Be(P),Ne(([{items:D},X])=>D.length>0&&!X),pe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),at(op),_n(0)));ve(ae,f.scrollSeekRangeChanged),ve(ee(H,Be(R,L,T,z),pe(([D,X,oe,G,Z])=>{const te=up(D),{align:se,behavior:ue,offset:ge}=te;let Me=te.index;Me==="LAST"&&(Me=G-1),Me=Co(0,Me,Ka(G-1,Me));let Oe=qa(X,Z,oe,Me);return se==="end"?Oe=Dp(Oe-X.height+oe.height):se==="center"&&(Oe=Dp(Oe-X.height/2+oe.height/2)),ge&&(Oe+=ge),{behavior:ue,top:Oe}})),l);const W=Rt(ee(j,pe(D=>D.offsetBottom+D.bottom)),0);return ve(ee(k,pe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:x,data:N,deviation:q,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:M,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:W,...m,endReached:K,propsReady:g,rangeChanged:ae,startReached:Y,stateChanged:$,stateRestoreInProgress:P,...C}},it($a,Ft,So,yp,Vn,Ba,Un));function $p(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function Fp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=qa(e,t,n,r[0].index);return{bottom:qa(e,t,n,r[r.length-1].index)+o,top:s}}function qa(e,t,n,r){const o=$p(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const UC=qe(()=>{const e=ie(p=>`Item ${p}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie(Wa),i=ie("div"),a=ie(Pr),l=(p,m=null)=>Rt(ee(t,pe(f=>f[p]),at()),m),c=ie(!1),d=ie(!1);return ve(Ee(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),WC=qe(([e,t])=>({...e,...t}),it(HC,UC)),VC=b.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=on("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),p=on("itemDimensions"),m=on("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=on("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();p({height:k,width:C})}m({column:zp("column-gap",getComputedStyle(y).columnGap,f),row:zp("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Ip(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),KC=b.memo(function(){const e=ut("HeaderComponent"),t=on("headerHeight"),n=ut("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),qC=b.memo(function(){const e=ut("FooterComponent"),t=on("footerHeight"),n=ut("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),GC=({children:e})=>{const t=b.useContext(Ep),n=on("itemDimensions"),r=on("viewportDimensions"),o=or(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Ms(!1),children:e})},YC=({children:e})=>{const t=b.useContext(Ep),n=on("windowViewportRect"),r=on("itemDimensions"),o=ut("customScrollParent"),s=Jf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Ms(!1),children:e})},XC=b.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?ZC:JC,o=n||t?YC:GC,s=ut("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(KC,{}),u.jsx(VC,{}),u.jsx(qC,{})]})})}),{useEmitter:Bp,useEmitterValue:ut,usePublisher:on}=Tp(WC,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},XC),JC=Pp({useEmitter:Bp,useEmitterValue:ut,usePublisher:on}),ZC=Rp({useEmitter:Bp,useEmitterValue:ut,usePublisher:on});function zp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const QC=zr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Hp({className:e,variant:t,...n}){return u.jsx("div",{className:ne(QC({variant:t}),e),...n})}var Ls="Dialog",[Up,TN]=un(Ls),[eT,mn]=Up(Ls),Wp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(eT,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Wp.displayName=Ls;var Vp="DialogTrigger",Kp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Vp,n),s=Fe(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Kp.displayName=Vp;var Ga="DialogPortal",[tT,qp]=Up(Ga,{forceMount:void 0}),Gp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=mn(Ga,t);return u.jsx(tT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Gp.displayName=Ga;var $s="DialogOverlay",Yp=h.forwardRef((e,t)=>{const n=qp($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(rT,{...o,ref:t})}):null});Yp.displayName=$s;var nT=Yt.createSlot("DialogOverlay.RemoveScroll"),rT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn($s,n);return u.jsx(gs,{as:nT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Xp=h.forwardRef((e,t)=>{const n=qp(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=mn(ar,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(oT,{...o,ref:t}):u.jsx(sT,{...o,ref:t})})});Xp.displayName=ar;var oT=h.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=h.useRef(null),o=Fe(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Jp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),sT=h.forwardRef((e,t)=>{const n=mn(ar,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Jp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=mn(ar,n),l=h.useRef(null),c=Fe(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(iT,{titleId:a.titleId}),u.jsx(lT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Zp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Ya,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Zp.displayName=Ya;var Qp="DialogDescription",eh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(Qp,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});eh.displayName=Qp;var th="DialogClose",nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=mn(th,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});nh.displayName=th;function Xa(e){return e?"open":"closed"}var rh="DialogTitleWarning",[kN,oh]=Sb(rh,{contentName:ar,titleName:Ya,docsSlug:"dialog"}),iT=({titleId:e})=>{const t=oh(rh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},aT="DialogDescriptionWarning",lT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${rp(aT).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Uh,cT=Vh,Za=qh,To=Gh,ko=Yh,lr=Jh,Fs=Qh,op=tp;const Qa=Ja,uT=Za,sp=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));sp.displayName=To.displayName;const Bs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(uT,{children:[u.jsx(sp,{}),u.jsxs(ko,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(op,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=lr.displayName;const dT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));dT.displayName=Fs.displayName;const fT=1,hT=1e6;let el=0;function pT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,ip=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},hT);tl.set(e,t)},mT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,fT)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?ip(n):e.toasts.forEach(r=>{ip(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Us=[];let Ws={toasts:[]};function Eo(e){Ws=mT(Ws,e),Us.forEach(t=>{t(Ws)})}function gT({...e}){const t=pT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:gT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ap({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:h}=nl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Zc(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Qe,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Hs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function lp(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let cr=lp();function xT(e){cr=e}const cp=/[&<>"']/,vT=new RegExp(cp.source,"g"),up=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,bT=new RegExp(up.source,"g"),wT={"&":"&","<":"<",">":">",'"':""","'":"'"},dp=e=>wT[e];function Ot(e,t){if(t){if(cp.test(e))return e.replace(vT,dp)}else if(up.test(e))return e.replace(bT,dp);return e}const yT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function fp(e){return e.replace(yT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const ST=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ST,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const CT=/[^\w:]/g,TT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function hp(e,t,n){if(e){let r;try{r=decodeURIComponent(fp(n)).replace(CT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!TT.test(n)&&(n=NT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},kT=/^[^:]+:\/*[^/]*$/,ET=/^([^:]+:)[\s\S]*$/,IT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function NT(e,t){Vs[" "+e]||(kT.test(e)?Vs[" "+e]=e+"/":Vs[" "+e]=qs(e,"/",!0)),e=Vs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(ET,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(IT,"$1")+t:e+t}const Ks={exec:function(){}};function pp(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function qs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function AT(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function jT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function mp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function gp(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function _T(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},aT="DialogDescriptionWarning",lT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${oh(aT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Wp,cT=Kp,Za=Gp,To=Yp,ko=Xp,lr=Zp,Fs=eh,sh=nh;const Qa=Ja,uT=Za,ih=h.forwardRef(({className:e,...t},n)=>u.jsx(To,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));ih.displayName=To.displayName;const Bs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(uT,{children:[u.jsx(ih,{}),u.jsxs(ko,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(sh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=lr.displayName;const dT=h.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));dT.displayName=Fs.displayName;const fT=1,pT=1e6;let el=0;function hT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,ah=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},pT);tl.set(e,t)},mT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,fT)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?ah(n):e.toasts.forEach(r=>{ah(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Us=[];let Ws={toasts:[]};function Eo(e){Ws=mT(Ws,e),Us.forEach(t=>{t(Ws)})}function gT({...e}){const t=hT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=h.useState(Ws);return h.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:gT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function lh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:p}=nl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Qc(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Qe,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Hs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ch(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let cr=ch();function xT(e){cr=e}const uh=/[&<>"']/,vT=new RegExp(uh.source,"g"),dh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,bT=new RegExp(dh.source,"g"),wT={"&":"&","<":"<",">":">",'"':""","'":"'"},fh=e=>wT[e];function Ot(e,t){if(t){if(uh.test(e))return e.replace(vT,fh)}else if(dh.test(e))return e.replace(bT,fh);return e}const yT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ph(e){return e.replace(yT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const ST=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ST,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const CT=/[^\w:]/g,TT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function hh(e,t,n){if(e){let r;try{r=decodeURIComponent(ph(n)).replace(CT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!TT.test(n)&&(n=NT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},kT=/^[^:]+:\/*[^/]*$/,ET=/^([^:]+:)[\s\S]*$/,IT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function NT(e,t){Vs[" "+e]||(kT.test(e)?Vs[" "+e]=e+"/":Vs[" "+e]=qs(e,"/",!0)),e=Vs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(ET,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(IT,"$1")+t:e+t}const Ks={exec:function(){}};function mh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function qs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function AT(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function jT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function gh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function xh(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function _T(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
85
|
`)}class rl{constructor(t){this.options=t||cr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:qs(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=_T(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=qs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,
|
|
87
|
-
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(
|
|
89
|
-
`,t=t.substring(
|
|
90
|
-
`,1)[0],
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`,t=t.substring(m.length+1),d=
|
|
94
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=
|
|
95
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Ot(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=qs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=AT(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),
|
|
96
|
-
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=_T(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=qs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
|
+
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),p=t.split(`
|
|
88
|
+
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
|
|
89
|
+
`,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
|
+
`,1)[0],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(p)||E.test(p)||k.test(p)||C.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
|
|
91
|
+
`+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||C.test(d))break;f+=`
|
|
92
|
+
`+p}!l&&!p.trim()&&(l=!0),r+=m+`
|
|
93
|
+
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:mh(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=mh(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Ot(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=qs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=AT(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),xh(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return xh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Ot(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Ot(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Ks,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=st(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=st(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=st(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=st(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=st(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.blockquote=st(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=st(Se.gfm.table).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.gfm.paragraph=st(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ks,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ks,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ks,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=st(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=st(Se._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=st(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=st(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=st(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,he.autolink=st(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=st(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=st(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=st(he.reflink).replace("label",he._label).replace("ref",Se._label).getRegex(),he.nolink=st(he.nolink).replace("ref",Se._label).getRegex(),he.reflinkSearch=st(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:st(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:st(he.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=st(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:st(he.br).replace("{2,}","*").getRegex(),text:st(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function PT(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function vh(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Kn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||cr,this.options.tokenizer=this.options.tokenizer||new rl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Se.normal,inline:he.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:he}}static lex(t,n){return new Kn(n).lex(t)}static lexInline(t,n){return new Kn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
97
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
@@ -103,7 +103,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+
|
|
106
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+gh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+gh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,vh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,vh))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,PT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class ol{constructor(t){this.options=t||cr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
107
|
`,o?'<pre><code class="'+this.options.langPrefix+Ot(o)+'">'+(r?t:Ot(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Ot(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -123,8 +123,8 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}ex(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function wp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=MT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(jT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&we.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;we.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(we.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return wp(Kn.lex,qn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},xT(we.defaults),we},we.getDefaults=lp,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=we.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=we.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=we.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(we.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=we.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=wp(Kn.lexInline,qn.parseInline),we.Parser=qn,we.parser=qn.parse,we.Renderer=ol,we.TextRenderer=vp,we.Lexer=Kn,we.lexer=Kn.lex,we.Tokenizer=rl,we.Slugger=bp,we.Hooks=Gs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,qn.parse,Kn.lex;function Rr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function yp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Sp({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(de.Clock,{className:"w-4 h-4"})),[s,i]=b.useState("Processing");return b.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(de.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(de.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(de.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(de.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(de.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function Cp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>rb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(yp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const RT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:RT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(de.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const Ip={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},OT=e=>{if(!e)return null;const t=e.toLowerCase().trim();return Ip[t]?Ip[t]:{label:t.replace(/(^\w|\s\w)/g,r=>r.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}};function Np({message:e,viewMode:t,isStreaming:n=!1}){var m;const o=Ri(e).name||"tool",s=((m=e.artifact)==null?void 0:m.type)==="research_task_info"?e.artifact:null,i=s==null?void 0:s.status,a=typeof i=="string"?i:null,l=a?OT(a):null,c=f=>{if(f==null)return null;const v=typeof f=="string"?Mi(f)??f:f;if(v&&typeof v=="object")return u.jsx(ul,{data:v});const g=typeof v=="string"?v:(()=>{try{return vr(v)}catch{return String(v??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:g})},d=f=>{if(f==null)return null;const{content:v,isMarkdown:g}=Xv(f);return g?u.jsx(Rr,{content:v,className:"text-current"}):c(f)},h=()=>{const f=e.content.find(x=>x.type!=="tool_call");if(!f)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(f.type==="text"){const y=(f.text??"").trim();if(!y)return null;const w=Qr(y);return d(w)}const v=Zr(f),g=Qr(v);return d(g)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),l&&u.jsx("div",{className:"flex flex-wrap items-center gap-1",children:u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${l.badgeClass}`,children:l.label})}),t==="expanded"&&h()]})}function Ap({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function jp({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Rr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function _p({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:j,activeInterruptValue:M,iconForeground:L}){const H=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),B=b.useCallback(({part:N,i:z})=>{if(N.type==="text"){const $=N.text??"",R=$.trim(),P=Mi(R);return P&&w!=="tool"?u.jsx(ul,{data:P},z):w==="user"&&S&&R.length>k?u.jsx(jp,{text:R,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},z):u.jsx(Rr,{content:$,allowHtml:!1},z)}if(N.type==="image_url"){const $=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},z)}if(N.type==="file"){const $=N,R=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,z),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[z]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[R,v[z]?" (processing)":""]})]},z)}if(N.type==="interrupt"){const $=N,R=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(j&&R&&R===j),I=P?M??($==null?void 0:$.value):$==null?void 0:$.value,V=R?{...$,id:R,interrupt_id:R}:$;return u.jsx(kp,{interruptPart:V,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},z)}return null},[f,v,g,x,w,S,k,C,E,j,M,y]),q=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return H();if(!t&&!q&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Np,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const N=u.jsx("div",{className:"space-y-2",children:i.map((z,$)=>u.jsx(B,{part:z,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(Ap,{className:L})]}):N}return null}function Pp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mp(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Jv(r),toolMeta:Ri(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Zv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:h=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:j=[]}){const[M,L]=b.useState(!1),[H,B]=b.useState("preview"),[q,N]=b.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:$}=eo(),R=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",V=b.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!V,_=!(r&&P!=="user"),{uploadingFiles:O,handleFileClick:K,fileViewerOpen:Y,currentFileInfo:ae,closeFileViewer:W}=Pp({allowFileOpen:_,currentThreadId:z}),D=b.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),X=Mp(t,V),{contentParts:oe,imageParts:G,fileParts:Z,interruptParts:te,textContent:se,toolMeta:ue,toolRaw:ge,isToolStreaming:Re}=X,Oe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Te=Go(Oe),nt=y==null?void 0:y.value,ht=b.useMemo(()=>V||!m?null:t.artifact||null,[V,t,m]),Tt=b.useCallback(async()=>{const ke=I?ge:se;async function et(Ae){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ae);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Le=new Blob([Ae],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Le})]);return}throw new Error("Clipboard API not supported in this context.")}try{await et(ke),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(ke)}catch(Ae){console.error("Failed to copy:",Ae)}},[I,ge,se,x]),Ke=b.useCallback(()=>{if(!v||!t.id)return;const ke=(I?ge:se)??"",et="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ke,et)},[v,t.id,I,ge,se,t]),Ge=b.useCallback(()=>{g==null||g(n)},[g,n]),Ve=b.useCallback(()=>{const et=ne(R?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(de.User,{className:et});case"assistant":return u.jsx(de.Bot,{className:et});case"tool":return u.jsx(de.Wrench,{className:et});default:return u.jsx(de.Bot,{className:et})}},[R,D,P]),$e=b.useCallback(()=>{const ke="group relative mb-4 flex w-full";switch(P){case"user":return ne(ke,"justify-end");case"assistant":case"tool":case"system":return ne(ke,"justify-start");default:return ke}},[P]),He=b.useCallback(()=>{const ke=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",R&&"px-3 py-2 text-sm");if(J)return ne(ke,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(ke,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ke,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[R,J,P]),mt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!0)}catch(Ae){console.error("Failed to approve interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),Dt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!1)}catch(Ae){console.error("Failed to reject interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),lt=b.useMemo(()=>V?"Assistant":Qv(t),[V,t]),kt=P==="user"&&(C??1)>1&&typeof E=="function",wt=(j==null?void 0:j.length)??0,gt=wt>0&&T<wt-1?j[T+1]:void 0,pt=wt>0&&T>0?j[T-1]:void 0,an=b.useCallback(()=>{!gt||!E||E(gt.id,void 0,!!gt.isLatestAttempt)},[gt,E]),dt=b.useCallback(()=>{!pt||!E||E(pt.id,void 0,!!pt.isLatestAttempt)},[pt,E]);return I&&!h&&!ht?null:J&&V?u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:ne("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:V.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",R&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&<&&u.jsx("span",{className:ne("font-medium",R?"text-xs":"text-sm"),children:lt}),I&&u.jsxs(zh,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",R&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>B(ke=>ke==="expanded"?"preview":"expanded"),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),B(et=>et==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ue.name??"Tool Output"}),ue.toolCallId&&u.jsx("span",{className:"opacity-70",children:ue.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[kt&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||an()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||dt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",D,R&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:ne(M?"text-success":D,R?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:ne(D,R?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,R&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:ne(D,R?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(_p,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:ht,toolViewMode:H,isToolStreaming:Re,contentParts:oe,textContent:se,imageParts:G,fileParts:Z,interruptParts:te,isStreamingMessage:r,defaultMessage:V,handleFileClick:K,uploadingFiles:O,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:w,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:q,setIsUserExpanded:N,isCompactLayout:R,activeInterruptId:Te,activeInterruptValue:nt,iconForeground:D}),m&&ht&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:ht,idx:0})})]}),I&&H==="expanded"&&(ue.toolCallId||ue.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",R&&"text-xs"),children:[ue.name&&u.jsxs("div",{children:["Function: ",ue.name]}),ue.toolCallId&&u.jsxs("div",{children:["Call ID: ",ue.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.Copy,{className:ne(M?"text-success":"text-current",R?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.Edit,{className:ne("text-current",R?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",R&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:ne("text-current",R?"h-3 w-3":"h-4 w-4")})})]})]})}),ae&&u.jsx(ap,{isOpen:Y,onClose:W,fileId:ae.id,fileName:ae.name,mimeType:ae.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const DT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,onSelectCheckpoint:S}){const k=dl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=w??DT,M=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:H,attempts:B}=b.useMemo(()=>ec(t.id,M,j),[t.id,M,j]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:H,attemptMetas:B,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0,forceSyntheticThinking:B=!1},q)=>{const N=b.useRef(null),z=b.useRef(null),$=b.useRef(!1),R=b.useRef(!1),[P,I]=b.useState(!0),V=b.useMemo(()=>w?e.some(te=>te.role==="default_message"?!1:Array.isArray(te==null?void 0:te.content)&&te.content.some(se=>se&&se.type==="interrupt"&&(se.id??se.interrupt_id)===w.id)):!1,[w,e]),J=b.useMemo(()=>{if(!w||V)return null;const te=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let se;const ue=w.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const ge=ue.title;typeof ge=="string"&&ge.trim()&&(se=ge.trim())}return{id:`interrupt-${te}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:te,value:ue,title:se}]}},[w,V]),_=b.useMemo(()=>J?[...e,J]:e,[e,J]),O=b.useMemo(()=>{const te=n&&_.some(ue=>ue.id===n);return H&&(t||B)&&!te&&_.length>0?[..._,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:_},[_,t,n,H,B]),K=b.useMemo(()=>T?O:O.filter(te=>(te==null?void 0:te.role)!=="tool"),[O,T]),Y=b.useCallback(te=>{I(te),x&&x(!te),y&&y(te)},[x,y]),ae=b.useMemo(()=>{if(a)return async()=>{if(!$.current){$.current=!0;try{await a()}finally{$.current=!1}}}},[a]),W=b.useMemo(()=>!v||g?!1:P?"auto":!1,[P,v,g]),D=b.useMemo(()=>{if(typeof f!="string")return null;const te=f.trim();return!te||K&&K.length>0?null:{id:"default-message",role:"default_message",content:te,createdAt:new Date().toISOString()}},[f,K]),X=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),oe=()=>D?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:D,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),G=K.length,Z=G>0;return b.useEffect(()=>{var te,se;if(G===0){R.current=!1;return}if(!R.current)if(R.current=!0,N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[G,K.length]),b.useImperativeHandle(q,()=>({scrollToLatest:()=>{var te,se;if(N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var te,se;N.current&&K.length>0?(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[K]),u.jsx("div",{className:X,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx($C,{ref:te=>{N.current=te},scrollerRef:te=>{z.current=te instanceof HTMLDivElement?te:null},data:K,followOutput:W,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{ae&&ae()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(te,se)=>dl(se,te),itemContent:(te,se)=>u.jsx(fl,{message:se,index:te,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:j,activeCheckpointId:M,onSelectCheckpoint:L})}):oe()})})});hl.displayName="MessageList";const Rp={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:h=!0,payloadExtras:m={},customStyles:f={},onMessageSent:v,onExcelUploadSuccess:g,onError:x}){const{api:y}=Xr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:M,checkpoints:L,interrupt:H,metadata:B,checkpointIndex:q}=eo(),{isStreaming:N,error:z,connectionState:$,submit:R,stop:P}=Li(),I=S??w??null,V=(M==null?void 0:M.id)??null,J=(M==null?void 0:M.namespace)??null,_=(B==null?void 0:B.assemblingMessageId)??null,O=H,[K,Y]=b.useState(!1),[ae,W]=b.useState(!1);b.useEffect(()=>{O||Y(!1)},[O]);const D=b.useCallback(()=>{Y(!0)},[]),X=b.useCallback(()=>{Y(!1)},[]),oe=!!O||K,[G,Z]=b.useState(null),[te,se]=b.useState(""),[ue,ge]=b.useState(null),[Re,Oe]=b.useState(null),[Te,nt]=b.useState([]),[ht,Tt]=b.useState(0),[Ke,Ge]=b.useState(0),[Ve,$e]=b.useState(!1),[He,mt]=b.useState(null),[Dt,lt]=b.useState(null),[kt,wt]=b.useState(!1),[gt,pt]=b.useState(null),an=b.useRef(!1),[dt,ke]=b.useState(()=>Rp.value),et=b.useRef(dt),Ae=b.useRef(null),Le=b.useCallback(le=>{Rp.value=le,ke(le)},[]),[Bt,re]=b.useState(!1),ye=b.useRef(null),rt=b.useRef(null),xe=b.useRef(null),Pe=b.useCallback(()=>{rt.current&&(rt.current.value=""),xe.current&&(xe.current.value=""),Tt(le=>le+1),Ge(le=>le+1)},[]),Xe=b.useCallback(le=>{Le(le)},[Le]),St=b.useRef(!1);b.useEffect(()=>{St.current&&!N&&(nt([]),Pe()),St.current=N},[N,Pe]),b.useEffect(()=>{N||W(!1)},[N]),b.useEffect(()=>{B!=null&&B.assemblingMessageId&&W(!1)},[B==null?void 0:B.assemblingMessageId]);const[Et,Nt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const Ce=window.innerWidth;Nt(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{an.current=!1},[I]),b.useEffect(()=>{et.current=dt},[dt]),b.useEffect(()=>{if(!G){Ae.current=null;return}Ae.current===null&&(Ae.current=et.current),Le(te??"")},[te,G,Le]),b.useEffect(()=>{(async()=>{if(!y.baseUrl){pt(null);return}try{const be=(await y.getAgent("default")).uiDefaultMessage||"";pt(be||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),pt(null)}})()},[y.baseUrl]),b.useEffect(()=>{z&&!kt&&(x==null||x(z))},[z,kt,x]);const zt=async le=>{const Ce=le.trim();if(!(!Ce&&Te.length===0))try{const be=G?(ue==null?void 0:ue.checkpointId)??V??void 0:V??void 0,ze=G?(ue==null?void 0:ue.checkpointNs)??J??void 0:J??void 0;await R({text:Ce||"",attachments:Te,payload:m},{checkpointId:be,checkpointNs:ze,edit:!!G,originalMessageId:G??void 0}),v==null||v(Ce),W(!0),Le(""),Oe(null),nt([]),Pe(),Z(null),se(""),ge(null)}catch(be){const ze=(be==null?void 0:be.message)||"Failed to send message";Oe(ze),x==null||x(ze),W(!1)}},_e=b.useCallback((le,Ce,be)=>{c&&(Ae.current=dt,Z(le),se(Ce),Le(Ce),Oe(null),ge({checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null}))},[dt,c,Le]),ct=b.useCallback(()=>{Z(null),se(""),ge(null),Oe(null),Le(Ae.current??dt),Ae.current=null},[dt,Le]),Je=b.useCallback((le,Ce,be)=>{_e(le,Ce,be)},[_e]),ft=b.useCallback(le=>{let Ce=null;for(let jt=le-1;jt>=0;jt--)if(k[jt].role==="user"){Ce=k[jt];break}if(!Ce)return;const be=Array.isArray(Ce.content)?Ce.content:[],At=be.filter(jt=>(jt==null?void 0:jt.type)==="text").map(jt=>jt.text).join("")||(()=>{try{return JSON.stringify(be,null,2)}catch{return String(be)}})();At&&R({text:At,payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0,edit:!0,originalMessageId:Ce.id})},[k,R,V,J,m]),ln=le=>{const Ce=Array.from(le.target.files||[]);nt(be=>[...be,...Ce]),le.target.value=""},A=le=>{nt(Ce=>{const be=Ce.filter((ze,At)=>le!==At);return be.length===0&&Pe(),be})},Q=async le=>{const Ce=(le.target.files||[])[0];if(Ce){mt(null),lt(null),$e(!0);try{await R({attachments:[Ce],payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0});const be=`Uploaded ${Ce.name} - processing through chat stream`;lt(be)}catch(be){const ze=be instanceof Error?be.message:"Failed to upload Excel file";console.error("Excel upload failed",be),mt(ze),x==null||x(ze)}finally{$e(!1),le.target.value="",Pe()}}},fe=async le=>{if(w){re(!0);try{if(!le){await j(),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToLatest()});return}const Ce=L.find(ze=>ze.checkpointId===le),be=(Ce==null?void 0:Ce.checkpointNs)??null;await E(le,be),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToTop()})}finally{re(!1)}}},Ie=b.useCallback(async(le,Ce,be)=>{await fe(be?null:le)},[fe]),Ye=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,tt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,Ue=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Ye,children:[!!z&&!kt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:z}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${tt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:ye,className:"h-full",style:{height:"100%"},messages:k,isStreaming:N,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:G,onEdit:Je,onRegenerate:ft,onCancelEdit:ct,emptyMessage:gt??void 0,isNavigatingCheckpoint:Bt,activeInterrupt:O,disableInterruptActions:K,onInterruptActionStart:D,onInterruptActionEnd:X,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:q,activeCheckpointId:V,onSelectCheckpoint:Ie,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae}),($==="reconnecting"||$==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Bt)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ue,children:[G&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:rt,type:"file",multiple:!0,onChange:le=>ln(le),className:"hidden"},ht),Te.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map((le,Ce)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>A(Ce),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${le.name}`,children:u.jsx(de.X,{size:12})})]},Ce))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:xe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},Ke),Ve&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Dt&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Dt}),He&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:He})]})]}),Re&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Re}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:N||oe,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(zn,{onClick:()=>{var le;return(le=rt.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(zn,{onClick:()=>{var le;Ve||(le=xe.current)==null||le.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(NS,{initialValue:te,editingMessageId:G,value:dt,onValueChange:Xe,placeholder:G?"Edit your message...":t,isStreaming:N,disabled:oe,onSend:zt,onCancelEdit:ct,onStop:P,allowEmptySend:Te.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${G?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Re?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}var Op=1,LT=.9,$T=.8,FT=.17,pl=.1,ml=.999,BT=.9999,zT=.99,HT=/[\\\/_+.#"@\[\(\{&]/,UT=/[\\\/_+.#"@\[\(\{&]/g,WT=/[\s-]/,Dp=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Op:zT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Op:HT.test(e.charAt(c-1))?(h*=$T,f=e.slice(o,c-1).match(UT),f&&o>0&&(h*=Math.pow(ml,f.length))):WT.test(e.charAt(c-1))?(h*=LT,v=e.slice(o,c-1).match(Dp),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=FT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=BT)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Lp(e){return e.toLowerCase().replace(Dp," ")}function VT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Lp(e),Lp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',KT='[cmdk-group-heading=""]',$p='[cmdk-item=""]',Fp=`${$p}:not([aria-disabled="true"])`,vl="cmdk-item-select",Dr="data-value",qT=(e,t,n)=>VT(e,t,n),Bp=p.createContext(void 0),No=()=>p.useContext(Bp),zp=p.createContext(void 0),bl=()=>p.useContext(zp),Hp=p.createContext(void 0),Up=p.forwardRef((e,t)=>{let n=Lr(()=>{var _,O;return{search:"",value:(O=(_=e.value)!=null?_:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Wp(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=ok();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,q)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,O,K)=>{var Y,ae,W,D;if(!Object.is(n.current[_],O)){if(n.current[_]=O,_==="search")B(),L(),T(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(w))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),K||T(5,q),((ae=a.current)==null?void 0:ae.value)!==void 0){let X=O??"";(D=(W=a.current).onValueChange)==null||D.call(W,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=p.useMemo(()=>({value:(_,O,K)=>{var Y;O!==((Y=s.current.get(_))==null?void 0:Y.value)&&(s.current.set(_,{value:O,keywords:K}),n.current.filtered.items.set(_,M(O,K)),T(2,()=>{L(),E.emit()}))},item:(_,O)=>(r.current.add(_),O&&(o.current.has(O)?o.current.get(O).add(_):o.current.set(O,new Set([_]))),T(3,()=>{B(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let K=N();T(4,()=>{B(),(K==null?void 0:K.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function M(_,O){var K,Y;let ae=(Y=(K=a.current)==null?void 0:K.filter)!=null?Y:qT;return _?ae(_,n.current.search,O):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(Y=>{let ae=o.current.get(Y),W=0;ae.forEach(D=>{let X=_.get(D);W=Math.max(X,W)}),O.push([Y,W])});let K=C.current;z().sort((Y,ae)=>{var W,D;let X=Y.getAttribute("id"),oe=ae.getAttribute("id");return((W=_.get(oe))!=null?W:0)-((D=_.get(X))!=null?D:0)}).forEach(Y=>{let ae=Y.closest(xl);ae?ae.appendChild(Y.parentElement===ae?Y:Y.closest(`${xl} > *`)):K.appendChild(Y.parentElement===K?Y:Y.closest(`${xl} > *`))}),O.sort((Y,ae)=>ae[1]-Y[1]).forEach(Y=>{var ae;let W=(ae=C.current)==null?void 0:ae.querySelector(`${Io}[${Dr}="${encodeURIComponent(Y[0])}"]`);W==null||W.parentElement.appendChild(W)})}function H(){let _=z().find(K=>K.getAttribute("aria-disabled")!=="true"),O=_==null?void 0:_.getAttribute(Dr);E.setState("value",O||void 0)}function B(){var _,O,K,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ae=0;for(let W of r.current){let D=(O=(_=s.current.get(W))==null?void 0:_.value)!=null?O:"",X=(Y=(K=s.current.get(W))==null?void 0:K.keywords)!=null?Y:[],oe=M(D,X);n.current.filtered.items.set(W,oe),oe>0&&ae++}for(let[W,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=ae}function q(){var _,O,K;let Y=N();Y&&(((_=Y.parentElement)==null?void 0:_.firstChild)===Y&&((K=(O=Y.closest(Io))==null?void 0:O.querySelector(KT))==null||K.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var _;return(_=C.current)==null?void 0:_.querySelector(`${$p}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(Fp))||[])}function $(_){let O=z()[_];O&&E.setState("value",O.getAttribute(Dr))}function R(_){var O;let K=N(),Y=z(),ae=Y.findIndex(D=>D===K),W=Y[ae+_];(O=a.current)!=null&&O.loop&&(W=ae+_<0?Y[Y.length-1]:ae+_===Y.length?Y[0]:Y[ae+_]),W&&E.setState("value",W.getAttribute(Dr))}function P(_){let O=N(),K=O==null?void 0:O.closest(Io),Y;for(;K&&!Y;)K=_>0?nk(K,Io):rk(K,Io),Y=K==null?void 0:K.querySelector(Fp);Y?E.setState("value",Y.getAttribute(Dr)):R(_)}let I=()=>$(z().length-1),V=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):R(1)},J=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):R(-1)};return p.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var O;(O=y.onKeyDown)==null||O.call(y,_);let K=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||K))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&V(_);break}case"ArrowDown":{V(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let Y=N();if(Y){let ae=new Event(vl);Y.dispatchEvent(ae)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:ik},l),Xs(e,_=>p.createElement(zp.Provider,{value:E},p.createElement(Bp.Provider,{value:j},_))))}),GT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(Hp),a=No(),l=Wp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Vp(o,s,[e.value,e.children,s],e.keywords),h=bl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(me.div,{ref:Dn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),YT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=No(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Vp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Hp.Provider,{value:m},f))))}),XT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),JT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ZT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),QT=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Up,{ref:t,...a}))))}),ek=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),tk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Up,{List:ZT,Item:GT,Input:JT,Group:YT,Separator:XT,Dialog:QT,Empty:ek,Loading:tk});function nk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function rk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Wp(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Vp(e,t,n,r=[]){let o=p.useRef(),s=No();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Dr,a),o.current=a}),o}var ok=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function sk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(sk(t),{ref:t.ref},n(t.props.children)):n(t)}var ik={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));wl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Tl.displayName=Kt.Group.displayName;const ak=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));ak.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function lk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Kp,kN]=un(Il),[ck,sn]=Kp(Il),qp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),M=Fe(t,H=>l(H)),L=Xo(o);return u.jsx(ck,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(me.div,{dir:L,...i,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});qp.displayName=Il;var Gp="ScrollAreaViewport",Yp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(Gp,n),a=p.useRef(null),l=Fe(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Yp.displayName=Gp;var Nn="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(uk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(dk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Xp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=Nn;var uk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Xp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),dk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=lk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Xp=p.forwardRef((e,t)=>{const n=sn(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(Nn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=tm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return xk(m,i.current,a,f)}return n==="horizontal"?u.jsx(fk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=nm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(hk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=nm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),fk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Fe(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),om(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),hk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Fe(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),om(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[pk,Jp]=Kp(Nn),Zp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(Nn,n),[v,g]=p.useState(null),x=Fe(t,M=>g(M)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=vt(d),T=vt(l),E=ei(h,10);function j(M){if(y.current){const L=M.clientX-y.current.left,H=M.clientY-y.current.top;c({x:L,y:H})}}return p.useEffect(()=>{const M=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(pk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(M))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(e.onPointerUp,M=>{const L=M.target;L.hasPointerCapture(M.pointerId)&&L.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Qp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Jp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(mk,{ref:t,...r})})}),mk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Jp(Js,n),{onThumbPositionChange:a}=i,l=Fe(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=vk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Qp.displayName=Js;var jl="ScrollAreaCorner",em=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(gk,{...e,ref:t}):null});em.displayName=jl;var gk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function tm(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=tm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function xk(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return rm([l,c],h)(e)}function nm(e,t,n="ltr"){const r=Qs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=El(e,l);return rm([0,i],[0,a])(c)}function rm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function om(e,t){return e>0&&e<t}var vk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ei(e,t){const n=vt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=vt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var sm=qp,bk=Yp,wk=em;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(sm,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(bk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(im,{}),u.jsx(wk,{})]}));_l.displayName=sm.displayName;const im=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Qp,{className:"relative flex-1 rounded-full bg-border"})}));im.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Pl.displayName="Input";const yk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Sk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ck="bg-slate-600 border-slate-500";function am({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??Ck}`:`${x??Sk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${yk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(de.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(zn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(de.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const lm=25,cm="thread-manager-view",Tk=e=>e==="default"||e==="shared",kk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(cm);if(Tk(e))return e}catch{}return null};function um({defaultView:e}={}){const[t,n]=b.useState(()=>kk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(cm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ek=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:M,actions:L,shareInFlight:H,shareStatus:B,clearShareStatus:q}=xr(),{createThread:N,deleteThread:z,renameThread:$,shareThread:R}=L,{loadThread:P}=eo(),I=i??T,[V,J]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(V.length>0),O=b.useRef(null),K=b.useRef(0),[Y,ae]=b.useState(null),[W,D]=b.useState(""),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(null),[ue,ge]=b.useState(""),Re=v&&v.length>0?v:Ek,Oe=um({defaultView:m}),Te=g??Oe,nt=h??Te.view,ht=b.useCallback(re=>{h||Te.setView(re),f==null||f(re)},[h,f,Te]),Tt=Re.find(re=>re.key===nt)??Re[0],Ke=re=>{se(re),ge(""),Z(!0)},Ge=()=>{Z(!1),se(null),ge(""),q()},Ve=b.useCallback(async re=>{if(!(!te||H)&&re.id)try{await R(te,re.id),setTimeout(()=>Ge(),600)}catch(ye){console.error("Failed to share thread:",ye)}},[Ge,H,te,R]),$e=b.useMemo(()=>{const re=y??[],ye=ue.trim().toLowerCase();return ye?S?re.filter(rt=>S(rt,ye)):re.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ye)):re},[y,ue,S]),He=nt==="shared",mt=He?C:V,Dt=He?M:j,lt=He?"No shared conversations yet":"No conversations yet",kt=re=>{const ye=re.sharedAt?` • ${Ae(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${ye}`},wt=re=>"sharedByUserId"in re;b.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,J(re);return}j||(_.current=!1,J(re))},[k,j]),b.useEffect(()=>{if(!O.current)return;const re=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let ye=null,rt=null;return ye=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{re.scrollTop=K.current})}),()=>{ye!==null&&cancelAnimationFrame(ye),rt!==null&&cancelAnimationFrame(rt)}},[V]);const gt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(ye){console.error("Failed to select thread:",ye)}},pt=async()=>{try{oe(!0);const re=await N();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{oe(!1)}},an=async(re,ye)=>{if(ye.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const rt=O.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(K.current=rt.scrollTop)}try{await z(re),d==null||d(re)}catch(rt){console.error("Failed to delete thread:",rt)}}},dt=(re,ye)=>{ye.stopPropagation(),ae(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},ke=async re=>{if(W.trim())try{await $(re,W.trim()),ae(null),D("")}catch(ye){console.error("Failed to update title:",ye)}},et=()=>{ae(null),D("")},Ae=re=>{if(!re)return"";try{const ye=new Date(re),xe=new Date().getTime()-ye.getTime(),Pe=Math.floor(xe/(1e3*60*60*24));return Pe===0?ye.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ye.toLocaleDateString()}catch{return""}},Le=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Bt=re=>{const ye=Le(re);return ye.length<=lm?ye:`${ye.slice(0,lm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Qe,{onClick:pt,disabled:X||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(de.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Tt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Re.map(re=>u.jsxs(zn,{className:"justify-between text-[12px]",onClick:ye=>{ye.preventDefault(),ht(re.key)},children:[u.jsx("span",{children:re.label}),nt===re.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Dt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:lt})]}):mt.slice().sort((re,ye)=>new Date(ye.updatedAt||ye.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(am,{thread:re,isActive:I===re.threadId,editingThreadId:Y,editingTitle:W,onSelect:gt,onStartEditing:dt,onEditingTitleChange:ye=>D(ye),onSaveEditing:ke,onCancelEditing:et,onShare:()=>Ke(re.threadId),onDelete:an,showEditTitle:r,showDeleteButton:n,formatDate:Ae,getDisplayThreadTitle:Bt,secondaryLine:He&&wt(re)?kt(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:G,onOpenChange:re=>!re&&Ge(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(wl,{children:[u.jsx(yl,{autoFocus:!0,value:ue,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[B&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:B.startsWith("Failed")?"text-red-500":B.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:B})]}),u.jsx(Cl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),$e.length>0&&u.jsx(Tl,{heading:"Recipients",children:$e.map(re=>u.jsx(kl,{onSelect:()=>Ve(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function Ik({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Nk({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function Ak({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function jk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(de.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(de.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ak,{placeholder:t,onMessageSent:r})})]})})}):null}function _k({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(de.Edit3,{size:16}),t??e]})}var Pk="Label",dm=p.forwardRef((e,t)=>u.jsx(me.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));dm.displayName=Pk;var fm=dm;const Mk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),hm=p.forwardRef(({className:e,...t},n)=>u.jsx(fm,{ref:n,className:ne(Mk(),e),...t}));hm.displayName=fm.displayName;function pm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var mm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Rk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...mm,...e.style}}));ni.displayName=Rk;var Ok=ni,Dk=[" ","Enter","ArrowUp","ArrowDown"],Lk=[" ","Enter"],dr="Select",[ri,oi,$k]=Yo(dr),[Fr,EN]=un(dr,[$k,Er]),si=Er(),[Fk,Yn]=Fr(dr),[Bk,zk]=Fr(dr),gm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,j]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[M,L]=Ln({prop:i,defaultProp:a,onChange:l,caller:dr}),H=p.useRef(null),B=x?v||!!x.closest("form"):!0,[q,N]=p.useState(new Set),z=Array.from(q).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Fk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:M,onValueChange:L,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(Bk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{N(R=>new Set(R).add($))},[]),onNativeOptionRemove:p.useCallback($=>{N(R=>{const P=new Set(R);return P.delete($),P})},[]),children:n})}),B?u.jsxs(Bm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:M,onChange:$=>L($.target.value),disabled:m,form:v,children:[M===void 0?u.jsx("option",{value:""}):null,Array.from(q)]},z):null]})})};gm.displayName=dr;var xm="SelectTrigger",vm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Yn(xm,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=Hm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Um(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{asChild:!0,...s,children:u.jsx(me.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":zm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Dk.includes(g.key)&&(v(),g.preventDefault())})})})});vm.displayName=xm;var bm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(bm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Fe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:h,style:{pointerEvents:"none"},children:zm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=bm;var Hk="SelectIcon",ym=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ym.displayName=Hk;var Uk="SelectPortal",Sm=e=>u.jsx(so,{asChild:!0,...e});Sm.displayName=Uk;var fr="SelectContent",Cm=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Tm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(km,{...e,ref:t})});Cm.displayName=fr;var gn=10,[Tm,Xn]=Fr(fr),Wk="SelectContentImpl",Vk=Yt.createSlot("SelectContent.RemoveScroll"),km=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=Fe(t,W=>k(W)),[j,M]=p.useState(null),[L,H]=p.useState(null),B=oi(n),[q,N]=p.useState(!1),z=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(W=>{const[D,...X]=B().map(Z=>Z.ref.current),[oe]=X.slice(-1),G=document.activeElement;for(const Z of W)if(Z===G||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===D&&C&&(C.scrollTop=0),Z===oe&&C&&(C.scrollTop=C.scrollHeight),Z==null||Z.focus(),document.activeElement!==G))return},[B,C]),R=p.useCallback(()=>$([j,S]),[$,j,S]);p.useEffect(()=>{q&&R()},[q,R]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;p.useEffect(()=>{if(S){let W={x:0,y:0};const D=oe=>{var G,Z;W={x:Math.abs(Math.round(oe.pageX)-(((G=I.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((Z=I.current)==null?void 0:Z.y)??0))}},X=oe=>{W.x<=10&&W.y<=10?oe.preventDefault():S.contains(oe.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,I]),p.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[V,J]=Hm(W=>{const D=B().filter(G=>!G.disabled),X=D.find(G=>G.ref.current===document.activeElement),oe=Um(D,W,X);oe&&setTimeout(()=>oe.ref.current.focus())}),_=p.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&(M(W),oe&&(z.current=!0))},[w.value]),O=p.useCallback(()=>S==null?void 0:S.focus(),[S]),K=p.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&H(W)},[w.value]),Y=r==="popper"?Ml:Em,ae=Y===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Tm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:O,itemTextRefCallback:K,focusSelectedItem:R,selectedItemText:L,position:r,isPositioned:q,searchRef:V,children:u.jsx(gs,{as:Vk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...ae,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&J(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let oe=B().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(W.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const G=W.target,Z=oe.indexOf(G);oe=oe.slice(Z+1)}setTimeout(()=>$(oe)),W.preventDefault()}})})})})})})});km.displayName=Wk;var Kk="SelectItemAlignedPosition",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Fe(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const G=L.left-j.left,Z=M.left-G,te=E.left-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Re=El(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.left=Re+"px"}else{const G=j.right-L.right,Z=window.innerWidth-M.right-G,te=window.innerWidth-E.right-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Re=El(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.right=Re+"px"}const H=m(),B=window.innerHeight-gn*2,q=g.scrollHeight,N=window.getComputedStyle(c),z=parseInt(N.borderTopWidth,10),$=parseInt(N.paddingTop,10),R=parseInt(N.borderBottomWidth,10),P=parseInt(N.paddingBottom,10),I=z+$+q+P+R,V=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),O=parseInt(J.paddingBottom,10),K=E.top+E.height/2-gn,Y=B-K,ae=x.offsetHeight/2,W=x.offsetTop+ae,D=z+$+W,X=I-D;if(D<=K){const G=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-g.offsetTop-g.offsetHeight,te=Math.max(Y,ae+(G?O:0)+Z+R),se=D+te;a.style.height=se+"px"}else{const G=H.length>0&&x===H[0].ref.current;a.style.top="0px";const te=Math.max(K,z+g.offsetTop+(G?_:0)+ae)+X;a.style.height=te+"px",g.scrollTop=D-K+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=p.useState();It(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(Gk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(me.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Em.displayName=Kk;var qk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=si(n);return u.jsx(ia,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ml.displayName=qk;var[Gk,Rl]=Fr(fr,{}),Ol="SelectViewport",Im=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Ol,n),i=Rl(Ol,n),a=Fe(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-gn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Im.displayName=Ol;var Nm="SelectGroup",[Yk,Xk]=Fr(Nm),Jk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(Yk,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Jk.displayName=Nm;var Am="SelectLabel",jm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Xk(Am,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});jm.displayName=Am;var ii="SelectItem",[Zk,_m]=Fr(ii),Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ii,n),l=Xn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Fe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Zk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Lk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Pm.displayName=ii;var Ao="SelectItemText",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(Ao,n),a=Xn(Ao,n),l=_m(Ao,n),c=zk(Ao,n),[d,h]=p.useState(null),m=Fe(t,y=>h(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Mm.displayName=Ao;var Rm="SelectItemIndicator",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return _m(Rm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Om.displayName=Rm;var Dl="SelectScrollUpButton",Dm=p.forwardRef((e,t)=>{const n=Xn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Dm.displayName=Dl;var Ll="SelectScrollDownButton",Lm=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Lm.displayName=Ll;var $m=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),Qk="SelectSeparator",Fm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Fm.displayName=Qk;var $l="SelectArrow",eE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Yn($l,n),i=Xn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});eE.displayName=$l;var tE="SelectBubbleInput",Bm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Fe(r,o),i=pm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(me.select,{...n,style:{...mm,...n.style},ref:s,defaultValue:t})});Bm.displayName=tE;function zm(e){return e===""||e===void 0}function Hm(e){const t=vt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Um(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=nE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function nE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rE=gm,Wm=vm,oE=wm,sE=ym,iE=Sm,Vm=Cm,aE=Im,Km=jm,qm=Pm,lE=Mm,cE=Om,Gm=Dm,Ym=Lm,Xm=Fm;const uE=rE,dE=oE,Jm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wm,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(sE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Jm.displayName=Wm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));Qm.displayName=Ym.displayName;const eg=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(iE,{children:u.jsxs(Vm,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Zm,{}),u.jsx(aE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Qm,{})]})}));eg.displayName=Vm.displayName;const fE=p.forwardRef(({className:e,...t},n)=>u.jsx(Km,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));fE.displayName=Km.displayName;const tg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(qm,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(cE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(lE,{children:t})]}));tg.displayName=qm.displayName;const hE=p.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hE.displayName=Xm.displayName;var pE="Separator",ng="horizontal",mE=["horizontal","vertical"],rg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=ng,...o}=e,s=gE(r)?r:ng,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});rg.displayName=pE;function gE(e){return mE.includes(e)}var og=rg;const sg=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(og,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sg.displayName=og.displayName;var ai="Switch",[xE,IN]=un(ai),[vE,bE]=xE(ai),ig=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Fe(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Ln({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(vE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":ug(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(cg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ig.displayName=ai;var ag="SwitchThumb",lg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=bE(ag,n);return u.jsx(me.span,{"data-state":ug(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});lg.displayName=ag;var wE="SwitchBubbleInput",cg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Fe(i,s),l=pm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});cg.displayName=wE;function ug(e){return e?"checked":"unchecked"}var dg=ig,yE=lg;const fg=p.forwardRef(({className:e,...t},n)=>u.jsx(dg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(yE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));fg.displayName=dg.displayName;const SE=Ja,CE=cT,TE=Za,hg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));hg.displayName=To.displayName;const kE=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),pg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(TE,{children:[u.jsx(hg,{}),u.jsxs(ko,{ref:o,className:ne(kE({side:e}),t),...r,children:[n,u.jsxs(op,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pg.displayName=ko.displayName;const mg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});mg.displayName="SheetHeader";const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));gg.displayName=lr.displayName;const xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));xg.displayName=Fs.displayName;var[li,NN]=un("Tooltip",[Er]),ci=Er(),vg="TooltipProvider",EE=700,Fl="tooltip.open",[IE,Bl]=li(vg),bg=e=>{const{__scopeTooltip:t,delayDuration:n=EE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(IE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};bg.displayName=vg;var jo="Tooltip",[NE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Ln({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(E)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(NE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var zl="TooltipTrigger",yg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Fe(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});yg.displayName=zl;var AE="TooltipPortal",[AN,jE]=li(AE,{forceMount:void 0}),Br="TooltipContent",Sg=p.forwardRef((e,t)=>{const n=jE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Br,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Cg,{side:o,...s,ref:t}):u.jsx(_E,{side:o,...s,ref:t})})}),_E=p.forwardRef((e,t)=>{const n=ui(Br,e.__scopeTooltip),r=Bl(Br,e.__scopeTooltip),o=p.useRef(null),s=Fe(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=DE(y,x.getBoundingClientRect()),S=LE(y,w),k=$E(g.getBoundingClientRect()),C=BE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!FE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Cg,{...e,ref:s})}),[PE,ME]=li(jo,{isInside:!1}),RE=Yt.createSlottable("TooltipContent"),Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Br,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(RE,{children:r}),u.jsx(PE,{scope:n,isInside:!0,children:u.jsx(Ok,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Sg.displayName=Br;var Tg="TooltipArrow",OE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return ME(Tg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});OE.displayName=Tg;function DE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function LE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function $E(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function FE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function BE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),zE(t)}function zE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var HE=bg,UE=wg,WE=yg,kg=Sg;const VE=HE,KE=UE,qE=WE,Eg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(kg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Eg.displayName=kg.displayName;var Hl="ToastProvider",[Ul,GE,YE]=Yo("Toast"),[Ig,jN]=un("Toast",[YE]),[XE,di]=Ig(Hl),Ng=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(XE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ng.displayName=Hl;var Ag="ToastViewport",JE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",jg=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=JE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ag,n),a=GE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Fe(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...uI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,M=w.shiftKey;if(w.target===x&&M){(C=c.current)==null||C.focus();return}const B=g({tabbingDirection:M?"backwards":"forwards"}),q=B.findIndex(N=>N===j);Gl(B.slice(q+1))?w.preventDefault():M?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Lb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});jg.displayName=Ag;var _g="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(_g,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=_g;var _o="Toast",ZE="toast.swipeStart",QE="toast.swipeMove",eI="toast.swipeCancel",tI="toast.swipeEnd",Pg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Ln({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(oI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});Pg.displayName=_o;var[nI,rI]=Ig(_o,{onClose(){}}),oI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),w=Fe(t,N=>y(N)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:M,onToastRemove:L}=g,H=vt(()=>{var z;(x==null?void 0:x.contains(document.activeElement))&&((z=g.viewport)==null||z.focus()),i()}),B=p.useCallback(N=>{!N||N===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(H,N))},[H]);p.useEffect(()=>{const N=g.viewport;if(N){const z=()=>{B(E.current),c==null||c()},$=()=>{const R=new Date().getTime()-T.current;E.current=E.current-R,window.clearTimeout(j.current),l==null||l()};return N.addEventListener(Wl,$),N.addEventListener(Vl,z),()=>{N.removeEventListener(Wl,$),N.removeEventListener(Vl,z)}}},[g.viewport,C,l,c,B]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(C)},[s,C,g.isClosePausedRef,B]),p.useEffect(()=>(M(),()=>L()),[M,L]);const q=p.useMemo(()=>x?Fg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[q&&u.jsx(sI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:q}),u.jsx(nI,{scope:n,onClose:H,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Db,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ce(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:ce(e.onPointerMove,N=>{if(!S.current)return;const z=N.clientX-S.current.x,$=N.clientY-S.current.y,R=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=P?I(0,z):0,J=P?0:I(0,$),_=N.pointerType==="touch"?10:2,O={x:V,y:J},K={originalEvent:N,delta:O};R?(k.current=O,fi(QE,h,K,{discrete:!1})):Bg(O,g.swipeDirection,_)?(k.current=O,fi(ZE,d,K,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(z)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,N=>{const z=k.current,$=N.target;if($.hasPointerCapture(N.pointerId)&&$.releasePointerCapture(N.pointerId),k.current=null,S.current=null,z){const R=N.currentTarget,P={originalEvent:N,delta:z};Bg(z,g.swipeDirection,g.swipeThreshold)?fi(tI,f,P,{discrete:!0}):fi(eI,m,P,{discrete:!0}),R.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),sI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return lI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},iI="ToastTitle",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Mg.displayName=iI;var aI="ToastDescription",Rg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Rg.displayName=aI;var Og="ToastAction",Dg=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx($g,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Og}\`. Expected non-empty \`string\`.`),null)});Dg.displayName=Og;var Lg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=rI(Lg,n);return u.jsx($g,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Lg;var $g=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Fg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),cI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Fg(r))}}),t}function fi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Bg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function lI(e=()=>{}){const t=vt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function cI(e){return e.nodeType===e.ELEMENT_NODE}function uI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var dI=Ng,zg=jg,Hg=Pg,Ug=Mg,Wg=Rg,Vg=Dg,Kg=ql;const fI=dI,qg=p.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));qg.displayName=zg.displayName;const hI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Gg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Hg,{ref:r,className:ne(hI({variant:t}),e),...n}));Gg.displayName=Hg.displayName;const pI=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));pI.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(de.X,{className:"h-4 w-4"})}));Yg.displayName=Kg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:ne("text-sm font-semibold",e),...t}));Xg.displayName=Ug.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Jg.displayName=Wg.displayName;function mI(){const{toasts:e}=nl();return u.jsxs(fI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Gg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Xg,{children:n}),r&&u.jsx(Jg,{children:r})]}),o,u.jsx(Yg,{})]},t)}),u.jsx(qg,{})]})}var gI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},xI=p.createContext(void 0),vI={setTheme:e=>{},themes:[]},bI=()=>{var e;return(e=p.useContext(xI))!=null?e:vI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${gI.toString()})(${d})`}})});var wI=e=>{switch(e){case"success":return CI;case"info":return kI;case"warning":return TI;case"error":return EI;default:return null}},yI=Array(12).fill(0),SI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},yI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),CI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),TI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.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"})),kI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),EI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),II=b.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"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),NI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Yl=1,AI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let 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;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Yl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,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 n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(_I(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},qt=new AI,jI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},_I=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",PI=jI,MI=()=>qt.toasts,RI=()=>qt.getActiveToasts();Object.assign(PI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:MI,getToasts:RI});function OI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}OI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
|
-
`);function hi(e){return e.label!==void 0}var DI=3,LI="32px",$I="16px",Zg=4e3,FI=356,BI=14,zI=20,HI=200;function xn(...e){return e.filter(Boolean).join(" ")}function UI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var WI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:M,cancelButtonStyle:L,actionButtonStyle:H,className:B="",descriptionClassName:q="",duration:N,position:z,gap:$,loadingIcon:R,expandByDefault:P,classNames:I,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[O,K]=b.useState(null),[Y,ae]=b.useState(null),[W,D]=b.useState(!1),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(!1),[ue,ge]=b.useState(!1),[Re,Oe]=b.useState(0),[Te,nt]=b.useState(0),ht=b.useRef(f.duration||N||Zg),Tt=b.useRef(null),Ke=b.useRef(null),Ge=S===0,Ve=S+1<=y,$e=f.type,He=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",lt=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),kt=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:j},[f.closeButton,j]),wt=b.useMemo(()=>f.duration||N||Zg,[f.duration,N]),gt=b.useRef(0),pt=b.useRef(0),an=b.useRef(0),dt=b.useRef(null),[ke,et]=z.split("-"),Ae=b.useMemo(()=>w.reduce((xe,Pe,Xe)=>Xe>=lt?xe:xe+Pe.height,0),[w,lt]),Le=NI(),Bt=f.invert||m,re=$e==="loading";pt.current=b.useMemo(()=>lt*$+Ae,[lt,Ae]),b.useEffect(()=>{ht.current=wt},[wt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let xe=Ke.current;if(xe){let Pe=xe.getBoundingClientRect().height;return nt(Pe),x(Xe=>[{toastId:f.id,height:Pe,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(St=>St.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=Ke.current,Pe=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Pe,nt(Xe),x(St=>St.find(Et=>Et.toastId===f.id)?St.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...St])},[W,f.title,f.description,x,f.id]);let ye=b.useCallback(()=>{oe(!0),Oe(pt.current),x(xe=>xe.filter(Pe=>Pe.toastId!==f.id)),setTimeout(()=>{T(f)},HI)},[f,T,x,pt]);b.useEffect(()=>{if(f.promise&&$e==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Le?(()=>{if(an.current<gt.current){let Pe=new Date().getTime()-gt.current;ht.current=ht.current-Pe}an.current=new Date().getTime()})():ht.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Pe;(Pe=f.onAutoClose)==null||Pe.call(f,f),ye()},ht.current)),()=>clearTimeout(xe)},[C,g,f,$e,_,Le,ye]),b.useEffect(()=>{f.delete&&ye()},[ye,f.delete]);function rt(){var xe,Pe,Xe;return V!=null&&V.loading?b.createElement("div",{className:xn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":$e==="loading"},V.loading):R?b.createElement("div",{className:xn(I==null?void 0:I.loader,(Pe=f==null?void 0:f.classNames)==null?void 0:Pe.loader,"sonner-loader"),"data-visible":$e==="loading"},R):b.createElement(SI,{className:xn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:$e==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ke,className:xn(B,mt,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[$e],(n=f==null?void 0:f.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":X,"data-visible":Ve,"data-y-position":ke,"data-x-position":et,"data-index":S,"data-front":Ge,"data-swiping":G,"data-dismissible":He,"data-type":$e,"data-invert":Bt,"data-swipe-out":te,"data-swipe-direction":Y,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Re:pt.current}px`,"--initial-height":P?"auto":`${Te}px`,...M,...f.style},onDragEnd:()=>{Z(!1),K(null),dt.current=null},onPointerDown:xe=>{re||!He||(Tt.current=new Date,Oe(pt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(Z(!0),dt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Pe,Xe,St;if(te||!He)return;dt.current=null;let Et=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Pe=Ke.current)==null?void 0:Pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zt=new Date().getTime()-((Xe=Tt.current)==null?void 0:Xe.getTime()),_e=O==="x"?Et:Nt,ct=Math.abs(_e)/zt;if(Math.abs(_e)>=zI||ct>.11){Oe(pt.current),(St=f.onDismiss)==null||St.call(f,f),ae(O==="x"?Et>0?"right":"left":Nt>0?"down":"up"),ye(),se(!0),ge(!1);return}Z(!1),K(null)},onPointerMove:xe=>{var Pe,Xe,St,Et;if(!dt.current||!He||((Pe=window.getSelection())==null?void 0:Pe.toString().length)>0)return;let Nt=xe.clientY-dt.current.y,zt=xe.clientX-dt.current.x,_e=(Xe=e.swipeDirections)!=null?Xe:UI(z);!O&&(Math.abs(zt)>1||Math.abs(Nt)>1)&&K(Math.abs(zt)>Math.abs(Nt)?"x":"y");let ct={x:0,y:0};O==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&&Nt<0||_e.includes("bottom")&&Nt>0)&&(ct.y=Nt):O==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&zt<0||_e.includes("right")&&zt>0)&&(ct.x=zt),(Math.abs(ct.x)>0||Math.abs(ct.y)>0)&&ge(!0),(St=Ke.current)==null||St.style.setProperty("--swipe-amount-x",`${ct.x}px`),(Et=Ke.current)==null||Et.style.setProperty("--swipe-amount-y",`${ct.y}px`)}},kt&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var xe;ye(),(xe=f.onDismiss)==null||xe.call(f,f)},className:xn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:II):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,$e||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:xn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||rt():null,f.type!=="loading"?f.icon||(V==null?void 0:V[$e])||wI($e):null):null,b.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:xn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:xn(q,Dt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Pe,Xe;hi(f.cancel)&&He&&((Xe=(Pe=f.cancel).onClick)==null||Xe.call(Pe,xe),ye())},className:xn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&hi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:xe=>{var Pe,Xe;hi(f.action)&&((Xe=(Pe=f.action).onClick)==null||Xe.call(Pe,xe),!xe.defaultPrevented&&ye())},className:xn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Qg(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function VI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?$I:LI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var KI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:v=DI,toastOptions:g,dir:x=Qg(),gap:y=BI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[M,L]=b.useState([]),[H,B]=b.useState(!1),[q,N]=b.useState(!1),[z,$]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),V=b.useRef(!1),J=b.useCallback(_=>{E(O=>{var K;return(K=O.find(Y=>Y.id===_.id))!=null&&K.delete||qt.dismiss(_.id),O.filter(({id:Y})=>Y!==_.id)})},[]);return b.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(O=>O.map(K=>K.id===_.id?{...K,delete:!0}:K));return}setTimeout(()=>{Po.flushSync(()=>{E(O=>{let K=O.findIndex(Y=>Y.id===_.id);return K!==-1?[...O.slice(0,K),{...O[K],..._},...O.slice(K+1)]:[_,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:O})=>{$(O?"dark":"light")})}catch{_.addListener(({matches:K})=>{try{$(K?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),b.useEffect(()=>{T.length<=1&&B(!1)},[T]),b.useEffect(()=>{let _=O=>{var K,Y;o.every(ae=>O[ae]||O.code===ae)&&(B(!0),(K=R.current)==null||K.focus()),O.code==="Escape"&&(document.activeElement===R.current||(Y=R.current)!=null&&Y.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(R.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,V.current=!1)}},[R.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,O)=>{var K;let[Y,ae]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?Qg():x,tabIndex:-1,ref:R,className:a,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":Y,"data-lifted":H&&T.length>1&&!s,"data-x-position":ae,style:{"--front-toast-height":`${((K=M[0])==null?void 0:K.height)||0}px`,"--width":`${FI}px`,"--gap":`${y}px`,...f,...VI(l,c)},onBlur:W=>{V.current&&!W.currentTarget.contains(W.relatedTarget)&&(V.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||V.current||(V.current=!0,I.current=W.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{q||B(!1)},onDragEnd:()=>B(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(W=>!W.position&&O===0||W.position===_).map((W,D)=>{var X,oe;return b.createElement(WI,{key:W.id,icons:S,index:D,toast:W,defaultRichColors:h,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(oe=g==null?void 0:g.closeButton)!=null?oe:i,interacting:q,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(G=>G.position==W.position),heights:M.filter(G=>G.position==W.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const qI=({...e})=>{const{theme:t="system"}=bI();return u.jsx(KI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=Bv,F.ApiClient=Fv,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=zh,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=Ik,F.ChatInput=Hf,F.ChatInterface=Or,F.ChatProviders=br,F.ChatWidget=jk,F.Command=wl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=zn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ap,F.HISTORY_TIMEOUT_MS=Xc,F.Input=Pl,F.InterruptPartRenderer=kp,F.Label=hm,F.MarkdownContent=Rr,F.MessageBody=_p,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=_k,F.PlotArtifact=yp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=_l,F.Select=uE,F.SelectContent=eg,F.SelectItem=tg,F.SelectTrigger=Jm,F.SelectValue=dE,F.Separator=sg,F.Sheet=SE,F.SheetContent=pg,F.SheetDescription=xg,F.SheetHeader=mg,F.SheetTitle=gg,F.SheetTrigger=CE,F.SimpleChat=Nk,F.SimpleJsonView=ul,F.Sonner=qI,F.StreamProgress=Ep,F.Switch=fg,F.Textarea=Ta,F.ThinkingIndicator=Ap,F.ThreadListItem=am,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=gx,F.Toaster=mI,F.ToolComponent=Np,F.Tooltip=KE,F.TooltipContent=Eg,F.TooltipProvider=VE,F.TooltipTrigger=qE,F.UserTextContent=jp,F.applySettings=wb,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=sx,F.chatApiClient=On,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=ix,F.getCurrentSettings=bb,F.getDefaultApiConfig=Mu,F.getDefaultChatSettings=Ru,F.getFileContent=_i,F.getFileInfo=Hv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=Mn,F.resolveChatBaseUrl=bn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=Lt,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=Pp,F.useHasChatSession=gb,F.useParsedMessageContent=Mp,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=wu,F.useThreadManagerViewState=um,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=xr,F.useThreadsState=uu,F.viewFileById=zv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|
|
126
|
+
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=hh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=hh(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class bh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class wh{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class qn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new bh,this.slugger=new wh}static parse(t,n){return new qn(n).parse(t)}static parseInline(t,n){return new qn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,ph(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}ex(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function RT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function yh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=RT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(jT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&we.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;we.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(we.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return yh(Kn.lex,qn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},xT(we.defaults),we},we.getDefaults=ch,we.defaults=cr,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=we.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=we.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=we.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(we.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=we.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=yh(Kn.lexInline,qn.parseInline),we.Parser=qn,we.parser=qn.parse,we.Renderer=ol,we.TextRenderer=bh,we.Lexer=Kn,we.lexer=Kn.lex,we.Tokenizer=rl,we.Slugger=wh,we.Hooks=Gs,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,qn.parse,Kn.lex;function Mr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof we.parse=="function"?we.parse(i):we(i)}return typeof we.parse=="function"?we.parse(e):we(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Sh({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const Ch={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},MT=e=>{if(!e)return Ch.processing;const t=e.toLowerCase().trim();return Ch[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},OT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Th({artifact:e}){const t=MT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(de.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:OT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Mr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(de.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function sl({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>rb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Th,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Sh,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const il=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));il.displayName="Card";const al=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ul.displayName="CardContent";const kh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));kh.displayName="CardFooter";function Eh({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(il,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(kh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const DT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:DT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Ih({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(de.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Nh({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const p=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:p}=Xv(c);return p?u.jsx(Mr,{content:d,className:"text-current"}):i(c)},l=()=>{if(s)return null;const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),p=Qr(d);return a(p)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(sl,{artifact:s,idx:0}),u.jsx(Ih,{message:e,isStreaming:n}),t==="expanded"&&l()]})}function Ah({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function jh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Mr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function _h({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:j,activeInterruptValue:R,iconForeground:L}){const H=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),B=b.useCallback(({part:N,i:z})=>{if(N.type==="text"){const $=N.text??"",M=$.trim(),P=Ri(M);return P&&w!=="tool"?u.jsx(dl,{data:P},z):w==="user"&&S&&M.length>k?u.jsx(jh,{text:M,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},z):u.jsx(Mr,{content:$,allowHtml:!1},z)}if(N.type==="image_url"){const $=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},z)}if(N.type==="file"){const $=N,M=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,z),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[z]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[M,v[z]?" (processing)":""]})]},z)}if(N.type==="interrupt"){const $=N,M=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(j&&M&&M===j),I=P?R??($==null?void 0:$.value):$==null?void 0:$.value,V=M?{...$,id:M,interrupt_id:M}:$;return u.jsx(Eh,{interruptPart:V,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},z)}return null},[f,v,g,x,w,S,k,C,E,j,R,y]),q=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!q&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Nh,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const N=u.jsx("div",{className:"space-y-2",children:i.map((z,$)=>u.jsx(B,{part:z,i:$},$))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(Ah,{className:L})]}):N}return null}function Ph(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),p=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Rh(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Jv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Zv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:j=[]}){const[R,L]=b.useState(!1),[H,B]=b.useState("preview"),[q,N]=b.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:$}=eo(),M=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",V=b.useMemo(()=>t.role==="default_message"?t:null,[t]),J=!!V,_=!(r&&P!=="user"),{uploadingFiles:O,handleFileClick:K,fileViewerOpen:Y,currentFileInfo:ae,closeFileViewer:W}=Ph({allowFileOpen:_,currentThreadId:z}),D=b.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),X=Rh(t,V),{contentParts:oe,imageParts:G,fileParts:Z,interruptParts:te,textContent:se,toolMeta:ue,toolRaw:ge,isToolStreaming:Me}=X,Oe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Te=Go(Oe),nt=y==null?void 0:y.value,pt=b.useMemo(()=>V||!m?null:t.artifact||null,[V,t,m]),Tt=b.useCallback(async()=>{const ke=I?ge:se;async function et(Ae){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ae);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Le=new Blob([Ae],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Le})]);return}throw new Error("Clipboard API not supported in this context.")}try{await et(ke),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(ke)}catch(Ae){console.error("Failed to copy:",Ae)}},[I,ge,se,x]),Ke=b.useCallback(()=>{if(!v||!t.id)return;const ke=(I?ge:se)??"",et="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ke,et)},[v,t.id,I,ge,se,t]),Ge=b.useCallback(()=>{g==null||g(n)},[g,n]),Ve=b.useCallback(()=>{const et=ne(M?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(de.User,{className:et});case"assistant":return u.jsx(de.Bot,{className:et});case"tool":return u.jsx(de.Wrench,{className:et});default:return u.jsx(de.Bot,{className:et})}},[M,D,P]),$e=b.useCallback(()=>{const ke="group relative mb-4 flex w-full";switch(P){case"user":return ne(ke,"justify-end");case"assistant":case"tool":case"system":return ne(ke,"justify-start");default:return ke}},[P]),He=b.useCallback(()=>{const ke=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",M&&"px-3 py-2 text-sm");if(J)return ne(ke,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(ke,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(ke,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(ke,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[M,J,P]),mt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!0)}catch(Ae){console.error("Failed to approve interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),Dt=b.useCallback(async ke=>{if(w)return;const et=Go((ke==null?void 0:ke.id)??(ke==null?void 0:ke.interrupt_id));if(!et){console.warn("Interrupt part missing id",ke);return}try{S==null||S(),await $(et,!1)}catch(Ae){console.error("Failed to reject interrupt:",Ae)}finally{k==null||k()}},[w,k,S,$]),lt=b.useMemo(()=>V?"Assistant":Qv(t),[V,t]),kt=P==="user"&&(C??1)>1&&typeof E=="function",wt=(j==null?void 0:j.length)??0,gt=wt>0&&T<wt-1?j[T+1]:void 0,ht=wt>0&&T>0?j[T-1]:void 0,an=b.useCallback(()=>{!gt||!E||E(gt.id,void 0,!!gt.isLatestAttempt)},[gt,E]),dt=b.useCallback(()=>{!ht||!E||E(ht.id,void 0,!!ht.isLatestAttempt)},[ht,E]);return I&&!p&&!pt?null:J&&V?u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:ne("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:V.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne($e(),f.container),children:u.jsxs("div",{className:ne(He(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",M&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ve(),a&<&&u.jsx("span",{className:ne("font-medium",M?"text-xs":"text-sm"),children:lt}),I&&u.jsxs(Hp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",M&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>B(ke=>ke==="expanded"?"preview":"expanded"),onKeyDown:ke=>{(ke.key==="Enter"||ke.key===" ")&&(ke.preventDefault(),B(et=>et==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ue.name??"Tool Output"}),ue.toolCallId&&u.jsx("span",{className:"opacity-70",children:ue.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[kt&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||an()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||dt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",D,M&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:ne(R?"text-success":D,M?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:ne(D,M?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",D,M&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:ne(D,M?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(_h,{message:t,isToolMessage:I,showToolMessages:p,artifactToRender:pt,toolViewMode:H,isToolStreaming:Me,contentParts:oe,textContent:se,imageParts:G,fileParts:Z,interruptParts:te,isStreamingMessage:r,defaultMessage:V,handleFileClick:K,uploadingFiles:O,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:w,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:q,setIsUserExpanded:N,isCompactLayout:M,activeInterruptId:Te,activeInterruptValue:nt,iconForeground:D}),m&&pt&&u.jsx("div",{className:"mt-3",children:u.jsx(sl,{artifact:pt,idx:0})})]}),I&&H==="expanded"&&(ue.toolCallId||ue.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",M&&"text-xs"),children:[ue.name&&u.jsxs("div",{children:["Function: ",ue.name]}),ue.toolCallId&&u.jsxs("div",{children:["Call ID: ",ue.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Tt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.Copy,{className:ne(R?"text-success":"text-current",M?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.Edit,{className:ne("text-current",M?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",M&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:ne("text-current",M?"h-3 w-3":"h-4 w-4")})})]})]})}),ae&&u.jsx(lh,{isOpen:Y,onClose:W,fileId:ae.id,fileName:ae.name,mimeType:ae.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mu(e.message)===mu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=gu(e.message),a=gu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const LT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,pl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,onSelectCheckpoint:S}){const k=fl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,j=w??LT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:H,attempts:B}=b.useMemo(()=>tc(t.id,R,j),[t.id,R,j]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:H,attemptMetas:B,onSelectCheckpoint:S})})});pl.displayName="MessageRow";const hl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:j,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0,forceSyntheticThinking:B=!1},q)=>{const N=b.useRef(null),z=b.useRef(null),$=b.useRef(!1),M=b.useRef(!1),[P,I]=b.useState(!0),V=b.useMemo(()=>w?e.some(te=>te.role==="default_message"?!1:Array.isArray(te==null?void 0:te.content)&&te.content.some(se=>se&&se.type==="interrupt"&&(se.id??se.interrupt_id)===w.id)):!1,[w,e]),J=b.useMemo(()=>{if(!w||V)return null;const te=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let se;const ue=w.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const ge=ue.title;typeof ge=="string"&&ge.trim()&&(se=ge.trim())}return{id:`interrupt-${te}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:te,value:ue,title:se}]}},[w,V]),_=b.useMemo(()=>J?[...e,J]:e,[e,J]),O=b.useMemo(()=>{const te=n&&_.some(ue=>ue.id===n);return H&&(t||B)&&!te&&_.length>0?[..._,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:_},[_,t,n,H,B]),K=b.useMemo(()=>T?O:O.filter(te=>(te==null?void 0:te.role)!=="tool"),[O,T]),Y=b.useCallback(te=>{I(te),x&&x(!te),y&&y(te)},[x,y]),ae=b.useMemo(()=>{if(a)return async()=>{if(!$.current){$.current=!0;try{await a()}finally{$.current=!1}}}},[a]),W=b.useMemo(()=>!v||g?!1:P?"auto":!1,[P,v,g]),D=b.useMemo(()=>{if(typeof f!="string")return null;const te=f.trim();return!te||K&&K.length>0?null:{id:"default-message",role:"default_message",content:te,createdAt:new Date().toISOString()}},[f,K]),X=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),oe=()=>D?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:D,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),G=K.length,Z=G>0;return b.useEffect(()=>{var te,se;if(G===0){M.current=!1;return}if(!M.current)if(M.current=!0,N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[G,K.length]),b.useImperativeHandle(q,()=>({scrollToLatest:()=>{var te,se;if(N.current&&K.length>0){const ue=K.length-1;(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:ue,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var te,se;N.current&&K.length>0?(se=(te=N.current).scrollToIndex)==null||se.call(te,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[K]),u.jsx("div",{className:X,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx($C,{ref:te=>{N.current=te},scrollerRef:te=>{z.current=te instanceof HTMLDivElement?te:null},data:K,followOutput:W,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{ae&&ae()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(te,se)=>fl(se,te),itemContent:(te,se)=>u.jsx(pl,{message:se,index:te,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:j,activeCheckpointId:R,onSelectCheckpoint:L})}):oe()})})});hl.displayName="MessageList";const Mh={value:""};function Or({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,payloadExtras:m={},customStyles:f={},onMessageSent:v,onExcelUploadSuccess:g,onError:x}){const{api:y}=Xr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:R,checkpoints:L,interrupt:H,metadata:B,checkpointIndex:q}=eo(),{isStreaming:N,error:z,connectionState:$,submit:M,stop:P}=Li(),I=S??w??null,V=(R==null?void 0:R.id)??null,J=(R==null?void 0:R.namespace)??null,_=(B==null?void 0:B.assemblingMessageId)??null,O=H,[K,Y]=b.useState(!1),[ae,W]=b.useState(!1);b.useEffect(()=>{O||Y(!1)},[O]);const D=b.useCallback(()=>{Y(!0)},[]),X=b.useCallback(()=>{Y(!1)},[]),oe=!!O||K,[G,Z]=b.useState(null),[te,se]=b.useState(""),[ue,ge]=b.useState(null),[Me,Oe]=b.useState(null),[Te,nt]=b.useState([]),[pt,Tt]=b.useState(0),[Ke,Ge]=b.useState(0),[Ve,$e]=b.useState(!1),[He,mt]=b.useState(null),[Dt,lt]=b.useState(null),[kt,wt]=b.useState(!1),[gt,ht]=b.useState(null),an=b.useRef(!1),[dt,ke]=b.useState(()=>Mh.value),et=b.useRef(dt),Ae=b.useRef(null),Le=b.useCallback(le=>{Mh.value=le,ke(le)},[]),[Bt,re]=b.useState(!1),ye=b.useRef(null),rt=b.useRef(null),xe=b.useRef(null),Pe=b.useCallback(()=>{rt.current&&(rt.current.value=""),xe.current&&(xe.current.value=""),Tt(le=>le+1),Ge(le=>le+1)},[]),Xe=b.useCallback(le=>{Le(le)},[Le]),St=b.useRef(!1);b.useEffect(()=>{St.current&&!N&&(nt([]),Pe()),St.current=N},[N,Pe]),b.useEffect(()=>{N||W(!1)},[N]),b.useEffect(()=>{B!=null&&B.assemblingMessageId&&W(!1)},[B==null?void 0:B.assemblingMessageId]);const[Et,Nt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const Ce=window.innerWidth;Nt(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{an.current=!1},[I]),b.useEffect(()=>{et.current=dt},[dt]),b.useEffect(()=>{if(!G){Ae.current=null;return}Ae.current===null&&(Ae.current=et.current),Le(te??"")},[te,G,Le]),b.useEffect(()=>{(async()=>{if(!y.baseUrl){ht(null);return}try{const be=(await y.getAgent("default")).uiDefaultMessage||"";ht(be||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),ht(null)}})()},[y.baseUrl]),b.useEffect(()=>{z&&!kt&&(x==null||x(z))},[z,kt,x]);const zt=async le=>{const Ce=le.trim();if(!(!Ce&&Te.length===0))try{const be=G?(ue==null?void 0:ue.checkpointId)??V??void 0:V??void 0,ze=G?(ue==null?void 0:ue.checkpointNs)??J??void 0:J??void 0;await M({text:Ce||"",attachments:Te,payload:m},{checkpointId:be,checkpointNs:ze,edit:!!G,originalMessageId:G??void 0}),v==null||v(Ce),W(!0),Le(""),Oe(null),nt([]),Pe(),Z(null),se(""),ge(null)}catch(be){const ze=(be==null?void 0:be.message)||"Failed to send message";Oe(ze),x==null||x(ze),W(!1)}},_e=b.useCallback((le,Ce,be)=>{c&&(Ae.current=dt,Z(le),se(Ce),Le(Ce),Oe(null),ge({checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null}))},[dt,c,Le]),ct=b.useCallback(()=>{Z(null),se(""),ge(null),Oe(null),Le(Ae.current??dt),Ae.current=null},[dt,Le]),Je=b.useCallback((le,Ce,be)=>{_e(le,Ce,be)},[_e]),ft=b.useCallback(le=>{let Ce=null;for(let jt=le-1;jt>=0;jt--)if(k[jt].role==="user"){Ce=k[jt];break}if(!Ce)return;const be=Array.isArray(Ce.content)?Ce.content:[],At=be.filter(jt=>(jt==null?void 0:jt.type)==="text").map(jt=>jt.text).join("")||(()=>{try{return JSON.stringify(be,null,2)}catch{return String(be)}})();At&&M({text:At,payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0,edit:!0,originalMessageId:Ce.id})},[k,M,V,J,m]),ln=le=>{const Ce=Array.from(le.target.files||[]);nt(be=>[...be,...Ce]),le.target.value=""},A=le=>{nt(Ce=>{const be=Ce.filter((ze,At)=>le!==At);return be.length===0&&Pe(),be})},Q=async le=>{const Ce=(le.target.files||[])[0];if(Ce){mt(null),lt(null),$e(!0);try{await M({attachments:[Ce],payload:m},{checkpointId:V??void 0,checkpointNs:J??void 0});const be=`Uploaded ${Ce.name} - processing through chat stream`;lt(be)}catch(be){const ze=be instanceof Error?be.message:"Failed to upload Excel file";console.error("Excel upload failed",be),mt(ze),x==null||x(ze)}finally{$e(!1),le.target.value="",Pe()}}},fe=async le=>{if(w){re(!0);try{if(!le){await j(),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToLatest()});return}const Ce=L.find(ze=>ze.checkpointId===le),be=(Ce==null?void 0:Ce.checkpointNs)??null;await E(le,be),requestAnimationFrame(()=>{var ze;(ze=ye.current)==null||ze.scrollToTop()})}finally{re(!1)}}},Ie=b.useCallback(async(le,Ce,be)=>{await fe(be?null:le)},[fe]),Ye=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,tt=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,Ue=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:Ye,children:[!!z&&!kt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:z}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${tt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:ye,className:"h-full",style:{height:"100%"},messages:k,isStreaming:N,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:G,onEdit:Je,onRegenerate:ft,onCancelEdit:ct,emptyMessage:gt??void 0,isNavigatingCheckpoint:Bt,activeInterrupt:O,disableInterruptActions:K,onInterruptActionStart:D,onInterruptActionEnd:X,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:q,activeCheckpointId:V,onSelectCheckpoint:Ie,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae}),($==="reconnecting"||$==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),$==="reconnecting"?"Reconnecting…":"Connecting…"]})}),$==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Bt)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ue,children:[G&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(de.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ct,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:rt,type:"file",multiple:!0,onChange:le=>ln(le),className:"hidden"},pt),Te.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Te.map((le,Ce)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>A(Ce),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${le.name}`,children:u.jsx(de.X,{size:12})})]},Ce))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:xe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},Ke),Ve&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Dt&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Dt}),He&&!Ve&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:He})]})]}),Me&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Me}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:N||oe,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(zn,{onClick:()=>{var le;return(le=rt.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(zn,{onClick:()=>{var le;Ve||(le=xe.current)==null||le.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(NS,{initialValue:te,editingMessageId:G,value:dt,onValueChange:Xe,placeholder:G?"Edit your message...":t,isStreaming:N,disabled:oe,onSend:zt,onCancelEdit:ct,onStop:P,allowEmptySend:Te.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${G?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Me?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}var Oh=1,$T=.9,FT=.8,BT=.17,ml=.1,gl=.999,zT=.9999,HT=.99,UT=/[\\\/_+.#"@\[\(\{&]/,WT=/[\\\/_+.#"@\[\(\{&]/g,VT=/[\s-]/,Dh=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Oh:HT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=xl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Oh:UT.test(e.charAt(c-1))?(p*=FT,f=e.slice(o,c-1).match(WT),f&&o>0&&(p*=Math.pow(gl,f.length))):VT.test(e.charAt(c-1))?(p*=$T,v=e.slice(o,c-1).match(Dh),v&&o>0&&(p*=Math.pow(gl,v.length))):(p*=BT,o>0&&(p*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=zT)),(p<ml&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=xl(e,t,n,r,c+1,s+2,i),m*ml>p&&(p=m*ml)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Lh(e){return e.toLowerCase().replace(Dh," ")}function KT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Lh(e),Lh(t),0,0,{})}var Io='[cmdk-group=""]',vl='[cmdk-group-items=""]',qT='[cmdk-group-heading=""]',$h='[cmdk-item=""]',Fh=`${$h}:not([aria-disabled="true"])`,bl="cmdk-item-select",Dr="data-value",GT=(e,t,n)=>KT(e,t,n),Bh=h.createContext(void 0),No=()=>h.useContext(Bh),zh=h.createContext(void 0),wl=()=>h.useContext(zh),Hh=h.createContext(void 0),Uh=h.forwardRef((e,t)=>{let n=Lr(()=>{var _,O;return{search:"",value:(O=(_=e.value)!=null?_:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>new Set),a=Wh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Pt(),S=Pt(),k=Pt(),C=h.useRef(null),T=sk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,q)},[]);let E=h.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,O,K)=>{var Y,ae,W,D;if(!Object.is(n.current[_],O)){if(n.current[_]=O,_==="search")B(),L(),T(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(w))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),K||T(5,q),((ae=a.current)==null?void 0:ae.value)!==void 0){let X=O??"";(D=(W=a.current).onValueChange)==null||D.call(W,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=h.useMemo(()=>({value:(_,O,K)=>{var Y;O!==((Y=s.current.get(_))==null?void 0:Y.value)&&(s.current.set(_,{value:O,keywords:K}),n.current.filtered.items.set(_,R(O,K)),T(2,()=>{L(),E.emit()}))},item:(_,O)=>(r.current.add(_),O&&(o.current.has(O)?o.current.get(O).add(_):o.current.set(O,new Set([_]))),T(3,()=>{B(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let K=N();T(4,()=>{B(),(K==null?void 0:K.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,O){var K,Y;let ae=(Y=(K=a.current)==null?void 0:K.filter)!=null?Y:GT;return _?ae(_,n.current.search,O):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(Y=>{let ae=o.current.get(Y),W=0;ae.forEach(D=>{let X=_.get(D);W=Math.max(X,W)}),O.push([Y,W])});let K=C.current;z().sort((Y,ae)=>{var W,D;let X=Y.getAttribute("id"),oe=ae.getAttribute("id");return((W=_.get(oe))!=null?W:0)-((D=_.get(X))!=null?D:0)}).forEach(Y=>{let ae=Y.closest(vl);ae?ae.appendChild(Y.parentElement===ae?Y:Y.closest(`${vl} > *`)):K.appendChild(Y.parentElement===K?Y:Y.closest(`${vl} > *`))}),O.sort((Y,ae)=>ae[1]-Y[1]).forEach(Y=>{var ae;let W=(ae=C.current)==null?void 0:ae.querySelector(`${Io}[${Dr}="${encodeURIComponent(Y[0])}"]`);W==null||W.parentElement.appendChild(W)})}function H(){let _=z().find(K=>K.getAttribute("aria-disabled")!=="true"),O=_==null?void 0:_.getAttribute(Dr);E.setState("value",O||void 0)}function B(){var _,O,K,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ae=0;for(let W of r.current){let D=(O=(_=s.current.get(W))==null?void 0:_.value)!=null?O:"",X=(Y=(K=s.current.get(W))==null?void 0:K.keywords)!=null?Y:[],oe=R(D,X);n.current.filtered.items.set(W,oe),oe>0&&ae++}for(let[W,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=ae}function q(){var _,O,K;let Y=N();Y&&(((_=Y.parentElement)==null?void 0:_.firstChild)===Y&&((K=(O=Y.closest(Io))==null?void 0:O.querySelector(qT))==null||K.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var _;return(_=C.current)==null?void 0:_.querySelector(`${$h}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(Fh))||[])}function $(_){let O=z()[_];O&&E.setState("value",O.getAttribute(Dr))}function M(_){var O;let K=N(),Y=z(),ae=Y.findIndex(D=>D===K),W=Y[ae+_];(O=a.current)!=null&&O.loop&&(W=ae+_<0?Y[Y.length-1]:ae+_===Y.length?Y[0]:Y[ae+_]),W&&E.setState("value",W.getAttribute(Dr))}function P(_){let O=N(),K=O==null?void 0:O.closest(Io),Y;for(;K&&!Y;)K=_>0?rk(K,Io):ok(K,Io),Y=K==null?void 0:K.querySelector(Fh);Y?E.setState("value",Y.getAttribute(Dr)):M(_)}let I=()=>$(z().length-1),V=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):M(1)},J=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):M(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var O;(O=y.onKeyDown)==null||O.call(y,_);let K=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||K))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&V(_);break}case"ArrowDown":{V(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let Y=N();if(Y){let ae=new Event(bl);Y.dispatchEvent(ae)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:ak},l),Xs(e,_=>h.createElement(zh.Provider,{value:E},h.createElement(Bh.Provider,{value:j},_))))}),YT=h.forwardRef((e,t)=>{var n,r;let o=Pt(),s=h.useRef(null),i=h.useContext(Hh),a=No(),l=Wh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Vh(o,s,[e.value,e.children,s],e.keywords),p=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(bl,v),()=>T.removeEventListener(bl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(me.div,{ref:Dn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),XT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=h.useRef(null),l=h.useRef(null),c=Pt(),d=No(),p=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Vh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(me.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Hh.Provider,{value:m},f))))}),JT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),ZT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=No();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(me.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),QT=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Gn(c=>c.selectedItemId),l=No();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(me.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),ek=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Ja,{open:n,onOpenChange:r},h.createElement(Za,{container:i},h.createElement(To,{"cmdk-overlay":"",className:o}),h.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Uh,{ref:t,...a}))))}),tk=h.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),nk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Uh,{List:QT,Item:YT,Input:ZT,Group:XT,Separator:JT,Dialog:ek,Empty:tk,Loading:nk});function rk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ok(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Wh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Lr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Vh(e,t,n,r=[]){let o=h.useRef(),s=No();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Dr,a),o.current=a}),o}var sk=()=>{let[e,t]=h.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function ik(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(ik(t),{ref:t.ref},n(t.props.children)):n(t)}var ak={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Kt.displayName;const Sl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Sl.displayName=Kt.Input.displayName;const Cl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Kt.List.displayName;const Tl=h.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Kt.Empty.displayName;const kl=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));kl.displayName=Kt.Group.displayName;const lk=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));lk.displayName=Kt.Separator.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));El.displayName=Kt.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function ck(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Kh,EN]=un(Nl),[uk,sn]=Kh(Nl),qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,j]=h.useState(!1),R=Fe(t,H=>l(H)),L=Xo(o);return u.jsx(uk,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(me.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});qh.displayName=Nl;var Gh="ScrollAreaViewport",Yh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(Gh,n),a=h.useRef(null),l=Fe(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Yh.displayName=Gh;var Nn="ScrollAreaScrollbar",Al=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(dk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(fk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Xh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(jl,{...r,ref:t}):null});Al.displayName=Nn;var dk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Xh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),fk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=ck("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Xh=h.forwardRef((e,t)=>{const n=sn(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(jl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),jl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(Nn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=tm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return vk(m,i.current,a,f)}return n==="horizontal"?u.jsx(pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=nm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(hk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=nm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Fe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zh,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),om(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),hk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Fe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Zh,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),om(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[mk,Jh]=Kh(Nn),Zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=sn(Nn,n),[v,g]=h.useState(null),x=Fe(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=vt(d),T=vt(l),E=ei(p,10);function j(R){if(y.current){const L=R.clientX-y.current.left,H=R.clientY-y.current.top;c({x:L,y:H})}}return h.useEffect(()=>{const R=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(mk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(R))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Qh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Jh(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(gk,{ref:t,...r})})}),gk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Jh(Js,n),{onThumbPositionChange:a}=i,l=Fe(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=bk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ce(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Qh.displayName=Js;var _l="ScrollAreaCorner",em=h.forwardRef((e,t)=>{const n=sn(_l,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(xk,{...e,ref:t}):null});em.displayName=_l;var xk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(_l,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function tm(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=tm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function vk(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return rm([l,c],p)(e)}function nm(e,t,n="ltr"){const r=Qs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Il(e,l);return rm([0,i],[0,a])(c)}function rm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function om(e,t){return e>0&&e<t}var bk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ei(e,t){const n=vt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=vt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var sm=qh,wk=Yh,yk=em;const Pl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(sm,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(wk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(im,{}),u.jsx(yk,{})]}));Pl.displayName=sm.displayName;const im=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Qh,{className:"relative flex-1 rounded-full bg-border"})}));im.displayName=Al.displayName;const Rl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Rl.displayName="Input";const Sk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Ck="bg-slate-700 border-slate-600 hover:bg-slate-600",Tk="bg-slate-600 border-slate-500";function am({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??Tk}`:`${x??Ck}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Sk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Rl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(de.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(zn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(de.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const lm=25,cm="thread-manager-view",kk=e=>e==="default"||e==="shared",Ek=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(cm);if(kk(e))return e}catch{}return null};function um({defaultView:e}={}){const[t,n]=b.useState(()=>Ek()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(cm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ik=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:B,clearShareStatus:q}=xr(),{createThread:N,deleteThread:z,renameThread:$,shareThread:M}=L,{loadThread:P}=eo(),I=i??T,[V,J]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(V.length>0),O=b.useRef(null),K=b.useRef(0),[Y,ae]=b.useState(null),[W,D]=b.useState(""),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(null),[ue,ge]=b.useState(""),Me=v&&v.length>0?v:Ik,Oe=um({defaultView:m}),Te=g??Oe,nt=p??Te.view,pt=b.useCallback(re=>{p||Te.setView(re),f==null||f(re)},[p,f,Te]),Tt=Me.find(re=>re.key===nt)??Me[0],Ke=re=>{se(re),ge(""),Z(!0)},Ge=()=>{Z(!1),se(null),ge(""),q()},Ve=b.useCallback(async re=>{if(!(!te||H)&&re.id)try{await M(te,re.id),setTimeout(()=>Ge(),600)}catch(ye){console.error("Failed to share thread:",ye)}},[Ge,H,te,M]),$e=b.useMemo(()=>{const re=y??[],ye=ue.trim().toLowerCase();return ye?S?re.filter(rt=>S(rt,ye)):re.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ye)):re},[y,ue,S]),He=nt==="shared",mt=He?C:V,Dt=He?R:j,lt=He?"No shared conversations yet":"No conversations yet",kt=re=>{const ye=re.sharedAt?` • ${Ae(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${ye}`},wt=re=>"sharedByUserId"in re;b.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,J(re);return}j||(_.current=!1,J(re))},[k,j]),b.useEffect(()=>{if(!O.current)return;const re=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let ye=null,rt=null;return ye=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{re.scrollTop=K.current})}),()=>{ye!==null&&cancelAnimationFrame(ye),rt!==null&&cancelAnimationFrame(rt)}},[V]);const gt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(ye){console.error("Failed to select thread:",ye)}},ht=async()=>{try{oe(!0);const re=await N();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{oe(!1)}},an=async(re,ye)=>{if(ye.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const rt=O.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(K.current=rt.scrollTop)}try{await z(re),d==null||d(re)}catch(rt){console.error("Failed to delete thread:",rt)}}},dt=(re,ye)=>{ye.stopPropagation(),ae(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},ke=async re=>{if(W.trim())try{await $(re,W.trim()),ae(null),D("")}catch(ye){console.error("Failed to update title:",ye)}},et=()=>{ae(null),D("")},Ae=re=>{if(!re)return"";try{const ye=new Date(re),xe=new Date().getTime()-ye.getTime(),Pe=Math.floor(xe/(1e3*60*60*24));return Pe===0?ye.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ye.toLocaleDateString()}catch{return""}},Le=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Bt=re=>{const ye=Le(re);return ye.length<=lm?ye:`${ye.slice(0,lm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Qe,{onClick:ht,disabled:X||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(de.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:Tt.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:Me.map(re=>u.jsxs(zn,{className:"justify-between text-[12px]",onClick:ye=>{ye.preventDefault(),pt(re.key)},children:[u.jsx("span",{children:re.label}),nt===re.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(Pl,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:Dt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:lt})]}):mt.slice().sort((re,ye)=>new Date(ye.updatedAt||ye.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(am,{thread:re,isActive:I===re.threadId,editingThreadId:Y,editingTitle:W,onSelect:gt,onStartEditing:dt,onEditingTitleChange:ye=>D(ye),onSaveEditing:ke,onCancelEditing:et,onShare:()=>Ke(re.threadId),onDelete:an,showEditTitle:r,showDeleteButton:n,formatDate:Ae,getDisplayThreadTitle:Bt,secondaryLine:He&&wt(re)?kt(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:G,onOpenChange:re=>!re&&Ge(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:ue,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[B&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:B.startsWith("Failed")?"text-red-500":B.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:B})]}),u.jsx(Tl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),$e.length>0&&u.jsx(kl,{heading:"Recipients",children:$e.map(re=>u.jsx(El,{onSelect:()=>Ve(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function Nk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Or,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Ak({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function jk({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function _k({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(de.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(de.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(jk,{placeholder:t,onMessageSent:r})})]})})}):null}function Pk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(de.Edit3,{size:16}),t??e]})}var Rk="Label",dm=h.forwardRef((e,t)=>u.jsx(me.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));dm.displayName=Rk;var fm=dm;const Mk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),pm=h.forwardRef(({className:e,...t},n)=>u.jsx(fm,{ref:n,className:ne(Mk(),e),...t}));pm.displayName=fm.displayName;function hm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var mm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ok="VisuallyHidden",ni=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...mm,...e.style}}));ni.displayName=Ok;var Dk=ni,Lk=[" ","Enter","ArrowUp","ArrowDown"],$k=[" ","Enter"],dr="Select",[ri,oi,Fk]=Yo(dr),[Fr,IN]=un(dr,[Fk,Er]),si=Er(),[Bk,Yn]=Fr(dr),[zk,Hk]=Fr(dr),gm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Xo(c),[E,j]=Ln({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,L]=Ln({prop:i,defaultProp:a,onChange:l,caller:dr}),H=h.useRef(null),B=x?v||!!x.closest("form"):!0,[q,N]=h.useState(new Set),z=Array.from(q).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Bk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:R,onValueChange:L,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(zk,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback($=>{N(M=>new Set(M).add($))},[]),onNativeOptionRemove:h.useCallback($=>{N(M=>{const P=new Set(M);return P.delete($),P})},[]),children:n})}),B?u.jsxs(Bm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:$=>L($.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(q)]},z):null]})})};gm.displayName=dr;var xm="SelectTrigger",vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Yn(xm,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),c=oi(n),d=h.useRef("touch"),[p,m,f]=Hm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Um(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{asChild:!0,...s,children:u.jsx(me.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":zm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ce(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Lk.includes(g.key)&&(v(),g.preventDefault())})})})});vm.displayName=xm;var bm="SelectValue",wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(bm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Fe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:p,style:{pointerEvents:"none"},children:zm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=bm;var Uk="SelectIcon",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});ym.displayName=Uk;var Wk="SelectPortal",Sm=e=>u.jsx(so,{asChild:!0,...e});Sm.displayName=Wk;var fr="SelectContent",Cm=h.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Tm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(km,{...e,ref:t})});Cm.displayName=fr;var gn=10,[Tm,Xn]=Fr(fr),Vk="SelectContentImpl",Kk=Yt.createSlot("SelectContent.RemoveScroll"),km=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=Fe(t,W=>k(W)),[j,R]=h.useState(null),[L,H]=h.useState(null),B=oi(n),[q,N]=h.useState(!1),z=h.useRef(!1);h.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=h.useCallback(W=>{const[D,...X]=B().map(Z=>Z.ref.current),[oe]=X.slice(-1),G=document.activeElement;for(const Z of W)if(Z===G||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===D&&C&&(C.scrollTop=0),Z===oe&&C&&(C.scrollTop=C.scrollHeight),Z==null||Z.focus(),document.activeElement!==G))return},[B,C]),M=h.useCallback(()=>$([j,S]),[$,j,S]);h.useEffect(()=>{q&&M()},[q,M]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(S){let W={x:0,y:0};const D=oe=>{var G,Z;W={x:Math.abs(Math.round(oe.pageX)-(((G=I.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(oe.pageY)-(((Z=I.current)==null?void 0:Z.y)??0))}},X=oe=>{W.x<=10&&W.y<=10?oe.preventDefault():S.contains(oe.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,I]),h.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[V,J]=Hm(W=>{const D=B().filter(G=>!G.disabled),X=D.find(G=>G.ref.current===document.activeElement),oe=Um(D,W,X);oe&&setTimeout(()=>oe.ref.current.focus())}),_=h.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&(R(W),oe&&(z.current=!0))},[w.value]),O=h.useCallback(()=>S==null?void 0:S.focus(),[S]),K=h.useCallback((W,D,X)=>{const oe=!z.current&&!X;(w.value!==void 0&&w.value===D||oe)&&H(W)},[w.value]),Y=r==="popper"?Ml:Em,ae=Y===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Tm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:O,itemTextRefCallback:K,focusSelectedItem:M,selectedItemText:L,position:r,isPositioned:q,searchRef:V,children:u.jsx(gs,{as:Kk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...ae,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const D=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!D&&W.key.length===1&&J(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let oe=B().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(W.key)&&(oe=oe.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const G=W.target,Z=oe.indexOf(G);oe=oe.slice(Z+1)}setTimeout(()=>$(oe)),W.preventDefault()}})})})})})})});km.displayName=Vk;var qk="SelectItemAlignedPosition",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Fe(t,E=>d(E)),m=oi(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const G=L.left-j.left,Z=R.left-G,te=E.left-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Me=Il(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.left=Me+"px"}else{const G=j.right-L.right,Z=window.innerWidth-R.right-G,te=window.innerWidth-E.right-Z,se=E.width+te,ue=Math.max(se,j.width),ge=window.innerWidth-gn,Me=Il(Z,[gn,Math.max(gn,ge-ue)]);a.style.minWidth=se+"px",a.style.right=Me+"px"}const H=m(),B=window.innerHeight-gn*2,q=g.scrollHeight,N=window.getComputedStyle(c),z=parseInt(N.borderTopWidth,10),$=parseInt(N.paddingTop,10),M=parseInt(N.borderBottomWidth,10),P=parseInt(N.paddingBottom,10),I=z+$+q+P+M,V=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),O=parseInt(J.paddingBottom,10),K=E.top+E.height/2-gn,Y=B-K,ae=x.offsetHeight/2,W=x.offsetTop+ae,D=z+$+W,X=I-D;if(D<=K){const G=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-g.offsetTop-g.offsetHeight,te=Math.max(Y,ae+(G?O:0)+Z+M),se=D+te;a.style.height=se+"px"}else{const G=H.length>0&&x===H[0].ref.current;a.style.top="0px";const te=Math.max(K,z+g.offsetTop+(G?_:0)+ae)+X;a.style.height=te+"px",g.scrollTop=D-K+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=h.useState();It(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(Yk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(me.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Em.displayName=qk;var Gk="SelectPopperPosition",Ml=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=si(n);return u.jsx(ia,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ml.displayName=Gk;var[Yk,Ol]=Fr(fr,{}),Dl="SelectViewport",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Dl,n),i=Ol(Dl,n),a=Fe(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-gn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Im.displayName=Dl;var Nm="SelectGroup",[Xk,Jk]=Fr(Nm),Zk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(Xk,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Zk.displayName=Nm;var Am="SelectLabel",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Jk(Am,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});jm.displayName=Am;var ii="SelectItem",[Qk,_m]=Fr(ii),Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ii,n),l=Xn(ii,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=Fe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Pt(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Qk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||($k.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Pm.displayName=ii;var Ao="SelectItemText",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(Ao,n),a=Xn(Ao,n),l=_m(Ao,n),c=Hk(Ao,n),[d,p]=h.useState(null),m=Fe(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Rm.displayName=Ao;var Mm="SelectItemIndicator",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return _m(Mm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Om.displayName=Mm;var Ll="SelectScrollUpButton",Dm=h.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=h.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Dm.displayName=Ll;var $l="SelectScrollDownButton",Lm=h.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=h.useState(!1),i=Fe(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx($m,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Lm.displayName=$l;var $m=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=h.useRef(null),a=oi(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),eE="SelectSeparator",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Fm.displayName=eE;var Fl="SelectArrow",tE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Yn(Fl,n),i=Xn(Fl,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});tE.displayName=Fl;var nE="SelectBubbleInput",Bm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Fe(r,o),i=hm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(me.select,{...n,style:{...mm,...n.style},ref:s,defaultValue:t})});Bm.displayName=nE;function zm(e){return e===""||e===void 0}function Hm(e){const t=vt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Um(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=rE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function rE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oE=gm,Wm=vm,sE=wm,iE=ym,aE=Sm,Vm=Cm,lE=Im,Km=jm,qm=Pm,cE=Rm,uE=Om,Gm=Dm,Ym=Lm,Xm=Fm;const dE=oE,fE=sE,Jm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wm,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(iE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Jm.displayName=Wm.displayName;const Zm=h.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));Qm.displayName=Ym.displayName;const eg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(aE,{children:u.jsxs(Vm,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Zm,{}),u.jsx(lE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Qm,{})]})}));eg.displayName=Vm.displayName;const pE=h.forwardRef(({className:e,...t},n)=>u.jsx(Km,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));pE.displayName=Km.displayName;const tg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(qm,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(uE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(cE,{children:t})]}));tg.displayName=qm.displayName;const hE=h.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hE.displayName=Xm.displayName;var mE="Separator",ng="horizontal",gE=["horizontal","vertical"],rg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=ng,...o}=e,s=xE(r)?r:ng,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});rg.displayName=mE;function xE(e){return gE.includes(e)}var og=rg;const sg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(og,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sg.displayName=og.displayName;var ai="Switch",[vE,NN]=un(ai),[bE,wE]=vE(ai),ig=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=Fe(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Ln({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(bE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":ug(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(cg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ig.displayName=ai;var ag="SwitchThumb",lg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=wE(ag,n);return u.jsx(me.span,{"data-state":ug(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});lg.displayName=ag;var yE="SwitchBubbleInput",cg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Fe(i,s),l=hm(n),c=bd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});cg.displayName=yE;function ug(e){return e?"checked":"unchecked"}var dg=ig,SE=lg;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(SE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));fg.displayName=dg.displayName;const CE=Ja,TE=cT,kE=Za,pg=h.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));pg.displayName=To.displayName;const EE=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(kE,{children:[u.jsx(pg,{}),u.jsxs(ko,{ref:o,className:ne(EE({side:e}),t),...r,children:[n,u.jsxs(sh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const mg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});mg.displayName="SheetHeader";const gg=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));gg.displayName=lr.displayName;const xg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));xg.displayName=Fs.displayName;var[li,AN]=un("Tooltip",[Er]),ci=Er(),vg="TooltipProvider",IE=700,Bl="tooltip.open",[NE,zl]=li(vg),bg=e=>{const{__scopeTooltip:t,delayDuration:n=IE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(NE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};bg.displayName=vg;var jo="Tooltip",[AE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(jo,e.__scopeTooltip),c=ci(t),[d,p]=h.useState(null),m=Pt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=Ln({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:jo}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(AE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var Hl="TooltipTrigger",yg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(Hl,n),s=zl(Hl,n),i=ci(n),a=h.useRef(null),l=Fe(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});yg.displayName=Hl;var jE="TooltipPortal",[jN,_E]=li(jE,{forceMount:void 0}),Br="TooltipContent",Sg=h.forwardRef((e,t)=>{const n=_E(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Br,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Cg,{side:o,...s,ref:t}):u.jsx(PE,{side:o,...s,ref:t})})}),PE=h.forwardRef((e,t)=>{const n=ui(Br,e.__scopeTooltip),r=zl(Br,e.__scopeTooltip),o=h.useRef(null),s=Fe(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=LE(y,x.getBoundingClientRect()),S=$E(y,w),k=FE(g.getBoundingClientRect()),C=zE([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!BE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Cg,{...e,ref:s})}),[RE,ME]=li(jo,{isInside:!1}),OE=Yt.createSlottable("TooltipContent"),Cg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Br,n),c=ci(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Bl,d),()=>document.removeEventListener(Bl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(OE,{children:r}),u.jsx(RE,{scope:n,isInside:!0,children:u.jsx(Dk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Sg.displayName=Br;var Tg="TooltipArrow",DE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return ME(Tg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});DE.displayName=Tg;function LE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function $E(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function FE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function BE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function zE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),HE(t)}function HE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var UE=bg,WE=wg,VE=yg,kg=Sg;const KE=UE,qE=WE,GE=VE,Eg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(kg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Eg.displayName=kg.displayName;var Ul="ToastProvider",[Wl,YE,XE]=Yo("Toast"),[Ig,_N]=un("Toast",[XE]),[JE,di]=Ig(Ul),Ng=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ul}\`. Expected non-empty \`string\`.`),u.jsx(Wl.Provider,{scope:t,children:u.jsx(JE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Ng.displayName=Ul;var Ag="ToastViewport",ZE=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",jg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=ZE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ag,n),a=YE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Fe(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...dI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const B=g({tabbingDirection:R?"backwards":"forwards"}),q=B.findIndex(N=>N===j);Yl(B.slice(q+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Lb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(ql,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Yl(x)}}),u.jsx(Wl.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(ql,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Yl(x)}})]})});jg.displayName=Ag;var _g="ToastFocusProxy",ql=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(_g,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ql.displayName=_g;var _o="Toast",QE="toast.swipeStart",eI="toast.swipeMove",tI="toast.swipeCancel",nI="toast.swipeEnd",Pg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Ln({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(sI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ce(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ce(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Pg.displayName=_o;var[rI,oI]=Ig(_o,{onClose(){}}),sI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=h.useState(null),w=Fe(t,N=>y(N)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),j=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=vt(()=>{var z;(x==null?void 0:x.contains(document.activeElement))&&((z=g.viewport)==null||z.focus()),i()}),B=h.useCallback(N=>{!N||N===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(H,N))},[H]);h.useEffect(()=>{const N=g.viewport;if(N){const z=()=>{B(E.current),c==null||c()},$=()=>{const M=new Date().getTime()-T.current;E.current=E.current-M,window.clearTimeout(j.current),l==null||l()};return N.addEventListener(Vl,$),N.addEventListener(Kl,z),()=>{N.removeEventListener(Vl,$),N.removeEventListener(Kl,z)}}},[g.viewport,C,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(C)},[s,C,g.isClosePausedRef,B]),h.useEffect(()=>(R(),()=>L()),[R,L]);const q=h.useMemo(()=>x?Fg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[q&&u.jsx(iI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:q}),u.jsx(rI,{scope:n,onClose:H,children:Hr.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx(Db,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ce(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:ce(e.onPointerMove,N=>{if(!S.current)return;const z=N.clientX-S.current.x,$=N.clientY-S.current.y,M=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=P?I(0,z):0,J=P?0:I(0,$),_=N.pointerType==="touch"?10:2,O={x:V,y:J},K={originalEvent:N,delta:O};M?(k.current=O,fi(eI,p,K,{discrete:!1})):Bg(O,g.swipeDirection,_)?(k.current=O,fi(QE,d,K,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(z)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,N=>{const z=k.current,$=N.target;if($.hasPointerCapture(N.pointerId)&&$.releasePointerCapture(N.pointerId),k.current=null,S.current=null,z){const M=N.currentTarget,P={originalEvent:N,delta:z};Bg(z,g.swipeDirection,g.swipeThreshold)?fi(nI,f,P,{discrete:!0}):fi(tI,m,P,{discrete:!0}),M.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),iI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return cI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},aI="ToastTitle",Rg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Rg.displayName=aI;var lI="ToastDescription",Mg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Mg.displayName=lI;var Og="ToastAction",Dg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx($g,{altText:n,asChild:!0,children:u.jsx(Gl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Og}\`. Expected non-empty \`string\`.`),null)});Dg.displayName=Og;var Lg="ToastClose",Gl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=oI(Lg,n);return u.jsx($g,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});Gl.displayName=Lg;var $g=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Fg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),uI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Fg(r))}}),t}function fi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Bg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function cI(e=()=>{}){const t=vt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function uI(e){return e.nodeType===e.ELEMENT_NODE}function dI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Yl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var fI=Ng,zg=jg,Hg=Pg,Ug=Rg,Wg=Mg,Vg=Dg,Kg=Gl;const pI=fI,qg=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));qg.displayName=zg.displayName;const hI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Gg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Hg,{ref:r,className:ne(hI({variant:t}),e),...n}));Gg.displayName=Hg.displayName;const mI=h.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));mI.displayName=Vg.displayName;const Yg=h.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(de.X,{className:"h-4 w-4"})}));Yg.displayName=Kg.displayName;const Xg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:ne("text-sm font-semibold",e),...t}));Xg.displayName=Ug.displayName;const Jg=h.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Jg.displayName=Wg.displayName;function gI(){const{toasts:e}=nl();return u.jsxs(pI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Gg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Xg,{children:n}),r&&u.jsx(Jg,{children:r})]}),o,u.jsx(Yg,{})]},t)}),u.jsx(qg,{})]})}var xI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},vI=h.createContext(void 0),bI={setTheme:e=>{},themes:[]},wI=()=>{var e;return(e=h.useContext(vI))!=null?e:bI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${xI.toString()})(${d})`}})});var yI=e=>{switch(e){case"success":return TI;case"info":return EI;case"warning":return kI;case"error":return II;default:return null}},SI=Array(12).fill(0),CI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},SI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),TI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),kI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.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"})),EI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),II=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.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"})),NI=b.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"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),AI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,jI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let 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;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Xl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,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 n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(PI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},qt=new jI,_I=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return qt.addToast({title:e,...t,id:n}),n},PI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",RI=_I,MI=()=>qt.toasts,OI=()=>qt.getActiveToasts();Object.assign(RI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:MI,getToasts:OI});function DI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}DI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
|
+
`);function pi(e){return e.label!==void 0}var LI=3,$I="32px",FI="16px",Zg=4e3,BI=356,zI=14,HI=20,UI=200;function xn(...e){return e.filter(Boolean).join(" ")}function WI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var VI=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:R,cancelButtonStyle:L,actionButtonStyle:H,className:B="",descriptionClassName:q="",duration:N,position:z,gap:$,loadingIcon:M,expandByDefault:P,classNames:I,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[O,K]=b.useState(null),[Y,ae]=b.useState(null),[W,D]=b.useState(!1),[X,oe]=b.useState(!1),[G,Z]=b.useState(!1),[te,se]=b.useState(!1),[ue,ge]=b.useState(!1),[Me,Oe]=b.useState(0),[Te,nt]=b.useState(0),pt=b.useRef(f.duration||N||Zg),Tt=b.useRef(null),Ke=b.useRef(null),Ge=S===0,Ve=S+1<=y,$e=f.type,He=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",lt=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),kt=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:j},[f.closeButton,j]),wt=b.useMemo(()=>f.duration||N||Zg,[f.duration,N]),gt=b.useRef(0),ht=b.useRef(0),an=b.useRef(0),dt=b.useRef(null),[ke,et]=z.split("-"),Ae=b.useMemo(()=>w.reduce((xe,Pe,Xe)=>Xe>=lt?xe:xe+Pe.height,0),[w,lt]),Le=AI(),Bt=f.invert||m,re=$e==="loading";ht.current=b.useMemo(()=>lt*$+Ae,[lt,Ae]),b.useEffect(()=>{pt.current=wt},[wt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let xe=Ke.current;if(xe){let Pe=xe.getBoundingClientRect().height;return nt(Pe),x(Xe=>[{toastId:f.id,height:Pe,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(St=>St.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=Ke.current,Pe=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Pe,nt(Xe),x(St=>St.find(Et=>Et.toastId===f.id)?St.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...St])},[W,f.title,f.description,x,f.id]);let ye=b.useCallback(()=>{oe(!0),Oe(ht.current),x(xe=>xe.filter(Pe=>Pe.toastId!==f.id)),setTimeout(()=>{T(f)},UI)},[f,T,x,ht]);b.useEffect(()=>{if(f.promise&&$e==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Le?(()=>{if(an.current<gt.current){let Pe=new Date().getTime()-gt.current;pt.current=pt.current-Pe}an.current=new Date().getTime()})():pt.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Pe;(Pe=f.onAutoClose)==null||Pe.call(f,f),ye()},pt.current)),()=>clearTimeout(xe)},[C,g,f,$e,_,Le,ye]),b.useEffect(()=>{f.delete&&ye()},[ye,f.delete]);function rt(){var xe,Pe,Xe;return V!=null&&V.loading?b.createElement("div",{className:xn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":$e==="loading"},V.loading):M?b.createElement("div",{className:xn(I==null?void 0:I.loader,(Pe=f==null?void 0:f.classNames)==null?void 0:Pe.loader,"sonner-loader"),"data-visible":$e==="loading"},M):b.createElement(CI,{className:xn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:$e==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ke,className:xn(B,mt,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[$e],(n=f==null?void 0:f.classNames)==null?void 0:n[$e]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":X,"data-visible":Ve,"data-y-position":ke,"data-x-position":et,"data-index":S,"data-front":Ge,"data-swiping":G,"data-dismissible":He,"data-type":$e,"data-invert":Bt,"data-swipe-out":te,"data-swipe-direction":Y,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Me:ht.current}px`,"--initial-height":P?"auto":`${Te}px`,...R,...f.style},onDragEnd:()=>{Z(!1),K(null),dt.current=null},onPointerDown:xe=>{re||!He||(Tt.current=new Date,Oe(ht.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(Z(!0),dt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Pe,Xe,St;if(te||!He)return;dt.current=null;let Et=Number(((xe=Ke.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Pe=Ke.current)==null?void 0:Pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),zt=new Date().getTime()-((Xe=Tt.current)==null?void 0:Xe.getTime()),_e=O==="x"?Et:Nt,ct=Math.abs(_e)/zt;if(Math.abs(_e)>=HI||ct>.11){Oe(ht.current),(St=f.onDismiss)==null||St.call(f,f),ae(O==="x"?Et>0?"right":"left":Nt>0?"down":"up"),ye(),se(!0),ge(!1);return}Z(!1),K(null)},onPointerMove:xe=>{var Pe,Xe,St,Et;if(!dt.current||!He||((Pe=window.getSelection())==null?void 0:Pe.toString().length)>0)return;let Nt=xe.clientY-dt.current.y,zt=xe.clientX-dt.current.x,_e=(Xe=e.swipeDirections)!=null?Xe:WI(z);!O&&(Math.abs(zt)>1||Math.abs(Nt)>1)&&K(Math.abs(zt)>Math.abs(Nt)?"x":"y");let ct={x:0,y:0};O==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&&Nt<0||_e.includes("bottom")&&Nt>0)&&(ct.y=Nt):O==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&zt<0||_e.includes("right")&&zt>0)&&(ct.x=zt),(Math.abs(ct.x)>0||Math.abs(ct.y)>0)&&ge(!0),(St=Ke.current)==null||St.style.setProperty("--swipe-amount-x",`${ct.x}px`),(Et=Ke.current)==null||Et.style.setProperty("--swipe-amount-y",`${ct.y}px`)}},kt&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var xe;ye(),(xe=f.onDismiss)==null||xe.call(f,f)},className:xn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:NI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,$e||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:xn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||rt():null,f.type!=="loading"?f.icon||(V==null?void 0:V[$e])||yI($e):null):null,b.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:xn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:xn(q,Dt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&pi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Pe,Xe;pi(f.cancel)&&He&&((Xe=(Pe=f.cancel).onClick)==null||Xe.call(Pe,xe),ye())},className:xn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&pi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:xe=>{var Pe,Xe;pi(f.action)&&((Xe=(Pe=f.action).onClick)==null||Xe.call(Pe,xe),!xe.defaultPrevented&&ye())},className:xn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Qg(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function KI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?FI:$I;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var qI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=LI,toastOptions:g,dir:x=Qg(),gap:y=zI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,L]=b.useState([]),[H,B]=b.useState(!1),[q,N]=b.useState(!1),[z,$]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),V=b.useRef(!1),J=b.useCallback(_=>{E(O=>{var K;return(K=O.find(Y=>Y.id===_.id))!=null&&K.delete||qt.dismiss(_.id),O.filter(({id:Y})=>Y!==_.id)})},[]);return b.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(O=>O.map(K=>K.id===_.id?{...K,delete:!0}:K));return}setTimeout(()=>{Po.flushSync(()=>{E(O=>{let K=O.findIndex(Y=>Y.id===_.id);return K!==-1?[...O.slice(0,K),{...O[K],..._},...O.slice(K+1)]:[_,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:O})=>{$(O?"dark":"light")})}catch{_.addListener(({matches:K})=>{try{$(K?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),b.useEffect(()=>{T.length<=1&&B(!1)},[T]),b.useEffect(()=>{let _=O=>{var K,Y;o.every(ae=>O[ae]||O.code===ae)&&(B(!0),(K=M.current)==null||K.focus()),O.code==="Escape"&&(document.activeElement===M.current||(Y=M.current)!=null&&Y.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(M.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,V.current=!1)}},[M.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,O)=>{var K;let[Y,ae]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?Qg():x,tabIndex:-1,ref:M,className:a,"data-sonner-toaster":!0,"data-theme":z,"data-y-position":Y,"data-lifted":H&&T.length>1&&!s,"data-x-position":ae,style:{"--front-toast-height":`${((K=R[0])==null?void 0:K.height)||0}px`,"--width":`${BI}px`,"--gap":`${y}px`,...f,...KI(l,c)},onBlur:W=>{V.current&&!W.currentTarget.contains(W.relatedTarget)&&(V.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||V.current||(V.current=!0,I.current=W.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{q||B(!1)},onDragEnd:()=>B(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(W=>!W.position&&O===0||W.position===_).map((W,D)=>{var X,oe;return b.createElement(VI,{key:W.id,icons:S,index:D,toast:W,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(oe=g==null?void 0:g.closeButton)!=null?oe:i,interacting:q,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(G=>G.position==W.position),heights:R.filter(G=>G.position==W.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const GI=({...e})=>{const{theme:t="system"}=wI();return u.jsx(qI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=Bv,F.ApiClient=Fv,F.ApiProvider=nu,F.ArtifactRenderer=sl,F.Badge=Hp,F.Button=Qe,F.Card=il,F.CardContent=ul,F.CardDescription=cl,F.CardHeader=al,F.CardTitle=ll,F.ChatApi=Ko,F.ChatApp=Nk,F.ChatInput=Uf,F.ChatInterface=Or,F.ChatProviders=br,F.ChatWidget=_k,F.Command=yl,F.CommandEmpty=Tl,F.CommandGroup=kl,F.CommandInput=Sl,F.CommandItem=El,F.CommandList=Cl,F.DEFAULT_TIMEOUT_MS=Xc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=po,F.DropdownMenuItem=zn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=lh,F.HISTORY_TIMEOUT_MS=Jc,F.Input=Rl,F.InterruptPartRenderer=Eh,F.Label=pm,F.MarkdownContent=Mr,F.MessageBody=_h,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=pl,F.NewChatButton=Pk,F.PlotArtifact=Sh,F.ResearchTaskArtifact=Th,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=Pl,F.Select=dE,F.SelectContent=eg,F.SelectItem=tg,F.SelectTrigger=Jm,F.SelectValue=fE,F.Separator=sg,F.Sheet=CE,F.SheetContent=hg,F.SheetDescription=xg,F.SheetHeader=mg,F.SheetTitle=gg,F.SheetTrigger=TE,F.SimpleChat=Ak,F.SimpleJsonView=dl,F.Sonner=GI,F.StreamProgress=Ih,F.Switch=fg,F.Textarea=Ta,F.ThinkingIndicator=Ah,F.ThreadListItem=am,F.ThreadManager=ti,F.ThreadStateProvider=ku,F.ThreadsProvider=pu,F.TimelineColumn=gx,F.Toaster=gI,F.ToolComponent=Nh,F.Tooltip=qE,F.TooltipContent=Eg,F.TooltipProvider=KE,F.TooltipTrigger=GE,F.UserTextContent=jh,F.applySettings=wb,F.buildCheckpointIndex=ec,F.buildCheckpointPreviewMap=sx,F.chatApiClient=On,F.del=Ai,F.downloadFileById=Qc,F.extractConfigFields=mi,F.fileToBase64=ru,F.get=Jt,F.getChatToken=Gc,F.getCheckpointForMessage=ix,F.getCurrentSettings=bb,F.getDefaultApiConfig=Mu,F.getDefaultChatSettings=Ou,F.getFileContent=_i,F.getFileInfo=Hv,F.getMessageAttemptInfo=tc,F.getMessageDomKey=fl,F.getPreviewForMessage=hi,F.httpClient=Xt,F.hydrateHistorySnapshots=Mn,F.isEnvelope=su,F.listFiles=eu,F.loadStoredSettings=Du,F.onChatTokenChanged=Yc,F.post=Vo,F.processAttachments=ou,F.put=Zc,F.readNumber=rc,F.readString=Rn,F.resolveChatBaseUrl=bn,F.saveSettings=Lu,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=Lt,F.useApi=Xr,F.useCheckpointIndex=nc,F.useFilePreview=Ph,F.useHasChatSession=gb,F.useParsedMessageContent=Rh,F.useShallowStableValue=ju,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=yu,F.useThreadManagerViewState=um,F.useThreadState=eo,F.useThreadStateUpdater=Tu,F.useThreads=xr,F.useThreadsState=du,F.viewFileById=zv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|