teodor-new-chat-ui 4.3.434 → 4.3.436
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/features/messaging/components/message/MessageBody.d.ts +9 -2
- package/dist/index.esm.js +2871 -2809
- package/dist/index.umd.js +31 -31
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(B,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(B=typeof globalThis<"u"?globalThis:B||self,w(B.NewChatUI={},B.React,B.reactSlot,B.classVarianceAuthority,B.clsx,B.tailwindMerge,B.ReactDOM,B.LucideReact))})(this,function(B,w,Yt,zr,tx,nx,Po,le){"use strict";var GI=Object.defineProperty;var YI=(B,w,Yt)=>w in B?GI(B,w,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):B[w]=Yt;var Qg=(B,w,Yt)=>YI(B,typeof w!="symbol"?w+"":w,Yt);function Jl(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 p=Jl(w),Hr=Jl(Po),Zl=120;function rx(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>Zl?`${n.slice(0,Zl-3)}…`:n:""}function pi(e){return rx(e.content)||""}function ox(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=pi(o);s&&t.set(r.checkpointId,s)}}return t}function Ql(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`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 b=Array.isArray(d.messages)?d.messages:[];for(const T of b)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),h&&t.set(h,C),h&&y){const T=pi(y);T&&r.set(h,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((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===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 h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function ec(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 sx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return w.useMemo(()=>Ql(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Pn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function nc(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=_n(e);if(t)return _n(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)=>ix(s,i)).filter(s=>!!s)].sort((s,i)=>rc(i.createdAt)-rc(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 ix(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=>ax(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=mi(e.config),i=_n(e.parent_config??e.parentConfig),a=mi(i),l=Pn(s,["checkpoint_id","checkpointId"]),c=Pn(s,["checkpoint_ns","checkpointNs"]),d=Pn(a,["checkpoint_id","checkpointId"]),h=Pn(a,["checkpoint_id","checkpointId"])??null,m=Pn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(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:nc(o,["step"])??0,source:Pn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:dx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ax(e){var s,i,a;if(!e||typeof e!="object")return null;const t=lx(e);if(!t)return null;const n=ux(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 lx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&cx(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 cx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"}function ux(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function dx(e,t){return fx(e,t)}function fx(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 rc(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 oc;function hx(){if(oc)return Ur;oc=1;var e=w,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,h={},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)&&(h[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)h[d]===void 0&&(h[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:h,_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,30 +14,30 @@
|
|
|
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
|
|
18
|
-
`+
|
|
17
|
+
*/var sc;function px(){return sc||(sc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,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"),h=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 b(A){{for(var Q=arguments.length,he=new Array(Q>1?Q-1:0),Ie=1;Ie<Q;Ie++)he[Ie-1]=arguments[Ie];S("error",A,he)}}function S(A,Q,he){{var Ie=y.ReactDebugCurrentFrame,Je=Ie.getStackAddendum();Je!==""&&(Q+="%s",he=he.concat([Je]));var nt=he.map(function(ie){return String(ie)});nt.unshift("Warning: "+Q),Function.prototype.apply.call(console[A],console,nt)}}var k=!1,C=!1,T=!1,E=!1,N=!1,R;R=Symbol.for("react.module.reference");function L(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||N||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===h||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===R||A.getModuleId!==void 0))}function z(A,Q,he){var Ie=A.displayName;if(Ie)return Ie;var Je=Q.displayName||Q.name||"";return Je!==""?he+"("+Je+")":he}function V(A){return A.displayName||"Context"}function U(A){if(A==null)return null;if(typeof A.tag=="number"&&b("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 V(Q)+".Consumer";case i:var he=A;return V(he._context)+".Provider";case l:return z(A,A.render,"ForwardRef");case h:var Ie=A.displayName||null;return Ie!==null?Ie:U(A.type)||"Memo";case m:{var Je=A,nt=Je._payload,ie=Je._init;try{return U(ie(nt))}catch{return null}}}return null}var j=Object.assign,W=0,$,O,P,I,q,Y,_;function M(){}M.__reactDisabledLog=!0;function G(){{if(W===0){$=console.log,O=console.info,P=console.warn,I=console.error,q=console.group,Y=console.groupCollapsed,_=console.groupEnd;var A={configurable:!0,enumerable:!0,value:M,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}W++}}function J(){{if(W--,W===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},A,{value:$}),info:j({},A,{value:O}),warn:j({},A,{value:P}),error:j({},A,{value:I}),group:j({},A,{value:q}),groupCollapsed:j({},A,{value:Y}),groupEnd:j({},A,{value:_})})}W<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=y.ReactCurrentDispatcher,K;function D(A,Q,he){{if(K===void 0)try{throw Error()}catch(Je){var Ie=Je.stack.trim().match(/\n( *(at )?)/);K=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+K+A}}var X=!1,Z;{var ue=typeof WeakMap=="function"?WeakMap:Map;Z=new ue}function F(A,Q){if(!A||X)return"";{var he=Z.get(A);if(he!==void 0)return he}var Ie;X=!0;var Je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var nt;nt=oe.current,oe.current=null,G();try{if(Q){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(Gt){Ie=Gt}Reflect.construct(A,[],ie)}else{try{ie.call()}catch(Gt){Ie=Gt}A.call(ie.prototype)}}else{try{throw Error()}catch(Gt){Ie=Gt}A()}}catch(Gt){if(Gt&&Ie&&typeof Gt.stack=="string"){for(var fe=Gt.stack.split(`
|
|
19
19
|
`),Ne=Ie.stack.split(`
|
|
20
20
|
`),Oe=fe.length-1,et=Ne.length-1;Oe>=1&&et>=0&&fe[Oe]!==Ne[et];)et--;for(;Oe>=1&&et>=0;Oe--,et--)if(fe[Oe]!==Ne[et]){if(Oe!==1||et!==1)do if(Oe--,et--,et<0||fe[Oe]!==Ne[et]){var pt=`
|
|
21
|
-
`+fe[Oe].replace(" at new "," at ");return A.displayName&&pt.includes("<anonymous>")&&(pt=pt.replace("<anonymous>",A.displayName)),typeof A=="function"&&Z.set(A,pt),pt}while(Oe>=1&&et>=0);break}}}finally{X=!1,oe.current=nt,J(),Error.prepareStackTrace=Je}var Br=A?A.displayName||A.name:"",fr=Br?
|
|
21
|
+
`+fe[Oe].replace(" at new "," at ");return A.displayName&&pt.includes("<anonymous>")&&(pt=pt.replace("<anonymous>",A.displayName)),typeof A=="function"&&Z.set(A,pt),pt}while(Oe>=1&&et>=0);break}}}finally{X=!1,oe.current=nt,J(),Error.prepareStackTrace=Je}var Br=A?A.displayName||A.name:"",fr=Br?D(Br):"";return typeof A=="function"&&Z.set(A,fr),fr}function ne(A,Q,he){return F(A,!1)}function de(A){var Q=A.prototype;return!!(Q&&Q.isReactComponent)}function ce(A,Q,he){if(A==null)return"";if(typeof A=="function")return F(A,de(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 ne(A.render);case h:return ce(A.type,Q,he);case m:{var Ie=A,Je=Ie._payload,nt=Ie._init;try{return ce(nt(Je),Q,he)}catch{}}}return""}var ge=Object.prototype.hasOwnProperty,Ce={},Pe=y.ReactDebugCurrentFrame;function De(A){if(A){var Q=A._owner,he=ce(A.type,A._source,Q?Q.type:null);Pe.setExtraStackFrame(he)}else Pe.setExtraStackFrame(null)}function ze(A,Q,he,Ie,Je){{var nt=Function.call.bind(ge);for(var ie in A)if(nt(A,ie)){var fe=void 0;try{if(typeof A[ie]!="function"){var Ne=Error((Ie||"React class")+": "+he+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ne.name="Invariant Violation",Ne}fe=A[ie](Q,ie,Ie,he,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Oe){fe=Oe}fe&&!(fe instanceof Error)&&(De(Je),b("%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",he,ie,typeof fe),De(null)),fe instanceof Error&&!(fe.message in Ce)&&(Ce[fe.message]=!0,De(Je),b("Failed %s type: %s",he,fe.message),De(null))}}}var rt=Array.isArray;function Ct(A){return rt(A)}function Ve(A){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,he=Q&&A[Symbol.toStringTag]||A.constructor.name||"Object";return he}}function He(A){try{return Ye(A),!1}catch{return!0}}function Ye(A){return""+A}function Le(A){if(He(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(A)),Ye(A)}var Ue=y.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},Dt,at;function At(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 dt(A,Q){typeof A.ref=="string"&&Ue.current}function bt(A,Q){{var he=function(){Dt||(Dt=!0,b("%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))};he.isReactWarning=!0,Object.defineProperty(A,"key",{get:he,configurable:!0})}}function Tt(A,Q){{var he=function(){at||(at=!0,b("%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))};he.isReactWarning=!0,Object.defineProperty(A,"ref",{get:he,configurable:!0})}}var jt=function(A,Q,he,Ie,Je,nt,ie){var fe={$$typeof:t,type:A,key:Q,ref:he,props:ie,_owner:nt};return fe._store={},Object.defineProperty(fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Je}),Object.freeze&&(Object.freeze(fe.props),Object.freeze(fe)),fe};function Te(A,Q,he,Ie,Je){{var nt,ie={},fe=null,Ne=null;he!==void 0&&(Le(he),fe=""+he),wt(Q)&&(Le(Q.key),fe=""+Q.key),At(Q)&&(Ne=Q.ref,dt(Q,Je));for(nt in Q)ge.call(Q,nt)&&!mt.hasOwnProperty(nt)&&(ie[nt]=Q[nt]);if(A&&A.defaultProps){var Oe=A.defaultProps;for(nt in Oe)ie[nt]===void 0&&(ie[nt]=Oe[nt])}if(fe||Ne){var et=typeof A=="function"?A.displayName||A.name||"Unknown":A;fe&&bt(ie,et),Ne&&Tt(ie,et)}return jt(A,fe,Ne,Je,Ie,Ue.current,ie)}}var qe=y.ReactCurrentOwner,Ee=y.ReactDebugCurrentFrame;function Ke(A){if(A){var Q=A._owner,he=ce(A.type,A._source,Q?Q.type:null);Ee.setExtraStackFrame(he)}else Ee.setExtraStackFrame(null)}var zt;zt=!1;function re(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function be(){{if(qe.current){var A=U(qe.current.type);if(A)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+A+"`."}return""}}function ot(A){return""}var xe={};function Be(A){{var Q=be();if(!Q){var he=typeof A=="string"?A:A.displayName||A.name;he&&(Q=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+he+">.")}return Q}}function Xe(A,Q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var he=Be(Q);if(xe[he])return;xe[he]=!0;var Ie="";A&&A._owner&&A._owner!==qe.current&&(Ie=" It was passed a child from "+
|
|
25
|
+
Check the top-level render call using <`+he+">.")}return Q}}function Xe(A,Q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var he=Be(Q);if(xe[he])return;xe[he]=!0;var Ie="";A&&A._owner&&A._owner!==qe.current&&(Ie=" It was passed a child from "+U(A._owner.type)+"."),Ke(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',he,Ie),Ke(null)}}function kt(A,Q){{if(typeof A!="object")return;if(Ct(A))for(var he=0;he<A.length;he++){var Ie=A[he];re(Ie)&&Xe(Ie,Q)}else if(re(A))A._store&&(A._store.validated=!0);else if(A){var Je=x(A);if(typeof Je=="function"&&Je!==A.entries)for(var nt=Je.call(A),ie;!(ie=nt.next()).done;)re(ie.value)&&Xe(ie.value,Q)}}}function Et(A){{var Q=A.type;if(Q==null||typeof Q=="string")return;var he;if(typeof Q=="function")he=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===h))he=Q.propTypes;else return;if(he){var Ie=U(Q);ze(he,A.props,"prop",Ie,A)}else if(Q.PropTypes!==void 0&&!zt){zt=!0;var Je=U(Q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Je||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&b("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),he=0;he<Q.length;he++){var Ie=Q[he];if(Ie!=="children"&&Ie!=="key"){Ke(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Ke(null);break}}A.ref!==null&&(Ke(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ke(null))}}var Lt={};function je(A,Q,he,Ie,Je,nt){{var ie=L(A);if(!ie){var fe="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(fe+=" 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 Ne=ot();Ne?fe+=Ne:fe+=be();var Oe;A===null?Oe="null":Ct(A)?Oe="array":A!==void 0&&A.$$typeof===t?(Oe="<"+(U(A.type)||"Unknown")+" />",fe=" Did you accidentally export a JSX literal instead of a component?"):Oe=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Oe,fe)}var et=Te(A,Q,he,Je,nt);if(et==null)return et;if(ie){var pt=Q.children;if(pt!==void 0)if(Ie)if(Ct(pt)){for(var Br=0;Br<pt.length;Br++)kt(pt[Br],A);Object.freeze&&Object.freeze(pt)}else b("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 kt(pt,A)}if(ge.call(Q,"key")){var fr=U(A),Gt=Object.keys(Q).filter(function(qI){return qI!=="key"}),Xl=Gt.length>0?"{key: someKey, "+Gt.join(": ..., ")+": ...}":"{key: someKey}";if(!Lt[fr+Xl]){var KI=Gt.length>0?"{"+Gt.join(": ..., ")+": ...}":"{}";b(`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} />`,Gl,fr,HI,fr),Lt[fr+Gl]=!0}}return A===r?Nt(et):Et(et),et}}function ht(A,Q,he){return je(A,Q,he,!0)}function Ze(A,Q,he){return je(A,Q,he,!1)}var ft=Ze,an=ht;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=an}()),Wr}process.env.NODE_ENV==="production"?gi.exports=lx():gi.exports=cx();var u=gi.exports;const ux=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.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 oc(e,t){return function(){return e.apply(t,arguments)}}const{toString:dx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Mo,toStringTag:sc}=Symbol,Ro=(e=>t=>{const n=dx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Oo=e=>t=>typeof t===e,{isArray:hr}=Array,pr=Oo("undefined");function Vr(e){return e!==null&&!pr(e)&&e.constructor!==null&&!pr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ic=ln("ArrayBuffer");function fx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ic(e.buffer),t}const hx=Oo("string"),Ht=Oo("function"),ac=Oo("number"),Kr=e=>e!==null&&typeof e=="object",px=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)&&!(sc in e)&&!(Mo in e)},mx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},gx=ln("Date"),xx=ln("File"),vx=ln("Blob"),wx=ln("FileList"),bx=e=>Kr(e)&&Ht(e.pipe),yx=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]"))},Sx=ln("URLSearchParams"),[Cx,Tx,kx,Ex]=["ReadableStream","Request","Response","Headers"].map(ln),Ix=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 lc(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,cc=e=>!pr(e)&&e!==Xn;function vi(){const{caseless:e,skipUndefined:t}=cc(this)&&this||{},n={},r=(o,s)=>{const i=e&&lc(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||!pr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Nx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=oc(o,n):e[s]=o},{allOwnKeys:r}),e),Ax=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),jx=(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)},Px=(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},Mx=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!ac(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Rx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Ox=(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])}},Dx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Lx=ln("HTMLFormElement"),$x=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),uc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Fx=ln("RegExp"),dc=(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)},Bx=e=>{dc(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+"'")})}})},zx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Hx=()=>{},Ux=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Wx(e){return!!(e&&Ht(e.append)&&e[sc]==="FormData"&&e[Mo])}const Vx=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);!pr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Kx=ln("AsyncFunction"),qx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),fc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Gx=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||fc,U={isArray:hr,isArrayBuffer:ic,isBuffer:Vr,isFormData:yx,isArrayBufferView:fx,isString:hx,isNumber:ac,isBoolean:px,isObject:Kr,isPlainObject:Do,isEmptyObject:mx,isReadableStream:Cx,isRequest:Tx,isResponse:kx,isHeaders:Ex,isUndefined:pr,isDate:gx,isFile:xx,isBlob:vx,isRegExp:Fx,isFunction:Ht,isStream:bx,isURLSearchParams:Sx,isTypedArray:Rx,isFileList:wx,forEach:qr,merge:vi,extend:Nx,trim:Ix,stripBOM:Ax,inherits:jx,toFlatObject:Px,kindOf:Ro,kindOfTest:ln,endsWith:_x,toArray:Mx,forEachEntry:Ox,matchAll:Dx,isHTMLForm:Lx,hasOwnProperty:uc,hasOwnProp:uc,reduceDescriptors:dc,freezeMethods:Bx,toObjectSet:zx,toCamelCase:$x,noop:Hx,toFiniteNumber:Ux,findKey:lc,global:Xn,isContextDefined:cc,isSpecCompliantForm:Wx,toJSONObject:Vx,isAsyncFn:Kx,isThenable:qx,setImmediate:fc,asap:Gx,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 hc=Me.prototype,pc={};["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=>{pc[e]={value:e}}),Object.defineProperties(Me,pc),Object.defineProperty(hc,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(hc);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 Yx=null;function wi(e){return U.isPlainObject(e)||U.isArray(e)}function mc(e){return U.endsWith(e,"[]")?e.slice(0,-2):e}function gc(e,t,n){return e?e.concat(t).map(function(o,s){return o=mc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Xx(e){return U.isArray(e)&&!e.some(wi)}const Jx=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)&&Xx(v)||(U.isFileList(v)||U.endsWith(g,"[]"))&&(y=U.toArray(v)))return g=mc(g),y.forEach(function(S,k){!(U.isUndefined(S)||S===null)&&t.append(i===!0?gc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(gc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(Jx,{defaultVisitor:d,convertValue:c,isVisitable:wi});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,b){(!(U.isUndefined(y)||y===null)&&o.call(t,y,U.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!U.isObject(e))throw new TypeError("data must be an object");return f(e),t}function xc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function bi(e,t){this._pairs=[],e&&Lo(e,this,t)}const vc=bi.prototype;vc.append=function(t,n){this._pairs.push([t,n])},vc.toString=function(t){const n=t?function(r){return t.call(this,r,xc)}:xc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Zx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function wc(e,t,n){if(!t)return e;const r=n&&n.encode||Zx;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 bi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class bc{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 yc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Qx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:bi,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,ev=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),tv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",nv=yi&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:ev,hasStandardBrowserWebWorkerEnv:tv,navigator:Si,origin:nv},Symbol.toStringTag,{value:"Module"})),...Qx};function rv(e,t){return Lo(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&U.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function ov(e){return U.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function sv(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 Sc(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]=sv(o[i])),!a)}if(U.isFormData(e)&&U.isFunction(e.entries)){const n={};return U.forEachEntry(e,(r,o)=>{t(ov(r),o,n,0)}),n}return null}function iv(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:yc,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(Sc(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 rv(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),iv(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:Pt.classes.FormData,Blob:Pt.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 av=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"]),lv=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[Cc]=this[Cc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(fv(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 Tc(e){return!!(e&&e.__CANCEL__)}function mr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}U.inherits(mr,Me,{__CANCEL__:!0});function kc(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 hv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pv(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 mv(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=pv(50,250);return mv(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)},Ec=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ic=e=>(...t)=>U.asap(()=>e(...t)),gv=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,xv=Pt.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 vv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function wv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Nc(e,t,n){let r=!vv(t);return e&&(r||n==!1)?wv(e,t):t}const Ac=e=>e instanceof Ut?{...e}:e;function Jn(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(Ac(c),Ac(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 jc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=wc(Nc(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(Pt.hasStandardBrowserEnv||Pt.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(Pt.hasStandardBrowserEnv&&(r&&U.isFunction(r)&&(r=r(t)),r||r!==!1&&gv(t.url))){const l=o&&s&&xv.read(s);l&&i.set(o,l)}return t},bv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=jc(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};kc(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||yc;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 mr(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 b=hv(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}x.send(s||null)})},yv=(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 mr(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}},Sv=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},Cv=async function*(e,t){for await(const n of Tv(e))yield*Sv(n,t)},Tv=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()}},Pc=(e,t,n,r)=>{const o=Cv(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})},_c=64*1024,{isFunction:Bo}=U,kv=(({Request:e,Response:t})=>({Request:e,Response:t}))(U.global),{ReadableStream:Mc,TextEncoder:Rc}=U.global,Oc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ev=e=>{e=U.merge.call({skipUndefined:!0},kv,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(Mc),l=o&&(typeof Rc=="function"?(v=>g=>v.encode(g))(new Rc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Oc(()=>{let v=!1;const g=new n(Pt.origin,{body:new Mc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Oc(()=>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(Pt.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:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:N,withCredentials:R="same-origin",fetchOptions:D}=jc(v),B=t||fetch;E=E?(E+"").toLowerCase():"text";let H=yv([b,S&&S.toAbortSignal()],k),L=null;const j=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await f(N,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(U.isFormData(y)&&(P=Y.headers.get("content-type"))&&N.setContentType(P),Y.body){const[M,G]=Ec(K,Fo(Ic(T)));y=Pc(Y.body,_c,M,G)}}U.isString(R)||(R=R?"include":"omit");const V=s&&"credentials"in n.prototype,$={...D,signal:H,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:V?R:void 0};L=s&&new n(g,$);let _=await(s?B(L,D):B(g,$));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&j)){const Y={};["status","statusText","headers"].forEach(J=>{Y[J]=_[J]});const P=U.toFiniteNumber(_.headers.get("content-length")),[M,G]=C&&Ec(P,Fo(Ic(C),!0))||[];_=new r(Pc(_.body,_c,M,()=>{G&&G(),j&&j()}),Y)}E=E||"text";let q=await h[U.findKey(h,E)||"text"](_,v);return!I&&j&&j(),await new Promise((Y,P)=>{kc(Y,P,{data:q,headers:Ut.from(_.headers),status:_.status,statusText:_.statusText,config:v,request:L})})}catch(V){throw j&&j(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,L),{cause:V.cause||V}):Me.from(V,V&&V.code,v,L)}}},Iv=new Map,Dc=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=Iv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Ev(t)),d=c;return c};Dc();const ki={http:Yx,xhr:bv,fetch:{get:Dc}};U.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Lc=e=>`- ${e}`,Nv=e=>U.isFunction(e)||e===null||e===!1,$c={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,!Nv(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=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(U.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.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=[Fc.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=Fc.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=Jn(this.defaults,t);const n=Nc(t.baseURL,t.url,t.allowAbsoluteUrls);return wc(n,t.params,t.paramsSerializer)}};U.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(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(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let jv=class Qg{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 mr(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 Qg(function(o){t=o}),cancel:t}}};function Pv(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 Hc(e){const t=new Zn(e),n=oc(Zn.prototype.request,t);return U.extend(n,Zn.prototype,t,{allOwnKeys:!0}),U.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Hc(Jn(e,o))},n}const gt=Hc(Gr);gt.Axios=Zn,gt.CanceledError=mr,gt.CancelToken=jv,gt.isCancel=Tc,gt.VERSION=Bc,gt.toFormData=Lo,gt.AxiosError=Me,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Pv,gt.isAxiosError=_v,gt.mergeConfig=Jn,gt.AxiosHeaders=Ut,gt.formToJSON=e=>Sc(U.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=$c.getAdapter,gt.HttpStatusCode=Ii,gt.default=gt;const{Axios:ZI,AxiosError:QI,CanceledError:eN,isCancel:tN,CancelToken:nN,VERSION:rN,all:oN,Cancel:sN,isAxiosError:iN,spread:aN,toFormData:lN,AxiosHeaders:cN,HttpStatusCode:uN,formToJSON:dN,getAdapter:fN,mergeConfig:hN}=gt,Uc=typeof window<"u"?window.__API_BASE_URL__:void 0,Wc=Uc?vn(Uc):void 0;function vn(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 Vc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Kc(e){return Ni.add(e),()=>Ni.delete(e)}const qc=3e4,Gc=9e4,Xt=gt.create({...Wc?{baseURL:Wc}:{},timeout:qc,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 Yc(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 $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return Vc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Kc(t)}async listThreads(){const t=await Jt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=$t(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 $t(r)}async updateThread(t,n){const r=await Yc(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Jt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return $t(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 $t(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:Gc});return $t(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return $t(r)}}const Rn=new Ko,Mv=Ko,Rv=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 Ov(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 Pi(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Xc(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 Dv(e){return await Jt(`/files/${e}`)}async function Jc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const Zc=w.createContext(null);function Qc({children:e,apiConfig:t}){const n=Rn;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(Zc.Provider,{value:r,children:e})}async function eu(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 tu(e=[]){const t=[],n=[];for(const r of e)try{const o=await eu(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=w.useContext(Zc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function nu(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function _i(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 Lv(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 ru(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function ou(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function su(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??ou(e);let l="",c=e.slice();if(s){const h=$v(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 iu(e){return e.replace(/\s+/g," ").trim()}function $v(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=iu(e),o=iu(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 Fv(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 au(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Bv(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[S,k]=w.useState(null),C=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),N=w.useRef(null),R=w.useRef(null),D=w.useRef(null),B=w.useRef(null),H=w.useRef({messageId:null,lastSeq:null,lastText:""}),L=w.useCallback($=>{o($)},[]),j=w.useCallback(()=>{m(""),v(null),d(null),R.current=null,D.current=null,B.current=null,k(null),H.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var $;console.debug("[use-chat] stop() invoked - aborting stream"),($=C.current)==null||$.abort(),C.current=null,N.current=null,l(!1),b(!1),E.current=0,x(0)},[]),V=w.useCallback(($,_,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,D.current=null,B.current=null,k(null),H.current={messageId:null,lastSeq:null,lastText:""};const q=new AbortController;C.current=q;let Y=null,P=null,M=!1;return N.current={threadId:$.threadId??null,headers:{}},(async()=>{var J,oe,W,O,X,Z,ue,F,ne,de,ce,ge,Ce,_e,De,ze,rt,Ct;const G=Ve=>{var He;try{const Ye=JSON.parse(JSON.stringify(Ve));return(He=Ye==null?void 0:Ye.payload)!=null&&He.files_info&&Array.isArray(Ye.payload.files_info)&&(Ye.payload.files_info=Ye.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),Ye}catch{return Ve}};try{let Ve={};try{if(r)Ve={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,zt=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let re=null;try{const ot=(oe=window.localStorage)==null?void 0:oe.getItem("chat-settings");ot&&(re=((W=JSON.parse(ot))==null?void 0:W.apiKey)||null)}catch{}const be=Ke||zt||re||null;be&&(Ve={Authorization:`Bearer ${be}`})}}catch{}console.debug("[use-chat] POST",t+n,G($));let He={};if(typeof window<"u")try{const Ee=(O=window.localStorage)==null?void 0:O.getItem("authSessionId");Ee&&(He={"X-Session-Id":Ee})}catch{}const Ye={...Ve,...He,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...Ye},Ue=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify($),signal:q.signal,credentials:i});if(N.current&&(N.current.headers=Ye),!Ue.ok||!Ue.body){const Ee=await Ue.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ue.status,Ee==null?void 0:Ee.slice(0,500));const Ke=`stream ${Ue.status}${Ee?": "+Ee:""}`;throw(X=I==null?void 0:I.onConnectionError)==null||X.call(I,Ke),M=!0,Y="error",P=Ke,new Error(Ke)}b(!0);const mt=Ue.body.getReader(),Dt=new TextDecoder;let at="",At=[];E.current=0,x(0);let wt=0,ut=null;const bt=()=>{if(At.length){const Ee=At.join("");At=[],T.current&&m(Ke=>Ke+Ee)}ut=null},Tt=()=>{typeof window<"u"&&ut==null&&(ut=requestAnimationFrame(bt))};let jt=Date.now();const Te=setInterval(()=>{var Ee;if(Date.now()-jt>18e5){const Ke="Stream idle timeout";d(Ke),Y="error",P=Ke,q.abort(),(Ee=I==null?void 0:I.onError)==null||Ee.call(I,Ke)}},5e3),qe=1024*1024;try{const Ee=Ue.headers.get("X-Thread-Id")||Ue.headers.get("x-thread-id"),Ke=Ue.headers.get("X-Thread-Created")||Ue.headers.get("x-thread-created"),zt=Ee??null,re=String(Ke??"").toLowerCase()==="true";for(N.current&&!N.current.threadId&&(N.current={...N.current,threadId:zt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:zt,created:re});;){const{value:be,done:ot}=await mt.read();if(ot)break;at+=Dt.decode(be,{stream:!0}),at.length>qe&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=at.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,Xl,fr,KI,fr),Lt[fr+Xl]=!0}}return A===r?Nt(et):Et(et),et}}function ht(A,Q,he){return je(A,Q,he,!0)}function Ze(A,Q,he){return je(A,Q,he,!1)}var ft=Ze,an=ht;Wr.Fragment=r,Wr.jsx=ft,Wr.jsxs=an}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=px();var u=gi.exports;const mx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.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:gx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Mo,toStringTag:ac}=Symbol,Ro=(e=>t=>{const n=gx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Ro(t)===e),Oo=e=>t=>typeof t===e,{isArray:hr}=Array,pr=Oo("undefined");function Vr(e){return e!==null&&!pr(e)&&e.constructor!==null&&!pr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=ln("ArrayBuffer");function xx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const vx=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)},bx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},yx=ln("Date"),Sx=ln("File"),Cx=ln("Blob"),Tx=ln("FileList"),kx=e=>Kr(e)&&Ht(e.pipe),Ex=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]"))},Ix=ln("URLSearchParams"),[Nx,Ax,jx,_x]=["ReadableStream","Request","Response","Headers"].map(ln),Px=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 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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!pr(e)&&e!==Xn;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):hr(o)?n[i]=o.slice():(!t||!pr(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]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Rx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ox=(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)},Dx=(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},Lx=(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},$x=e=>{if(!e)return null;if(hr(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},Fx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Bx=(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])}},zx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Hx=ln("HTMLFormElement"),Ux=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),Wx=ln("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)},Vx=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+"'")})}})},Kx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},qx=()=>{},Gx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Yx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Mo])}const Xx=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);!pr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Jx=ln("AsyncFunction"),Zx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Qx=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||pc,H={isArray:hr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ex,isArrayBufferView:xx,isString:vx,isNumber:cc,isBoolean:wx,isObject:Kr,isPlainObject:Do,isEmptyObject:bx,isReadableStream:Nx,isRequest:Ax,isResponse:jx,isHeaders:_x,isUndefined:pr,isDate:yx,isFile:Sx,isBlob:Cx,isRegExp:Wx,isFunction:Ht,isStream:kx,isURLSearchParams:Ix,isTypedArray:Fx,isFileList:Tx,forEach:qr,merge:vi,extend:Mx,trim:Px,stripBOM:Rx,inherits:Ox,toFlatObject:Dx,kindOf:Ro,kindOfTest:ln,endsWith:Lx,toArray:$x,forEachEntry:Bx,matchAll:zx,isHTMLForm:Hx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Vx,toObjectSet:Kx,toCamelCase:Ux,noop:qx,toFiniteNumber:Gx,findKey:uc,global:Xn,isContextDefined:dc,isSpecCompliantForm:Yx,toJSONObject:Xx,isAsyncFn:Jx,isThenable:Zx,setImmediate:pc,asap:Qx,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)}H.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:H.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);H.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 ev=null;function wi(e){return H.isPlainObject(e)||H.isArray(e)}function xc(e){return H.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 tv(e){return H.isArray(e)&&!e.some(wi)}const nv=H.toFlatObject(H,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!H.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=H.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!H.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&H.isSpecCompliantForm(t);if(!H.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(H.isDate(v))return v.toISOString();if(H.isBoolean(v))return v.toString();if(!l&&H.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return H.isArrayBuffer(v)||H.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(H.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(H.isArray(v)&&tv(v)||(H.isFileList(v)||H.endsWith(g,"[]"))&&(y=H.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(H.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(nv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!H.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),H.forEach(v,function(y,b){(!(H.isUndefined(y)||y===null)&&o.call(t,y,H.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!H.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 bi(e,t){this._pairs=[],e&&Lo(e,this,t)}const bc=bi.prototype;bc.append=function(t,n){this._pairs.push([t,n])},bc.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 rv(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||rv;H.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=H.isURLSearchParams(t)?t.toString():new bi(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){H.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ov={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:bi,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,sv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),iv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",av=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:sv,hasStandardBrowserWebWorkerEnv:iv,navigator:Si,origin:av},Symbol.toStringTag,{value:"Module"})),...ov};function lv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&H.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function cv(e){return H.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function uv(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&&H.isArray(o)?o.length:i,l?(H.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!H.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&H.isArray(o[i])&&(o[i]=uv(o[i])),!a)}if(H.isFormData(e)&&H.isFunction(e.entries)){const n={};return H.forEachEntry(e,(r,o)=>{t(cv(r),o,n,0)}),n}return null}function dv(e,t,n){if(H.isString(e))try{return(t||JSON.parse)(e),H.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=H.isObject(t);if(s&&H.isHTMLForm(t)&&(t=new FormData(t)),H.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(H.isArrayBuffer(t)||H.isBuffer(t)||H.isStream(t)||H.isFile(t)||H.isBlob(t)||H.isReadableStream(t))return t;if(H.isArrayBufferView(t))return t.buffer;if(H.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 lv(t,this.formSerializer).toString();if((a=H.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),dv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(H.isResponse(t)||H.isReadableStream(t))return t;if(t&&H.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}}};H.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const fv=H.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]&&fv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},kc=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:H.isArray(e)?e.map($o):String(e)}function pv(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 mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ci(e,t,n,r,o){if(H.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!H.isString(t)){if(H.isString(r))return t.indexOf(r)!==-1;if(H.isRegExp(r))return r.test(t)}}function gv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xv(e,t){const n=H.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 h=H.findKey(o,d);(!h||o[h]===void 0||c===!0||c===void 0&&o[h]!==!1)&&(o[h||l]=$o(a))}const i=(a,l)=>H.forEach(a,(c,d)=>s(c,d,l));if(H.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(H.isString(t)&&(t=t.trim())&&!mv(t))i(hv(t),n);else if(H.isObject(t)&&H.isIterable(t)){let a={},l,c;for(const d of t){if(!H.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?H.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=H.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return pv(o);if(H.isFunction(n))return n.call(this,o,r);if(H.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=H.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=H.findKey(r,i);a&&(!n||Ci(r,r[a],a,n))&&(delete r[a],o=!0)}}return H.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 H.forEach(this,(o,s)=>{const i=H.findKey(r,s);if(i){n[i]=$o(o),delete n[s];return}const a=t?gv(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 H.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&H.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[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(xv(o,i),r[a]=!0)}return H.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),H.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),H.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return H.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 mr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}H.inherits(mr,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 vv(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 bv(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 bv(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)=>H.asap(()=>e(...t)),yv=_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,Sv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];H.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),H.isString(r)&&i.push("path="+r),H.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 Cv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Cv(t);return e&&(r||n==!1)?Tv(e,t):t}const _c=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,h,m){return H.isPlainObject(c)&&H.isPlainObject(d)?H.merge.call({caseless:m},c,d):H.isPlainObject(d)?H.merge({},d):H.isArray(d)?d.slice():d}function o(c,d,h,m){if(H.isUndefined(d)){if(!H.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!H.isUndefined(d))return r(void 0,d)}function i(c,d){if(H.isUndefined(d)){if(!H.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 H.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);H.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Pc=e=>{const t=Jn({},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)):""))),H.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(H.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&&H.isFunction(r)&&(r=r(t)),r||r!==!1&&yv(t.url))){const l=o&&s&&Sv.read(s);l&&i.set(o,l)}return t},kv=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&&H.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),H.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 mr(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 b=vv(o.url);if(b&&_t.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Ev=(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 mr(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=()=>H.asap(a),l}},Iv=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},Nv=async function*(e,t){for await(const n of Av(e))yield*Iv(n,t)},Av=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=Nv(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}=H,jv=(({Request:e,Response:t})=>({Request:e,Response:t}))(H.global),{ReadableStream:Oc,TextEncoder:Dc}=H.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_v=e=>{e=H.merge.call({skipUndefined:!0},jv,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(()=>H.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(H.isBlob(v))return v.size;if(H.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(H.isArrayBufferView(v)||H.isArrayBuffer(v))return v.byteLength;if(H.isURLSearchParams(v)&&(v=v+""),H.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=H.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:N,withCredentials:R="same-origin",fetchOptions:L}=Pc(v),z=t||fetch;E=E?(E+"").toLowerCase():"text";let V=Ev([b,S&&S.toAbortSignal()],k),U=null;const j=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let W;try{if(T&&c&&x!=="get"&&x!=="head"&&(W=await f(N,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(H.isFormData(y)&&(_=Y.headers.get("content-type"))&&N.setContentType(_),Y.body){const[M,G]=Nc(W,Fo(Ac(T)));y=Mc(Y.body,Rc,M,G)}}H.isString(R)||(R=R?"include":"omit");const $=s&&"credentials"in n.prototype,O={...L,signal:V,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:$?R:void 0};U=s&&new n(g,O);let P=await(s?z(U,L):z(g,O));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&j)){const Y={};["status","statusText","headers"].forEach(J=>{Y[J]=P[J]});const _=H.toFiniteNumber(P.headers.get("content-length")),[M,G]=C&&Nc(_,Fo(Ac(C),!0))||[];P=new r(Mc(P.body,Rc,M,()=>{G&&G(),j&&j()}),Y)}E=E||"text";let q=await h[H.findKey(h,E)||"text"](P,v);return!I&&j&&j(),await new Promise((Y,_)=>{Ic(Y,_,{data:q,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:U})})}catch($){throw j&&j(),$&&$.name==="TypeError"&&/Load failed|fetch/i.test($.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,U),{cause:$.cause||$}):Me.from($,$&&$.code,v,U)}}},Pv=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=Pv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:_v(t)),d=c;return c};$c();const ki={http:ev,xhr:kv,fetch:{get:$c}};H.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Mv=e=>H.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=H.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 Me(`Unknown adapter '${a}'`);if(o&&(H.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(Fc).join(`
|
|
34
|
+
`):" "+Fc(i[0]):"as no adapter specified";throw new Me("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 mr(null,e)}function zc(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),Bc.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 Ec(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 Hc="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 Uc={};zo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Hc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Me(o(i," has been removed"+(n?" in "+n:"")),Me.ERR_DEPRECATED);return n&&!Uc[i]&&(Uc[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 Rv(e,t,n){if(typeof e!="object")throw new Me("options must be an object",Me.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 Me("option "+s+" must be "+l,Me.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Me("Unknown option "+s,Me.ERR_BAD_OPTION)}}const Ho={assertOptions:Rv,validators:zo},xn=Ho.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Sc,response:new Sc}}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=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(H.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&H.merge(s.common,s[n.method]);s&&H.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=Jn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),H.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Ov=class ex{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 mr(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 ex(function(o){t=o}),cancel:t}}};function Dv(e){return function(n){return e.apply(null,n)}}function Lv(e){return H.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 Zn(e),n=ic(Zn.prototype.request,t);return H.extend(n,Zn.prototype,t,{allOwnKeys:!0}),H.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Jn(e,o))},n}const gt=Wc(Gr);gt.Axios=Zn,gt.CanceledError=mr,gt.CancelToken=Ov,gt.isCancel=Ec,gt.VERSION=Hc,gt.toFormData=Lo,gt.AxiosError=Me,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Dv,gt.isAxiosError=Lv,gt.mergeConfig=Jn,gt.AxiosHeaders=Ut,gt.formToJSON=e=>Tc(H.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=Bc.getAdapter,gt.HttpStatusCode=Ii,gt.default=gt;const{Axios:nN,AxiosError:rN,CanceledError:oN,isCancel:sN,CancelToken:iN,VERSION:aN,all:lN,Cancel:cN,isAxiosError:uN,spread:dN,toFormData:fN,AxiosHeaders:hN,HttpStatusCode:pN,formToJSON:mN,getAdapter:gN,mergeConfig:xN}=gt,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?vn(Vc):void 0;function vn(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=gt.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 $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(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=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=$t(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 $t(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Jt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return $t(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 $t(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 $t(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return $t(r)}}const Rn=new Ko,$v=Ko,Fv=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 Bv(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 zv(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=w.createContext(null);function tu({children:e,apiConfig:t}){const n=Rn;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=w.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 Hv(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=Uv(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 Uv(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 Wv(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 Vv(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[S,k]=w.useState(null),C=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),N=w.useRef(null),R=w.useRef(null),L=w.useRef(null),z=w.useRef(null),V=w.useRef({messageId:null,lastSeq:null,lastText:""}),U=w.useCallback(O=>{o(O)},[]),j=w.useCallback(()=>{m(""),v(null),d(null),R.current=null,L.current=null,z.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""}},[]),W=w.useCallback(()=>{var O;console.debug("[use-chat] stop() invoked - aborting stream"),(O=C.current)==null||O.abort(),C.current=null,N.current=null,l(!1),b(!1),E.current=0,x(0)},[]),$=w.useCallback((O,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,z.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""};const q=new AbortController;C.current=q;let Y=null,_=null,M=!1;return N.current={threadId:O.threadId??null,headers:{}},(async()=>{var J,oe,K,D,X,Z,ue,F,ne,de,ce,ge,Ce,Pe,De,ze,rt,Ct;const G=Ve=>{var He;try{const Ye=JSON.parse(JSON.stringify(Ve));return(He=Ye==null?void 0:Ye.payload)!=null&&He.files_info&&Array.isArray(Ye.payload.files_info)&&(Ye.payload.files_info=Ye.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),Ye}catch{return Ve}};try{let Ve={};try{if(r)Ve={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,zt=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let re=null;try{const ot=(oe=window.localStorage)==null?void 0:oe.getItem("chat-settings");ot&&(re=((K=JSON.parse(ot))==null?void 0:K.apiKey)||null)}catch{}const be=Ke||zt||re||null;be&&(Ve={Authorization:`Bearer ${be}`})}}catch{}console.debug("[use-chat] POST",t+n,G(O));let He={};if(typeof window<"u")try{const Ee=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Ee&&(He={"X-Session-Id":Ee})}catch{}const Ye={...Ve,...He,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...Ye},Ue=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify(O),signal:q.signal,credentials:i});if(N.current&&(N.current.headers=Ye),!Ue.ok||!Ue.body){const Ee=await Ue.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ue.status,Ee==null?void 0:Ee.slice(0,500));const Ke=`stream ${Ue.status}${Ee?": "+Ee:""}`;throw(X=I==null?void 0:I.onConnectionError)==null||X.call(I,Ke),M=!0,Y="error",_=Ke,new Error(Ke)}b(!0);const mt=Ue.body.getReader(),Dt=new TextDecoder;let at="",At=[];E.current=0,x(0);let wt=0,dt=null;const bt=()=>{if(At.length){const Ee=At.join("");At=[],T.current&&m(Ke=>Ke+Ee)}dt=null},Tt=()=>{typeof window<"u"&&dt==null&&(dt=requestAnimationFrame(bt))};let jt=Date.now();const Te=setInterval(()=>{var Ee;if(Date.now()-jt>18e5){const Ke="Stream idle timeout";d(Ke),Y="error",_=Ke,q.abort(),(Ee=I==null?void 0:I.onError)==null||Ee.call(I,Ke)}},5e3),qe=1024*1024;try{const Ee=Ue.headers.get("X-Thread-Id")||Ue.headers.get("x-thread-id"),Ke=Ue.headers.get("X-Thread-Created")||Ue.headers.get("x-thread-created"),zt=Ee??null,re=String(Ke??"").toLowerCase()==="true";for(N.current&&!N.current.threadId&&(N.current={...N.current,threadId:zt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:zt,created:re});;){const{value:be,done:ot}=await mt.read();if(ot)break;at+=Dt.decode(be,{stream:!0}),at.length>qe&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=at.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const Be=at.slice(0,xe);at=at.slice(xe+2);const Xe=Be.split(/\r?\n/),kt=[];for(const Ze of Xe)if(!(!Ze||Ze.startsWith(":"))&&Ze.startsWith("data:")){const ft=Ze.slice(5);kt.push(ft.startsWith(" ")?ft.slice(1):ft)}const Et=kt.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 Lt=nu(Nt)?Nt.data:Nt;if(!Lt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const je=Lt;jt=Date.now();const ht=je.seq;if(ht!==void 0){if(ht<=wt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ht,lastProcessedSeq:wt,type:je.type});continue}wt>0&&ht>wt+1&&((ue=I==null?void 0:I.onGap)==null||ue.call(I,{from:wt,to:ht})),wt=ht,E.current=ht,x(ht)}if(je.type==="message.start"&&je.role==="assistant"){const Ze=au(je.model);H.current={messageId:je.id,lastSeq:ht??null,lastText:""},k({id:je.id,role:"assistant",name:Ze??void 0,model:je.model,createdAt:new Date().toISOString(),content:[]})}if(je.type==="checkpoint")R.current=je.checkpointId??null,D.current=je.checkpointNs??null,v(je.checkpointId??null);else if(je.type==="state_history"){B.current=je;try{const ft=Mn(je).latest;ft&&(R.current=ft.checkpointId??null,D.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Ze){console.warn("[use-chat] Failed to hydrate state_history payload",Ze)}}try{_==null||_(je)}catch(Ze){console.error("[use-chat] Error in onEvent callback:",Ze,"for event:",je.type)}if(je.type==="message.delta"){k(ft=>{const an=H.current;if(!ft||an.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:he}=su(ft.content??[],je.delta,{lastSeq:an.lastSeq,lastText:an.lastText},ht??null);return he?(H.current={...an,lastSeq:Q.lastSeq??an.lastSeq,lastText:Q.lastText??an.lastText},{...ft,content:A}):ft});const Ze=je.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Ze&&e.autoAppendAssistant!==!1&&(At.push(Ze),Tt())}else if(je.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(F=I==null?void 0:I.onHeartbeat)==null||F.call(I,je)}catch(Ze){console.warn("[use-chat] heartbeat callback failed",Ze)}}else if(ut!==null&&cancelAnimationFrame(ut),bt(),je.type==="checkpoint")v(je.checkpointId);else if(je.type==="error"){const Ze=je;if(d(Ze.message),Y="error",P=Ze.message,Ze.error_type==="auth_error"||Ze.code==="TOKEN_EXPIRED"||((ne=Ze.message)==null?void 0:ne.includes("token"))||((de=Ze.message)==null?void 0:de.includes("401"))||((ce=Ze.message)==null?void 0:ce.includes("unauthorized"))||((ge=Ze.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ze.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,Ze.message)}catch(an){console.warn("[use-chat] onAuthError handler failed",an)}q.abort()}}}}bt(),Y===null&&!q.signal.aborted&&(Y="complete")}catch(Ee){if(Ee.name==="AbortError")Y=Y??"aborted";else{const Ke=Ee.message||String(Ee);Y="error",P=Ke,d(Ke),(_e=I==null?void 0:I.onError)==null||_e.call(I,Ke)}}finally{try{await mt.cancel()}catch{}finally{(De=mt.releaseLock)==null||De.call(mt)}ut!==null&&typeof window<"u"&&window.cancelAnimationFrame(ut),clearInterval(Te)}}catch(Ve){if(Ve.name==="AbortError")Y=Y??"aborted";else{const He=Ve.message||String(Ve);Y="error",P=He,d(He),(ze=I==null?void 0:I.onError)==null||ze.call(I,He),M||((rt=I==null?void 0:I.onConnectionError)==null||rt.call(I,He),M=!0)}}finally{const Ve=E.current,He=R.current,Ye=D.current,Le=B.current,Ue=Y??(q.signal.aborted?"aborted":P?"error":"complete");try{(Ct=I==null?void 0:I.onClosed)==null||Ct.call(I,{reason:Ue,lastSeq:Ve,lastCheckpointId:He,lastCheckpointNs:Ye,lastStateHistory:Le,error:P})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),b(!1),C.current=null,E.current=0,x(0),N.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var $;T.current=!1,($=C.current)==null||$.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:V,stop:K,clear:j,setToken:L}}const zv=["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 zv){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 Hv(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 lu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,C]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const N=w.useCallback(async()=>{d(!0),m(null);try{const _=await e.listThreads();i(_??[])}catch(_){const I=String(_);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),R=w.useCallback(async()=>{x(!0),y(null);try{const _=await e.listSharedThreads();v(_??[])}catch(_){const I=String(_);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{N()},[N]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const D=w.useCallback(async _=>{try{const I=await e.createThread(_);return l(I.threadId),await N(),I.threadId}catch(I){const q=String(I);return n==null||n(q),null}},[e,n,N]),B=w.useCallback(async _=>{const I=s;i(Y=>Y.filter(P=>P.threadId!==_));const q=new AbortController;E.current.set(_,q);try{await e.deleteThread(_),T.current===_&&(l(null),o==null||o())}catch(Y){i(I);const P=String(Y);n==null||n(P)}finally{E.current.delete(_)}},[e,o,n,s]),H=w.useCallback(async(_,I)=>{try{await e.updateThread(_,I),await N()}catch(q){n==null||n(String(q))}},[e,n,N]),L=w.useCallback(async(_,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(_,I),await R(),S("Shared successfully")}catch(q){const Y=Hv(q);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,R]),j=w.useCallback(async(_,I)=>{try{await e.unshareThread(_,I),await R()}catch(q){const Y=String(q);throw n==null||n(Y),q}},[e,n,R]),K=w.useMemo(()=>({createThread:D,deleteThread:B,renameThread:H,refreshThreads:N,refreshSharedThreads:R,shareThread:L,unshareThread:j}),[D,B,H,N,R,L,j]),V=w.useCallback(_=>{if(!(_!=null&&_.threadId))return;const I={threadId:_.threadId,title:_.title||`Thread ${_.threadId.slice(0,8)}`,createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),messageCount:_.messageCount??1};i(q=>{let Y=!1;const P=q.map(M=>M.threadId===I.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...M,title:I.title??M.title,updatedAt:I.updatedAt??M.updatedAt,messageCount:I.messageCount??M.messageCount}):M);return Y?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),$=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:V,shareInFlight:k,shareStatus:b,clearShareStatus:$}}const cu=w.createContext(null);function uu({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}=lu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.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(cu.Provider,{value:b,children:e})}function gr(){const e=w.useContext(cu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function du(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 fu(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(fu(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 xr(e){if(typeof e=="string")return e;if(fu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Uv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Wv(e){const t=xr(e);return typeof e=="string"&&Uv(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=du(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 Vv(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 Kv(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 hu(e){if("type"in e&&e.type==="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 Gv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Yv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Xv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Gv(n),i=o?`data:${s};base64,${e}`:t,a=Yv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Jv(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 Xv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function pu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Zv={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Qv(e,t){var n;switch(t.type){case"reset":return{messages:_i(((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=_i(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=_i(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 mu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>mu(o,s),e):e}default:return e}}function ew(e=[]){const[t,n]=w.useReducer(Qv,{...Zv,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 mu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=au(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 nw(e,t);if(t.type==="tool.progress")return rw(e,t);if(t.type==="tool.end")return ow(e,t);if(t.type==="message.delta"){const s=e.assemblingId??ru(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:ou(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}=su(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??ru(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=Fv(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?Lv(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 Ri(e){return e.call_id??e.id??null}function gu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function xu(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 Oi(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 tw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(t??e);return n?[{type:"text",text:n}]:[]}function vu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function nw(e,t){const n=Ri(t),r=Oi(e.messages,n),o=t.name??t.tool??void 0,s=gu(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=xu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function rw(e,t){const n=Ri(t);if(!n)return e;const r=Oi(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=vu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function ow(e,t){const n=Ri(t),r=gu(t);let o=e.messages,s=Oi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,xu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=tw(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=vu(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]=w.useState(null),v=w.useMemo(()=>Mn(h),[h]).checkpoints,g=Ql(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,N]=w.useState(!1),[R,D]=w.useState(!1),[B,H]=w.useState(null),L=w.useRef(o),j=w.useRef(null),K=w.useRef(null),V=w.useRef(null),$=w.useRef(null),_=w.useRef(!1),I=w.useRef(null),q=w.useRef(new Map);w.useEffect(()=>{L.current=o},[o]);const Y=w.useCallback(async F=>{var de,ce;if(!F.threadId)return;const ne=F.threadId;(de=F.onStart)==null||de.call(F),F.setLoading(!0);try{await F.action(ne)}catch(ge){if(L.current===ne){const Ce=String(ge);(ce=F.handleError)==null||ce.call(F,Ce),r==null||r(Ce)}throw ge}finally{F.setLoading(!1)}},[r]),P=w.useCallback(async(F,ne)=>{if(!F)return;const de=`${F}:${ne??"latest"}`,ce=q.current.get(de);if(ce)return ce;const ge=Y({threadId:F,setLoading:T,onStart:()=>H(null),handleError:Ce=>H(Ce),action:async Ce=>{const _e=await e.getStateHistory({threadId:Ce,checkpointId:ne??void 0});if(L.current!==Ce){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ce}, now ${L.current}), discarding stale data`);return}const{checkpoints:De}=Mn(_e),ze=De.find(rt=>rt.messages&&rt.messages.length>0)??(ne?De.find(rt=>rt.checkpointId===ne):null)??De[0];t((ze==null?void 0:ze.messages)??[],{checkpointId:(ze==null?void 0:ze.checkpointId)??null,checkpointNs:(ze==null?void 0:ze.checkpointNs)??null}),m(_e),b(!!(ze!=null&&ze.nextCursor)),k((ze==null?void 0:ze.nextCursor)??null)}});q.current.set(de,ge);try{await ge}finally{q.current.delete(de)}return L.current===F&&(I.current=de),ge},[e,t,Y]),M=w.useCallback(async(F,ne)=>{$.current=F;try{await P(F,ne)}finally{$.current===F&&($.current=null)}},[P]),G=w.useCallback(F=>{K.current=F},[]),J=w.useCallback(F=>{V.current=F},[]),oe=w.useCallback(F=>{const ne=F.threadId??L.current;if(!ne||L.current&&L.current!==ne)return;const{checkpoints:de}=Mn(F);if(!de.length)return;const ce=de.find(Ce=>Ce.messages&&Ce.messages.length>0)??de.find(Ce=>!!Ce.checkpointId)??de[0],ge=V.current===ne;!c&&!ge&&t((ce==null?void 0:ce.messages)??[],{checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}),m(F),b(!!(ce!=null&&ce.nextCursor)),k((ce==null?void 0:ce.nextCursor)??null),I.current=`${ne}:latest`,K.current=null,V.current===ne&&(V.current=null)},[t,c]),W=w.useCallback(async(F,ne)=>{const de=L.current;await Y({threadId:de,setLoading:D,action:async ce=>{const ge=await e.getStateHistory({threadId:ce,checkpointId:F,checkpointNs:ne??void 0});if(L.current!==ce){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ce}, now ${L.current}), discarding stale data`);return}const{checkpoints:Ce}=Mn(ge),_e=Ce.find(De=>De.checkpointId===F&&(ne?De.checkpointNs===ne:!0));if(!_e){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:ne});return}m(ge),t(_e.messages??[],{checkpointId:_e.checkpointId??null,checkpointNs:_e.checkpointNs??null})}}).catch(()=>{})},[e,t,Y]),O=w.useCallback((F,ne)=>{t(d(),{checkpointId:F??null,checkpointNs:ne??null})},[d,t]),X=w.useCallback(async()=>{L.current&&await M(L.current)},[M]),Z=w.useCallback(async()=>{const F=L.current;!F||!S||await Y({threadId:F,setLoading:N,action:async ne=>{const de=await e.getStateHistory({threadId:ne,checkpointId:S});if(L.current!==ne)return;const{checkpoints:ce}=Mn(de);if(ce.length>0){const ge=ce[ce.length-1];n((ge==null?void 0:ge.messages)??[]),b(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,Y]);w.useEffect(()=>{if(!l||!o||C||c)return;if(K.current===o){K.current=null,j.current=o;return}if(V.current===o){j.current=o;return}if($.current===o){$.current=null,j.current=o;return}if(j.current===o)return;j.current=o;const F=!_.current&&!!i&&o===s;let ne;F&&i?(ne=i,_.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",ne,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const de=`${o}:${ne??"latest"}`;I.current!==de&&M(o,ne)},[l,o,i,a,s,C,c,M]);const ue=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),N(!1),D(!1),H(null),K.current=null,V.current=null,j.current=null,I.current=null,$.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:B,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:W,loadOlderMessages:Z,setCurrentCheckpointId:O,returnToLatest:X,handleStateHistoryEvent:oe,markSkipNextLoad:G,markStreamPendingThread:J,resetHistoryState:ue}}const bu=w.createContext(null),yu=w.createContext(null);function eo(){const e=w.useContext(bu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Su(){const e=w.useContext(yu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Cu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=gr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=ew(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:D,handleStateHistoryEvent:B,markSkipNextLoad:H,markStreamPendingThread:L,resetHistoryState:j}=wu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[K,V]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[$,_]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const I=w.useCallback(G=>V(()=>G),[]),q=w.useCallback(G=>_(()=>G),[]),Y=w.useMemo(()=>{const G=c.assemblingId??null;return G?{assemblingMessageId:G}:null},[c.assemblingId]),P=w.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:Y,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:K,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:D,loadThread:T,clearThread:K,respondToInterrupt:$,messagePreviews:x.messagePreviews,handleStateHistoryEvent:B,markSkipNextLoad:H,markStreamPendingThread:L,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,b,S,k,C,N,K,E,R,D,T,$,x.messagePreviews,B,H,L,j,m,f]),M=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:q}),[I,q]);return u.jsx(yu.Provider,{value:M,children:u.jsx(bu.Provider,{value:P,children:e})})}function Tu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return _n(r,t)??null}function sw(e){const t=Tu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Tu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function iw(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 aw(e,t){const n=[...e].sort(iw);for(const r of n){if(r.messageId!==t)continue;const o=sw(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 ku=w.createContext(null),Eu=w.createContext(!1);function lw({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=w.useMemo(()=>vn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Bv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(uu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Cu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Eu.Provider,{value:!0,children:u.jsx(cw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function cw({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}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:N}=Su(),R=w.useCallback($=>{v($),f.current!==$.threadId&&(($.created??!f.current)&&b($.threadId),S($.threadId),m($.threadId))},[v,b,S,m,f]),D=w.useCallback($=>{$.type==="thread_info"?R($):$.type==="state_history"?y($):$.type==="tool.end"?i==null||i($):T($)},[R,y,T,i]),B=w.useCallback($=>{a($,D,{onError:_=>{console.error("[StreamingProvider] Stream error:",_),r==null||r(_)},onAuthError:_=>{console.error("[StreamingProvider] Auth error:",_),o==null||o(_)},onConnectionError:_=>{console.error("[StreamingProvider] Connection error:",_),s==null||s(_)}})},[a,D,r,o,s]),H=w.useRef(g);w.useEffect(()=>{H.current=g},[g]);const L=w.useCallback(async($,_,I)=>{const q=f.current;if(!q)throw new Error("No active thread to handle interrupt");const Y=_?I??!0:!1,P=H.current,M={threadId:q,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:Y}};B(M)},[f,B]);w.useEffect(()=>{N(L)},[L,N]);const j=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch($){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",$)}},[t,k,m,l]);w.useEffect(()=>{E(j)},[j,E]);const K=w.useCallback(async($,_)=>{let I=f.current;const q=($==null?void 0:$.text)??"",Y=($==null?void 0:$.attachments)??[],P=(q==null?void 0:q.trim())??"",M={...($==null?void 0:$.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!I&&!P&&Y.length===0&&!J)return;if(!I){const _e=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),De=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${_e}${De}`,b(I),m(I)}const{contentParts:oe,filesInfo:W}=await tu(Y),O=[...oe];P&&O.push({type:"text",text:q});const X=_==null?void 0:_.originalMessageId,Z=!!(_!=null&&_.edit&&X),ue=!J&&O.length>0;let F=null;ue&&(F={id:Z?X:`msg-${Date.now()}`,role:"user",content:O,createdAt:new Date().toISOString()},Z?C(F,X):C(F));const ne=J?G:F?[F]:[],de={...M,...W.length?{files_info:W}:{}};ne.length?de.messages=ne:"messages"in de||(de.messages=[]);let ce=(_==null?void 0:_.checkpointId)??g.id??void 0,ge=(_==null?void 0:_.checkpointNs)??g.namespace??void 0;if(Z&&X){const _e=aw(x,X);ce=_e.checkpointId,ge=_e.checkpointNs??void 0}const Ce={threadId:I,payload:de,checkpointId:ce,checkpointNs:ge,edit:!!(_!=null&&_.edit)};B(Ce)},[g,f,b,C,B,x]),V=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:h}),[c,d,K,l,h]);return u.jsx(ku.Provider,{value:V,children:e})}function Di(){const e=w.useContext(ku);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function uw(){return w.useContext(Eu)}function Iu(e){return typeof e=="object"&&e!==null}function dw(e,t){if(Object.is(e,t))return!0;if(!Iu(e)||!Iu(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 Nu(e){const t=w.useRef(e),n=w.useRef(e);return dw(t.current,e)||(t.current=e,n.current=e),n.current}function vr({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=Nu(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=w.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(Qc,{apiConfig:h,children:u.jsx(lw,{...y,children:e})})}function to(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function fw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Au(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=fw(t);if(n)return n}}function ju(){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 vn(t);return vn()}function _u(){const e={},t=Au(),n=ju();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Mu(){const e=_u(),t=Rn.getAuthToken(),n=Au();return{apiBaseUrl:Pu(e.baseUrl,Rn.baseUrl,n),apiKey:t||e.apiKey||ju()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Li="chat-settings";function Ru(){try{const e=localStorage.getItem(Li);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Ou(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Li,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function hw(){const e=Mu(),t=Ru(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(Rn.baseUrl,r,e.apiBaseUrl)}}function pw(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Ou(e)}function te(...e){return tx.twMerge(ex.clsx(e))}const mw=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"}}),tt=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(mw({variant:t,size:n,className:e})),ref:s,...o})});tt.displayName="Button";function ae(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 Du(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Du(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():Du(e[o],null)}}}}function $e(...e){return p.useCallback(On(...e),e)}function gw(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 cn(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,xw(o,...t)]}function xw(...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:()=>{},vw=p[" useInsertionEffect ".trim().toString()]||It;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ww({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=bw(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 ww({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return vw(()=>{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 bw(e){return typeof e=="function"}var yw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=yw.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 $i(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=$e(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=$e(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const S=Array.from(b.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 Sw=p.createContext(void 0);function Xo(e){const t=p.useContext(Sw);return e||t||"ltr"}function xt(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 Cw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(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 Tw="DismissableLayer",Fi="dismissableLayer.update",kw="dismissableLayer.pointerDownOutside",Ew="dismissableLayer.focusOutside",Lu,$u=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),br=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext($u),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=$e(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Nw(E=>{const N=E.target,R=[...c.branches].some(D=>D.contains(N));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Aw(E=>{const N=E.target;[...c.branches].some(D=>D.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Cw(E=>{b===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&&(Lu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Bu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Lu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Bu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Fi,E),()=>document.removeEventListener(Fi,E)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});br.displayName=Tw;var Iw="DismissableLayerBranch",Fu=p.forwardRef((e,t)=>{const n=p.useContext($u),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Fu.displayName=Iw;function Nw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){zu(kw,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 Aw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&zu(Ew,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 Bu(){const e=new CustomEvent(Fi);document.dispatchEvent(e)}function zu(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?$i(o,s):o.dispatchEvent(s)}var jw=br,Pw=Fu,Bi=0;function zi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Hu()),document.body.insertAdjacentElement("beforeend",e[1]??Hu()),Bi++,()=>{Bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Bi--}},[])}function Hu(){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 Hi="focusScope.autoFocusOnMount",Ui="focusScope.autoFocusOnUnmount",Uu={bubbles:!1,cancelable:!0},_w="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=xt(o),d=xt(s),h=p.useRef(null),m=$e(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:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Ku.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Hi,Uu);a.addEventListener(Hi,c),a.dispatchEvent(y),y.defaultPrevented||(Mw($w(Wu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Hi,c),setTimeout(()=>{const y=new CustomEvent(Ui,Uu);a.addEventListener(Ui,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Ui,d),Ku.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 b=g.currentTarget,[S,k]=Rw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=_w;function Mw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Rw(e){const t=Wu(e),n=Vu(t,e),r=Vu(t.reverse(),e);return[n,r]}function Wu(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 Vu(e,t){for(const n of e)if(!Ow(n,{upTo:t}))return n}function Ow(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 Dw(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dw(e)&&t&&e.select()}}var Ku=Lw();function Lw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=qu(e,t),e.unshift(t)},remove(t){var n;e=qu(e,t),(n=e[0])==null||n.resume()}}}function qu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function $w(e){return e.filter(t=>t.tagName!=="A")}var Fw=p[" useId ".trim().toString()]||(()=>{}),Bw=0;function _t(e){const[t,n]=p.useState(Fw());return It(()=>{n(r=>r??String(Bw++))},[e]),t?`radix-${t}`:""}const zw=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),Hw={left:"right",right:"left",bottom:"top",top:"bottom"},Uw={start:"end",end:"start"};function Wi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Vi(e){return e==="x"?"y":"x"}function Ki(e){return e==="y"?"height":"width"}const Ww=new Set(["top","bottom"]);function bn(e){return Ww.has(An(e))?"y":"x"}function qi(e){return Vi(bn(e))}function Vw(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=qi(e),s=Ki(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 Kw(e){const t=es(e);return[Gi(e),t,Gi(t)]}function Gi(e){return e.replace(/start|end/g,t=>Uw[t])}const Gu=["left","right"],Yu=["right","left"],qw=["top","bottom"],Gw=["bottom","top"];function Yw(e,t,n){switch(e){case"top":case"bottom":return n?t?Yu:Gu:t?Gu:Yu;case"left":case"right":return t?qw:Gw;default:return[]}}function Xw(e,t,n,r){const o=yr(e);let s=Yw(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Gi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>Hw[t])}function Jw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Xu(e){return typeof e!="number"?Jw(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 Ju(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=qi(t),a=Ki(i),l=An(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(yr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const Zw=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}=Ju(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,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=b??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}=Ju(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}=Nn(t,e),v=Xu(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})),b=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:b,offsetParent:S,strategy:l}):b);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 Qw=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}=Nn(e,t)||{};if(c==null)return{};const h=Xu(d),m={x:n,y:r},f=qi(o),v=Ki(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=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 N=k/2-C/2,R=E/2-g[v]/2-1,D=$n(h[y],R),B=$n(h[b],R),H=D,L=E-g[v]-B,j=E/2-g[v]/2+N,K=Wi(H,j,L),V=!l.arrow&&yr(o)!=null&&j!==K&&s.reference[v]/2-(j<H?D:B)-g[v]/2<0,$=V?j<H?j-H:j-L:0;return{[f]:m[f]+$,data:{[f]:K,centerOffset:j-K-$,...V&&{alignmentOffset:$}},reset:V}}}),eb=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}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),b=bn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Kw(a)),T=v!=="none";!m&&T&&C.push(...Xw(a,g,v,k));const E=[a,...C],N=await no(t,x),R=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),h){const j=Vw(o,i,k);R.push(N[j[0]],N[j[1]])}if(D=[...D,{placement:o,overflows:R}],!R.every(j=>j<=0)){var B,H;const j=(((B=s.flip)==null?void 0:B.index)||0)+1,K=E[j];if(K&&(!(h==="alignment"?b!==bn(K):!1)||D.every(_=>bn(_.placement)===b?_.overflows[0]>0:!0)))return{data:{index:j,overflows:D},reset:{placement:K}};let V=(H=D.filter($=>$.overflows[0]<=0).sort(($,_)=>$.overflows[1]-_.overflows[1])[0])==null?void 0:H.placement;if(!V)switch(f){case"bestFit":{var L;const $=(L=D.filter(_=>{if(T){const I=bn(_.placement);return I===b||I==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(I=>I>0).reduce((I,q)=>I+q,0)]).sort((_,I)=>_[1]-I[1])[0])==null?void 0:L[0];$&&(V=$);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function Zu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Qu(e){return zw.some(t=>e[t]>=0)}const tb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Zu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Qu(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Zu(s,n.floating);return{data:{escapedOffsets:i,escaped:Qu(i)}}}default:return{}}}}},ed=new Set(["left","top"]);async function nb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=bn(n)==="y",c=ed.has(i)?-1:1,d=s&&l?-1:1,h=Nn(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 rb=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 nb(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}}}}},ob=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:b}=x;return{x:y,y:b}}},...l}=Nn(e,t),c={x:n,y:r},d=await no(t,l),h=bn(An(o)),m=Vi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Wi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Wi(b,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}}}}}},sb=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}=Nn(e,t),d={x:n,y:r},h=bn(o),m=Vi(h);let f=d[m],v=d[h];const g=Nn(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,b;const S=m==="y"?"width":"height",k=ed.has(An(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:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},ib=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}=Nn(e,t),d=await no(t,c),h=An(o),m=yr(o),f=bn(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 b=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],b),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const D=Zt(d.left,0),B=Zt(d.right,0),H=Zt(d.top,0),L=Zt(d.bottom,0);f?N=v-2*(D!==0||B!==0?D+B:Zt(d.left,d.right)):E=g-2*(H!==0||L!==0?H+L:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,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 Sr(e){return td(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(td(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function td(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function nd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const ab=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ab.has(o)}const lb=new Set(["table","td","th"]);function cb(e){return lb.has(Sr(e))}const ub=[":popover-open",":modal"];function rs(e){return ub.some(t=>{try{return e.matches(t)}catch{return!1}})}const db=["transform","translate","scale","rotate","perspective"],fb=["transform","translate","scale","rotate","perspective","filter"],hb=["paint","layout","strict","content"];function Yi(e){const t=Xi(),n=un(e)?dn(e):e;return db.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)||fb.some(r=>(n.willChange||"").includes(r))||hb.some(r=>(n.contain||"").includes(r))}function pb(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Yi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Xi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const mb=new Set(["html","body","#document"]);function Cr(e){return mb.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||nd(e)&&e.host||yn(e);return nd(t)?t.host:t}function rd(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ro(t)?t:rd(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=rd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Ji(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Ji(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function od(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(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 Zi(e){return un(e)?e:e.contextElement}function Tr(e){const t=Zi(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=od(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 gb=wn(0);function sd(e){const t=Qt(e);return!Xi()||!t.visualViewport?gb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Zi(e);let i=wn(1);t&&(r?un(r)&&(i=Tr(r)):i=Tr(e));const a=xb(s,n,r)?sd(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&&un(r)?Qt(r):r;let v=m,g=Ji(v);for(;g&&r&&f!==v;){const x=Tr(g),y=g.getBoundingClientRect(),b=dn(g),S=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Qt(g),g=Ji(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:Qn(yn(e)).left+n}function id(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 vb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(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=Sn(r);if((h||!h&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const f=Qn(r);c=Tr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?id(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 wb(e){return Array.from(e.getClientRects())}function bb(e){const t=yn(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 dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ad=25;function yb(e,t){const n=Qt(e),r=yn(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=Xi();(!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<=ad&&(s-=v)}else c<=ad&&(s+=c);return{width:s,height:i,x:a,y:l}}const Sb=new Set(["absolute","fixed"]);function Cb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(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 ld(e,t,n){let r;if(t==="viewport")r=yb(e,n);else if(t==="document")r=bb(yn(e));else if(un(t))r=Cb(t,n);else{const o=sd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function cd(e,t){const n=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||cd(n,t)}function Tb(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Yi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Sb.has(o.position)||ro(i)&&!l&&cd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function kb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Tb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=ld(t,d,o);return c.top=Zt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},ld(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Eb(e){const{width:t,height:n}=od(e);return{width:t,height:n}}function Ib(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(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((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=Qn(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?id(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 Qi(e){return dn(e).position==="static"}function ud(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function dd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!Qi(o))return o;o=Fn(o)}return n}let r=ud(e,t);for(;r&&cb(r)&&Qi(r);)r=ud(r,t);return r&&Cr(r)&&Qi(r)&&!Yi(r)?n:r||pb(e)||n}const Nb=async function(e){const t=this.getOffsetParent||dd,n=this.getDimensions,r=await n(e.floating);return{reference:Ib(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ab(e){return dn(e).direction==="rtl"}const jb={convertOffsetParentRelativeRectToViewportRelativeRect:vb,getDocumentElement:yn,getClippingRect:kb,getOffsetParent:dd,getElementRects:Nb,getClientRects:wb,getDimensions:Eb,getScale:Tr,isElement:un,isRTL:Ab};function fd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Pb(e,t){let n=null,r;const o=yn(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,$n(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&&!fd(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 _b(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=Zi(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?Pb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.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?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!fd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Mb=rb,Rb=ob,Ob=eb,Db=ib,Lb=tb,hd=Qw,$b=sb,Fb=(e,t,n)=>{const r=new Map,o={platform:jb,...n},s={...o.platform,_c:r};return Zw(e,t,{...o,platform:s})};var Bb=typeof document<"u",zb=function(){},is=Bb?w.useLayoutEffect:zb;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 pd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function md(e,t){const n=pd(e);return Math.round(t*n)/n}function ea(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function Hb(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),b=p.useCallback(_=>{_!==T.current&&(T.current=_,g(_))},[]),S=p.useCallback(_=>{_!==E.current&&(E.current=_,y(_))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),N=p.useRef(d),R=l!=null,D=ea(l),B=ea(o),H=ea(c),L=p.useCallback(()=>{if(!T.current||!E.current)return;const _={placement:t,strategy:n,middleware:m};B.current&&(_.platform=B.current),Fb(T.current,E.current,_).then(I=>{const q={...I,isPositioned:H.current!==!1};j.current&&!as(N.current,q)&&(N.current=q,Hr.flushSync(()=>{h(q)}))})},[m,t,n,B,H]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(_=>({..._,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,L);L()}},[k,C,L,D,R]);const K=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),V=p.useMemo(()=>({reference:k,floating:C}),[k,C]),$=p.useMemo(()=>{const _={position:n,left:0,top:0};if(!V.floating)return _;const I=md(V.floating,d.x),q=md(V.floating,d.y);return a?{..._,transform:"translate("+I+"px, "+q+"px)",...pd(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,V.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:L,refs:K,elements:V,floatingStyles:$}),[d,L,K,V,$])}const Ub=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?hd({element:r.current,padding:o}).fn(n):{}:r?hd({element:r,padding:o}).fn(n):{}}}},Wb=(e,t)=>({...Mb(e),options:[e,t]}),Vb=(e,t)=>({...Rb(e),options:[e,t]}),Kb=(e,t)=>({...$b(e),options:[e,t]}),qb=(e,t)=>({...Ob(e),options:[e,t]}),Gb=(e,t)=>({...Db(e),options:[e,t]}),Yb=(e,t)=>({...Lb(e),options:[e,t]}),Xb=(e,t)=>({...Ub(e),options:[e,t]});var Jb="Arrow",gd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.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"})})});gd.displayName=Jb;var Zb=gd;function xd(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 ta="Popper",[vd,kr]=cn(ta),[Qb,wd]=vd(ta),bd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(Qb,{scope:t,anchor:r,onAnchorChange:o,children:n})};bd.displayName=ta;var yd="PopperAnchor",Sd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(yd,n),i=p.useRef(null),a=$e(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(ve.div,{...o,ref:a})});Sd.displayName=yd;var na="PopperContent",[ey,ty]=vd(na),Cd=p.forwardRef((e,t)=>{var W,O,X,Z,ue,F;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(na,n),[y,b]=p.useState(null),S=$e(t,ne=>b(ne)),[k,C]=p.useState(null),T=xd(k),E=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},B=Array.isArray(c)?c:[c],H=B.length>0,L={padding:D,boundary:B.filter(ry),altBoundary:H},{refs:j,floatingStyles:K,placement:V,isPositioned:$,middlewareData:_}=Hb({strategy:"fixed",placement:R,whileElementsMounted:(...ne)=>_b(...ne,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Wb({mainAxis:o+N,alignmentAxis:i}),l&&Vb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Kb():void 0,...L}),l&&qb({...L}),Gb({...L,apply:({elements:ne,rects:de,availableWidth:ce,availableHeight:ge})=>{const{width:Ce,height:_e}=de.reference,De=ne.floating.style;De.setProperty("--radix-popper-available-width",`${ce}px`),De.setProperty("--radix-popper-available-height",`${ge}px`),De.setProperty("--radix-popper-anchor-width",`${Ce}px`),De.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),k&&Xb({element:k,padding:a}),oy({arrowWidth:E,arrowHeight:N}),m&&Yb({strategy:"referenceHidden",...L})]}),[I,q]=Ed(V),Y=xt(v);It(()=>{$&&(Y==null||Y())},[$,Y]);const P=(W=_.arrow)==null?void 0:W.x,M=(O=_.arrow)==null?void 0:O.y,G=((X=_.arrow)==null?void 0:X.centerOffset)!==0,[J,oe]=p.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:$?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=_.transformOrigin)==null?void 0:Z.x,(ue=_.transformOrigin)==null?void 0:ue.y].join(" "),...((F=_.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(ey,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":I,"data-align":q,...g,ref:S,style:{...g.style,animation:$?void 0:"none"}})})})});Cd.displayName=na;var Td="PopperArrow",ny={top:"bottom",right:"left",bottom:"top",left:"right"},kd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=ty(Td,r),i=ny[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(Zb,{...o,ref:n,style:{...o.style,display:"block"}})})});kd.displayName=Td;function ry(e){return e!==null}var oy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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]=Ed(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.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 Ed(e){const[t,n="center"]=e.split("-");return[t,n]}var ra=bd,oa=Sd,sa=Cd,ia=kd,sy="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?_o.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});so.displayName=sy;function iy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=ay(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=$e(r.ref,ly(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function ay(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=iy(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 ly(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 aa="rovingFocusGroup.onEntryFocus",cy={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[la,Id,uy]=Yo(io),[dy,Nd]=cn(io,[uy]),[fy,hy]=dy(io),Ad=p.forwardRef((e,t)=>u.jsx(la.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(la.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(py,{...e,ref:t})})}));Ad.displayName=io;var py=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=$e(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=xt(c),k=Id(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(aa,S),()=>N.removeEventListener(aa,S)},[S]),u.jsx(fy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const D=new CustomEvent(aa,cy);if(N.currentTarget.dispatchEvent(D),!D.defaultPrevented){const B=k().filter(V=>V.focusable),H=B.find(V=>V.active),L=B.find(V=>V.id===g),K=[H,L,...B].filter(Boolean).map(V=>V.ref.current);_d(K,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),jd="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=hy(jd,n),h=d.currentTabStopId===c,m=Id(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(la.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=xy(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?vy(S,k+1):S.slice(k+1)}setTimeout(()=>_d(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=jd;var my={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function xy(e,t,n){const r=gy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return my[r]}function _d(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function vy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var wy=Ad,by=Pd,yy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ca=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},Sy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Md(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})},Cy=function(e,t,n,r){var o=Sy(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=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.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(),ca++,function(){i.forEach(function(h){var m=Er.get(h)-1,f=s.get(h)-1;Er.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ca--,ca||(Er=new WeakMap,Er=new WeakMap,cs=new WeakMap,us={})}},ua=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=yy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Cy(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function Rd(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 Ty(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",ky="with-scroll-bars-hidden",Ey="--removed-body-scroll-bar-size";function da(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Iy(e,t){var n=w.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 Ny=typeof window<"u"?p.useLayoutEffect:p.useEffect,Od=new WeakMap;function Ay(e,t){var n=Iy(null,function(r){return e.forEach(function(o){return da(o,r)})});return Ny(function(){var r=Od.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||da(a,null)}),s.forEach(function(a){o.has(a)||da(a,i)})}Od.set(n,e)},[e]),n}function jy(e){return e}function Py(e,t){t===void 0&&(t=jy);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=Py(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Dd=function(e){var t=e.sideCar,n=Rd(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,Cn({},n))};Dd.isSideCarExport=!0;function My(e,t){return e.useMedium(t),Dd}var Ld=_y(),fa=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:fa,onWheelCapture:fa,onTouchMoveCapture:fa}),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,b=y===void 0?"div":y,S=e.gapMode,k=Rd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ay([n,t]),E=Cn(Cn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Ld,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),Cn(Cn({},E),{ref:T})):p.createElement(b,Cn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Ry=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Oy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ry();return t&&e.setAttribute("nonce",t),e}function Dy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ly(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $y=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Oy())&&(Dy(t,n),Ly(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fy=function(){var e=$y();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},$d=function(){var e=Fy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},By={left:0,top:0,right:0,gap:0},ha=function(e){return parseInt(e||"",10)||0},zy=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)]},Hy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return By;var t=zy(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])}},Uy=$d(),Ir="data-scroll-locked",Wy=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
|
-
.`.concat(
|
|
38
|
+
`);if(!Et)continue;let Nt;try{Nt=JSON.parse(Et)}catch{console.debug("[use-chat] malformed SSE:",Et.slice(0,200));continue}const Lt=ou(Nt)?Nt.data:Nt;if(!Lt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const je=Lt;jt=Date.now();const ht=je.seq;if(ht!==void 0){if(ht<=wt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ht,lastProcessedSeq:wt,type:je.type});continue}wt>0&&ht>wt+1&&((ue=I==null?void 0:I.onGap)==null||ue.call(I,{from:wt,to:ht})),wt=ht,E.current=ht,x(ht)}if(je.type==="message.start"&&je.role==="assistant"){const Ze=cu(je.model);V.current={messageId:je.id,lastSeq:ht??null,lastText:""},k({id:je.id,role:"assistant",name:Ze??void 0,model:je.model,createdAt:new Date().toISOString(),content:[]})}if(je.type==="checkpoint")R.current=je.checkpointId??null,L.current=je.checkpointNs??null,v(je.checkpointId??null);else if(je.type==="state_history"){z.current=je;try{const ft=Mn(je).latest;ft&&(R.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Ze){console.warn("[use-chat] Failed to hydrate state_history payload",Ze)}}try{P==null||P(je)}catch(Ze){console.error("[use-chat] Error in onEvent callback:",Ze,"for event:",je.type)}if(je.type==="message.delta"){k(ft=>{const an=V.current;if(!ft||an.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:he}=au(ft.content??[],je.delta,{lastSeq:an.lastSeq,lastText:an.lastText},ht??null);return he?(V.current={...an,lastSeq:Q.lastSeq??an.lastSeq,lastText:Q.lastText??an.lastText},{...ft,content:A}):ft});const Ze=je.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Ze&&e.autoAppendAssistant!==!1&&(At.push(Ze),Tt())}else if(je.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(F=I==null?void 0:I.onHeartbeat)==null||F.call(I,je)}catch(Ze){console.warn("[use-chat] heartbeat callback failed",Ze)}}else if(dt!==null&&cancelAnimationFrame(dt),bt(),je.type==="checkpoint")v(je.checkpointId);else if(je.type==="error"){const Ze=je;if(d(Ze.message),Y="error",_=Ze.message,Ze.error_type==="auth_error"||Ze.code==="TOKEN_EXPIRED"||((ne=Ze.message)==null?void 0:ne.includes("token"))||((de=Ze.message)==null?void 0:de.includes("401"))||((ce=Ze.message)==null?void 0:ce.includes("unauthorized"))||((ge=Ze.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ze.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,Ze.message)}catch(an){console.warn("[use-chat] onAuthError handler failed",an)}q.abort()}}}}bt(),Y===null&&!q.signal.aborted&&(Y="complete")}catch(Ee){if(Ee.name==="AbortError")Y=Y??"aborted";else{const Ke=Ee.message||String(Ee);Y="error",_=Ke,d(Ke),(Pe=I==null?void 0:I.onError)==null||Pe.call(I,Ke)}}finally{try{await mt.cancel()}catch{}finally{(De=mt.releaseLock)==null||De.call(mt)}dt!==null&&typeof window<"u"&&window.cancelAnimationFrame(dt),clearInterval(Te)}}catch(Ve){if(Ve.name==="AbortError")Y=Y??"aborted";else{const He=Ve.message||String(Ve);Y="error",_=He,d(He),(ze=I==null?void 0:I.onError)==null||ze.call(I,He),M||((rt=I==null?void 0:I.onConnectionError)==null||rt.call(I,He),M=!0)}}finally{const Ve=E.current,He=R.current,Ye=L.current,Le=z.current,Ue=Y??(q.signal.aborted?"aborted":_?"error":"complete");try{(Ct=I==null?void 0:I.onClosed)==null||Ct.call(I,{reason:Ue,lastSeq:Ve,lastCheckpointId:He,lastCheckpointNs:Ye,lastStateHistory:Le,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),b(!1),C.current=null,E.current=0,x(0),N.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var O;T.current=!1,(O=C.current)==null||O.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:W,clear:j,setToken:U}}const Kv=["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 Kv){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 qv(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]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,C]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const N=w.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=w.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]);w.useEffect(()=>{N()},[N]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await N(),I.threadId}catch(I){const q=String(I);return n==null||n(q),null}},[e,n,N]),z=w.useCallback(async P=>{const I=s;i(Y=>Y.filter(_=>_.threadId!==P));const q=new AbortController;E.current.set(P,q);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(Y){i(I);const _=String(Y);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),V=w.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await N()}catch(q){n==null||n(String(q))}},[e,n,N]),U=w.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await R(),S("Shared successfully")}catch(q){const Y=qv(q);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,R]),j=w.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await R()}catch(q){const Y=String(q);throw n==null||n(Y),q}},[e,n,R]),W=w.useMemo(()=>({createThread:L,deleteThread:z,renameThread:V,refreshThreads:N,refreshSharedThreads:R,shareThread:U,unshareThread:j}),[L,z,V,N,R,U,j]),$=w.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(q=>{let Y=!1;const _=q.map(M=>M.threadId===I.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...M,title:I.title??M.title,updatedAt:I.updatedAt??M.updatedAt,messageCount:I.messageCount??M.messageCount}):M);return Y?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),O=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:$,shareInFlight:k,shareStatus:b,clearShareStatus:O}}const du=w.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}),b=w.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:b,children:e})}function gr(){const e=w.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 xr(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 Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=xr(e);return typeof e=="string"&&Gv(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 Xv(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 Jv(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 Zv(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("type"in e&&e.type==="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 Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ew(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=ew(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nw(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 tw({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 rw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ow(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 sw(e=[]){const[t,n]=w.useReducer(ow,{...rw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 aw(e,t);if(t.type==="tool.progress")return lw(e,t);if(t.type==="tool.end")return cw(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},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}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=Wv(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?Hv(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 iw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(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 aw(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 lw(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 cw(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=iw(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=wu(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 bu({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]=w.useState(null),v=w.useMemo(()=>Mn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,N]=w.useState(!1),[R,L]=w.useState(!1),[z,V]=w.useState(null),U=w.useRef(o),j=w.useRef(null),W=w.useRef(null),$=w.useRef(null),O=w.useRef(null),P=w.useRef(!1),I=w.useRef(null),q=w.useRef(new Map);w.useEffect(()=>{U.current=o},[o]);const Y=w.useCallback(async F=>{var de,ce;if(!F.threadId)return;const ne=F.threadId;(de=F.onStart)==null||de.call(F),F.setLoading(!0);try{await F.action(ne)}catch(ge){if(U.current===ne){const Ce=String(ge);(ce=F.handleError)==null||ce.call(F,Ce),r==null||r(Ce)}throw ge}finally{F.setLoading(!1)}},[r]),_=w.useCallback(async(F,ne)=>{if(!F)return;const de=`${F}:${ne??"latest"}`,ce=q.current.get(de);if(ce)return ce;const ge=Y({threadId:F,setLoading:T,onStart:()=>V(null),handleError:Ce=>V(Ce),action:async Ce=>{const Pe=await e.getStateHistory({threadId:Ce,checkpointId:ne??void 0});if(U.current!==Ce){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:De}=Mn(Pe),ze=De.find(rt=>rt.messages&&rt.messages.length>0)??(ne?De.find(rt=>rt.checkpointId===ne):null)??De[0];t((ze==null?void 0:ze.messages)??[],{checkpointId:(ze==null?void 0:ze.checkpointId)??null,checkpointNs:(ze==null?void 0:ze.checkpointNs)??null}),m(Pe),b(!!(ze!=null&&ze.nextCursor)),k((ze==null?void 0:ze.nextCursor)??null)}});q.current.set(de,ge);try{await ge}finally{q.current.delete(de)}return U.current===F&&(I.current=de),ge},[e,t,Y]),M=w.useCallback(async(F,ne)=>{O.current=F;try{await _(F,ne)}finally{O.current===F&&(O.current=null)}},[_]),G=w.useCallback(F=>{W.current=F},[]),J=w.useCallback(F=>{$.current=F},[]),oe=w.useCallback(F=>{const ne=F.threadId??U.current;if(!ne||U.current&&U.current!==ne)return;const{checkpoints:de}=Mn(F);if(!de.length)return;const ce=de.find(Ce=>Ce.messages&&Ce.messages.length>0)??de.find(Ce=>!!Ce.checkpointId)??de[0],ge=$.current===ne;!c&&!ge&&t((ce==null?void 0:ce.messages)??[],{checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}),m(F),b(!!(ce!=null&&ce.nextCursor)),k((ce==null?void 0:ce.nextCursor)??null),I.current=`${ne}:latest`,W.current=null,$.current===ne&&($.current=null)},[t,c]),K=w.useCallback(async(F,ne)=>{const de=U.current;await Y({threadId:de,setLoading:L,action:async ce=>{const ge=await e.getStateHistory({threadId:ce,checkpointId:F,checkpointNs:ne??void 0});if(U.current!==ce){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:Ce}=Mn(ge),Pe=Ce.find(De=>De.checkpointId===F&&(ne?De.checkpointNs===ne:!0));if(!Pe){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:ne});return}m(ge),t(Pe.messages??[],{checkpointId:Pe.checkpointId??null,checkpointNs:Pe.checkpointNs??null})}}).catch(()=>{})},[e,t,Y]),D=w.useCallback((F,ne)=>{t(d(),{checkpointId:F??null,checkpointNs:ne??null})},[d,t]),X=w.useCallback(async()=>{U.current&&await M(U.current)},[M]),Z=w.useCallback(async()=>{const F=U.current;!F||!S||await Y({threadId:F,setLoading:N,action:async ne=>{const de=await e.getStateHistory({threadId:ne,checkpointId:S});if(U.current!==ne)return;const{checkpoints:ce}=Mn(de);if(ce.length>0){const ge=ce[ce.length-1];n((ge==null?void 0:ge.messages)??[]),b(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,Y]);w.useEffect(()=>{if(!l||!o||C||c)return;if(W.current===o){W.current=null,j.current=o;return}if($.current===o){j.current=o;return}if(O.current===o){O.current=null,j.current=o;return}if(j.current===o)return;j.current=o;const F=!P.current&&!!i&&o===s;let ne;F&&i?(ne=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",ne,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const de=`${o}:${ne??"latest"}`;I.current!==de&&M(o,ne)},[l,o,i,a,s,C,c,M]);const ue=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),N(!1),L(!1),V(null),W.current=null,$.current=null,j.current=null,I.current=null,O.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:z,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:K,loadOlderMessages:Z,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:oe,markSkipNextLoad:G,markStreamPendingThread:J,resetHistoryState:ue}}const yu=w.createContext(null),Su=w.createContext(null);function eo(){const e=w.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=w.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}=gr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j}=bu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[W,$]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[O,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const I=w.useCallback(G=>$(()=>G),[]),q=w.useCallback(G=>P(()=>G),[]),Y=w.useMemo(()=>{const G=c.assemblingId??null;return G?{assemblingMessageId:G}:null},[c.assemblingId]),_=w.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:Y,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:W,respondToInterrupt:O,messagePreviews:x.messagePreviews,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,b,S,k,C,N,W,E,R,L,T,O,x.messagePreviews,z,V,U,j,m,f]),M=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:q}),[I,q]);return u.jsx(Su.Provider,{value:M,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Pn(r,t)??null}function uw(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 dw(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 fw(e,t){const n=[...e].sort(dw);for(const r of n){if(r.messageId!==t)continue;const o=uw(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=w.createContext(null),Iu=w.createContext(!1);function hw({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=w.useMemo(()=>vn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[b,S]=w.useState(!1);return w.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:b,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pw({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}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:N}=Cu(),R=w.useCallback(O=>{v(O),f.current!==O.threadId&&((O.created??!f.current)&&b(O.threadId),S(O.threadId),m(O.threadId))},[v,b,S,m,f]),L=w.useCallback(O=>{O.type==="thread_info"?R(O):O.type==="state_history"?y(O):O.type==="tool.end"?i==null||i(O):T(O)},[R,y,T,i]),z=w.useCallback(O=>{a(O,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]),V=w.useRef(g);w.useEffect(()=>{V.current=g},[g]);const U=w.useCallback(async(O,P,I)=>{const q=f.current;if(!q)throw new Error("No active thread to handle interrupt");const Y=P?I??!0:!1,_=V.current,M={threadId:q,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:Y}};z(M)},[f,z]);w.useEffect(()=>{N(U)},[U,N]);const j=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(O){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",O)}},[t,k,m,l]);w.useEffect(()=>{E(j)},[j,E]);const W=w.useCallback(async(O,P)=>{let I=f.current;const q=(O==null?void 0:O.text)??"",Y=(O==null?void 0:O.attachments)??[],_=(q==null?void 0:q.trim())??"",M={...(O==null?void 0:O.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!I&&!_&&Y.length===0&&!J)return;if(!I){const Pe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),De=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Pe}${De}`,b(I),m(I)}const{contentParts:oe,filesInfo:K}=await ru(Y),D=[...oe];_&&D.push({type:"text",text:q});const X=P==null?void 0:P.originalMessageId,Z=!!(P!=null&&P.edit&&X),ue=!J&&D.length>0;let F=null;ue&&(F={id:Z?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},Z?C(F,X):C(F));const ne=J?G:F?[F]:[],de={...M,...K.length?{files_info:K}:{}};ne.length?de.messages=ne:"messages"in de||(de.messages=[]);let ce=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(Z&&X){const Pe=fw(x,X);ce=Pe.checkpointId,ge=Pe.checkpointNs??void 0}const Ce={threadId:I,payload:de,checkpointId:ce,checkpointNs:ge,edit:!!(P!=null&&P.edit)};z(Ce)},[g,f,b,C,z,x]),$=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:h}),[c,d,W,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=w.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mw(){return w.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gw(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=w.useRef(e),n=w.useRef(e);return gw(t.current,e)||(t.current=e,n.current=e),n.current}function vr({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=w.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(hw,{...y,children:e})})}function to(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(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=xw(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 vn(t);return vn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=Rn.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,Rn.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:vn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vw(){const e=Ru(),t=Ou(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(Rn.baseUrl,r,e.apiBaseUrl)}}function ww(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function te(...e){return nx.twMerge(tx.clsx(e))}const bw=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"}}),tt=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(bw({variant:t,size:n,className:e})),ref:s,...o})});tt.displayName="Button";function ae(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 On(...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 $e(...e){return p.useCallback(On(...e),e)}function yw(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 cn(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,Sw(o,...t)]}function Sw(...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:()=>{},Cw=p[" useInsertionEffect ".trim().toString()]||It;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tw({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=kw(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 Tw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cw(()=>{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 kw(e){return typeof e=="function"}var Ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Ew.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]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=$e(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=$e(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const S=Array.from(b.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 Iw=p.createContext(void 0);function Xo(e){const t=p.useContext(Iw);return e||t||"ltr"}function xt(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 Nw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(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 Aw="DismissableLayer",Bi="dismissableLayer.update",jw="dismissableLayer.pointerDownOutside",_w="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),br=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=$e(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Mw(E=>{const N=E.target,R=[...c.branches].some(L=>L.contains(N));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Rw(E=>{const N=E.target;[...c.branches].some(L=>L.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Nw(E=>{b===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(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});br.displayName=Aw;var Pw="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Bu.displayName=Pw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jw,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 Rw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_w,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 Ow=br,Dw=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},Lw="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=xt(o),d=xt(s),h=p.useRef(null),m=$e(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:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.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||($w(Uw(Vu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(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 b=g.currentTarget,[S,k]=Fw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lw;function $w(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Fw(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(!Bw(n,{upTo:t}))return n}function Bw(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 zw(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var qu=Hw();function Hw(){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 Uw(e){return e.filter(t=>t.tagName!=="A")}var Ww=p[" useId ".trim().toString()]||(()=>{}),Vw=0;function Pt(e){const[t,n]=p.useState(Ww());return It(()=>{n(r=>r??String(Vw++))},[e]),t?`radix-${t}`:""}const Kw=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),qw={left:"right",right:"left",bottom:"top",top:"bottom"},Gw={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yw=new Set(["top","bottom"]);function bn(e){return Yw.has(An(e))?"y":"x"}function Gi(e){return Ki(bn(e))}function Xw(e,t,n){n===void 0&&(n=!1);const r=yr(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 Jw(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gw[t])}const Yu=["left","right"],Xu=["right","left"],Zw=["top","bottom"],Qw=["bottom","top"];function eb(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zw:Qw;default:return[]}}function tb(e,t,n,r){const o=yr(e);let s=eb(An(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=>qw[t])}function nb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nb(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=bn(t),i=Gi(t),a=qi(i),l=An(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(yr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rb=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:b,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=b??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}=Nn(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})),b=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:b,offsetParent:S,strategy:l}):b);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 ob=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}=Nn(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",b=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 N=k/2-C/2,R=E/2-g[v]/2-1,L=$n(h[y],R),z=$n(h[b],R),V=L,U=E-g[v]-z,j=E/2-g[v]/2+N,W=Vi(V,j,U),$=!l.arrow&&yr(o)!=null&&j!==W&&s.reference[v]/2-(j<V?L:z)-g[v]/2<0,O=$?j<V?j-V:j-U:0;return{[f]:m[f]+O,data:{[f]:W,centerOffset:j-W-O,...$&&{alignmentOffset:O}},reset:$}}}),sb=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}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),b=bn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jw(a)),T=v!=="none";!m&&T&&C.push(...tb(a,g,v,k));const E=[a,...C],N=await no(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),h){const j=Xw(o,i,k);R.push(N[j[0]],N[j[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(j=>j<=0)){var z,V;const j=(((z=s.flip)==null?void 0:z.index)||0)+1,W=E[j];if(W&&(!(h==="alignment"?b!==bn(W):!1)||L.every(P=>bn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:j,overflows:L},reset:{placement:W}};let $=(V=L.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:V.placement;if(!$)switch(f){case"bestFit":{var U;const O=(U=L.filter(P=>{if(T){const I=bn(P.placement);return I===b||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,q)=>I+q,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:U[0];O&&($=O);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 Kw.some(t=>e[t]>=0)}const ib=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(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 ab(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=bn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=Nn(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 lb=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 ab(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}}}}},cb=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:b}=x;return{x:y,y:b}}},...l}=Nn(e,t),c={x:n,y:r},d=await no(t,l),h=bn(An(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Vi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Vi(b,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}}}}}},ub=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}=Nn(e,t),d={x:n,y:r},h=bn(o),m=Ki(h);let f=d[m],v=d[h];const g=Nn(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,b;const S=m==="y"?"width":"height",k=td.has(An(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:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},db=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}=Nn(e,t),d=await no(t,c),h=An(o),m=yr(o),f=bn(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 b=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],b),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),z=Zt(d.right,0),V=Zt(d.top,0),U=Zt(d.bottom,0);f?N=v-2*(L!==0||z!==0?L+z:Zt(d.left,d.right)):E=g-2*(V!==0||U!==0?V+U:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,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 Sr(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 yn(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 un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(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 fb=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fb.has(o)}const hb=new Set(["table","td","th"]);function pb(e){return hb.has(Sr(e))}const mb=[":popover-open",":modal"];function rs(e){return mb.some(t=>{try{return e.matches(t)}catch{return!1}})}const gb=["transform","translate","scale","rotate","perspective"],xb=["transform","translate","scale","rotate","perspective","filter"],vb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=un(e)?dn(e):e;return gb.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)||xb.some(r=>(n.willChange||"").includes(r))||vb.some(r=>(n.contain||"").includes(r))}function wb(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Xi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bb=new Set(["html","body","#document"]);function Cr(e){return bb.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||yn(e);return rd(t)?t.host:t}function od(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(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=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(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 un(e)?e:e.contextElement}function Tr(e){const t=Qi(e);if(!Sn(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 yb=wn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(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?un(r)&&(i=Tr(r)):i=Tr(e));const a=Sb(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&&un(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=Tr(g),y=g.getBoundingClientRect(),b=dn(g),S=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.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:Qn(yn(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 Cb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(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=Sn(r);if((h||!h&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const f=Qn(r);c=Tr(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 Tb(e){return Array.from(e.getClientRects())}function kb(e){const t=yn(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 dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Eb(e,t){const n=Qt(e),r=yn(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 Ib=new Set(["absolute","fixed"]);function Nb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(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=Eb(e,n);else if(t==="document")r=kb(yn(e));else if(un(t))r=Nb(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=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||ud(n,t)}function Ab(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ib.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function jb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Ab(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=$n(h.right,c.right),c.bottom=$n(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 _b(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(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((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=Qn(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 dn(e).position==="static"}function dd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!ea(o))return o;o=Fn(o)}return n}let r=dd(e,t);for(;r&&pb(r)&&ea(r);)r=dd(r,t);return r&&Cr(r)&&ea(r)&&!Xi(r)?n:r||wb(e)||n}const Mb=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return dn(e).direction==="rtl"}const Ob={convertOffsetParentRelativeRectToViewportRelativeRect:Cb,getDocumentElement:yn,getClippingRect:jb,getOffsetParent:fd,getElementRects:Mb,getClientRects:Tb,getDimensions:_b,getScale:Tr,isElement:un,isRTL:Rb};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Db(e,t){let n=null,r;const o=yn(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,$n(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 Lb(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?Db(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.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?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!hd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $b=lb,Fb=cb,Bb=sb,zb=db,Hb=ib,pd=ob,Ub=ub,Wb=(e,t,n)=>{const r=new Map,o={platform:Ob,...n},s={...o.platform,_c:r};return rb(e,t,{...o,platform:s})};var Vb=typeof document<"u",Kb=function(){},is=Vb?w.useLayoutEffect:Kb;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 qb(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),b=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),N=p.useRef(d),R=l!=null,L=ta(l),z=ta(o),V=ta(c),U=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};z.current&&(P.platform=z.current),Wb(T.current,E.current,P).then(I=>{const q={...I,isPositioned:V.current!==!1};j.current&&!as(N.current,q)&&(N.current=q,Hr.flushSync(()=>{h(q)}))})},[m,t,n,z,V]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,U);U()}},[k,C,U,L,R]);const W=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),O=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),q=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+q+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:U,refs:W,elements:$,floatingStyles:O}),[d,U,W,$,O])}const Gb=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):{}}}},Yb=(e,t)=>({...$b(e),options:[e,t]}),Xb=(e,t)=>({...Fb(e),options:[e,t]}),Jb=(e,t)=>({...Ub(e),options:[e,t]}),Zb=(e,t)=>({...Bb(e),options:[e,t]}),Qb=(e,t)=>({...zb(e),options:[e,t]}),ey=(e,t)=>({...Hb(e),options:[e,t]}),ty=(e,t)=>({...Gb(e),options:[e,t]});var ny="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.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=ny;var ry=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",[wd,kr]=cn(na),[oy,bd]=wd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{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=bd(Sd,n),i=p.useRef(null),a=$e(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(ve.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=wd(ra),Td=p.forwardRef((e,t)=>{var K,D,X,Z,ue,F;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=bd(ra,n),[y,b]=p.useState(null),S=$e(t,ne=>b(ne)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,N=(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},z=Array.isArray(c)?c:[c],V=z.length>0,U={padding:L,boundary:z.filter(ly),altBoundary:V},{refs:j,floatingStyles:W,placement:$,isPositioned:O,middlewareData:P}=qb({strategy:"fixed",placement:R,whileElementsMounted:(...ne)=>Lb(...ne,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yb({mainAxis:o+N,alignmentAxis:i}),l&&Xb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jb():void 0,...U}),l&&Zb({...U}),Qb({...U,apply:({elements:ne,rects:de,availableWidth:ce,availableHeight:ge})=>{const{width:Ce,height:Pe}=de.reference,De=ne.floating.style;De.setProperty("--radix-popper-available-width",`${ce}px`),De.setProperty("--radix-popper-available-height",`${ge}px`),De.setProperty("--radix-popper-anchor-width",`${Ce}px`),De.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:E,arrowHeight:N}),m&&ey({strategy:"referenceHidden",...U})]}),[I,q]=Id($),Y=xt(v);It(()=>{O&&(Y==null||Y())},[O,Y]);const _=(K=P.arrow)==null?void 0:K.x,M=(D=P.arrow)==null?void 0:D.y,G=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[J,oe]=p.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:O?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(ue=P.transformOrigin)==null?void 0:ue.y].join(" "),...((F=P.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":I,"data-align":q,...g,ref:S,style:{...g.style,animation:O?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[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(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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=(((b=o.arrow)==null?void 0:b.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,uy="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(ve.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=$e(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(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 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",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=cn(io,[my]),[xy,vy]=gy(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=$e(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=xt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(la,S),()=>N.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const L=new CustomEvent(la,py);if(N.currentTarget.dispatchEvent(L),!L.defaultPrevented){const z=k().filter($=>$.focusable),V=z.find($=>$.active),U=z.find($=>$.id===g),W=[V,U,...z].filter(Boolean).map($=>$.ref.current);Md(W,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!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=vy(_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(ve.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(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?Cy(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 by={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return by[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 Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Iy=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})},Ny=function(e,t,n,r){var o=Iy(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=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.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=Er.get(h)-1,f=s.get(h)-1;Er.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Er=new WeakMap,Er=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=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.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 Ay(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",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(e,t){var n=w.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"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Ry(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(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 Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);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 Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Cn({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,Cn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),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,b=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=Ry([n,t]),E=Cn(Cn({},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),Cn(Cn({},E),{ref:T})):p.createElement(b,Cn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=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)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(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])}},Gy=Fd(),Ir="data-scroll-locked",Yy=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
|
+
.`.concat(jy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -71,29 +71,29 @@ React keys must be passed directly to JSX without using spread:
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(Ir,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(_y,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},
|
|
76
|
+
`)},Bd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},Xy=function(){p.useEffect(function(){return document.body.setAttribute(Ir,(Bd()+1).toString()),function(){var e=Bd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},Jy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xy();var s=p.useMemo(function(){return qy(o)},[o]);return p.createElement(Gy,{styles:Yy(s,!t,o,n?"":"!important")})},ma=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return ma=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{ma=!1}var Nr=ma?{passive:!1}:!1,Zy=function(e){return e.tagName==="TEXTAREA"},zd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Zy(e)&&n[t]==="visible")},Qy=function(e){return zd(e,"overflowY")},e0=function(e){return zd(e,"overflowX")},Hd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ud(e,r);if(o){var s=Wd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},t0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},n0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ud=function(e,t){return e==="v"?Qy(t):e0(t)},Wd=function(e,t){return e==="v"?t0(t):n0(t)},r0=function(e,t){return e==="h"&&t==="rtl"?-1:1},o0=function(e,t,n,r,o){var s=r0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,h=0,m=0;do{if(!a)break;var f=Wd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Ud(e,a)&&(h+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(h)<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]},Vd=function(e){return[e.deltaX,e.deltaY]},Kd=function(e){return e&&"current"in e?e.current:e},s0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},i0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},n0=0,Ar=[];function r0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(n0++)[0],s=p.useState($d)[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=Ty([e.lockRef.current],(e.shards||[]).map(Vd),!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),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[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 N=zd(E,T);if(!N)return!0;if(N?C=E:(C=E==="v"?"h":"v",N=zd(E,T)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return Qy(R,x,g,R==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?Wd(x):ms(x),b=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&e0(C.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Vd).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,b){var S={name:g,delta:x,target:y,should:b,shadowParent:o0(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,Wd(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 Ar.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:t0(o)}):null,f?p.createElement(Ky,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function o0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const s0=My(Ld,r0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Cn({},e,{ref:t,sideCar:s0}))});gs.classNames=hs.classNames;var ma=["Enter"," "],i0=["ArrowDown","PageUp","Home"],Kd=["ArrowUp","PageDown","End"],a0=[...i0,...Kd],l0={ltr:[...ma,"ArrowRight"],rtl:[...ma,"ArrowLeft"]},c0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,u0,d0]=Yo(ao),[er,qd]=cn(ao,[d0,kr,Nd]),xs=kr(),Gd=Nd(),[f0,tr]=er(ao),[h0,co]=er(ao),Yd=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=xt(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(ra,{...a,children:u.jsx(f0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(h0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Yd.displayName=ao;var p0="MenuAnchor",ga=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(oa,{...o,...r,ref:t})});ga.displayName=p0;var xa="MenuPortal",[m0,Xd]=er(xa,{forceMount:void 0}),Jd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(xa,t);return u.jsx(m0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Jd.displayName=xa;var nn="MenuContent",[g0,va]=er(nn),Zd=p.forwardRef((e,t)=>{const n=Xd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(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(x0,{...o,ref:t}):u.jsx(v0,{...o,ref:t})})})})}),x0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ua(s)},[]),u.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),v0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),w0=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=tr(nn,n),y=co(nn,n),b=xs(n),S=Gd(n),k=u0(n),[C,T]=p.useState(null),E=p.useRef(null),N=$e(t,E,x.onContentChange),R=p.useRef(0),D=p.useRef(""),B=p.useRef(0),H=p.useRef(null),L=p.useRef("right"),j=p.useRef(0),K=v?gs:p.Fragment,V=v?{as:w0,allowPinchZoom:!0}:void 0,$=I=>{var W,O;const q=D.current+I,Y=k().filter(X=>!X.disabled),P=document.activeElement,M=(W=Y.find(X=>X.ref.current===P))==null?void 0:W.textValue,G=Y.map(X=>X.textValue),J=P0(G,q,M),oe=(O=Y.find(X=>X.textValue===J))==null?void 0:O.ref.current;(function X(Z){D.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(q),oe&&setTimeout(()=>oe.focus())};p.useEffect(()=>()=>window.clearTimeout(R.current),[]),zi();const _=p.useCallback(I=>{var Y,P;return L.current===((Y=H.current)==null?void 0:Y.side)&&M0(I,(P=H.current)==null?void 0:P.area)},[]);return u.jsx(g0,{scope:n,searchRef:D,onItemEnter:p.useCallback(I=>{_(I)&&I.preventDefault()},[_]),onItemLeave:p.useCallback(I=>{var q;_(I)||((q=E.current)==null||q.focus(),T(null))},[_]),onTriggerLeave:p.useCallback(I=>{_(I)&&I.preventDefault()},[_]),pointerGraceTimerRef:B,onPointerGraceIntentChange:p.useCallback(I=>{H.current=I},[]),children:u.jsx(K,{...V,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var q;I.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(wy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(sa,{role:"menu","aria-orientation":"vertical","data-state":gf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const Y=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,M=I.key.length===1;Y&&(I.key==="Tab"&&I.preventDefault(),!P&&M&&$(I.key));const G=E.current;if(I.target!==G||!a0.includes(I.key))return;I.preventDefault();const oe=k().filter(W=>!W.disabled).map(W=>W.ref.current);Kd.includes(I.key)&&oe.reverse(),A0(oe)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),D.current="")}),onPointerMove:ae(e.onPointerMove,fo(I=>{const q=I.target,Y=j.current!==I.clientX;if(I.currentTarget.contains(q)&&Y){const P=I.clientX>j.current?"right":"left";L.current=P,j.current=I.clientX}}))})})})})})})});Zd.displayName=nn;var b0="MenuGroup",ba=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});ba.displayName=b0;var y0="MenuLabel",Qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Qd.displayName=y0;var vs="MenuItem",ef="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=va(vs,e.__scopeMenu),l=$e(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(ef,{bubbles:!0,cancelable:!0});h.addEventListener(ef,f=>r==null?void 0:r(f),{once:!0}),$i(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(tf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ae(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ma.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=vs;var tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=va(vs,n),a=Gd(n),l=p.useRef(null),c=$e(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(by,{asChild:!0,...a,focusable:!r,children:u.jsx(ve.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>h(!0)),onBlur:ae(e.onBlur,()=>h(!1))})})})}),S0="MenuCheckboxItem",nf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(lf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":bs(n)?"mixed":n,...o,ref:t,"data-state":Sa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(bs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nf.displayName=S0;var rf="MenuRadioGroup",[C0,T0]=er(rf,{value:void 0,onValueChange:()=>{}}),of=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=xt(r);return u.jsx(C0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ba,{...o,ref:t})})});of.displayName=rf;var sf="MenuRadioItem",af=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=T0(sf,e.__scopeMenu),s=n===o.value;return u.jsx(lf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});af.displayName=sf;var ya="MenuItemIndicator",[lf,k0]=er(ya,{checked:!1}),cf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=k0(ya,n);return u.jsx(Wt,{present:r||bs(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":Sa(s.checked)})})});cf.displayName=ya;var E0="MenuSeparator",uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});uf.displayName=E0;var I0="MenuArrow",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(ia,{...o,...r,ref:t})});df.displayName=I0;var N0="MenuSub",[pN,ff]=er(N0),uo="MenuSubTrigger",hf=p.forwardRef((e,t)=>{const n=tr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=ff(uo,e.__scopeMenu),s=va(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(ga,{asChild:!0,...c,children:u.jsx(tf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":gf(n.open),...e,ref:On(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:ae(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:ae(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,b=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:b,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:ae(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||l0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});hf.displayName=uo;var pf="MenuSubContent",mf=p.forwardRef((e,t)=>{const n=Xd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=ff(pf,e.__scopeMenu),l=p.useRef(null),c=$e(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:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=c0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});mf.displayName=pf;function gf(e){return e?"open":"closed"}function bs(e){return e==="indeterminate"}function Sa(e){return bs(e)?"indeterminate":e?"checked":"unchecked"}function A0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function j0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function P0(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=j0(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 M0(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 R0=Yd,O0=ga,D0=Jd,L0=Zd,$0=ba,F0=Qd,B0=ws,z0=nf,H0=of,U0=af,W0=cf,V0=uf,K0=df,q0=hf,G0=mf,ys="DropdownMenu",[Y0,mN]=cn(ys,[qd]),Ft=qd(),[X0,xf]=Y0(ys),vf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(X0,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(R0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};vf.displayName=ys;var wf="DropdownMenuTrigger",bf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=xf(wf,n),i=Ft(n);return u.jsx(O0,{asChild:!0,...i,children:u.jsx(ve.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:On(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});bf.displayName=wf;var J0="DropdownMenuPortal",yf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(D0,{...r,...n})};yf.displayName=J0;var Sf="DropdownMenuContent",Cf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xf(Sf,n),s=Ft(n),i=p.useRef(!1);return u.jsx(L0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(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)"}})});Cf.displayName=Sf;var Z0="DropdownMenuGroup",Q0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx($0,{...o,...r,ref:t})});Q0.displayName=Z0;var eS="DropdownMenuLabel",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(F0,{...o,...r,ref:t})});Tf.displayName=eS;var tS="DropdownMenuItem",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(B0,{...o,...r,ref:t})});kf.displayName=tS;var nS="DropdownMenuCheckboxItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(z0,{...o,...r,ref:t})});Ef.displayName=nS;var rS="DropdownMenuRadioGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(H0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuRadioItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(U0,{...o,...r,ref:t})});If.displayName=sS;var iS="DropdownMenuItemIndicator",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(W0,{...o,...r,ref:t})});Nf.displayName=iS;var aS="DropdownMenuSeparator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(V0,{...o,...r,ref:t})});Af.displayName=aS;var lS="DropdownMenuArrow",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(K0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuSubTrigger",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(q0,{...o,...r,ref:t})});jf.displayName=uS;var dS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(G0,{...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=dS;var fS=vf,hS=bf,pS=yf,_f=Cf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf;const Ss=fS,Cs=hS,mS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Ff,{ref:o,className:te("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(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));mS.displayName=Ff.displayName;const gS=p.forwardRef(({className:e,...t},n)=>u.jsx(Bf,{ref:n,className:te("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}));gS.displayName=Bf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(pS,{children:u.jsx(_f,{ref:r,sideOffset:t,className:te("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=_f.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Rf,{ref:r,className:te("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}));Bn.displayName=Rf.displayName;const xS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Of,{ref:o,className:te("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(Lf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));xS.displayName=Of.displayName;const vS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Df,{ref:r,className:te("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(Lf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));vS.displayName=Df.displayName;const wS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));wS.displayName=Mf.displayName;const bS=p.forwardRef(({className:e,...t},n)=>u.jsx($f,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));bS.displayName=$f.displayName;const Ca=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));Ca.displayName="Textarea";const yS=1e4;function zf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=yS,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,b]=w.useState(e),S=(x?i:y)??"",[k,C]=w.useTransition(),T=w.useRef(null),E=w.useRef(0),N=w.useRef(null),R=w.useRef("");w.useEffect(()=>{x||(b(e??""),N.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[D,B]=w.useState(null),H=w.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),L=w.useMemo(()=>v??H,[v,H]),j=w.useCallback(M=>{const G=L(M);return B(G),g==null||g(G),R.current=M,G},[L,g]),K=w.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);w.useEffect(()=>{K()},[K,S]),w.useEffect(()=>{if(!D)return;const M=(S??"").trim();R.current!==M&&j(M)},[S,D,j]);const V=w.useCallback((M,{fromUser:G})=>{x||b(M),G&&(a==null||a(M))},[x,a]),$=w.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!f||j(G))return;const J=++E.current;N.current={id:J,shouldClear:!0},C(()=>{var oe,W,O;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Z,ue;((Z=N.current)==null?void 0:Z.id)===J&&N.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ue=N.current)==null?void 0:ue.id)===J&&(N.current=null)}).catch(()=>{var Z;((Z=N.current)==null?void 0:Z.id)===J&&(N.current=null)}):(((oe=N.current)==null?void 0:oe.id)===J&&N.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=N.current)==null?void 0:W.id)===J&&(N.current=null))}catch{((O=N.current)==null?void 0:O.id)===J&&(N.current=null)}})},[S,l,f,x,a,j]),_=w.useCallback(M=>{const G=M.target.value;V(G,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),D&&j(G.trim())},[V,j,D]),I=w.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),$()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[$,t,c]),P=`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:M=>void $(M),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ca,{ref:T,value:S,onChange:_,onKeyDown:I,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),D&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:D})]}),u.jsx("div",{children:r?u.jsx(tt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(tt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(le.Send,{size:16})})})]})})}const SS=w.memo(zf),Ts=0,zn=1,jr=2,Hf=4;function Uf(e){return()=>e}function CS(e){e()}function Wf(e,t){return n=>e(t(n))}function Vf(e,t){return()=>e(t)}function TS(e,t){return n=>e(t,n)}function Ta(e){return e!==void 0}function kS(...e){return()=>{e.map(CS)}}function Pr(){}function ks(e,t){return t(e),e}function ES(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(zn,t)}function Re(e,t){e(Ts,t)}function ka(e){e(jr)}function vt(e){return e(Hf)}function we(e,t){return Qe(e,TS(t,Ts))}function fn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Kf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function qf(e,t){return e===t}function ct(e=qf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function pe(e){return t=>Wf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=IS(...t);return(r,o)=>{switch(r){case jr:ka(e);return;case zn:return Qe(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Fe(...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);Qe(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 IS(...e){return t=>e.reduceRight(ES,t)}function NS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Pr);case jr:r(),n=null;return}}}function se(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case zn:{o(t);break}case Hf:return t}return n(r,o)}}function Mt(e,t){return ks(se(t),n=>we(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case jr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>we(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:AS(),singleton:n}}const AS=()=>Symbol();function jS(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);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case jr:{ka(t);return}case zn:return r===o&&i(n),Qe(t,i)}}}function ke(e,t=qf){return ee(e,ct(t))}function Ea(...e){return function(t,n){switch(t){case jr:return;case zn:return kS(...e.map(r=>Qe(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 PS={0:"debug",3:"error",1:"log",2:"warn"},_S=()=>typeof globalThis>"u"?window:globalThis,Hn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=_S().VIRTUOSO_LOG_LEVEL)!=null?o:vt(e);r>=s&&console[PS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Ia(e,t,n).callbackRef}function Ia(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 MS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=RS(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?Gf("column-gap",getComputedStyle(d).columnGap,o):Gf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Ia(c,n,l)}function RS(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 Gf(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 Yf(e,t,n){const r=w.useRef(null),o=w.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}=Ia(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.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 Bt=Ge(()=>{const e=We(),t=We(),n=se(0),r=We(),o=se(0),s=We(),i=We(),a=se(0),l=se(0),c=se(0),d=se(0),h=We(),m=We(),f=se(!1),v=se(!1),g=se(!1);return we(ee(e,pe(({scrollTop:x})=>x)),t),we(ee(e,pe(({scrollHeight:x})=>x)),i),we(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 Xf(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 st(e){return e===po}function mo(e,t){if(!st(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(st(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 st(e)?Qf(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?eh(St(e,{l:tn(e.l,t,n)})):eh(St(e,{r:tn(e.r,t,n)}))}function _r(){return po}function Es(e,t,n){if(st(e))return[];const r=hn(e,t)[0];return OS(Aa(e,r,n))}function Na(e,t){if(st(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=Zf(r);return Is(St(e,{k:s,l:Jf(r),v:i}))}}else return t<n?Is(St(e,{l:Na(r,t)})):Is(St(e,{r:Na(o,t)}))}function or(e){return st(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Aa(e,t,n){if(st(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Aa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Aa(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(ja(t))return th(St(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ja(e))return Pa(St(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=ja(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return Qf(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 Jf(e){return st(e.r)?e.l:Is(St(e,{r:Jf(e.r)}))}function ja(e){return st(e)||e.lvl>e.r.lvl}function Zf(e){return st(e.r)?[e.k,e.v]:Zf(e.r)}function Qf(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function eh(e){return Pa(th(e))}function th(e){const{l:t}=e;return!st(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function OS(e){return Xf(e,({k:t,v:n})=>({index:t,value:n}))}function nh(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 _a=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function rh(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 DS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!st(e.groupOffsetTree)}function Ma({index:e},t){return t===e?0:t<e?-1:1}function LS(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function $S(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(VS(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Na(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 FS(e){return typeof e.groupIndex<"u"}function BS({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}=rh(t,e,Ma),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function oh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function sh(e,t,n){if(FS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=oh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function zS(e,t,n,r=0){return r>0&&(t=Math.max(t,rh(e,r,Ma).offset)),Xf(DS(e,t,n,BS),WS)}function HS(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&&st(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]=$S(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Ra(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,h,o)),_r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function US(e){return or(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 ih(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 Ra(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 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 WS(e){return{index:e.index,value:e}}function VS(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 KS={offsetHeight:"height",offsetWidth:"width"},En=Ge(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Mt(r,0),s=We(),i=We(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,KS[T])),m=se(void 0),f=se(0),v=LS(),g=Mt(ee(n,Fe(l,e,f),kn(HS,v),ct()),v),x=Mt(ee(l,ct(),kn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),pe(({prev:C})=>C)),[]);we(ee(l,Ae(C=>C.length>0),Fe(g,f),pe(([C,T,E])=>{const N=C.reduce((R,D,B)=>tn(R,D,xo(D,T.offsetTree,E)||B),_r());return{...T,groupIndices:C,groupOffsetTree:N}})),g),we(ee(r,Fe(g),Ae(([C,{lastIndex:T}])=>C<T),pe(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),we(c,d);const y=Mt(ee(c,pe(C=>C===void 0)),!0);we(ee(d,Ae(C=>C!==void 0&&st(vt(g).sizeTree)),pe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=en(ee(n,Fe(g),kn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),pe(C=>C.changed)));Qe(ee(a,kn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),pe(C=>C.diff)),C=>{const{groupIndices:T}=vt(g);if(C>0)Re(t,!0),Re(s,C+ih(C,T));else if(C<0){const E=vt(x);E.length>0&&(C-=ih(-C,E)),Re(i,C)}}),Qe(ee(a,Fe(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);we(ee(s,Fe(g),pe(([C,T])=>{const E=T.groupIndices.length>0,N=[],R=T.lastSize;if(E){const D=mo(T.sizeTree,0);let B=0,H=0;for(;B<C;){const j=T.groupIndices[H],K=T.groupIndices.length===H+1?1/0:T.groupIndices[H+1]-j-1;N.push({endIndex:j,size:D,startIndex:j}),N.push({endIndex:j+1+K-1,size:R,startIndex:j+1}),H++,B+=K+1}const L=or(T.sizeTree);return B!==C&&L.shift(),L.reduce((j,{k:K,v:V})=>{let $=j.ranges;return j.prevSize!==0&&($=[...j.ranges,{endIndex:K+C-1,size:j.prevSize,startIndex:j.prevIndex}]),{prevIndex:K+C,prevSize:V,ranges:$}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return or(T.sizeTree).reduce((D,{k:B,v:H})=>({prevIndex:B+C,prevSize:H,ranges:[...D.ranges,{endIndex:B+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=en(ee(i,Fe(g,f),pe(([C,{offsetTree:T},E])=>{const N=-C;return xo(N,T,E)})));return we(ee(i,Fe(g,f),pe(([C,T,E])=>{if(T.groupIndices.length>0){if(st(T.sizeTree))return T;let N=_r();const R=vt(x);let D=0,B=0,H=0;for(;D<-C;){H=R[B];const L=R[B+1]-H-1;B++,D+=L+1}if(N=or(T.sizeTree).reduce((L,{k:j,v:K})=>tn(L,Math.max(0,j+C),K),N),D!==-C){const L=mo(T.sizeTree,H);N=tn(N,0,L);const j=hn(T.sizeTree,-C+1)[1];N=tn(N,1,j)}return{...T,sizeTree:N,...Ra(T.offsetTree,0,N,E)}}else{const N=or(T.sizeTree).reduce((R,{k:D,v:B})=>tn(R,Math.max(0,D+C),B),_r());return{...T,sizeTree:N,...Ra(T.offsetTree,0,N,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Hn,_a),{singleton:!0});function qS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ah=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,pe(qS)));return we(ee(a,pe(l=>l.totalCount)),n),we(ee(a,pe(l=>l.groupIndices)),e),we(ee(yt(o,t,r),Ae(([l,c])=>As(c)),pe(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),pe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(En,Bt)),Wn=Ge(([{log:e}])=>{const t=se(!1),n=en(ee(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&vt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},lt(Hn),{singleton:!0}),GS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function lh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!GS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=Ge(([{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=se(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Re(l,!1)}return we(ee(f,Fe(n,h,r,g,a,i,m),Fe(e,s,o),pe(([[k,C,T,E,N,R,D,B],H,L,j])=>{const K=lh(k),{align:V,behavior:$,offset:_}=K,I=E-1,q=sh(K,C,I);let Y=xo(q,C.offsetTree,H)+R;V==="end"?(Y+=L+hn(C.sizeTree,q)[1]-T+j,q===I&&(Y+=D)):V==="center"?Y+=(L+hn(C.sizeTree,q)[1]-T+j)/2:Y-=N,_&&(Y+=_);const P=M=>{S(),M?(B("retrying to scroll to",{location:k},Vt.DEBUG),Re(f,k)):(Re(v,!0),B("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),$==="smooth"){let M=!1;b=Qe(t,G=>{M=M||G}),x=fn(d,()=>{P(M)})}else x=fn(ee(t,YS(150)),P);return y=setTimeout(()=>{S()},1200),Re(l,!0),B("scrolling from index to",{behavior:$,index:q,top:Y},Vt.DEBUG),{behavior:$,top:Y}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},lt(En,Bt,Hn),{singleton:!0});function YS(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Oa(e,t){e==0?t():requestAnimationFrame(()=>{Oa(e-1,t)})}function Da(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const wo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return we(ee(i,Fe(l),Ae(([d,h])=>!!h),Tn(!1)),a),we(ee(i,Fe(l),Ae(([d,h])=>!!h),Tn(!1)),c),Qe(ee(yt(t,i),Fe(a,n,e,c),Ae(([[,d],h,{sizeTree:m},f,v])=>d&&(!st(m)||Ta(f))&&!h&&!v),Fe(l)),([,d])=>{fn(o,()=>{Re(c,!0)}),Oa(4,()=>{fn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(En,Bt,vo,Wn),{singleton:!0});function ch(e,t){return Math.abs(e-t)<1.01}const bo="up",yo="down",XS="none",JS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ZS=0,So=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=We(),c=We(),d=se(4),h=se(ZS),m=Mt(ee(Ea(ee(ke(o),nr(1),Tn(!0)),ee(ke(o),nr(1),Tn(!1),Kf(100))),ct()),!1),f=Mt(ee(Ea(ee(n,Tn(!0)),ee(n,Tn(!1),Kf(200))),ct()),!1);we(ee(yt(ke(o),ke(h)),pe(([b,S])=>b<=S),ct()),a),we(ee(a,jn(50)),c);const v=en(ee(yt(r,ke(s),ke(t),ke(e),ke(d)),kn((b,[{scrollHeight:S,scrollTop:k},C,T,E,N])=>{const R=k+C-S>-N,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let H,L;return k>b.state.scrollTop?(H="SCROLLED_DOWN",L=b.state.scrollTop-k):(H="SIZE_DECREASED",L=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:H,scrollTopDelta:L,state:D}}let B;return D.scrollHeight>b.state.scrollHeight?B="SIZE_INCREASED":C<b.state.viewportHeight?B="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?B="SCROLLING_UPWARDS":B="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:B,state:D}},JS),ct((b,S)=>b&&b.atBottom===S.atBottom))),g=Mt(ee(r,kn((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(ch(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(b=>b.changed),pe(b=>b.jump)),0);we(ee(v,pe(b=>b.atBottom)),i),we(ee(i,jn(50)),l);const x=se(yo);we(ee(r,pe(({scrollTop:b})=>b),ct(),kn((b,S)=>vt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?bo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),pe(b=>b.direction)),x),we(ee(r,jn(50),Tn(XS)),x);const y=se(0);return we(ee(m,Ae(b=>!b),Tn(0)),y),we(ee(o,jn(100),Fe(m),Ae(([b,S])=>!!S),kn(([b,S],[k])=>[S,k],[0,0]),pe(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},lt(Bt)),js="top",Ps="bottom",uh="none";function dh(e,t,n){return typeof e=="number"?n===bo&&t===js||n===yo&&t===Ps?e:0:n===bo?t===js?e.main:e.reverse:t===Ps?e.main:e.reverse}function fh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const La=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=se(0),a=se(0),l=se(0),c=Mt(ee(yt(ke(r),ke(o),ke(n),ke(s,go),ke(l),ke(i),ke(t),ke(e),ke(a)),pe(([d,h,m,[f,v],g,x,y,b,S])=>{const k=d-b,C=x+y,T=Math.max(m-k,0);let E=uh;const N=fh(S,js),R=fh(S,Ps);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+C-N&&(E=bo),v<d-T+h+R&&(E=yo),E!==uh?[Math.max(k-m-dh(g,js,E)-N,0),k-T-y+h+dh(g,Ps,E)+R]:null}),Ae(d=>d!=null),ct(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},lt(Bt),{singleton:!0});function QS(e,t,n){if(As(t)){const r=oh(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 $a={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function _s(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:ph(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:ph(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function hh(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=Da(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return _s(c,[],a,o,n,r)}function ph(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 sr=Ge(([{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=se([]),x=se(0),y=We();we(s.topItemsIndexes,g);const b=Mt(ee(yt(f,v,ke(l,go),ke(o),ke(r),ke(c),d,ke(g),ke(t),ke(n),e),Ae(([T,E,,N,,,,,,,R])=>{const D=R&&R.length!==N;return T&&!E&&!D}),pe(([,,[T,E],N,R,D,B,H,L,j,K])=>{const V=R,{offsetTree:$,sizeTree:_}=V,I=vt(x);if(N===0)return{...$a,totalCount:N};if(T===0&&E===0)return I===0?{...$a,totalCount:N}:hh(I,D,R,L,j,K||[]);if(st(_))return I>0?null:_s(QS(Da(D,N),V,K),[],N,j,V,L);const q=[];if(H.length>0){const J=H[0],oe=H[H.length-1];let W=0;for(const O of Es(_,J,oe)){const X=O.value,Z=Math.max(O.start,J),ue=Math.min(O.end,oe);for(let F=Z;F<=ue;F++)q.push({data:K==null?void 0:K[F],index:F,offset:W,size:X}),W+=X}}if(!B)return _s([],q,N,j,V,L);const Y=H.length>0?H[H.length-1]+1:0,P=zS($,T,E,Y);if(P.length===0)return null;const M=N-1,G=ks([],J=>{for(const oe of P){const W=oe.value;let O=W.offset,X=oe.start;const Z=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+j)/(Z+j));const F=X-oe.start;O+=F*Z+F*j}X<Y&&(O+=(Y-X)*Z,X=Y);const ue=Math.min(oe.end,M);for(let F=X;F<=ue&&!(O>=E);F++)J.push({data:K==null?void 0:K[F],index:F,offset:O,size:Z}),O+=Z+j}});return _s(G,q,N,j,V,L)}),Ae(T=>T!==null),ct()),$a);we(ee(e,Ae(Ta),pe(T=>T==null?void 0:T.length)),o),we(ee(b,pe(T=>T.topListHeight)),h),we(h,a),we(ee(b,pe(T=>[T.top,T.bottom])),i),we(ee(b,pe(T=>T.items)),y);const S=en(ee(b,Ae(({items:T})=>T.length>0),Fe(o,e),Ae(([{items:T},E])=>T[T.length-1].originalIndex===E-1),pe(([,T,E])=>[T-1,E]),ct(go),pe(([T])=>T))),k=en(ee(b,jn(200),Ae(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),pe(({items:T})=>T[0].index),ct())),C=en(ee(b,Ae(({items:T})=>T.length>0),pe(({items:T})=>{let E=0,N=T.length-1;for(;T[E].type==="group"&&E<N;)E++;for(;T[N].type==="group"&&N>E;)N--;return{endIndex:T[N].index,startIndex:T[E].index}}),ct(nh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},lt(En,ah,La,wo,vo,So,Wn,_a),{singleton:!0}),mh=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Mt(ee(yt(n,e,r,t,o),pe(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return we(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Bt,sr),{singleton:!0}),eC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Mt(ee(yt(n,e,t),Ae(([o])=>o),pe(([,o,s])=>Math.max(0,o-s)),jn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Bt,mh),{singleton:!0}),gh=Ge(()=>({context:se(null)})),tC=({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,xh=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return we(ee(d,Fe(t,l,n,s,o,r,a),Fe(e),pe(([[h,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=tC,done:E,...N}=h,R=sh(h,m,v-1),D=xo(R,m.offsetTree,S)+g+x,B=D+hn(m.sizeTree,R)[1],H=b+x,L=b+f-y,j=T({itemBottom:B,itemTop:D,locationParams:{align:k,behavior:C,...N},viewportBottom:L,viewportTop:H});return j?E&&fn(ee(i,Ae(K=>!K),nr(vt(i)?1:2)),E):E&&E(),j}),Ae(h=>h!==null)),c),{scrollIntoView:d}},lt(En,Bt,vo,sr,Hn),{singleton:!0});function vh(e){return e?e==="smooth"?"smooth":"auto":!1}const nC=(e,t)=>typeof e=="function"?vh(e(t)):t&&vh(e),rC=Ge(([{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=se(!1),g=We();let x=null;function y(C){Re(i,{align:"end",behavior:C,index:"LAST"})}Qe(ee(yt(ee(ke(t),nr(1)),l),Fe(ke(v),s,a,h),pe(([[C,T],E,N,R,D])=>{let B=T&&R,H="auto";return B&&(H=nC(E,N||D),B=B&&!!H),{followOutputBehavior:H,shouldFollow:B,totalCount:C}}),Ae(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=fn(e,()=>{vt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function b(C){const T=fn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(vt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Qe(ee(yt(ke(v),t,c),Ae(([C,,T])=>C&&T),kn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ae(({refreshed:C})=>C),Fe(v,t)),([,C])=>{vt(a)&&b(C!==!1)}),Qe(g,()=>{b(vt(v)!==!1)}),Qe(yt(ke(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=We();return we(Ea(ee(ke(r),pe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(ke(t))),k),Qe(ee(yt(ee(k,nr(1)),l),Fe(ke(S),a,h,m),pe(([[C,T],E,N,R,D])=>T&&N&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:R}))),Ae(C=>!!C),jn(0)),C=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("scrolling into view",{}),Re(f,C)}):x=fn(e,()=>{vt(d)("scrolling into view",{}),Re(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},lt(En,So,vo,wo,Wn,Hn,Bt,gh,xh)),oC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(we(ee(a,Fe(s),Ae(([,l])=>l!==0),Fe(o,r,t,n,e),pe(([[,l],c,d,h,m,f=[]])=>hh(l,c,d,h,m,f))),i),{}),lt(En,wo,sr,Wn),{singleton:!0}),sC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Qe(ee(e,Fe(r),Ae(([,o])=>o!==0),pe(([,o])=>({top:o}))),o=>{fn(ee(n,nr(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},lt(Wn,Bt,sr),{singleton:!0}),wh=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=We(),r=se(!1);return we(ee(e,Fe(r,t,n),Ae(([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}),ct()),t),Qe(ee(yt(t,e,n),Fe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(So),{singleton:!0}),Fa=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=se(!1),i=se(void 0);return we(ee(yt(n,r),pe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),we(ee(t,Fe(r),pe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Bt)),iC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=se(void 0),h=se(null),m=se(null);return we(a,h),we(l,m),Qe(ee(c,Fe(t,r,i,h,m,n)),([f,v,g,x,y,b,S])=>{const k=US(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),we(ee(d,Ae(Ta),pe(aC)),o),we(ee(s,Fe(d),Ae(([,f])=>f!==void 0),ct(),pe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},lt(En,Bt,wo,Wn,Fa));function aC(e){return{align:"start",index:0,offset:e.scrollTop}}const lC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return we(ee(t,Ae(n=>n>=0),pe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(sr));function bh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const cC=bh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),uC=Ge(([{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,Fe(i),kn(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},N])=>{const R=k+T;let D=0;return b===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=R-S,D!==0&&(D+=N))),[D,C,E,R]},[0,[],0,0]),Ae(([y])=>y!==0),Fe(r,a,n,o,f,v),Ae(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===bo),pe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(Re(t,{behavior:"auto",top:-y}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-y}))}return Qe(ee(g,Fe(e,s)),([y,b,S])=>{S&&cC()?Re(e,b-y):x(-y)}),Qe(ee(yt(Mt(s,!1),e,v),Ae(([y,b,S])=>!y&&!S&&b!==0),pe(([y,b])=>b),jn(1)),x),we(ee(h,pe(y=>({top:-y}))),t),Qe(ee(c,Fe(m,d),pe(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(b.length===0)return T(y);{let E=0;const N=mo(k,0);let R=0,D=0;for(;R<y;){R++,E+=N;let B=b.length===D+1?1/0:b[D+1]-b[D]-1;R+B>y&&(E-=N,B=y-R+1),R+=B,E+=T(B),D++}return E}})),y=>{Re(e,y),requestAnimationFrame(()=>{Re(t,{top:y}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},lt(Bt,So,sr,En,Hn,_a)),dC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),lt(La,oC,Wn,wh,mh,sC,eC,Fa,xh,Hn,gh)),yh=Ge(([{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:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:N},R])=>(we(k.rangeChanged,R.scrollSeekRangeChanged),we(ee(R.windowViewportRect,pe(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...R,...g,sizes:l,...x}),lt(En,wo,Bt,iC,rC,sr,vo,uC,lC,ah,dC));function fC(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"?w.useLayoutEffect:w.useEffect;function Sh(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=w.createContext({});function l(x,y){x.propsReady&&Re(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];Re(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];Re(S,y[b])}x.propsReady&&Re(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const k=x[t.methods[b]];Re(k,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=NS(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>ks(jS(e),E=>{l(E,S)})),[C]=w.useState(Vf(d,k));Ms(()=>{for(const E of i)E in S&&Qe(C[E],S[E]);return()=>{Object.values(C).map(ka)}},[S,C,k]),Ms(()=>{l(k,S)}),w.useImperativeHandle(y,Uf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...fC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Re(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(S=>Qe(y,S),[y]);return w.useSyncExternalStore(b,()=>vt(y),()=>vt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Vf(vt,y));return Ms(()=>Qe(y,k=>{k!==b&&S(Uf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ms(()=>Qe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Ch=w.createContext(void 0),Th=w.createContext(void 0),kh=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ba(e){return"self"in e}function hC(e){return"body"in e}function Eh(e,t,n,r=Pr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(hC(x)||Ba(x)){const b=Ba(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.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():_o.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]);w.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;Ba(f)?(x=Math.max(Un(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=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),ch(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 za="-webkit-sticky",Ih="sticky",Ha=bh(()=>{if(typeof document>"u")return Ih;const e=document.createElement("div");return e.style.position=za,e.style.position===za?za:Ih});function Ua(e){return e}const pC=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ua),o=se("div"),s=se(Pr),i=(a,l=null)=>Mt(ee(n,pe(c=>c[a]),ct()),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")}}),mC=Ge(([e,t])=>({...e,...t}),lt(yh,pC)),gC=({height:e})=>u.jsx("div",{style:{height:e}}),xC={overflowAnchor:"none",position:Ha(),zIndex:1},Nh={overflowAnchor:"none"},vC={...Nh,display:"inline-block",height:"100%"},Ah=w.memo(function({showTopList:e=!1}){const t=Pe("listState"),n=rn("sizeRanges"),r=Pe("useWindowScroll"),o=Pe("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Pe("itemContent"),c=Pe("context"),d=Pe("groupContent"),h=Pe("trackItemSizes"),m=Pe("itemSize"),f=Pe("log"),v=rn("gap"),g=Pe("horizontalDirection"),{callbackRef:x}=MS(n,m,h,e?Pr:a,f,v,o,g,Pe("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Wa("deviation",j=>{y!==j&&b(j)});const S=Pe("EmptyPlaceholder"),k=Pe("ScrollSeekPlaceholder")||gC,C=Pe("ListComponent"),T=Pe("ItemComponent"),E=Pe("GroupComponent"),N=Pe("computeItemKey"),R=Pe("isSeeking"),D=Pe("groupIndices").length>0,B=Pe("alignToBottom"),H=Pe("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:B?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:B?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...H?{}:{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:L,children:(e?t.topItems:t.items).map(j=>{const K=j.originalIndex,V=N(K+t.firstItemIndex,j.data,c);return R?w.createElement(k,{...Rt(k,c),height:j.size,index:j.index,key:V,type:j.type||"item",...j.type==="group"?{}:{groupIndex:j.groupIndex}}):j.type==="group"?w.createElement(E,{...Rt(E,c),"data-index":K,"data-item-index":j.index,"data-known-size":j.size,key:V,style:xC},d(j.index,c)):w.createElement(T,{...Rt(T,c),...SC(T,j.data),"data-index":K,"data-item-group-index":j.groupIndex,"data-item-index":j.index,"data-known-size":j.size,key:V,style:g?vC:Nh},D?l(j.index,j.groupIndex,j.data,c):l(j.index,j.data,c))})})}),wC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},bC={outline:"none",overflowX:"auto",position:"relative"},Rs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),yC={position:Ha(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function SC(e,t){return{item:typeof e=="string"?void 0:t}}const CC=w.memo(function(){const e=Pe("HeaderComponent"),t=rn("headerHeight"),n=Pe("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),TC=w.memo(function(){const e=Pe("FooterComponent"),t=rn("footerHeight"),n=Pe("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function jh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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}=Eh(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?bC:wC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Ph({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Eh(a,c,l,v,m);return kh(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.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 kC=({children:e})=>{const t=w.useContext(Ch),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Pe("alignToBottom"),s=Pe("horizontalDirection"),i=w.useMemo(()=>Wf(n,l=>Un(l,s?"width":"height")),[n,s]),a=rr(i,!0,Pe("skipAnimationFrameInResizeObserver"));return w.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})},EC=({children:e})=>{const t=w.useContext(Ch),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Pe("customScrollParent"),s=Yf(n,o,Pe("skipAnimationFrameInResizeObserver")),i=Pe("alignToBottom");return w.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})},IC=({children:e})=>{const t=Pe("TopItemListComponent")||"div",n=Pe("headerHeight"),r={...yC,marginTop:`${n}px`},o=Pe("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},NC=w.memo(function(e){const t=Pe("useWindowScroll"),n=Pe("topItemsIndexes").length>0,r=Pe("customScrollParent"),o=Pe("context");return u.jsxs(r||t?PC:jC,{...e,context:o,children:[n&&u.jsx(IC,{children:u.jsx(Ah,{showTopList:!0})}),u.jsxs(r||t?EC:kC,{children:[u.jsx(CC,{}),u.jsx(Ah,{}),u.jsx(TC,{})]})]})}),{Component:AC,useEmitter:Wa,useEmitterValue:Pe,usePublisher:rn}=Sh(mC,{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"}},NC),jC=jh({useEmitter:Wa,useEmitterValue:Pe,usePublisher:rn}),PC=Ph({useEmitter:Wa,useEmitterValue:Pe,usePublisher:rn}),_C=AC;lt(yh,Ge(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Ua),a=se(Pr),l=(c,d=null)=>Mt(ee(s,pe(h=>h[c]),ct()),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")}})),Ha();const _h={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},MC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Mh,floor:Os,max:Co,min:Va,round:Rh}=Math;function Oh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function RC(e){return{...MC,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function OC(e,t){return e&&e.column===t.column&&e.row===t.row}const DC=Ge(([{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:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),N=se(_h),R=se({height:0,width:0}),D=se({height:0,width:0}),B=We(),H=We(),L=se(0),j=se(null),K=se({column:0,row:0}),V=We(),$=We(),_=se(!1),I=se(0),q=se(!0),Y=se(!1),P=se(!1);Qe(ee(v,Fe(I),Ae(([O,X])=>!!X)),()=>{Re(q,!1)}),Qe(ee(yt(v,q,D,R,I,Y),Ae(([O,X,Z,ue,,F])=>O&&!X&&Z.height!==0&&ue.height!==0&&!F)),([,,,,O])=>{Re(Y,!0),Oa(1,()=>{Re(B,O)}),fn(ee(c),()=>{Re(t,[0,0]),Re(q,!0)})}),we(ee($,Ae(O=>O!=null&&O.scrollTop>0),Tn(0)),E),Qe(ee(v,Fe($),Ae(([,O])=>O!=null)),([,O])=>{O&&(Re(R,O.viewport),Re(D,O.item),Re(K,O.gap),O.scrollTop>0&&(Re(_,!0),fn(ee(c,nr(1)),X=>{Re(_,!1)}),Re(l,{top:O.scrollTop})))}),we(ee(R,pe(({height:O})=>O)),h),we(ee(yt(ke(R,Ds),ke(D,Ds),ke(K,(O,X)=>O&&O.column===X.column&&O.row===X.row),ke(c)),pe(([O,X,Z,ue])=>({gap:Z,item:X,scrollTop:ue,viewport:O}))),V),we(ee(yt(ke(T),r,ke(K,OC),ke(D,Ds),ke(R,Ds),ke(j),ke(E),ke(_),ke(q),ke(I)),Ae(([,,,,,,,O])=>!O),pe(([O,[X,Z],ue,F,ne,de,ce,,ge,Ce])=>{const{column:_e,row:De}=ue,{height:ze,width:rt}=F,{width:Ct}=ne;if(ce===0&&(O===0||Ct===0))return _h;if(rt===0){const At=Da(Ce,O),wt=At+Math.max(ce-1,0);return RC(Oh(At,wt,de))}const Ve=Dh(Ct,rt,_e);let He,Ye;ge?X===0&&Z===0&&ce>0?(He=0,Ye=ce-1):(He=Ve*Os((X+De)/(ze+De)),Ye=Ve*Mh((Z+De)/(ze+De))-1,Ye=Va(O-1,Co(Ye,Ve-1)),He=Va(Ye,Co(0,He))):(He=0,Ye=-1);const Le=Oh(He,Ye,de),{bottom:Ue,top:mt}=Lh(ne,ue,F,Le),Dt=Mh(O/Ve),at=Dt*ze+(Dt-1)*De-Ue;return{bottom:Ue,itemHeight:ze,items:Le,itemWidth:rt,offsetBottom:at,offsetTop:mt,top:mt}})),N),we(ee(j,Ae(O=>O!==null),pe(O=>O.length)),T),we(ee(yt(R,D,N,K),Ae(([O,X,{items:Z}])=>Z.length>0&&X.height!==0&&O.height!==0),pe(([O,X,{items:Z},ue])=>{const{bottom:F,top:ne}=Lh(O,ue,X,Z);return[ne,F]}),ct(go)),t);const M=se(!1);we(ee(c,Fe(M),pe(([O,X])=>X||O!==0)),M);const G=en(ee(yt(N,T),Ae(([{items:O}])=>O.length>0),Fe(M),Ae(([[O,X],Z])=>{const ue=O.items[O.items.length-1].index===X-1;return(Z||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===X)&&ue}),pe(([[,O]])=>O-1),ct())),J=en(ee(ke(N),Ae(({items:O})=>O.length>0&&O[0].index===0),Tn(0),ct())),oe=en(ee(ke(N),Fe(_),Ae(([{items:O},X])=>O.length>0&&!X),pe(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),ct(nh),jn(0)));we(oe,f.scrollSeekRangeChanged),we(ee(B,Fe(R,D,T,K),pe(([O,X,Z,ue,F])=>{const ne=lh(O),{align:de,behavior:ce,offset:ge}=ne;let Ce=ne.index;Ce==="LAST"&&(Ce=ue-1),Ce=Co(0,Ce,Va(ue-1,Ce));let _e=Ka(X,F,Z,Ce);return de==="end"?_e=Rh(_e-X.height+Z.height):de==="center"&&(_e=Rh(_e-X.height/2+Z.height/2)),ge&&(_e+=ge),{behavior:ce,top:_e}})),l);const W=Mt(ee(N,pe(O=>O.offsetBottom+O.bottom)),0);return we(ee(k,pe(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:x,data:j,deviation:L,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:$,scrollBy:i,scrollContainerState:a,scrollHeight:H,scrollTo:l,scrollToIndex:B,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:W,...m,endReached:G,propsReady:g,rangeChanged:oe,startReached:J,stateChanged:V,stateRestoreInProgress:_,...C}},lt(La,Bt,So,wh,Wn,Fa,Hn));function Dh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function Lh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ka(e,t,n,r[0].index);return{bottom:Ka(e,t,n,r[r.length-1].index)+o,top:s}}function Ka(e,t,n,r){const o=Dh(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 LC=Ge(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ua),i=se("div"),a=se(Pr),l=(h,m=null)=>Mt(ee(t,pe(f=>f[h]),ct()),m),c=se(!1),d=se(!1);return we(ke(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")}}),$C=Ge(([e,t])=>({...e,...t}),lt(DC,LC)),FC=w.memo(function(){const e=dt("gridState"),t=dt("listClassName"),n=dt("itemClassName"),r=dt("itemContent"),o=dt("computeItemKey"),s=dt("isSeeking"),i=on("scrollHeight"),a=dt("ItemComponent"),l=dt("ListComponent"),c=dt("ScrollSeekPlaceholder"),d=dt("context"),h=on("itemDimensions"),m=on("gap"),f=dt("log"),v=dt("stateRestoreInProgress"),g=on("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Fh("column-gap",getComputedStyle(y).columnGap,f),row:Fh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return kh(()=>{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 b=o(y.index,y.data,d);return s?u.jsx(c,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),BC=w.memo(function(){const e=dt("HeaderComponent"),t=on("headerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),zC=w.memo(function(){const e=dt("FooterComponent"),t=on("footerHeight"),n=dt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=dt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),HC=({children:e})=>{const t=w.useContext(Th),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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})},UC=({children:e})=>{const t=w.useContext(Th),n=on("windowViewportRect"),r=on("itemDimensions"),o=dt("customScrollParent"),s=Yf(n,o,!1);return w.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})},WC=w.memo(function({...e}){const t=dt("useWindowScroll"),n=dt("customScrollParent"),r=n||t?KC:VC,o=n||t?UC:HC,s=dt("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(BC,{}),u.jsx(FC,{}),u.jsx(zC,{})]})})}),{useEmitter:$h,useEmitterValue:dt,usePublisher:on}=Sh($C,{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"}},WC),VC=jh({useEmitter:$h,useEmitterValue:dt,usePublisher:on}),KC=Ph({useEmitter:$h,useEmitterValue:dt,usePublisher:on});function Fh(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 Bh({className:e,variant:t,...n}){return u.jsx("div",{className:te(qC({variant:t}),e),...n})}var Ls="Dialog",[zh,xN]=cn(Ls),[GC,pn]=zh(Ls),Hh=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]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(GC,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Hh.displayName=Ls;var Uh="DialogTrigger",Wh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Uh,n),s=$e(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ya(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Wh.displayName=Uh;var qa="DialogPortal",[YC,Vh]=zh(qa,{forceMount:void 0}),Kh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(qa,t);return u.jsx(YC,{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})}))})};Kh.displayName=qa;var $s="DialogOverlay",qh=p.forwardRef((e,t)=>{const n=Vh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(JC,{...o,ref:t})}):null});qh.displayName=$s;var XC=Yt.createSlot("DialogOverlay.RemoveScroll"),JC=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn($s,n);return u.jsx(gs,{as:XC,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Ya(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Gh=p.forwardRef((e,t)=>{const n=Vh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(ZC,{...o,ref:t}):u.jsx(QC,{...o,ref:t})})});Gh.displayName=ir;var ZC=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(null),o=$e(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return ua(s)},[]),u.jsx(Yh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),QC=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Yh,{...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()}})}),Yh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(ir,n),l=p.useRef(null),c=$e(t,l);return zi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(br,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ya(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(eT,{titleId:a.titleId}),u.jsx(nT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ga="DialogTitle",Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Ga,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Xh.displayName=Ga;var Jh="DialogDescription",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Jh,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Zh.displayName=Jh;var Qh="DialogClose",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Qh,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});ep.displayName=Qh;function Ya(e){return e?"open":"closed"}var tp="DialogTitleWarning",[vN,np]=gw(tp,{contentName:ir,titleName:Ga,docsSlug:"dialog"}),eT=({titleId:e})=>{const t=np(tp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},a0=0,Ar=[];function l0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(a0++)[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=Ay([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),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[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 N=Hd(E,T);if(!N)return!0;if(N?C=E:(C=E==="v"?"h":"v",N=Hd(E,T)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return o0(R,x,g,R==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),b=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&s0(C.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){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,b){var S={name:g,delta:x,target:y,should:b,shadowParent:c0(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 Ar.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:i0(o)}):null,f?p.createElement(Jy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function c0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const u0=$y($d,l0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Cn({},e,{ref:t,sideCar:u0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],d0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],f0=[...d0,...qd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},p0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,m0,g0]=Yo(ao),[er,Gd]=cn(ao,[g0,kr,Ad]),xs=kr(),Yd=Ad(),[x0,tr]=er(ao),[v0,co]=er(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=xt(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(x0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(v0,{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",[b0,Jd]=er(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(va,t);return u.jsx(b0,{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",[y0,wa]=er(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(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(S0,{...o,ref:t}):u.jsx(C0,{...o,ref:t})})})})}),S0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(ba,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(ba,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),T0=Yt.createSlot("MenuContent.ScrollLock"),ba=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=tr(nn,n),y=co(nn,n),b=xs(n),S=Yd(n),k=m0(n),[C,T]=p.useState(null),E=p.useRef(null),N=$e(t,E,x.onContentChange),R=p.useRef(0),L=p.useRef(""),z=p.useRef(0),V=p.useRef(null),U=p.useRef("right"),j=p.useRef(0),W=v?gs:p.Fragment,$=v?{as:T0,allowPinchZoom:!0}:void 0,O=I=>{var K,D;const q=L.current+I,Y=k().filter(X=>!X.disabled),_=document.activeElement,M=(K=Y.find(X=>X.ref.current===_))==null?void 0:K.textValue,G=Y.map(X=>X.textValue),J=D0(G,q,M),oe=(D=Y.find(X=>X.textValue===J))==null?void 0:D.ref.current;(function X(Z){L.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(q),oe&&setTimeout(()=>oe.focus())};p.useEffect(()=>()=>window.clearTimeout(R.current),[]),Hi();const P=p.useCallback(I=>{var Y,_;return U.current===((Y=V.current)==null?void 0:Y.side)&&$0(I,(_=V.current)==null?void 0:_.area)},[]);return u.jsx(y0,{scope:n,searchRef:L,onItemEnter:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:p.useCallback(I=>{var q;P(I)||((q=E.current)==null||q.focus(),T(null))},[P]),onTriggerLeave:p.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:z,onPointerGraceIntentChange:p.useCallback(I=>{V.current=I},[]),children:u.jsx(W,{...$,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var q;I.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ty,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ae(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,...b,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const Y=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,M=I.key.length===1;Y&&(I.key==="Tab"&&I.preventDefault(),!_&&M&&O(I.key));const G=E.current;if(I.target!==G||!f0.includes(I.key))return;I.preventDefault();const oe=k().filter(K=>!K.disabled).map(K=>K.ref.current);qd.includes(I.key)&&oe.reverse(),R0(oe)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),L.current="")}),onPointerMove:ae(e.onPointerMove,fo(I=>{const q=I.target,Y=j.current!==I.clientX;if(I.currentTarget.contains(q)&&Y){const _=I.clientX>j.current?"right":"left";U.current=_,j.current=I.clientX}}))})})})})})})});Qd.displayName=nn;var k0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});ya.displayName=k0;var E0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});ef.displayName=E0;var vs="MenuItem",tf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=wa(vs,e.__scopeMenu),l=$e(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:ae(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ae(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ga.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(vs,n),a=Yd(n),l=p.useRef(null),c=$e(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(ky,{asChild:!0,...a,focusable:!r,children:u.jsx(ve.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>h(!0)),onBlur:ae(e.onBlur,()=>h(!1))})})})}),I0="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(ws,{role:"menuitemcheckbox","aria-checked":bs(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(bs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=I0;var of="MenuRadioGroup",[N0,A0]=er(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=xt(r);return u.jsx(N0,{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=A0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,j0]=er(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=j0(Sa,n);return u.jsx(Wt,{present:r||bs(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var _0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=_0;var P0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=P0;var M0="MenuSub",[vN,hf]=er(M0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=tr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=wa(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:On(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:ae(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:ae(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,b=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:b,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:ae(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||h0[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=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=$e(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(ba,{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:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=p0[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 bs(e){return e==="indeterminate"}function Ca(e){return bs(e)?"indeterminate":e?"checked":"unchecked"}function R0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function D0(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=O0(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 L0(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 $0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return L0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F0=Xd,B0=xa,z0=Zd,H0=Qd,U0=ya,W0=ef,V0=ws,K0=rf,q0=sf,G0=lf,Y0=uf,X0=df,J0=ff,Z0=pf,Q0=gf,ys="DropdownMenu",[eS,wN]=cn(ys,[Gd]),Ft=Gd(),[tS,vf]=eS(ys),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(tS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(F0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=ys;var bf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(bf,n),i=Ft(n);return u.jsx(B0,{asChild:!0,...i,children:u.jsx(ve.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:On(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(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=bf;var nS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(z0,{...r,...n})};Sf.displayName=nS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=Ft(n),i=p.useRef(!1);return u.jsx(H0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(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 rS="DropdownMenuGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(U0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(W0,{...o,...r,ref:t})});kf.displayName=sS;var iS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuRadioGroup",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(q0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(G0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var hS="DropdownMenuArrow",pS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=hS;var mS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Z0,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Q0,{...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=gS;var xS=wf,vS=yf,wS=Sf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf;const Ss=xS,Cs=vS,bS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{ref:o,className:te("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(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));bS.displayName=Bf.displayName;const yS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{ref:n,className:te("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}));yS.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:te("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 Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:te("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}));Bn.displayName=Of.displayName;const SS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{ref:o,className:te("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(le.Check,{className:"h-4 w-4"})})}),t]}));SS.displayName=Df.displayName;const CS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{ref:r,className:te("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(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));CS.displayName=Lf.displayName;const TS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Rf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));TS.displayName=Rf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));kS.displayName=Ff.displayName;const Ta=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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 ES=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=ES,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,b]=w.useState(e),S=(x?i:y)??"",[k,C]=w.useTransition(),T=w.useRef(null),E=w.useRef(0),N=w.useRef(null),R=w.useRef("");w.useEffect(()=>{x||(b(e??""),N.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,z]=w.useState(null),V=w.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),U=w.useMemo(()=>v??V,[v,V]),j=w.useCallback(M=>{const G=U(M);return z(G),g==null||g(G),R.current=M,G},[U,g]),W=w.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);w.useEffect(()=>{W()},[W,S]),w.useEffect(()=>{if(!L)return;const M=(S??"").trim();R.current!==M&&j(M)},[S,L,j]);const $=w.useCallback((M,{fromUser:G})=>{x||b(M),G&&(a==null||a(M))},[x,a]),O=w.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!f||j(G))return;const J=++E.current;N.current={id:J,shouldClear:!0},C(()=>{var oe,K,D;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Z,ue;((Z=N.current)==null?void 0:Z.id)===J&&N.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ue=N.current)==null?void 0:ue.id)===J&&(N.current=null)}).catch(()=>{var Z;((Z=N.current)==null?void 0:Z.id)===J&&(N.current=null)}):(((oe=N.current)==null?void 0:oe.id)===J&&N.current.shouldClear&&(x||(b(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((K=N.current)==null?void 0:K.id)===J&&(N.current=null))}catch{((D=N.current)==null?void 0:D.id)===J&&(N.current=null)}})},[S,l,f,x,a,j]),P=w.useCallback(M=>{const G=M.target.value;$(G,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&j(G.trim())},[$,j,L]),I=w.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),O()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[O,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:M=>void O(M),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(tt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(tt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(le.Send,{size:16})})})]})})}const IS=w.memo(Hf),Ts=0,zn=1,jr=2,Uf=4;function Wf(e){return()=>e}function NS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function AS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function jS(...e){return()=>{e.map(NS)}}function _r(){}function ks(e,t){return t(e),e}function _S(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(zn,t)}function Re(e,t){e(Ts,t)}function Ea(e){e(jr)}function vt(e){return e(Uf)}function we(e,t){return Qe(e,AS(t,Ts))}function fn(e,t){const n=e(zn,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 ct(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function pe(e){return t=>Vf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=PS(...t);return(r,o)=>{switch(r){case jr:Ea(e);return;case zn:return Qe(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Fe(...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);Qe(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 PS(...e){return t=>e.reduceRight(_S,t)}function MS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),_r);case jr:r(),n=null;return}}}function se(e){let t=e;const n=We();return(r,o)=>{switch(r){case Ts:t=o;break;case zn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(se(t),n=>we(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case jr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(We(),t=>we(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:RS(),singleton:n}}const RS=()=>Symbol();function OS(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);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case jr:{Ea(t);return}case zn:return r===o&&i(n),Qe(t,i)}}}function ke(e,t=Gf){return ee(e,ct(t))}function Ia(...e){return function(t,n){switch(t){case jr:return;case zn:return jS(...e.map(r=>Qe(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 DS={0:"debug",3:"error",1:"log",2:"warn"},LS=()=>typeof globalThis>"u"?window:globalThis,Hn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=LS().VIRTUOSO_LOG_LEVEL)!=null?o:vt(e);r>=s&&console[DS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Na(e,t,n).callbackRef}function Na(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 $S(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=FS(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 FS(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=w.useRef(null),o=w.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=w.useCallback(()=>{o(i.current)},[o,i]);return w.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 Bt=Ge(()=>{const e=We(),t=We(),n=se(0),r=We(),o=se(0),s=We(),i=We(),a=se(0),l=se(0),c=se(0),d=se(0),h=We(),m=We(),f=se(!1),v=se(!1),g=se(!1);return we(ee(e,pe(({scrollTop:x})=>x)),t),we(ee(e,pe(({scrollHeight:x})=>x)),i),we(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 st(e){return e===po}function mo(e,t){if(!st(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(st(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 st(e)?eh(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?th(St(e,{l:tn(e.l,t,n)})):th(St(e,{r:tn(e.r,t,n)}))}function Pr(){return po}function Es(e,t,n){if(st(e))return[];const r=hn(e,t)[0];return BS(ja(e,r,n))}function Aa(e,t){if(st(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=Qf(r);return Is(St(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(St(e,{l:Aa(r,t)})):Is(St(e,{r:Aa(o,t)}))}function or(e){return st(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ja(e,t,n){if(st(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(St(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(St(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(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 st(e.r)?e.l:Is(St(e,{r:Zf(e.r)}))}function _a(e){return st(e)||e.lvl>e.r.lvl}function Qf(e){return st(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!st(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function BS(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=Ge(()=>({recalcInProgress:se(!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 zS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!st(e.groupOffsetTree)}function Ra({index:e},t){return t===e?0:t<e?-1:1}function HS(){return{groupIndices:[],groupOffsetTree:Pr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Pr()}}function US(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(XS(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 WS(e){return typeof e.groupIndex<"u"}function VS({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(WS(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 KS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ra).offset)),Jf(zS(e,t,n,VS),YS)}function qS(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&&st(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]=US(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)),Pr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function GS(e){return or(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=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 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 YS(e){return{index:e.index,value:e}}function XS(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 JS={offsetHeight:"height",offsetWidth:"width"},En=Ge(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Mt(r,0),s=We(),i=We(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,JS[T])),m=se(void 0),f=se(0),v=HS(),g=Mt(ee(n,Fe(l,e,f),kn(qS,v),ct()),v),x=Mt(ee(l,ct(),kn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),pe(({prev:C})=>C)),[]);we(ee(l,Ae(C=>C.length>0),Fe(g,f),pe(([C,T,E])=>{const N=C.reduce((R,L,z)=>tn(R,L,xo(L,T.offsetTree,E)||z),Pr());return{...T,groupIndices:C,groupOffsetTree:N}})),g),we(ee(r,Fe(g),Ae(([C,{lastIndex:T}])=>C<T),pe(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),we(c,d);const y=Mt(ee(c,pe(C=>C===void 0)),!0);we(ee(d,Ae(C=>C!==void 0&&st(vt(g).sizeTree)),pe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=en(ee(n,Fe(g),kn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),pe(C=>C.changed)));Qe(ee(a,kn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),pe(C=>C.diff)),C=>{const{groupIndices:T}=vt(g);if(C>0)Re(t,!0),Re(s,C+ah(C,T));else if(C<0){const E=vt(x);E.length>0&&(C-=ah(-C,E)),Re(i,C)}}),Qe(ee(a,Fe(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);we(ee(s,Fe(g),pe(([C,T])=>{const E=T.groupIndices.length>0,N=[],R=T.lastSize;if(E){const L=mo(T.sizeTree,0);let z=0,V=0;for(;z<C;){const j=T.groupIndices[V],W=T.groupIndices.length===V+1?1/0:T.groupIndices[V+1]-j-1;N.push({endIndex:j,size:L,startIndex:j}),N.push({endIndex:j+1+W-1,size:R,startIndex:j+1}),V++,z+=W+1}const U=or(T.sizeTree);return z!==C&&U.shift(),U.reduce((j,{k:W,v:$})=>{let O=j.ranges;return j.prevSize!==0&&(O=[...j.ranges,{endIndex:W+C-1,size:j.prevSize,startIndex:j.prevIndex}]),{prevIndex:W+C,prevSize:$,ranges:O}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return or(T.sizeTree).reduce((L,{k:z,v:V})=>({prevIndex:z+C,prevSize:V,ranges:[...L.ranges,{endIndex:z+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=en(ee(i,Fe(g,f),pe(([C,{offsetTree:T},E])=>{const N=-C;return xo(N,T,E)})));return we(ee(i,Fe(g,f),pe(([C,T,E])=>{if(T.groupIndices.length>0){if(st(T.sizeTree))return T;let N=Pr();const R=vt(x);let L=0,z=0,V=0;for(;L<-C;){V=R[z];const U=R[z+1]-V-1;z++,L+=U+1}if(N=or(T.sizeTree).reduce((U,{k:j,v:W})=>tn(U,Math.max(0,j+C),W),N),L!==-C){const U=mo(T.sizeTree,V);N=tn(N,0,U);const j=hn(T.sizeTree,-C+1)[1];N=tn(N,1,j)}return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,E)}}else{const N=or(T.sizeTree).reduce((R,{k:L,v:z})=>tn(R,Math.max(0,L+C),z),Pr());return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Hn,Ma),{singleton:!0});function ZS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=en(ee(s,pe(ZS)));return we(ee(a,pe(l=>l.totalCount)),n),we(ee(a,pe(l=>l.groupIndices)),e),we(ee(yt(o,t,r),Ae(([l,c])=>As(c)),pe(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),pe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(En,Bt)),Wn=Ge(([{log:e}])=>{const t=se(!1),n=en(ee(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&vt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},lt(Hn),{singleton:!0}),QS=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||!QS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=Ge(([{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=se(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Re(l,!1)}return we(ee(f,Fe(n,h,r,g,a,i,m),Fe(e,s,o),pe(([[k,C,T,E,N,R,L,z],V,U,j])=>{const W=ch(k),{align:$,behavior:O,offset:P}=W,I=E-1,q=ih(W,C,I);let Y=xo(q,C.offsetTree,V)+R;$==="end"?(Y+=U+hn(C.sizeTree,q)[1]-T+j,q===I&&(Y+=L)):$==="center"?Y+=(U+hn(C.sizeTree,q)[1]-T+j)/2:Y-=N,P&&(Y+=P);const _=M=>{S(),M?(z("retrying to scroll to",{location:k},Vt.DEBUG),Re(f,k)):(Re(v,!0),z("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),O==="smooth"){let M=!1;b=Qe(t,G=>{M=M||G}),x=fn(d,()=>{_(M)})}else x=fn(ee(t,eC(150)),_);return y=setTimeout(()=>{S()},1200),Re(l,!0),z("scrolling from index to",{behavior:O,index:q,top:Y},Vt.DEBUG),{behavior:O,top:Y}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},lt(En,Bt,Hn),{singleton:!0});function eC(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 wo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return we(ee(i,Fe(l),Ae(([d,h])=>!!h),Tn(!1)),a),we(ee(i,Fe(l),Ae(([d,h])=>!!h),Tn(!1)),c),Qe(ee(yt(t,i),Fe(a,n,e,c),Ae(([[,d],h,{sizeTree:m},f,v])=>d&&(!st(m)||ka(f))&&!h&&!v),Fe(l)),([,d])=>{fn(o,()=>{Re(c,!0)}),Da(4,()=>{fn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(En,Bt,vo,Wn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const bo="up",yo="down",tC="none",nC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rC=0,So=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=We(),c=We(),d=se(4),h=se(rC),m=Mt(ee(Ia(ee(ke(o),nr(1),Tn(!0)),ee(ke(o),nr(1),Tn(!1),qf(100))),ct()),!1),f=Mt(ee(Ia(ee(n,Tn(!0)),ee(n,Tn(!1),qf(200))),ct()),!1);we(ee(yt(ke(o),ke(h)),pe(([b,S])=>b<=S),ct()),a),we(ee(a,jn(50)),c);const v=en(ee(yt(r,ke(s),ke(t),ke(e),ke(d)),kn((b,[{scrollHeight:S,scrollTop:k},C,T,E,N])=>{const R=k+C-S>-N,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let V,U;return k>b.state.scrollTop?(V="SCROLLED_DOWN",U=b.state.scrollTop-k):(V="SIZE_DECREASED",U=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:U,state:L}}let z;return L.scrollHeight>b.state.scrollHeight?z="SIZE_INCREASED":C<b.state.viewportHeight?z="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?z="SCROLLING_UPWARDS":z="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:z,state:L}},nC),ct((b,S)=>b&&b.atBottom===S.atBottom))),g=Mt(ee(r,kn((b,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(b=>b.changed),pe(b=>b.jump)),0);we(ee(v,pe(b=>b.atBottom)),i),we(ee(i,jn(50)),l);const x=se(yo);we(ee(r,pe(({scrollTop:b})=>b),ct(),kn((b,S)=>vt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?bo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),pe(b=>b.direction)),x),we(ee(r,jn(50),Tn(tC)),x);const y=se(0);return we(ee(m,Ae(b=>!b),Tn(0)),y),we(ee(o,jn(100),Fe(m),Ae(([b,S])=>!!S),kn(([b,S],[k])=>[S,k],[0,0]),pe(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},lt(Bt)),js="top",_s="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===bo&&t===js||n===yo&&t===_s?e:0:n===bo?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=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=se(0),a=se(0),l=se(0),c=Mt(ee(yt(ke(r),ke(o),ke(n),ke(s,go),ke(l),ke(i),ke(t),ke(e),ke(a)),pe(([d,h,m,[f,v],g,x,y,b,S])=>{const k=d-b,C=x+y,T=Math.max(m-k,0);let E=dh;const N=hh(S,js),R=hh(S,_s);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+C-N&&(E=bo),v<d-T+h+R&&(E=yo),E!==dh?[Math.max(k-m-fh(g,js,E)-N,0),k-T-y+h+fh(g,_s,E)+R]:null}),Ae(d=>d!=null),ct(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},lt(Bt),{singleton:!0});function oC(e,t,n){if(As(t)){const r=sh(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 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 sr=Ge(([{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=se([]),x=se(0),y=We();we(s.topItemsIndexes,g);const b=Mt(ee(yt(f,v,ke(l,go),ke(o),ke(r),ke(c),d,ke(g),ke(t),ke(n),e),Ae(([T,E,,N,,,,,,,R])=>{const L=R&&R.length!==N;return T&&!E&&!L}),pe(([,,[T,E],N,R,L,z,V,U,j,W])=>{const $=R,{offsetTree:O,sizeTree:P}=$,I=vt(x);if(N===0)return{...Fa,totalCount:N};if(T===0&&E===0)return I===0?{...Fa,totalCount:N}:ph(I,L,R,U,j,W||[]);if(st(P))return I>0?null:Ps(oC(La(L,N),$,W),[],N,j,$,U);const q=[];if(V.length>0){const J=V[0],oe=V[V.length-1];let K=0;for(const D of Es(P,J,oe)){const X=D.value,Z=Math.max(D.start,J),ue=Math.min(D.end,oe);for(let F=Z;F<=ue;F++)q.push({data:W==null?void 0:W[F],index:F,offset:K,size:X}),K+=X}}if(!z)return Ps([],q,N,j,$,U);const Y=V.length>0?V[V.length-1]+1:0,_=KS(O,T,E,Y);if(_.length===0)return null;const M=N-1,G=ks([],J=>{for(const oe of _){const K=oe.value;let D=K.offset,X=oe.start;const Z=K.size;if(K.offset<T){X+=Math.floor((T-K.offset+j)/(Z+j));const F=X-oe.start;D+=F*Z+F*j}X<Y&&(D+=(Y-X)*Z,X=Y);const ue=Math.min(oe.end,M);for(let F=X;F<=ue&&!(D>=E);F++)J.push({data:W==null?void 0:W[F],index:F,offset:D,size:Z}),D+=Z+j}});return Ps(G,q,N,j,$,U)}),Ae(T=>T!==null),ct()),Fa);we(ee(e,Ae(ka),pe(T=>T==null?void 0:T.length)),o),we(ee(b,pe(T=>T.topListHeight)),h),we(h,a),we(ee(b,pe(T=>[T.top,T.bottom])),i),we(ee(b,pe(T=>T.items)),y);const S=en(ee(b,Ae(({items:T})=>T.length>0),Fe(o,e),Ae(([{items:T},E])=>T[T.length-1].originalIndex===E-1),pe(([,T,E])=>[T-1,E]),ct(go),pe(([T])=>T))),k=en(ee(b,jn(200),Ae(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),pe(({items:T})=>T[0].index),ct())),C=en(ee(b,Ae(({items:T})=>T.length>0),pe(({items:T})=>{let E=0,N=T.length-1;for(;T[E].type==="group"&&E<N;)E++;for(;T[N].type==="group"&&N>E;)N--;return{endIndex:T[N].index,startIndex:T[E].index}}),ct(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},lt(En,lh,$a,wo,vo,So,Wn,Ma),{singleton:!0}),gh=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Mt(ee(yt(n,e,r,t,o),pe(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return we(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Bt,sr),{singleton:!0}),sC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Mt(ee(yt(n,e,t),Ae(([o])=>o),pe(([,o,s])=>Math.max(0,o-s)),jn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Bt,gh),{singleton:!0}),xh=Ge(()=>({context:se(null)})),iC=({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=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return we(ee(d,Fe(t,l,n,s,o,r,a),Fe(e),pe(([[h,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:C,calculateViewLocation:T=iC,done:E,...N}=h,R=ih(h,m,v-1),L=xo(R,m.offsetTree,S)+g+x,z=L+hn(m.sizeTree,R)[1],V=b+x,U=b+f-y,j=T({itemBottom:z,itemTop:L,locationParams:{align:k,behavior:C,...N},viewportBottom:U,viewportTop:V});return j?E&&fn(ee(i,Ae(W=>!W),nr(vt(i)?1:2)),E):E&&E(),j}),Ae(h=>h!==null)),c),{scrollIntoView:d}},lt(En,Bt,vo,sr,Hn),{singleton:!0});function wh(e){return e?e==="smooth"?"smooth":"auto":!1}const aC=(e,t)=>typeof e=="function"?wh(e(t)):t&&wh(e),lC=Ge(([{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=se(!1),g=We();let x=null;function y(C){Re(i,{align:"end",behavior:C,index:"LAST"})}Qe(ee(yt(ee(ke(t),nr(1)),l),Fe(ke(v),s,a,h),pe(([[C,T],E,N,R,L])=>{let z=T&&R,V="auto";return z&&(V=aC(E,N||L),z=z&&!!V),{followOutputBehavior:V,shouldFollow:z,totalCount:C}}),Ae(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=fn(e,()=>{vt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function b(C){const T=fn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(vt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Qe(ee(yt(ke(v),t,c),Ae(([C,,T])=>C&&T),kn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ae(({refreshed:C})=>C),Fe(v,t)),([,C])=>{vt(a)&&b(C!==!1)}),Qe(g,()=>{b(vt(v)!==!1)}),Qe(yt(ke(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=We();return we(Ia(ee(ke(r),pe(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(ke(t))),k),Qe(ee(yt(ee(k,nr(1)),l),Fe(ke(S),a,h,m),pe(([[C,T],E,N,R,L])=>T&&N&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:R}))),Ae(C=>!!C),jn(0)),C=>{x&&(x(),x=null),vt(n)?requestAnimationFrame(()=>{vt(d)("scrolling into view",{}),Re(f,C)}):x=fn(e,()=>{vt(d)("scrolling into view",{}),Re(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},lt(En,So,vo,wo,Wn,Hn,Bt,xh,vh)),cC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(we(ee(a,Fe(s),Ae(([,l])=>l!==0),Fe(o,r,t,n,e),pe(([[,l],c,d,h,m,f=[]])=>ph(l,c,d,h,m,f))),i),{}),lt(En,wo,sr,Wn),{singleton:!0}),uC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Qe(ee(e,Fe(r),Ae(([,o])=>o!==0),pe(([,o])=>({top:o}))),o=>{fn(ee(n,nr(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},lt(Wn,Bt,sr),{singleton:!0}),bh=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=We(),r=se(!1);return we(ee(e,Fe(r,t,n),Ae(([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}),ct()),t),Qe(ee(yt(t,e,n),Fe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(So),{singleton:!0}),Ba=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=se(!1),i=se(void 0);return we(ee(yt(n,r),pe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),we(ee(t,Fe(r),pe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Bt)),dC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=se(void 0),h=se(null),m=se(null);return we(a,h),we(l,m),Qe(ee(c,Fe(t,r,i,h,m,n)),([f,v,g,x,y,b,S])=>{const k=GS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),we(ee(d,Ae(ka),pe(fC)),o),we(ee(s,Fe(d),Ae(([,f])=>f!==void 0),ct(),pe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},lt(En,Bt,wo,Wn,Ba));function fC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return we(ee(t,Ae(n=>n>=0),pe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(sr));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mC=Ge(([{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,Fe(i),kn(([,y,b,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},N])=>{const R=k+T;let L=0;return b===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=R-S,L!==0&&(L+=N))),[L,C,E,R]},[0,[],0,0]),Ae(([y])=>y!==0),Fe(r,a,n,o,f,v),Ae(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===bo),pe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(Re(t,{behavior:"auto",top:-y}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-y}))}return Qe(ee(g,Fe(e,s)),([y,b,S])=>{S&&pC()?Re(e,b-y):x(-y)}),Qe(ee(yt(Mt(s,!1),e,v),Ae(([y,b,S])=>!y&&!S&&b!==0),pe(([y,b])=>b),jn(1)),x),we(ee(h,pe(y=>({top:-y}))),t),Qe(ee(c,Fe(m,d),pe(([y,{groupIndices:b,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(b.length===0)return T(y);{let E=0;const N=mo(k,0);let R=0,L=0;for(;R<y;){R++,E+=N;let z=b.length===L+1?1/0:b[L+1]-b[L]-1;R+z>y&&(E-=N,z=y-R+1),R+=z,E+=T(z),L++}return E}})),y=>{Re(e,y),requestAnimationFrame(()=>{Re(t,{top:y}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},lt(Bt,So,sr,En,Hn,Ma)),gC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),lt($a,cC,Wn,bh,gh,uC,sC,Ba,vh,Hn,xh)),Sh=Ge(([{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:b,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:N},R])=>(we(k.rangeChanged,R.scrollSeekRangeChanged),we(ee(R.windowViewportRect,pe(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...R,...g,sizes:l,...x}),lt(En,wo,Bt,dC,lC,sr,vo,mC,hC,lh,gC));function xC(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"?w.useLayoutEffect:w.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=w.createContext({});function l(x,y){x.propsReady&&Re(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];Re(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];Re(S,y[b])}x.propsReady&&Re(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const k=x[t.methods[b]];Re(k,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=MS(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>ks(OS(e),E=>{l(E,S)})),[C]=w.useState(Kf(d,k));Ms(()=>{for(const E of i)E in S&&Qe(C[E],S[E]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Ms(()=>{l(k,S)}),w.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...xC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Re(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(S=>Qe(y,S),[y]);return w.useSyncExternalStore(b,()=>vt(y),()=>vt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Kf(vt,y));return Ms(()=>Qe(y,k=>{k!==b&&S(Wf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ms(()=>Qe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Th=w.createContext(void 0),kh=w.createContext(void 0),Eh=typeof document<"u"?w.useLayoutEffect:w.useEffect;function za(e){return"self"in e}function vC(e){return"body"in e}function Ih(e,t,n,r=_r,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(vC(x)||za(x)){const b=za(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.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]);w.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(Un(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=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,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=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Wa),o=se("div"),s=se(_r),i=(a,l=null)=>Mt(ee(n,pe(c=>c[a]),ct()),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")}}),bC=Ge(([e,t])=>({...e,...t}),lt(Sh,wC)),yC=({height:e})=>u.jsx("div",{style:{height:e}}),SC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},CC={...Ah,display:"inline-block",height:"100%"},jh=w.memo(function({showTopList:e=!1}){const t=_e("listState"),n=rn("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),h=_e("trackItemSizes"),m=_e("itemSize"),f=_e("log"),v=rn("gap"),g=_e("horizontalDirection"),{callbackRef:x}=$S(n,m,h,e?_r:a,f,v,o,g,_e("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Va("deviation",j=>{y!==j&&b(j)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||yC,C=_e("ListComponent"),T=_e("ItemComponent"),E=_e("GroupComponent"),N=_e("computeItemKey"),R=_e("isSeeking"),L=_e("groupIndices").length>0,z=_e("alignToBottom"),V=_e("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:z?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:z?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{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:U,children:(e?t.topItems:t.items).map(j=>{const W=j.originalIndex,$=N(W+t.firstItemIndex,j.data,c);return R?w.createElement(k,{...Rt(k,c),height:j.size,index:j.index,key:$,type:j.type||"item",...j.type==="group"?{}:{groupIndex:j.groupIndex}}):j.type==="group"?w.createElement(E,{...Rt(E,c),"data-index":W,"data-item-index":j.index,"data-known-size":j.size,key:$,style:SC},d(j.index,c)):w.createElement(T,{...Rt(T,c),...IC(T,j.data),"data-index":W,"data-item-group-index":j.groupIndex,"data-item-index":j.index,"data-known-size":j.size,key:$,style:g?CC:Ah},L?l(j.index,j.groupIndex,j.data,c):l(j.index,j.data,c))})})}),TC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},kC={outline:"none",overflowX:"auto",position:"relative"},Rs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),EC={position:Ua(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function IC(e,t){return{item:typeof e=="string"?void 0:t}}const NC=w.memo(function(){const e=_e("HeaderComponent"),t=rn("headerHeight"),n=_e("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),AC=w.memo(function(){const e=_e("FooterComponent"),t=rn("footerHeight"),n=_e("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("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 w.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?kC:TC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Ph({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ih(a,c,l,v,m);return Eh(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.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 jC=({children:e})=>{const t=w.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=w.useMemo(()=>Vf(n,l=>Un(l,s?"width":"height")),[n,s]),a=rr(i,!0,_e("skipAnimationFrameInResizeObserver"));return w.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})},_C=({children:e})=>{const t=w.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=_e("customScrollParent"),s=Xf(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return w.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})},PC=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...EC,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},MC=w.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?DC:OC,{...e,context:o,children:[n&&u.jsx(PC,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?_C:jC,{children:[u.jsx(NC,{}),u.jsx(jh,{}),u.jsx(AC,{})]})]})}),{Component:RC,useEmitter:Va,useEmitterValue:_e,usePublisher:rn}=Ch(bC,{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),OC=_h({useEmitter:Va,useEmitterValue:_e,usePublisher:rn}),DC=Ph({useEmitter:Va,useEmitterValue:_e,usePublisher:rn}),LC=RC;lt(Sh,Ge(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Wa),a=se(_r),l=(c,d=null)=>Mt(ee(s,pe(h=>h[c]),ct()),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},$C={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 FC(e){return{...$C,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function BC(e,t){return e&&e.column===t.column&&e.row===t.row}const zC=Ge(([{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:b,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),N=se(Mh),R=se({height:0,width:0}),L=se({height:0,width:0}),z=We(),V=We(),U=se(0),j=se(null),W=se({column:0,row:0}),$=We(),O=We(),P=se(!1),I=se(0),q=se(!0),Y=se(!1),_=se(!1);Qe(ee(v,Fe(I),Ae(([D,X])=>!!X)),()=>{Re(q,!1)}),Qe(ee(yt(v,q,L,R,I,Y),Ae(([D,X,Z,ue,,F])=>D&&!X&&Z.height!==0&&ue.height!==0&&!F)),([,,,,D])=>{Re(Y,!0),Da(1,()=>{Re(z,D)}),fn(ee(c),()=>{Re(t,[0,0]),Re(q,!0)})}),we(ee(O,Ae(D=>D!=null&&D.scrollTop>0),Tn(0)),E),Qe(ee(v,Fe(O),Ae(([,D])=>D!=null)),([,D])=>{D&&(Re(R,D.viewport),Re(L,D.item),Re(W,D.gap),D.scrollTop>0&&(Re(P,!0),fn(ee(c,nr(1)),X=>{Re(P,!1)}),Re(l,{top:D.scrollTop})))}),we(ee(R,pe(({height:D})=>D)),h),we(ee(yt(ke(R,Ds),ke(L,Ds),ke(W,(D,X)=>D&&D.column===X.column&&D.row===X.row),ke(c)),pe(([D,X,Z,ue])=>({gap:Z,item:X,scrollTop:ue,viewport:D}))),$),we(ee(yt(ke(T),r,ke(W,BC),ke(L,Ds),ke(R,Ds),ke(j),ke(E),ke(P),ke(q),ke(I)),Ae(([,,,,,,,D])=>!D),pe(([D,[X,Z],ue,F,ne,de,ce,,ge,Ce])=>{const{column:Pe,row:De}=ue,{height:ze,width:rt}=F,{width:Ct}=ne;if(ce===0&&(D===0||Ct===0))return Mh;if(rt===0){const At=La(Ce,D),wt=At+Math.max(ce-1,0);return FC(Dh(At,wt,de))}const Ve=Lh(Ct,rt,Pe);let He,Ye;ge?X===0&&Z===0&&ce>0?(He=0,Ye=ce-1):(He=Ve*Os((X+De)/(ze+De)),Ye=Ve*Rh((Z+De)/(ze+De))-1,Ye=Ka(D-1,Co(Ye,Ve-1)),He=Ka(Ye,Co(0,He))):(He=0,Ye=-1);const Le=Dh(He,Ye,de),{bottom:Ue,top:mt}=$h(ne,ue,F,Le),Dt=Rh(D/Ve),at=Dt*ze+(Dt-1)*De-Ue;return{bottom:Ue,itemHeight:ze,items:Le,itemWidth:rt,offsetBottom:at,offsetTop:mt,top:mt}})),N),we(ee(j,Ae(D=>D!==null),pe(D=>D.length)),T),we(ee(yt(R,L,N,W),Ae(([D,X,{items:Z}])=>Z.length>0&&X.height!==0&&D.height!==0),pe(([D,X,{items:Z},ue])=>{const{bottom:F,top:ne}=$h(D,ue,X,Z);return[ne,F]}),ct(go)),t);const M=se(!1);we(ee(c,Fe(M),pe(([D,X])=>X||D!==0)),M);const G=en(ee(yt(N,T),Ae(([{items:D}])=>D.length>0),Fe(M),Ae(([[D,X],Z])=>{const ue=D.items[D.items.length-1].index===X-1;return(Z||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&ue}),pe(([[,D]])=>D-1),ct())),J=en(ee(ke(N),Ae(({items:D})=>D.length>0&&D[0].index===0),Tn(0),ct())),oe=en(ee(ke(N),Fe(P),Ae(([{items:D},X])=>D.length>0&&!X),pe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ct(rh),jn(0)));we(oe,f.scrollSeekRangeChanged),we(ee(z,Fe(R,L,T,W),pe(([D,X,Z,ue,F])=>{const ne=ch(D),{align:de,behavior:ce,offset:ge}=ne;let Ce=ne.index;Ce==="LAST"&&(Ce=ue-1),Ce=Co(0,Ce,Ka(ue-1,Ce));let Pe=qa(X,F,Z,Ce);return de==="end"?Pe=Oh(Pe-X.height+Z.height):de==="center"&&(Pe=Oh(Pe-X.height/2+Z.height/2)),ge&&(Pe+=ge),{behavior:ce,top:Pe}})),l);const K=Mt(ee(N,pe(D=>D.offsetBottom+D.bottom)),0);return we(ee(k,pe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:x,data:j,deviation:U,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:O,scrollBy:i,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:z,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:K,...m,endReached:G,propsReady:g,rangeChanged:oe,startReached:J,stateChanged:$,stateRestoreInProgress:P,...C}},lt($a,Bt,So,bh,Wn,Ba,Hn));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 HC=Ge(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Wa),i=se("div"),a=se(_r),l=(h,m=null)=>Mt(ee(t,pe(f=>f[h]),ct()),m),c=se(!1),d=se(!1);return we(ke(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")}}),UC=Ge(([e,t])=>({...e,...t}),lt(zC,HC)),WC=w.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=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);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 b=o(y.index,y.data,d);return s?u.jsx(c,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),VC=w.memo(function(){const e=ut("HeaderComponent"),t=on("headerHeight"),n=ut("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),KC=w.memo(function(){const e=ut("FooterComponent"),t=on("footerHeight"),n=ut("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),qC=({children:e})=>{const t=w.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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})},GC=({children:e})=>{const t=w.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=ut("customScrollParent"),s=Xf(n,o,!1);return w.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})},YC=w.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?JC:XC,o=n||t?GC:qC,s=ut("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(VC,{}),u.jsx(WC,{}),u.jsx(KC,{})]})})}),{useEmitter:Fh,useEmitterValue:ut,usePublisher:on}=Ch(UC,{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"}},YC),XC=_h({useEmitter:Fh,useEmitterValue:ut,usePublisher:on}),JC=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 ZC=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:te(ZC({variant:t}),e),...n})}var Ls="Dialog",[Hh,yN]=cn(Ls),[QC,pn]=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]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(QC,{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=pn(Wh,n),s=$e(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Vh.displayName=Wh;var Ga="DialogPortal",[eT,Kh]=Hh(Ga,{forceMount:void 0}),qh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(Ga,t);return u.jsx(eT,{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=pn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(nT,{...o,ref:t})}):null});Gh.displayName=$s;var tT=Yt.createSlot("DialogOverlay.RemoveScroll"),nT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn($s,n);return u.jsx(gs,{as:tT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Yh=p.forwardRef((e,t)=>{const n=Kh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(rT,{...o,ref:t}):u.jsx(oT,{...o,ref:t})})});Yh.displayName=ir;var rT=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(null),o=$e(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:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),oT=p.forwardRef((e,t)=>{const n=pn(ir,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=pn(ir,n),l=p.useRef(null),c=$e(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(br,{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(sT,{titleId:a.titleId}),u.jsx(aT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Ya,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Jh.displayName=Ya;var Zh="DialogDescription",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Zh,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Qh.displayName=Zh;var ep="DialogClose",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(ep,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});tp.displayName=ep;function Xa(e){return e?"open":"closed"}var np="DialogTitleWarning",[SN,rp]=yw(np,{contentName:ir,titleName:Ya,docsSlug:"dialog"}),sT=({titleId:e})=>{const t=rp(np),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},tT="DialogDescriptionWarning",nT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${np(tT).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},Xa=Hh,rT=Wh,Ja=Kh,To=qh,ko=Gh,ar=Xh,Fs=Zh,rp=ep;const Za=Xa,oT=Ja,op=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{ref:n,className:te("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}));op.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===ar||(c==null?void 0:c.displayName)===ar.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(oT,{children:[u.jsx(op,{}),u.jsxs(ko,{ref:r,className:te("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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(rp,{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(le.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:te("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(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=ar.displayName;const sT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));sT.displayName=Fs.displayName;const iT=1,aT=1e6;let Qa=0;function lT(){return Qa=(Qa+1)%Number.MAX_SAFE_INTEGER,Qa.toString()}const el=new Map,sp=e=>{if(el.has(e))return;const t=setTimeout(()=>{el.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},aT);el.set(e,t)},cT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,iT)};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?sp(n):e.toasts.forEach(r=>{sp(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=cT(Ws,e),Us.forEach(t=>{t(Ws)})}function uT({...e}){const t=lT(),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 tl(){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:uT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ip({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:h}=tl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Pi(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]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Xc(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 Pi(n),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);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(le.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(tt,{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(le.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(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(Za,{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(tt,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(tt,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ap(){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 lr=ap();function dT(e){lr=e}const lp=/[&<>"']/,fT=new RegExp(lp.source,"g"),cp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,hT=new RegExp(cp.source,"g"),pT={"&":"&","<":"<",">":">",'"':""","'":"'"},up=e=>pT[e];function Ot(e,t){if(t){if(lp.test(e))return e.replace(fT,up)}else if(cp.test(e))return e.replace(hT,up);return e}const mT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function dp(e){return e.replace(mT,(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 gT=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(gT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const xT=/[^\w:]/g,vT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function fp(e,t,n){if(e){let r;try{r=decodeURIComponent(dp(n)).replace(xT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!vT.test(n)&&(n=ST(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},wT=/^[^:]+:\/*[^/]*$/,bT=/^([^:]+:)[\s\S]*$/,yT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function ST(e,t){Vs[" "+e]||(wT.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(bT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(yT,"$1")+t:e+t}const Ks={exec:function(){}};function hp(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 CT(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 TT(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 pp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function mp(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 kT(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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},iT="DialogDescriptionWarning",aT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${rp(iT).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,lT=Vh,Za=qh,To=Gh,ko=Yh,ar=Jh,Fs=Qh,op=tp;const Qa=Ja,cT=Za,sp=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{ref:n,className:te("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===ar||(c==null?void 0:c.displayName)===ar.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(cT,{children:[u.jsx(sp,{}),u.jsxs(ko,{ref:r,className:te("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(ar,{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(le.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:te("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(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=ar.displayName;const uT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));uT.displayName=Fs.displayName;const dT=1,fT=1e6;let el=0;function hT(){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})},fT);tl.set(e,t)},pT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,dT)};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=pT(Ws,e),Us.forEach(t=>{t(Ws)})}function mT({...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]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:mT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ap({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:h}=nl(),m=w.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]);w.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),b=new Blob([y],{type:o}),S=URL.createObjectURL(b);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(le.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(tt,{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(le.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(le.Image,{className:"h-5 w-5"}):u.jsx(le.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(tt,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(tt,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.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 lr=lp();function gT(e){lr=e}const cp=/[&<>"']/,xT=new RegExp(cp.source,"g"),up=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vT=new RegExp(up.source,"g"),wT={"&":"&","<":"<",">":">",'"':""","'":"'"},dp=e=>wT[e];function Ot(e,t){if(t){if(cp.test(e))return e.replace(xT,dp)}else if(up.test(e))return e.replace(vT,dp);return e}const bT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function fp(e){return e.replace(bT,(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 yT=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ST=/[^\w:]/g,CT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function hp(e,t,n){if(e){let r;try{r=decodeURIComponent(fp(n)).replace(ST,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!CT.test(n)&&(n=IT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},TT=/^[^:]+:\/*[^/]*$/,kT=/^([^:]+:)[\s\S]*$/,ET=/^([^:]+:\/*[^/]*)[\s\S]*$/;function IT(e,t){Vs[" "+e]||(TT.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(kT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(ET,"$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 NT(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 AT(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 jT(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
|
-
`)}class
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
85
|
+
`)}class rl{constructor(t){this.options=t||lr}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=jT(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,h,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 b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),h=t.split(`
|
|
88
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(h)&&(r+=h+`
|
|
89
89
|
`,t=t.substring(h.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
90
|
`,1)[0],h=m,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(h)||E.test(h)||k.test(h)||C.test(t)));){if(h.search(/[^ ]/)>=i||!h.trim())f+=`
|
|
91
91
|
`+h.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||C.test(d))break;f+=`
|
|
92
92
|
`+h}!l&&!h.trim()&&(l=!0),r+=m+`
|
|
93
|
-
`,t=t.substring(m.length+1),d=h.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:
|
|
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=
|
|
96
|
-
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const me={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])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=it(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=it(Se._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=it(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=it(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=it(me.emStrong.rDelimUnd,"g").replace(/punct/g,me._punctuation).getRegex(),me._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,me._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,me._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])?)+(?![-_])/,me.autolink=it(me.autolink).replace("scheme",me._scheme).replace("email",me._email).getRegex(),me._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,me.tag=it(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=it(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=it(me.reflink).replace("label",me._label).replace("ref",Se._label).getRegex(),me.nolink=it(me.nolink).replace("ref",Se._label).getRegex(),me.reflinkSearch=it(me.reflinkSearch,"g").replace("reflink",me.reflink).replace("nolink",me.nolink).getRegex(),me.normal={...me},me.pedantic={...me.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:it(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:it(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:it(me.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},me.gfm.url=it(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:it(me.br).replace("{2,}","*").getRegex(),text:it(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function
|
|
93
|
+
`,t=t.substring(m.length+1),d=h.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:pp(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]=pp(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=NT(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)),gp(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 gp(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 h=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+i);(o=h.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=it(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=it(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=it(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=it(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=it(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=it(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=it(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=it(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:it(`^ *(?: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:it(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 me={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])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=it(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=it(Se._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=it(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=it(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=it(me.emStrong.rDelimUnd,"g").replace(/punct/g,me._punctuation).getRegex(),me._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,me._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,me._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])?)+(?![-_])/,me.autolink=it(me.autolink).replace("scheme",me._scheme).replace("email",me._email).getRegex(),me._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,me.tag=it(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=it(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=it(me.reflink).replace("label",me._label).replace("ref",Se._label).getRegex(),me.nolink=it(me.nolink).replace("ref",Se._label).getRegex(),me.reflinkSearch=it(me.reflinkSearch,"g").replace("reflink",me.reflink).replace("nolink",me.nolink).getRegex(),me.normal={...me},me.pedantic={...me.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:it(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:it(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:it(me.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},me.gfm.url=it(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:it(me.br).replace("{2,}","*").getRegex(),text:it(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function _T(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 xp(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 Vn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,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:me.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=me.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=me.breaks:n.inline=me.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:me}}static lex(t,n){return new Vn(n).lex(t)}static lexInline(t,n){return new Vn(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)+"["+mp("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)+"["+mp("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,xp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,xp))){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 h=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},h),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,_T)){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||lr}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 N='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}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||lr}preprocess(t){return t}postprocess(t){return t}}
|
|
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={...ye.defaults,...s};const i=IT(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(TT(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&&ye.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;ye.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(ye.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&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return wp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},dT(ye.defaults),ye},ye.getDefaults=ap,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.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=ye.defaults.renderer||new rl;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=ye.defaults.tokenizer||new nl;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=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.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=ye.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}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=wp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=rl,ye.TextRenderer=xp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=nl,ye.Slugger=vp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Mr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.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 ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(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=w.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:te("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 bp({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 yp({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(le.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(le.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(le.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(le.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(le.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(le.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(Mr,{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(le.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 Sp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Jv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(yp,{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(bp,{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 ol=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ol.displayName="Card";const sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));sl.displayName="CardHeader";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));il.displayName="CardTitle";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));al.displayName="CardDescription";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));ll.displayName="CardContent";const Cp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));Cp.displayName="CardFooter";function Tp({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=xr(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(ol,{className:te("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(sl,{className:"pb-3",children:[u.jsx(il,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(al,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ll,{className:"pt-0 pb-3",children:a}),u.jsx(Cp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(tt,{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(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const NT="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 kp({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:NT,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:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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(le.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 Ip({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?du(l)??l:l;if(c&&typeof c=="object")return u.jsx(kp,{data:c});const d=typeof c=="string"?c:(()=>{try{return xr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Wv(l);return d?u.jsx(Mr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(h=>h.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Qr(m);return i(f)}const c=Zr(l),d=Qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function AT({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:te("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:te("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(tt,{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(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ap({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:h,handleFileClick:m,uploadingFiles:f,handleInterruptApprove:v,handleInterruptReject:g,disableInterruptActions:x,activeInterruptId:y,activeInterruptValue:b,messageRole:S,iconForeground:k}){const C=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),T=w.useCallback(({part:B,i:H})=>{if(B.type==="image_url"){const L=B;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:L.url,alt:L.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},H)}if(B.type==="file"){const L=B,j=L.name||"file";return u.jsxs("a",{href:L.url,onClick:K=>m(K.nativeEvent,L,H),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:[f[H]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[j,f[H]?" (processing)":""]})]},H)}if(B.type==="interrupt"){const L=B,j=Go((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),K=!!(y&&j&&j===y),V=K?b??(L==null?void 0:L.value):L==null?void 0:L.value,$=j?{...L,id:j,interrupt_id:j}:L;return u.jsx(Tp,{interruptPart:$,onApprove:v,onReject:g,disabled:x,isActive:K,payload:V},H)}return null},[m,f,v,g,y,b,x]),E=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return C();if(!t&&!E&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;const N=i.filter(B=>B.type!=="text"),R=S==="user",D=u.jsxs("div",{className:"space-y-2",children:[a.trim().length>0&&(R?u.jsx("pre",{className:"font-sans whitespace-pre-wrap break-words text-current",children:a}):u.jsx(Mr,{content:a,allowHtml:!1})),N.map((B,H)=>u.jsx(T,{part:B,i:H},`non-text-${H}`))]});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[D,u.jsx(Np,{className:k})]}):D}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=tl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),S=b.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(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Jc(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(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(e,t){return w.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:Vv(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:Kv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=w.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:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[R,D]=w.useState(!1),[B,H]=w.useState("preview"),[L,j]=w.useState(!1),{currentThreadId:K}=gr(),{respondToInterrupt:V}=eo(),$=l==="phone"||l==="half-screen",_=t.role,I=_==="tool",q=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),Y=!!q,P=!(r&&_!=="user"),{uploadingFiles:M,handleFileClick:G,fileViewerOpen:J,currentFileInfo:oe,closeFileViewer:W}=jp({allowFileOpen:P,currentThreadId:K}),O=w.useMemo(()=>{switch(_){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))]"}},[_]),X=Pp(t,q),{contentParts:Z,imageParts:ue,fileParts:F,interruptParts:ne,textContent:de,toolMeta:ce,toolRaw:ge,isToolStreaming:Ce}=X,_e=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),De=Go(_e),ze=y==null?void 0:y.value,rt=w.useMemo(()=>q||!m?null:t.artifact||null,[q,t,m]),Ct=w.useCallback(async()=>{const Te=I?ge:de;async function qe(Ee){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ee);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ke=new Blob([Ee],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ke})]);return}throw new Error("Clipboard API not supported in this context.")}try{await qe(Te),D(!0),setTimeout(()=>D(!1),2e3),x==null||x(Te)}catch(Ee){console.error("Failed to copy:",Ee)}},[I,ge,de,x]),Ve=w.useCallback(()=>{if(!v||!t.id)return;const Te=(I?ge:de)??"",qe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,Te,qe)},[v,t.id,I,ge,de,t]),He=w.useCallback(()=>{g==null||g(n)},[g,n]),Ye=w.useCallback(()=>{const qe=te($?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",O);switch(_){case"user":return u.jsx(le.User,{className:qe});case"assistant":return u.jsx(le.Bot,{className:qe});case"tool":return u.jsx(le.Wrench,{className:qe});default:return u.jsx(le.Bot,{className:qe})}},[$,O,_]),Le=w.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(_){case"user":return te(Te,"justify-end");case"assistant":case"tool":case"system":return te(Te,"justify-start");default:return Te}},[_]),Ue=w.useCallback(()=>{const Te=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",$&&"px-3 py-2 text-sm");if(Y)return te(Te,"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(_){case"user":return te(Te,"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 te(Te,"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 te(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Te,"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")}},[$,Y,_]),mt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await V(qe,!0)}catch(Ee){console.error("Failed to approve interrupt:",Ee)}finally{k==null||k()}},[b,k,S,V]),Dt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await V(qe,!1)}catch(Ee){console.error("Failed to reject interrupt:",Ee)}finally{k==null||k()}},[b,k,S,V]),at=w.useMemo(()=>q?"Assistant":qv(t),[q,t]),At=_==="user"&&(C??1)>1&&typeof E=="function",wt=(N==null?void 0:N.length)??0,ut=wt>0&&T<wt-1?N[T+1]:void 0,bt=wt>0&&T>0?N[T-1]:void 0,Tt=w.useCallback(()=>{!ut||!E||E(ut.id,void 0,!!ut.isLatestAttempt)},[ut,E]),jt=w.useCallback(()=>{!bt||!E||E(bt.id,void 0,!!bt.isLatestAttempt)},[bt,E]);return I&&!h&&!rt?null:Y&&q?u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:te("h-4 w-4",O)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:q.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",$&&"mb-1 pb-1",O,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ye(),a&&at&&u.jsx("span",{className:te("font-medium",$?"text-xs":"text-sm"),children:at}),I&&u.jsxs(Bh,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",O,"border border-current/40",$&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":B==="expanded",onClick:()=>H(Te=>Te==="expanded"?"preview":"expanded"),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),H(qe=>qe==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),B==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[At&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("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||Tt()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(le.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:te("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||jt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",O,$&&"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:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",O,$&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(R?"text-success":O,$?"h-3 w-3":"h-4 w-4")})})}),_==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-foreground/10",O,$&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(O,$?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-foreground/10",O,$&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(O,$?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Ap,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:rt,toolViewMode:B,isToolStreaming:Ce,contentParts:Z,textContent:de,imageParts:ue,fileParts:F,interruptParts:ne,isStreamingMessage:r,handleFileClick:G,uploadingFiles:M,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:_,activeInterruptId:De,activeInterruptValue:ze,iconForeground:O}),m&&rt&&u.jsx("div",{className:"mt-3",children:u.jsx(Sp,{artifact:rt,idx:0})})]}),I&&B==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",$&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(R?"text-success":"text-current",$?"h-3 w-3":"h-4 w-4")})}),_==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})}),_==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",$&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",$?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(ip,{isOpen:J,onClose:W,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&hu(e.message)===hu(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=pu(e.message),a=pu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const jT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},cl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ul=w.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:b,onSelectCheckpoint:S}){const k=cl(t,n),C="type"in t&&t.type==="default_message",E=!!t.__syntheticStreaming,N=b??jT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:D,attemptIndex:B,attempts:H}=w.useMemo(()=>Zl(t.id,R,N),[t.id,R,N]);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,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:D,attemptIndex:B,attemptMetas:H,onSelectCheckpoint:S})})});ul.displayName="MessageRow";const dl=w.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:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:D,createSyntheticThinkingMessage:B=!0},H)=>{const L=w.useRef(null),j=w.useRef(null),K=w.useRef(!1),V=w.useRef(!1),[$,_]=w.useState(!0),I=w.useMemo(()=>b?e.some(F=>"type"in F&&F.type==="default_message"?!1:Array.isArray(F==null?void 0:F.content)&&F.content.some(ne=>ne&&ne.type==="interrupt"&&(ne.id??ne.interrupt_id)===b.id)):!1,[b,e]),q=w.useMemo(()=>{if(!b||I)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ne;const de=b.value;if(de&&typeof de=="object"&&!Array.isArray(de)){const ce=de.title;typeof ce=="string"&&ce.trim()&&(ne=ce.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:de,title:ne}]}},[b,I]),Y=w.useMemo(()=>q?[...e,q]:e,[e,q]),P=w.useMemo(()=>!B||!t?Y:!Y.some(ne=>ne.role==="assistant")&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y,[Y,t,B]),M=w.useMemo(()=>T?P:P.filter(F=>(F==null?void 0:F.role)!=="tool"),[P,T]),G=w.useCallback(F=>{_(F),x&&x(!F),y&&y(F)},[x,y]),J=w.useMemo(()=>{if(a)return async()=>{if(!K.current){K.current=!0;try{await a()}finally{K.current=!1}}}},[a]),oe=w.useMemo(()=>!v||g?!1:$?"auto":!1,[$,v,g]),W=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return!F||M&&M.length>0?null:{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}},[f,M]),O=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>W?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:W,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!"}),Z=M.length,ue=Z>0;return w.useEffect(()=>{var F,ne;if(Z===0){V.current=!1;return}if(!V.current)if(V.current=!0,L.current&&M.length>0){const de=M.length-1;(ne=(F=L.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[Z,M.length]),w.useImperativeHandle(H,()=>({scrollToLatest:()=>{var F,ne;if(L.current&&M.length>0){const de=M.length-1;(ne=(F=L.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var F,ne;L.current&&M.length>0?(ne=(F=L.current).scrollToIndex)==null||ne.call(F,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:O,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ue?u.jsx(_C,{ref:F=>{L.current=F},scrollerRef:F=>{j.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,ne)=>cl(ne,F),itemContent:(F,ne)=>u.jsx(ul,{message:ne,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:D})}):X()})})});dl.displayName="MessageList";const _p={value:""};function Rr({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,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:N,checkpoints:R,interrupt:D,metadata:B,checkpointIndex:H}=eo(),{isStreaming:L,error:j,connectionState:K,submit:V,stop:$}=Di(),_=b??y??null,I=(N==null?void 0:N.id)??null,q=(N==null?void 0:N.namespace)??null,[Y,P]=w.useState(null),M=(B==null?void 0:B.assemblingMessageId)??(L&&Y?Y:null),G=D,[J,oe]=w.useState(!1);w.useEffect(()=>{G||oe(!1)},[G]);const W=w.useCallback(()=>{oe(!0)},[]),O=w.useCallback(()=>{oe(!1)},[]),X=!!G||J,[Z,ue]=w.useState(null),[F,ne]=w.useState(""),[de,ce]=w.useState(null),[ge,Ce]=w.useState(null),[_e,De]=w.useState([]),[ze,rt]=w.useState(0),[Ct,Ve]=w.useState(0),[He,Ye]=w.useState(!1),[Le,Ue]=w.useState(null),[mt,Dt]=w.useState(null),[at,At]=w.useState(!1),[wt,ut]=w.useState(null),bt=w.useRef(!1),[Tt,jt]=w.useState(()=>_p.value),Te=w.useRef(Tt),qe=w.useRef(null),Ee=w.useCallback(ie=>{_p.value=ie,jt(ie)},[]),[Ke,zt]=w.useState(!1),re=w.useRef(null),be=w.useRef(null),ot=w.useRef(null),xe=w.useCallback(()=>{be.current&&(be.current.value=""),ot.current&&(ot.current.value=""),rt(ie=>ie+1),Ve(ie=>ie+1)},[]),Be=w.useCallback(ie=>{Ee(ie)},[Ee]),Xe=w.useRef(!1);w.useEffect(()=>{Xe.current&&!L&&(De([]),xe()),Xe.current=L},[L,xe]),w.useEffect(()=>{L||P(null)},[L]);const[kt,Et]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const fe=window.innerWidth;Et(fe<640?"phone":fe<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{bt.current=!1},[_]),w.useEffect(()=>{Te.current=Tt},[Tt]),w.useEffect(()=>{if(!Z){qe.current=null;return}qe.current===null&&(qe.current=Te.current),Ee(F??"")},[F,Z,Ee]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){ut(null);return}try{const Ne=(await x.getAgent("default")).uiDefaultMessage||"";ut(Ne||null)}catch(fe){console.warn("Failed to fetch default message:",fe),ut(null)}})()},[x.baseUrl]),w.useEffect(()=>{S&&S.length>0&&ut(null)},[S.length]),w.useEffect(()=>{j&&!at&&(g==null||g(j))},[j,at,g]);const Nt=async ie=>{const fe=ie.trim();if(!fe&&_e.length===0)return;const Ne=Z;try{const Oe=Z?(de==null?void 0:de.checkpointId)??I??void 0:I??void 0,et=Z?(de==null?void 0:de.checkpointNs)??q??void 0:q??void 0;await V({text:fe||"",attachments:_e},{checkpointId:Oe,checkpointNs:et,edit:!!Z,originalMessageId:Z??void 0}),f==null||f(fe),Ne&&P(Ne),Ee(""),Ce(null),De([]),xe(),ue(null),ne(""),ce(null)}catch(Oe){const et=(Oe==null?void 0:Oe.message)||"Failed to send message";Ce(et),g==null||g(et)}},Lt=w.useCallback((ie,fe,Ne)=>{c&&(qe.current=Tt,ue(ie),ne(fe),Ee(fe),Ce(null),ce({checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}))},[Tt,c,Ee]),je=w.useCallback(()=>{ue(null),ne(""),ce(null),Ce(null),Ee(qe.current??Tt),qe.current=null,P(null)},[Tt,Ee]),ht=w.useCallback((ie,fe,Ne)=>{Lt(ie,fe,Ne)},[Lt]),Ze=w.useCallback(ie=>{let fe=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){fe=S[pt];break}if(!fe)return;const Ne=Array.isArray(fe.content)?fe.content:[],et=Ne.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ne,null,2)}catch{return String(Ne)}})();et&&V({text:et},{checkpointId:I??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:fe.id})},[S,V,I,q]),ft=ie=>{const fe=Array.from(ie.target.files||[]);De(Ne=>[...Ne,...fe]),ie.target.value=""},an=ie=>{De(fe=>{const Ne=fe.filter((Oe,et)=>ie!==et);return Ne.length===0&&xe(),Ne})},A=async ie=>{const fe=(ie.target.files||[])[0];if(fe){Ue(null),Dt(null),Ye(!0);try{await V({attachments:[fe]},{checkpointId:I??void 0,checkpointNs:q??void 0});const Ne=`Uploaded ${fe.name} - processing through chat stream`;Dt(Ne)}catch(Ne){const Oe=Ne instanceof Error?Ne.message:"Failed to upload Excel file";console.error("Excel upload failed",Ne),Ue(Oe),g==null||g(Oe)}finally{Ye(!1),ie.target.value="",xe()}}},Q=async ie=>{if(y){zt(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToLatest()});return}const fe=R.find(Oe=>Oe.checkpointId===ie),Ne=(fe==null?void 0:fe.checkpointNs)??null;await T(ie,Ne),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToTop()})}finally{zt(!1)}}},he=w.useCallback(async(ie,fe,Ne)=>{await Q(Ne?null:ie)},[Q]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Je=`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 ${m.messagesArea||""}`,nt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!at&&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:j}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>At(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(dl,{ref:re,className:"h-full",style:{height:"100%"},messages:S,isStreaming:L,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:c,editingMessageId:Z,onEdit:ht,onRegenerate:Ze,onCancelEdit:je,emptyMessage:wt??void 0,isNavigatingCheckpoint:Ke,activeInterrupt:G,disableInterruptActions:J,onInterruptActionStart:W,onInterruptActionEnd:O,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:H,activeCheckpointId:I,onSelectCheckpoint:he,createSyntheticThinkingMessage:!0}),(K==="reconnecting"||K==="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(le.Loader2,{className:"h-3 w-3 animate-spin"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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"}),C&&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(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ke)&&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(le.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:nt,children:[Z&&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(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.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:be,type:"file",multiple:!0,onChange:ie=>ft(ie),className:"hidden"},ze),_e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:_e.map((ie,fe)=>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(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ie.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>an(fe),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 ${ie.name}`,children:u.jsx(le.X,{size:12})})]},fe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:ot,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},Ct),He&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),mt&&!He&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:mt}),Le&&!He&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Le})]})]}),ge&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ge}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:L||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var ie;return(ie=be.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var ie;He||(ie=ot.current)==null||ie.click()},className:`cursor-pointer ${He?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(SS,{initialValue:F,editingMessageId:Z,value:Tt,onValueChange:Be,placeholder:Z?"Edit your message...":t,isStreaming:L,disabled:X,onSend:Nt,onCancelEdit:je,onStop:$,allowEmptySend:_e.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Z?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ge?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Mp=1,PT=.9,_T=.8,MT=.17,fl=.1,hl=.999,RT=.9999,OT=.99,DT=/[\\\/_+.#"@\[\(\{&]/,LT=/[\\\/_+.#"@\[\(\{&]/g,$T=/[\s-]/,Rp=/[\s-]/g;function pl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Mp:OT;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=pl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Mp:DT.test(e.charAt(c-1))?(h*=_T,f=e.slice(o,c-1).match(LT),f&&o>0&&(h*=Math.pow(hl,f.length))):$T.test(e.charAt(c-1))?(h*=PT,v=e.slice(o,c-1).match(Rp),v&&o>0&&(h*=Math.pow(hl,v.length))):(h*=MT,o>0&&(h*=Math.pow(hl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=RT)),(h<fl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=pl(e,t,n,r,c+1,s+2,i),m*fl>h&&(h=m*fl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Op(e){return e.toLowerCase().replace(Rp," ")}function FT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,pl(e,t,Op(e),Op(t),0,0,{})}var Io='[cmdk-group=""]',ml='[cmdk-group-items=""]',BT='[cmdk-group-heading=""]',Dp='[cmdk-item=""]',Lp=`${Dp}:not([aria-disabled="true"])`,gl="cmdk-item-select",Or="data-value",zT=(e,t,n)=>FT(e,t,n),$p=p.createContext(void 0),No=()=>p.useContext($p),Fp=p.createContext(void 0),xl=()=>p.useContext(Fp),Bp=p.createContext(void 0),zp=p.forwardRef((e,t)=>{let n=Dr(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Hp(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),S=_t(),k=_t(),C=p.useRef(null),T=ZT();cr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),cr(()=>{T(6,L)},[]);let E=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var J,oe,W,O;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")H(),D(),T(1,B);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(b))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,E.emit()}),G||T(5,L),((oe=a.current)==null?void 0:oe.value)!==void 0){let X=M??"";(O=(W=a.current).onValueChange)==null||O.call(W,X);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),N=p.useMemo(()=>({value:(P,M,G)=>{var J;M!==((J=s.current.get(P))==null?void 0:J.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{D(),E.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{H(),D(),n.current.value||B(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=j();T(4,()=>{H(),(G==null?void 0:G.getAttribute("id"))===P&&B(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,J;let oe=(J=(G=a.current)==null?void 0:G.filter)!=null?J:zT;return P?oe(P,n.current.search,M):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let oe=o.current.get(J),W=0;oe.forEach(O=>{let X=P.get(O);W=Math.max(X,W)}),M.push([J,W])});let G=C.current;K().sort((J,oe)=>{var W,O;let X=J.getAttribute("id"),Z=oe.getAttribute("id");return((W=P.get(Z))!=null?W:0)-((O=P.get(X))!=null?O:0)}).forEach(J=>{let oe=J.closest(ml);oe?oe.appendChild(J.parentElement===oe?J:J.closest(`${ml} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${ml} > *`))}),M.sort((J,oe)=>oe[1]-J[1]).forEach(J=>{var oe;let W=(oe=C.current)==null?void 0:oe.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);W==null||W.parentElement.appendChild(W)})}function B(){let P=K().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(Or);E.setState("value",M||void 0)}function H(){var P,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let W of r.current){let O=(M=(P=s.current.get(W))==null?void 0:P.value)!=null?M:"",X=(J=(G=s.current.get(W))==null?void 0:G.keywords)!=null?J:[],Z=R(O,X);n.current.filtered.items.set(W,Z),Z>0&&oe++}for(let[W,O]of o.current)for(let X of O)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=oe}function L(){var P,M,G;let J=j();J&&(((P=J.parentElement)==null?void 0:P.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(BT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Dp}[aria-selected="true"]`)}function K(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Lp))||[])}function V(P){let M=K()[P];M&&E.setState("value",M.getAttribute(Or))}function $(P){var M;let G=j(),J=K(),oe=J.findIndex(O=>O===G),W=J[oe+P];(M=a.current)!=null&&M.loop&&(W=oe+P<0?J[J.length-1]:oe+P===J.length?J[0]:J[oe+P]),W&&E.setState("value",W.getAttribute(Or))}function _(P){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=P>0?XT(G,Io):JT(G,Io),J=G==null?void 0:G.querySelector(Lp);J?E.setState("value",J.getAttribute(Or)):$(P)}let I=()=>V(K().length-1),q=P=>{P.preventDefault(),P.metaKey?I():P.altKey?_(1):$(1)},Y=P=>{P.preventDefault(),P.metaKey?V(0):P.altKey?_(-1):$(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&q(P);break}case"ArrowDown":{q(P);break}case"p":case"k":{x&&P.ctrlKey&&Y(P);break}case"ArrowUp":{Y(P);break}case"Home":{P.preventDefault(),V(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let J=j();if(J){let oe=new Event(gl);J.dispatchEvent(oe)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:ek},l),Xs(e,P=>p.createElement(Fp.Provider,{value:E},p.createElement($p.Provider,{value:N},P))))}),HT=p.forwardRef((e,t)=>{var n,r;let o=_t(),s=p.useRef(null),i=p.useContext(Bp),a=No(),l=Hp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Up(o,s,[e.value,e.children,s],e.keywords),h=xl(),m=qn(T=>T.value&&T.value===d.current),f=qn(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(gl,v),()=>T.removeEventListener(gl,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:b,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(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)}),UT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=p.useRef(null),l=p.useRef(null),c=_t(),d=No(),h=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Up(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(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(Bp.Provider,{value:m},f))))}),WT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),VT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=xl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.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)}})}),KT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(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(ve.div,{ref:On(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:On(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(Xa,{open:n,onOpenChange:r},p.createElement(Ja,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(zp,{ref:t,...a}))))}),GT=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),YT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.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(zp,{List:KT,Item:HT,Input:VT,Group:UT,Separator:WT,Dialog:qT,Empty:GT,Loading:YT});function XT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function JT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Hp(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=xl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Up(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{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(Or,a),o.current=a}),o}var ZT=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function QT(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(QT(t),{ref:t.ref},n(t.props.children)):n(t)}var ek={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const vl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));vl.displayName=Kt.displayName;const wl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:te("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})]}));wl.displayName=Kt.Input.displayName;const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));bl.displayName=Kt.List.displayName;const yl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));yl.displayName=Kt.Empty.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:te("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}));Sl.displayName=Kt.Group.displayName;const tk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));tk.displayName=Kt.Separator.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:te("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}));Cl.displayName=Kt.Item.displayName;function Tl(e,[t,n]){return Math.min(n,Math.max(t,e))}function nk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var kl="ScrollArea",[Wp,wN]=cn(kl),[rk,sn]=Wp(kl),Vp=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,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,N]=p.useState(!1),R=$e(t,B=>l(B)),D=Xo(o);return u.jsx(rk,{scope:n,type:r,dir:D,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:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:D,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Vp.displayName=kl;var Kp="ScrollAreaViewport",qp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(Kp,n),a=p.useRef(null),l=$e(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(ve.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})})]})});qp.displayName=Kp;var In="ScrollAreaScrollbar",El=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,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(ok,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(sk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Gp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Il,{...r,ref:t}):null});El.displayName=In;var ok=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,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(Gp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),sk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=nk("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(Il,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Gp=p.forwardRef((e,t)=>{const n=sn(In,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 Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Il,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Il=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,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=Qp(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 dk(m,i.current,a,f)}return n==="horizontal"?u.jsx(ik,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=em(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(ak,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=em(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}),ik=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Xp,{"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),nm(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)}})}})}),ak=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Xp,{"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),nm(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)}})}})}),[lk,Yp]=Wp(In),Xp=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(In,n),[v,g]=p.useState(null),x=$e(t,R=>g(R)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=xt(d),T=xt(l),E=ei(h,10);function N(R){if(y.current){const D=R.clientX-y.current.left,B=R.clientY-y.current.top;c({x:D,y:B})}}return p.useEffect(()=>{const R=D=>{const B=D.target;(v==null?void 0:v.contains(B))&&C(D,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(lk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:T,onThumbPointerDown:xt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,R=>{const D=R.target;D.hasPointerCapture(R.pointerId)&&D.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Jp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Yp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(ck,{ref:t,...r})})}),ck=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Yp(Js,n),{onThumbPositionChange:a}=i,l=$e(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=fk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.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:ae(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:ae(e.onPointerUp,i.onThumbPointerUp)})});Jp.displayName=Js;var Nl="ScrollAreaCorner",Zp=p.forwardRef((e,t)=>{const n=sn(Nl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(uk,{...e,ref:t}):null});Zp.displayName=Nl;var uk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(Nl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.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 Qp(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=Qp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function dk(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 tm([l,c],h)(e)}function em(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=Tl(e,l);return tm([0,i],[0,a])(c)}function tm(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 nm(e,t){return e>0&&e<t}var fk=(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=xt(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 Lr(e,t){const n=xt(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 rm=Vp,hk=qp,pk=Zp;const Al=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(rm,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(hk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(om,{}),u.jsx(pk,{})]}));Al.displayName=rm.displayName;const om=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(El,{ref:r,orientation:t,className:te("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(Jp,{className:"relative flex-1 rounded-full bg-border"})}));om.displayName=El.displayName;const jl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("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}));jl.displayName="Input";const mk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",gk="bg-slate-700 border-slate-600 hover:bg-slate-600",xk="bg-slate-600 border-slate-500";function sm({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 b=n===e.threadId,S=t?`${y??xk}`:`${x??gk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${mk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(jl,{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(tt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.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(le.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(tt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(le.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 im=25,am="thread-manager-view",vk=e=>e==="default"||e==="shared",wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(am);if(vk(e))return e}catch{}return null};function lm({defaultView:e}={}){const[t,n]=w.useState(()=>wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(am,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const bk=[{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:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:R,actions:D,shareInFlight:B,shareStatus:H,clearShareStatus:L}=gr(),{createThread:j,deleteThread:K,renameThread:V,shareThread:$}=D,{loadThread:_}=eo(),I=i??T,[q,Y]=w.useState(Array.isArray(k)?k:[]),P=w.useRef(q.length>0),M=w.useRef(null),G=w.useRef(0),[J,oe]=w.useState(null),[W,O]=w.useState(""),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(null),[ce,ge]=w.useState(""),Ce=v&&v.length>0?v:bk,_e=lm({defaultView:m}),De=g??_e,ze=h??De.view,rt=w.useCallback(re=>{h||De.setView(re),f==null||f(re)},[h,f,De]),Ct=Ce.find(re=>re.key===ze)??Ce[0],Ve=re=>{de(re),ge(""),F(!0)},He=()=>{F(!1),de(null),ge(""),L()},Ye=w.useCallback(async re=>{if(!(!ne||B)&&re.id)try{await $(ne,re.id),setTimeout(()=>He(),600)}catch(be){console.error("Failed to share thread:",be)}},[He,B,ne,$]),Le=w.useMemo(()=>{const re=y??[],be=ce.trim().toLowerCase();return be?S?re.filter(ot=>S(ot,be)):re.filter(ot=>`${ot.label} ${ot.secondaryLabel??""}`.toLowerCase().includes(be)):re},[y,ce,S]),Ue=ze==="shared",mt=Ue?C:q,Dt=Ue?R:N,at=Ue?"No shared conversations yet":"No conversations yet",At=re=>{const be=re.sharedAt?` • ${Ee(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${be}`},wt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){P.current=!0,Y(re);return}N||(P.current=!1,Y(re))},[k,N]),w.useEffect(()=>{if(!M.current)return;const re=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let be=null,ot=null;return be=requestAnimationFrame(()=>{ot=requestAnimationFrame(()=>{re.scrollTop=G.current})}),()=>{be!==null&&cancelAnimationFrame(be),ot!==null&&cancelAnimationFrame(ot)}},[q]);const ut=async re=>{try{E(re),await _(re),a==null||a(re),l==null||l(re)}catch(be){console.error("Failed to select thread:",be)}},bt=async()=>{try{Z(!0);const re=await j();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{Z(!1)}},Tt=async(re,be)=>{if(be.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const ot=M.current.querySelector("[data-radix-scroll-area-viewport]");ot&&(G.current=ot.scrollTop)}try{await K(re),d==null||d(re)}catch(ot){console.error("Failed to delete thread:",ot)}}},jt=(re,be)=>{be.stopPropagation(),oe(re.threadId),O(re.title||`Thread ${re.threadId.slice(0,8)}`)},Te=async re=>{if(W.trim())try{await V(re,W.trim()),oe(null),O("")}catch(be){console.error("Failed to update title:",be)}},qe=()=>{oe(null),O("")},Ee=re=>{if(!re)return"";try{const be=new Date(re),xe=new Date().getTime()-be.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?be.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:be.toLocaleDateString()}catch{return""}},Ke=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,zt=re=>{const be=Ke(re);return be.length<=im?be:`${be.slice(0,im)}...`};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(tt,{onClick:bt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(le.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(tt,{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:Ct.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(re=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:be=>{be.preventDefault(),rt(re.key)},children:[u.jsx("span",{children:re.label}),ze===re.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(Al,{ref:M,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(le.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(le.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:at})]}):mt.slice().sort((re,be)=>new Date(be.updatedAt||be.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(sm,{thread:re,isActive:I===re.threadId,editingThreadId:J,editingTitle:W,onSelect:ut,onStartEditing:jt,onEditingTitleChange:be=>O(be),onSaveEditing:Te,onCancelEditing:qe,onShare:()=>Ve(re.threadId),onDelete:Tt,showEditTitle:r,showDeleteButton:n,formatDate:Ee,getDisplayThreadTitle:zt,secondaryLine:Ue&&wt(re)?At(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Za,{open:ue,onOpenChange:re=>!re&&He(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(vl,{children:[u.jsx(wl,{autoFocus:!0,value:ce,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(bl,{children:[H&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[B&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:H.startsWith("Failed")?"text-red-500":H.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:H})]}),u.jsx(yl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Le.length>0&&u.jsx(Sl,{heading:"Recipients",children:Le.map(re=>u.jsx(Cl,{onSelect:()=>Ye(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 yk({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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...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(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...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(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Sk({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function Ck({placeholder:e,onMessageSent:t}){const[n,r]=w.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(le.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(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Rr,{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 Tk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(vr,{...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(tt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(tt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(tt,{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(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ck,{placeholder:t,onMessageSent:r})})]})})}):null}function kk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(tt,{variant:r,size:o,className:te("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Ek="Label",cm=p.forwardRef((e,t)=>u.jsx(ve.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())}}));cm.displayName=Ek;var um=cm;const Ik=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),dm=p.forwardRef(({className:e,...t},n)=>u.jsx(um,{ref:n,className:te(Ik(),e),...t}));dm.displayName=um.displayName;function fm(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 hm=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"}),Nk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...hm,...e.style}}));ni.displayName=Nk;var Ak=ni,jk=[" ","Enter","ArrowUp","ArrowDown"],Pk=[" ","Enter"],ur="Select",[ri,oi,_k]=Yo(ur),[$r,bN]=cn(ur,[_k,kr]),si=kr(),[Mk,Gn]=$r(ur),[Rk,Ok]=$r(ur),pm=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),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,D]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),B=p.useRef(null),H=x?v||!!x.closest("form"):!0,[L,j]=p.useState(new Set),K=Array.from(L).map(V=>V.props.value).join(";");return u.jsx(ra,{...g,children:u.jsxs(Mk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:_t(),value:R,onValueChange:D,open:E,onOpenChange:N,dir:T,triggerPointerDownPosRef:B,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(Rk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(V=>{j($=>new Set($).add(V))},[]),onNativeOptionRemove:p.useCallback(V=>{j($=>{const _=new Set($);return _.delete(V),_})},[]),children:n})}),H?u.jsxs($m,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:V=>D(V.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(L)]},K):null]})})};pm.displayName=ur;var mm="SelectTrigger",gm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(mm,n),a=i.disabled||r,l=$e(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=Bm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=zm(x,g,y);b!==void 0&&i.onValueChange(b.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(oa,{asChild:!0,...s,children:u.jsx(ve.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":Fm(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(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:ae(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&jk.includes(g.key)&&(v(),g.preventDefault())})})})});gm.displayName=mm;var xm="SelectValue",vm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(xm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=$e(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Fm(l.value)?u.jsx(u.Fragment,{children:i}):s})});vm.displayName=xm;var Dk="SelectIcon",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wm.displayName=Dk;var Lk="SelectPortal",bm=e=>u.jsx(so,{asChild:!0,...e});bm.displayName=Lk;var dr="SelectContent",ym=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Sm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Cm,{...e,ref:t})});ym.displayName=dr;var mn=10,[Sm,Yn]=$r(dr),$k="SelectContentImpl",Fk=Yt.createSlot("SelectContent.RemoveScroll"),Cm=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,b=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=$e(t,W=>k(W)),[N,R]=p.useState(null),[D,B]=p.useState(null),H=oi(n),[L,j]=p.useState(!1),K=p.useRef(!1);p.useEffect(()=>{if(S)return ua(S)},[S]),zi();const V=p.useCallback(W=>{const[O,...X]=H().map(F=>F.ref.current),[Z]=X.slice(-1),ue=document.activeElement;for(const F of W)if(F===ue||(F==null||F.scrollIntoView({block:"nearest"}),F===O&&C&&(C.scrollTop=0),F===Z&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==ue))return},[H,C]),$=p.useCallback(()=>V([N,S]),[V,N,S]);p.useEffect(()=>{L&&$()},[L,$]);const{onOpenChange:_,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let W={x:0,y:0};const O=Z=>{var ue,F;W={x:Math.abs(Math.round(Z.pageX)-(((ue=I.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((F=I.current)==null?void 0:F.y)??0))}},X=Z=>{W.x<=10&&W.y<=10?Z.preventDefault():S.contains(Z.target)||_(!1),document.removeEventListener("pointermove",O),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,_,I]),p.useEffect(()=>{const W=()=>_(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[_]);const[q,Y]=Bm(W=>{const O=H().filter(ue=>!ue.disabled),X=O.find(ue=>ue.ref.current===document.activeElement),Z=zm(O,W,X);Z&&setTimeout(()=>Z.ref.current.focus())}),P=p.useCallback((W,O,X)=>{const Z=!K.current&&!X;(b.value!==void 0&&b.value===O||Z)&&(R(W),Z&&(K.current=!0))},[b.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((W,O,X)=>{const Z=!K.current&&!X;(b.value!==void 0&&b.value===O||Z)&&B(W)},[b.value]),J=r==="popper"?Pl:Tm,oe=J===Pl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Sm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:$,selectedItemText:D,position:r,isPositioned:L,searchRef:q,children:u.jsx(gs,{as:Fk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ae(o,W=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:W=>W.preventDefault(),...y,...oe,onPlaced:()=>j(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,W=>{const O=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!O&&W.key.length===1&&Y(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let Z=H().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(W.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const ue=W.target,F=Z.indexOf(ue);Z=Z.slice(F+1)}setTimeout(()=>V(Z)),W.preventDefault()}})})})})})})});Cm.displayName=$k;var Bk="SelectItemAlignedPosition",Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=$e(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const ue=D.left-N.left,F=R.left-ue,ne=E.left-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=Tl(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.left=Ce+"px"}else{const ue=N.right-D.right,F=window.innerWidth-R.right-ue,ne=window.innerWidth-E.right-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=Tl(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.right=Ce+"px"}const B=m(),H=window.innerHeight-mn*2,L=g.scrollHeight,j=window.getComputedStyle(c),K=parseInt(j.borderTopWidth,10),V=parseInt(j.paddingTop,10),$=parseInt(j.borderBottomWidth,10),_=parseInt(j.paddingBottom,10),I=K+V+L+_+$,q=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),P=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=E.top+E.height/2-mn,J=H-G,oe=x.offsetHeight/2,W=x.offsetTop+oe,O=K+V+W,X=I-O;if(O<=G){const ue=B.length>0&&x===B[B.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,ne=Math.max(J,oe+(ue?M:0)+F+$),de=O+ne;a.style.height=de+"px"}else{const ue=B.length>0&&x===B[0].ref.current;a.style.top="0px";const ne=Math.max(G,K+g.offsetTop+(ue?P:0)+oe)+X;a.style.height=ne+"px",g.scrollTop=O-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=H+"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(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Hk,{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(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Tm.displayName=Bk;var zk="SelectPopperPosition",Pl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(sa,{...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)"}})});Pl.displayName=zk;var[Hk,_l]=$r(dr,{}),Ml="SelectViewport",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ml,n),i=_l(Ml,n),a=$e(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(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(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-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-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})})})]})});km.displayName=Ml;var Em="SelectGroup",[Uk,Wk]=$r(Em),Vk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(Uk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Vk.displayName=Em;var Im="SelectLabel",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Wk(Im,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Nm.displayName=Im;var ii="SelectItem",[Kk,Am]=$r(ii),jm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=$e(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=_t(),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(Kk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.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:ae(i.onFocus,()=>f(!0)),onBlur:ae(i.onBlur,()=>f(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Pk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});jm.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=Am(Ao,n),c=Ok(Ao,n),[d,h]=p.useState(null),m=$e(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.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(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var _m="SelectItemIndicator",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Am(_m,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Mm.displayName=_m;var Rl="SelectScrollUpButton",Rm=p.forwardRef((e,t)=>{const n=Yn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(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(Dm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Rm.displayName=Rl;var Ol="SelectScrollDownButton",Om=p.forwardRef((e,t)=>{const n=Yn(Ol,e.__scopeSelect),r=_l(Ol,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(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(Dm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Om.displayName=Ol;var Dm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("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(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),qk="SelectSeparator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});Lm.displayName=qk;var Dl="SelectArrow",Gk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn(Dl,n),i=Yn(Dl,n);return s.open&&i.position==="popper"?u.jsx(ia,{...o,...r,ref:t}):null});Gk.displayName=Dl;var Yk="SelectBubbleInput",$m=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=$e(r,o),i=fm(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(ve.select,{...n,style:{...hm,...n.style},ref:s,defaultValue:t})});$m.displayName=Yk;function Fm(e){return e===""||e===void 0}function Bm(e){const t=xt(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 zm(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=Xk(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 Xk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Jk=pm,Hm=gm,Zk=vm,Qk=wm,eE=bm,Um=ym,tE=km,Wm=Nm,Vm=jm,nE=Pm,rE=Mm,Km=Rm,qm=Om,Gm=Lm;const oE=Jk,sE=Zk,Ym=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hm,{ref:r,className:te("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(Qk,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ym.displayName=Hm.displayName;const Xm=p.forwardRef(({className:e,...t},n)=>u.jsx(Km,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));Xm.displayName=Km.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(eE,{children:u.jsxs(Um,{ref:o,className:te("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(Xm,{}),u.jsx(tE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Jm,{})]})}));Zm.displayName=Um.displayName;const iE=p.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));iE.displayName=Wm.displayName;const Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Vm,{ref:r,className:te("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(rE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(nE,{children:t})]}));Qm.displayName=Vm.displayName;const aE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));aE.displayName=Gm.displayName;var lE="Separator",eg="horizontal",cE=["horizontal","vertical"],tg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=eg,...o}=e,s=uE(r)?r:eg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});tg.displayName=lE;function uE(e){return cE.includes(e)}var ng=tg;const rg=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ng,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));rg.displayName=ng.displayName;var ai="Switch",[dE,yN]=cn(ai),[fE,hE]=dE(ai),og=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=$e(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(fE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":lg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(ag,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});og.displayName=ai;var sg="SwitchThumb",ig=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=hE(sg,n);return u.jsx(ve.span,{"data-state":lg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ig.displayName=sg;var pE="SwitchBubbleInput",ag=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=$e(i,s),l=fm(n),c=xd(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}})});ag.displayName=pE;function lg(e){return e?"checked":"unchecked"}var cg=og,mE=ig;const ug=p.forwardRef(({className:e,...t},n)=>u.jsx(cg,{className:te("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(mE,{className:te("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")})}));ug.displayName=cg.displayName;const gE=Xa,xE=rT,vE=Ja,dg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:te("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}));dg.displayName=To.displayName;const wE=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"}}),fg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(vE,{children:[u.jsx(dg,{}),u.jsxs(ko,{ref:o,className:te(wE({side:e}),t),...r,children:[n,u.jsxs(rp,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fg.displayName=ko.displayName;const hg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});hg.displayName="SheetHeader";const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));pg.displayName=ar.displayName;const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));mg.displayName=Fs.displayName;var[li,SN]=cn("Tooltip",[kr]),ci=kr(),gg="TooltipProvider",bE=700,Ll="tooltip.open",[yE,$l]=li(gg),xg=e=>{const{__scopeTooltip:t,delayDuration:n=bE,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(yE,{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})};xg.displayName=gg;var jo="Tooltip",[SE,ui]=li(jo),vg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=$l(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=_t(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ll))):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,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ra,{...c,children:u.jsx(SE,{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})})};vg.displayName=jo;var Fl="TooltipTrigger",wg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(Fl,n),s=$l(Fl,n),i=ci(n),a=p.useRef(null),l=$e(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(oa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});wg.displayName=Fl;var CE="TooltipPortal",[CN,TE]=li(CE,{forceMount:void 0}),Fr="TooltipContent",bg=p.forwardRef((e,t)=>{const n=TE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(yg,{side:o,...s,ref:t}):u.jsx(kE,{side:o,...s,ref:t})})}),kE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=$l(Fr,e.__scopeTooltip),o=p.useRef(null),s=$e(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},b=jE(y,x.getBoundingClientRect()),S=PE(y,b),k=_E(g.getBoundingClientRect()),C=RE([...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},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!ME(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(yg,{...e,ref:s})}),[EE,IE]=li(jo,{isInside:!1}),NE=Yt.createSlottable("TooltipContent"),yg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Ll,d),()=>document.removeEventListener(Ll,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(br,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(sa,{"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(NE,{children:r}),u.jsx(EE,{scope:n,isInside:!0,children:u.jsx(Ak,{id:l.contentId,role:"tooltip",children:o||r})})]})})});bg.displayName=Fr;var Sg="TooltipArrow",AE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return IE(Sg,n).isInside?null:u.jsx(ia,{...o,...r,ref:t})});AE.displayName=Sg;function jE(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 PE(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 ME(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 RE(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),OE(t)}function OE(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 DE=xg,LE=vg,$E=wg,Cg=bg;const FE=DE,BE=LE,zE=$E,Tg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Cg,{ref:r,sideOffset:t,className:te("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}));Tg.displayName=Cg.displayName;var Bl="ToastProvider",[zl,HE,UE]=Yo("Toast"),[kg,TN]=cn("Toast",[UE]),[WE,di]=kg(Bl),Eg=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 \`${Bl}\`. Expected non-empty \`string\`.`),u.jsx(zl.Provider,{scope:t,children:u.jsx(WE,{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})})};Eg.displayName=Bl;var Ig="ToastViewport",VE=["F8"],Hl="toast.viewportPause",Ul="toast.viewportResume",Ng=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=VE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ig,n),a=HE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=$e(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 b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Hl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Ul);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...oI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(C=c.current)==null||C.focus();return}const H=g({tabbingDirection:R?"backwards":"forwards"}),L=H.findIndex(j=>j===N);Kl(H.slice(L+1))?b.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(Pw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Wl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Kl(x)}}),u.jsx(zl.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Wl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Kl(x)}})]})});Ng.displayName=Ig;var Ag="ToastFocusProxy",Wl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(Ag,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()}})});Wl.displayName=Ag;var Po="Toast",KE="toast.swipeStart",qE="toast.swipeMove",GE="toast.swipeCancel",YE="toast.swipeEnd",jg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:Po});return u.jsx(Wt,{present:n||a,children:u.jsx(ZE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(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:ae(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:ae(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)})})})});jg.displayName=Po;var[XE,JE]=kg(Po,{onClose(){}}),ZE=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(Po,n),[x,y]=p.useState(null),b=$e(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:D}=g,B=xt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),H=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout(B,j))},[B]);p.useEffect(()=>{const j=g.viewport;if(j){const K=()=>{H(E.current),c==null||c()},V=()=>{const $=new Date().getTime()-T.current;E.current=E.current-$,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Hl,V),j.addEventListener(Ul,K),()=>{j.removeEventListener(Hl,V),j.removeEventListener(Ul,K)}}},[g.viewport,C,l,c,H]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&H(C)},[s,C,g.isClosePausedRef,H]),p.useEffect(()=>(R(),()=>D()),[R,D]);const L=p.useMemo(()=>x?Lg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[L&&u.jsx(QE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:L}),u.jsx(XE,{scope:n,onClose:B,children:Hr.createPortal(u.jsx(zl.ItemSlot,{scope:n,children:u.jsx(jw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||B(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,B()))}),onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ae(e.onPointerMove,j=>{if(!S.current)return;const K=j.clientX-S.current.x,V=j.clientY-S.current.y,$=!!k.current,_=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=_?I(0,K):0,Y=_?0:I(0,V),P=j.pointerType==="touch"?10:2,M={x:q,y:Y},G={originalEvent:j,delta:M};$?(k.current=M,fi(qE,h,G,{discrete:!1})):$g(M,g.swipeDirection,P)?(k.current=M,fi(KE,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(K)>P||Math.abs(V)>P)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,j=>{const K=k.current,V=j.target;if(V.hasPointerCapture(j.pointerId)&&V.releasePointerCapture(j.pointerId),k.current=null,S.current=null,K){const $=j.currentTarget,_={originalEvent:j,delta:K};$g(K,g.swipeDirection,g.swipeThreshold)?fi(YE,f,_,{discrete:!0}):fi(GE,m,_,{discrete:!0}),$.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),QE=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(Po,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return nI(()=>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]})})})},eI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=eI;var tI="ToastDescription",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});_g.displayName=tI;var Mg="ToastAction",Rg=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Dg,{altText:n,asChild:!0,children:u.jsx(Vl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Mg}\`. Expected non-empty \`string\`.`),null)});Rg.displayName=Mg;var Og="ToastClose",Vl=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=JE(Og,n);return u.jsx(Dg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Vl.displayName=Og;var Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Lg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),rI(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(...Lg(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?$i(o,s):o.dispatchEvent(s)}var $g=(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 nI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function rI(e){return e.nodeType===e.ELEMENT_NODE}function oI(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 Kl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var sI=Eg,Fg=Ng,Bg=jg,zg=Pg,Hg=_g,Ug=Rg,Wg=Vl;const iI=sI,Vg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Vg.displayName=Fg.displayName;const aI=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"}}),Kg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Bg,{ref:r,className:te(aI({variant:t}),e),...n}));Kg.displayName=Bg.displayName;const lI=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("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}));lI.displayName=Ug.displayName;const qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:te("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(le.X,{className:"h-4 w-4"})}));qg.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:te("text-sm font-semibold",e),...t}));Gg.displayName=zg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:te("text-sm opacity-90",e),...t}));Yg.displayName=Hg.displayName;function cI(){const{toasts:e}=tl();return u.jsxs(iI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Kg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Gg,{children:n}),r&&u.jsx(Yg,{children:r})]}),o,u.jsx(qg,{})]},t)}),u.jsx(Vg,{})]})}var uI=(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{}},dI=p.createContext(void 0),fI={setTheme:e=>{},themes:[]},hI=()=>{var e;return(e=p.useContext(dI))!=null?e:fI};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:`(${uI.toString()})(${d})`}})});var pI=e=>{switch(e){case"success":return xI;case"info":return wI;case"warning":return vI;case"error":return bI;default:return null}},mI=Array(12).fill(0),gI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},mI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),xI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),vI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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"})),wI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),bI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),yI=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),SI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},ql=1,CI=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:ql++,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],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(kI(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)||ql++;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 CI,TI=(e,t)=>{let n=(t==null?void 0:t.id)||ql++;return qt.addToast({title:e,...t,id:n}),n},kI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",EI=TI,II=()=>qt.toasts,NI=()=>qt.getActiveToasts();Object.assign(EI,{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:II,getToasts:NI});function AI(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))}AI(`: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 jI=3,PI="32px",_I="16px",Xg=4e3,MI=356,RI=14,OI=20,DI=200;function gn(...e){return e.filter(Boolean).join(" ")}function LI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var $I=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:b,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:N,style:R,cancelButtonStyle:D,actionButtonStyle:B,className:H="",descriptionClassName:L="",duration:j,position:K,gap:V,loadingIcon:$,expandByDefault:_,classNames:I,icons:q,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:P}=e,[M,G]=w.useState(null),[J,oe]=w.useState(null),[W,O]=w.useState(!1),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(!1),[ce,ge]=w.useState(!1),[Ce,_e]=w.useState(0),[De,ze]=w.useState(0),rt=w.useRef(f.duration||j||Xg),Ct=w.useRef(null),Ve=w.useRef(null),He=S===0,Ye=S+1<=y,Le=f.type,Ue=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(xe=>xe.toastId===f.id)||0,[b,f.id]),At=w.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:N},[f.closeButton,N]),wt=w.useMemo(()=>f.duration||j||Xg,[f.duration,j]),ut=w.useRef(0),bt=w.useRef(0),Tt=w.useRef(0),jt=w.useRef(null),[Te,qe]=K.split("-"),Ee=w.useMemo(()=>b.reduce((xe,Be,Xe)=>Xe>=at?xe:xe+Be.height,0),[b,at]),Ke=SI(),zt=f.invert||m,re=Le==="loading";bt.current=w.useMemo(()=>at*V+Ee,[at,Ee]),w.useEffect(()=>{rt.current=wt},[wt]),w.useEffect(()=>{O(!0)},[]),w.useEffect(()=>{let xe=Ve.current;if(xe){let Be=xe.getBoundingClientRect().height;return ze(Be),x(Xe=>[{toastId:f.id,height:Be,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(kt=>kt.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!W)return;let xe=Ve.current,Be=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Be,ze(Xe),x(kt=>kt.find(Et=>Et.toastId===f.id)?kt.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...kt])},[W,f.title,f.description,x,f.id]);let be=w.useCallback(()=>{Z(!0),_e(bt.current),x(xe=>xe.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{T(f)},DI)},[f,T,x,bt]);w.useEffect(()=>{if(f.promise&&Le==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||P&&Ke?(()=>{if(Tt.current<ut.current){let Be=new Date().getTime()-ut.current;rt.current=rt.current-Be}Tt.current=new Date().getTime()})():rt.current!==1/0&&(ut.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=f.onAutoClose)==null||Be.call(f,f),be()},rt.current)),()=>clearTimeout(xe)},[C,g,f,Le,P,Ke,be]),w.useEffect(()=>{f.delete&&be()},[be,f.delete]);function ot(){var xe,Be,Xe;return q!=null&&q.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Le==="loading"},q.loading):$?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Le==="loading"},$):w.createElement(gI,{className:gn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ve,className:gn(H,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[Le],(n=f==null?void 0:f.classNames)==null?void 0:n[Le]),"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":ce,"data-removed":X,"data-visible":Ye,"data-y-position":Te,"data-x-position":qe,"data-index":S,"data-front":He,"data-swiping":ue,"data-dismissible":Ue,"data-type":Le,"data-invert":zt,"data-swipe-out":ne,"data-swipe-direction":J,"data-expanded":!!(C||_&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ce:bt.current}px`,"--initial-height":_?"auto":`${De}px`,...R,...f.style},onDragEnd:()=>{F(!1),G(null),jt.current=null},onPointerDown:xe=>{re||!Ue||(Ct.current=new Date,_e(bt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(F(!0),jt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Xe,kt;if(ne||!Ue)return;jt.current=null;let Et=Number(((xe=Ve.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Be=Ve.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Xe=Ct.current)==null?void 0:Xe.getTime()),je=M==="x"?Et:Nt,ht=Math.abs(je)/Lt;if(Math.abs(je)>=OI||ht>.11){_e(bt.current),(kt=f.onDismiss)==null||kt.call(f,f),oe(M==="x"?Et>0?"right":"left":Nt>0?"down":"up"),be(),de(!0),ge(!1);return}F(!1),G(null)},onPointerMove:xe=>{var Be,Xe,kt,Et;if(!jt.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let Nt=xe.clientY-jt.current.y,Lt=xe.clientX-jt.current.x,je=(Xe=e.swipeDirections)!=null?Xe:LI(K);!M&&(Math.abs(Lt)>1||Math.abs(Nt)>1)&&G(Math.abs(Lt)>Math.abs(Nt)?"x":"y");let ht={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&Nt<0||je.includes("bottom")&&Nt>0)&&(ht.y=Nt):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(ht.x=Lt),(Math.abs(ht.x)>0||Math.abs(ht.y)>0)&&ge(!0),(kt=Ve.current)==null||kt.style.setProperty("--swipe-amount-x",`${ht.x}px`),(Et=Ve.current)==null||Et.style.setProperty("--swipe-amount-y",`${ht.y}px`)}},At&&!f.jsx?w.createElement("button",{"aria-label":Y,"data-disabled":re,"data-close-button":!0,onClick:re||!Ue?()=>{}:()=>{var xe;be(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:yI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,Le||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(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||ot():null,f.type!=="loading"?f.icon||(q==null?void 0:q[Le])||pI(Le):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(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?w.createElement("div",{"data-description":"",className:gn(L,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),w.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||D,onClick:xe=>{var Be,Xe;hi(f.cancel)&&Ue&&((Xe=(Be=f.cancel).onClick)==null||Xe.call(Be,xe),be())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&hi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||B,onClick:xe=>{var Be,Xe;hi(f.action)&&((Xe=(Be=f.action).onClick)==null||Xe.call(Be,xe),!xe.defaultPrevented&&be())},className:gn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Jg(){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 FI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?_I:PI;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 BI=w.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=jI,toastOptions:g,dir:x=Jg(),gap:y=RI,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),N=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,D]=w.useState([]),[B,H]=w.useState(!1),[L,j]=w.useState(!1),[K,V]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=w.useRef(null),_=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),q=w.useRef(!1),Y=w.useCallback(P=>{E(M=>{var G;return(G=M.find(J=>J.id===P.id))!=null&&G.delete||qt.dismiss(P.id),M.filter(({id:J})=>J!==P.id)})},[]);return w.useEffect(()=>qt.subscribe(P=>{if(P.dismiss){E(M=>M.map(G=>G.id===P.id?{...G,delete:!0}:G));return}setTimeout(()=>{_o.flushSync(()=>{E(M=>{let G=M.findIndex(J=>J.id===P.id);return G!==-1?[...M.slice(0,G),{...M[G],...P},...M.slice(G+1)]:[P,...M]})})})}),[]),w.useEffect(()=>{if(d!=="system"){V(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?V("dark"):V("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:M})=>{V(M?"dark":"light")})}catch{P.addListener(({matches:G})=>{try{V(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),w.useEffect(()=>{T.length<=1&&H(!1)},[T]),w.useEffect(()=>{let P=M=>{var G,J;o.every(oe=>M[oe]||M.code===oe)&&(H(!0),(G=$.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===$.current||(J=$.current)!=null&&J.contains(document.activeElement))&&H(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),w.useEffect(()=>{if($.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[$.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((P,M)=>{var G;let[J,oe]=P.split("-");return T.length?w.createElement("ol",{key:P,dir:x==="auto"?Jg():x,tabIndex:-1,ref:$,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":J,"data-lifted":B&&T.length>1&&!s,"data-x-position":oe,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${MI}px`,"--gap":`${y}px`,...f,...FI(l,c)},onBlur:W=>{q.current&&!W.currentTarget.contains(W.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=W.relatedTarget)},onMouseEnter:()=>H(!0),onMouseMove:()=>H(!0),onMouseLeave:()=>{L||H(!1)},onDragEnd:()=>H(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(W=>!W.position&&M===0||W.position===P).map((W,O)=>{var X,Z;return w.createElement($I,{key:W.id,icons:S,index:O,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:L,position:P,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:Y,toasts:T.filter(ue=>ue.position==W.position),heights:R.filter(ue=>ue.position==W.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:b,expanded:B,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const zI=({...e})=>{const{theme:t="system"}=hI();return u.jsx(BI,{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})};z.Api=Rv,z.ApiClient=Mv,z.ApiProvider=Qc,z.ArtifactRenderer=Sp,z.Badge=Bh,z.Button=tt,z.Card=ol,z.CardContent=ll,z.CardDescription=al,z.CardHeader=sl,z.CardTitle=il,z.ChatApi=Ko,z.ChatApp=yk,z.ChatInput=zf,z.ChatInterface=Rr,z.ChatProviders=vr,z.ChatWidget=Tk,z.Command=vl,z.CommandEmpty=yl,z.CommandGroup=Sl,z.CommandInput=wl,z.CommandItem=Cl,z.CommandList=bl,z.DEFAULT_TIMEOUT_MS=qc,z.Dialog=Za,z.DialogContent=Bs,z.DialogHeader=zs,z.DialogTitle=Hs,z.DropdownMenu=Ss,z.DropdownMenuContent=ho,z.DropdownMenuItem=Bn,z.DropdownMenuTrigger=Cs,z.FileViewerModal=ip,z.HISTORY_TIMEOUT_MS=Gc,z.Input=jl,z.InterruptPartRenderer=Tp,z.Label=dm,z.MarkdownContent=Mr,z.MessageBody=Ap,z.MessageComponent=Ys,z.MessageList=dl,z.MessageRow=ul,z.NewChatButton=kk,z.PlotArtifact=bp,z.ResearchTaskArtifact=yp,z.SETTINGS_STORAGE_KEY=Li,z.ScrollArea=Al,z.Select=oE,z.SelectContent=Zm,z.SelectItem=Qm,z.SelectTrigger=Ym,z.SelectValue=sE,z.Separator=rg,z.Sheet=gE,z.SheetContent=fg,z.SheetDescription=mg,z.SheetHeader=hg,z.SheetTitle=pg,z.SheetTrigger=xE,z.SimpleChat=Sk,z.SimpleJsonView=kp,z.Sonner=zI,z.StreamProgress=Ep,z.Switch=ug,z.Textarea=Ca,z.ThinkingIndicator=Np,z.ThreadListItem=sm,z.ThreadManager=ti,z.ThreadStateProvider=Cu,z.ThreadsProvider=uu,z.TimelineColumn=ux,z.Toaster=cI,z.ToolComponent=Ip,z.Tooltip=BE,z.TooltipContent=Tg,z.TooltipProvider=FE,z.TooltipTrigger=zE,z.UserTextContent=AT,z.applySettings=pw,z.buildCheckpointIndex=Jl,z.buildCheckpointPreviewMap=rx,z.chatApiClient=Rn,z.del=Ai,z.downloadFileById=Xc,z.extractConfigFields=mi,z.fileToBase64=eu,z.get=Jt,z.getChatToken=Vc,z.getCheckpointForMessage=ox,z.getCurrentSettings=hw,z.getDefaultApiConfig=_u,z.getDefaultChatSettings=Mu,z.getFileContent=Pi,z.getFileInfo=Dv,z.getMessageAttemptInfo=Zl,z.getMessageDomKey=cl,z.getPreviewForMessage=pi,z.httpClient=Xt,z.hydrateHistorySnapshots=Mn,z.isEnvelope=nu,z.listFiles=Jc,z.loadStoredSettings=Ru,z.onChatTokenChanged=Kc,z.post=Vo,z.processAttachments=tu,z.put=Yc,z.readNumber=ec,z.readString=_n,z.resolveChatBaseUrl=vn,z.saveSettings=Ou,z.setChatToken=Wo,z.toPlainObject=Pn,z.unwrap=$t,z.useApi=Xr,z.useCheckpointIndex=Ql,z.useFilePreview=jp,z.useHasChatSession=uw,z.useParsedMessageContent=Pp,z.useShallowStableValue=Nu,z.useStream=Di,z.useStreamingHook=Di,z.useThreadHistoryState=wu,z.useThreadManagerViewState=lm,z.useThreadState=eo,z.useThreadStateUpdater=Su,z.useThreads=gr,z.useThreadsState=lu,z.viewFileById=Ov,Object.defineProperty(z,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=hp(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=hp(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 vp{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 wp{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 Kn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vp,this.slugger=new wp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,b,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,fp(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(h="",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(h+=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(h,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++)b=f.items[s],S=b.checked,k=b.task,y="",b.task&&(C=this.renderer.checkbox(S),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.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 N='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}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||lr}preprocess(t){return t}postprocess(t){return t}}Qg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function PT(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 bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=PT(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(AT(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&&ye.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;ye.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(ye.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&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},gT(ye.defaults),ye},ye.getDefaults=lp,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.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=ye.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=ye.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=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.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=ye.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}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=vp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=wp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Mr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.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 ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(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=w.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:te("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]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(le.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(le.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(le.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(le.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(le.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(le.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(Mr,{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(le.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=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nw(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:te("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:te("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:te("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:te("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("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=xr(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:te("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(tt,{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(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="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:MT,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:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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(le.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 Ip({message:e,viewMode:t,isStreaming:n=!1}){const o=Ri(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Mi(l)??l:l;if(c&&typeof c=="object")return u.jsx(ul,{data:c});const d=typeof c=="string"?c:(()=>{try{return xr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Yv(l);return d?u.jsx(Mr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(h=>h.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Qr(m);return i(f)}const c=Zr(l),d=Qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ap({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:te("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:te("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(tt,{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(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function jp({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:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:N,activeInterruptValue:R,iconForeground:L}){const z=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=w.useCallback(({part:j,i:W})=>{if(j.type==="text"){const $=j.text??"",O=$.trim(),P=Mi(O);return P&&b!=="tool"?u.jsx(ul,{data:P},W):b==="user"&&S&&O.length>k?u.jsx(Ap,{text:O,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},W):u.jsx(Mr,{content:$,allowHtml:!1},W)}if(j.type==="image_url"){const $=j;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"})},W)}if(j.type==="file"){const $=j,O=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,W),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[W]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[O,v[W]?" (processing)":""]})]},W)}if(j.type==="interrupt"){const $=j,O=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(N&&O&&O===N),I=P?R??($==null?void 0:$.value):$==null?void 0:$.value,q=O?{...$,id:O,interrupt_id:O}:$;return u.jsx(kp,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},W)}return null},[f,v,g,x,b,S,k,C,E,N,R,y]),U=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return z();if(!t&&!U&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const j=u.jsx("div",{className:"space-y-2",children:i.map((W,$)=>u.jsx(V,{part:W,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[j,u.jsx(Np,{className:L})]}):j}return null}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),S=b.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(b.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(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(e,t){return w.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:Xv(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:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=w.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:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[R,L]=w.useState(!1),[z,V]=w.useState("preview"),[U,j]=w.useState(!1),{currentThreadId:W}=gr(),{respondToInterrupt:$}=eo(),O=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",q=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),Y=!!q,_=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:G,fileViewerOpen:J,currentFileInfo:oe,closeFileViewer:K}=_p({allowFileOpen:_,currentThreadId:W}),D=w.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=Pp(t,q),{contentParts:Z,imageParts:ue,fileParts:F,interruptParts:ne,textContent:de,toolMeta:ce,toolRaw:ge,isToolStreaming:Ce}=X,Pe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),De=Go(Pe),ze=y==null?void 0:y.value,rt=w.useMemo(()=>q||!m?null:t.artifact||null,[q,t,m]),Ct=w.useCallback(async()=>{const Te=I?ge:de;async function qe(Ee){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ee);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ke=new Blob([Ee],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ke})]);return}throw new Error("Clipboard API not supported in this context.")}try{await qe(Te),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(Te)}catch(Ee){console.error("Failed to copy:",Ee)}},[I,ge,de,x]),Ve=w.useCallback(()=>{if(!v||!t.id)return;const Te=(I?ge:de)??"",qe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,Te,qe)},[v,t.id,I,ge,de,t]),He=w.useCallback(()=>{g==null||g(n)},[g,n]),Ye=w.useCallback(()=>{const qe=te(O?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(le.User,{className:qe});case"assistant":return u.jsx(le.Bot,{className:qe});case"tool":return u.jsx(le.Wrench,{className:qe});default:return u.jsx(le.Bot,{className:qe})}},[O,D,P]),Le=w.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(P){case"user":return te(Te,"justify-end");case"assistant":case"tool":case"system":return te(Te,"justify-start");default:return Te}},[P]),Ue=w.useCallback(()=>{const Te=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",O&&"px-3 py-2 text-sm");if(Y)return te(Te,"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 te(Te,"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 te(Te,"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 te(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Te,"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")}},[O,Y,P]),mt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!0)}catch(Ee){console.error("Failed to approve interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),Dt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!1)}catch(Ee){console.error("Failed to reject interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),at=w.useMemo(()=>q?"Assistant":Zv(t),[q,t]),At=P==="user"&&(C??1)>1&&typeof E=="function",wt=(N==null?void 0:N.length)??0,dt=wt>0&&T<wt-1?N[T+1]:void 0,bt=wt>0&&T>0?N[T-1]:void 0,Tt=w.useCallback(()=>{!dt||!E||E(dt.id,void 0,!!dt.isLatestAttempt)},[dt,E]),jt=w.useCallback(()=>{!bt||!E||E(bt.id,void 0,!!bt.isLatestAttempt)},[bt,E]);return I&&!h&&!rt?null:Y&&q?u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:te("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:q.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ye(),a&&at&&u.jsx("span",{className:te("font-medium",O?"text-xs":"text-sm"),children:at}),I&&u.jsxs(zh,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>V(Te=>Te==="expanded"?"preview":"expanded"),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),V(qe=>qe==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[At&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("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||Tt()},"aria-label":"Older attempt (back in time)",disabled:T>=C-1,children:u.jsx(le.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:te("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||jt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",D,O&&"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:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(R?"text-success":D,O?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(D,O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(D,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(jp,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:rt,toolViewMode:z,isToolStreaming:Ce,contentParts:Z,textContent:de,imageParts:ue,fileParts:F,interruptParts:ne,isStreamingMessage:r,defaultMessage:q,handleFileClick:G,uploadingFiles:M,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:j,isCompactLayout:O,activeInterruptId:De,activeInterruptValue:ze,iconForeground:D}),m&&rt&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:rt,idx:0})})]}),I&&z==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(R?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(ap,{isOpen:J,onClose:K,fileId:oe.id,fileName:oe.name,mimeType:oe.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 RT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=w.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:b,onSelectCheckpoint:S}){const k=dl(t,n),C="type"in t&&t.type==="default_message",E=!!t.__syntheticStreaming,N=b??RT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:z,attempts:V}=w.useMemo(()=>ec(t.id,R,N),[t.id,R,N]);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,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:z,attemptMetas:V,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=w.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:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:z=!0},V)=>{const U=w.useRef(null),j=w.useRef(null),W=w.useRef(!1),$=w.useRef(!1),[O,P]=w.useState(!0),I=w.useMemo(()=>b?e.some(F=>"type"in F&&F.type==="default_message"?!1:Array.isArray(F==null?void 0:F.content)&&F.content.some(ne=>ne&&ne.type==="interrupt"&&(ne.id??ne.interrupt_id)===b.id)):!1,[b,e]),q=w.useMemo(()=>{if(!b||I)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ne;const de=b.value;if(de&&typeof de=="object"&&!Array.isArray(de)){const ce=de.title;typeof ce=="string"&&ce.trim()&&(ne=ce.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:de,title:ne}]}},[b,I]),Y=w.useMemo(()=>q?[...e,q]:e,[e,q]),_=w.useMemo(()=>!z||!t?Y:!Y.some(ne=>ne.role==="assistant")&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y,[Y,t,z]),M=w.useMemo(()=>T?_:_.filter(F=>(F==null?void 0:F.role)!=="tool"),[_,T]),G=w.useCallback(F=>{P(F),x&&x(!F),y&&y(F)},[x,y]),J=w.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),oe=w.useMemo(()=>!v||g?!1:O?"auto":!1,[O,v,g]),K=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return!F||M&&M.length>0?null:{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}},[f,M]),D=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>K?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:K,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!"}),Z=M.length,ue=Z>0;return w.useEffect(()=>{var F,ne;if(Z===0){$.current=!1;return}if(!$.current)if($.current=!0,U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[Z,M.length]),w.useImperativeHandle(V,()=>({scrollToLatest:()=>{var F,ne;if(U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var F,ne;U.current&&M.length>0?(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ue?u.jsx(LC,{ref:F=>{U.current=F},scrollerRef:F=>{j.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,ne)=>dl(ne,F),itemContent:(F,ne)=>u.jsx(fl,{message:ne,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});hl.displayName="MessageList";const Mp={value:""};function Rr({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,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:N,checkpoints:R,interrupt:L,metadata:z,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:W,submit:$,stop:O}=Li(),P=b??y??null,I=(N==null?void 0:N.id)??null,q=(N==null?void 0:N.namespace)??null,[Y,_]=w.useState(null),M=(z==null?void 0:z.assemblingMessageId)??(U&&Y?Y:null),G=L,[J,oe]=w.useState(!1);w.useEffect(()=>{G||oe(!1)},[G]);const K=w.useCallback(()=>{oe(!0)},[]),D=w.useCallback(()=>{oe(!1)},[]),X=!!G||J,[Z,ue]=w.useState(null),[F,ne]=w.useState(""),[de,ce]=w.useState(null),[ge,Ce]=w.useState(null),[Pe,De]=w.useState([]),[ze,rt]=w.useState(0),[Ct,Ve]=w.useState(0),[He,Ye]=w.useState(!1),[Le,Ue]=w.useState(null),[mt,Dt]=w.useState(null),[at,At]=w.useState(!1),[wt,dt]=w.useState(null),bt=w.useRef(!1),[Tt,jt]=w.useState(()=>Mp.value),Te=w.useRef(Tt),qe=w.useRef(null),Ee=w.useCallback(ie=>{Mp.value=ie,jt(ie)},[]),[Ke,zt]=w.useState(!1),re=w.useRef(null),be=w.useRef(null),ot=w.useRef(null),xe=w.useCallback(()=>{be.current&&(be.current.value=""),ot.current&&(ot.current.value=""),rt(ie=>ie+1),Ve(ie=>ie+1)},[]),Be=w.useCallback(ie=>{Ee(ie)},[Ee]),Xe=w.useRef(!1);w.useEffect(()=>{Xe.current&&!U&&(De([]),xe()),Xe.current=U},[U,xe]),w.useEffect(()=>{U||_(null)},[U]);const[kt,Et]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const fe=window.innerWidth;Et(fe<640?"phone":fe<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{bt.current=!1},[P]),w.useEffect(()=>{Te.current=Tt},[Tt]),w.useEffect(()=>{if(!Z){qe.current=null;return}qe.current===null&&(qe.current=Te.current),Ee(F??"")},[F,Z,Ee]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){dt(null);return}try{const Ne=(await x.getAgent("default")).uiDefaultMessage||"";dt(Ne||null)}catch(fe){console.warn("Failed to fetch default message:",fe),dt(null)}})()},[x.baseUrl]),w.useEffect(()=>{j&&!at&&(g==null||g(j))},[j,at,g]);const Nt=async ie=>{const fe=ie.trim();if(!fe&&Pe.length===0)return;const Ne=Z;try{const Oe=Z?(de==null?void 0:de.checkpointId)??I??void 0:I??void 0,et=Z?(de==null?void 0:de.checkpointNs)??q??void 0:q??void 0;await $({text:fe||"",attachments:Pe},{checkpointId:Oe,checkpointNs:et,edit:!!Z,originalMessageId:Z??void 0}),f==null||f(fe),Ne&&_(Ne),Ee(""),Ce(null),De([]),xe(),ue(null),ne(""),ce(null)}catch(Oe){const et=(Oe==null?void 0:Oe.message)||"Failed to send message";Ce(et),g==null||g(et)}},Lt=w.useCallback((ie,fe,Ne)=>{c&&(qe.current=Tt,ue(ie),ne(fe),Ee(fe),Ce(null),ce({checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}))},[Tt,c,Ee]),je=w.useCallback(()=>{ue(null),ne(""),ce(null),Ce(null),Ee(qe.current??Tt),qe.current=null,_(null)},[Tt,Ee]),ht=w.useCallback((ie,fe,Ne)=>{Lt(ie,fe,Ne)},[Lt]),Ze=w.useCallback(ie=>{let fe=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){fe=S[pt];break}if(!fe)return;const Ne=Array.isArray(fe.content)?fe.content:[],et=Ne.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ne,null,2)}catch{return String(Ne)}})();et&&$({text:et},{checkpointId:I??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:fe.id})},[S,$,I,q]),ft=ie=>{const fe=Array.from(ie.target.files||[]);De(Ne=>[...Ne,...fe]),ie.target.value=""},an=ie=>{De(fe=>{const Ne=fe.filter((Oe,et)=>ie!==et);return Ne.length===0&&xe(),Ne})},A=async ie=>{const fe=(ie.target.files||[])[0];if(fe){Ue(null),Dt(null),Ye(!0);try{await $({attachments:[fe]},{checkpointId:I??void 0,checkpointNs:q??void 0});const Ne=`Uploaded ${fe.name} - processing through chat stream`;Dt(Ne)}catch(Ne){const Oe=Ne instanceof Error?Ne.message:"Failed to upload Excel file";console.error("Excel upload failed",Ne),Ue(Oe),g==null||g(Oe)}finally{Ye(!1),ie.target.value="",xe()}}},Q=async ie=>{if(y){zt(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToLatest()});return}const fe=R.find(Oe=>Oe.checkpointId===ie),Ne=(fe==null?void 0:fe.checkpointNs)??null;await T(ie,Ne),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToTop()})}finally{zt(!1)}}},he=w.useCallback(async(ie,fe,Ne)=>{await Q(Ne?null:ie)},[Q]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Je=`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 ${m.messagesArea||""}`,nt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!at&&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:j}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>At(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:re,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:c,editingMessageId:Z,onEdit:ht,onRegenerate:Ze,onCancelEdit:je,emptyMessage:wt??void 0,isNavigatingCheckpoint:Ke,activeInterrupt:G,disableInterruptActions:J,onInterruptActionStart:K,onInterruptActionEnd:D,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:V,activeCheckpointId:I,onSelectCheckpoint:he,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="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(le.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="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"}),C&&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(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ke)&&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(le.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:nt,children:[Z&&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(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.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:be,type:"file",multiple:!0,onChange:ie=>ft(ie),className:"hidden"},ze),Pe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map((ie,fe)=>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(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ie.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>an(fe),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 ${ie.name}`,children:u.jsx(le.X,{size:12})})]},fe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:ot,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},Ct),He&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),mt&&!He&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:mt}),Le&&!He&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Le})]})]}),ge&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ge}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var ie;return(ie=be.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var ie;He||(ie=ot.current)==null||ie.click()},className:`cursor-pointer ${He?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(IS,{initialValue:F,editingMessageId:Z,value:Tt,onValueChange:Be,placeholder:Z?"Edit your message...":t,isStreaming:U,disabled:X,onSend:Nt,onCancelEdit:je,onStop:O,allowEmptySend:Pe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Z?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ge?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Rp=1,OT=.9,DT=.8,LT=.17,pl=.1,ml=.999,$T=.9999,FT=.99,BT=/[\\\/_+.#"@\[\(\{&]/,zT=/[\\\/_+.#"@\[\(\{&]/g,HT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Rp:FT;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*=Rp:BT.test(e.charAt(c-1))?(h*=DT,f=e.slice(o,c-1).match(zT),f&&o>0&&(h*=Math.pow(ml,f.length))):HT.test(e.charAt(c-1))?(h*=OT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=LT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=$T)),(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 Dp(e){return e.toLowerCase().replace(Op," ")}function UT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',WT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",VT=(e,t,n)=>UT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),wl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,M;return{search:"",value:(M=(_=e.value)!=null?_:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=nk();cr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),cr(()=>{T(6,U)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,M,G)=>{var J,oe,K,D;if(!Object.is(n.current[_],M)){if(n.current[_]=M,_==="search")V(),L(),T(1,z);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(b))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,E.emit()}),G||T(5,U),((oe=a.current)==null?void 0:oe.value)!==void 0){let X=M??"";(D=(K=a.current).onValueChange)==null||D.call(K,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,M,G)=>{var J;M!==((J=s.current.get(_))==null?void 0:J.value)&&(s.current.set(_,{value:M,keywords:G}),n.current.filtered.items.set(_,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(_,M)=>(r.current.add(_),M&&(o.current.has(M)?o.current.get(M).add(_):o.current.set(M,new Set([_]))),T(3,()=>{V(),L(),n.current.value||z(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===_&&z(),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:b,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,M){var G,J;let oe=(J=(G=a.current)==null?void 0:G.filter)!=null?J:VT;return _?oe(_,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let oe=o.current.get(J),K=0;oe.forEach(D=>{let X=_.get(D);K=Math.max(X,K)}),M.push([J,K])});let G=C.current;W().sort((J,oe)=>{var K,D;let X=J.getAttribute("id"),Z=oe.getAttribute("id");return((K=_.get(Z))!=null?K:0)-((D=_.get(X))!=null?D:0)}).forEach(J=>{let oe=J.closest(xl);oe?oe.appendChild(J.parentElement===oe?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,oe)=>oe[1]-J[1]).forEach(J=>{var oe;let K=(oe=C.current)==null?void 0:oe.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);K==null||K.parentElement.appendChild(K)})}function z(){let _=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=_==null?void 0:_.getAttribute(Or);E.setState("value",M||void 0)}function V(){var _,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let K of r.current){let D=(M=(_=s.current.get(K))==null?void 0:_.value)!=null?M:"",X=(J=(G=s.current.get(K))==null?void 0:G.keywords)!=null?J:[],Z=R(D,X);n.current.filtered.items.set(K,Z),Z>0&&oe++}for(let[K,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(K);break}n.current.filtered.count=oe}function U(){var _,M,G;let J=j();J&&(((_=J.parentElement)==null?void 0:_.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(WT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function W(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function $(_){let M=W()[_];M&&E.setState("value",M.getAttribute(Or))}function O(_){var M;let G=j(),J=W(),oe=J.findIndex(D=>D===G),K=J[oe+_];(M=a.current)!=null&&M.loop&&(K=oe+_<0?J[J.length-1]:oe+_===J.length?J[0]:J[oe+_]),K&&E.setState("value",K.getAttribute(Or))}function P(_){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=_>0?ek(G,Io):tk(G,Io),J=G==null?void 0:G.querySelector($p);J?E.setState("value",J.getAttribute(Or)):O(_)}let I=()=>$(W().length-1),q=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):O(1)},Y=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):O(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var M;(M=y.onKeyDown)==null||M.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&q(_);break}case"ArrowDown":{q(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let J=j();if(J){let oe=new Event(vl);J.dispatchEvent(oe)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:ok},l),Xs(e,_=>p.createElement(Bp.Provider,{value:E},p.createElement(Fp.Provider,{value:N},_))))}),KT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=qn(T=>T.value&&T.value===d.current),f=qn(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:b,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(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)}),qT=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=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(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(zp.Provider,{value:m},f))))}),GT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),YT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.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)}})}),XT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(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(ve.div,{ref:On(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:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),JT=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(Hp,{ref:t,...a}))))}),ZT=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.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(Hp,{List:XT,Item:KT,Input:YT,Group:qT,Separator:GT,Dialog:JT,Empty:ZT,Loading:QT});function ek(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{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(Or,a),o.current=a}),o}var nk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function rk(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(rk(t),{ref:t.ref},n(t.props.children)):n(t)}var ok={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));bl.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(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:te("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:te("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:te("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 sk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));sk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:te("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 ik(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,CN]=cn(Il),[ak,sn]=Vp(Il),Kp=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,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,N]=p.useState(!1),R=$e(t,z=>l(z)),L=Xo(o);return u.jsx(ak,{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:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.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}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=$e(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(ve.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})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,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(lk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(ck,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var lk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,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(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=ik("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:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,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 Lr(n.viewport,l),Lr(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(In,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=em(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 mk(m,i.current,a,f)}return n==="horizontal"?u.jsx(uk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(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(dk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(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}),uk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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),rm(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)}})}})}),dk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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),rm(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)}})}})}),[fk,Xp]=Vp(In),Jp=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(In,n),[v,g]=p.useState(null),x=$e(t,R=>g(R)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=xt(d),T=xt(l),E=ei(h,10);function N(R){if(y.current){const L=R.clientX-y.current.left,z=R.clientY-y.current.top;c({x:L,y:z})}}return p.useEffect(()=>{const R=L=>{const z=L.target;(v==null?void 0:v.contains(z))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(fk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:T,onThumbPointerDown:xt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(hk,{ref:t,...r})})}),hk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=$e(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=gk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.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:ae(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:ae(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(pk,{...e,ref:t}):null});Qp.displayName=jl;var pk=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 Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.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 em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function mk(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 nm([l,c],h)(e)}function tm(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 nm([0,i],[0,a])(c)}function nm(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 rm(e,t){return e>0&&e<t}var gk=(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=xt(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 Lr(e,t){const n=xt(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 om=Kp,xk=Gp,vk=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(xk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(vk,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:te("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(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("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 wk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",bk="bg-slate-700 border-slate-600 hover:bg-slate-600",yk="bg-slate-600 border-slate-500";function im({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 b=n===e.threadId,S=t?`${y??yk}`:`${x??bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${wk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?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(tt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.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(le.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(tt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(le.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 am=25,lm="thread-manager-view",Sk=e=>e==="default"||e==="shared",Ck=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(Sk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=w.useState(()=>Ck()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Tk=[{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:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:R,actions:L,shareInFlight:z,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:W,renameThread:$,shareThread:O}=L,{loadThread:P}=eo(),I=i??T,[q,Y]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(q.length>0),M=w.useRef(null),G=w.useRef(0),[J,oe]=w.useState(null),[K,D]=w.useState(""),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(null),[ce,ge]=w.useState(""),Ce=v&&v.length>0?v:Tk,Pe=cm({defaultView:m}),De=g??Pe,ze=h??De.view,rt=w.useCallback(re=>{h||De.setView(re),f==null||f(re)},[h,f,De]),Ct=Ce.find(re=>re.key===ze)??Ce[0],Ve=re=>{de(re),ge(""),F(!0)},He=()=>{F(!1),de(null),ge(""),U()},Ye=w.useCallback(async re=>{if(!(!ne||z)&&re.id)try{await O(ne,re.id),setTimeout(()=>He(),600)}catch(be){console.error("Failed to share thread:",be)}},[He,z,ne,O]),Le=w.useMemo(()=>{const re=y??[],be=ce.trim().toLowerCase();return be?S?re.filter(ot=>S(ot,be)):re.filter(ot=>`${ot.label} ${ot.secondaryLabel??""}`.toLowerCase().includes(be)):re},[y,ce,S]),Ue=ze==="shared",mt=Ue?C:q,Dt=Ue?R:N,at=Ue?"No shared conversations yet":"No conversations yet",At=re=>{const be=re.sharedAt?` • ${Ee(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${be}`},wt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,Y(re);return}N||(_.current=!1,Y(re))},[k,N]),w.useEffect(()=>{if(!M.current)return;const re=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let be=null,ot=null;return be=requestAnimationFrame(()=>{ot=requestAnimationFrame(()=>{re.scrollTop=G.current})}),()=>{be!==null&&cancelAnimationFrame(be),ot!==null&&cancelAnimationFrame(ot)}},[q]);const dt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(be){console.error("Failed to select thread:",be)}},bt=async()=>{try{Z(!0);const re=await j();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{Z(!1)}},Tt=async(re,be)=>{if(be.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const ot=M.current.querySelector("[data-radix-scroll-area-viewport]");ot&&(G.current=ot.scrollTop)}try{await W(re),d==null||d(re)}catch(ot){console.error("Failed to delete thread:",ot)}}},jt=(re,be)=>{be.stopPropagation(),oe(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},Te=async re=>{if(K.trim())try{await $(re,K.trim()),oe(null),D("")}catch(be){console.error("Failed to update title:",be)}},qe=()=>{oe(null),D("")},Ee=re=>{if(!re)return"";try{const be=new Date(re),xe=new Date().getTime()-be.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?be.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:be.toLocaleDateString()}catch{return""}},Ke=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,zt=re=>{const be=Ke(re);return be.length<=am?be:`${be.slice(0,am)}...`};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(tt,{onClick:bt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(le.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(tt,{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:Ct.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(re=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:be=>{be.preventDefault(),rt(re.key)},children:[u.jsx("span",{children:re.label}),ze===re.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:M,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(le.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(le.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:at})]}):mt.slice().sort((re,be)=>new Date(be.updatedAt||be.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(im,{thread:re,isActive:I===re.threadId,editingThreadId:J,editingTitle:K,onSelect:dt,onStartEditing:jt,onEditingTitleChange:be=>D(be),onSaveEditing:Te,onCancelEditing:qe,onShare:()=>Ve(re.threadId),onDelete:Tt,showEditTitle:r,showDeleteButton:n,formatDate:Ee,getDisplayThreadTitle:zt,secondaryLine:Ue&&wt(re)?At(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:ue,onOpenChange:re=>!re&&He(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(bl,{children:[u.jsx(yl,{autoFocus:!0,value:ce,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[z&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(Cl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Le.length>0&&u.jsx(Tl,{heading:"Recipients",children:Le.map(re=>u.jsx(kl,{onSelect:()=>Ye(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 kk({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=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...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(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...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(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Ek({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function Ik({placeholder:e,onMessageSent:t}){const[n,r]=w.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(le.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(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Rr,{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 Nk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(vr,{...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(tt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(tt,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(tt,{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(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ik,{placeholder:t,onMessageSent:r})})]})})}):null}function Ak({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(tt,{variant:r,size:o,className:te("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var jk="Label",um=p.forwardRef((e,t)=>u.jsx(ve.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())}}));um.displayName=jk;var dm=um;const _k=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:te(_k(),e),...t}));fm.displayName=dm.displayName;function hm(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 pm=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"}),Pk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Pk;var Mk=ni,Rk=[" ","Enter","ArrowUp","ArrowDown"],Ok=[" ","Enter"],ur="Select",[ri,oi,Dk]=Yo(ur),[$r,TN]=cn(ur,[Dk,kr]),si=kr(),[Lk,Gn]=$r(ur),[$k,Fk]=$r(ur),mm=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),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,L]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),z=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),W=Array.from(U).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Lk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:R,onValueChange:L,open:E,onOpenChange:N,dir:T,triggerPointerDownPosRef:z,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx($k,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{j(O=>new Set(O).add($))},[]),onNativeOptionRemove:p.useCallback($=>{j(O=>{const P=new Set(O);return P.delete($),P})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:$=>L($.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},W):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=$e(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Hm(x,g,y);b!==void 0&&i.onValueChange(b.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(ve.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":Bm(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(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:ae(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Rk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=$e(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=vm;var Bk="SelectIcon",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});bm.displayName=Bk;var zk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=zk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Hk="SelectContentImpl",Uk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=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,b=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=$e(t,K=>k(K)),[N,R]=p.useState(null),[L,z]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(K=>{const[D,...X]=V().map(F=>F.ref.current),[Z]=X.slice(-1),ue=document.activeElement;for(const F of K)if(F===ue||(F==null||F.scrollIntoView({block:"nearest"}),F===D&&C&&(C.scrollTop=0),F===Z&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==ue))return},[V,C]),O=p.useCallback(()=>$([N,S]),[$,N,S]);p.useEffect(()=>{U&&O()},[U,O]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let K={x:0,y:0};const D=Z=>{var ue,F;K={x:Math.abs(Math.round(Z.pageX)-(((ue=I.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((F=I.current)==null?void 0:F.y)??0))}},X=Z=>{K.x<=10&&K.y<=10?Z.preventDefault():S.contains(Z.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 K=()=>P(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[P]);const[q,Y]=zm(K=>{const D=V().filter(ue=>!ue.disabled),X=D.find(ue=>ue.ref.current===document.activeElement),Z=Hm(D,K,X);Z&&setTimeout(()=>Z.ref.current.focus())}),_=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&(R(K),Z&&(W.current=!0))},[b.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&z(K)},[b.value]),J=r==="popper"?Ml:km,oe=J===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:O,selectedItemText:L,position:r,isPositioned:U,searchRef:q,children:u.jsx(gs,{as:Uk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ae(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...oe,onPlaced:()=>j(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&Y(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let Z=V().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(K.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const ue=K.target,F=Z.indexOf(ue);Z=Z.slice(F+1)}setTimeout(()=>$(Z)),K.preventDefault()}})})})})})})});Tm.displayName=Hk;var Wk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=$e(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ue=L.left-N.left,F=R.left-ue,ne=E.left-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.left=Ce+"px"}else{const ue=N.right-L.right,F=window.innerWidth-R.right-ue,ne=window.innerWidth-E.right-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.right=Ce+"px"}const z=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),W=parseInt(j.borderTopWidth,10),$=parseInt(j.paddingTop,10),O=parseInt(j.borderBottomWidth,10),P=parseInt(j.paddingBottom,10),I=W+$+U+P+O,q=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=E.top+E.height/2-mn,J=V-G,oe=x.offsetHeight/2,K=x.offsetTop+oe,D=W+$+K,X=I-D;if(D<=G){const ue=z.length>0&&x===z[z.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,ne=Math.max(J,oe+(ue?M:0)+F+O),de=D+ne;a.style.height=de+"px"}else{const ue=z.length>0&&x===z[0].ref.current;a.style.top="0px";const ne=Math.max(G,W+g.offsetTop+(ue?_:0)+oe)+X;a.style.height=ne+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=V+"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(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Kk,{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(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Wk;var Vk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...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=Vk;var[Kk,Rl]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Rl(Ol,n),a=$e(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(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(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-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-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})})})]})});Em.displayName=Ol;var Im="SelectGroup",[qk,Gk]=$r(Im),Yk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(qk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Yk.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gk(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[Xk,jm]=$r(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=$e(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,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(Xk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.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:ae(i.onFocus,()=>f(!0)),onBlur:ae(i.onBlur,()=>f(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Ok.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=Fk(Ao,n),[d,h]=p.useState(null),m=$e(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.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(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Mm="SelectItemIndicator",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Mm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Rm.displayName=Mm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(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(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(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(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("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(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),Jk="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=Jk;var $l="SelectArrow",Zk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});Zk.displayName=$l;var Qk="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=$e(r,o),i=hm(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(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=Qk;function Bm(e){return e===""||e===void 0}function zm(e){const t=xt(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 Hm(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=eE(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 eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=mm,Um=xm,nE=wm,rE=bm,oE=ym,Wm=Sm,sE=Em,Vm=Am,Km=_m,iE=Pm,aE=Rm,qm=Om,Gm=Dm,Ym=$m;const lE=tE,cE=nE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{ref:r,className:te("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(rE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(oE,{children:u.jsxs(Wm,{ref:o,className:te("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(Jm,{}),u.jsx(sE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Zm,{})]})}));Qm.displayName=Wm.displayName;const uE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("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(aE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(iE,{children:t})]}));eg.displayName=Km.displayName;const dE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));dE.displayName=Ym.displayName;var fE="Separator",tg="horizontal",hE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=pE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=fE;function pE(e){return hE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[mE,kN]=cn(ai),[gE,xE]=mE(ai),sg=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=$e(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(gE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=xE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var vE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=$e(i,s),l=hm(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}})});lg.displayName=vE;function cg(e){return e?"checked":"unchecked"}var ug=sg,wE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{className:te("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(wE,{className:te("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")})}));dg.displayName=ug.displayName;const bE=Ja,yE=lT,SE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:te("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}));fg.displayName=To.displayName;const CE=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=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(SE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:te(CE({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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,EN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",TE=700,Fl="tooltip.open",[kE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=TE,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(kE,{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})};vg.displayName=xg;var jo="Tooltip",[EE,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,b]=Dn({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,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(EE,{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",bg=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=$e(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(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});bg.displayName=zl;var IE="TooltipPortal",[IN,NE]=li(IE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=NE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(AE,{side:o,...s,ref:t})})}),AE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=$e(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},b=RE(y,x.getBoundingClientRect()),S=OE(y,b),k=DE(g.getBoundingClientRect()),C=$E([...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},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!LE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[jE,_E]=li(jo,{isInside:!1}),PE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,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(br,{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(PE,{children:r}),u.jsx(jE,{scope:n,isInside:!0,children:u.jsx(Mk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",ME=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return _E(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});ME.displayName=Cg;function RE(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 OE(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 DE(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 LE(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 $E(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),FE(t)}function FE(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 BE=vg,zE=wg,HE=bg,Tg=yg;const UE=BE,WE=zE,VE=HE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{ref:r,sideOffset:t,className:te("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}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,KE,qE]=Yo("Toast"),[Eg,NN]=cn("Toast",[qE]),[GE,di]=Eg(Hl),Ig=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(GE,{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})})};Ig.displayName=Hl;var Ng="ToastViewport",YE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=YE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=KE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=$e(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 b=()=>{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",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...lI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?b.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(Dw,{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(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,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=jg;var _o="Toast",XE="toast.swipeStart",JE="toast.swipeMove",ZE="toast.swipeCancel",QE="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(nI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(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:ae(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:ae(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)})})})});_g.displayName=_o;var[eI,tI]=Eg(_o,{onClose(){}}),nI=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),b=$e(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:L}=g,z=xt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout(z,j))},[z]);p.useEffect(()=>{const j=g.viewport;if(j){const W=()=>{V(E.current),c==null||c()},$=()=>{const O=new Date().getTime()-T.current;E.current=E.current-O,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,$),j.addEventListener(Vl,W),()=>{j.removeEventListener(Wl,$),j.removeEventListener(Vl,W)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>L()),[R,L]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(rI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(eI,{scope:n,onClose:z,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ow,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||z(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ae(e.onPointerMove,j=>{if(!S.current)return;const W=j.clientX-S.current.x,$=j.clientY-S.current.y,O=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=P?I(0,W):0,Y=P?0:I(0,$),_=j.pointerType==="touch"?10:2,M={x:q,y:Y},G={originalEvent:j,delta:M};O?(k.current=M,fi(JE,h,G,{discrete:!1})):Fg(M,g.swipeDirection,_)?(k.current=M,fi(XE,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(W)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,j=>{const W=k.current,$=j.target;if($.hasPointerCapture(j.pointerId)&&$.releasePointerCapture(j.pointerId),k.current=null,S.current=null,W){const O=j.currentTarget,P={originalEvent:j,delta:W};Fg(W,g.swipeDirection,g.swipeThreshold)?fi(QE,f,P,{discrete:!0}):fi(ZE,m,P,{discrete:!0}),O.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),rI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return iI(()=>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]})})})},oI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=oI;var sI="ToastDescription",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Mg.displayName=sI;var Rg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Rg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Rg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=tI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),aI(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(...$g(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 Fg=(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 iI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function aI(e){return e.nodeType===e.ELEMENT_NODE}function lI(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 cI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Mg,Wg=Og,Vg=ql;const uI=cI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Kg.displayName=Bg.displayName;const dI=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"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:te(dI({variant:t}),e),...n}));qg.displayName=zg.displayName;const fI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:te("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}));fI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("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(le.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:te("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function hI(){const{toasts:e}=nl();return u.jsxs(uI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var pI=(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{}},mI=p.createContext(void 0),gI={setTheme:e=>{},themes:[]},xI=()=>{var e;return(e=p.useContext(mI))!=null?e:gI};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:`(${pI.toString()})(${d})`}})});var vI=e=>{switch(e){case"success":return yI;case"info":return CI;case"warning":return SI;case"error":return TI;default:return null}},wI=Array(12).fill(0),bI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},wI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),yI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),SI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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"})),CI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),TI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),kI=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),EI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Yl=1,II=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],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(AI(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 II,NI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},AI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jI=NI,_I=()=>qt.toasts,PI=()=>qt.getActiveToasts();Object.assign(jI,{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:_I,getToasts:PI});function MI(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))}MI(`: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 RI=3,OI="32px",DI="16px",Jg=4e3,LI=356,$I=14,FI=20,BI=200;function gn(...e){return e.filter(Boolean).join(" ")}function zI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var HI=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:b,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:N,style:R,cancelButtonStyle:L,actionButtonStyle:z,className:V="",descriptionClassName:U="",duration:j,position:W,gap:$,loadingIcon:O,expandByDefault:P,classNames:I,icons:q,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:_}=e,[M,G]=w.useState(null),[J,oe]=w.useState(null),[K,D]=w.useState(!1),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(!1),[ce,ge]=w.useState(!1),[Ce,Pe]=w.useState(0),[De,ze]=w.useState(0),rt=w.useRef(f.duration||j||Jg),Ct=w.useRef(null),Ve=w.useRef(null),He=S===0,Ye=S+1<=y,Le=f.type,Ue=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(xe=>xe.toastId===f.id)||0,[b,f.id]),At=w.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:N},[f.closeButton,N]),wt=w.useMemo(()=>f.duration||j||Jg,[f.duration,j]),dt=w.useRef(0),bt=w.useRef(0),Tt=w.useRef(0),jt=w.useRef(null),[Te,qe]=W.split("-"),Ee=w.useMemo(()=>b.reduce((xe,Be,Xe)=>Xe>=at?xe:xe+Be.height,0),[b,at]),Ke=EI(),zt=f.invert||m,re=Le==="loading";bt.current=w.useMemo(()=>at*$+Ee,[at,Ee]),w.useEffect(()=>{rt.current=wt},[wt]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let xe=Ve.current;if(xe){let Be=xe.getBoundingClientRect().height;return ze(Be),x(Xe=>[{toastId:f.id,height:Be,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(kt=>kt.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!K)return;let xe=Ve.current,Be=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Be,ze(Xe),x(kt=>kt.find(Et=>Et.toastId===f.id)?kt.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...kt])},[K,f.title,f.description,x,f.id]);let be=w.useCallback(()=>{Z(!0),Pe(bt.current),x(xe=>xe.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{T(f)},BI)},[f,T,x,bt]);w.useEffect(()=>{if(f.promise&&Le==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Ke?(()=>{if(Tt.current<dt.current){let Be=new Date().getTime()-dt.current;rt.current=rt.current-Be}Tt.current=new Date().getTime()})():rt.current!==1/0&&(dt.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=f.onAutoClose)==null||Be.call(f,f),be()},rt.current)),()=>clearTimeout(xe)},[C,g,f,Le,_,Ke,be]),w.useEffect(()=>{f.delete&&be()},[be,f.delete]);function ot(){var xe,Be,Xe;return q!=null&&q.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Le==="loading"},q.loading):O?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Le==="loading"},O):w.createElement(bI,{className:gn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ve,className:gn(V,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[Le],(n=f==null?void 0:f.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":K,"data-promise":!!f.promise,"data-swiped":ce,"data-removed":X,"data-visible":Ye,"data-y-position":Te,"data-x-position":qe,"data-index":S,"data-front":He,"data-swiping":ue,"data-dismissible":Ue,"data-type":Le,"data-invert":zt,"data-swipe-out":ne,"data-swipe-direction":J,"data-expanded":!!(C||P&&K),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ce:bt.current}px`,"--initial-height":P?"auto":`${De}px`,...R,...f.style},onDragEnd:()=>{F(!1),G(null),jt.current=null},onPointerDown:xe=>{re||!Ue||(Ct.current=new Date,Pe(bt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(F(!0),jt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Xe,kt;if(ne||!Ue)return;jt.current=null;let Et=Number(((xe=Ve.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Be=Ve.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Xe=Ct.current)==null?void 0:Xe.getTime()),je=M==="x"?Et:Nt,ht=Math.abs(je)/Lt;if(Math.abs(je)>=FI||ht>.11){Pe(bt.current),(kt=f.onDismiss)==null||kt.call(f,f),oe(M==="x"?Et>0?"right":"left":Nt>0?"down":"up"),be(),de(!0),ge(!1);return}F(!1),G(null)},onPointerMove:xe=>{var Be,Xe,kt,Et;if(!jt.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let Nt=xe.clientY-jt.current.y,Lt=xe.clientX-jt.current.x,je=(Xe=e.swipeDirections)!=null?Xe:zI(W);!M&&(Math.abs(Lt)>1||Math.abs(Nt)>1)&&G(Math.abs(Lt)>Math.abs(Nt)?"x":"y");let ht={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&Nt<0||je.includes("bottom")&&Nt>0)&&(ht.y=Nt):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(ht.x=Lt),(Math.abs(ht.x)>0||Math.abs(ht.y)>0)&&ge(!0),(kt=Ve.current)==null||kt.style.setProperty("--swipe-amount-x",`${ht.x}px`),(Et=Ve.current)==null||Et.style.setProperty("--swipe-amount-y",`${ht.y}px`)}},At&&!f.jsx?w.createElement("button",{"aria-label":Y,"data-disabled":re,"data-close-button":!0,onClick:re||!Ue?()=>{}:()=>{var xe;be(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:kI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,Le||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(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||ot():null,f.type!=="loading"?f.icon||(q==null?void 0:q[Le])||vI(Le):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(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?w.createElement("div",{"data-description":"",className:gn(U,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),w.isValidElement(f.cancel)?f.cancel:f.cancel&&hi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Be,Xe;hi(f.cancel)&&Ue&&((Xe=(Be=f.cancel).onClick)==null||Xe.call(Be,xe),be())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&hi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||z,onClick:xe=>{var Be,Xe;hi(f.action)&&((Xe=(Be=f.action).onClick)==null||Xe.call(Be,xe),!xe.defaultPrevented&&be())},className:gn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){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 UI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?DI:OI;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 WI=w.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=RI,toastOptions:g,dir:x=Zg(),gap:y=$I,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),N=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,L]=w.useState([]),[z,V]=w.useState(!1),[U,j]=w.useState(!1),[W,$]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),q=w.useRef(!1),Y=w.useCallback(_=>{E(M=>{var G;return(G=M.find(J=>J.id===_.id))!=null&&G.delete||qt.dismiss(_.id),M.filter(({id:J})=>J!==_.id)})},[]);return w.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(M=>M.map(G=>G.id===_.id?{...G,delete:!0}:G));return}setTimeout(()=>{Po.flushSync(()=>{E(M=>{let G=M.findIndex(J=>J.id===_.id);return G!==-1?[...M.slice(0,G),{...M[G],..._},...M.slice(G+1)]:[_,...M]})})})}),[]),w.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:M})=>{$(M?"dark":"light")})}catch{_.addListener(({matches:G})=>{try{$(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),w.useEffect(()=>{T.length<=1&&V(!1)},[T]),w.useEffect(()=>{let _=M=>{var G,J;o.every(oe=>M[oe]||M.code===oe)&&(V(!0),(G=O.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===O.current||(J=O.current)!=null&&J.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),w.useEffect(()=>{if(O.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[O.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((_,M)=>{var G;let[J,oe]=_.split("-");return T.length?w.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:O,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":J,"data-lifted":z&&T.length>1&&!s,"data-x-position":oe,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${LI}px`,"--gap":`${y}px`,...f,...UI(l,c)},onBlur:K=>{q.current&&!K.currentTarget.contains(K.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=K.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{U||V(!1)},onDragEnd:()=>V(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(K=>!K.position&&M===0||K.position===_).map((K,D)=>{var X,Z;return w.createElement(HI,{key:K.id,icons:S,index:D,toast:K,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:U,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:Y,toasts:T.filter(ue=>ue.position==K.position),heights:R.filter(ue=>ue.position==K.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:z,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const VI=({...e})=>{const{theme:t="system"}=xI();return u.jsx(WI,{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})};B.Api=Fv,B.ApiClient=$v,B.ApiProvider=tu,B.ArtifactRenderer=Cp,B.Badge=zh,B.Button=tt,B.Card=sl,B.CardContent=cl,B.CardDescription=ll,B.CardHeader=il,B.CardTitle=al,B.ChatApi=Ko,B.ChatApp=kk,B.ChatInput=Hf,B.ChatInterface=Rr,B.ChatProviders=vr,B.ChatWidget=Nk,B.Command=bl,B.CommandEmpty=Cl,B.CommandGroup=Tl,B.CommandInput=yl,B.CommandItem=kl,B.CommandList=Sl,B.DEFAULT_TIMEOUT_MS=Yc,B.Dialog=Qa,B.DialogContent=Bs,B.DialogHeader=zs,B.DialogTitle=Hs,B.DropdownMenu=Ss,B.DropdownMenuContent=ho,B.DropdownMenuItem=Bn,B.DropdownMenuTrigger=Cs,B.FileViewerModal=ap,B.HISTORY_TIMEOUT_MS=Xc,B.Input=Pl,B.InterruptPartRenderer=kp,B.Label=fm,B.MarkdownContent=Mr,B.MessageBody=jp,B.MessageComponent=Ys,B.MessageList=hl,B.MessageRow=fl,B.NewChatButton=Ak,B.PlotArtifact=yp,B.ResearchTaskArtifact=Sp,B.SETTINGS_STORAGE_KEY=$i,B.ScrollArea=_l,B.Select=lE,B.SelectContent=Qm,B.SelectItem=eg,B.SelectTrigger=Xm,B.SelectValue=cE,B.Separator=og,B.Sheet=bE,B.SheetContent=hg,B.SheetDescription=gg,B.SheetHeader=pg,B.SheetTitle=mg,B.SheetTrigger=yE,B.SimpleChat=Ek,B.SimpleJsonView=ul,B.Sonner=VI,B.StreamProgress=Ep,B.Switch=dg,B.Textarea=Ta,B.ThinkingIndicator=Np,B.ThreadListItem=im,B.ThreadManager=ti,B.ThreadStateProvider=Tu,B.ThreadsProvider=fu,B.TimelineColumn=mx,B.Toaster=hI,B.ToolComponent=Ip,B.Tooltip=WE,B.TooltipContent=kg,B.TooltipProvider=UE,B.TooltipTrigger=VE,B.UserTextContent=Ap,B.applySettings=ww,B.buildCheckpointIndex=Ql,B.buildCheckpointPreviewMap=ox,B.chatApiClient=Rn,B.del=Ai,B.downloadFileById=Zc,B.extractConfigFields=mi,B.fileToBase64=nu,B.get=Jt,B.getChatToken=qc,B.getCheckpointForMessage=sx,B.getCurrentSettings=vw,B.getDefaultApiConfig=Mu,B.getDefaultChatSettings=Ru,B.getFileContent=_i,B.getFileInfo=zv,B.getMessageAttemptInfo=ec,B.getMessageDomKey=dl,B.getPreviewForMessage=pi,B.httpClient=Xt,B.hydrateHistorySnapshots=Mn,B.isEnvelope=ou,B.listFiles=Qc,B.loadStoredSettings=Ou,B.onChatTokenChanged=Gc,B.post=Vo,B.processAttachments=ru,B.put=Jc,B.readNumber=nc,B.readString=Pn,B.resolveChatBaseUrl=vn,B.saveSettings=Du,B.setChatToken=Wo,B.toPlainObject=_n,B.unwrap=$t,B.useApi=Xr,B.useCheckpointIndex=tc,B.useFilePreview=_p,B.useHasChatSession=mw,B.useParsedMessageContent=Pp,B.useShallowStableValue=Au,B.useStream=Li,B.useStreamingHook=Li,B.useThreadHistoryState=bu,B.useThreadManagerViewState=cm,B.useThreadState=eo,B.useThreadStateUpdater=Cu,B.useThreads=gr,B.useThreadsState=uu,B.viewFileById=Bv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|