teodor-new-chat-ui 4.3.422 → 4.3.423
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/checkpoint/utils/editUtils.d.ts +11 -0
- package/dist/index.esm.js +2702 -2668
- package/dist/index.umd.js +33 -33
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,qt,Dr,
|
|
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,qt,Dr,Qg,ex,Ao,fe){"use strict";var zI=Object.defineProperty;var HI=(B,w,qt)=>w in B?zI(B,w,{enumerable:!0,configurable:!0,writable:!0,value:qt}):B[w]=qt;var Jg=(B,w,qt)=>HI(B,typeof w!="symbol"?w+"":w,qt);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 h=Jl(w),Lr=Jl(Ao),Zl=120;function tx(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 ui(e){return tx(e.content)||""}function nx(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=ui(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],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const C of b)C.role==="user"&&(y||(y=C),C.id&&(x=C.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,T={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(T),p&&t.set(p,T),p&&y){const C=ui(y);C&&r.set(p,C)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function 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 rx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return w.useMemo(()=>Ql(e),[e])}function Nn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function An(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 di(e){const t=Nn(e);if(t)return Nn(t.configurable)??t}function jn(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)=>ox(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 ox(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).filter(k=>!!(k&&typeof k=="object"&&typeof k.role=="string")),o=Nn(e.metadata)??{},s=di(e.config),i=Nn(e.parent_config??e.parentConfig),a=di(i),l=An(s,["checkpoint_id","checkpointId"]),c=An(s,["checkpoint_ns","checkpointNs"]),d=An(a,["checkpoint_id","checkpointId"]),p=An(a,["checkpoint_id","checkpointId"])??null,m=An(a,["checkpoint_ns","checkpointNs"])??null,f=Nn(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:An(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:p,nextCursorNs:m,interrupt:sx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function sx(e,t){return ix(e,t)}function ix(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 fi={exports:{}},$r={};/**
|
|
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 oc;function
|
|
9
|
+
*/var oc;function ax(){if(oc)return $r;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,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return $r.Fragment=n,$r.jsx=i,$r.jsxs=i,$r}var Fr={};/**
|
|
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 sc;function
|
|
18
|
-
`+V+A}}var
|
|
17
|
+
*/var sc;function lx(){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"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var ee=v&&A[v]||A[g];return typeof ee=="function"?ee:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var ee=arguments.length,pe=new Array(ee>1?ee-1:0),ke=1;ke<ee;ke++)pe[ke-1]=arguments[ke];S("error",A,pe)}}function S(A,ee,pe){{var ke=y.ReactDebugCurrentFrame,Je=ke.getStackAddendum();Je!==""&&(ee+="%s",pe=pe.concat([Je]));var rt=pe.map(function(ie){return String(ie)});rt.unshift("Warning: "+ee),Function.prototype.apply.call(console[A],console,rt)}}var k=!1,T=!1,C=!1,E=!1,N=!1,O;O=Symbol.for("react.module.reference");function $(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||N||A===o||A===c||A===d||E||A===f||k||T||C||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===O||A.getModuleId!==void 0))}function H(A,ee,pe){var ke=A.displayName;if(ke)return ke;var Je=ee.displayName||ee.name||"";return Je!==""?pe+"("+Je+")":pe}function K(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 ee=A;return K(ee)+".Consumer";case i:var pe=A;return K(pe._context)+".Provider";case l:return H(A,A.render,"ForwardRef");case p:var ke=A.displayName||null;return ke!==null?ke:U(A.type)||"Memo";case m:{var Je=A,rt=Je._payload,ie=Je._init;try{return U(ie(rt))}catch{return null}}}return null}var I=Object.assign,W=0,_,D,P,j,G,Z,R;function M(){}M.__reactDisabledLog=!0;function q(){{if(W===0){_=console.log,D=console.info,P=console.warn,j=console.error,G=console.group,Z=console.groupCollapsed,R=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 X(){{if(W--,W===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},A,{value:_}),info:I({},A,{value:D}),warn:I({},A,{value:P}),error:I({},A,{value:j}),group:I({},A,{value:G}),groupCollapsed:I({},A,{value:Z}),groupEnd:I({},A,{value:R})})}W<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=y.ReactCurrentDispatcher,V;function L(A,ee,pe){{if(V===void 0)try{throw Error()}catch(Je){var ke=Je.stack.trim().match(/\n( *(at )?)/);V=ke&&ke[1]||""}return`
|
|
18
|
+
`+V+A}}var Y=!1,J;{var ce=typeof WeakMap=="function"?WeakMap:Map;J=new ce}function F(A,ee){if(!A||Y)return"";{var pe=J.get(A);if(pe!==void 0)return pe}var ke;Y=!0;var Je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var rt;rt=oe.current,oe.current=null,q();try{if(ee){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(Kt){ke=Kt}Reflect.construct(A,[],ie)}else{try{ie.call()}catch(Kt){ke=Kt}A.call(ie.prototype)}}else{try{throw Error()}catch(Kt){ke=Kt}A()}}catch(Kt){if(Kt&&ke&&typeof Kt.stack=="string"){for(var de=Kt.stack.split(`
|
|
19
19
|
`),Ee=ke.stack.split(`
|
|
20
|
-
`),
|
|
21
|
-
`+de[
|
|
20
|
+
`),Oe=de.length-1,et=Ee.length-1;Oe>=1&&et>=0&&de[Oe]!==Ee[et];)et--;for(;Oe>=1&&et>=0;Oe--,et--)if(de[Oe]!==Ee[et]){if(Oe!==1||et!==1)do if(Oe--,et--,et<0||de[Oe]!==Ee[et]){var pt=`
|
|
21
|
+
`+de[Oe].replace(" at new "," at ");return A.displayName&&pt.includes("<anonymous>")&&(pt=pt.replace("<anonymous>",A.displayName)),typeof A=="function"&&J.set(A,pt),pt}while(Oe>=1&&et>=0);break}}}finally{Y=!1,oe.current=rt,X(),Error.prepareStackTrace=Je}var Or=A?A.displayName||A.name:"",cr=Or?L(Or):"";return typeof A=="function"&&J.set(A,cr),cr}function re(A,ee,pe){return F(A,!1)}function ue(A){var ee=A.prototype;return!!(ee&&ee.isReactComponent)}function le(A,ee,pe){if(A==null)return"";if(typeof A=="function")return F(A,ue(A));if(typeof A=="string")return L(A);switch(A){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return re(A.render);case p:return le(A.type,ee,pe);case m:{var ke=A,Je=ke._payload,rt=ke._init;try{return le(rt(Je),ee,pe)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,Ne={},_e=y.ReactDebugCurrentFrame;function De(A){if(A){var ee=A._owner,pe=le(A.type,A._source,ee?ee.type:null);_e.setExtraStackFrame(pe)}else _e.setExtraStackFrame(null)}function Ae(A,ee,pe,ke,Je){{var rt=Function.call.bind(xe);for(var ie in A)if(rt(A,ie)){var de=void 0;try{if(typeof A[ie]!="function"){var Ee=Error((ke||"React class")+": "+pe+" 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 Ee.name="Invariant Violation",Ee}de=A[ie](ee,ie,ke,pe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Oe){de=Oe}de&&!(de 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).",ke||"React class",pe,ie,typeof de),De(null)),de instanceof Error&&!(de.message in Ne)&&(Ne[de.message]=!0,De(Je),b("Failed %s type: %s",pe,de.message),De(null))}}}var Be=Array.isArray;function tt(A){return Be(A)}function qe(A){{var ee=typeof Symbol=="function"&&Symbol.toStringTag,pe=ee&&A[Symbol.toStringTag]||A.constructor.name||"Object";return pe}}function ze(A){try{return it(A),!1}catch{return!0}}function it(A){return""+A}function nt(A){if(ze(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",qe(A)),it(A)}var Ze=y.ReactCurrentOwner,St={key:!0,ref:!0,__self:!0,__source:!0},xt,at;function Rt(A){if(xe.call(A,"ref")){var ee=Object.getOwnPropertyDescriptor(A,"ref").get;if(ee&&ee.isReactWarning)return!1}return A.ref!==void 0}function Mt(A){if(xe.call(A,"key")){var ee=Object.getOwnPropertyDescriptor(A,"key").get;if(ee&&ee.isReactWarning)return!1}return A.key!==void 0}function Ct(A,ee){typeof A.ref=="string"&&Ze.current}function Tt(A,ee){{var pe=function(){xt||(xt=!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)",ee))};pe.isReactWarning=!0,Object.defineProperty(A,"key",{get:pe,configurable:!0})}}function kt(A,ee){{var pe=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)",ee))};pe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:pe,configurable:!0})}}var Ve=function(A,ee,pe,ke,Je,rt,ie){var de={$$typeof:t,type:A,key:ee,ref:pe,props:ie,_owner:rt};return de._store={},Object.defineProperty(de._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(de,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(de,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Je}),Object.freeze&&(Object.freeze(de.props),Object.freeze(de)),de};function ge(A,ee,pe,ke,Je){{var rt,ie={},de=null,Ee=null;pe!==void 0&&(nt(pe),de=""+pe),Mt(ee)&&(nt(ee.key),de=""+ee.key),Rt(ee)&&(Ee=ee.ref,Ct(ee,Je));for(rt in ee)xe.call(ee,rt)&&!St.hasOwnProperty(rt)&&(ie[rt]=ee[rt]);if(A&&A.defaultProps){var Oe=A.defaultProps;for(rt in Oe)ie[rt]===void 0&&(ie[rt]=Oe[rt])}if(de||Ee){var et=typeof A=="function"?A.displayName||A.name||"Unknown":A;de&&Tt(ie,et),Ee&&kt(ie,et)}return Ve(A,de,Ee,Je,ke,Ze.current,ie)}}var He=y.ReactCurrentOwner,Ye=y.ReactDebugCurrentFrame;function vt(A){if(A){var ee=A._owner,pe=le(A.type,A._source,ee?ee.type:null);Ye.setExtraStackFrame(pe)}else Ye.setExtraStackFrame(null)}var $t;$t=!1;function ne(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function Se(){{if(He.current){var A=U(He.current.type);if(A)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+A+"`."}return""}}function dt(A){return""}var we={};function
|
|
23
|
+
Check the render method of \``+A+"`."}return""}}function dt(A){return""}var we={};function Me(A){{var ee=Se();if(!ee){var pe=typeof A=="string"?A:A.displayName||A.name;pe&&(ee=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+pe+">.")}return ee}}function Ue(A,ee){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var pe=
|
|
25
|
+
Check the top-level render call using <`+pe+">.")}return ee}}function Ue(A,ee){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var pe=Me(ee);if(we[pe])return;we[pe]=!0;var ke="";A&&A._owner&&A._owner!==He.current&&(ke=" It was passed a child from "+U(A._owner.type)+"."),vt(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.',pe,ke),vt(null)}}function Et(A,ee){{if(typeof A!="object")return;if(tt(A))for(var pe=0;pe<A.length;pe++){var ke=A[pe];ne(ke)&&Ue(ke,ee)}else if(ne(A))A._store&&(A._store.validated=!0);else if(A){var Je=x(A);if(typeof Je=="function"&&Je!==A.entries)for(var rt=Je.call(A),ie;!(ie=rt.next()).done;)ne(ie.value)&&Ue(ie.value,ee)}}}function Ke(A){{var ee=A.type;if(ee==null||typeof ee=="string")return;var pe;if(typeof ee=="function")pe=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===p))pe=ee.propTypes;else return;if(pe){var ke=U(ee);Ae(pe,A.props,"prop",ke,A)}else if(ee.PropTypes!==void 0&&!$t){$t=!0;var Je=U(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Je||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wt(A){{for(var ee=Object.keys(A.props),pe=0;pe<ee.length;pe++){var ke=ee[pe];if(ke!=="children"&&ke!=="key"){vt(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),vt(null);break}}A.ref!==null&&(vt(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),vt(null))}}var Fe={};function Xe(A,ee,pe,ke,Je,rt){{var ie=$(A);if(!ie){var de="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(de+=" 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 Ee=dt();Ee?de+=Ee:de+=Se();var Oe;A===null?Oe="null":tt(A)?Oe="array":A!==void 0&&A.$$typeof===t?(Oe="<"+(U(A.type)||"Unknown")+" />",de=" 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,de)}var et=ge(A,ee,pe,Je,rt);if(et==null)return et;if(ie){var pt=ee.children;if(pt!==void 0)if(ke)if(tt(pt)){for(var Or=0;Or<pt.length;Or++)Et(pt[Or],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 Et(pt,A)}if(xe.call(ee,"key")){var cr=U(A),Kt=Object.keys(ee).filter(function(BI){return BI!=="key"}),Xl=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[cr+Xl]){var FI=Kt.length>0?"{"+Kt.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} />`,Xl,lr,OI,lr),Le[lr+Xl]=!0}}return A===r?wt(et):Ke(et),et}}function Vt(A,ee,pe){return Xe(A,ee,pe,!0)}function ql(A,ee,pe){return Xe(A,ee,pe,!1)}var Gl=ql,Yl=Vt;Fr.Fragment=r,Fr.jsx=Gl,Fr.jsxs=Yl}()),Fr}process.env.NODE_ENV==="production"?fi.exports=ix():fi.exports=ax();var u=fi.exports;const lx=({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:cx}=Object.prototype,{getPrototypeOf:pi}=Object,{iterator:jo,toStringTag:ac}=Symbol,_o=(e=>t=>{const n=cx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>_o(t)===e),Po=e=>t=>typeof t===e,{isArray:ur}=Array,dr=Po("undefined");function Br(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=on("ArrayBuffer");function ux(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const dx=Po("string"),Ft=Po("function"),cc=Po("number"),zr=e=>e!==null&&typeof e=="object",fx=e=>e===!0||e===!1,Ro=e=>{if(_o(e)!=="object")return!1;const t=pi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(jo in e)},px=e=>{if(!zr(e)||Br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},hx=on("Date"),mx=on("File"),gx=on("Blob"),xx=on("FileList"),vx=e=>zr(e)&&Ft(e.pipe),wx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=_o(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},bx=on("URLSearchParams"),[yx,Sx,Cx,Tx]=["ReadableStream","Request","Response","Headers"].map(on),kx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ur(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Br(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(Br(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 Kn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!dr(e)&&e!==Kn;function hi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Ro(n[i])&&Ro(o)?n[i]=hi(n[i],o):Ro(o)?n[i]=hi({},o):ur(o)?n[i]=o.slice():(!t||!dr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Hr(arguments[o],r);return n}const Ex=(e,t,n,{allOwnKeys:r}={})=>(Hr(t,(o,s)=>{n&&Ft(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Ix=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Nx=(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)},Ax=(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&&pi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},jx=(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(ur(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},Px=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&pi(Uint8Array)),Rx=(e,t)=>{const r=(e&&e[jo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Mx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ox=on("HTMLFormElement"),Dx=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),Lx=on("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Hr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},$x=e=>{pc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Fx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},Bx=()=>{},zx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Hx(e){return!!(e&&Ft(e.append)&&e[ac]==="FormData"&&e[jo])}const Ux=e=>{const t=new Array(10),n=(r,o)=>{if(zr(r)){if(t.indexOf(r)>=0)return;if(Br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return Hr(r,(i,a)=>{const l=n(i,o+1);!dr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Wx=on("AsyncFunction"),Vx=e=>e&&(zr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),hc=((e,t)=>e?setImmediate:t?((n,r)=>(Kn.addEventListener("message",({source:o,data:s})=>{o===Kn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Kn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(Kn.postMessage)),Kx=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||hc,z={isArray:ur,isArrayBuffer:lc,isBuffer:Br,isFormData:wx,isArrayBufferView:ux,isString:dx,isNumber:cc,isBoolean:fx,isObject:zr,isPlainObject:Ro,isEmptyObject:px,isReadableStream:yx,isRequest:Sx,isResponse:Cx,isHeaders:Tx,isUndefined:dr,isDate:hx,isFile:mx,isBlob:gx,isRegExp:Lx,isFunction:Ft,isStream:vx,isURLSearchParams:bx,isTypedArray:Px,isFileList:xx,forEach:Hr,merge:hi,extend:Ex,trim:kx,stripBOM:Ix,inherits:Nx,toFlatObject:Ax,kindOf:_o,kindOfTest:on,endsWith:jx,toArray:_x,forEachEntry:Rx,matchAll:Mx,isHTMLForm:Ox,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:pc,freezeMethods:$x,toObjectSet:Fx,toCamelCase:Dx,noop:Bx,toFiniteNumber:zx,findKey:uc,global:Kn,isContextDefined:dc,isSpecCompliantForm:Hx,toJSONObject:Ux,isAsyncFn:Wx,isThenable:Vx,setImmediate:hc,asap:Kx,isIterable:e=>e!=null&&Ft(e[jo])};function _e(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)}z.inherits(_e,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:z.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=_e.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(_e,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);z.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 _e.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 qx=null;function mi(e){return z.isPlainObject(e)||z.isArray(e)}function xc(e){return z.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 Gx(e){return z.isArray(e)&&!e.some(mi)}const Yx=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function Mo(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!z.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new _e("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.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(z.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&Gx(v)||(z.isFileList(v)||z.endsWith(g,"[]"))&&(y=z.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(z.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return mi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(Yx,{defaultVisitor:d,convertValue:c,isVisitable:mi});function f(v,g){if(!z.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),z.forEach(v,function(y,b){(!(z.isUndefined(y)||y===null)&&o.call(t,y,z.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!z.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 gi(e,t){this._pairs=[],e&&Mo(e,this,t)}const bc=gi.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 Xx(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||Xx;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new gi(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){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Jx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:gi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},xi=typeof window<"u"&&typeof document<"u",vi=typeof navigator=="object"&&navigator||void 0,Zx=xi&&(!vi||["ReactNative","NativeScript","NS"].indexOf(vi.product)<0),Qx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ev=xi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:Zx,hasStandardBrowserWebWorkerEnv:Qx,navigator:vi,origin:ev},Symbol.toStringTag,{value:"Module"})),...Jx};function tv(e,t){return Mo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function nv(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function rv(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&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=rv(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(nv(r),o,n,0)}),n}return null}function ov(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ur={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 tv(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Mo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),ov(t)):t}],transformResponse:[function(t){const n=this.transitional||Ur.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.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"?_e.from(a,_e.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:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Ur.headers[e]={}});const sv=z.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"]),iv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Wr(i);r[a]||(uv(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods(Bt);function bi(e,t){const n=this||Ur,r=t||n,o=Bt.from(r.headers);let s=r.data;return z.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 fr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(fr,_e,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function dv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function fv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function pv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Do=(e,t,n=3)=>{let r=0;const o=fv(50,250);return pv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>z.asap(()=>e(...t)),hv=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,mv=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 gv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function xv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!gv(t);return e&&(r||n==!1)?xv(e,t):t}const _c=e=>e instanceof Bt?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return z.isPlainObject(c)&&z.isPlainObject(d)?z.merge.call({caseless:m},c,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(c,d,p,m){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!z.isUndefined(d))return r(void 0,d)}function i(c,d){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(_c(c),_c(d),p,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);z.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Pc=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.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)):""))),z.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Nt.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&hv(t.url))){const l=o&&s&&mv.read(s);l&&i.set(o,l)}return t},vv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),T={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()},T),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 _e("Request aborted",_e.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new _e(T,_e.ERR_NETWORK,e,x);C.event=k||null,r(C),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new _e(k,T.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&z.forEach(i.toJSON(),function(k,T){x.setRequestHeader(T,k)}),z.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Do(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Do(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new fr(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=dv(o.url);if(b&&Nt.protocols.indexOf(b)===-1){r(new _e("Unsupported protocol "+b+":",_e.ERR_BAD_REQUEST,e));return}x.send(s||null)})},wv=(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 _e?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.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=()=>z.asap(a),l}},bv=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},yv=async function*(e,t){for await(const n of Sv(e))yield*bv(n,t)},Sv=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()}},Rc=(e,t,n,r)=>{const o=yv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Mc=64*1024,{isFunction:Lo}=z,Cv=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Oc,TextEncoder:Dc}=z.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Tv=e=>{e=z.merge.call({skipUndefined:!0},Cv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Lo(t):typeof fetch=="function",s=Lo(n),i=Lo(r);if(!o)return!1;const a=o&&Lo(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(Nt.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>z.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new _e(`Response type '${v}' is not supported`,_e.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=z.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:O="same-origin",fetchOptions:$}=Pc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let K=wv([b,S&&S.toAbortSignal()],k),U=null;const I=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let W;try{if(C&&c&&x!=="get"&&x!=="head"&&(W=await f(N,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),R;if(z.isFormData(y)&&(R=J.headers.get("content-type"))&&N.setContentType(R),J.body){const[M,q]=Nc(W,Do(Ac(C)));y=Rc(J.body,Mc,M,q)}}z.isString(O)||(O=O?"include":"omit");const _=s&&"credentials"in n.prototype,D={...$,signal:K,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:_?O:void 0};U=s&&new n(g,D);let P=await(s?H(U,$):H(g,D));const j=d&&(E==="stream"||E==="response");if(d&&(T||j&&I)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=P[Y]});const R=z.toFiniteNumber(P.headers.get("content-length")),[M,q]=T&&Nc(R,Do(Ac(T),!0))||[];P=new r(Rc(P.body,Mc,M,()=>{q&&q(),I&&I()}),J)}E=E||"text";let G=await p[z.findKey(p,E)||"text"](P,v);return!j&&I&&I(),await new Promise((J,R)=>{Ic(J,R,{data:G,headers:Bt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:U})})}catch(_){throw I&&I(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,v,U),{cause:_.cause||_}):_e.from(_,_&&_.code,v,U)}}},kv=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=kv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Tv(t)),d=c;return c};$c();const yi={http:qx,xhr:vv,fetch:{get:$c}};z.forEach(yi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Ev=e=>z.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=z.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,!Ev(r)&&(o=yi[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${a}'`);if(o&&(z.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 :
|
|
30
|
+
<%s key={someKey} {...props} />`,Xl,cr,FI,cr),Fe[cr+Xl]=!0}}return A===r?wt(et):Ke(et),et}}function Vt(A,ee,pe){return Xe(A,ee,pe,!0)}function ql(A,ee,pe){return Xe(A,ee,pe,!1)}var Gl=ql,Yl=Vt;Fr.Fragment=r,Fr.jsx=Gl,Fr.jsxs=Yl}()),Fr}process.env.NODE_ENV==="production"?fi.exports=ax():fi.exports=lx();var u=fi.exports;const cx=({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:ux}=Object.prototype,{getPrototypeOf:pi}=Object,{iterator:jo,toStringTag:ac}=Symbol,_o=(e=>t=>{const n=ux.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>_o(t)===e),Po=e=>t=>typeof t===e,{isArray:ur}=Array,dr=Po("undefined");function Br(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=on("ArrayBuffer");function dx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const fx=Po("string"),Ft=Po("function"),cc=Po("number"),zr=e=>e!==null&&typeof e=="object",px=e=>e===!0||e===!1,Ro=e=>{if(_o(e)!=="object")return!1;const t=pi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(jo in e)},hx=e=>{if(!zr(e)||Br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},mx=on("Date"),gx=on("File"),xx=on("Blob"),vx=on("FileList"),wx=e=>zr(e)&&Ft(e.pipe),bx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=_o(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},yx=on("URLSearchParams"),[Sx,Cx,Tx,kx]=["ReadableStream","Request","Response","Headers"].map(on),Ex=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ur(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Br(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(Br(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 qn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!dr(e)&&e!==qn;function hi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Ro(n[i])&&Ro(o)?n[i]=hi(n[i],o):Ro(o)?n[i]=hi({},o):ur(o)?n[i]=o.slice():(!t||!dr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Hr(arguments[o],r);return n}const Ix=(e,t,n,{allOwnKeys:r}={})=>(Hr(t,(o,s)=>{n&&Ft(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Nx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ax=(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)},jx=(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&&pi(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},Px=e=>{if(!e)return null;if(ur(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},Rx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&pi(Uint8Array)),Mx=(e,t)=>{const r=(e&&e[jo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Ox=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Dx=on("HTMLFormElement"),Lx=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),$x=on("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Hr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Fx=e=>{pc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Bx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},zx=()=>{},Hx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ux(e){return!!(e&&Ft(e.append)&&e[ac]==="FormData"&&e[jo])}const Wx=e=>{const t=new Array(10),n=(r,o)=>{if(zr(r)){if(t.indexOf(r)>=0)return;if(Br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return Hr(r,(i,a)=>{const l=n(i,o+1);!dr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Vx=on("AsyncFunction"),Kx=e=>e&&(zr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),hc=((e,t)=>e?setImmediate:t?((n,r)=>(qn.addEventListener("message",({source:o,data:s})=>{o===qn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),qn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(qn.postMessage)),qx=typeof queueMicrotask<"u"?queueMicrotask.bind(qn):typeof process<"u"&&process.nextTick||hc,z={isArray:ur,isArrayBuffer:lc,isBuffer:Br,isFormData:bx,isArrayBufferView:dx,isString:fx,isNumber:cc,isBoolean:px,isObject:zr,isPlainObject:Ro,isEmptyObject:hx,isReadableStream:Sx,isRequest:Cx,isResponse:Tx,isHeaders:kx,isUndefined:dr,isDate:mx,isFile:gx,isBlob:xx,isRegExp:$x,isFunction:Ft,isStream:wx,isURLSearchParams:yx,isTypedArray:Rx,isFileList:vx,forEach:Hr,merge:hi,extend:Ix,trim:Ex,stripBOM:Nx,inherits:Ax,toFlatObject:jx,kindOf:_o,kindOfTest:on,endsWith:_x,toArray:Px,forEachEntry:Mx,matchAll:Ox,isHTMLForm:Dx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:pc,freezeMethods:Fx,toObjectSet:Bx,toCamelCase:Lx,noop:zx,toFiniteNumber:Hx,findKey:uc,global:qn,isContextDefined:dc,isSpecCompliantForm:Ux,toJSONObject:Wx,isAsyncFn:Vx,isThenable:Kx,setImmediate:hc,asap:qx,isIterable:e=>e!=null&&Ft(e[jo])};function Pe(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)}z.inherits(Pe,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:z.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Pe.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(Pe,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);z.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 Pe.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 Gx=null;function mi(e){return z.isPlainObject(e)||z.isArray(e)}function xc(e){return z.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 Yx(e){return z.isArray(e)&&!e.some(mi)}const Xx=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function Mo(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!z.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.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(z.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&Yx(v)||(z.isFileList(v)||z.endsWith(g,"[]"))&&(y=z.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(z.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return mi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(Xx,{defaultVisitor:d,convertValue:c,isVisitable:mi});function f(v,g){if(!z.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),z.forEach(v,function(y,b){(!(z.isUndefined(y)||y===null)&&o.call(t,y,z.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!z.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 gi(e,t){this._pairs=[],e&&Mo(e,this,t)}const bc=gi.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 Jx(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||Jx;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new gi(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){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Zx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:gi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},xi=typeof window<"u"&&typeof document<"u",vi=typeof navigator=="object"&&navigator||void 0,Qx=xi&&(!vi||["ReactNative","NativeScript","NS"].indexOf(vi.product)<0),ev=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tv=xi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:Qx,hasStandardBrowserWebWorkerEnv:ev,navigator:vi,origin:tv},Symbol.toStringTag,{value:"Module"})),...Zx};function nv(e,t){return Mo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function rv(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ov(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&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=ov(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(rv(r),o,n,0)}),n}return null}function sv(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ur={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 nv(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Mo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),sv(t)):t}],transformResponse:[function(t){const n=this.transitional||Ur.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.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"?Pe.from(a,Pe.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:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Ur.headers[e]={}});const iv=z.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"]),av=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]&&iv[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 Wr(e){return e&&String(e).trim().toLowerCase()}function Oo(e){return e===!1||e==null?e:z.isArray(e)?e.map(Oo):String(e)}function lv(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 cv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function wi(e,t,n,r,o){if(z.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!z.isString(t)){if(z.isString(r))return t.indexOf(r)!==-1;if(z.isRegExp(r))return r.test(t)}}function uv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function dv(e,t){const n=z.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 Bt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Wr(l);if(!d)throw new Error("header name must be a non-empty string");const p=z.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=Oo(a))}const i=(a,l)=>z.forEach(a,(c,d)=>s(c,d,l));if(z.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(z.isString(t)&&(t=t.trim())&&!cv(t))i(av(t),n);else if(z.isObject(t)&&z.isIterable(t)){let a={},l,c;for(const d of t){if(!z.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?z.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=Wr(t),t){const r=z.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return lv(o);if(z.isFunction(n))return n.call(this,o,r);if(z.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Wr(t),t){const r=z.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||wi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Wr(i),i){const a=z.findKey(r,i);a&&(!n||wi(r,r[a],a,n))&&(delete r[a],o=!0)}}return z.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||wi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return z.forEach(this,(o,s)=>{const i=z.findKey(r,s);if(i){n[i]=Oo(o),delete n[s];return}const a=t?uv(s):String(s).trim();a!==s&&delete n[s],n[a]=Oo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return z.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&z.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=Wr(i);r[a]||(dv(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods(Bt);function bi(e,t){const n=this||Ur,r=t||n,o=Bt.from(r.headers);let s=r.data;return z.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 fr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(fr,Pe,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function fv(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 p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function hv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Do=(e,t,n=3)=>{let r=0;const o=pv(50,250);return hv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>z.asap(()=>e(...t)),mv=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,gv=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 xv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function vv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!xv(t);return e&&(r||n==!1)?vv(e,t):t}const _c=e=>e instanceof Bt?{...e}:e;function Gn(e,t){t=t||{};const n={};function r(c,d,p,m){return z.isPlainObject(c)&&z.isPlainObject(d)?z.merge.call({caseless:m},c,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(c,d,p,m){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!z.isUndefined(d))return r(void 0,d)}function i(c,d){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(_c(c),_c(d),p,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);z.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Pc=e=>{const t=Gn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.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)):""))),z.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Nt.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&mv(t.url))){const l=o&&s&&gv.read(s);l&&i.set(o,l)}return t},wv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),T={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()},T),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 Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Pe(T,Pe.ERR_NETWORK,e,x);C.event=k||null,r(C),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&z.forEach(i.toJSON(),function(k,T){x.setRequestHeader(T,k)}),z.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Do(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Do(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new fr(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=fv(o.url);if(b&&Nt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},bv=(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 Pe?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.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=()=>z.asap(a),l}},yv=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},Sv=async function*(e,t){for await(const n of Cv(e))yield*yv(n,t)},Cv=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()}},Rc=(e,t,n,r)=>{const o=Sv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Mc=64*1024,{isFunction:Lo}=z,Tv=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Oc,TextEncoder:Dc}=z.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kv=e=>{e=z.merge.call({skipUndefined:!0},Tv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Lo(t):typeof fetch=="function",s=Lo(n),i=Lo(r);if(!o)return!1;const a=o&&Lo(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(Nt.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>z.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=z.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:O="same-origin",fetchOptions:$}=Pc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let K=bv([b,S&&S.toAbortSignal()],k),U=null;const I=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let W;try{if(C&&c&&x!=="get"&&x!=="head"&&(W=await f(N,y))!==0){let Z=new n(g,{method:"POST",body:y,duplex:"half"}),R;if(z.isFormData(y)&&(R=Z.headers.get("content-type"))&&N.setContentType(R),Z.body){const[M,q]=Nc(W,Do(Ac(C)));y=Rc(Z.body,Mc,M,q)}}z.isString(O)||(O=O?"include":"omit");const _=s&&"credentials"in n.prototype,D={...$,signal:K,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:_?O:void 0};U=s&&new n(g,D);let P=await(s?H(U,$):H(g,D));const j=d&&(E==="stream"||E==="response");if(d&&(T||j&&I)){const Z={};["status","statusText","headers"].forEach(X=>{Z[X]=P[X]});const R=z.toFiniteNumber(P.headers.get("content-length")),[M,q]=T&&Nc(R,Do(Ac(T),!0))||[];P=new r(Rc(P.body,Mc,M,()=>{q&&q(),I&&I()}),Z)}E=E||"text";let G=await p[z.findKey(p,E)||"text"](P,v);return!j&&I&&I(),await new Promise((Z,R)=>{Ic(Z,R,{data:G,headers:Bt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:U})})}catch(_){throw I&&I(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,U),{cause:_.cause||_}):Pe.from(_,_&&_.code,v,U)}}},Ev=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=Ev;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:kv(t)),d=c;return c};$c();const yi={http:Gx,xhr:wv,fetch:{get:$c}};z.forEach(yi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Iv=e=>z.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=z.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,!Iv(r)&&(o=yi[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(z.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
33
|
`+i.map(Fc).join(`
|
|
34
|
-
`):" "+Fc(i[0]):"as no adapter specified";throw new
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Fo.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:Fo.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fo.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=qn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Gn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Gn.prototype[t]=n(),Gn.prototype[t+"Form"]=n(!0)});let Nv=class Jg{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 fr(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 Jg(function(o){t=o}),cancel:t}}};function Av(e){return function(n){return e.apply(null,n)}}function jv(e){return z.isObject(e)&&e.isAxiosError===!0}const Ci={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(Ci).forEach(([e,t])=>{Ci[t]=e});function Wc(e){const t=new Gn(e),n=ic(Gn.prototype.request,t);return z.extend(n,Gn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(qn(e,o))},n}const ht=Wc(Ur);ht.Axios=Gn,ht.CanceledError=fr,ht.CancelToken=Nv,ht.isCancel=Ec,ht.VERSION=Hc,ht.toFormData=Mo,ht.AxiosError=_e,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Av,ht.isAxiosError=jv,ht.mergeConfig=qn,ht.AxiosHeaders=Bt,ht.formToJSON=e=>Tc(z.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Bc.getAdapter,ht.HttpStatusCode=Ci,ht.default=ht;const{Axios:VI,AxiosError:KI,CanceledError:qI,isCancel:GI,CancelToken:YI,VERSION:XI,all:JI,Cancel:ZI,isAxiosError:QI,spread:e1,toFormData:t1,AxiosHeaders:n1,HttpStatusCode:r1,formToJSON:o1,getAdapter:s1,mergeConfig:i1}=ht,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?mn(Vc):void 0;function mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Bo=null;const Ti=new Set;function qc(){return Bo}function zo(e){Bo=e,Ti.forEach(t=>t(e))}function Gc(e){return Ti.add(e),()=>Ti.delete(e)}const Yc=3e4,Xc=9e4,Gt=ht.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Gt.interceptors.request.use(e=>(Bo&&(e.headers.Authorization=`Bearer ${Bo}`),e)),Gt.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),zo(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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ho(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ki(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Uo{get baseUrl(){const t=Gt.defaults.baseURL;return t?mn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=mn(String(t.baseUrl))),t.authToken!==void 0&&zo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){zo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ho("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await ki(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await Ho(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return Ot(n)}async cancelRun(t){const n=await Ho("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await ki(`/threads/${t}/share/${n}`);return Ot(r)}}const An=new Uo,_v=Uo,Pv=Uo;async function Ei(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Rv(e,t){const n=await Ei(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ii(e,t){return await(await Ei(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await Ei(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/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 Mv(e){return await Yt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const eu=w.createContext(null);function tu({children:e,apiConfig:t}){const n=An;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 Vr(){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 Ov(e={}){const t=w.useMemo(()=>mn(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),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),N=w.useRef(null),O=w.useRef(null),$=w.useCallback(I=>{o(I)},[]),H=w.useCallback(()=>{m(""),v(null),d(null),E.current=null,N.current=null,O.current=null},[]),K=w.useCallback(()=>{var I;console.debug("[use-chat] stop() invoked - aborting stream"),(I=S.current)==null||I.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,x(0)},[]),U=w.useCallback((I,W,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,N.current=null,O.current=null;const D=new AbortController;S.current=D;let P=null,j=null,G=!1;return C.current={threadId:I.threadId??null,headers:{}},(async()=>{var R,M,q,Y,oe,V,L,X,Z,ce,F,re,ue,le,xe,Ne,$e,Fe;const J=Ae=>{var Be;try{const tt=JSON.parse(JSON.stringify(Ae));return(Be=tt==null?void 0:tt.payload)!=null&&Be.files_info&&Array.isArray(tt.payload.files_info)&&(tt.payload.files_info=tt.payload.files_info.map(qe=>({...qe,data:qe!=null&&qe.data?`<base64 ${String(qe.data).length} chars>`:qe==null?void 0:qe.data}))),tt}catch{return Ae}};try{let Ae={};try{if(r)Ae={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ge=window.__AUTH_TOKEN__,He=((R=window.localStorage)==null?void 0:R.getItem("authToken"))||null;let Ye=null;try{const $t=(M=window.localStorage)==null?void 0:M.getItem("chat-settings");$t&&(Ye=((q=JSON.parse($t))==null?void 0:q.apiKey)||null)}catch{}const vt=ge||He||Ye||null;vt&&(Ae={Authorization:`Bearer ${vt}`})}}catch{}console.debug("[use-chat] POST",t+n,J(I));let Be={};if(typeof window<"u")try{const Ve=(Y=window.localStorage)==null?void 0:Y.getItem("authSessionId");Ve&&(Be={"X-Session-Id":Ve})}catch{}const tt={...Ae,...Be,...s.current},qe={"Content-Type":"application/json",Accept:"text/event-stream",...tt},ze=await fetch(t+n,{method:"POST",headers:qe,body:JSON.stringify(I),signal:D.signal,credentials:i});if(C.current&&(C.current.headers=tt),!ze.ok||!ze.body){const Ve=await ze.text().catch(()=>"");console.debug("[use-chat] non-OK response",ze.status,Ve==null?void 0:Ve.slice(0,500));const ge=`stream ${ze.status}${Ve?": "+Ve:""}`;throw(oe=_==null?void 0:_.onConnectionError)==null||oe.call(_,ge),G=!0,P="error",j=ge,new Error(ge)}b(!0);const it=ze.body.getReader(),nt=new TextDecoder;let Ze="",St=[];T.current=0,x(0);let xt=0,at=null;const Rt=()=>{if(St.length){const Ve=St.join("");St=[],k.current&&m(ge=>ge+Ve)}at=null},Mt=()=>{typeof window<"u"&&at==null&&(at=requestAnimationFrame(Rt))};let Ct=Date.now();const Tt=setInterval(()=>{var Ve;if(Date.now()-Ct>18e5){const ge="Stream idle timeout";d(ge),P="error",j=ge,D.abort(),(Ve=_==null?void 0:_.onError)==null||Ve.call(_,ge)}},5e3),kt=1024*1024;try{const Ve=ze.headers.get("X-Thread-Id")||ze.headers.get("x-thread-id"),ge=ze.headers.get("X-Thread-Created")||ze.headers.get("x-thread-created"),He=Ve??null,Ye=String(ge??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:He}),(V=_==null?void 0:_.onOpen)==null||V.call(_,{threadId:He,created:Ye});;){const{value:vt,done:$t}=await it.read();if($t)break;Ze+=nt.decode(vt,{stream:!0}),Ze.length>kt&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=Ze.indexOf(`
|
|
34
|
+
`):" "+Fc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:yi};function Si(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fr(null,e)}function zc(e){return Si(e),e.headers=Bt.from(e.headers),e.data=bi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Bc.getAdapter(e.adapter||Ur.adapter,e)(e).then(function(r){return Si(e),r.data=bi.call(e,e.transformResponse,r),r.headers=Bt.from(r.headers),r},function(r){return Ec(r)||(Si(e),r&&r.response&&(r.response.data=bi.call(e,e.transformResponse,r.response),r.response.headers=Bt.from(r.response.headers))),Promise.reject(r)})}const Hc="1.12.2",$o={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{$o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Uc={};$o.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 Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.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}},$o.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Nv(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.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 Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const Fo={assertOptions:Nv,validators:$o},hn=Fo.validators;let Yn=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=Gn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Fo.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:Fo.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Fo.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Gn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Yn.prototype[t]=function(n,r){return this.request(Gn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Gn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Yn.prototype[t]=n(),Yn.prototype[t+"Form"]=n(!0)});let Av=class Zg{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 fr(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 Zg(function(o){t=o}),cancel:t}}};function jv(e){return function(n){return e.apply(null,n)}}function _v(e){return z.isObject(e)&&e.isAxiosError===!0}const Ci={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(Ci).forEach(([e,t])=>{Ci[t]=e});function Wc(e){const t=new Yn(e),n=ic(Yn.prototype.request,t);return z.extend(n,Yn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Gn(e,o))},n}const ht=Wc(Ur);ht.Axios=Yn,ht.CanceledError=fr,ht.CancelToken=Av,ht.isCancel=Ec,ht.VERSION=Hc,ht.toFormData=Mo,ht.AxiosError=Pe,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=jv,ht.isAxiosError=_v,ht.mergeConfig=Gn,ht.AxiosHeaders=Bt,ht.formToJSON=e=>Tc(z.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Bc.getAdapter,ht.HttpStatusCode=Ci,ht.default=ht;const{Axios:YI,AxiosError:XI,CanceledError:JI,isCancel:ZI,CancelToken:QI,VERSION:eN,all:tN,Cancel:nN,isAxiosError:rN,spread:oN,toFormData:sN,AxiosHeaders:iN,HttpStatusCode:aN,formToJSON:lN,getAdapter:cN,mergeConfig:uN}=ht,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?mn(Vc):void 0;function mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Bo=null;const Ti=new Set;function qc(){return Bo}function zo(e){Bo=e,Ti.forEach(t=>t(e))}function Gc(e){return Ti.add(e),()=>Ti.delete(e)}const Yc=3e4,Xc=9e4,Gt=ht.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Gt.interceptors.request.use(e=>(Bo&&(e.headers.Authorization=`Bearer ${Bo}`),e)),Gt.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),zo(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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ho(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ki(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Uo{get baseUrl(){const t=Gt.defaults.baseURL;return t?mn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=mn(String(t.baseUrl))),t.authToken!==void 0&&zo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){zo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ho("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await ki(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await Ho(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return Ot(n)}async cancelRun(t){const n=await Ho("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await ki(`/threads/${t}/share/${n}`);return Ot(r)}}const _n=new Uo,Pv=Uo,Rv=Uo;async function Ei(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Mv(e,t){const n=await Ei(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ii(e,t){return await(await Ei(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await Ei(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/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 Ov(e){return await Yt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const eu=w.createContext(null);function tu({children:e,apiConfig:t}){const n=_n;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 Vr(){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 Dv(e={}){const t=w.useMemo(()=>mn(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),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),N=w.useRef(null),O=w.useRef(null),$=w.useCallback(I=>{o(I)},[]),H=w.useCallback(()=>{m(""),v(null),d(null),E.current=null,N.current=null,O.current=null},[]),K=w.useCallback(()=>{var I;console.debug("[use-chat] stop() invoked - aborting stream"),(I=S.current)==null||I.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,x(0)},[]),U=w.useCallback((I,W,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,N.current=null,O.current=null;const D=new AbortController;S.current=D;let P=null,j=null,G=!1;return C.current={threadId:I.threadId??null,headers:{}},(async()=>{var R,M,q,X,oe,V,L,Y,J,ce,F,re,ue,le,xe,Ne,_e,De;const Z=Ae=>{var Be;try{const tt=JSON.parse(JSON.stringify(Ae));return(Be=tt==null?void 0:tt.payload)!=null&&Be.files_info&&Array.isArray(tt.payload.files_info)&&(tt.payload.files_info=tt.payload.files_info.map(qe=>({...qe,data:qe!=null&&qe.data?`<base64 ${String(qe.data).length} chars>`:qe==null?void 0:qe.data}))),tt}catch{return Ae}};try{let Ae={};try{if(r)Ae={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ge=window.__AUTH_TOKEN__,He=((R=window.localStorage)==null?void 0:R.getItem("authToken"))||null;let Ye=null;try{const $t=(M=window.localStorage)==null?void 0:M.getItem("chat-settings");$t&&(Ye=((q=JSON.parse($t))==null?void 0:q.apiKey)||null)}catch{}const vt=ge||He||Ye||null;vt&&(Ae={Authorization:`Bearer ${vt}`})}}catch{}console.debug("[use-chat] POST",t+n,Z(I));let Be={};if(typeof window<"u")try{const Ve=(X=window.localStorage)==null?void 0:X.getItem("authSessionId");Ve&&(Be={"X-Session-Id":Ve})}catch{}const tt={...Ae,...Be,...s.current},qe={"Content-Type":"application/json",Accept:"text/event-stream",...tt},ze=await fetch(t+n,{method:"POST",headers:qe,body:JSON.stringify(I),signal:D.signal,credentials:i});if(C.current&&(C.current.headers=tt),!ze.ok||!ze.body){const Ve=await ze.text().catch(()=>"");console.debug("[use-chat] non-OK response",ze.status,Ve==null?void 0:Ve.slice(0,500));const ge=`stream ${ze.status}${Ve?": "+Ve:""}`;throw(oe=_==null?void 0:_.onConnectionError)==null||oe.call(_,ge),G=!0,P="error",j=ge,new Error(ge)}b(!0);const it=ze.body.getReader(),nt=new TextDecoder;let Ze="",St=[];T.current=0,x(0);let xt=0,at=null;const Rt=()=>{if(St.length){const Ve=St.join("");St=[],k.current&&m(ge=>ge+Ve)}at=null},Mt=()=>{typeof window<"u"&&at==null&&(at=requestAnimationFrame(Rt))};let Ct=Date.now();const Tt=setInterval(()=>{var Ve;if(Date.now()-Ct>18e5){const ge="Stream idle timeout";d(ge),P="error",j=ge,D.abort(),(Ve=_==null?void 0:_.onError)==null||Ve.call(_,ge)}},5e3),kt=1024*1024;try{const Ve=ze.headers.get("X-Thread-Id")||ze.headers.get("x-thread-id"),ge=ze.headers.get("X-Thread-Created")||ze.headers.get("x-thread-created"),He=Ve??null,Ye=String(ge??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:He}),(V=_==null?void 0:_.onOpen)==null||V.call(_,{threadId:He,created:Ye});;){const{value:vt,done:$t}=await it.read();if($t)break;Ze+=nt.decode(vt,{stream:!0}),Ze.length>kt&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=Ze.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const Se=Ze.slice(0,ne);Ze=Ze.slice(ne+2);const dt=Se.split(/\r?\n/),we=[];for(const
|
|
38
|
-
`);if(!Re)continue;let Ue;try{Ue=JSON.parse(Re)}catch{console.debug("[use-chat] malformed SSE:",Re.slice(0,200));continue}const Et=ou(Ue)?Ue.data:Ue;if(!Et){console.warn("[use-chat] dropped envelope event without payload",Ue);continue}const Ke=Et;Ct=Date.now();const wt=Ke.seq;if(wt!==void 0){if(wt<=xt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:wt,lastProcessedSeq:xt,type:Ke.type});continue}xt>0&&wt>xt+1&&((L=_==null?void 0:_.onGap)==null||L.call(_,{from:xt,to:wt})),xt=wt,T.current=wt,x(wt)}if(Ke.type==="checkpoint")E.current=Ke.checkpointId??null,N.current=Ke.checkpointNs??null,v(Ke.checkpointId??null);else if(Ke.type==="state_history"){O.current=Ke;try{const Xe=Nn(Ke).latest;Xe&&(E.current=Xe.checkpointId??null,N.current=Xe.checkpointNs??null,v(Xe.checkpointId??null))}catch(Le){console.warn("[use-chat] Failed to hydrate state_history payload",Le)}}try{W==null||W(Ke)}catch(Le){console.error("[use-chat] Error in onEvent callback:",Le,"for event:",Ke.type)}if(Ke.type==="message.delta"){const Le=Ke.delta.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("");Le&&e.autoAppendAssistant!==!1&&(St.push(Le),Mt())}else if(Ke.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(X=_==null?void 0:_.onHeartbeat)==null||X.call(_,Ke)}catch(Le){console.warn("[use-chat] heartbeat callback failed",Le)}}else if(at!==null&&cancelAnimationFrame(at),Rt(),Ke.type==="checkpoint")v(Ke.checkpointId);else if(Ke.type==="error"){const Le=Ke;if(d(Le.message),P="error",j=Le.message,Le.error_type==="auth_error"||Le.code==="TOKEN_EXPIRED"||((Z=Le.message)==null?void 0:Z.includes("token"))||((ce=Le.message)==null?void 0:ce.includes("401"))||((F=Le.message)==null?void 0:F.includes("unauthorized"))||((re=Le.message)==null?void 0:re.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Le.message);try{(ue=_==null?void 0:_.onAuthError)==null||ue.call(_,Le.message)}catch(Vt){console.warn("[use-chat] onAuthError handler failed",Vt)}D.abort()}}}}Rt(),P===null&&!D.signal.aborted&&(P="complete")}catch(Ve){if(Ve.name==="AbortError")P=P??"aborted";else{const ge=Ve.message||String(Ve);P="error",j=ge,d(ge),(le=_==null?void 0:_.onError)==null||le.call(_,ge)}}finally{try{await it.cancel()}catch{}finally{(xe=it.releaseLock)==null||xe.call(it)}at!==null&&typeof window<"u"&&window.cancelAnimationFrame(at),clearInterval(Tt)}}catch(Ae){if(Ae.name==="AbortError")P=P??"aborted";else{const Be=Ae.message||String(Ae);P="error",j=Be,d(Be),(Ne=_==null?void 0:_.onError)==null||Ne.call(_,Be),G||(($e=_==null?void 0:_.onConnectionError)==null||$e.call(_,Be),G=!0)}}finally{const Ae=T.current,Be=E.current,tt=N.current,qe=O.current,ze=P??(D.signal.aborted?"aborted":j?"error":"complete");try{(Fe=_==null?void 0:_.onClosed)==null||Fe.call(_,{reason:ze,lastSeq:Ae,lastCheckpointId:Be,lastCheckpointNs:tt,lastStateHistory:qe,error:j})}catch(it){console.warn("[use-chat] onClosed callback failed",it)}l(!1),b(!1),S.current=null,T.current=0,x(0),C.current=null}})(),{close:()=>D.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var I;k.current=!1,(I=S.current)==null||I.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:U,stop:K,clear:H,setToken:$}}const Dv=["detail","message","error","description","title"];function Wo(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=Wo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Dv){const r=Wo(t[n]);if(r)return r}if("errors"in t){const n=Wo(t.errors);if(n)return n}}return null}function Lv(e){if(!e)return"Request failed";const t=e.response,n=Wo(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 su({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),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,T]=w.useState(!1),C=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{C.current=a},[a]);const N=w.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const j=String(P);m(j),n==null||n(j)}finally{d(!1)}},[e,n]),O=w.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const j=String(P);y(j),n==null||n(j)}finally{x(!1)}},[e,n]);w.useEffect(()=>{N()},[N]),w.useEffect(()=>{O()},[O]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async P=>{try{const j=await e.createThread(P);return l(j.threadId),await N(),j.threadId}catch(j){const G=String(j);return n==null||n(G),null}},[e,n,N]),H=w.useCallback(async P=>{const j=s;i(J=>J.filter(R=>R.threadId!==P));const G=new AbortController;E.current.set(P,G);try{await e.deleteThread(P),C.current===P&&(l(null),o==null||o())}catch(J){i(j);const R=String(J);n==null||n(R)}finally{E.current.delete(P)}},[e,o,n,s]),K=w.useCallback(async(P,j)=>{try{await e.updateThread(P,j),await N()}catch(G){n==null||n(String(G))}},[e,n,N]),U=w.useCallback(async(P,j)=>{T(!0),S("Sharing thread…");try{await e.shareThread(P,j),await O(),S("Shared successfully")}catch(G){const J=Lv(G);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{T(!1)}},[e,n,O]),I=w.useCallback(async(P,j)=>{try{await e.unshareThread(P,j),await O()}catch(G){const J=String(G);throw n==null||n(J),G}},[e,n,O]),W=w.useMemo(()=>({createThread:$,deleteThread:H,renameThread:K,refreshThreads:N,refreshSharedThreads:O,shareThread:U,unshareThread:I}),[$,H,K,N,O,U,I]),_=w.useCallback(P=>{if(!(P!=null&&P.threadId))return;const j={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(G=>{let J=!1;const R=G.map(M=>M.threadId===j.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...M,title:j.title??M.title,updatedAt:j.updatedAt??M.updatedAt,messageCount:j.messageCount??M.messageCount}):M);return J?R:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...G])})},[]),D=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:C,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:_,shareInFlight:k,shareStatus:b,clearShareStatus:D}}const iu=w.createContext(null);function au({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Vr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=su({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(iu.Provider,{value:b,children:e})}function pr(){const e=w.useContext(iu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ni(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 lu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Kr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Kr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(lu(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=Kr(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 hr(e){if(typeof e=="string")return e;if(lu(e))return"";try{const t=Kr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function $v(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Fv(e){const t=hr(e);return typeof e=="string"&&$v(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=Ni(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 Bv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ai(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 Vo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function zv(e){const t=r=>{try{const o=Kr(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 Hv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function cu(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 Uv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Wv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Vv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Uv(n),i=o?`data:${s};base64,${e}`:t,a=Wv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Kv(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 Vv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function uu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ji(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 Gr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function qv(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 du(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function fu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Gv(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??fu(e);let l="",c=e.slice();if(s){const p=Yv(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function pu(e){return e.replace(/\s+/g," ").trim()}function Yv(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=pu(e),o=pu(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 Xv(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 Gr(e,r,s)}return e}function Jv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}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:ji(((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=ji(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=ji(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 hu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>hu(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,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function hu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Jv(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??du(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(T=>T.id===s&&T.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:fu(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}=Gv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Gr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.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??du(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Xv(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=Nn(t),i=s.interrupt,a=s.latest,l=i===null?qv(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 _i(e){return e.call_id??e.id??null}function mu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function gu(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 Pi(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||Ai(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=hr(t??e);return n?[{type:"text",text:n}]:[]}function xu(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=_i(t),r=Pi(e.messages,n),o=t.name??t.tool??void 0,s=mu(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:Gr(e.messages,r,d)}}const i=gu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function rw(e,t){const n=_i(t);if(!n)return e;const r=Pi(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=xu(e.messages[r],o);return{...e,messages:Gr(e.messages,r,a)}}function ow(e,t){const n=_i(t),r=mu(t);let o=e.messages,s=Pi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,gu(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 p=xu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Gr(o,s,f)}}function vu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=w.useState(null),v=w.useMemo(()=>Nn(p),[p]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[T,C]=w.useState(!1),[E,N]=w.useState(!1),[O,$]=w.useState(!1),[H,K]=w.useState(null),U=w.useRef(o),I=w.useRef(null),W=w.useRef(null),_=w.useRef(null),D=w.useRef(null),P=w.useRef(!1),j=w.useRef(null),G=w.useRef(new Map);w.useEffect(()=>{U.current=o},[o]);const J=w.useCallback(async F=>{var ue,le;if(!F.threadId)return;const re=F.threadId;(ue=F.onStart)==null||ue.call(F),F.setLoading(!0);try{await F.action(re)}catch(xe){if(U.current===re){const Ne=String(xe);(le=F.handleError)==null||le.call(F,Ne),r==null||r(Ne)}throw xe}finally{F.setLoading(!1)}},[r]),R=w.useCallback(async(F,re)=>{if(!F)return;const ue=`${F}:${re??"latest"}`,le=G.current.get(ue);if(le)return le;const xe=J({threadId:F,setLoading:C,onStart:()=>K(null),handleError:Ne=>K(Ne),action:async Ne=>{const $e=await e.getStateHistory({threadId:Ne,checkpointId:re??void 0});if(U.current!==Ne){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ne}, now ${U.current}), discarding stale data`);return}const{checkpoints:Fe}=Nn($e),Ae=Fe.find(Be=>Be.messages&&Be.messages.length>0)??(re?Fe.find(Be=>Be.checkpointId===re):null)??Fe[0];t((Ae==null?void 0:Ae.messages)??[],{checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}),m($e),b(!!(Ae!=null&&Ae.nextCursor)),k((Ae==null?void 0:Ae.nextCursor)??null)}});G.current.set(ue,xe);try{await xe}finally{G.current.delete(ue)}return U.current===F&&(j.current=ue),xe},[e,t,J]),M=w.useCallback(async(F,re)=>{D.current=F;try{await R(F,re)}finally{D.current===F&&(D.current=null)}},[R]),q=w.useCallback(F=>{W.current=F},[]),Y=w.useCallback(F=>{_.current=F},[]),oe=w.useCallback(F=>{const re=F.threadId??U.current;if(!re||U.current&&U.current!==re)return;const{checkpoints:ue}=Nn(F);if(!ue.length)return;const le=ue.find(xe=>xe.messages&&xe.messages.length>0)??ue.find(xe=>!!xe.checkpointId)??ue[0];t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),m(F),b(!!(le!=null&&le.nextCursor)),k((le==null?void 0:le.nextCursor)??null),j.current=`${re}:latest`,W.current=null,_.current=null},[t]),V=w.useCallback(async(F,re)=>{const ue=U.current;await J({threadId:ue,setLoading:$,action:async le=>{const xe=await e.getStateHistory({threadId:le,checkpointId:F,checkpointNs:re??void 0});if(U.current!==le){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${le}, now ${U.current}), discarding stale data`);return}const{checkpoints:Ne}=Nn(xe),$e=Ne.find(Fe=>Fe.checkpointId===F&&(re?Fe.checkpointNs===re:!0));if(!$e){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:re});return}m(xe),t($e.messages??[],{checkpointId:$e.checkpointId??null,checkpointNs:$e.checkpointNs??null})}}).catch(()=>{})},[e,t,J]),L=w.useCallback((F,re)=>{t(d(),{checkpointId:F??null,checkpointNs:re??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 J({threadId:F,setLoading:N,action:async re=>{const ue=await e.getStateHistory({threadId:re,checkpointId:S});if(U.current!==re)return;const{checkpoints:le}=Nn(ue);if(le.length>0){const xe=le[le.length-1];n((xe==null?void 0:xe.messages)??[]),b(!!(xe!=null&&xe.nextCursor)),k((xe==null?void 0:xe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,J]);w.useEffect(()=>{if(!l||!o||T||c)return;if(W.current===o){W.current=null,I.current=o;return}if(_.current===o){I.current=o;return}if(D.current===o){D.current=null,I.current=o;return}if(I.current===o)return;I.current=o;const F=!P.current&&!!i&&o===s;let re;F&&i?(re=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",re,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const ue=`${o}:${re??"latest"}`;j.current!==ue&&M(o,re)},[l,o,i,a,s,T,c,M]);const ce=w.useCallback(()=>{m(null),b(!1),k(null),C(!1),N(!1),$(!1),K(null),W.current=null,_.current=null,I.current=null,j.current=null,D.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:T,isHistoryLoading:E,isLoadingCheckpoint:O,threadStateError:H,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:V,loadOlderMessages:Z,setCurrentCheckpointId:L,returnToLatest:X,handleStateHistoryEvent:oe,markSkipNextLoad:q,markStreamPendingThread:Y,resetHistoryState:ce}}const wu=w.createContext(null),bu=w.createContext(null);function Yr(){const e=w.useContext(wu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function yu(){const e=w.useContext(bu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Su({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Vr(),{currentThreadId:l}=pr(),{state:c,seed:d,prepend:p,pushUser:m,onEvent:f}=ew(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:T,loadThread:C,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:O,returnToLatest:$,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:U,resetHistoryState:I}=vu({api:a,seed:d,prepend:p,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")}),[D,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),I())},[l,d,I]);const j=w.useCallback(q=>_(()=>q),[]),G=w.useCallback(q=>P(()=>q),[]),J=w.useMemo(()=>{const q=c.assemblingId??null;return q?{assemblingMessageId:q}:null},[c.assemblingId]),R=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:J,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:T,loadOlder:N,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:O,returnToLatest:$,loadThread:C,clearThread:W,respondToInterrupt:D,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:U,resetHistoryState:I,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,b,S,k,T,N,W,E,O,$,C,D,x.messagePreviews,H,K,U,I,m,f]),M=w.useMemo(()=>({registerClearThread:j,registerRespondToInterrupt:G}),[j,G]);return u.jsx(bu.Provider,{value:M,children:u.jsx(wu.Provider,{value:R,children:e})})}const Cu=w.createContext(null),Tu=w.createContext(!1);function sw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Vr(),m=w.useMemo(()=>mn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Ov({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(au,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Su,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Tu.Provider,{value:!0,children:u.jsx(iw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function iw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=pr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:T,onEvent:C}=Yr(),{registerClearThread:E,registerRespondToInterrupt:N}=yu(),O=w.useCallback(D=>{v(D),f.current!==D.threadId&&((D.created??!f.current)&&b(D.threadId),S(D.threadId),m(D.threadId))},[v,b,S,m,f]),$=w.useCallback(D=>{D.type==="thread_info"?O(D):D.type==="state_history"?y(D):D.type==="tool.end"?i==null||i(D):C(D)},[O,y,C,i]),H=w.useCallback(D=>{a(D,$,{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,$,r,o,s]),K=w.useRef(g);w.useEffect(()=>{K.current=g},[g]);const U=w.useCallback(async(D,P,j)=>{const G=f.current;if(!G)throw new Error("No active thread to handle interrupt");const J=P?j??!0:!1,R=K.current,M={threadId:G,checkpointId:R.id??void 0,checkpointNs:R.namespace??void 0,command:{kind:"resume",value:J}};H(M)},[f,H]);w.useEffect(()=>{N(U)},[U,N]);const I=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(D){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",D)}},[t,k,m,l]);w.useEffect(()=>{E(I)},[I,E]);const W=w.useCallback(async(D,P)=>{let j=f.current;const G=(D==null?void 0:D.text)??"",J=(D==null?void 0:D.attachments)??[],R=(G==null?void 0:G.trim())??"",M={...(D==null?void 0:D.payload)??{}},q=Array.isArray(M.messages)?M.messages:void 0;q&&delete M.messages;const Y=!!(q&&q.length);if(!j&&!R&&J.length===0&&!Y)return;if(!j){const xe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ne=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);j=`${xe}${Ne}`,b(j),m(j)}const{contentParts:oe,filesInfo:V}=await ru(J),L=[...oe];R&&L.push({type:"text",text:G});const X=P==null?void 0:P.originalMessageId,Z=!!(P!=null&&P.edit&&X),ce=!Y&&L.length>0;let F=null;ce&&(F={id:Z?X:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},Z?T(F,X):T(F));const re=Y?q:F?[F]:[],ue={...M,...V.length?{files_info:V}:{}};re.length?ue.messages=re:"messages"in ue||(ue.messages=[]);const le={threadId:j,payload:ue,checkpointId:g.id??void 0,checkpointNs:g.namespace??void 0,edit:!!(P!=null&&P.edit),timelineCheckpoints:x};H(le)},[g,f,b,T,H,x]),_=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:p}),[c,d,W,l,p]);return u.jsx(Cu.Provider,{value:_,children:e})}function Ri(){const e=w.useContext(Cu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function aw(){return w.useContext(Tu)}function ku(e){return typeof e=="object"&&e!==null}function lw(e,t){if(Object.is(e,t))return!0;if(!ku(e)||!ku(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 Eu(e){const t=w.useRef(e),n=w.useRef(e);return lw(t.current,e)||(t.current=e,n.current=e),n.current}function Xr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Eu(t),m=Jr(a),f=Jr(l),v=Jr(i),g=Jr(c),x=Jr(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:p,children:u.jsx(sw,{...y,children:e})})}function Jr(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 mr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function cw(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function Iu(){const e=[mr("__API_BASE_URL__"),mr("__CHAT_API_BASE_URL__"),mr("__CHAT_API_URL__")];for(const t of e){const n=cw(t);if(n)return n}}function Nu(){const e=[mr("__API_AUTH_TOKEN__"),mr("__CHAT_API_KEY__"),mr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Au(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function ju(){const e={},t=Iu(),n=Nu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function _u(){const e=ju(),t=An.getAuthToken(),n=Iu();return{apiBaseUrl:Au(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||Nu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Mi="chat-settings";function Pu(){try{const e=localStorage.getItem(Mi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Ru(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Mi,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function uw(){const e=_u(),t=Pu(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Au(An.baseUrl,r,e.apiBaseUrl)}}function dw(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Ru(e)}function te(...e){return Qg.twMerge(Zg.clsx(e))}const fw=Dr.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"}}),lt=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:te(fw({variant:t,size:n,className:e})),ref:s,...o})});lt.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 Mu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Mu(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():Mu(e[o],null)}}}}function Oe(...e){return h.useCallback(jn(...e),e)}function pw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function sn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,hw(o,...t)]}function hw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},mw=h[" useInsertionEffect ".trim().toString()]||It;function _n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=gw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=xw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function gw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return mw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function xw(e){return typeof e=="function"}var vw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=vw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Oi(e,t){e&&Lr.flushSync(()=>e.dispatchEvent(t))}function Ko(e){const t=e+"CollectionProvider",[n,r]=sn(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=qt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=Oe(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=qt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),T=Oe(x,k),C=s(d,y);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:T,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(`[${p}]`));return Array.from(x.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var ww=h.createContext(void 0);function qo(e){const t=h.useContext(ww);return e||t||"ltr"}function mt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function bw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var yw="DismissableLayer",Di="dismissableLayer.update",Sw="dismissableLayer.pointerDownOutside",Cw="dismissableLayer.focusOutside",Ou,Du=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Du),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=Oe(t,E=>p(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,T=kw(E=>{const N=E.target,O=[...c.branches].some($=>$.contains(N));!k||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),C=Ew(E=>{const N=E.target;[...c.branches].some($=>$.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return bw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ou=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),$u(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ou)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),$u())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Di,E),()=>document.removeEventListener(Di,E)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,T.onPointerDownCapture)})});gr.displayName=yw;var Tw="DismissableLayerBranch",Lu=h.forwardRef((e,t)=>{const n=h.useContext(Du),r=h.useRef(null),o=Oe(t,r);return h.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})});Lu.displayName=Tw;function kw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Fu(Sw,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 Ew(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Fu(Cw,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 $u(){const e=new CustomEvent(Di);document.dispatchEvent(e)}function Fu(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?Oi(o,s):o.dispatchEvent(s)}var Iw=gr,Nw=Lu,Li=0;function $i(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Bu()),document.body.insertAdjacentElement("beforeend",e[1]??Bu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function Bu(){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 Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",zu={bubbles:!1,cancelable:!0},Aw="FocusScope",Go=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=mt(o),d=mt(s),p=h.useRef(null),m=Oe(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:Pn(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Pn(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Pn(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]),h.useEffect(()=>{if(a){Wu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,zu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(jw(Ow(Hu(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,zu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Wu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=_w(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Pn(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Pn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Go.displayName=Aw;function jw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function _w(e){const t=Hu(e),n=Uu(t,e),r=Uu(t.reverse(),e);return[n,r]}function Hu(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 Uu(e,t){for(const n of e)if(!Pw(n,{upTo:t}))return n}function Pw(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 Rw(e){return e instanceof HTMLInputElement&&"select"in e}function Pn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Rw(e)&&t&&e.select()}}var Wu=Mw();function Mw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Vu(e,t),e.unshift(t)},remove(t){var n;e=Vu(e,t),(n=e[0])==null||n.resume()}}}function Vu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ow(e){return e.filter(t=>t.tagName!=="A")}var Dw=h[" useId ".trim().toString()]||(()=>{}),Lw=0;function At(e){const[t,n]=h.useState(Dw());return It(()=>{n(r=>r??String(Lw++))},[e]),t?`radix-${t}`:""}const $w=["top","right","bottom","left"],Rn=Math.min,Xt=Math.max,Yo=Math.round,Xo=Math.floor,gn=e=>({x:e,y:e}),Fw={left:"right",right:"left",bottom:"top",top:"bottom"},Bw={start:"end",end:"start"};function zi(e,t,n){return Xt(e,Rn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function xr(e){return e.split("-")[1]}function Hi(e){return e==="x"?"y":"x"}function Ui(e){return e==="y"?"height":"width"}const zw=new Set(["top","bottom"]);function xn(e){return zw.has(En(e))?"y":"x"}function Wi(e){return Hi(xn(e))}function Hw(e,t,n){n===void 0&&(n=!1);const r=xr(e),o=Wi(e),s=Ui(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Jo(i)),[i,Jo(i)]}function Uw(e){const t=Jo(e);return[Vi(e),t,Vi(t)]}function Vi(e){return e.replace(/start|end/g,t=>Bw[t])}const Ku=["left","right"],qu=["right","left"],Ww=["top","bottom"],Vw=["bottom","top"];function Kw(e,t,n){switch(e){case"top":case"bottom":return n?t?qu:Ku:t?Ku:qu;case"left":case"right":return t?Ww:Vw;default:return[]}}function qw(e,t,n,r){const o=xr(e);let s=Kw(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Vi)))),s}function Jo(e){return e.replace(/left|right|bottom|top/g,t=>Fw[t])}function Gw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Gu(e){return typeof e!="number"?Gw(e):{top:e,right:e,bottom:e,left:e}}function Zo(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 Yu(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Wi(t),a=Ui(i),l=En(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(xr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const Yw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Yu(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:T}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,p=S??p,f={...f,[x]:{...f[x],...k}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:p}=Yu(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Zr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=kn(t,e),v=Gu(f),x=a[m?p==="floating"?"reference":"floating":p],y=Zo(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=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-T.top+v.top)/k.y,bottom:(T.bottom-y.bottom+v.bottom)/k.y,left:(y.left-T.left+v.left)/k.x,right:(T.right-y.right+v.right)/k.x}}const Xw=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}=kn(e,t)||{};if(c==null)return{};const p=Gu(d),m={x:n,y:r},f=Wi(o),v=Ui(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],T=m[f]-s.reference[f],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[v]);const N=k/2-T/2,O=E/2-g[v]/2-1,$=Rn(p[y],O),H=Rn(p[b],O),K=$,U=E-g[v]-H,I=E/2-g[v]/2+N,W=zi(K,I,U),_=!l.arrow&&xr(o)!=null&&I!==W&&s.reference[v]/2-(I<K?$:H)-g[v]/2<0,D=_?I<K?I-K:I-U:0;return{[f]:m[f]+D,data:{[f]:W,centerOffset:I-W-D,..._&&{alignmentOffset:D}},reset:_}}}),Jw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=En(o),b=xn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(S||!g?[Jo(a)]:Uw(a)),C=v!=="none";!m&&C&&T.push(...qw(a,g,v,k));const E=[a,...T],N=await Zr(t,x),O=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(N[y]),p){const I=Hw(o,i,k);O.push(N[I[0]],N[I[1]])}if($=[...$,{placement:o,overflows:O}],!O.every(I=>I<=0)){var H,K;const I=(((H=s.flip)==null?void 0:H.index)||0)+1,W=E[I];if(W&&(!(p==="alignment"?b!==xn(W):!1)||$.every(P=>xn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:I,overflows:$},reset:{placement:W}};let _=(K=$.filter(D=>D.overflows[0]<=0).sort((D,P)=>D.overflows[1]-P.overflows[1])[0])==null?void 0:K.placement;if(!_)switch(f){case"bestFit":{var U;const D=(U=$.filter(P=>{if(C){const j=xn(P.placement);return j===b||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,G)=>j+G,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:U[0];D&&(_=D);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Xu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ju(e){return $w.some(t=>e[t]>=0)}const Zw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=kn(e,t);switch(r){case"referenceHidden":{const s=await Zr(t,{...o,elementContext:"reference"}),i=Xu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Ju(i)}}}case"escaped":{const s=await Zr(t,{...o,altBoundary:!0}),i=Xu(s,n.floating);return{data:{escapedOffsets:i,escaped:Ju(i)}}}default:return{}}}}},Zu=new Set(["left","top"]);async function Qw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=En(n),a=xr(n),l=xn(n)==="y",c=Zu.has(i)?-1:1,d=s&&l?-1:1,p=kn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const eb=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 Qw(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}}}}},tb=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}=kn(e,t),c={x:n,y:r},d=await Zr(t,l),p=xn(En(o)),m=Hi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=zi(b,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=zi(b,v,S)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},nb=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}=kn(e,t),d={x:n,y:r},p=xn(o),m=Hi(p);let f=d[m],v=d[p];const g=kn(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,T=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>T&&(f=T)}if(c){var y,b;const S=m==="y"?"width":"height",k=Zu.has(En(o)),T=s.reference[p]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),C=s.reference[p]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<T?v=T:v>C&&(v=C)}return{[m]:f,[p]:v}}}},rb=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}=kn(e,t),d=await Zr(t,c),p=En(o),m=xr(o),f=xn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=Rn(g-d[x],b),T=Rn(v-d[y],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!m){const $=Xt(d.left,0),H=Xt(d.right,0),K=Xt(d.top,0),U=Xt(d.bottom,0);f?N=v-2*($!==0||H!==0?$+H:Xt(d.left,d.right)):E=g-2*(K!==0||U!==0?K+U:Xt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function Qo(){return typeof window<"u"}function vr(e){return Qu(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Qu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Qu(e){return Qo()?e instanceof Node||e instanceof Jt(e).Node:!1}function an(e){return Qo()?e instanceof Element||e instanceof Jt(e).Element:!1}function wn(e){return Qo()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function ed(e){return!Qo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const ob=new Set(["inline","contents"]);function Qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ob.has(o)}const sb=new Set(["table","td","th"]);function ib(e){return sb.has(vr(e))}const ab=[":popover-open",":modal"];function es(e){return ab.some(t=>{try{return e.matches(t)}catch{return!1}})}const lb=["transform","translate","scale","rotate","perspective"],cb=["transform","translate","scale","rotate","perspective","filter"],ub=["paint","layout","strict","content"];function Ki(e){const t=qi(),n=an(e)?ln(e):e;return lb.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)||cb.some(r=>(n.willChange||"").includes(r))||ub.some(r=>(n.contain||"").includes(r))}function db(e){let t=Mn(e);for(;wn(t)&&!wr(t);){if(Ki(t))return t;if(es(t))return null;t=Mn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fb=new Set(["html","body","#document"]);function wr(e){return fb.has(vr(e))}function ln(e){return Jt(e).getComputedStyle(e)}function ts(e){return an(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ed(e)&&e.host||vn(e);return ed(t)?t.host:t}function td(e){const t=Mn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Qr(t)?t:td(t)}function eo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=td(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=Gi(i);return t.concat(i,i.visualViewport||[],Qr(o)?o:[],a&&n?eo(a):[])}return t.concat(o,eo(o,[],n))}function Gi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nd(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Yo(n)!==s||Yo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Yi(e){return an(e)?e:e.contextElement}function br(e){const t=Yi(e);if(!wn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=nd(t);let i=(s?Yo(n.width):n.width)/r,a=(s?Yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const pb=gn(0);function rd(e){const t=Jt(e);return!qi()||!t.visualViewport?pb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function Yn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Yi(e);let i=gn(1);t&&(r?an(r)&&(i=br(r)):i=br(e));const a=hb(s,n,r)?rd(s):gn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Jt(s),f=r&&an(r)?Jt(r):r;let v=m,g=Gi(v);for(;g&&r&&f!==v;){const x=br(g),y=g.getBoundingClientRect(),b=ln(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,p*=x.y,l+=S,c+=k,v=Jt(g),g=Gi(v)}}return Zo({width:d,height:p,x:l,y:c})}function ns(e,t){const n=ts(e).scrollLeft;return t?t.left+n:Yn(vn(e)).left+n}function od(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ns(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?es(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),p=wn(r);if((p||!p&&!s)&&((vr(r)!=="body"||Qr(i))&&(l=ts(r)),wn(r))){const f=Yn(r);c=br(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?od(i,l):gn(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 gb(e){return Array.from(e.getClientRects())}function xb(e){const t=vn(e),n=ts(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ns(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const sd=25;function vb(e,t){const n=Jt(e),r=vn(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=qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ns(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=sd&&(s-=v)}else c<=sd&&(s+=c);return{width:s,height:i,x:a,y:l}}const wb=new Set(["absolute","fixed"]);function bb(e,t){const n=Yn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):gn(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 id(e,t,n){let r;if(t==="viewport")r=vb(e,n);else if(t==="document")r=xb(vn(e));else if(an(t))r=bb(t,n);else{const o=rd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zo(r)}function ad(e,t){const n=Mn(e);return n===t||!an(n)||wr(n)?!1:ln(n).position==="fixed"||ad(n,t)}function yb(e,t){const n=t.get(e);if(n)return n;let r=eo(e,[],!1).filter(a=>an(a)&&vr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Mn(e):e;for(;an(i)&&!wr(i);){const a=ln(i),l=Ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&wb.has(o.position)||Qr(i)&&!l&&ad(e,i))?r=r.filter(d=>d!==i):o=a,i=Mn(i)}return t.set(e,r),r}function Sb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?es(t)?[]:yb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=id(t,d,o);return c.top=Xt(p.top,c.top),c.right=Rn(p.right,c.right),c.bottom=Rn(p.bottom,c.bottom),c.left=Xt(p.left,c.left),c},id(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Cb(e){const{width:t,height:n}=nd(e);return{width:t,height:n}}function Tb(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Yn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=ns(o)}if(r||!r&&!s)if((vr(t)!=="body"||Qr(o))&&(a=ts(t)),r){const f=Yn(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?od(o,a):gn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function Xi(e){return ln(e).position==="static"}function ld(e,t){if(!wn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function cd(e,t){const n=Jt(e);if(es(e))return n;if(!wn(e)){let o=Mn(e);for(;o&&!wr(o);){if(an(o)&&!Xi(o))return o;o=Mn(o)}return n}let r=ld(e,t);for(;r&&ib(r)&&Xi(r);)r=ld(r,t);return r&&wr(r)&&Xi(r)&&!Ki(r)?n:r||db(e)||n}const kb=async function(e){const t=this.getOffsetParent||cd,n=this.getDimensions,r=await n(e.floating);return{reference:Tb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eb(e){return ln(e).direction==="rtl"}const Ib={convertOffsetParentRelativeRectToViewportRelativeRect:mb,getDocumentElement:vn,getClippingRect:Sb,getOffsetParent:cd,getElementRects:kb,getClientRects:gb,getDimensions:Cb,getScale:br,isElement:an,isRTL:Eb};function ud(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nb(e,t){let n=null,r;const o=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Xo(p),g=Xo(o.clientWidth-(d+m)),x=Xo(o.clientHeight-(p+f)),y=Xo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,Rn(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!ud(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function Ab(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=Yi(e),d=o||s?[...c?eo(c):[],...eo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Nb(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?Yn(e):null;l&&x();function x(){const y=Yn(e);g&&!ud(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)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const jb=eb,_b=tb,Pb=Jw,Rb=rb,Mb=Zw,dd=Xw,Ob=nb,Db=(e,t,n)=>{const r=new Map,o={platform:Ib,...n},s={...o.platform,_c:r};return Yw(e,t,{...o,platform:s})};var Lb=typeof document<"u",$b=function(){},rs=Lb?w.useLayoutEffect:$b;function os(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(!os(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)&&!os(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function fd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pd(e,t){const n=fd(e);return Math.round(t*n)/n}function Ji(e){const t=h.useRef(e);return rs(()=>{t.current=e}),t}function Fb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);os(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),S=h.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,T=i||x,C=h.useRef(null),E=h.useRef(null),N=h.useRef(d),O=l!=null,$=Ji(l),H=Ji(o),K=Ji(c),U=h.useCallback(()=>{if(!C.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),Db(C.current,E.current,P).then(j=>{const G={...j,isPositioned:K.current!==!1};I.current&&!os(N.current,G)&&(N.current=G,Lr.flushSync(()=>{p(G)}))})},[m,t,n,H,K]);rs(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,p(P=>({...P,isPositioned:!1})))},[c]);const I=h.useRef(!1);rs(()=>(I.current=!0,()=>{I.current=!1}),[]),rs(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if($.current)return $.current(k,T,U);U()}},[k,T,U,$,O]);const W=h.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),_=h.useMemo(()=>({reference:k,floating:T}),[k,T]),D=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!_.floating)return P;const j=pd(_.floating,d.x),G=pd(_.floating,d.y);return a?{...P,transform:"translate("+j+"px, "+G+"px)",...fd(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:G}},[n,a,_.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:U,refs:W,elements:_,floatingStyles:D}),[d,U,W,_,D])}const Bb=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?dd({element:r.current,padding:o}).fn(n):{}:r?dd({element:r,padding:o}).fn(n):{}}}},zb=(e,t)=>({...jb(e),options:[e,t]}),Hb=(e,t)=>({..._b(e),options:[e,t]}),Ub=(e,t)=>({...Ob(e),options:[e,t]}),Wb=(e,t)=>({...Pb(e),options:[e,t]}),Vb=(e,t)=>({...Rb(e),options:[e,t]}),Kb=(e,t)=>({...Mb(e),options:[e,t]}),qb=(e,t)=>({...Bb(e),options:[e,t]});var Gb="Arrow",hd=h.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"})})});hd.displayName=Gb;var Yb=hd;function md(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Zi="Popper",[gd,yr]=sn(Zi),[Xb,xd]=gd(Zi),vd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(Xb,{scope:t,anchor:r,onAnchorChange:o,children:n})};vd.displayName=Zi;var wd="PopperAnchor",bd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=xd(wd,n),i=h.useRef(null),a=Oe(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});bd.displayName=wd;var Qi="PopperContent",[Jb,Zb]=gd(Qi),yd=h.forwardRef((e,t)=>{var V,L,X,Z,ce,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:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=xd(Qi,n),[y,b]=h.useState(null),S=Oe(t,re=>b(re)),[k,T]=h.useState(null),C=md(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,O=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],K=H.length>0,U={padding:$,boundary:H.filter(ey),altBoundary:K},{refs:I,floatingStyles:W,placement:_,isPositioned:D,middlewareData:P}=Fb({strategy:"fixed",placement:O,whileElementsMounted:(...re)=>Ab(...re,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[zb({mainAxis:o+N,alignmentAxis:i}),l&&Hb({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Ub():void 0,...U}),l&&Wb({...U}),Vb({...U,apply:({elements:re,rects:ue,availableWidth:le,availableHeight:xe})=>{const{width:Ne,height:$e}=ue.reference,Fe=re.floating.style;Fe.setProperty("--radix-popper-available-width",`${le}px`),Fe.setProperty("--radix-popper-available-height",`${xe}px`),Fe.setProperty("--radix-popper-anchor-width",`${Ne}px`),Fe.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),k&&qb({element:k,padding:a}),ty({arrowWidth:E,arrowHeight:N}),m&&Kb({strategy:"referenceHidden",...U})]}),[j,G]=Td(_),J=mt(v);It(()=>{D&&(J==null||J())},[D,J]);const R=(V=P.arrow)==null?void 0:V.x,M=(L=P.arrow)==null?void 0:L.y,q=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[Y,oe]=h.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:D?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(ce=P.transformOrigin)==null?void 0:ce.y].join(" "),...((F=P.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Jb,{scope:n,placedSide:j,onArrowChange:T,arrowX:R,arrowY:M,shouldHideArrow:q,children:u.jsx(ve.div,{"data-side":j,"data-align":G,...g,ref:S,style:{...g.style,animation:D?void 0:"none"}})})})});yd.displayName=Qi;var Sd="PopperArrow",Qb={top:"bottom",right:"left",bottom:"top",left:"right"},Cd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Zb(Sd,r),i=Qb[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(Yb,{...o,ref:n,style:{...o.style,display:"block"}})})});Cd.displayName=Sd;function ey(e){return e!==null}var ty=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]=Td(n),p={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?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Td(e){const[t,n="center"]=e.split("-");return[t,n]}var ea=vd,ta=bd,na=yd,ra=Cd,ny="Portal",to=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ao.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});to.displayName=ny;function ry(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=oy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Oe(r.ref,sy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function oy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=ry(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ss(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=ss(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ss(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=ss(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ss(e){return(e==null?void 0:e.animationName)||"none"}function sy(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 oa="rovingFocusGroup.onEntryFocus",iy={bubbles:!1,cancelable:!0},no="RovingFocusGroup",[sa,kd,ay]=Ko(no),[ly,Ed]=sn(no,[ay]),[cy,uy]=ly(no),Id=h.forwardRef((e,t)=>u.jsx(sa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(sa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(dy,{...e,ref:t})})}));Id.displayName=no;var dy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Oe(t,m),v=qo(s),[g,x]=_n({prop:i,defaultProp:a??null,onChange:l,caller:no}),[y,b]=h.useState(!1),S=mt(c),k=kd(n),T=h.useRef(!1),[C,E]=h.useState(0);return h.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(oa,S),()=>N.removeEventListener(oa,S)},[S]),u.jsx(cy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(N=>x(N),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{T.current=!0}),onFocus:ae(e.onFocus,N=>{const O=!T.current;if(N.target===N.currentTarget&&O&&!y){const $=new CustomEvent(oa,iy);if(N.currentTarget.dispatchEvent($),!$.defaultPrevented){const H=k().filter(_=>_.focusable),K=H.find(_=>_.active),U=H.find(_=>_.id===g),W=[K,U,...H].filter(Boolean).map(_=>_.ref.current);jd(W,d)}}T.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Nd="RovingFocusGroupItem",Ad=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=uy(Nd,n),p=d.currentTabStopId===c,m=kd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(sa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:p?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=hy(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?my(S,k+1):S.slice(k+1)}setTimeout(()=>jd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Ad.displayName=Nd;var fy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function py(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function hy(e,t,n){const r=py(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return fy[r]}function jd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function my(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var gy=Id,xy=Ad,vy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,is=new WeakMap,as={},ia=0,_d=function(e){return e&&(e.host||_d(e.parentNode))},wy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=_d(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})},by=function(e,t,n,r){var o=wy(t,Array.isArray(e)?e:[e]);as[n]||(as[n]=new WeakMap);var s=as[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Sr.get(m)||0)+1,x=(s.get(m)||0)+1;Sr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&is.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(),ia++,function(){i.forEach(function(p){var m=Sr.get(p)-1,f=s.get(p)-1;Sr.set(p,m),s.set(p,f),m||(is.has(p)||p.removeAttribute(r),is.delete(p)),f||p.removeAttribute(n)}),ia--,ia||(Sr=new WeakMap,Sr=new WeakMap,is=new WeakMap,as={})}},aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=vy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),by(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=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},bn.apply(this,arguments)};function Pd(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 yy(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 ls="right-scroll-bar-position",cs="width-before-scroll-bar",Sy="with-scroll-bars-hidden",Cy="--removed-body-scroll-bar-size";function la(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ty(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 ky=typeof window<"u"?h.useLayoutEffect:h.useEffect,Rd=new WeakMap;function Ey(e,t){var n=Ty(null,function(r){return e.forEach(function(o){return la(o,r)})});return ky(function(){var r=Rd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||la(a,null)}),s.forEach(function(a){o.has(a)||la(a,i)})}Rd.set(n,e)},[e]),n}function Iy(e){return e}function Ny(e,t){t===void 0&&(t=Iy);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 Ay(e){e===void 0&&(e={});var t=Ny(null);return t.options=bn({async:!0,ssr:!1},e),t}var Md=function(e){var t=e.sideCar,n=Pd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,bn({},n))};Md.isSideCarExport=!0;function jy(e,t){return e.useMedium(t),Md}var Od=Ay(),ca=function(){},us=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:ca,onWheelCapture:ca,onTouchMoveCapture:ca}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Pd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,C=Ey([n,t]),E=bn(bn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:Od,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),bn(bn({},E),{ref:C})):h.createElement(b,bn({},E,{className:l,ref:C}),a))});us.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},us.classNames={fullWidth:cs,zeroRight:ls};var _y=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Py(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=_y();return t&&e.setAttribute("nonce",t),e}function Ry(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function My(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Oy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Py())&&(Ry(t,n),My(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Dy=function(){var e=Oy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Dd=function(){var e=Dy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ly={left:0,top:0,right:0,gap:0},ua=function(e){return parseInt(e||"",10)||0},$y=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[ua(n),ua(r),ua(o)]},Fy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ly;var t=$y(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])}},By=Dd(),Cr="data-scroll-locked",zy=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(
|
|
37
|
+
`))>=0;){const Se=Ze.slice(0,ne);Ze=Ze.slice(ne+2);const dt=Se.split(/\r?\n/),we=[];for(const Fe of dt)if(!(!Fe||Fe.startsWith(":"))&&Fe.startsWith("data:")){const Xe=Fe.slice(5);we.push(Xe.startsWith(" ")?Xe.slice(1):Xe)}const Me=we.join(`
|
|
38
|
+
`);if(!Me)continue;let Ue;try{Ue=JSON.parse(Me)}catch{console.debug("[use-chat] malformed SSE:",Me.slice(0,200));continue}const Et=ou(Ue)?Ue.data:Ue;if(!Et){console.warn("[use-chat] dropped envelope event without payload",Ue);continue}const Ke=Et;Ct=Date.now();const wt=Ke.seq;if(wt!==void 0){if(wt<=xt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:wt,lastProcessedSeq:xt,type:Ke.type});continue}xt>0&&wt>xt+1&&((L=_==null?void 0:_.onGap)==null||L.call(_,{from:xt,to:wt})),xt=wt,T.current=wt,x(wt)}if(Ke.type==="checkpoint")E.current=Ke.checkpointId??null,N.current=Ke.checkpointNs??null,v(Ke.checkpointId??null);else if(Ke.type==="state_history"){O.current=Ke;try{const Xe=jn(Ke).latest;Xe&&(E.current=Xe.checkpointId??null,N.current=Xe.checkpointNs??null,v(Xe.checkpointId??null))}catch(Fe){console.warn("[use-chat] Failed to hydrate state_history payload",Fe)}}try{W==null||W(Ke)}catch(Fe){console.error("[use-chat] Error in onEvent callback:",Fe,"for event:",Ke.type)}if(Ke.type==="message.delta"){const Fe=Ke.delta.filter(Xe=>Xe.type==="text").map(Xe=>Xe.text).join("");Fe&&e.autoAppendAssistant!==!1&&(St.push(Fe),Mt())}else if(Ke.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Y=_==null?void 0:_.onHeartbeat)==null||Y.call(_,Ke)}catch(Fe){console.warn("[use-chat] heartbeat callback failed",Fe)}}else if(at!==null&&cancelAnimationFrame(at),Rt(),Ke.type==="checkpoint")v(Ke.checkpointId);else if(Ke.type==="error"){const Fe=Ke;if(d(Fe.message),P="error",j=Fe.message,Fe.error_type==="auth_error"||Fe.code==="TOKEN_EXPIRED"||((J=Fe.message)==null?void 0:J.includes("token"))||((ce=Fe.message)==null?void 0:ce.includes("401"))||((F=Fe.message)==null?void 0:F.includes("unauthorized"))||((re=Fe.message)==null?void 0:re.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Fe.message);try{(ue=_==null?void 0:_.onAuthError)==null||ue.call(_,Fe.message)}catch(Vt){console.warn("[use-chat] onAuthError handler failed",Vt)}D.abort()}}}}Rt(),P===null&&!D.signal.aborted&&(P="complete")}catch(Ve){if(Ve.name==="AbortError")P=P??"aborted";else{const ge=Ve.message||String(Ve);P="error",j=ge,d(ge),(le=_==null?void 0:_.onError)==null||le.call(_,ge)}}finally{try{await it.cancel()}catch{}finally{(xe=it.releaseLock)==null||xe.call(it)}at!==null&&typeof window<"u"&&window.cancelAnimationFrame(at),clearInterval(Tt)}}catch(Ae){if(Ae.name==="AbortError")P=P??"aborted";else{const Be=Ae.message||String(Ae);P="error",j=Be,d(Be),(Ne=_==null?void 0:_.onError)==null||Ne.call(_,Be),G||((_e=_==null?void 0:_.onConnectionError)==null||_e.call(_,Be),G=!0)}}finally{const Ae=T.current,Be=E.current,tt=N.current,qe=O.current,ze=P??(D.signal.aborted?"aborted":j?"error":"complete");try{(De=_==null?void 0:_.onClosed)==null||De.call(_,{reason:ze,lastSeq:Ae,lastCheckpointId:Be,lastCheckpointNs:tt,lastStateHistory:qe,error:j})}catch(it){console.warn("[use-chat] onClosed callback failed",it)}l(!1),b(!1),S.current=null,T.current=0,x(0),C.current=null}})(),{close:()=>D.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var I;k.current=!1,(I=S.current)==null||I.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:U,stop:K,clear:H,setToken:$}}const Lv=["detail","message","error","description","title"];function Wo(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=Wo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Lv){const r=Wo(t[n]);if(r)return r}if("errors"in t){const n=Wo(t.errors);if(n)return n}}return null}function $v(e){if(!e)return"Request failed";const t=e.response,n=Wo(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 su({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),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,T]=w.useState(!1),C=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{C.current=a},[a]);const N=w.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const j=String(P);m(j),n==null||n(j)}finally{d(!1)}},[e,n]),O=w.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const j=String(P);y(j),n==null||n(j)}finally{x(!1)}},[e,n]);w.useEffect(()=>{N()},[N]),w.useEffect(()=>{O()},[O]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async P=>{try{const j=await e.createThread(P);return l(j.threadId),await N(),j.threadId}catch(j){const G=String(j);return n==null||n(G),null}},[e,n,N]),H=w.useCallback(async P=>{const j=s;i(Z=>Z.filter(R=>R.threadId!==P));const G=new AbortController;E.current.set(P,G);try{await e.deleteThread(P),C.current===P&&(l(null),o==null||o())}catch(Z){i(j);const R=String(Z);n==null||n(R)}finally{E.current.delete(P)}},[e,o,n,s]),K=w.useCallback(async(P,j)=>{try{await e.updateThread(P,j),await N()}catch(G){n==null||n(String(G))}},[e,n,N]),U=w.useCallback(async(P,j)=>{T(!0),S("Sharing thread…");try{await e.shareThread(P,j),await O(),S("Shared successfully")}catch(G){const Z=$v(G);throw n==null||n(Z),S(`Failed to share: ${Z}`),new Error(Z)}finally{T(!1)}},[e,n,O]),I=w.useCallback(async(P,j)=>{try{await e.unshareThread(P,j),await O()}catch(G){const Z=String(G);throw n==null||n(Z),G}},[e,n,O]),W=w.useMemo(()=>({createThread:$,deleteThread:H,renameThread:K,refreshThreads:N,refreshSharedThreads:O,shareThread:U,unshareThread:I}),[$,H,K,N,O,U,I]),_=w.useCallback(P=>{if(!(P!=null&&P.threadId))return;const j={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(G=>{let Z=!1;const R=G.map(M=>M.threadId===j.threadId?(Z=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...M,title:j.title??M.title,updatedAt:j.updatedAt??M.updatedAt,messageCount:j.messageCount??M.messageCount}):M);return Z?R:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...G])})},[]),D=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:C,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:_,shareInFlight:k,shareStatus:b,clearShareStatus:D}}const iu=w.createContext(null);function au({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Vr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=su({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(iu.Provider,{value:b,children:e})}function pr(){const e=w.useContext(iu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ni(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 lu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Kr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Kr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(lu(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=Kr(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 hr(e){if(typeof e=="string")return e;if(lu(e))return"";try{const t=Kr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Fv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Bv(e){const t=hr(e);return typeof e=="string"&&Fv(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=Ni(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 zv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ai(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 Vo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Hv(e){const t=r=>{try{const o=Kr(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 Uv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function cu(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 Wv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Vv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Kv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Wv(n),i=o?`data:${s};base64,${e}`:t,a=Vv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function qv(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 Kv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function uu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ji(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 Gr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Gv(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 du(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function fu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Yv(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??fu(e);let l="",c=e.slice();if(s){const p=Xv(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function pu(e){return e.replace(/\s+/g," ").trim()}function Xv(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=pu(e),o=pu(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 Jv(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 Gr(e,r,s)}return e}function Zv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Qv={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ew(e,t){var n;switch(t.type){case"reset":return{messages:ji(((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=ji(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=ji(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 hu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>hu(o,s),e):e}default:return e}}function tw(e=[]){const[t,n]=w.useReducer(ew,{...Qv,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,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function hu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Zv(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 rw(e,t);if(t.type==="tool.progress")return ow(e,t);if(t.type==="tool.end")return sw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??du(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(T=>T.id===s&&T.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:fu(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}=Yv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Gr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.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??du(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Jv(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=jn(t),i=s.interrupt,a=s.latest,l=i===null?Gv(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 _i(e){return e.call_id??e.id??null}function mu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function gu(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 Pi(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||Ai(r).toolCallId===t)return n}return-1}function nw(e){if(e==null)return[];const t=qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=hr(t??e);return n?[{type:"text",text:n}]:[]}function xu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function rw(e,t){const n=_i(t),r=Pi(e.messages,n),o=t.name??t.tool??void 0,s=mu(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:Gr(e.messages,r,d)}}const i=gu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ow(e,t){const n=_i(t);if(!n)return e;const r=Pi(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=xu(e.messages[r],o);return{...e,messages:Gr(e.messages,r,a)}}function sw(e,t){const n=_i(t),r=mu(t);let o=e.messages,s=Pi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,gu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=nw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=xu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Gr(o,s,f)}}function vu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=w.useState(null),v=w.useMemo(()=>jn(p),[p]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[T,C]=w.useState(!1),[E,N]=w.useState(!1),[O,$]=w.useState(!1),[H,K]=w.useState(null),U=w.useRef(o),I=w.useRef(null),W=w.useRef(null),_=w.useRef(null),D=w.useRef(null),P=w.useRef(!1),j=w.useRef(null),G=w.useRef(new Map);w.useEffect(()=>{U.current=o},[o]);const Z=w.useCallback(async F=>{var ue,le;if(!F.threadId)return;const re=F.threadId;(ue=F.onStart)==null||ue.call(F),F.setLoading(!0);try{await F.action(re)}catch(xe){if(U.current===re){const Ne=String(xe);(le=F.handleError)==null||le.call(F,Ne),r==null||r(Ne)}throw xe}finally{F.setLoading(!1)}},[r]),R=w.useCallback(async(F,re)=>{if(!F)return;const ue=`${F}:${re??"latest"}`,le=G.current.get(ue);if(le)return le;const xe=Z({threadId:F,setLoading:C,onStart:()=>K(null),handleError:Ne=>K(Ne),action:async Ne=>{const _e=await e.getStateHistory({threadId:Ne,checkpointId:re??void 0});if(U.current!==Ne){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ne}, now ${U.current}), discarding stale data`);return}const{checkpoints:De}=jn(_e),Ae=De.find(Be=>Be.messages&&Be.messages.length>0)??(re?De.find(Be=>Be.checkpointId===re):null)??De[0];t((Ae==null?void 0:Ae.messages)??[],{checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}),m(_e),b(!!(Ae!=null&&Ae.nextCursor)),k((Ae==null?void 0:Ae.nextCursor)??null)}});G.current.set(ue,xe);try{await xe}finally{G.current.delete(ue)}return U.current===F&&(j.current=ue),xe},[e,t,Z]),M=w.useCallback(async(F,re)=>{D.current=F;try{await R(F,re)}finally{D.current===F&&(D.current=null)}},[R]),q=w.useCallback(F=>{W.current=F},[]),X=w.useCallback(F=>{_.current=F},[]),oe=w.useCallback(F=>{const re=F.threadId??U.current;if(!re||U.current&&U.current!==re)return;const{checkpoints:ue}=jn(F);if(!ue.length)return;const le=ue.find(xe=>xe.messages&&xe.messages.length>0)??ue.find(xe=>!!xe.checkpointId)??ue[0];t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),m(F),b(!!(le!=null&&le.nextCursor)),k((le==null?void 0:le.nextCursor)??null),j.current=`${re}:latest`,W.current=null,_.current=null},[t]),V=w.useCallback(async(F,re)=>{const ue=U.current;await Z({threadId:ue,setLoading:$,action:async le=>{const xe=await e.getStateHistory({threadId:le,checkpointId:F,checkpointNs:re??void 0});if(U.current!==le){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${le}, now ${U.current}), discarding stale data`);return}const{checkpoints:Ne}=jn(xe),_e=Ne.find(De=>De.checkpointId===F&&(re?De.checkpointNs===re:!0));if(!_e){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:re});return}m(xe),t(_e.messages??[],{checkpointId:_e.checkpointId??null,checkpointNs:_e.checkpointNs??null})}}).catch(()=>{})},[e,t,Z]),L=w.useCallback((F,re)=>{t(d(),{checkpointId:F??null,checkpointNs:re??null})},[d,t]),Y=w.useCallback(async()=>{U.current&&await M(U.current)},[M]),J=w.useCallback(async()=>{const F=U.current;!F||!S||await Z({threadId:F,setLoading:N,action:async re=>{const ue=await e.getStateHistory({threadId:re,checkpointId:S});if(U.current!==re)return;const{checkpoints:le}=jn(ue);if(le.length>0){const xe=le[le.length-1];n((xe==null?void 0:xe.messages)??[]),b(!!(xe!=null&&xe.nextCursor)),k((xe==null?void 0:xe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,Z]);w.useEffect(()=>{if(!l||!o||T||c)return;if(W.current===o){W.current=null,I.current=o;return}if(_.current===o){I.current=o;return}if(D.current===o){D.current=null,I.current=o;return}if(I.current===o)return;I.current=o;const F=!P.current&&!!i&&o===s;let re;F&&i?(re=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",re,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const ue=`${o}:${re??"latest"}`;j.current!==ue&&M(o,re)},[l,o,i,a,s,T,c,M]);const ce=w.useCallback(()=>{m(null),b(!1),k(null),C(!1),N(!1),$(!1),K(null),W.current=null,_.current=null,I.current=null,j.current=null,D.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:T,isHistoryLoading:E,isLoadingCheckpoint:O,threadStateError:H,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:V,loadOlderMessages:J,setCurrentCheckpointId:L,returnToLatest:Y,handleStateHistoryEvent:oe,markSkipNextLoad:q,markStreamPendingThread:X,resetHistoryState:ce}}const wu=w.createContext(null),bu=w.createContext(null);function Yr(){const e=w.useContext(wu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function yu(){const e=w.useContext(bu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Su({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Vr(),{currentThreadId:l}=pr(),{state:c,seed:d,prepend:p,pushUser:m,onEvent:f}=tw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:T,loadThread:C,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:O,returnToLatest:$,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:U,resetHistoryState:I}=vu({api:a,seed:d,prepend:p,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")}),[D,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),I())},[l,d,I]);const j=w.useCallback(q=>_(()=>q),[]),G=w.useCallback(q=>P(()=>q),[]),Z=w.useMemo(()=>{const q=c.assemblingId??null;return q?{assemblingMessageId:q}:null},[c.assemblingId]),R=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:Z,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:T,loadOlder:N,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:O,returnToLatest:$,loadThread:C,clearThread:W,respondToInterrupt:D,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:U,resetHistoryState:I,pushUser:m,onEvent:f}),[l,c,v,g,x,Z,y,b,S,k,T,N,W,E,O,$,C,D,x.messagePreviews,H,K,U,I,m,f]),M=w.useMemo(()=>({registerClearThread:j,registerRespondToInterrupt:G}),[j,G]);return u.jsx(bu.Provider,{value:M,children:u.jsx(wu.Provider,{value:R,children:e})})}function Cu(e,t){if(!e)return null;const n=Nn(e);if(!n)return null;const r=Nn(n.configurable)??n;return An(r,t)??null}function iw(e){const t=Cu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Cu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function aw(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 lw(e,t){const n=[...e].sort(aw);for(const r of n){if(r.messageId!==t)continue;const o=iw(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 Tu=w.createContext(null),ku=w.createContext(!1);function cw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Vr(),m=w.useMemo(()=>mn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Dv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(au,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Su,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(ku.Provider,{value:!0,children:u.jsx(uw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function uw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=pr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:T,onEvent:C}=Yr(),{registerClearThread:E,registerRespondToInterrupt:N}=yu(),O=w.useCallback(D=>{v(D),f.current!==D.threadId&&((D.created??!f.current)&&b(D.threadId),S(D.threadId),m(D.threadId))},[v,b,S,m,f]),$=w.useCallback(D=>{D.type==="thread_info"?O(D):D.type==="state_history"?y(D):D.type==="tool.end"?i==null||i(D):C(D)},[O,y,C,i]),H=w.useCallback(D=>{a(D,$,{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,$,r,o,s]),K=w.useRef(g);w.useEffect(()=>{K.current=g},[g]);const U=w.useCallback(async(D,P,j)=>{const G=f.current;if(!G)throw new Error("No active thread to handle interrupt");const Z=P?j??!0:!1,R=K.current,M={threadId:G,checkpointId:R.id??void 0,checkpointNs:R.namespace??void 0,command:{kind:"resume",value:Z}};H(M)},[f,H]);w.useEffect(()=>{N(U)},[U,N]);const I=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(D){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",D)}},[t,k,m,l]);w.useEffect(()=>{E(I)},[I,E]);const W=w.useCallback(async(D,P)=>{let j=f.current;const G=(D==null?void 0:D.text)??"",Z=(D==null?void 0:D.attachments)??[],R=(G==null?void 0:G.trim())??"",M={...(D==null?void 0:D.payload)??{}},q=Array.isArray(M.messages)?M.messages:void 0;q&&delete M.messages;const X=!!(q&&q.length);if(!j&&!R&&Z.length===0&&!X)return;if(!j){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);j=`${_e}${De}`,b(j),m(j)}const{contentParts:oe,filesInfo:V}=await ru(Z),L=[...oe];R&&L.push({type:"text",text:G});const Y=P==null?void 0:P.originalMessageId,J=!!(P!=null&&P.edit&&Y),ce=!X&&L.length>0;let F=null;ce&&(F={id:J?Y:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},J?T(F,Y):T(F));const re=X?q:F?[F]:[],ue={...M,...V.length?{files_info:V}:{}};re.length?ue.messages=re:"messages"in ue||(ue.messages=[]);let le=(P==null?void 0:P.checkpointId)??g.id??void 0,xe=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(J&&Y){const _e=lw(x,Y);le=_e.checkpointId,xe=_e.checkpointNs??void 0}const Ne={threadId:j,payload:ue,checkpointId:le,checkpointNs:xe,edit:!!(P!=null&&P.edit)};H(Ne)},[g,f,b,T,H,x]),_=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:p}),[c,d,W,l,p]);return u.jsx(Tu.Provider,{value:_,children:e})}function Ri(){const e=w.useContext(Tu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function dw(){return w.useContext(ku)}function Eu(e){return typeof e=="object"&&e!==null}function fw(e,t){if(Object.is(e,t))return!0;if(!Eu(e)||!Eu(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 Iu(e){const t=w.useRef(e),n=w.useRef(e);return fw(t.current,e)||(t.current=e,n.current=e),n.current}function Xr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Iu(t),m=Jr(a),f=Jr(l),v=Jr(i),g=Jr(c),x=Jr(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:p,children:u.jsx(cw,{...y,children:e})})}function Jr(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 mr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function pw(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function Nu(){const e=[mr("__API_BASE_URL__"),mr("__CHAT_API_BASE_URL__"),mr("__CHAT_API_URL__")];for(const t of e){const n=pw(t);if(n)return n}}function Au(){const e=[mr("__API_AUTH_TOKEN__"),mr("__CHAT_API_KEY__"),mr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ju(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function _u(){const e={},t=Nu(),n=Au();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Pu(){const e=_u(),t=_n.getAuthToken(),n=Nu();return{apiBaseUrl:ju(e.baseUrl,_n.baseUrl,n),apiKey:t||e.apiKey||Au()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Mi="chat-settings";function Ru(){try{const e=localStorage.getItem(Mi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Mu(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Mi,JSON.stringify(t)),t.apiKey&&_n.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function hw(){const e=Pu(),t=Ru(),n=_n.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ju(_n.baseUrl,r,e.apiBaseUrl)}}function mw(e){_n.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Mu(e)}function te(...e){return ex.twMerge(Qg.clsx(e))}const gw=Dr.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"}}),lt=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:te(gw({variant:t,size:n,className:e})),ref:s,...o})});lt.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 Ou(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Pn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ou(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():Ou(e[o],null)}}}}function Le(...e){return h.useCallback(Pn(...e),e)}function xw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function sn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,vw(o,...t)]}function vw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},ww=h[" useInsertionEffect ".trim().toString()]||It;function Rn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=bw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=yw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function bw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return ww(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function yw(e){return typeof e=="function"}var Sw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Sw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Oi(e,t){e&&Lr.flushSync(()=>e.dispatchEvent(t))}function Ko(e){const t=e+"CollectionProvider",[n,r]=sn(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=qt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=Le(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=qt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),T=Le(x,k),C=s(d,y);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:T,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(`[${p}]`));return Array.from(x.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Cw=h.createContext(void 0);function qo(e){const t=h.useContext(Cw);return e||t||"ltr"}function mt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Tw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var kw="DismissableLayer",Di="dismissableLayer.update",Ew="dismissableLayer.pointerDownOutside",Iw="dismissableLayer.focusOutside",Du,Lu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Lu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=Le(t,E=>p(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,T=Aw(E=>{const N=E.target,O=[...c.branches].some($=>$.contains(N));!k||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),C=jw(E=>{const N=E.target;[...c.branches].some($=>$.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Tw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Du=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Fu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Du)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Fu())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Di,E),()=>document.removeEventListener(Di,E)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,T.onPointerDownCapture)})});gr.displayName=kw;var Nw="DismissableLayerBranch",$u=h.forwardRef((e,t)=>{const n=h.useContext(Lu),r=h.useRef(null),o=Le(t,r);return h.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})});$u.displayName=Nw;function Aw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Bu(Ew,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 jw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Bu(Iw,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 Fu(){const e=new CustomEvent(Di);document.dispatchEvent(e)}function Bu(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?Oi(o,s):o.dispatchEvent(s)}var _w=gr,Pw=$u,Li=0;function $i(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??zu()),document.body.insertAdjacentElement("beforeend",e[1]??zu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function zu(){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 Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Hu={bubbles:!1,cancelable:!0},Rw="FocusScope",Go=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=mt(o),d=mt(s),p=h.useRef(null),m=Le(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:Mn(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Mn(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Mn(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]),h.useEffect(()=>{if(a){Vu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,Hu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(Mw(Fw(Uu(a)),{select:!0}),document.activeElement===g&&Mn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,Hu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Mn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Vu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=Ow(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Mn(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Mn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Go.displayName=Rw;function Mw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Mn(r,{select:t}),document.activeElement!==n)return}function Ow(e){const t=Uu(e),n=Wu(t,e),r=Wu(t.reverse(),e);return[n,r]}function Uu(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 Wu(e,t){for(const n of e)if(!Dw(n,{upTo:t}))return n}function Dw(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 Lw(e){return e instanceof HTMLInputElement&&"select"in e}function Mn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lw(e)&&t&&e.select()}}var Vu=$w();function $w(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ku(e,t),e.unshift(t)},remove(t){var n;e=Ku(e,t),(n=e[0])==null||n.resume()}}}function Ku(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Fw(e){return e.filter(t=>t.tagName!=="A")}var Bw=h[" useId ".trim().toString()]||(()=>{}),zw=0;function At(e){const[t,n]=h.useState(Bw());return It(()=>{n(r=>r??String(zw++))},[e]),t?`radix-${t}`:""}const Hw=["top","right","bottom","left"],On=Math.min,Xt=Math.max,Yo=Math.round,Xo=Math.floor,gn=e=>({x:e,y:e}),Uw={left:"right",right:"left",bottom:"top",top:"bottom"},Ww={start:"end",end:"start"};function zi(e,t,n){return Xt(e,On(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function xr(e){return e.split("-")[1]}function Hi(e){return e==="x"?"y":"x"}function Ui(e){return e==="y"?"height":"width"}const Vw=new Set(["top","bottom"]);function xn(e){return Vw.has(En(e))?"y":"x"}function Wi(e){return Hi(xn(e))}function Kw(e,t,n){n===void 0&&(n=!1);const r=xr(e),o=Wi(e),s=Ui(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Jo(i)),[i,Jo(i)]}function qw(e){const t=Jo(e);return[Vi(e),t,Vi(t)]}function Vi(e){return e.replace(/start|end/g,t=>Ww[t])}const qu=["left","right"],Gu=["right","left"],Gw=["top","bottom"],Yw=["bottom","top"];function Xw(e,t,n){switch(e){case"top":case"bottom":return n?t?Gu:qu:t?qu:Gu;case"left":case"right":return t?Gw:Yw;default:return[]}}function Jw(e,t,n,r){const o=xr(e);let s=Xw(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Vi)))),s}function Jo(e){return e.replace(/left|right|bottom|top/g,t=>Uw[t])}function Zw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Yu(e){return typeof e!="number"?Zw(e):{top:e,right:e,bottom:e,left:e}}function Zo(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 Xu(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Wi(t),a=Ui(i),l=En(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(xr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const Qw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Xu(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:T}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,p=S??p,f={...f,[x]:{...f[x],...k}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:p}=Xu(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Zr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=kn(t,e),v=Yu(f),x=a[m?p==="floating"?"reference":"floating":p],y=Zo(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=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-T.top+v.top)/k.y,bottom:(T.bottom-y.bottom+v.bottom)/k.y,left:(y.left-T.left+v.left)/k.x,right:(T.right-y.right+v.right)/k.x}}const eb=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}=kn(e,t)||{};if(c==null)return{};const p=Yu(d),m={x:n,y:r},f=Wi(o),v=Ui(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],T=m[f]-s.reference[f],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[v]);const N=k/2-T/2,O=E/2-g[v]/2-1,$=On(p[y],O),H=On(p[b],O),K=$,U=E-g[v]-H,I=E/2-g[v]/2+N,W=zi(K,I,U),_=!l.arrow&&xr(o)!=null&&I!==W&&s.reference[v]/2-(I<K?$:H)-g[v]/2<0,D=_?I<K?I-K:I-U:0;return{[f]:m[f]+D,data:{[f]:W,centerOffset:I-W-D,..._&&{alignmentOffset:D}},reset:_}}}),tb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=En(o),b=xn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(S||!g?[Jo(a)]:qw(a)),C=v!=="none";!m&&C&&T.push(...Jw(a,g,v,k));const E=[a,...T],N=await Zr(t,x),O=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(N[y]),p){const I=Kw(o,i,k);O.push(N[I[0]],N[I[1]])}if($=[...$,{placement:o,overflows:O}],!O.every(I=>I<=0)){var H,K;const I=(((H=s.flip)==null?void 0:H.index)||0)+1,W=E[I];if(W&&(!(p==="alignment"?b!==xn(W):!1)||$.every(P=>xn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:I,overflows:$},reset:{placement:W}};let _=(K=$.filter(D=>D.overflows[0]<=0).sort((D,P)=>D.overflows[1]-P.overflows[1])[0])==null?void 0:K.placement;if(!_)switch(f){case"bestFit":{var U;const D=(U=$.filter(P=>{if(C){const j=xn(P.placement);return j===b||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,G)=>j+G,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:U[0];D&&(_=D);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Ju(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Zu(e){return Hw.some(t=>e[t]>=0)}const nb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=kn(e,t);switch(r){case"referenceHidden":{const s=await Zr(t,{...o,elementContext:"reference"}),i=Ju(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Zu(i)}}}case"escaped":{const s=await Zr(t,{...o,altBoundary:!0}),i=Ju(s,n.floating);return{data:{escapedOffsets:i,escaped:Zu(i)}}}default:return{}}}}},Qu=new Set(["left","top"]);async function rb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=En(n),a=xr(n),l=xn(n)==="y",c=Qu.has(i)?-1:1,d=s&&l?-1:1,p=kn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const ob=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 rb(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}}}}},sb=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}=kn(e,t),c={x:n,y:r},d=await Zr(t,l),p=xn(En(o)),m=Hi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=zi(b,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=zi(b,v,S)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},ib=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}=kn(e,t),d={x:n,y:r},p=xn(o),m=Hi(p);let f=d[m],v=d[p];const g=kn(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,T=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>T&&(f=T)}if(c){var y,b;const S=m==="y"?"width":"height",k=Qu.has(En(o)),T=s.reference[p]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),C=s.reference[p]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<T?v=T:v>C&&(v=C)}return{[m]:f,[p]:v}}}},ab=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}=kn(e,t),d=await Zr(t,c),p=En(o),m=xr(o),f=xn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=On(g-d[x],b),T=On(v-d[y],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!m){const $=Xt(d.left,0),H=Xt(d.right,0),K=Xt(d.top,0),U=Xt(d.bottom,0);f?N=v-2*($!==0||H!==0?$+H:Xt(d.left,d.right)):E=g-2*(K!==0||U!==0?K+U:Xt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function Qo(){return typeof window<"u"}function vr(e){return ed(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(ed(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ed(e){return Qo()?e instanceof Node||e instanceof Jt(e).Node:!1}function an(e){return Qo()?e instanceof Element||e instanceof Jt(e).Element:!1}function wn(e){return Qo()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function td(e){return!Qo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const lb=new Set(["inline","contents"]);function Qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!lb.has(o)}const cb=new Set(["table","td","th"]);function ub(e){return cb.has(vr(e))}const db=[":popover-open",":modal"];function es(e){return db.some(t=>{try{return e.matches(t)}catch{return!1}})}const fb=["transform","translate","scale","rotate","perspective"],pb=["transform","translate","scale","rotate","perspective","filter"],hb=["paint","layout","strict","content"];function Ki(e){const t=qi(),n=an(e)?ln(e):e;return fb.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)||pb.some(r=>(n.willChange||"").includes(r))||hb.some(r=>(n.contain||"").includes(r))}function mb(e){let t=Dn(e);for(;wn(t)&&!wr(t);){if(Ki(t))return t;if(es(t))return null;t=Dn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const gb=new Set(["html","body","#document"]);function wr(e){return gb.has(vr(e))}function ln(e){return Jt(e).getComputedStyle(e)}function ts(e){return an(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||td(e)&&e.host||vn(e);return td(t)?t.host:t}function nd(e){const t=Dn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Qr(t)?t:nd(t)}function eo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=nd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=Gi(i);return t.concat(i,i.visualViewport||[],Qr(o)?o:[],a&&n?eo(a):[])}return t.concat(o,eo(o,[],n))}function Gi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function rd(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Yo(n)!==s||Yo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Yi(e){return an(e)?e:e.contextElement}function br(e){const t=Yi(e);if(!wn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=rd(t);let i=(s?Yo(n.width):n.width)/r,a=(s?Yo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const xb=gn(0);function od(e){const t=Jt(e);return!qi()||!t.visualViewport?xb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function Xn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Yi(e);let i=gn(1);t&&(r?an(r)&&(i=br(r)):i=br(e));const a=vb(s,n,r)?od(s):gn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Jt(s),f=r&&an(r)?Jt(r):r;let v=m,g=Gi(v);for(;g&&r&&f!==v;){const x=br(g),y=g.getBoundingClientRect(),b=ln(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,p*=x.y,l+=S,c+=k,v=Jt(g),g=Gi(v)}}return Zo({width:d,height:p,x:l,y:c})}function ns(e,t){const n=ts(e).scrollLeft;return t?t.left+n:Xn(vn(e)).left+n}function sd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ns(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function wb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?es(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),p=wn(r);if((p||!p&&!s)&&((vr(r)!=="body"||Qr(i))&&(l=ts(r)),wn(r))){const f=Xn(r);c=br(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?sd(i,l):gn(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 bb(e){return Array.from(e.getClientRects())}function yb(e){const t=vn(e),n=ts(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ns(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const id=25;function Sb(e,t){const n=Jt(e),r=vn(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=qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ns(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=id&&(s-=v)}else c<=id&&(s+=c);return{width:s,height:i,x:a,y:l}}const Cb=new Set(["absolute","fixed"]);function Tb(e,t){const n=Xn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):gn(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 ad(e,t,n){let r;if(t==="viewport")r=Sb(e,n);else if(t==="document")r=yb(vn(e));else if(an(t))r=Tb(t,n);else{const o=od(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zo(r)}function ld(e,t){const n=Dn(e);return n===t||!an(n)||wr(n)?!1:ln(n).position==="fixed"||ld(n,t)}function kb(e,t){const n=t.get(e);if(n)return n;let r=eo(e,[],!1).filter(a=>an(a)&&vr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Dn(e):e;for(;an(i)&&!wr(i);){const a=ln(i),l=Ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Cb.has(o.position)||Qr(i)&&!l&&ld(e,i))?r=r.filter(d=>d!==i):o=a,i=Dn(i)}return t.set(e,r),r}function Eb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?es(t)?[]:kb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=ad(t,d,o);return c.top=Xt(p.top,c.top),c.right=On(p.right,c.right),c.bottom=On(p.bottom,c.bottom),c.left=Xt(p.left,c.left),c},ad(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ib(e){const{width:t,height:n}=rd(e);return{width:t,height:n}}function Nb(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Xn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=ns(o)}if(r||!r&&!s)if((vr(t)!=="body"||Qr(o))&&(a=ts(t)),r){const f=Xn(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?sd(o,a):gn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function Xi(e){return ln(e).position==="static"}function cd(e,t){if(!wn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function ud(e,t){const n=Jt(e);if(es(e))return n;if(!wn(e)){let o=Dn(e);for(;o&&!wr(o);){if(an(o)&&!Xi(o))return o;o=Dn(o)}return n}let r=cd(e,t);for(;r&&ub(r)&&Xi(r);)r=cd(r,t);return r&&wr(r)&&Xi(r)&&!Ki(r)?n:r||mb(e)||n}const Ab=async function(e){const t=this.getOffsetParent||ud,n=this.getDimensions,r=await n(e.floating);return{reference:Nb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function jb(e){return ln(e).direction==="rtl"}const _b={convertOffsetParentRelativeRectToViewportRelativeRect:wb,getDocumentElement:vn,getClippingRect:Eb,getOffsetParent:ud,getElementRects:Ab,getClientRects:bb,getDimensions:Ib,getScale:br,isElement:an,isRTL:jb};function dd(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=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Xo(p),g=Xo(o.clientWidth-(d+m)),x=Xo(o.clientHeight-(p+f)),y=Xo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,On(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!dd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function Rb(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=Yi(e),d=o||s?[...c?eo(c):[],...eo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=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?Xn(e):null;l&&x();function x(){const y=Xn(e);g&&!dd(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)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Mb=ob,Ob=sb,Db=tb,Lb=ab,$b=nb,fd=eb,Fb=ib,Bb=(e,t,n)=>{const r=new Map,o={platform:_b,...n},s={...o.platform,_c:r};return Qw(e,t,{...o,platform:s})};var zb=typeof document<"u",Hb=function(){},rs=zb?w.useLayoutEffect:Hb;function os(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(!os(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)&&!os(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 hd(e,t){const n=pd(e);return Math.round(t*n)/n}function Ji(e){const t=h.useRef(e);return rs(()=>{t.current=e}),t}function Ub(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);os(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(P=>{P!==C.current&&(C.current=P,g(P))},[]),S=h.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,T=i||x,C=h.useRef(null),E=h.useRef(null),N=h.useRef(d),O=l!=null,$=Ji(l),H=Ji(o),K=Ji(c),U=h.useCallback(()=>{if(!C.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),Bb(C.current,E.current,P).then(j=>{const G={...j,isPositioned:K.current!==!1};I.current&&!os(N.current,G)&&(N.current=G,Lr.flushSync(()=>{p(G)}))})},[m,t,n,H,K]);rs(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,p(P=>({...P,isPositioned:!1})))},[c]);const I=h.useRef(!1);rs(()=>(I.current=!0,()=>{I.current=!1}),[]),rs(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if($.current)return $.current(k,T,U);U()}},[k,T,U,$,O]);const W=h.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),_=h.useMemo(()=>({reference:k,floating:T}),[k,T]),D=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!_.floating)return P;const j=hd(_.floating,d.x),G=hd(_.floating,d.y);return a?{...P,transform:"translate("+j+"px, "+G+"px)",...pd(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:G}},[n,a,_.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:U,refs:W,elements:_,floatingStyles:D}),[d,U,W,_,D])}const Wb=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?fd({element:r.current,padding:o}).fn(n):{}:r?fd({element:r,padding:o}).fn(n):{}}}},Vb=(e,t)=>({...Mb(e),options:[e,t]}),Kb=(e,t)=>({...Ob(e),options:[e,t]}),qb=(e,t)=>({...Fb(e),options:[e,t]}),Gb=(e,t)=>({...Db(e),options:[e,t]}),Yb=(e,t)=>({...Lb(e),options:[e,t]}),Xb=(e,t)=>({...$b(e),options:[e,t]}),Jb=(e,t)=>({...Wb(e),options:[e,t]});var Zb="Arrow",md=h.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"})})});md.displayName=Zb;var Qb=md;function gd(e){const[t,n]=h.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Zi="Popper",[xd,yr]=sn(Zi),[ey,vd]=xd(Zi),wd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(ey,{scope:t,anchor:r,onAnchorChange:o,children:n})};wd.displayName=Zi;var bd="PopperAnchor",yd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=vd(bd,n),i=h.useRef(null),a=Le(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});yd.displayName=bd;var Qi="PopperContent",[ty,ny]=xd(Qi),Sd=h.forwardRef((e,t)=>{var V,L,Y,J,ce,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:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=vd(Qi,n),[y,b]=h.useState(null),S=Le(t,re=>b(re)),[k,T]=h.useState(null),C=gd(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,O=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],K=H.length>0,U={padding:$,boundary:H.filter(oy),altBoundary:K},{refs:I,floatingStyles:W,placement:_,isPositioned:D,middlewareData:P}=Ub({strategy:"fixed",placement:O,whileElementsMounted:(...re)=>Rb(...re,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Vb({mainAxis:o+N,alignmentAxis:i}),l&&Kb({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?qb():void 0,...U}),l&&Gb({...U}),Yb({...U,apply:({elements:re,rects:ue,availableWidth:le,availableHeight:xe})=>{const{width:Ne,height:_e}=ue.reference,De=re.floating.style;De.setProperty("--radix-popper-available-width",`${le}px`),De.setProperty("--radix-popper-available-height",`${xe}px`),De.setProperty("--radix-popper-anchor-width",`${Ne}px`),De.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),k&&Jb({element:k,padding:a}),sy({arrowWidth:E,arrowHeight:N}),m&&Xb({strategy:"referenceHidden",...U})]}),[j,G]=kd(_),Z=mt(v);It(()=>{D&&(Z==null||Z())},[D,Z]);const R=(V=P.arrow)==null?void 0:V.x,M=(L=P.arrow)==null?void 0:L.y,q=((Y=P.arrow)==null?void 0:Y.centerOffset)!==0,[X,oe]=h.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:D?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(J=P.transformOrigin)==null?void 0:J.x,(ce=P.transformOrigin)==null?void 0:ce.y].join(" "),...((F=P.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(ty,{scope:n,placedSide:j,onArrowChange:T,arrowX:R,arrowY:M,shouldHideArrow:q,children:u.jsx(ve.div,{"data-side":j,"data-align":G,...g,ref:S,style:{...g.style,animation:D?void 0:"none"}})})})});Sd.displayName=Qi;var Cd="PopperArrow",ry={top:"bottom",right:"left",bottom:"top",left:"right"},Td=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=ny(Cd,r),i=ry[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(Qb,{...o,ref:n,style:{...o.style,display:"block"}})})});Td.displayName=Cd;function oy(e){return e!==null}var sy=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]=kd(n),p={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?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function kd(e){const[t,n="center"]=e.split("-");return[t,n]}var ea=wd,ta=yd,na=Sd,ra=Td,iy="Portal",to=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ao.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});to.displayName=iy;function ay(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=ly(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Le(r.ref,cy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function ly(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=ay(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ss(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=ss(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ss(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=ss(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ss(e){return(e==null?void 0:e.animationName)||"none"}function cy(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 oa="rovingFocusGroup.onEntryFocus",uy={bubbles:!1,cancelable:!0},no="RovingFocusGroup",[sa,Ed,dy]=Ko(no),[fy,Id]=sn(no,[dy]),[py,hy]=fy(no),Nd=h.forwardRef((e,t)=>u.jsx(sa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(sa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(my,{...e,ref:t})})}));Nd.displayName=no;var my=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Le(t,m),v=qo(s),[g,x]=Rn({prop:i,defaultProp:a??null,onChange:l,caller:no}),[y,b]=h.useState(!1),S=mt(c),k=Ed(n),T=h.useRef(!1),[C,E]=h.useState(0);return h.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(oa,S),()=>N.removeEventListener(oa,S)},[S]),u.jsx(py,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(N=>x(N),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:h.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{T.current=!0}),onFocus:ae(e.onFocus,N=>{const O=!T.current;if(N.target===N.currentTarget&&O&&!y){const $=new CustomEvent(oa,uy);if(N.currentTarget.dispatchEvent($),!$.defaultPrevented){const H=k().filter(_=>_.focusable),K=H.find(_=>_.active),U=H.find(_=>_.id===g),W=[K,U,...H].filter(Boolean).map(_=>_.ref.current);_d(W,d)}}T.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Ad="RovingFocusGroupItem",jd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=hy(Ad,n),p=d.currentTabStopId===c,m=Ed(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(sa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:p?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=vy(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?wy(S,k+1):S.slice(k+1)}setTimeout(()=>_d(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});jd.displayName=Ad;var gy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function xy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function vy(e,t,n){const r=xy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return gy[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 wy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var by=Nd,yy=jd,Sy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,is=new WeakMap,as={},ia=0,Pd=function(e){return e&&(e.host||Pd(e.parentNode))},Cy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Pd(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})},Ty=function(e,t,n,r){var o=Cy(t,Array.isArray(e)?e:[e]);as[n]||(as[n]=new WeakMap);var s=as[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Sr.get(m)||0)+1,x=(s.get(m)||0)+1;Sr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&is.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(),ia++,function(){i.forEach(function(p){var m=Sr.get(p)-1,f=s.get(p)-1;Sr.set(p,m),s.set(p,f),m||(is.has(p)||p.removeAttribute(r),is.delete(p)),f||p.removeAttribute(n)}),ia--,ia||(Sr=new WeakMap,Sr=new WeakMap,is=new WeakMap,as={})}},aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Sy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ty(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=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},bn.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 ky(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 ls="right-scroll-bar-position",cs="width-before-scroll-bar",Ey="with-scroll-bars-hidden",Iy="--removed-body-scroll-bar-size";function la(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ny(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 Ay=typeof window<"u"?h.useLayoutEffect:h.useEffect,Md=new WeakMap;function jy(e,t){var n=Ny(null,function(r){return e.forEach(function(o){return la(o,r)})});return Ay(function(){var r=Md.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||la(a,null)}),s.forEach(function(a){o.has(a)||la(a,i)})}Md.set(n,e)},[e]),n}function _y(e){return e}function Py(e,t){t===void 0&&(t=_y);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 Ry(e){e===void 0&&(e={});var t=Py(null);return t.options=bn({async:!0,ssr:!1},e),t}var Od=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 h.createElement(r,bn({},n))};Od.isSideCarExport=!0;function My(e,t){return e.useMedium(t),Od}var Dd=Ry(),ca=function(){},us=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:ca,onWheelCapture:ca,onTouchMoveCapture:ca}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,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"]),T=m,C=jy([n,t]),E=bn(bn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:Dd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),bn(bn({},E),{ref:C})):h.createElement(b,bn({},E,{className:l,ref:C}),a))});us.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},us.classNames={fullWidth:cs,zeroRight:ls};var Oy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Dy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Oy();return t&&e.setAttribute("nonce",t),e}function Ly(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $y(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Fy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Dy())&&(Ly(t,n),$y(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},By=function(){var e=Fy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ld=function(){var e=By(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},zy={left:0,top:0,right:0,gap:0},ua=function(e){return parseInt(e||"",10)||0},Hy=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[ua(n),ua(r),ua(o)]},Uy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zy;var t=Hy(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])}},Wy=Ld(),Cr="data-scroll-locked",Vy=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(Ey,` {
|
|
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(Cr,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Iy,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)}
|
|
76
|
+
`)},$d=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},Ky=function(){h.useEffect(function(){return document.body.setAttribute(Cr,($d()+1).toString()),function(){var e=$d()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},qy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Ky();var s=h.useMemo(function(){return Uy(o)},[o]);return h.createElement(Wy,{styles:Vy(s,!t,o,n?"":"!important")})},da=!1;if(typeof window<"u")try{var ds=Object.defineProperty({},"passive",{get:function(){return da=!0,!0}});window.addEventListener("test",ds,ds),window.removeEventListener("test",ds,ds)}catch{da=!1}var Tr=da?{passive:!1}:!1,Gy=function(e){return e.tagName==="TEXTAREA"},Fd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Gy(e)&&n[t]==="visible")},Yy=function(e){return Fd(e,"overflowY")},Xy=function(e){return Fd(e,"overflowX")},Bd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=zd(e,r);if(o){var s=Hd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Jy=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Zy=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},zd=function(e,t){return e==="v"?Yy(t):Xy(t)},Hd=function(e,t){return e==="v"?Jy(t):Zy(t)},Qy=function(e,t){return e==="h"&&t==="rtl"?-1:1},e0=function(e,t,n,r,o){var s=Qy(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=Hd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&zd(e,a)&&(p+=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(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},fs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ud=function(e){return[e.deltaX,e.deltaY]},Wd=function(e){return e&&"current"in e?e.current:e},t0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},n0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},Qy=0,kr=[];function e0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Qy++)[0],s=h.useState(Dd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=yy([e.lockRef.current],(e.shards||[]).map(Ud),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=fs(g),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],T,C=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&C.type==="range")return!1;var N=Fd(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=Fd(E,C)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=T),!T)return!0;var O=r.current||T;return Xy(O,x,g,O==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!kr.length||kr[kr.length-1]!==s)){var y="deltaY"in x?Hd(x):fs(x),b=t.current.filter(function(T){return T.name===x.type&&(T.target===x.target||x.target===T.shadowParent)&&Jy(T.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Ud).filter(Boolean).filter(function(T){return T.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var S={name:g,delta:x,target:y,should:b,shadowParent:t0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=fs(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,Hd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,fs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:Zy(o)}):null,f?h.createElement(Uy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function t0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const n0=jy(Od,e0);var ps=h.forwardRef(function(e,t){return h.createElement(us,bn({},e,{ref:t,sideCar:n0}))});ps.classNames=us.classNames;var fa=["Enter"," "],r0=["ArrowDown","PageUp","Home"],Wd=["ArrowUp","PageDown","End"],o0=[...r0,...Wd],s0={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},i0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ro="Menu",[oo,a0,l0]=Ko(ro),[Xn,Vd]=sn(ro,[l0,yr,Ed]),hs=yr(),Kd=Ed(),[c0,Jn]=Xn(ro),[u0,so]=Xn(ro),qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=hs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=mt(s),m=qo(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ea,{...a,children:u.jsx(c0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(u0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};qd.displayName=ro;var d0="MenuAnchor",pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return u.jsx(ta,{...o,...r,ref:t})});pa.displayName=d0;var ha="MenuPortal",[f0,Gd]=Xn(ha,{forceMount:void 0}),Yd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Jn(ha,t);return u.jsx(f0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(to,{asChild:!0,container:o,children:r})})})};Yd.displayName=ha;var en="MenuContent",[p0,ma]=Xn(en),Xd=h.forwardRef((e,t)=>{const n=Gd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(en,e.__scopeMenu),i=so(en,e.__scopeMenu);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(h0,{...o,ref:t}):u.jsx(m0,{...o,ref:t})})})})}),h0=h.forwardRef((e,t)=>{const n=Jn(en,e.__scopeMenu),r=h.useRef(null),o=Oe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),m0=h.forwardRef((e,t)=>{const n=Jn(en,e.__scopeMenu);return u.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),g0=qt.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=Jn(en,n),y=so(en,n),b=hs(n),S=Kd(n),k=a0(n),[T,C]=h.useState(null),E=h.useRef(null),N=Oe(t,E,x.onContentChange),O=h.useRef(0),$=h.useRef(""),H=h.useRef(0),K=h.useRef(null),U=h.useRef("right"),I=h.useRef(0),W=v?ps:h.Fragment,_=v?{as:g0,allowPinchZoom:!0}:void 0,D=j=>{var V,L;const G=$.current+j,J=k().filter(X=>!X.disabled),R=document.activeElement,M=(V=J.find(X=>X.ref.current===R))==null?void 0:V.textValue,q=J.map(X=>X.textValue),Y=N0(q,G,M),oe=(L=J.find(X=>X.textValue===Y))==null?void 0:L.ref.current;(function X(Z){$.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>X(""),1e3))})(G),oe&&setTimeout(()=>oe.focus())};h.useEffect(()=>()=>window.clearTimeout(O.current),[]),$i();const P=h.useCallback(j=>{var J,R;return U.current===((J=K.current)==null?void 0:J.side)&&j0(j,(R=K.current)==null?void 0:R.area)},[]);return u.jsx(p0,{scope:n,searchRef:$,onItemEnter:h.useCallback(j=>{P(j)&&j.preventDefault()},[P]),onItemLeave:h.useCallback(j=>{var G;P(j)||((G=E.current)==null||G.focus(),C(null))},[P]),onTriggerLeave:h.useCallback(j=>{P(j)&&j.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(j=>{K.current=j},[]),children:u.jsx(W,{..._,children:u.jsx(Go,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,j=>{var G;j.preventDefault(),(G=E.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(gy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:ae(l,j=>{y.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(na,{role:"menu","aria-orientation":"vertical","data-state":hf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,j=>{const J=j.target.closest("[data-radix-menu-content]")===j.currentTarget,R=j.ctrlKey||j.altKey||j.metaKey,M=j.key.length===1;J&&(j.key==="Tab"&&j.preventDefault(),!R&&M&&D(j.key));const q=E.current;if(j.target!==q||!o0.includes(j.key))return;j.preventDefault();const oe=k().filter(V=>!V.disabled).map(V=>V.ref.current);Wd.includes(j.key)&&oe.reverse(),E0(oe)}),onBlur:ae(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(O.current),$.current="")}),onPointerMove:ae(e.onPointerMove,ao(j=>{const G=j.target,J=I.current!==j.clientX;if(j.currentTarget.contains(G)&&J){const R=j.clientX>I.current?"right":"left";U.current=R,I.current=j.clientX}}))})})})})})})});Xd.displayName=en;var x0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});xa.displayName=x0;var v0="MenuLabel",Jd=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Jd.displayName=v0;var ms="MenuItem",Zd="menu.itemSelect",gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=so(ms,e.__scopeMenu),a=ma(ms,e.__scopeMenu),l=Oe(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Zd,{bubbles:!0,cancelable:!0});p.addEventListener(Zd,f=>r==null?void 0:r(f),{once:!0}),Oi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Qd,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ae(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||fa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});gs.displayName=ms;var Qd=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(ms,n),a=Kd(n),l=h.useRef(null),c=Oe(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(oo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(xy,{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,ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,ao(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>p(!0)),onBlur:ae(e.onBlur,()=>p(!1))})})})}),w0="MenuCheckboxItem",ef=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(sf,{scope:e.__scopeMenu,checked:n,children:u.jsx(gs,{role:"menuitemcheckbox","aria-checked":xs(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(xs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ef.displayName=w0;var tf="MenuRadioGroup",[b0,y0]=Xn(tf,{value:void 0,onValueChange:()=>{}}),nf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return u.jsx(b0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(xa,{...o,ref:t})})});nf.displayName=tf;var rf="MenuRadioItem",of=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=y0(rf,e.__scopeMenu),s=n===o.value;return u.jsx(sf,{scope:e.__scopeMenu,checked:s,children:u.jsx(gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});of.displayName=rf;var va="MenuItemIndicator",[sf,S0]=Xn(va,{checked:!1}),af=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=S0(va,n);return u.jsx(zt,{present:r||xs(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":wa(s.checked)})})});af.displayName=va;var C0="MenuSeparator",lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});lf.displayName=C0;var T0="MenuArrow",cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return u.jsx(ra,{...o,...r,ref:t})});cf.displayName=T0;var k0="MenuSub",[a1,uf]=Xn(k0),io="MenuSubTrigger",df=h.forwardRef((e,t)=>{const n=Jn(io,e.__scopeMenu),r=so(io,e.__scopeMenu),o=uf(io,e.__scopeMenu),s=ma(io,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(pa,{asChild:!0,...c,children:u.jsx(Qd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":hf(n.open),...e,ref:jn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,ao(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,ao(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.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(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||s0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});df.displayName=io;var ff="MenuSubContent",pf=h.forwardRef((e,t)=>{const n=Gd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(en,e.__scopeMenu),i=so(en,e.__scopeMenu),a=uf(ff,e.__scopeMenu),l=h.useRef(null),c=Oe(t,l);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:u.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside: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 p=d.currentTarget.contains(d.target),m=i0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});pf.displayName=ff;function hf(e){return e?"open":"closed"}function xs(e){return e==="indeterminate"}function wa(e){return xs(e)?"indeterminate":e?"checked":"unchecked"}function E0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function I0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function N0(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=I0(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 A0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function j0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return A0(n,t)}function ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var _0=qd,P0=pa,R0=Yd,M0=Xd,O0=xa,D0=Jd,L0=gs,$0=ef,F0=nf,B0=of,z0=af,H0=lf,U0=cf,W0=df,V0=pf,vs="DropdownMenu",[K0,l1]=sn(vs,[Vd]),Dt=Vd(),[q0,mf]=K0(vs),gf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=h.useRef(null),[d,p]=_n({prop:o,defaultProp:s??!1,onChange:i,caller:vs});return u.jsx(q0,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(_0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};gf.displayName=vs;var xf="DropdownMenuTrigger",vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=mf(xf,n),i=Dt(n);return u.jsx(P0,{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:jn(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())})})})});vf.displayName=xf;var G0="DropdownMenuPortal",wf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(R0,{...r,...n})};wf.displayName=G0;var bf="DropdownMenuContent",yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=mf(bf,n),s=Dt(n),i=h.useRef(!1);return u.jsx(M0,{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)"}})});yf.displayName=bf;var Y0="DropdownMenuGroup",X0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(O0,{...o,...r,ref:t})});X0.displayName=Y0;var J0="DropdownMenuLabel",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(D0,{...o,...r,ref:t})});Sf.displayName=J0;var Z0="DropdownMenuItem",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(L0,{...o,...r,ref:t})});Cf.displayName=Z0;var Q0="DropdownMenuCheckboxItem",Tf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx($0,{...o,...r,ref:t})});Tf.displayName=Q0;var eS="DropdownMenuRadioGroup",tS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(F0,{...o,...r,ref:t})});tS.displayName=eS;var nS="DropdownMenuRadioItem",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(B0,{...o,...r,ref:t})});kf.displayName=nS;var rS="DropdownMenuItemIndicator",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(z0,{...o,...r,ref:t})});Ef.displayName=rS;var oS="DropdownMenuSeparator",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(H0,{...o,...r,ref:t})});If.displayName=oS;var sS="DropdownMenuArrow",iS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(U0,{...o,...r,ref:t})});iS.displayName=sS;var aS="DropdownMenuSubTrigger",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(W0,{...o,...r,ref:t})});Nf.displayName=aS;var lS="DropdownMenuSubContent",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(V0,{...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)"}})});Af.displayName=lS;var cS=gf,uS=vf,dS=wf,jf=yf,_f=Sf,Pf=Cf,Rf=Tf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af;const ws=cS,bs=uS,fS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Lf,{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(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));fS.displayName=Lf.displayName;const pS=h.forwardRef(({className:e,...t},n)=>u.jsx($f,{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}));pS.displayName=$f.displayName;const lo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(dS,{children:u.jsx(jf,{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})}));lo.displayName=jf.displayName;const On=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Pf,{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}));On.displayName=Pf.displayName;const hS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Rf,{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(Of,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));hS.displayName=Rf.displayName;const mS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Mf,{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(Of,{children:u.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));mS.displayName=Mf.displayName;const gS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(_f,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));gS.displayName=_f.displayName;const xS=h.forwardRef(({className:e,...t},n)=>u.jsx(Df,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));xS.displayName=Df.displayName;const ba=h.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}));ba.displayName="Textarea";const vS=1e4;function Ff({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=vS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,b]=w.useState(e),S=(x?i:y)??"",[k,T]=w.useTransition(),C=w.useRef(null),E=w.useRef(0),N=w.useRef(null),O=w.useRef("");w.useEffect(()=>{x||(b(e??""),N.current=null,C.current&&(C.current.style.height="auto",C.current.style.height=`${C.current.scrollHeight}px`))},[e,t,x]);const[$,H]=w.useState(null),K=w.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),U=w.useMemo(()=>v??K,[v,K]),I=w.useCallback(M=>{const q=U(M);return H(q),g==null||g(q),O.current=M,q},[U,g]),W=w.useCallback(()=>{const M=C.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);w.useEffect(()=>{W()},[W,S]),w.useEffect(()=>{if(!$)return;const M=(S??"").trim();O.current!==M&&I(M)},[S,$,I]);const _=w.useCallback((M,{fromUser:q})=>{x||b(M),q&&(a==null||a(M))},[x,a]),D=w.useCallback(async M=>{M&&M.preventDefault();const q=(S??"").trim();if(!q&&!f||I(q))return;const Y=++E.current;N.current={id:Y,shouldClear:!0},T(()=>{var oe,V,L;try{const X=l(q);X&&typeof X.then=="function"?X.then(()=>{var Z,ce;((Z=N.current)==null?void 0:Z.id)===Y&&N.current.shouldClear&&(x||(b(""),C.current&&(C.current.style.height="auto"),a==null||a(""))),((ce=N.current)==null?void 0:ce.id)===Y&&(N.current=null)}).catch(()=>{var Z;((Z=N.current)==null?void 0:Z.id)===Y&&(N.current=null)}):(((oe=N.current)==null?void 0:oe.id)===Y&&N.current.shouldClear&&(x||(b(""),C.current&&(C.current.style.height="auto"),a==null||a(""))),((V=N.current)==null?void 0:V.id)===Y&&(N.current=null))}catch{((L=N.current)==null?void 0:L.id)===Y&&(N.current=null)}})},[S,l,f,x,a,I]),P=w.useCallback(M=>{const q=M.target.value;_(q,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),C.current&&(C.current.style.height="auto",C.current.style.height=`${C.current.scrollHeight}px`),$&&I(q.trim())},[_,I,$]),j=w.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),D()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[D,t,c]),R=`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 D(M),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ba,{ref:C,value:S,onChange:P,onKeyDown:j,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(lt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(fe.Square,{size:16})}):u.jsx(lt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(fe.Send,{size:16})})})]})})}const wS=w.memo(Ff),ys=0,Dn=1,Er=2,Bf=4;function zf(e){return()=>e}function bS(e){e()}function Hf(e,t){return n=>e(t(n))}function Uf(e,t){return()=>e(t)}function yS(e,t){return n=>e(t,n)}function ya(e){return e!==void 0}function SS(...e){return()=>{e.map(bS)}}function Ir(){}function Ss(e,t){return t(e),e}function CS(e,t){return t(e)}function ct(...e){return e}function Qe(e,t){return e(Dn,t)}function Pe(e,t){e(ys,t)}function Sa(e){e(Er)}function gt(e){return e(Bf)}function be(e,t){return Qe(e,yS(t,ys))}function cn(e,t){const n=e(Dn,r=>{n(),t(r)});return n}function Wf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Vf(e,t){return e===t}function ut(e=Vf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Hf(t,e)}function yn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=TS(...t);return(r,o)=>{switch(r){case Er:Sa(e);return;case Dn:return Qe(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Zn(e){return t=>n=>{e>0?e--:t(n)}}function In(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...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 TS(...e){return t=>e.reduceRight(CS,t)}function kS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Dn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function se(e){let t=e;const n=We();return(r,o)=>{switch(r){case ys:t=o;break;case Dn:{o(t);break}case Bf:return t}return n(r,o)}}function jt(e,t){return Ss(se(t),n=>be(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case ys:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Dn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ss(We(),t=>be(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ES(),singleton:n}}const ES=()=>Symbol();function IS(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 bt(...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&&Pe(t,n)})}),function(s,i){switch(s){case Er:{Sa(t);return}case Dn:return r===o&&i(n),Qe(t,i)}}}function Te(e,t=Vf){return Q(e,ut(t))}function Ca(...e){return function(t,n){switch(t){case Er:return;case Dn:return SS(...e.map(r=>Qe(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const NS={0:"debug",3:"error",1:"log",2:"warn"},AS=()=>typeof globalThis>"u"?window:globalThis,Ln=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=AS().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[NS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Qn(e,t,n){return Ta(e,t,n).callbackRef}function Ta(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 jS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=_S(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?Kf("column-gap",getComputedStyle(d).columnGap,o):Kf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ta(c,n,l)}function _S(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},Ht.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Kf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function qf(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 p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ta(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 Lt=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),p=We(),m=We(),f=se(!1),v=se(!1),g=se(!1);return be(Q(e,he(({scrollTop:x})=>x)),t),be(Q(e,he(({scrollHeight:x})=>x)),i),be(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),co={lvl:0};function Gf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===co}function uo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?uo(e.l,t):uo(e.r,t)}function un(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function Qt(e,t,n){return ot(e)?Jf(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?Zf(yt(e,{l:Qt(e.l,t,n)})):Zf(yt(e,{r:Qt(e.r,t,n)}))}function Nr(){return co}function Cs(e,t,n){if(ot(e))return[];const r=un(e,t)[0];return PS(Ea(e,r,n))}function ka(e,t){if(ot(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Xf(r);return Ts(yt(e,{k:s,l:Yf(r),v:i}))}}else return t<n?Ts(yt(e,{l:ka(r,t)})):Ts(yt(e,{r:ka(o,t)}))}function er(e){return ot(e)?[]:[...er(e.l),{k:e.k,v:e.v},...er(e.r)]}function Ea(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ea(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ea(s,t,n))),a}function Ts(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(Ia(t))return Qf(yt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ia(e))return Na(yt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ia(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Na(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return Jf(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 Yf(e){return ot(e.r)?e.l:Ts(yt(e,{r:Yf(e.r)}))}function Ia(e){return ot(e)||e.lvl>e.r.lvl}function Xf(e){return ot(e.r)?[e.k,e.v]:Xf(e.r)}function Jf(e,t,n,r=co,o=co){return{k:e,l:r,lvl:n,r:o,v:t}}function Zf(e){return Na(Qf(e))}function Qf(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Na(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function PS(e){return Gf(e,({k:t,v:n})=>({index:t,value:n}))}function ep(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function fo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Aa=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function tp(e,t,n){return e[ks(e,t,n)]}function ks(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 RS(e,t,n,r){const o=ks(e,t,r),s=ks(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function Es(e){return!ot(e.groupOffsetTree)}function ja({index:e},t){return t===e?0:t<e?-1:1}function MS(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function OS(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(HS(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=ka(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function DS(e){return typeof e.groupIndex<"u"}function LS({offset:e},t){return t===e?0:t<e?-1:1}function po(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=tp(t,e,ja),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function np(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function rp(e,t,n){if(DS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=np(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function $S(e,t,n,r=0){return r>0&&(t=Math.max(t,tp(e,r,ja).offset)),Gf(RS(e,t,n,LS),zS)}function FS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,f),i)}else[i,a]=OS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=_a(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,po(f,p,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function BS(e){return er(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 op(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 _a(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ks(o,t-1,ja),a=o[l].offset;const c=un(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Cs(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function zS(e){return{index:e.index,value:e}}function HS(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 US={offsetHeight:"height",offsetWidth:"width"},Cn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=jt(r,0),s=We(),i=We(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((T,C)=>$n(T,US[C])),m=se(void 0),f=se(0),v=MS(),g=jt(Q(n,De(l,e,f),Sn(FS,v),ut()),v),x=jt(Q(l,ut(),Sn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),he(({prev:T})=>T)),[]);be(Q(l,Ie(T=>T.length>0),De(g,f),he(([T,C,E])=>{const N=T.reduce((O,$,H)=>Qt(O,$,po($,C.offsetTree,E)||H),Nr());return{...C,groupIndices:T,groupOffsetTree:N}})),g),be(Q(r,De(g),Ie(([T,{lastIndex:C}])=>T<C),he(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),be(c,d);const y=jt(Q(c,he(T=>T===void 0)),!0);be(Q(d,Ie(T=>T!==void 0&&ot(gt(g).sizeTree)),he(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Zt(Q(n,De(g),Sn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:v}),he(T=>T.changed)));Qe(Q(a,Sn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),he(T=>T.diff)),T=>{const{groupIndices:C}=gt(g);if(T>0)Pe(t,!0),Pe(s,T+op(T,C));else if(T<0){const E=gt(x);E.length>0&&(T-=op(-T,E)),Pe(i,T)}}),Qe(Q(a,De(e)),([T,C])=>{T<0&&C("`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},Ht.ERROR)});const S=Zt(s);be(Q(s,De(g),he(([T,C])=>{const E=C.groupIndices.length>0,N=[],O=C.lastSize;if(E){const $=uo(C.sizeTree,0);let H=0,K=0;for(;H<T;){const I=C.groupIndices[K],W=C.groupIndices.length===K+1?1/0:C.groupIndices[K+1]-I-1;N.push({endIndex:I,size:$,startIndex:I}),N.push({endIndex:I+1+W-1,size:O,startIndex:I+1}),K++,H+=W+1}const U=er(C.sizeTree);return H!==T&&U.shift(),U.reduce((I,{k:W,v:_})=>{let D=I.ranges;return I.prevSize!==0&&(D=[...I.ranges,{endIndex:W+T-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:W+T,prevSize:_,ranges:D}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return er(C.sizeTree).reduce(($,{k:H,v:K})=>({prevIndex:H+T,prevSize:K,ranges:[...$.ranges,{endIndex:H+T-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const k=Zt(Q(i,De(g,f),he(([T,{offsetTree:C},E])=>{const N=-T;return po(N,C,E)})));return be(Q(i,De(g,f),he(([T,C,E])=>{if(C.groupIndices.length>0){if(ot(C.sizeTree))return C;let N=Nr();const O=gt(x);let $=0,H=0,K=0;for(;$<-T;){K=O[H];const U=O[H+1]-K-1;H++,$+=U+1}if(N=er(C.sizeTree).reduce((U,{k:I,v:W})=>Qt(U,Math.max(0,I+T),W),N),$!==-T){const U=uo(C.sizeTree,K);N=Qt(N,0,U);const I=un(C.sizeTree,-T+1)[1];N=Qt(N,1,I)}return{...C,sizeTree:N,..._a(C.offsetTree,0,N,E)}}else{const N=er(C.sizeTree).reduce((O,{k:$,v:H})=>Qt(O,Math.max(0,$+T),H),Nr());return{...C,sizeTree:N,..._a(C.offsetTree,0,N,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ct(Ln,Aa),{singleton:!0});function WS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const sp=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Zt(Q(s,he(WS)));return be(Q(a,he(l=>l.totalCount)),n),be(Q(a,he(l=>l.groupIndices)),e),be(Q(bt(o,t,r),Ie(([l,c])=>Es(c)),he(([l,c,d])=>un(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ut(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ct(Cn,Lt)),Fn=Ge(([{log:e}])=>{const t=se(!1),n=Zt(Q(t,Ie(r=>r),ut()));return Qe(t,r=>{r&>(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},ct(Ln),{singleton:!0}),VS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ip(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!VS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ho=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=We(),v=We(),g=se(0);let x=null,y=null,b=null;function S(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Pe(l,!1)}return be(Q(f,De(n,p,r,g,a,i,m),De(e,s,o),he(([[k,T,C,E,N,O,$,H],K,U,I])=>{const W=ip(k),{align:_,behavior:D,offset:P}=W,j=E-1,G=rp(W,T,j);let J=po(G,T.offsetTree,K)+O;_==="end"?(J+=U+un(T.sizeTree,G)[1]-C+I,G===j&&(J+=$)):_==="center"?J+=(U+un(T.sizeTree,G)[1]-C+I)/2:J-=N,P&&(J+=P);const R=M=>{S(),M?(H("retrying to scroll to",{location:k},Ht.DEBUG),Pe(f,k)):(Pe(v,!0),H("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),D==="smooth"){let M=!1;b=Qe(t,q=>{M=M||q}),x=cn(d,()=>{R(M)})}else x=cn(Q(t,KS(150)),R);return y=setTimeout(()=>{S()},1200),Pe(l,!0),H("scrolling from index to",{behavior:D,index:G,top:J},Ht.DEBUG),{behavior:D,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ct(Cn,Lt,Ln),{singleton:!0});function KS(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pa(e,t){e==0?t():requestAnimationFrame(()=>{Pa(e-1,t)})}function Ra(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const mo=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 be(Q(i,De(l),Ie(([d,p])=>!!p),yn(!1)),a),be(Q(i,De(l),Ie(([d,p])=>!!p),yn(!1)),c),Qe(Q(bt(t,i),De(a,n,e,c),Ie(([[,d],p,{sizeTree:m},f,v])=>d&&(!ot(m)||ya(f))&&!p&&!v),De(l)),([,d])=>{cn(o,()=>{Pe(c,!0)}),Pa(4,()=>{cn(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(Cn,Lt,ho,Fn),{singleton:!0});function ap(e,t){return Math.abs(e-t)<1.01}const go="up",xo="down",qS="none",GS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},YS=0,vo=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),p=se(YS),m=jt(Q(Ca(Q(Te(o),Zn(1),yn(!0)),Q(Te(o),Zn(1),yn(!1),Wf(100))),ut()),!1),f=jt(Q(Ca(Q(n,yn(!0)),Q(n,yn(!1),Wf(200))),ut()),!1);be(Q(bt(Te(o),Te(p)),he(([b,S])=>b<=S),ut()),a),be(Q(a,In(50)),c);const v=Zt(Q(bt(r,Te(s),Te(t),Te(e),Te(d)),Sn((b,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const O=k+T-S>-N,$={scrollHeight:S,scrollTop:k,viewportHeight:T};if(O){let K,U;return k>b.state.scrollTop?(K="SCROLLED_DOWN",U=b.state.scrollTop-k):(K="SIZE_DECREASED",U=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:U,state:$}}let H;return $.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":T<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:$}},GS),ut((b,S)=>b&&b.atBottom===S.atBottom))),g=jt(Q(r,Sn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(ap(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{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}),Ie(b=>b.changed),he(b=>b.jump)),0);be(Q(v,he(b=>b.atBottom)),i),be(Q(i,In(50)),l);const x=se(xo);be(Q(r,he(({scrollTop:b})=>b),ut(),Sn((b,S)=>gt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?go:xo,prevScrollTop:S},{direction:xo,prevScrollTop:0}),he(b=>b.direction)),x),be(Q(r,In(50),yn(qS)),x);const y=se(0);return be(Q(m,Ie(b=>!b),yn(0)),y),be(Q(o,In(100),De(m),Ie(([b,S])=>!!S),Sn(([b,S],[k])=>[S,k],[0,0]),he(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ct(Lt)),Is="top",Ns="bottom",lp="none";function cp(e,t,n){return typeof e=="number"?n===go&&t===Is||n===xo&&t===Ns?e:0:n===go?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function up(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ma=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=se(0),a=se(0),l=se(0),c=jt(Q(bt(Te(r),Te(o),Te(n),Te(s,fo),Te(l),Te(i),Te(t),Te(e),Te(a)),he(([d,p,m,[f,v],g,x,y,b,S])=>{const k=d-b,T=x+y,C=Math.max(m-k,0);let E=lp;const N=up(S,Is),O=up(S,Ns);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+T-N&&(E=go),v<d-C+p+O&&(E=xo),E!==lp?[Math.max(k-m-cp(g,Is,E)-N,0),k-C-y+p+cp(g,Ns,E)+O]:null}),Ie(d=>d!=null),ut(fo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ct(Lt),{singleton:!0});function XS(e,t,n){if(Es(t)){const r=np(e,t);return[{index:un(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 Oa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function As(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:fp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:fp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function dp(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=Ra(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function fp(e,t,n){if(e.length===0)return[];if(!Es(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=Cs(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 tr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=We();be(s.topItemsIndexes,g);const b=jt(Q(bt(f,v,Te(l,fo),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),Ie(([C,E,,N,,,,,,,O])=>{const $=O&&O.length!==N;return C&&!E&&!$}),he(([,,[C,E],N,O,$,H,K,U,I,W])=>{const _=O,{offsetTree:D,sizeTree:P}=_,j=gt(x);if(N===0)return{...Oa,totalCount:N};if(C===0&&E===0)return j===0?{...Oa,totalCount:N}:dp(j,$,O,U,I,W||[]);if(ot(P))return j>0?null:As(XS(Ra($,N),_,W),[],N,I,_,U);const G=[];if(K.length>0){const Y=K[0],oe=K[K.length-1];let V=0;for(const L of Cs(P,Y,oe)){const X=L.value,Z=Math.max(L.start,Y),ce=Math.min(L.end,oe);for(let F=Z;F<=ce;F++)G.push({data:W==null?void 0:W[F],index:F,offset:V,size:X}),V+=X}}if(!H)return As([],G,N,I,_,U);const J=K.length>0?K[K.length-1]+1:0,R=$S(D,C,E,J);if(R.length===0)return null;const M=N-1,q=Ss([],Y=>{for(const oe of R){const V=oe.value;let L=V.offset,X=oe.start;const Z=V.size;if(V.offset<C){X+=Math.floor((C-V.offset+I)/(Z+I));const F=X-oe.start;L+=F*Z+F*I}X<J&&(L+=(J-X)*Z,X=J);const ce=Math.min(oe.end,M);for(let F=X;F<=ce&&!(L>=E);F++)Y.push({data:W==null?void 0:W[F],index:F,offset:L,size:Z}),L+=Z+I}});return As(q,G,N,I,_,U)}),Ie(C=>C!==null),ut()),Oa);be(Q(e,Ie(ya),he(C=>C==null?void 0:C.length)),o),be(Q(b,he(C=>C.topListHeight)),p),be(p,a),be(Q(b,he(C=>[C.top,C.bottom])),i),be(Q(b,he(C=>C.items)),y);const S=Zt(Q(b,Ie(({items:C})=>C.length>0),De(o,e),Ie(([{items:C},E])=>C[C.length-1].originalIndex===E-1),he(([,C,E])=>[C-1,E]),ut(fo),he(([C])=>C))),k=Zt(Q(b,In(200),Ie(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),he(({items:C})=>C[0].index),ut())),T=Zt(Q(b,Ie(({items:C})=>C.length>0),he(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),ut(ep)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:g,...m}},ct(Cn,sp,Ma,mo,ho,vo,Fn,Aa),{singleton:!0}),pp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=jt(Q(bt(n,e,r,t,o),he(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return be(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(Lt,tr),{singleton:!0}),JS=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=jt(Q(bt(n,e,t),Ie(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),In(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(Lt,pp),{singleton:!0}),hp=Ge(()=>({context:se(null)})),ZS=({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,mp=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 be(Q(d,De(t,l,n,s,o,r,a),De(e),he(([[p,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=ZS,done:E,...N}=p,O=rp(p,m,v-1),$=po(O,m.offsetTree,S)+g+x,H=$+un(m.sizeTree,O)[1],K=b+x,U=b+f-y,I=C({itemBottom:H,itemTop:$,locationParams:{align:k,behavior:T,...N},viewportBottom:U,viewportTop:K});return I?E&&cn(Q(i,Ie(W=>!W),Zn(gt(i)?1:2)),E):E&&E(),I}),Ie(p=>p!==null)),c),{scrollIntoView:d}},ct(Cn,Lt,ho,tr,Ln),{singleton:!0});function gp(e){return e?e==="smooth"?"smooth":"auto":!1}const QS=(e,t)=>typeof e=="function"?gp(e(t)):t&&gp(e),eC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=We();let x=null;function y(T){Pe(i,{align:"end",behavior:T,index:"LAST"})}Qe(Q(bt(Q(Te(t),Zn(1)),l),De(Te(v),s,a,p),he(([[T,C],E,N,O,$])=>{let H=C&&O,K="auto";return H&&(K=QS(E,N||$),H=H&&!!K),{followOutputBehavior:K,shouldFollow:H,totalCount:T}}),Ie(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:C},Ht.DEBUG),y(T)}):x=cn(e,()=>{gt(d)("following output to ",{totalCount:C},Ht.DEBUG),y(T),x=null})});function b(T){const C=cn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(gt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(C,100)}Qe(Q(bt(Te(v),t,c),Ie(([T,,C])=>T&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ie(({refreshed:T})=>T),De(v,t)),([,T])=>{gt(a)&&b(T!==!1)}),Qe(g,()=>{b(gt(v)!==!1)}),Qe(bt(Te(v),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=We();return be(Ca(Q(Te(r),he(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),Q(Te(t))),k),Qe(Q(bt(Q(k,Zn(1)),l),De(Te(S),a,p,m),he(([[T,C],E,N,O,$])=>C&&N&&(E==null?void 0:E({context:$,totalCount:T,scrollingInProgress:O}))),Ie(T=>!!T),In(0)),T=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Pe(f,T)}):x=cn(e,()=>{gt(d)("scrolling into view",{}),Pe(f,T),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ct(Cn,vo,ho,mo,Fn,Ln,Lt,hp,mp)),tC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(Q(a,De(s),Ie(([,l])=>l!==0),De(o,r,t,n,e),he(([[,l],c,d,p,m,f=[]])=>dp(l,c,d,p,m,f))),i),{}),ct(Cn,mo,tr,Fn),{singleton:!0}),nC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Qe(Q(e,De(r),Ie(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{cn(Q(n,Zn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},ct(Fn,Lt,tr),{singleton:!0}),xp=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=We(),r=se(!1);return be(Q(e,De(r,t,n),Ie(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ut()),t),Qe(Q(bt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(vo),{singleton:!0}),Da=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=se(!1),i=se(void 0);return be(Q(bt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),be(Q(t,De(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(Lt)),rC=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),p=se(null),m=se(null);return be(a,p),be(l,m),Qe(Q(c,De(t,r,i,p,m,n)),([f,v,g,x,y,b,S])=>{const k=BS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),be(Q(d,Ie(ya),he(oC)),o),be(Q(s,De(d),Ie(([,f])=>f!==void 0),ut(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ct(Cn,Lt,mo,Fn,Da));function oC(e){return{align:"start",index:0,offset:e.scrollTop}}const sC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return be(Q(t,Ie(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(tr));function vp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const iC=vp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),aC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Zt(Q(l,De(i),Sn(([,y,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const O=k+C;let $=0;return b===E&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||($=O-S,$!==0&&($+=N))),[$,T,E,O]},[0,[],0,0]),Ie(([y])=>y!==0),De(r,a,n,o,f,v),Ie(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===go),he(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ht.DEBUG),y))));function x(y){y>0?(Pe(t,{behavior:"auto",top:-y}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-y}))}return Qe(Q(g,De(e,s)),([y,b,S])=>{S&&iC()?Pe(e,b-y):x(-y)}),Qe(Q(bt(jt(s,!1),e,v),Ie(([y,b,S])=>!y&&!S&&b!==0),he(([y,b])=>b),In(1)),x),be(Q(p,he(y=>({top:-y}))),t),Qe(Q(c,De(m,d),he(([y,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(y);{let E=0;const N=uo(k,0);let O=0,$=0;for(;O<y;){O++,E+=N;let H=b.length===$+1?1/0:b[$+1]-b[$]-1;O+H>y&&(E-=N,H=y-O+1),O+=H,E+=C(H),$++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},ct(Lt,vo,tr,Cn,Ln,Aa)),lC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ct(Ma,tC,Fn,xp,pp,nC,JS,Da,mp,Ln,hp)),wp=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},O])=>(be(k.rangeChanged,O.scrollSeekRangeChanged),be(Q(O.windowViewportRect,he($=>$.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:T,statefulTotalCount:c,trackItemSizes:p,...k,...O,...g,sizes:l,...x}),ct(Cn,mo,Lt,rC,eC,tr,ho,aC,sC,sp,lC));function cC(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 js=typeof document<"u"?w.useLayoutEffect:w.useEffect;function bp(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&&Pe(x.propsReady,!1);for(const b of r){const S=x[t.required[b]];Pe(S,y[b])}for(const b of o)if(b in y){const S=x[t.optional[b]];Pe(S,y[b])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=S=>{const k=x[t.methods[b]];Pe(k,S)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=kS(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>Ss(IS(e),E=>{l(E,S)})),[T]=w.useState(Uf(d,k));js(()=>{for(const E of i)E in S&&Qe(T[E],S[E]);return()=>{Object.values(T).map(Sa)}},[S,T,k]),js(()=>{l(k,S)}),w.useImperativeHandle(y,zf(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...cC([...r,...o,...i],S),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Pe(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,()=>gt(y),()=>gt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Uf(gt,y));return js(()=>Qe(y,k=>{k!==b&&S(zf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];js(()=>Qe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const yp=w.createContext(void 0),Sp=w.createContext(void 0),Cp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function La(e){return"self"in e}function uC(e){return"body"in e}function Tp(e,t,n,r=Ir,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(uC(x)||La(x)){const b=La(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():Ao.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;La(f)?(x=Math.max($n(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=$n(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)),ap(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const $a="-webkit-sticky",kp="sticky",Fa=vp(()=>{if(typeof document>"u")return kp;const e=document.createElement("div");return e.style.position=$a,e.style.position===$a?$a:kp});function Ba(e){return e}const dC=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ba),o=se("div"),s=se(Ir),i=(a,l=null)=>jt(Q(n,he(c=>c[a]),ut()),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")}}),fC=Ge(([e,t])=>({...e,...t}),ct(wp,dC)),pC=({height:e})=>u.jsx("div",{style:{height:e}}),hC={overflowAnchor:"none",position:Fa(),zIndex:1},Ep={overflowAnchor:"none"},mC={...Ep,display:"inline-block",height:"100%"},Ip=w.memo(function({showTopList:e=!1}){const t=je("listState"),n=tn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),p=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=tn("gap"),g=je("horizontalDirection"),{callbackRef:x}=jS(n,m,p,e?Ir:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);za("deviation",I=>{y!==I&&b(I)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||pC,T=je("ListComponent"),C=je("ItemComponent"),E=je("GroupComponent"),N=je("computeItemKey"),O=je("isSeeking"),$=je("groupIndices").length>0,H=je("alignToBottom"),K=je("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{..._t(S,c)}):u.jsx(T,{..._t(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:U,children:(e?t.topItems:t.items).map(I=>{const W=I.originalIndex,_=N(W+t.firstItemIndex,I.data,c);return O?w.createElement(k,{..._t(k,c),height:I.size,index:I.index,key:_,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?w.createElement(E,{..._t(E,c),"data-index":W,"data-item-index":I.index,"data-known-size":I.size,key:_,style:hC},d(I.index,c)):w.createElement(C,{..._t(C,c),...wC(C,I.data),"data-index":W,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:_,style:g?mC:Ep},$?l(I.index,I.groupIndex,I.data,c):l(I.index,I.data,c))})})}),gC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},xC={outline:"none",overflowX:"auto",position:"relative"},_s=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),vC={position:Fa(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function wC(e,t){return{item:typeof e=="string"?void 0:t}}const bC=w.memo(function(){const e=je("HeaderComponent"),t=tn("headerHeight"),n=je("HeaderFooterTag"),r=Qn(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),yC=w.memo(function(){const e=je("FooterComponent"),t=tn("footerHeight"),n=je("HeaderFooterTag"),r=Qn(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null});function Np({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"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Tp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?xC:gC,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function Ap({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"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Tp(a,c,l,v,m);return Cp(()=>{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+p}:{}},...i,..._t(l,s),children:r})})}const SC=({children:e})=>{const t=w.useContext(yp),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=w.useMemo(()=>Hf(n,l=>$n(l,s?"width":"height")),[n,s]),a=Qn(i,!0,je("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:_s(o),children:e})},CC=({children:e})=>{const t=w.useContext(yp),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=je("customScrollParent"),s=qf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("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:_s(i),children:e})},TC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...vC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,..._t(t,o),children:e})},kC=w.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?NC:IC,{...e,context:o,children:[n&&u.jsx(TC,{children:u.jsx(Ip,{showTopList:!0})}),u.jsxs(r||t?CC:SC,{children:[u.jsx(bC,{}),u.jsx(Ip,{}),u.jsx(yC,{})]})]})}),{Component:EC,useEmitter:za,useEmitterValue:je,usePublisher:tn}=bp(fC,{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"}},kC),IC=Np({useEmitter:za,useEmitterValue:je,usePublisher:tn}),NC=Ap({useEmitter:za,useEmitterValue:je,usePublisher:tn}),AC=EC;ct(wp,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(Ba),a=se(Ir),l=(c,d=null)=>jt(Q(s,he(p=>p[c]),ut()),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")}})),Fa();const jp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},jC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_p,floor:Ps,max:wo,min:Ha,round:Pp}=Math;function Rp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function _C(e){return{...jC,items:e}}function Rs(e,t){return e&&e.width===t.width&&e.height===t.height}function PC(e,t){return e&&e.column===t.column&&e.row===t.row}const RC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=se(0),E=se(0),N=se(jp),O=se({height:0,width:0}),$=se({height:0,width:0}),H=We(),K=We(),U=se(0),I=se(null),W=se({column:0,row:0}),_=We(),D=We(),P=se(!1),j=se(0),G=se(!0),J=se(!1),R=se(!1);Qe(Q(v,De(j),Ie(([L,X])=>!!X)),()=>{Pe(G,!1)}),Qe(Q(bt(v,G,$,O,j,J),Ie(([L,X,Z,ce,,F])=>L&&!X&&Z.height!==0&&ce.height!==0&&!F)),([,,,,L])=>{Pe(J,!0),Pa(1,()=>{Pe(H,L)}),cn(Q(c),()=>{Pe(t,[0,0]),Pe(G,!0)})}),be(Q(D,Ie(L=>L!=null&&L.scrollTop>0),yn(0)),E),Qe(Q(v,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Pe(O,L.viewport),Pe($,L.item),Pe(W,L.gap),L.scrollTop>0&&(Pe(P,!0),cn(Q(c,Zn(1)),X=>{Pe(P,!1)}),Pe(l,{top:L.scrollTop})))}),be(Q(O,he(({height:L})=>L)),p),be(Q(bt(Te(O,Rs),Te($,Rs),Te(W,(L,X)=>L&&L.column===X.column&&L.row===X.row),Te(c)),he(([L,X,Z,ce])=>({gap:Z,item:X,scrollTop:ce,viewport:L}))),_),be(Q(bt(Te(C),r,Te(W,PC),Te($,Rs),Te(O,Rs),Te(I),Te(E),Te(P),Te(G),Te(j)),Ie(([,,,,,,,L])=>!L),he(([L,[X,Z],ce,F,re,ue,le,,xe,Ne])=>{const{column:$e,row:Fe}=ce,{height:Ae,width:Be}=F,{width:tt}=re;if(le===0&&(L===0||tt===0))return jp;if(Be===0){const Rt=Ra(Ne,L),Mt=Rt+Math.max(le-1,0);return _C(Rp(Rt,Mt,ue))}const qe=Mp(tt,Be,$e);let ze,it;xe?X===0&&Z===0&&le>0?(ze=0,it=le-1):(ze=qe*Ps((X+Fe)/(Ae+Fe)),it=qe*_p((Z+Fe)/(Ae+Fe))-1,it=Ha(L-1,wo(it,qe-1)),ze=Ha(it,wo(0,ze))):(ze=0,it=-1);const nt=Rp(ze,it,ue),{bottom:Ze,top:St}=Op(re,ce,F,nt),xt=_p(L/qe),at=xt*Ae+(xt-1)*Fe-Ze;return{bottom:Ze,itemHeight:Ae,items:nt,itemWidth:Be,offsetBottom:at,offsetTop:St,top:St}})),N),be(Q(I,Ie(L=>L!==null),he(L=>L.length)),C),be(Q(bt(O,$,N,W),Ie(([L,X,{items:Z}])=>Z.length>0&&X.height!==0&&L.height!==0),he(([L,X,{items:Z},ce])=>{const{bottom:F,top:re}=Op(L,ce,X,Z);return[re,F]}),ut(fo)),t);const M=se(!1);be(Q(c,De(M),he(([L,X])=>X||L!==0)),M);const q=Zt(Q(bt(N,C),Ie(([{items:L}])=>L.length>0),De(M),Ie(([[L,X],Z])=>{const ce=L.items[L.items.length-1].index===X-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===X)&&ce}),he(([[,L]])=>L-1),ut())),Y=Zt(Q(Te(N),Ie(({items:L})=>L.length>0&&L[0].index===0),yn(0),ut())),oe=Zt(Q(Te(N),De(P),Ie(([{items:L},X])=>L.length>0&&!X),he(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(ep),In(0)));be(oe,f.scrollSeekRangeChanged),be(Q(H,De(O,$,C,W),he(([L,X,Z,ce,F])=>{const re=ip(L),{align:ue,behavior:le,offset:xe}=re;let Ne=re.index;Ne==="LAST"&&(Ne=ce-1),Ne=wo(0,Ne,Ha(ce-1,Ne));let $e=Ua(X,F,Z,Ne);return ue==="end"?$e=Pp($e-X.height+Z.height):ue==="center"&&($e=Pp($e-X.height/2+Z.height/2)),xe&&($e+=xe),{behavior:le,top:$e}})),l);const V=jt(Q(N,he(L=>L.offsetBottom+L.bottom)),0);return be(Q(k,he(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:x,data:I,deviation:U,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:y,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:R,initialTopMostItemIndex:j,totalListHeight:V,...m,endReached:q,propsReady:g,rangeChanged:oe,startReached:Y,stateChanged:_,stateRestoreInProgress:P,...T}},ct(Ma,Lt,vo,xp,Fn,Da,Ln));function Mp(e,t,n){return wo(1,Ps((e+n)/(Ps(t)+n)))}function Op(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ua(e,t,n,r[0].index);return{bottom:Ua(e,t,n,r[r.length-1].index)+o,top:s}}function Ua(e,t,n,r){const o=Mp(e.width,n.width,t.column),s=Ps(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const MC=Ge(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ba),i=se("div"),a=se(Ir),l=(p,m=null)=>jt(Q(t,he(f=>f[p]),ut()),m),c=se(!1),d=se(!1);return be(Te(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")}}),OC=Ge(([e,t])=>({...e,...t}),ct(RC,MC)),DC=w.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=nn("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),c=ft("ScrollSeekPlaceholder"),d=ft("context"),p=nn("itemDimensions"),m=nn("gap"),f=ft("log"),v=ft("stateRestoreInProgress"),g=nn("reportReadyState"),x=Qn(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();p({height:k,width:T})}m({column:Lp("column-gap",getComputedStyle(y).columnGap,f),row:Lp("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Cp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,..._t(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,{..._t(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{..._t(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),LC=w.memo(function(){const e=ft("HeaderComponent"),t=nn("headerHeight"),n=ft("headerFooterTag"),r=Qn(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),$C=w.memo(function(){const e=ft("FooterComponent"),t=nn("footerHeight"),n=ft("headerFooterTag"),r=Qn(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),FC=({children:e})=>{const t=w.useContext(Sp),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=Qn(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:_s(!1),children:e})},BC=({children:e})=>{const t=w.useContext(Sp),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=ft("customScrollParent"),s=qf(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:_s(!1),children:e})},zC=w.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?UC:HC,o=n||t?BC:FC,s=ft("context");return u.jsx(r,{...e,..._t(r,s),children:u.jsxs(o,{children:[u.jsx(LC,{}),u.jsx(DC,{}),u.jsx($C,{})]})})}),{useEmitter:Dp,useEmitterValue:ft,usePublisher:nn}=bp(OC,{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"}},zC),HC=Np({useEmitter:Dp,useEmitterValue:ft,usePublisher:nn}),UC=Ap({useEmitter:Dp,useEmitterValue:ft,usePublisher:nn});function Lp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}const WC=Dr.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 $p({className:e,variant:t,...n}){return u.jsx("div",{className:te(WC({variant:t}),e),...n})}var Ms="Dialog",[Fp,u1]=sn(Ms),[VC,dn]=Fp(Ms),Bp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:Ms});return u.jsx(VC,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Bp.displayName=Ms;var zp="DialogTrigger",Hp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(zp,n),s=Oe(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ka(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Hp.displayName=zp;var Wa="DialogPortal",[KC,Up]=Fp(Wa,{forceMount:void 0}),Wp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Wa,t);return u.jsx(KC,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(to,{asChild:!0,container:o,children:i})}))})};Wp.displayName=Wa;var Os="DialogOverlay",Vp=h.forwardRef((e,t)=>{const n=Up(Os,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Os,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(GC,{...o,ref:t})}):null});Vp.displayName=Os;var qC=qt.createSlot("DialogOverlay.RemoveScroll"),GC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Os,n);return u.jsx(ps,{as:qC,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),nr="DialogContent",Kp=h.forwardRef((e,t)=>{const n=Up(nr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(nr,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(YC,{...o,ref:t}):u.jsx(XC,{...o,ref:t})})});Kp.displayName=nr;var YC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(null),o=Oe(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(qp,{...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())})}),XC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(qp,{...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()}})}),qp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(nr,n),l=h.useRef(null),c=Oe(t,l);return $i(),u.jsxs(u.Fragment,{children:[u.jsx(Go,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(gr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(JC,{titleId:a.titleId}),u.jsx(QC,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Va="DialogTitle",Gp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Va,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Gp.displayName=Va;var Yp="DialogDescription",Xp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Yp,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Xp.displayName=Yp;var Jp="DialogClose",Zp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Jp,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});Zp.displayName=Jp;function Ka(e){return e?"open":"closed"}var Qp="DialogTitleWarning",[d1,eh]=pw(Qp,{contentName:nr,titleName:Va,docsSlug:"dialog"}),JC=({titleId:e})=>{const t=eh(Qp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},r0=0,kr=[];function o0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(r0++)[0],s=h.useState(Ld)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=ky([e.lockRef.current],(e.shards||[]).map(Wd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=fs(g),b=n.current,S="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],T,C=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&C.type==="range")return!1;var N=Bd(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=Bd(E,C)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=T),!T)return!0;var O=r.current||T;return e0(O,x,g,O==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!kr.length||kr[kr.length-1]!==s)){var y="deltaY"in x?Ud(x):fs(x),b=t.current.filter(function(T){return T.name===x.type&&(T.target===x.target||x.target===T.shadowParent)&&t0(T.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Wd).filter(Boolean).filter(function(T){return T.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var S={name:g,delta:x,target:y,should:b,shadowParent:s0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=fs(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,Ud(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,fs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:n0(o)}):null,f?h.createElement(qy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function s0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const i0=My(Dd,o0);var ps=h.forwardRef(function(e,t){return h.createElement(us,bn({},e,{ref:t,sideCar:i0}))});ps.classNames=us.classNames;var fa=["Enter"," "],a0=["ArrowDown","PageUp","Home"],Vd=["ArrowUp","PageDown","End"],l0=[...a0,...Vd],c0={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},u0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ro="Menu",[oo,d0,f0]=Ko(ro),[Jn,Kd]=sn(ro,[f0,yr,Id]),hs=yr(),qd=Id(),[p0,Zn]=Jn(ro),[h0,so]=Jn(ro),Gd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=hs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=mt(s),m=qo(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ea,{...a,children:u.jsx(p0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(h0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Gd.displayName=ro;var m0="MenuAnchor",pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return u.jsx(ta,{...o,...r,ref:t})});pa.displayName=m0;var ha="MenuPortal",[g0,Yd]=Jn(ha,{forceMount:void 0}),Xd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Zn(ha,t);return u.jsx(g0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(to,{asChild:!0,container:o,children:r})})})};Xd.displayName=ha;var en="MenuContent",[x0,ma]=Jn(en),Jd=h.forwardRef((e,t)=>{const n=Yd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Zn(en,e.__scopeMenu),i=so(en,e.__scopeMenu);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(v0,{...o,ref:t}):u.jsx(w0,{...o,ref:t})})})})}),v0=h.forwardRef((e,t)=>{const n=Zn(en,e.__scopeMenu),r=h.useRef(null),o=Le(t,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),w0=h.forwardRef((e,t)=>{const n=Zn(en,e.__scopeMenu);return u.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),b0=qt.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=Zn(en,n),y=so(en,n),b=hs(n),S=qd(n),k=d0(n),[T,C]=h.useState(null),E=h.useRef(null),N=Le(t,E,x.onContentChange),O=h.useRef(0),$=h.useRef(""),H=h.useRef(0),K=h.useRef(null),U=h.useRef("right"),I=h.useRef(0),W=v?ps:h.Fragment,_=v?{as:b0,allowPinchZoom:!0}:void 0,D=j=>{var V,L;const G=$.current+j,Z=k().filter(Y=>!Y.disabled),R=document.activeElement,M=(V=Z.find(Y=>Y.ref.current===R))==null?void 0:V.textValue,q=Z.map(Y=>Y.textValue),X=P0(q,G,M),oe=(L=Z.find(Y=>Y.textValue===X))==null?void 0:L.ref.current;(function Y(J){$.current=J,window.clearTimeout(O.current),J!==""&&(O.current=window.setTimeout(()=>Y(""),1e3))})(G),oe&&setTimeout(()=>oe.focus())};h.useEffect(()=>()=>window.clearTimeout(O.current),[]),$i();const P=h.useCallback(j=>{var Z,R;return U.current===((Z=K.current)==null?void 0:Z.side)&&M0(j,(R=K.current)==null?void 0:R.area)},[]);return u.jsx(x0,{scope:n,searchRef:$,onItemEnter:h.useCallback(j=>{P(j)&&j.preventDefault()},[P]),onItemLeave:h.useCallback(j=>{var G;P(j)||((G=E.current)==null||G.focus(),C(null))},[P]),onTriggerLeave:h.useCallback(j=>{P(j)&&j.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(j=>{K.current=j},[]),children:u.jsx(W,{..._,children:u.jsx(Go,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,j=>{var G;j.preventDefault(),(G=E.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(by,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:ae(l,j=>{y.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(na,{role:"menu","aria-orientation":"vertical","data-state":mf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,j=>{const Z=j.target.closest("[data-radix-menu-content]")===j.currentTarget,R=j.ctrlKey||j.altKey||j.metaKey,M=j.key.length===1;Z&&(j.key==="Tab"&&j.preventDefault(),!R&&M&&D(j.key));const q=E.current;if(j.target!==q||!l0.includes(j.key))return;j.preventDefault();const oe=k().filter(V=>!V.disabled).map(V=>V.ref.current);Vd.includes(j.key)&&oe.reverse(),j0(oe)}),onBlur:ae(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(O.current),$.current="")}),onPointerMove:ae(e.onPointerMove,ao(j=>{const G=j.target,Z=I.current!==j.clientX;if(j.currentTarget.contains(G)&&Z){const R=j.clientX>I.current?"right":"left";U.current=R,I.current=j.clientX}}))})})})})})})});Jd.displayName=en;var y0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});xa.displayName=y0;var S0="MenuLabel",Zd=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Zd.displayName=S0;var ms="MenuItem",Qd="menu.itemSelect",gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=so(ms,e.__scopeMenu),a=ma(ms,e.__scopeMenu),l=Le(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Qd,{bubbles:!0,cancelable:!0});p.addEventListener(Qd,f=>r==null?void 0:r(f),{once:!0}),Oi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(ef,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ae(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||fa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});gs.displayName=ms;var ef=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(ms,n),a=qd(n),l=h.useRef(null),c=Le(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(oo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(yy,{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,ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,ao(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>p(!0)),onBlur:ae(e.onBlur,()=>p(!1))})})})}),C0="MenuCheckboxItem",tf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(af,{scope:e.__scopeMenu,checked:n,children:u.jsx(gs,{role:"menuitemcheckbox","aria-checked":xs(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(xs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});tf.displayName=C0;var nf="MenuRadioGroup",[T0,k0]=Jn(nf,{value:void 0,onValueChange:()=>{}}),rf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return u.jsx(T0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(xa,{...o,ref:t})})});rf.displayName=nf;var of="MenuRadioItem",sf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=k0(of,e.__scopeMenu),s=n===o.value;return u.jsx(af,{scope:e.__scopeMenu,checked:s,children:u.jsx(gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});sf.displayName=of;var va="MenuItemIndicator",[af,E0]=Jn(va,{checked:!1}),lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=E0(va,n);return u.jsx(zt,{present:r||xs(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":wa(s.checked)})})});lf.displayName=va;var I0="MenuSeparator",cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});cf.displayName=I0;var N0="MenuArrow",uf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return u.jsx(ra,{...o,...r,ref:t})});uf.displayName=N0;var A0="MenuSub",[dN,df]=Jn(A0),io="MenuSubTrigger",ff=h.forwardRef((e,t)=>{const n=Zn(io,e.__scopeMenu),r=so(io,e.__scopeMenu),o=df(io,e.__scopeMenu),s=ma(io,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(pa,{asChild:!0,...c,children:u.jsx(ef,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":mf(n.open),...e,ref:Pn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,ao(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,ao(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.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(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||c0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});ff.displayName=io;var pf="MenuSubContent",hf=h.forwardRef((e,t)=>{const n=Yd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Zn(en,e.__scopeMenu),i=so(en,e.__scopeMenu),a=df(pf,e.__scopeMenu),l=h.useRef(null),c=Le(t,l);return u.jsx(oo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(oo.Slot,{scope:e.__scopeMenu,children:u.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside: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 p=d.currentTarget.contains(d.target),m=u0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});hf.displayName=pf;function mf(e){return e?"open":"closed"}function xs(e){return e==="indeterminate"}function wa(e){return xs(e)?"indeterminate":e?"checked":"unchecked"}function j0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function _0(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=_0(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 R0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function M0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return R0(n,t)}function ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var O0=Gd,D0=pa,L0=Xd,$0=Jd,F0=xa,B0=Zd,z0=gs,H0=tf,U0=rf,W0=sf,V0=lf,K0=cf,q0=uf,G0=ff,Y0=hf,vs="DropdownMenu",[X0,fN]=sn(vs,[Kd]),Dt=Kd(),[J0,gf]=X0(vs),xf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=h.useRef(null),[d,p]=Rn({prop:o,defaultProp:s??!1,onChange:i,caller:vs});return u.jsx(J0,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(O0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};xf.displayName=vs;var vf="DropdownMenuTrigger",wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=gf(vf,n),i=Dt(n);return u.jsx(D0,{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:Pn(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())})})})});wf.displayName=vf;var Z0="DropdownMenuPortal",bf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(L0,{...r,...n})};bf.displayName=Z0;var yf="DropdownMenuContent",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gf(yf,n),s=Dt(n),i=h.useRef(!1);return u.jsx($0,{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)"}})});Sf.displayName=yf;var Q0="DropdownMenuGroup",eS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(F0,{...o,...r,ref:t})});eS.displayName=Q0;var tS="DropdownMenuLabel",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(B0,{...o,...r,ref:t})});Cf.displayName=tS;var nS="DropdownMenuItem",Tf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(z0,{...o,...r,ref:t})});Tf.displayName=nS;var rS="DropdownMenuCheckboxItem",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(H0,{...o,...r,ref:t})});kf.displayName=rS;var oS="DropdownMenuRadioGroup",sS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(U0,{...o,...r,ref:t})});sS.displayName=oS;var iS="DropdownMenuRadioItem",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(W0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuItemIndicator",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(V0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuSeparator",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(K0,{...o,...r,ref:t})});Nf.displayName=lS;var cS="DropdownMenuArrow",uS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(q0,{...o,...r,ref:t})});uS.displayName=cS;var dS="DropdownMenuSubTrigger",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(G0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSubContent",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Y0,{...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)"}})});jf.displayName=fS;var pS=xf,hS=wf,mS=bf,_f=Sf,Pf=Cf,Rf=Tf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf;const ws=pS,bs=hS,gS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs($f,{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(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));gS.displayName=$f.displayName;const xS=h.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{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}));xS.displayName=Ff.displayName;const lo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(mS,{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})}));lo.displayName=_f.displayName;const Ln=h.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}));Ln.displayName=Rf.displayName;const vS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Mf,{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(Df,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));vS.displayName=Mf.displayName;const wS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Of,{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(Df,{children:u.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));wS.displayName=Of.displayName;const bS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Pf,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));bS.displayName=Pf.displayName;const yS=h.forwardRef(({className:e,...t},n)=>u.jsx(Lf,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));yS.displayName=Lf.displayName;const ba=h.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}));ba.displayName="Textarea";const SS=1e4;function Bf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=SS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,b]=w.useState(e),S=(x?i:y)??"",[k,T]=w.useTransition(),C=w.useRef(null),E=w.useRef(0),N=w.useRef(null),O=w.useRef("");w.useEffect(()=>{x||(b(e??""),N.current=null,C.current&&(C.current.style.height="auto",C.current.style.height=`${C.current.scrollHeight}px`))},[e,t,x]);const[$,H]=w.useState(null),K=w.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),U=w.useMemo(()=>v??K,[v,K]),I=w.useCallback(M=>{const q=U(M);return H(q),g==null||g(q),O.current=M,q},[U,g]),W=w.useCallback(()=>{const M=C.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);w.useEffect(()=>{W()},[W,S]),w.useEffect(()=>{if(!$)return;const M=(S??"").trim();O.current!==M&&I(M)},[S,$,I]);const _=w.useCallback((M,{fromUser:q})=>{x||b(M),q&&(a==null||a(M))},[x,a]),D=w.useCallback(async M=>{M&&M.preventDefault();const q=(S??"").trim();if(!q&&!f||I(q))return;const X=++E.current;N.current={id:X,shouldClear:!0},T(()=>{var oe,V,L;try{const Y=l(q);Y&&typeof Y.then=="function"?Y.then(()=>{var J,ce;((J=N.current)==null?void 0:J.id)===X&&N.current.shouldClear&&(x||(b(""),C.current&&(C.current.style.height="auto"),a==null||a(""))),((ce=N.current)==null?void 0:ce.id)===X&&(N.current=null)}).catch(()=>{var J;((J=N.current)==null?void 0:J.id)===X&&(N.current=null)}):(((oe=N.current)==null?void 0:oe.id)===X&&N.current.shouldClear&&(x||(b(""),C.current&&(C.current.style.height="auto"),a==null||a(""))),((V=N.current)==null?void 0:V.id)===X&&(N.current=null))}catch{((L=N.current)==null?void 0:L.id)===X&&(N.current=null)}})},[S,l,f,x,a,I]),P=w.useCallback(M=>{const q=M.target.value;_(q,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),C.current&&(C.current.style.height="auto",C.current.style.height=`${C.current.scrollHeight}px`),$&&I(q.trim())},[_,I,$]),j=w.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),D()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[D,t,c]),R=`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 D(M),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ba,{ref:C,value:S,onChange:P,onKeyDown:j,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),u.jsx("div",{children:r?u.jsx(lt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(fe.Square,{size:16})}):u.jsx(lt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(fe.Send,{size:16})})})]})})}const CS=w.memo(Bf),ys=0,$n=1,Er=2,zf=4;function Hf(e){return()=>e}function TS(e){e()}function Uf(e,t){return n=>e(t(n))}function Wf(e,t){return()=>e(t)}function kS(e,t){return n=>e(t,n)}function ya(e){return e!==void 0}function ES(...e){return()=>{e.map(TS)}}function Ir(){}function Ss(e,t){return t(e),e}function IS(e,t){return t(e)}function ct(...e){return e}function Qe(e,t){return e($n,t)}function Re(e,t){e(ys,t)}function Sa(e){e(Er)}function gt(e){return e(zf)}function be(e,t){return Qe(e,kS(t,ys))}function cn(e,t){const n=e($n,r=>{n(),t(r)});return n}function Vf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Kf(e,t){return e===t}function ut(e=Kf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Uf(t,e)}function yn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=NS(...t);return(r,o)=>{switch(r){case Er:Sa(e);return;case $n:return Qe(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Qn(e){return t=>n=>{e>0?e--:t(n)}}function In(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...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 NS(...e){return t=>e.reduceRight(IS,t)}function AS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case $n:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function se(e){let t=e;const n=We();return(r,o)=>{switch(r){case ys:t=o;break;case $n:{o(t);break}case zf:return t}return n(r,o)}}function jt(e,t){return Ss(se(t),n=>be(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case ys:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case $n:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ss(We(),t=>be(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:jS(),singleton:n}}const jS=()=>Symbol();function _S(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 bt(...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 Er:{Sa(t);return}case $n:return r===o&&i(n),Qe(t,i)}}}function Te(e,t=Kf){return Q(e,ut(t))}function Ca(...e){return function(t,n){switch(t){case Er:return;case $n:return ES(...e.map(r=>Qe(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const PS={0:"debug",3:"error",1:"log",2:"warn"},RS=()=>typeof globalThis>"u"?window:globalThis,Fn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=RS().VIRTUOSO_LOG_LEVEL)!=null?o:gt(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 er(e,t,n){return Ta(e,t,n).callbackRef}function Ta(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 p=OS(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?qf("column-gap",getComputedStyle(d).columnGap,o):qf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ta(c,n,l)}function OS(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},Ht.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function qf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function Gf(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 p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ta(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 Lt=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),p=We(),m=We(),f=se(!1),v=se(!1),g=se(!1);return be(Q(e,he(({scrollTop:x})=>x)),t),be(Q(e,he(({scrollHeight:x})=>x)),i),be(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),co={lvl:0};function Yf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===co}function uo(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?uo(e.l,t):uo(e.r,t)}function un(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function Qt(e,t,n){return ot(e)?Zf(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?Qf(yt(e,{l:Qt(e.l,t,n)})):Qf(yt(e,{r:Qt(e.r,t,n)}))}function Nr(){return co}function Cs(e,t,n){if(ot(e))return[];const r=un(e,t)[0];return DS(Ea(e,r,n))}function ka(e,t){if(ot(e))return co;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Jf(r);return Ts(yt(e,{k:s,l:Xf(r),v:i}))}}else return t<n?Ts(yt(e,{l:ka(r,t)})):Ts(yt(e,{r:ka(o,t)}))}function tr(e){return ot(e)?[]:[...tr(e.l),{k:e.k,v:e.v},...tr(e.r)]}function Ea(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ea(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ea(s,t,n))),a}function Ts(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(Ia(t))return ep(yt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ia(e))return Na(yt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ia(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Na(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return Zf(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 Xf(e){return ot(e.r)?e.l:Ts(yt(e,{r:Xf(e.r)}))}function Ia(e){return ot(e)||e.lvl>e.r.lvl}function Jf(e){return ot(e.r)?[e.k,e.v]:Jf(e.r)}function Zf(e,t,n,r=co,o=co){return{k:e,l:r,lvl:n,r:o,v:t}}function Qf(e){return Na(ep(e))}function ep(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Na(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function DS(e){return Yf(e,({k:t,v:n})=>({index:t,value:n}))}function tp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function fo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Aa=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function np(e,t,n){return e[ks(e,t,n)]}function ks(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 LS(e,t,n,r){const o=ks(e,t,r),s=ks(e,n,r,o);return e.slice(o,s+1)}function Bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Es(e){return!ot(e.groupOffsetTree)}function ja({index:e},t){return t===e?0:t<e?-1:1}function $S(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function FS(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(KS(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=ka(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function BS(e){return typeof e.groupIndex<"u"}function zS({offset:e},t){return t===e?0:t<e?-1:1}function po(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=np(t,e,ja),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function rp(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function op(e,t,n){if(BS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=rp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function HS(e,t,n,r=0){return r>0&&(t=Math.max(t,np(e,r,ja).offset)),Yf(LS(e,t,n,zS),VS)}function US(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,f),i)}else[i,a]=FS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=_a(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,po(f,p,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function WS(e){return tr(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 sp(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 _a(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ks(o,t-1,ja),a=o[l].offset;const c=un(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Cs(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function VS(e){return{index:e.index,value:e}}function KS(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 qS={offsetHeight:"height",offsetWidth:"width"},Cn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=jt(r,0),s=We(),i=We(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((T,C)=>Bn(T,qS[C])),m=se(void 0),f=se(0),v=$S(),g=jt(Q(n,$e(l,e,f),Sn(US,v),ut()),v),x=jt(Q(l,ut(),Sn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),he(({prev:T})=>T)),[]);be(Q(l,Ie(T=>T.length>0),$e(g,f),he(([T,C,E])=>{const N=T.reduce((O,$,H)=>Qt(O,$,po($,C.offsetTree,E)||H),Nr());return{...C,groupIndices:T,groupOffsetTree:N}})),g),be(Q(r,$e(g),Ie(([T,{lastIndex:C}])=>T<C),he(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),be(c,d);const y=jt(Q(c,he(T=>T===void 0)),!0);be(Q(d,Ie(T=>T!==void 0&&ot(gt(g).sizeTree)),he(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Zt(Q(n,$e(g),Sn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:v}),he(T=>T.changed)));Qe(Q(a,Sn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),he(T=>T.diff)),T=>{const{groupIndices:C}=gt(g);if(T>0)Re(t,!0),Re(s,T+sp(T,C));else if(T<0){const E=gt(x);E.length>0&&(T-=sp(-T,E)),Re(i,T)}}),Qe(Q(a,$e(e)),([T,C])=>{T<0&&C("`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},Ht.ERROR)});const S=Zt(s);be(Q(s,$e(g),he(([T,C])=>{const E=C.groupIndices.length>0,N=[],O=C.lastSize;if(E){const $=uo(C.sizeTree,0);let H=0,K=0;for(;H<T;){const I=C.groupIndices[K],W=C.groupIndices.length===K+1?1/0:C.groupIndices[K+1]-I-1;N.push({endIndex:I,size:$,startIndex:I}),N.push({endIndex:I+1+W-1,size:O,startIndex:I+1}),K++,H+=W+1}const U=tr(C.sizeTree);return H!==T&&U.shift(),U.reduce((I,{k:W,v:_})=>{let D=I.ranges;return I.prevSize!==0&&(D=[...I.ranges,{endIndex:W+T-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:W+T,prevSize:_,ranges:D}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return tr(C.sizeTree).reduce(($,{k:H,v:K})=>({prevIndex:H+T,prevSize:K,ranges:[...$.ranges,{endIndex:H+T-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const k=Zt(Q(i,$e(g,f),he(([T,{offsetTree:C},E])=>{const N=-T;return po(N,C,E)})));return be(Q(i,$e(g,f),he(([T,C,E])=>{if(C.groupIndices.length>0){if(ot(C.sizeTree))return C;let N=Nr();const O=gt(x);let $=0,H=0,K=0;for(;$<-T;){K=O[H];const U=O[H+1]-K-1;H++,$+=U+1}if(N=tr(C.sizeTree).reduce((U,{k:I,v:W})=>Qt(U,Math.max(0,I+T),W),N),$!==-T){const U=uo(C.sizeTree,K);N=Qt(N,0,U);const I=un(C.sizeTree,-T+1)[1];N=Qt(N,1,I)}return{...C,sizeTree:N,..._a(C.offsetTree,0,N,E)}}else{const N=tr(C.sizeTree).reduce((O,{k:$,v:H})=>Qt(O,Math.max(0,$+T),H),Nr());return{...C,sizeTree:N,..._a(C.offsetTree,0,N,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ct(Fn,Aa),{singleton:!0});function GS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ip=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Zt(Q(s,he(GS)));return be(Q(a,he(l=>l.totalCount)),n),be(Q(a,he(l=>l.groupIndices)),e),be(Q(bt(o,t,r),Ie(([l,c])=>Es(c)),he(([l,c,d])=>un(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ut(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ct(Cn,Lt)),zn=Ge(([{log:e}])=>{const t=se(!1),n=Zt(Q(t,Ie(r=>r),ut()));return Qe(t,r=>{r&>(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},ct(Fn),{singleton:!0}),YS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ap(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!YS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ho=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=We(),v=We(),g=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 be(Q(f,$e(n,p,r,g,a,i,m),$e(e,s,o),he(([[k,T,C,E,N,O,$,H],K,U,I])=>{const W=ap(k),{align:_,behavior:D,offset:P}=W,j=E-1,G=op(W,T,j);let Z=po(G,T.offsetTree,K)+O;_==="end"?(Z+=U+un(T.sizeTree,G)[1]-C+I,G===j&&(Z+=$)):_==="center"?Z+=(U+un(T.sizeTree,G)[1]-C+I)/2:Z-=N,P&&(Z+=P);const R=M=>{S(),M?(H("retrying to scroll to",{location:k},Ht.DEBUG),Re(f,k)):(Re(v,!0),H("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),D==="smooth"){let M=!1;b=Qe(t,q=>{M=M||q}),x=cn(d,()=>{R(M)})}else x=cn(Q(t,XS(150)),R);return y=setTimeout(()=>{S()},1200),Re(l,!0),H("scrolling from index to",{behavior:D,index:G,top:Z},Ht.DEBUG),{behavior:D,top:Z}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ct(Cn,Lt,Fn),{singleton:!0});function XS(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pa(e,t){e==0?t():requestAnimationFrame(()=>{Pa(e-1,t)})}function Ra(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const mo=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 be(Q(i,$e(l),Ie(([d,p])=>!!p),yn(!1)),a),be(Q(i,$e(l),Ie(([d,p])=>!!p),yn(!1)),c),Qe(Q(bt(t,i),$e(a,n,e,c),Ie(([[,d],p,{sizeTree:m},f,v])=>d&&(!ot(m)||ya(f))&&!p&&!v),$e(l)),([,d])=>{cn(o,()=>{Re(c,!0)}),Pa(4,()=>{cn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(Cn,Lt,ho,zn),{singleton:!0});function lp(e,t){return Math.abs(e-t)<1.01}const go="up",xo="down",JS="none",ZS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},QS=0,vo=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),p=se(QS),m=jt(Q(Ca(Q(Te(o),Qn(1),yn(!0)),Q(Te(o),Qn(1),yn(!1),Vf(100))),ut()),!1),f=jt(Q(Ca(Q(n,yn(!0)),Q(n,yn(!1),Vf(200))),ut()),!1);be(Q(bt(Te(o),Te(p)),he(([b,S])=>b<=S),ut()),a),be(Q(a,In(50)),c);const v=Zt(Q(bt(r,Te(s),Te(t),Te(e),Te(d)),Sn((b,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const O=k+T-S>-N,$={scrollHeight:S,scrollTop:k,viewportHeight:T};if(O){let K,U;return k>b.state.scrollTop?(K="SCROLLED_DOWN",U=b.state.scrollTop-k):(K="SIZE_DECREASED",U=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:U,state:$}}let H;return $.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":T<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:$}},ZS),ut((b,S)=>b&&b.atBottom===S.atBottom))),g=jt(Q(r,Sn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(lp(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{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}),Ie(b=>b.changed),he(b=>b.jump)),0);be(Q(v,he(b=>b.atBottom)),i),be(Q(i,In(50)),l);const x=se(xo);be(Q(r,he(({scrollTop:b})=>b),ut(),Sn((b,S)=>gt(f)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?go:xo,prevScrollTop:S},{direction:xo,prevScrollTop:0}),he(b=>b.direction)),x),be(Q(r,In(50),yn(JS)),x);const y=se(0);return be(Q(m,Ie(b=>!b),yn(0)),y),be(Q(o,In(100),$e(m),Ie(([b,S])=>!!S),Sn(([b,S],[k])=>[S,k],[0,0]),he(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ct(Lt)),Is="top",Ns="bottom",cp="none";function up(e,t,n){return typeof e=="number"?n===go&&t===Is||n===xo&&t===Ns?e:0:n===go?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function dp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ma=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=se(0),a=se(0),l=se(0),c=jt(Q(bt(Te(r),Te(o),Te(n),Te(s,fo),Te(l),Te(i),Te(t),Te(e),Te(a)),he(([d,p,m,[f,v],g,x,y,b,S])=>{const k=d-b,T=x+y,C=Math.max(m-k,0);let E=cp;const N=dp(S,Is),O=dp(S,Ns);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+T-N&&(E=go),v<d-C+p+O&&(E=xo),E!==cp?[Math.max(k-m-up(g,Is,E)-N,0),k-C-y+p+up(g,Ns,E)+O]:null}),Ie(d=>d!=null),ut(fo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ct(Lt),{singleton:!0});function eC(e,t,n){if(Es(t)){const r=rp(e,t);return[{index:un(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 Oa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function As(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:pp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:pp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function fp(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=Ra(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function pp(e,t,n){if(e.length===0)return[];if(!Es(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=Cs(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 nr=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=We();be(s.topItemsIndexes,g);const b=jt(Q(bt(f,v,Te(l,fo),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),Ie(([C,E,,N,,,,,,,O])=>{const $=O&&O.length!==N;return C&&!E&&!$}),he(([,,[C,E],N,O,$,H,K,U,I,W])=>{const _=O,{offsetTree:D,sizeTree:P}=_,j=gt(x);if(N===0)return{...Oa,totalCount:N};if(C===0&&E===0)return j===0?{...Oa,totalCount:N}:fp(j,$,O,U,I,W||[]);if(ot(P))return j>0?null:As(eC(Ra($,N),_,W),[],N,I,_,U);const G=[];if(K.length>0){const X=K[0],oe=K[K.length-1];let V=0;for(const L of Cs(P,X,oe)){const Y=L.value,J=Math.max(L.start,X),ce=Math.min(L.end,oe);for(let F=J;F<=ce;F++)G.push({data:W==null?void 0:W[F],index:F,offset:V,size:Y}),V+=Y}}if(!H)return As([],G,N,I,_,U);const Z=K.length>0?K[K.length-1]+1:0,R=HS(D,C,E,Z);if(R.length===0)return null;const M=N-1,q=Ss([],X=>{for(const oe of R){const V=oe.value;let L=V.offset,Y=oe.start;const J=V.size;if(V.offset<C){Y+=Math.floor((C-V.offset+I)/(J+I));const F=Y-oe.start;L+=F*J+F*I}Y<Z&&(L+=(Z-Y)*J,Y=Z);const ce=Math.min(oe.end,M);for(let F=Y;F<=ce&&!(L>=E);F++)X.push({data:W==null?void 0:W[F],index:F,offset:L,size:J}),L+=J+I}});return As(q,G,N,I,_,U)}),Ie(C=>C!==null),ut()),Oa);be(Q(e,Ie(ya),he(C=>C==null?void 0:C.length)),o),be(Q(b,he(C=>C.topListHeight)),p),be(p,a),be(Q(b,he(C=>[C.top,C.bottom])),i),be(Q(b,he(C=>C.items)),y);const S=Zt(Q(b,Ie(({items:C})=>C.length>0),$e(o,e),Ie(([{items:C},E])=>C[C.length-1].originalIndex===E-1),he(([,C,E])=>[C-1,E]),ut(fo),he(([C])=>C))),k=Zt(Q(b,In(200),Ie(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),he(({items:C})=>C[0].index),ut())),T=Zt(Q(b,Ie(({items:C})=>C.length>0),he(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),ut(tp)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:g,...m}},ct(Cn,ip,Ma,mo,ho,vo,zn,Aa),{singleton:!0}),hp=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=jt(Q(bt(n,e,r,t,o),he(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return be(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(Lt,nr),{singleton:!0}),tC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=jt(Q(bt(n,e,t),Ie(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),In(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(Lt,hp),{singleton:!0}),mp=Ge(()=>({context:se(null)})),nC=({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,gp=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 be(Q(d,$e(t,l,n,s,o,r,a),$e(e),he(([[p,m,f,v,g,x,y,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=nC,done:E,...N}=p,O=op(p,m,v-1),$=po(O,m.offsetTree,S)+g+x,H=$+un(m.sizeTree,O)[1],K=b+x,U=b+f-y,I=C({itemBottom:H,itemTop:$,locationParams:{align:k,behavior:T,...N},viewportBottom:U,viewportTop:K});return I?E&&cn(Q(i,Ie(W=>!W),Qn(gt(i)?1:2)),E):E&&E(),I}),Ie(p=>p!==null)),c),{scrollIntoView:d}},ct(Cn,Lt,ho,nr,Fn),{singleton:!0});function xp(e){return e?e==="smooth"?"smooth":"auto":!1}const rC=(e,t)=>typeof e=="function"?xp(e(t)):t&&xp(e),oC=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=We();let x=null;function y(T){Re(i,{align:"end",behavior:T,index:"LAST"})}Qe(Q(bt(Q(Te(t),Qn(1)),l),$e(Te(v),s,a,p),he(([[T,C],E,N,O,$])=>{let H=C&&O,K="auto";return H&&(K=rC(E,N||$),H=H&&!!K),{followOutputBehavior:K,shouldFollow:H,totalCount:T}}),Ie(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:C},Ht.DEBUG),y(T)}):x=cn(e,()=>{gt(d)("following output to ",{totalCount:C},Ht.DEBUG),y(T),x=null})});function b(T){const C=cn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(gt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(C,100)}Qe(Q(bt(Te(v),t,c),Ie(([T,,C])=>T&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ie(({refreshed:T})=>T),$e(v,t)),([,T])=>{gt(a)&&b(T!==!1)}),Qe(g,()=>{b(gt(v)!==!1)}),Qe(bt(Te(v),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=We();return be(Ca(Q(Te(r),he(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),Q(Te(t))),k),Qe(Q(bt(Q(k,Qn(1)),l),$e(Te(S),a,p,m),he(([[T,C],E,N,O,$])=>C&&N&&(E==null?void 0:E({context:$,totalCount:T,scrollingInProgress:O}))),Ie(T=>!!T),In(0)),T=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Re(f,T)}):x=cn(e,()=>{gt(d)("scrolling into view",{}),Re(f,T),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ct(Cn,vo,ho,mo,zn,Fn,Lt,mp,gp)),sC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(Q(a,$e(s),Ie(([,l])=>l!==0),$e(o,r,t,n,e),he(([[,l],c,d,p,m,f=[]])=>fp(l,c,d,p,m,f))),i),{}),ct(Cn,mo,nr,zn),{singleton:!0}),iC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Qe(Q(e,$e(r),Ie(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{cn(Q(n,Qn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},ct(zn,Lt,nr),{singleton:!0}),vp=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=We(),r=se(!1);return be(Q(e,$e(r,t,n),Ie(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ut()),t),Qe(Q(bt(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(vo),{singleton:!0}),Da=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=se(!1),i=se(void 0);return be(Q(bt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),be(Q(t,$e(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(Lt)),aC=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),p=se(null),m=se(null);return be(a,p),be(l,m),Qe(Q(c,$e(t,r,i,p,m,n)),([f,v,g,x,y,b,S])=>{const k=WS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),be(Q(d,Ie(ya),he(lC)),o),be(Q(s,$e(d),Ie(([,f])=>f!==void 0),ut(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ct(Cn,Lt,mo,zn,Da));function lC(e){return{align:"start",index:0,offset:e.scrollTop}}const cC=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return be(Q(t,Ie(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(nr));function wp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const uC=wp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),dC=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Zt(Q(l,$e(i),Sn(([,y,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const O=k+C;let $=0;return b===E&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||($=O-S,$!==0&&($+=N))),[$,T,E,O]},[0,[],0,0]),Ie(([y])=>y!==0),$e(r,a,n,o,f,v),Ie(([,y,b,S,,,k])=>!k&&!S&&y!==0&&b===go),he(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ht.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(Q(g,$e(e,s)),([y,b,S])=>{S&&uC()?Re(e,b-y):x(-y)}),Qe(Q(bt(jt(s,!1),e,v),Ie(([y,b,S])=>!y&&!S&&b!==0),he(([y,b])=>b),In(1)),x),be(Q(p,he(y=>({top:-y}))),t),Qe(Q(c,$e(m,d),he(([y,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(y);{let E=0;const N=uo(k,0);let O=0,$=0;for(;O<y;){O++,E+=N;let H=b.length===$+1?1/0:b[$+1]-b[$]-1;O+H>y&&(E-=N,H=y-O+1),O+=H,E+=C(H),$++}return E}})),y=>{Re(e,y),requestAnimationFrame(()=>{Re(t,{top:y}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},ct(Lt,vo,nr,Cn,Fn,Aa)),fC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ct(Ma,sC,zn,vp,hp,iC,tC,Da,gp,Fn,mp)),bp=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},O])=>(be(k.rangeChanged,O.scrollSeekRangeChanged),be(Q(O.windowViewportRect,he($=>$.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:T,statefulTotalCount:c,trackItemSizes:p,...k,...O,...g,sizes:l,...x}),ct(Cn,mo,Lt,aC,oC,nr,ho,dC,cC,ip,fC));function pC(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 js=typeof document<"u"?w.useLayoutEffect:w.useEffect;function yp(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]=AS(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...S}=x,[k]=w.useState(()=>Ss(_S(e),E=>{l(E,S)})),[T]=w.useState(Wf(d,k));js(()=>{for(const E of i)E in S&&Qe(T[E],S[E]);return()=>{Object.values(T).map(Sa)}},[S,T,k]),js(()=>{l(k,S)}),w.useImperativeHandle(y,Hf(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...pC([...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,()=>gt(y),()=>gt(y))},v=x=>{const y=w.useContext(a)[x],[b,S]=w.useState(Wf(gt,y));return js(()=>Qe(y,k=>{k!==b&&S(Hf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];js(()=>Qe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Sp=w.createContext(void 0),Cp=w.createContext(void 0),Tp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function La(e){return"self"in e}function hC(e){return"body"in e}function kp(e,t,n,r=Ir,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)||La(x)){const b=La(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():Ao.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;La(f)?(x=Math.max(Bn(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=Bn(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)),lp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const $a="-webkit-sticky",Ep="sticky",Fa=wp(()=>{if(typeof document>"u")return Ep;const e=document.createElement("div");return e.style.position=$a,e.style.position===$a?$a:Ep});function Ba(e){return e}const mC=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ba),o=se("div"),s=se(Ir),i=(a,l=null)=>jt(Q(n,he(c=>c[a]),ut()),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")}}),gC=Ge(([e,t])=>({...e,...t}),ct(bp,mC)),xC=({height:e})=>u.jsx("div",{style:{height:e}}),vC={overflowAnchor:"none",position:Fa(),zIndex:1},Ip={overflowAnchor:"none"},wC={...Ip,display:"inline-block",height:"100%"},Np=w.memo(function({showTopList:e=!1}){const t=je("listState"),n=tn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),p=je("trackItemSizes"),m=je("itemSize"),f=je("log"),v=tn("gap"),g=je("horizontalDirection"),{callbackRef:x}=MS(n,m,p,e?Ir:a,f,v,o,g,je("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);za("deviation",I=>{y!==I&&b(I)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||xC,T=je("ListComponent"),C=je("ItemComponent"),E=je("GroupComponent"),N=je("computeItemKey"),O=je("isSeeking"),$=je("groupIndices").length>0,H=je("alignToBottom"),K=je("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{..._t(S,c)}):u.jsx(T,{..._t(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:U,children:(e?t.topItems:t.items).map(I=>{const W=I.originalIndex,_=N(W+t.firstItemIndex,I.data,c);return O?w.createElement(k,{..._t(k,c),height:I.size,index:I.index,key:_,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?w.createElement(E,{..._t(E,c),"data-index":W,"data-item-index":I.index,"data-known-size":I.size,key:_,style:vC},d(I.index,c)):w.createElement(C,{..._t(C,c),...CC(C,I.data),"data-index":W,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:_,style:g?wC:Ip},$?l(I.index,I.groupIndex,I.data,c):l(I.index,I.data,c))})})}),bC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},yC={outline:"none",overflowX:"auto",position:"relative"},_s=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),SC={position:Fa(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function CC(e,t){return{item:typeof e=="string"?void 0:t}}const TC=w.memo(function(){const e=je("HeaderComponent"),t=tn("headerHeight"),n=je("HeaderFooterTag"),r=er(w.useMemo(()=>s=>{t(Bn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),kC=w.memo(function(){const e=je("FooterComponent"),t=tn("footerHeight"),n=je("HeaderFooterTag"),r=er(w.useMemo(()=>s=>{t(Bn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null});function Ap({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"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=kp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?yC:bC,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function jp({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"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=kp(a,c,l,v,m);return Tp(()=>{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+p}:{}},...i,..._t(l,s),children:r})})}const EC=({children:e})=>{const t=w.useContext(Sp),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=w.useMemo(()=>Uf(n,l=>Bn(l,s?"width":"height")),[n,s]),a=er(i,!0,je("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:_s(o),children:e})},IC=({children:e})=>{const t=w.useContext(Sp),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=je("customScrollParent"),s=Gf(n,o,je("skipAnimationFrameInResizeObserver")),i=je("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:_s(i),children:e})},NC=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...SC,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,..._t(t,o),children:e})},AC=w.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?PC:_C,{...e,context:o,children:[n&&u.jsx(NC,{children:u.jsx(Np,{showTopList:!0})}),u.jsxs(r||t?IC:EC,{children:[u.jsx(TC,{}),u.jsx(Np,{}),u.jsx(kC,{})]})]})}),{Component:jC,useEmitter:za,useEmitterValue:je,usePublisher:tn}=yp(gC,{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"}},AC),_C=Ap({useEmitter:za,useEmitterValue:je,usePublisher:tn}),PC=jp({useEmitter:za,useEmitterValue:je,usePublisher:tn}),RC=jC;ct(bp,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(Ba),a=se(Ir),l=(c,d=null)=>jt(Q(s,he(p=>p[c]),ut()),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")}})),Fa();const _p={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:Pp,floor:Ps,max:wo,min:Ha,round:Rp}=Math;function Mp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function OC(e){return{...MC,items:e}}function Rs(e,t){return e&&e.width===t.width&&e.height===t.height}function DC(e,t){return e&&e.column===t.column&&e.row===t.row}const LC=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=se(0),E=se(0),N=se(_p),O=se({height:0,width:0}),$=se({height:0,width:0}),H=We(),K=We(),U=se(0),I=se(null),W=se({column:0,row:0}),_=We(),D=We(),P=se(!1),j=se(0),G=se(!0),Z=se(!1),R=se(!1);Qe(Q(v,$e(j),Ie(([L,Y])=>!!Y)),()=>{Re(G,!1)}),Qe(Q(bt(v,G,$,O,j,Z),Ie(([L,Y,J,ce,,F])=>L&&!Y&&J.height!==0&&ce.height!==0&&!F)),([,,,,L])=>{Re(Z,!0),Pa(1,()=>{Re(H,L)}),cn(Q(c),()=>{Re(t,[0,0]),Re(G,!0)})}),be(Q(D,Ie(L=>L!=null&&L.scrollTop>0),yn(0)),E),Qe(Q(v,$e(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Re(O,L.viewport),Re($,L.item),Re(W,L.gap),L.scrollTop>0&&(Re(P,!0),cn(Q(c,Qn(1)),Y=>{Re(P,!1)}),Re(l,{top:L.scrollTop})))}),be(Q(O,he(({height:L})=>L)),p),be(Q(bt(Te(O,Rs),Te($,Rs),Te(W,(L,Y)=>L&&L.column===Y.column&&L.row===Y.row),Te(c)),he(([L,Y,J,ce])=>({gap:J,item:Y,scrollTop:ce,viewport:L}))),_),be(Q(bt(Te(C),r,Te(W,DC),Te($,Rs),Te(O,Rs),Te(I),Te(E),Te(P),Te(G),Te(j)),Ie(([,,,,,,,L])=>!L),he(([L,[Y,J],ce,F,re,ue,le,,xe,Ne])=>{const{column:_e,row:De}=ce,{height:Ae,width:Be}=F,{width:tt}=re;if(le===0&&(L===0||tt===0))return _p;if(Be===0){const Rt=Ra(Ne,L),Mt=Rt+Math.max(le-1,0);return OC(Mp(Rt,Mt,ue))}const qe=Op(tt,Be,_e);let ze,it;xe?Y===0&&J===0&&le>0?(ze=0,it=le-1):(ze=qe*Ps((Y+De)/(Ae+De)),it=qe*Pp((J+De)/(Ae+De))-1,it=Ha(L-1,wo(it,qe-1)),ze=Ha(it,wo(0,ze))):(ze=0,it=-1);const nt=Mp(ze,it,ue),{bottom:Ze,top:St}=Dp(re,ce,F,nt),xt=Pp(L/qe),at=xt*Ae+(xt-1)*De-Ze;return{bottom:Ze,itemHeight:Ae,items:nt,itemWidth:Be,offsetBottom:at,offsetTop:St,top:St}})),N),be(Q(I,Ie(L=>L!==null),he(L=>L.length)),C),be(Q(bt(O,$,N,W),Ie(([L,Y,{items:J}])=>J.length>0&&Y.height!==0&&L.height!==0),he(([L,Y,{items:J},ce])=>{const{bottom:F,top:re}=Dp(L,ce,Y,J);return[re,F]}),ut(fo)),t);const M=se(!1);be(Q(c,$e(M),he(([L,Y])=>Y||L!==0)),M);const q=Zt(Q(bt(N,C),Ie(([{items:L}])=>L.length>0),$e(M),Ie(([[L,Y],J])=>{const ce=L.items[L.items.length-1].index===Y-1;return(J||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Y)&&ce}),he(([[,L]])=>L-1),ut())),X=Zt(Q(Te(N),Ie(({items:L})=>L.length>0&&L[0].index===0),yn(0),ut())),oe=Zt(Q(Te(N),$e(P),Ie(([{items:L},Y])=>L.length>0&&!Y),he(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(tp),In(0)));be(oe,f.scrollSeekRangeChanged),be(Q(H,$e(O,$,C,W),he(([L,Y,J,ce,F])=>{const re=ap(L),{align:ue,behavior:le,offset:xe}=re;let Ne=re.index;Ne==="LAST"&&(Ne=ce-1),Ne=wo(0,Ne,Ha(ce-1,Ne));let _e=Ua(Y,F,J,Ne);return ue==="end"?_e=Rp(_e-Y.height+J.height):ue==="center"&&(_e=Rp(_e-Y.height/2+J.height/2)),xe&&(_e+=xe),{behavior:le,top:_e}})),l);const V=jt(Q(N,he(L=>L.offsetBottom+L.bottom)),0);return be(Q(k,he(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:x,data:I,deviation:U,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:y,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:R,initialTopMostItemIndex:j,totalListHeight:V,...m,endReached:q,propsReady:g,rangeChanged:oe,startReached:X,stateChanged:_,stateRestoreInProgress:P,...T}},ct(Ma,Lt,vo,vp,zn,Da,Fn));function Op(e,t,n){return wo(1,Ps((e+n)/(Ps(t)+n)))}function Dp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ua(e,t,n,r[0].index);return{bottom:Ua(e,t,n,r[r.length-1].index)+o,top:s}}function Ua(e,t,n,r){const o=Op(e.width,n.width,t.column),s=Ps(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const $C=Ge(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ba),i=se("div"),a=se(Ir),l=(p,m=null)=>jt(Q(t,he(f=>f[p]),ut()),m),c=se(!1),d=se(!1);return be(Te(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")}}),FC=Ge(([e,t])=>({...e,...t}),ct(LC,$C)),BC=w.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=nn("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),c=ft("ScrollSeekPlaceholder"),d=ft("context"),p=nn("itemDimensions"),m=nn("gap"),f=ft("log"),v=ft("stateRestoreInProgress"),g=nn("reportReadyState"),x=er(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();p({height:k,width:T})}m({column:$p("column-gap",getComputedStyle(y).columnGap,f),row:$p("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Tp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,..._t(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,{..._t(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{..._t(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),zC=w.memo(function(){const e=ft("HeaderComponent"),t=nn("headerHeight"),n=ft("headerFooterTag"),r=er(w.useMemo(()=>s=>{t(Bn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),HC=w.memo(function(){const e=ft("FooterComponent"),t=nn("footerHeight"),n=ft("headerFooterTag"),r=er(w.useMemo(()=>s=>{t(Bn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),UC=({children:e})=>{const t=w.useContext(Cp),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=er(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:_s(!1),children:e})},WC=({children:e})=>{const t=w.useContext(Cp),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=ft("customScrollParent"),s=Gf(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:_s(!1),children:e})},VC=w.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?qC:KC,o=n||t?WC:UC,s=ft("context");return u.jsx(r,{...e,..._t(r,s),children:u.jsxs(o,{children:[u.jsx(zC,{}),u.jsx(BC,{}),u.jsx(HC,{})]})})}),{useEmitter:Lp,useEmitterValue:ft,usePublisher:nn}=yp(FC,{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"}},VC),KC=Ap({useEmitter:Lp,useEmitterValue:ft,usePublisher:nn}),qC=jp({useEmitter:Lp,useEmitterValue:ft,usePublisher:nn});function $p(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}const GC=Dr.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 Fp({className:e,variant:t,...n}){return u.jsx("div",{className:te(GC({variant:t}),e),...n})}var Ms="Dialog",[Bp,hN]=sn(Ms),[YC,dn]=Bp(Ms),zp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=Rn({prop:r,defaultProp:o??!1,onChange:s,caller:Ms});return u.jsx(YC,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};zp.displayName=Ms;var Hp="DialogTrigger",Up=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Hp,n),s=Le(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ka(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Up.displayName=Hp;var Wa="DialogPortal",[XC,Wp]=Bp(Wa,{forceMount:void 0}),Vp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Wa,t);return u.jsx(XC,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(to,{asChild:!0,container:o,children:i})}))})};Vp.displayName=Wa;var Os="DialogOverlay",Kp=h.forwardRef((e,t)=>{const n=Wp(Os,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Os,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(ZC,{...o,ref:t})}):null});Kp.displayName=Os;var JC=qt.createSlot("DialogOverlay.RemoveScroll"),ZC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Os,n);return u.jsx(ps,{as:JC,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rr="DialogContent",qp=h.forwardRef((e,t)=>{const n=Wp(rr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(rr,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(QC,{...o,ref:t}):u.jsx(eT,{...o,ref:t})})});qp.displayName=rr;var QC=h.forwardRef((e,t)=>{const n=dn(rr,e.__scopeDialog),r=h.useRef(null),o=Le(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(Gp,{...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())})}),eT=h.forwardRef((e,t)=>{const n=dn(rr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Gp,{...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()}})}),Gp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(rr,n),l=h.useRef(null),c=Le(t,l);return $i(),u.jsxs(u.Fragment,{children:[u.jsx(Go,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(gr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(tT,{titleId:a.titleId}),u.jsx(rT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Va="DialogTitle",Yp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Va,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Yp.displayName=Va;var Xp="DialogDescription",Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Xp,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Jp.displayName=Xp;var Zp="DialogClose",Qp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Zp,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});Qp.displayName=Zp;function Ka(e){return e?"open":"closed"}var eh="DialogTitleWarning",[mN,th]=xw(eh,{contentName:rr,titleName:Va,docsSlug:"dialog"}),tT=({titleId:e})=>{const t=th(eh),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 h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ZC="DialogDescriptionWarning",QC=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${eh(ZC).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},qa=Bp,eT=Hp,Ga=Wp,bo=Vp,yo=Kp,rr=Gp,Ds=Xp,th=Zp;const Ya=qa,tT=Ga,nh=h.forwardRef(({className:e,...t},n)=>u.jsx(bo,{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}));nh.displayName=bo.displayName;const Ls=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===rr||(c==null?void 0:c.displayName)===rr.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(tT,{children:[u.jsx(nh,{}),u.jsxs(yo,{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(rr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(th,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ls.displayName=yo.displayName;const $s=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});$s.displayName="DialogHeader";const Fs=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Fs.displayName=rr.displayName;const nT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ds,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));nT.displayName=Ds.displayName;const rT=1,oT=1e6;let Xa=0;function sT(){return Xa=(Xa+1)%Number.MAX_SAFE_INTEGER,Xa.toString()}const Ja=new Map,rh=e=>{if(Ja.has(e))return;const t=setTimeout(()=>{Ja.delete(e),So({type:"REMOVE_TOAST",toastId:e})},oT);Ja.set(e,t)},iT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,rT)};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?rh(n):e.toasts.forEach(r=>{rh(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)}}},Bs=[];let zs={toasts:[]};function So(e){zs=iT(zs,e),Bs.forEach(t=>{t(zs)})}function aT({...e}){const t=sT(),n=o=>So({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>So({type:"DISMISS_TOAST",toastId:t});return So({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Za(){const[e,t]=h.useState(zs);return h.useEffect(()=>(Bs.push(t),()=>{const n=Bs.indexOf(t);n>-1&&Bs.splice(n,1)}),[e]),{...e,toast:aT,dismiss:n=>So({type:"DISMISS_TOAST",toastId:n})}}function oh({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:p}=Za(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ii(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),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Ii(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),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(fe.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(lt,{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(fe.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(fe.Image,{className:"h-5 w-5"}):u.jsx(fe.FileText,{className:"h-5 w-5"});return u.jsx(Ya,{open:e,onOpenChange:t,children:u.jsxs(Ls,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx($s,{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(Fs,{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(lt,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(fe.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(lt,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(fe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function sh(){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 or=sh();function lT(e){or=e}const ih=/[&<>"']/,cT=new RegExp(ih.source,"g"),ah=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,uT=new RegExp(ah.source,"g"),dT={"&":"&","<":"<",">":">",'"':""","'":"'"},lh=e=>dT[e];function Pt(e,t){if(t){if(ih.test(e))return e.replace(cT,lh)}else if(ah.test(e))return e.replace(uT,lh);return e}const fT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ch(e){return e.replace(fT,(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 pT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(pT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const hT=/[^\w:]/g,mT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function uh(e,t,n){if(e){let r;try{r=decodeURIComponent(ch(n)).replace(hT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!mT.test(n)&&(n=wT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Hs={},gT=/^[^:]+:\/*[^/]*$/,xT=/^([^:]+:)[\s\S]*$/,vT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function wT(e,t){Hs[" "+e]||(gT.test(e)?Hs[" "+e]=e+"/":Hs[" "+e]=Ws(e,"/",!0)),e=Hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(xT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(vT,"$1")+t:e+t}const Us={exec:function(){}};function dh(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 Ws(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 bT(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 yT(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 fh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ph(e,t,n,r){const o=t.href,s=t.title?Pt(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:Pt(i)}}function ST(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},nT="DialogDescriptionWarning",rT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${th(nT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},qa=zp,oT=Up,Ga=Vp,bo=Kp,yo=qp,or=Yp,Ds=Jp,nh=Qp;const Ya=qa,sT=Ga,rh=h.forwardRef(({className:e,...t},n)=>u.jsx(bo,{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}));rh.displayName=bo.displayName;const Ls=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.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(sT,{children:[u.jsx(rh,{}),u.jsxs(yo,{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(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs(nh,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ls.displayName=yo.displayName;const $s=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});$s.displayName="DialogHeader";const Fs=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Fs.displayName=or.displayName;const iT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ds,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));iT.displayName=Ds.displayName;const aT=1,lT=1e6;let Xa=0;function cT(){return Xa=(Xa+1)%Number.MAX_SAFE_INTEGER,Xa.toString()}const Ja=new Map,oh=e=>{if(Ja.has(e))return;const t=setTimeout(()=>{Ja.delete(e),So({type:"REMOVE_TOAST",toastId:e})},lT);Ja.set(e,t)},uT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,aT)};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?oh(n):e.toasts.forEach(r=>{oh(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)}}},Bs=[];let zs={toasts:[]};function So(e){zs=uT(zs,e),Bs.forEach(t=>{t(zs)})}function dT({...e}){const t=cT(),n=o=>So({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>So({type:"DISMISS_TOAST",toastId:t});return So({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Za(){const[e,t]=h.useState(zs);return h.useEffect(()=>(Bs.push(t),()=>{const n=Bs.indexOf(t);n>-1&&Bs.splice(n,1)}),[e]),{...e,toast:dT,dismiss:n=>So({type:"DISMISS_TOAST",toastId:n})}}function sh({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:p}=Za(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ii(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),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Ii(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),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(fe.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(lt,{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(fe.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(fe.Image,{className:"h-5 w-5"}):u.jsx(fe.FileText,{className:"h-5 w-5"});return u.jsx(Ya,{open:e,onOpenChange:t,children:u.jsxs(Ls,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx($s,{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(Fs,{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(lt,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(fe.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(lt,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(fe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ih(){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 sr=ih();function fT(e){sr=e}const ah=/[&<>"']/,pT=new RegExp(ah.source,"g"),lh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,hT=new RegExp(lh.source,"g"),mT={"&":"&","<":"<",">":">",'"':""","'":"'"},ch=e=>mT[e];function Pt(e,t){if(t){if(ah.test(e))return e.replace(pT,ch)}else if(lh.test(e))return e.replace(hT,ch);return e}const gT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function uh(e){return e.replace(gT,(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 xT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(xT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const vT=/[^\w:]/g,wT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function dh(e,t,n){if(e){let r;try{r=decodeURIComponent(uh(n)).replace(vT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!wT.test(n)&&(n=CT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Hs={},bT=/^[^:]+:\/*[^/]*$/,yT=/^([^:]+:)[\s\S]*$/,ST=/^([^:]+:\/*[^/]*)[\s\S]*$/;function CT(e,t){Hs[" "+e]||(bT.test(e)?Hs[" "+e]=e+"/":Hs[" "+e]=Ws(e,"/",!0)),e=Hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(yT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(ST,"$1")+t:e+t}const Us={exec:function(){}};function fh(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 Ws(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 TT(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 kT(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 ph(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function hh(e,t,n,r){const o=t.href,s=t.title?Pt(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:Pt(i)}}function ET(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 Qa{constructor(t){this.options=t||
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
85
|
+
`)}class Qa{constructor(t){this.options=t||sr}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:Ws(r,`
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=ET(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=Ws(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const 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)),p=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(p)&&(r+=p+`
|
|
89
89
|
`,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=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],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(p)||E.test(p)||k.test(p)||T.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
|
|
91
91
|
`+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||C.test(d)||E.test(d)||T.test(d))break;f+=`
|
|
92
92
|
`+p}!l&&!p.trim()&&(l=!0),r+=m+`
|
|
93
|
-
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(C=>C.type==="space"),T=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));y.loose=T}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]):Pt(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:Pt(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]):Pt(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=Ws(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=
|
|
96
|
-
]`).replace("lheading",Ce.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const me={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Us,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:Us,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=st(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=st(Ce._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=st(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=st(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=st(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=st(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=st(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=st(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=st(me.reflink).replace("label",me._label).replace("ref",Ce._label).getRegex(),me.nolink=st(me.nolink).replace("ref",Ce._label).getRegex(),me.reflinkSearch=st(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:st(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:st(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=st(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:st(me.br).replace("{2,}","*").getRegex(),text:st(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function
|
|
93
|
+
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(C=>C.type==="space"),T=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));y.loose=T}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]):Pt(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:fh(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]=fh(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:Pt(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]):Pt(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=Ws(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=TT(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)),hh(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 hh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Pt(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=Pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Pt(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=Pt(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=Pt(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]):Pt(r[0]):r[0]:o=Pt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Ce={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:Us,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ce._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ce._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Ce.def=st(Ce.def).replace("label",Ce._label).replace("title",Ce._title).getRegex(),Ce.bullet=/(?:[*+-]|\d{1,9}[.)])/,Ce.listItemStart=st(/^( *)(bull) */).replace("bull",Ce.bullet).getRegex(),Ce.list=st(Ce.list).replace(/bull/g,Ce.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ce.def.source+")").getRegex(),Ce._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",Ce._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Ce.html=st(Ce.html,"i").replace("comment",Ce._comment).replace("tag",Ce._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ce.paragraph=st(Ce._paragraph).replace("hr",Ce.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",Ce._tag).getRegex(),Ce.blockquote=st(Ce.blockquote).replace("paragraph",Ce.paragraph).getRegex(),Ce.normal={...Ce},Ce.gfm={...Ce.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Ce.gfm.table=st(Ce.gfm.table).replace("hr",Ce.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",Ce._tag).getRegex(),Ce.gfm.paragraph=st(Ce._paragraph).replace("hr",Ce.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ce.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",Ce._tag).getRegex(),Ce.pedantic={...Ce.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ce._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:Us,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(Ce.normal._paragraph).replace("hr",Ce.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",Ce.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const me={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Us,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:Us,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=st(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=st(Ce._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=st(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=st(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=st(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=st(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=st(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=st(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=st(me.reflink).replace("label",me._label).replace("ref",Ce._label).getRegex(),me.nolink=st(me.nolink).replace("ref",Ce._label).getRegex(),me.reflinkSearch=st(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:st(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:st(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=st(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:st(me.br).replace("{2,}","*").getRegex(),text:st(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function IT(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 mh(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 Hn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new Qa,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:Ce.normal,inline:me.normal};this.options.pedantic?(n.block=Ce.pedantic,n.inline=me.pedantic):this.options.gfm&&(n.block=Ce.gfm,this.options.breaks?n.inline=me.breaks:n.inline=me.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ce,inline:me}}static lex(t,n){return new Hn(n).lex(t)}static lexInline(t,n){return new Hn(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)+"["+ph("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)+"["+ph("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,mh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,mh))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,IT)){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 el{constructor(t){this.options=t||sr}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+Pt(o)+'">'+(r?t:Pt(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Pt(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 Vs{constructor(t){this.options=t||
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(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 xh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=TT(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(yT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(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 xh(Bn.lex,zn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},lT(ye.defaults),ye},ye.getDefaults=sh,ye.defaults=or,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 el;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 Qa;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 Vs;for(const s in n.hooks){const i=o[s];Vs.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=xh(Bn.lexInline,zn.parseInline),ye.Parser=zn,ye.parser=zn.parse,ye.Renderer=el,ye.TextRenderer=mh,ye.Lexer=Bn,ye.lexer=Bn.lex,ye.Tokenizer=Qa,ye.Slugger=gh,ye.Hooks=Vs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,zn.parse,Bn.lex;function Ar({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{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 vh({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 wh({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(fe.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(fe.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(fe.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(fe.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(fe.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(fe.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(Ar,{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(fe.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 bh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Kv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(wh,{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(vh,{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 tl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));tl.displayName="Card";const nl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));nl.displayName="CardHeader";const rl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));rl.displayName="CardTitle";const ol=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ol.displayName="CardDescription";const sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));sl.displayName="CardContent";const yh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));yh.displayName="CardFooter";function Sh({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=hr(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(tl,{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(nl,{className:"pb-3",children:[u.jsx(rl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ol,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(sl,{className:"pt-0 pb-3",children:a}),u.jsx(yh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(lt,{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(lt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const kT="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 il({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:kT,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:hr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)})}function Ch({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(fe.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 Th({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx(il,{data:c});const d=typeof c=="string"?c:(()=>{try{return hr(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}=Fv(l);return d?u.jsx(Ar,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.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=Kr(l),d=qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ch,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function kh({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 Eh({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(Ar,{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(lt,{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(fe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(fe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ih({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:T,setIsUserExpanded:C,isCompactLayout:E,activeInterruptId:N,activeInterruptValue:O,iconForeground:$}){const H=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=w.useCallback(({part:I,i:W})=>{if(I.type==="text"){const _=I.text??"",D=_.trim(),P=Ni(D);return P&&b!=="tool"?u.jsx(il,{data:P},W):b==="user"&&S&&D.length>k?u.jsx(Eh,{text:D,expanded:T,onExpandedChange:C,previewLength:k,isCompact:E},W):u.jsx(Ar,{content:_,allowHtml:!1},W)}if(I.type==="image_url"){const _=I;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(I.type==="file"){const _=I,D=_.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(fe.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[D,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const _=I,D=Vo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id)),P=!!(N&&D&&D===N),j=P?O??(_==null?void 0:_.value):_==null?void 0:_.value,G=D?{..._,id:D,interrupt_id:D}:_;return u.jsx(Sh,{interruptPart:G,onApprove:g,onReject:x,disabled:y,isActive:P,payload:j},W)}return null},[f,v,g,x,b,S,k,T,E,N,O,y]),U=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!U&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Th,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,_)=>u.jsx(K,{part:W,i:_},_))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(kh,{className:$})]}):I}return null}function Nh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),p=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],T=v.name||`file_${k}`,C=v.mimeType||"application/octet-stream";p({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){f.preventDefault(),s(T=>({...T,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await Qc(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.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(!(C!=null&&C.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");p({id:C.id,name:v.name||C.filename||`file_${C.id}`,mimeType:v.mimeType||C.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Ah(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:Bv(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:zv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ks=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:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:T=1,attemptIndex:C=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[O,$]=w.useState(!1),[H,K]=w.useState("preview"),[U,I]=w.useState(!1),{currentThreadId:W}=pr(),{respondToInterrupt:_}=Yr(),D=l==="phone"||l==="half-screen",P=t.role,j=P==="tool",G=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),J=!!G,R=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:q,fileViewerOpen:Y,currentFileInfo:oe,closeFileViewer:V}=Nh({allowFileOpen:R,currentThreadId:W}),L=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=Ah(t,G),{contentParts:Z,imageParts:ce,fileParts:F,interruptParts:re,textContent:ue,toolMeta:le,toolRaw:xe,isToolStreaming:Ne}=X,$e=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),Fe=Vo($e),Ae=y==null?void 0:y.value,Be=w.useMemo(()=>G||!m?null:t.artifact||null,[G,t,m]),tt=w.useCallback(async()=>{const ge=j?xe:ue;async function He(Ye){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ye);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const vt=new Blob([Ye],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":vt})]);return}throw new Error("Clipboard API not supported in this context.")}try{await He(ge),$(!0),setTimeout(()=>$(!1),2e3),x==null||x(ge)}catch(Ye){console.error("Failed to copy:",Ye)}},[j,xe,ue,x]),qe=w.useCallback(()=>{if(!v||!t.id)return;const ge=(j?xe:ue)??"",He="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ge,He)},[v,t.id,j,xe,ue,t]),ze=w.useCallback(()=>{g==null||g(n)},[g,n]),it=w.useCallback(()=>{const He=te(D?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",L);switch(P){case"user":return u.jsx(fe.User,{className:He});case"assistant":return u.jsx(fe.Bot,{className:He});case"tool":return u.jsx(fe.Wrench,{className:He});default:return u.jsx(fe.Bot,{className:He})}},[D,L,P]),nt=w.useCallback(()=>{const ge="group relative mb-4 flex w-full";switch(P){case"user":return te(ge,"justify-end");case"assistant":case"tool":case"system":return te(ge,"justify-start");default:return ge}},[P]),Ze=w.useCallback(()=>{const ge=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",D&&"px-3 py-2 text-sm");if(J)return te(ge,"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(ge,"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(ge,"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(ge,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(ge,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(ge,"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")}},[D,J,P]),St=w.useCallback(async ge=>{if(b)return;const He=Vo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id));if(!He){console.warn("Interrupt part missing id",ge);return}try{S==null||S(),await _(He,!0)}catch(Ye){console.error("Failed to approve interrupt:",Ye)}finally{k==null||k()}},[b,k,S,_]),xt=w.useCallback(async ge=>{if(b)return;const He=Vo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id));if(!He){console.warn("Interrupt part missing id",ge);return}try{S==null||S(),await _(He,!1)}catch(Ye){console.error("Failed to reject interrupt:",Ye)}finally{k==null||k()}},[b,k,S,_]),at=w.useMemo(()=>G?"Assistant":Hv(t),[G,t]),Rt=P==="user"&&(T??1)>1&&typeof E=="function",Mt=(N==null?void 0:N.length)??0,Ct=Mt>0&&C<Mt-1?N[C+1]:void 0,Tt=Mt>0&&C>0?N[C-1]:void 0,kt=w.useCallback(()=>{!Ct||!E||E(Ct.id,void 0,!!Ct.isLatestAttempt)},[Ct,E]),Ve=w.useCallback(()=>{!Tt||!E||E(Tt.id,void 0,!!Tt.isLatestAttempt)},[Tt,E]);return j&&!p&&!Be?null:J&&G?u.jsx("div",{className:te(nt(),f.container),children:u.jsxs("div",{className:te(Ze(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(fe.Bot,{className:te("h-4 w-4",L)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:G.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(nt(),f.container),children:u.jsxs("div",{className:te(Ze(),f.content),children:[(i||a||j)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",D&&"mb-1 pb-1",L,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[it(),a&&at&&u.jsx("span",{className:te("font-medium",D?"text-xs":"text-sm"),children:at}),j&&u.jsxs($p,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",L,"border border-current/40",D&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>K(ge=>ge==="expanded"?"preview":"expanded"),onKeyDown:ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),K(He=>He==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:le.name??"Tool Output"}),le.toolCallId&&u.jsx("span",{className:"opacity-70",children:le.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(fe.ChevronUp,{className:"h-3 w-3"}):u.jsx(fe.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Rt&&T>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",C<T-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C>=T-1||kt()},"aria-label":"Older attempt (back in time)",disabled:C>=T-1,children:u.jsx(fe.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[T-C," / ",T]})}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",C>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C<=0||Ve()},"aria-label":"Newer attempt (forward in time)",disabled:C<=0,children:u.jsx(fe.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",L,D&&"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(lt,{variant:"ghost",size:"sm",onClick:()=>tt(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(fe.Copy,{className:te(O?"text-success":L,D?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:qe,className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(fe.Edit,{className:te(L,D?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:ze,className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(fe.RotateCcw,{className:te(L,D?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Ih,{message:t,isToolMessage:j,showToolMessages:p,artifactToRender:Be,toolViewMode:H,isToolStreaming:Ne,contentParts:Z,textContent:ue,imageParts:ce,fileParts:F,interruptParts:re,isStreamingMessage:r,defaultMessage:G,handleFileClick:q,uploadingFiles:M,handleInterruptApprove:St,handleInterruptReject:xt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:I,isCompactLayout:D,activeInterruptId:Fe,activeInterruptValue:Ae,iconForeground:L}),m&&Be&&u.jsx("div",{className:"mt-3",children:u.jsx(bh,{artifact:Be,idx:0})})]}),j&&H==="expanded"&&(le.toolCallId||le.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",D&&"text-xs"),children:[le.name&&u.jsxs("div",{children:["Function: ",le.name]}),le.toolCallId&&u.jsxs("div",{children:["Call ID: ",le.toolCallId]})]}),!(i||a||j)&&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(lt,{variant:"ghost",size:"sm",onClick:()=>tt(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.Copy,{className:te(O?"text-success":"text-current",D?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:qe,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.Edit,{className:te("text-current",D?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:ze,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.RotateCcw,{className:te("text-current",D?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(oh,{isOpen:Y,onClose:V,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&cu(e.message)===cu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=uu(e.message),a=uu(t.message);return i.length===a.length});Ks.displayName="MessageComponent";const ET={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=al(t,n),T="type"in t&&t.type==="default_message",E=!!t.__syntheticStreaming,N=b??ET,O=!T&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:$,attemptIndex:H,attempts:K}=w.useMemo(()=>ec(t.id,O,N),[t.id,O,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(Ks,{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:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:$,attemptIndex:H,attemptMetas:K,onSelectCheckpoint:S})})});ll.displayName="MessageRow";const cl=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:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:O,onSelectCheckpoint:$,createSyntheticThinkingMessage:H=!0},K)=>{const U=w.useRef(null),I=w.useRef(null),W=w.useRef(!1),_=w.useRef(!1),[D,P]=w.useState(!0),j=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(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===b.id)):!1,[b,e]),G=w.useMemo(()=>{if(!b||j)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let re;const ue=b.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const le=ue.title;typeof le=="string"&&le.trim()&&(re=le.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:ue,title:re}]}},[b,j]),J=w.useMemo(()=>G?[...e,G]:e,[e,G]),R=w.useMemo(()=>!H||!t?J:!J.some(re=>re.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,H]),M=w.useMemo(()=>C?R:R.filter(F=>(F==null?void 0:F.role)!=="tool"),[R,C]),q=w.useCallback(F=>{P(F),x&&x(!F),y&&y(F)},[x,y]),Y=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:D?"auto":!1,[D,v,g]),V=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return F?{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}:null},[f]),L=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ks,{message:V,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,ce=Z>0;return w.useEffect(()=>{var F,re;if(Z===0){_.current=!1;return}if(!_.current)if(_.current=!0,U.current&&M.length>0){const ue=M.length-1;(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:ue,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[Z,M.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var F,re;if(U.current&&M.length>0){const ue=M.length-1;(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:ue,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var F,re;U.current&&M.length>0?(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ce?u.jsx(AC,{ref:F=>{U.current=F},scrollerRef:F=>{I.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Y&&Y()},atBottomStateChange:q,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,re)=>al(re,F),itemContent:(F,re)=>u.jsx(ll,{message:re,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:T,showToolMessages:C,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:O,onSelectCheckpoint:$})}):X()})})});cl.displayName="MessageList";const jh={value:""};function Co({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:T,navigateToCheckpoint:C,returnToLatest:E,checkpoint:N,checkpoints:O,interrupt:$,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:U,error:I,connectionState:W,submit:_,stop:D}=Ri(),P=b??y??null,j=(N==null?void 0:N.id)??null,G=(N==null?void 0:N.namespace)??null,[J,R]=w.useState(null),M=(H==null?void 0:H.assemblingMessageId)??(U&&J?J:null),q=$,[Y,oe]=w.useState(!1);w.useEffect(()=>{q||oe(!1)},[q]);const V=w.useCallback(()=>{oe(!0)},[]),L=w.useCallback(()=>{oe(!1)},[]),X=!!q||Y,[Z,ce]=w.useState(null),[F,re]=w.useState(""),[ue,le]=w.useState(null),[xe,Ne]=w.useState(null),[$e,Fe]=w.useState([]),[Ae,Be]=w.useState(0),[tt,qe]=w.useState(0),[ze,it]=w.useState(!1),[nt,Ze]=w.useState(null),[St,xt]=w.useState(null),[at,Rt]=w.useState(!1),[Mt,Ct]=w.useState(null),Tt=w.useRef(!1),[kt,Ve]=w.useState(()=>jh.value),ge=w.useRef(kt),He=w.useRef(null),Ye=w.useCallback(ie=>{jh.value=ie,Ve(ie)},[]),[vt,$t]=w.useState(!1),ne=w.useRef(null),Se=w.useRef(null),dt=w.useRef(null),we=w.useCallback(()=>{Se.current&&(Se.current.value=""),dt.current&&(dt.current.value=""),Be(ie=>ie+1),qe(ie=>ie+1)},[]),Re=w.useCallback(ie=>{Ye(ie)},[Ye]),Ue=w.useRef(!1);w.useEffect(()=>{Ue.current&&!U&&(Fe([]),we()),Ue.current=U},[U,we]),w.useEffect(()=>{U||R(null)},[U]);const[Et,Ke]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const de=window.innerWidth;Ke(de<640?"phone":de<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{Tt.current=!1},[P]),w.useEffect(()=>{ge.current=kt},[kt]),w.useEffect(()=>{if(!Z){He.current=null;return}He.current===null&&(He.current=ge.current),Ye(F??"")},[F,Z,Ye]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){Ct(null);return}try{const Ee=(await x.getAgent("default")).uiDefaultMessage||"";Ct(Ee||null)}catch(de){console.warn("Failed to fetch default message:",de),Ct(null)}})()},[x.baseUrl]),w.useEffect(()=>{I&&!at&&(g==null||g(I))},[I,at,g]);const wt=async ie=>{const de=ie.trim();if(!de&&$e.length===0)return;const Ee=Z;try{const Me=Z?(ue==null?void 0:ue.checkpointId)??j??void 0:j??void 0,et=Z?(ue==null?void 0:ue.checkpointNs)??G??void 0:G??void 0;await _({text:de||"",attachments:$e},{checkpointId:Me,checkpointNs:et,edit:!!Z,originalMessageId:Z??void 0}),f==null||f(de),Ee&&R(Ee),Ye(""),Ne(null),Fe([]),we(),ce(null),re(""),le(null)}catch(Me){const et=(Me==null?void 0:Me.message)||"Failed to send message";Ne(et),g==null||g(et)}},Le=w.useCallback((ie,de,Ee)=>{c&&(He.current=kt,ce(ie),re(de),Ye(de),Ne(null),le({checkpointId:(Ee==null?void 0:Ee.checkpointId)??null,checkpointNs:(Ee==null?void 0:Ee.checkpointNs)??null}))},[kt,c,Ye]),Xe=w.useCallback(()=>{ce(null),re(""),le(null),Ne(null),Ye(He.current??kt),He.current=null,R(null)},[kt,Ye]),Vt=w.useCallback((ie,de,Ee)=>{Le(ie,de,Ee)},[Le]),ql=w.useCallback(ie=>{let de=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){de=S[pt];break}if(!de)return;const Ee=Array.isArray(de.content)?de.content:[],et=Ee.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ee,null,2)}catch{return String(Ee)}})();et&&_({text:et},{checkpointId:j??void 0,checkpointNs:G??void 0,edit:!0,originalMessageId:de.id})},[S,_,j,G]),Gl=ie=>{const de=Array.from(ie.target.files||[]);Fe(Ee=>[...Ee,...de]),ie.target.value=""},Yl=ie=>{Fe(de=>{const Ee=de.filter((Me,et)=>ie!==et);return Ee.length===0&&we(),Ee})},A=async ie=>{const de=(ie.target.files||[])[0];if(de){Ze(null),xt(null),it(!0);try{await _({attachments:[de]},{checkpointId:j??void 0,checkpointNs:G??void 0});const Ee=`Uploaded ${de.name} - processing through chat stream`;xt(Ee)}catch(Ee){const Me=Ee instanceof Error?Ee.message:"Failed to upload Excel file";console.error("Excel upload failed",Ee),Ze(Me),g==null||g(Me)}finally{it(!1),ie.target.value="",we()}}},ee=async ie=>{if(y){$t(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Me;(Me=ne.current)==null||Me.scrollToLatest()});return}const de=O.find(Me=>Me.checkpointId===ie),Ee=(de==null?void 0:de.checkpointNs)??null;await C(ie,Ee),requestAnimationFrame(()=>{var Me;(Me=ne.current)==null||Me.scrollToTop()})}finally{$t(!1)}}},pe=w.useCallback(async(ie,de,Ee)=>{await ee(Ee?null:ie)},[ee]),ke=`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||""}`,rt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ke,children:[!!I&&!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:I}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>Rt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(fe.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:ne,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:Z,onEdit:Vt,onRegenerate:ql,onCancelEdit:Xe,emptyMessage:Mt??void 0,isNavigatingCheckpoint:vt,activeInterrupt:q,disableInterruptActions:Y,onInterruptActionStart:V,onInterruptActionEnd:L,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:pe,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(fe.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"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||vt)&&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(fe.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:rt,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(fe.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:Xe,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(fe.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:Se,type:"file",multiple:!0,onChange:ie=>Gl(ie),className:"hidden"},Ae),$e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:$e.map((ie,de)=>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(fe.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ie.name}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>Yl(de),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(fe.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:dt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},tt),ze&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),St&&!ze&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:St}),nt&&!ze&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:nt})]})]}),xe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:xe}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(fe.Plus,{size:16})})}),u.jsxs(lo,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(On,{onClick:()=>{var ie;return(ie=Se.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(On,{onClick:()=>{var ie;ze||(ie=dt.current)==null||ie.click()},className:`cursor-pointer ${ze?"opacity-60 pointer-events-none":""}`,children:[u.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(wS,{initialValue:F,editingMessageId:Z,value:kt,onValueChange:Re,placeholder:Z?"Edit your message...":t,isStreaming:U,disabled:X,onSend:wt,onCancelEdit:Xe,onStop:D,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":""} ${xe?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var _h=1,IT=.9,NT=.8,AT=.17,ul=.1,dl=.999,jT=.9999,_T=.99,PT=/[\\\/_+.#"@\[\(\{&]/,RT=/[\\\/_+.#"@\[\(\{&]/g,MT=/[\s-]/,Ph=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?_h:_T;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=_h:PT.test(e.charAt(c-1))?(p*=NT,f=e.slice(o,c-1).match(RT),f&&o>0&&(p*=Math.pow(dl,f.length))):MT.test(e.charAt(c-1))?(p*=IT,v=e.slice(o,c-1).match(Ph),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=AT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=jT)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Rh(e){return e.toLowerCase().replace(Ph," ")}function OT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,Rh(e),Rh(t),0,0,{})}var To='[cmdk-group=""]',pl='[cmdk-group-items=""]',DT='[cmdk-group-heading=""]',Mh='[cmdk-item=""]',Oh=`${Mh}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",LT=(e,t,n)=>OT(e,t,n),Dh=h.createContext(void 0),ko=()=>h.useContext(Dh),Lh=h.createContext(void 0),ml=()=>h.useContext(Lh),$h=h.createContext(void 0),Fh=h.forwardRef((e,t)=>{let n=_r(()=>{var R,M;return{search:"",value:(M=(R=e.value)!=null?R:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=Bh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=At(),S=At(),k=At(),T=h.useRef(null),C=GT();sr(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),sr(()=>{C(6,U)},[]);let E=h.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,M,q)=>{var Y,oe,V,L;if(!Object.is(n.current[R],M)){if(n.current[R]=M,R==="search")K(),$(),C(1,H);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(b))==null||Y.focus()}if(C(7,()=>{var X;n.current.selectedItemId=(X=I())==null?void 0:X.id,E.emit()}),q||C(5,U),((oe=a.current)==null?void 0:oe.value)!==void 0){let X=M??"";(L=(V=a.current).onValueChange)==null||L.call(V,X);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),N=h.useMemo(()=>({value:(R,M,q)=>{var Y;M!==((Y=s.current.get(R))==null?void 0:Y.value)&&(s.current.set(R,{value:M,keywords:q}),n.current.filtered.items.set(R,O(M,q)),C(2,()=>{$(),E.emit()}))},item:(R,M)=>(r.current.add(R),M&&(o.current.has(M)?o.current.get(M).add(R):o.current.set(M,new Set([R]))),C(3,()=>{K(),$(),n.current.value||H(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let q=I();C(4,()=>{K(),(q==null?void 0:q.getAttribute("id"))===R&&H(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:T}),[]);function O(R,M){var q,Y;let oe=(Y=(q=a.current)==null?void 0:q.filter)!=null?Y:LT;return R?oe(R,n.current.search,M):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(Y=>{let oe=o.current.get(Y),V=0;oe.forEach(L=>{let X=R.get(L);V=Math.max(X,V)}),M.push([Y,V])});let q=T.current;W().sort((Y,oe)=>{var V,L;let X=Y.getAttribute("id"),Z=oe.getAttribute("id");return((V=R.get(Z))!=null?V:0)-((L=R.get(X))!=null?L:0)}).forEach(Y=>{let oe=Y.closest(pl);oe?oe.appendChild(Y.parentElement===oe?Y:Y.closest(`${pl} > *`)):q.appendChild(Y.parentElement===q?Y:Y.closest(`${pl} > *`))}),M.sort((Y,oe)=>oe[1]-Y[1]).forEach(Y=>{var oe;let V=(oe=T.current)==null?void 0:oe.querySelector(`${To}[${jr}="${encodeURIComponent(Y[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let R=W().find(q=>q.getAttribute("aria-disabled")!=="true"),M=R==null?void 0:R.getAttribute(jr);E.setState("value",M||void 0)}function K(){var R,M,q,Y;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 V of r.current){let L=(M=(R=s.current.get(V))==null?void 0:R.value)!=null?M:"",X=(Y=(q=s.current.get(V))==null?void 0:q.keywords)!=null?Y:[],Z=O(L,X);n.current.filtered.items.set(V,Z),Z>0&&oe++}for(let[V,L]of o.current)for(let X of L)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=oe}function U(){var R,M,q;let Y=I();Y&&(((R=Y.parentElement)==null?void 0:R.firstChild)===Y&&((q=(M=Y.closest(To))==null?void 0:M.querySelector(DT))==null||q.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function I(){var R;return(R=T.current)==null?void 0:R.querySelector(`${Mh}[aria-selected="true"]`)}function W(){var R;return Array.from(((R=T.current)==null?void 0:R.querySelectorAll(Oh))||[])}function _(R){let M=W()[R];M&&E.setState("value",M.getAttribute(jr))}function D(R){var M;let q=I(),Y=W(),oe=Y.findIndex(L=>L===q),V=Y[oe+R];(M=a.current)!=null&&M.loop&&(V=oe+R<0?Y[Y.length-1]:oe+R===Y.length?Y[0]:Y[oe+R]),V&&E.setState("value",V.getAttribute(jr))}function P(R){let M=I(),q=M==null?void 0:M.closest(To),Y;for(;q&&!Y;)q=R>0?KT(q,To):qT(q,To),Y=q==null?void 0:q.querySelector(Oh);Y?E.setState("value",Y.getAttribute(jr)):D(R)}let j=()=>_(W().length-1),G=R=>{R.preventDefault(),R.metaKey?j():R.altKey?P(1):D(1)},J=R=>{R.preventDefault(),R.metaKey?_(0):R.altKey?P(-1):D(-1)};return h.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var M;(M=y.onKeyDown)==null||M.call(y,R);let q=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||q))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&G(R);break}case"ArrowDown":{G(R);break}case"p":case"k":{x&&R.ctrlKey&&J(R);break}case"ArrowUp":{J(R);break}case"Home":{R.preventDefault(),_(0);break}case"End":{R.preventDefault(),j();break}case"Enter":{R.preventDefault();let Y=I();if(Y){let oe=new Event(hl);Y.dispatchEvent(oe)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:XT},l),qs(e,R=>h.createElement(Lh.Provider,{value:E},h.createElement(Dh.Provider,{value:N},R))))}),$T=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext($h),a=ko(),l=Bh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;sr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=zh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Hn(C=>C.value&&C.value===d.current),f=Hn(C=>c||a.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);h.useEffect(()=>{let C=s.current;if(!(!C||e.disabled))return C.addEventListener(hl,v),()=>C.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var C,E;g(),(E=(C=l.current).onSelect)==null||E.call(C,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...T}=e;return h.createElement(ve.div,{ref:jn(s,t),...T,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)}),FT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=ko(),p=Hn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);sr(()=>d.group(i),[]),zh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(ve.div,{ref:jn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),qs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement($h.Provider,{value:m},f))))}),BT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Hn(i=>!i.search);return!n&&!s?null:h.createElement(ve.div,{ref:jn(o,t),...r,"cmdk-separator":"",role:"separator"})}),zT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Hn(c=>c.search),a=Hn(c=>c.selectedItemId),l=ko();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.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)}})}),HT=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Hn(c=>c.selectedItemId),l=ko();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(ve.div,{ref:jn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},qs(e,c=>h.createElement("div",{ref:jn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),UT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(bo,{"cmdk-overlay":"",className:o}),h.createElement(yo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Fh,{ref:t,...a}))))}),WT=h.forwardRef((e,t)=>Hn(n=>n.filtered.count===0)?h.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),VT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Fh,{List:HT,Item:$T,Input:zT,Group:FT,Separator:BT,Dialog:UT,Empty:WT,Loading:VT});function KT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function qT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Bh(e){let t=h.useRef(e);return sr(()=>{t.current=e}),t}var sr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function zh(e,t,n,r=[]){let o=h.useRef(),s=ko();return sr(()=>{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(jr,a),o.current=a}),o}var GT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return sr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function YT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(YT(t),{ref:t.ref},n(t.props.children)):n(t)}var XT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=Ut.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(fe.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.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})]}));xl.displayName=Ut.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=Ut.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=Ut.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));bl.displayName=Ut.Group.displayName;const JT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));JT.displayName=Ut.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));yl.displayName=Ut.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function ZT(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[Hh,f1]=sn(Cl),[QT,rn]=Hh(Cl),Uh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[S,k]=h.useState(0),[T,C]=h.useState(!1),[E,N]=h.useState(!1),O=Oe(t,H=>l(H)),$=qo(o);return u.jsx(QT,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:$,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Uh.displayName=Cl;var Wh="ScrollAreaViewport",Vh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Wh,n),a=h.useRef(null),l=Oe(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})})]})});Vh.displayName=Wh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(ek,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(tk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Kh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var ek=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(Kh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Js(()=>l("SCROLL_END"),100),[a,l]=ZT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Kh=h.forwardRef((e,t)=>{const n=rn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Js(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Jh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return ak(m,i.current,a,f)}return n==="horizontal"?u.jsx(nk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=Zh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(rk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Zh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),nk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Oe(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Gh,{"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":Xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),em(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Ys(i.paddingLeft),paddingEnd:Ys(i.paddingRight)}})}})}),rk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Oe(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Gh,{"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":Xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),em(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Ys(i.paddingTop),paddingEnd:Ys(i.paddingBottom)}})}})}),[ok,qh]=Hh(Tn),Gh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=rn(Tn,n),[v,g]=h.useState(null),x=Oe(t,O=>g(O)),y=h.useRef(null),b=h.useRef(""),S=f.viewport,k=r.content-r.viewport,T=mt(d),C=mt(l),E=Js(p,10);function N(O){if(y.current){const $=O.clientX-y.current.left,H=O.clientY-y.current.top;c({x:$,y:H})}}return h.useEffect(()=>{const O=$=>{const H=$.target;(v==null?void 0:v.contains(H))&&T($,k)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,v,k,T]),h.useEffect(C,[r,C]),Pr(v,E),Pr(f.content,E),u.jsx(ok,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:C,onThumbPointerDown:mt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(O))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,O=>{const $=O.target;$.hasPointerCapture(O.pointerId)&&$.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Gs="ScrollAreaThumb",Yh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=qh(Gs,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(sk,{ref:t,...r})})}),sk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(Gs,n),i=qh(Gs,n),{onThumbPositionChange:a}=i,l=Oe(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Js(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=lk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.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,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Yh.displayName=Gs;var El="ScrollAreaCorner",Xh=h.forwardRef((e,t)=>{const n=rn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(ik,{...e,ref:t}):null});Xh.displayName=El;var ik=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.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 Ys(e){return e?parseInt(e,10):0}function Jh(e,t){const n=e/t;return isNaN(n)?0:n}function Xs(e){const t=Jh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function ak(e,t,n,r="ltr"){const o=Xs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return Qh([l,c],p)(e)}function Zh(e,t,n="ltr"){const r=Xs(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=Sl(e,l);return Qh([0,i],[0,a])(c)}function Qh(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 em(e,t){return e>0&&e<t}var lk=(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 Js(e,t){const n=mt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Pr(e,t){const n=mt(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 tm=Uh,ck=Vh,uk=Xh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(tm,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(ck,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(nm,{}),u.jsx(uk,{})]}));Il.displayName=tm.displayName;const nm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{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(Yh,{className:"relative flex-1 rounded-full bg-border"})}));nm.displayName=Tl.displayName;const Nl=h.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}));Nl.displayName="Input";const dk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",fk="bg-slate-700 border-slate-600 hover:bg-slate-600",pk="bg-slate-600 border-slate-500";function rm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??pk}`:`${x??fk}`,k=T=>{T.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${dk} ${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:T=>T.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:T=>i(T.target.value),onKeyDown:T=>{T.key==="Enter"?a(e.threadId):T.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(fe.Check,{size:12})}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(fe.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(fe.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(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(fe.MoreHorizontal,{size:12})})}),u.jsxs(lo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(On,{onClick:T=>{T.preventDefault(),c(e.threadId)},children:[u.jsx(fe.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(On,{onClick:T=>{T.preventDefault(),s(e,T)},children:[u.jsx(fe.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(On,{className:"text-red-400 hover:text-red-300",onClick:T=>{T.preventDefault(),d(e.threadId,T)},children:[u.jsx(fe.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 om=25,sm="thread-manager-view",hk=e=>e==="default"||e==="shared",mk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(sm);if(hk(e))return e}catch{}return null};function im({defaultView:e}={}){const[t,n]=w.useState(()=>mk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(sm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const gk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:T,currentThreadId:C,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:O,actions:$,shareInFlight:H,shareStatus:K,clearShareStatus:U}=pr(),{createThread:I,deleteThread:W,renameThread:_,shareThread:D}=$,{loadThread:P}=Yr(),j=i??C,[G,J]=w.useState(Array.isArray(k)?k:[]),R=w.useRef(G.length>0),M=w.useRef(null),q=w.useRef(0),[Y,oe]=w.useState(null),[V,L]=w.useState(""),[X,Z]=w.useState(!1),[ce,F]=w.useState(!1),[re,ue]=w.useState(null),[le,xe]=w.useState(""),Ne=v&&v.length>0?v:gk,$e=im({defaultView:m}),Fe=g??$e,Ae=p??Fe.view,Be=w.useCallback(ne=>{p||Fe.setView(ne),f==null||f(ne)},[p,f,Fe]),tt=Ne.find(ne=>ne.key===Ae)??Ne[0],qe=ne=>{ue(ne),xe(""),F(!0)},ze=()=>{F(!1),ue(null),xe(""),U()},it=w.useCallback(async ne=>{if(!(!re||H)&&ne.id)try{await D(re,ne.id),setTimeout(()=>ze(),600)}catch(Se){console.error("Failed to share thread:",Se)}},[ze,H,re,D]),nt=w.useMemo(()=>{const ne=y??[],Se=le.trim().toLowerCase();return Se?S?ne.filter(dt=>S(dt,Se)):ne.filter(dt=>`${dt.label} ${dt.secondaryLabel??""}`.toLowerCase().includes(Se)):ne},[y,le,S]),Ze=Ae==="shared",St=Ze?T:G,xt=Ze?O:N,at=Ze?"No shared conversations yet":"No conversations yet",Rt=ne=>{const Se=ne.sharedAt?` • ${Ye(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${Se}`},Mt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){R.current=!0,J(ne);return}N||(R.current=!1,J(ne))},[k,N]),w.useEffect(()=>{if(!M.current)return;const ne=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let Se=null,dt=null;return Se=requestAnimationFrame(()=>{dt=requestAnimationFrame(()=>{ne.scrollTop=q.current})}),()=>{Se!==null&&cancelAnimationFrame(Se),dt!==null&&cancelAnimationFrame(dt)}},[G]);const Ct=async ne=>{try{E(ne),await P(ne),a==null||a(ne),l==null||l(ne)}catch(Se){console.error("Failed to select thread:",Se)}},Tt=async()=>{try{Z(!0);const ne=await I();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Z(!1)}},kt=async(ne,Se)=>{if(Se.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const dt=M.current.querySelector("[data-radix-scroll-area-viewport]");dt&&(q.current=dt.scrollTop)}try{await W(ne),d==null||d(ne)}catch(dt){console.error("Failed to delete thread:",dt)}}},Ve=(ne,Se)=>{Se.stopPropagation(),oe(ne.threadId),L(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},ge=async ne=>{if(V.trim())try{await _(ne,V.trim()),oe(null),L("")}catch(Se){console.error("Failed to update title:",Se)}},He=()=>{oe(null),L("")},Ye=ne=>{if(!ne)return"";try{const Se=new Date(ne),we=new Date().getTime()-Se.getTime(),Re=Math.floor(we/(1e3*60*60*24));return Re===0?Se.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Re===1?"Yesterday":Re<7?`${Re} days ago`:Se.toLocaleDateString()}catch{return""}},vt=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,$t=ne=>{const Se=vt(ne);return Se.length<=om?Se:`${Se.slice(0,om)}...`};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(lt,{onClick:Tt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(fe.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(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:tt.label})}),u.jsx(lo,{align:"start",sideOffset:6,className:"w-40",children:Ne.map(ne=>u.jsxs(On,{className:"justify-between text-[12px]",onClick:Se=>{Se.preventDefault(),Be(ne.key)},children:[u.jsx("span",{children:ne.label}),Ae===ne.key&&u.jsx(fe.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Il,{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:xt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):St.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(fe.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})]}):St.slice().sort((ne,Se)=>new Date(Se.updatedAt||Se.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(rm,{thread:ne,isActive:j===ne.threadId,editingThreadId:Y,editingTitle:V,onSelect:Ct,onStartEditing:Ve,onEditingTitleChange:Se=>L(Se),onSaveEditing:ge,onCancelEditing:He,onShare:()=>qe(ne.threadId),onDelete:kt,showEditTitle:r,showDeleteButton:n,formatDate:Ye,getDisplayThreadTitle:$t,secondaryLine:Ze&&Mt(ne)?Rt(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(Ya,{open:ce,onOpenChange:ne=>!ne&&ze(),children:u.jsxs(Ls,{className:"max-w-md p-0",children:[u.jsx($s,{children:u.jsx(Fs,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:le,onValueChange:ne=>xe(ne),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(wl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(ne=>u.jsx(yl,{onSelect:()=>it(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.id))})]})]})]})})]})}function xk({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(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Co,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...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(Al,{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(Co,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...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(Al,{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(Co,{onError:s.onError,enableFileUpload:!0})})]})})}function vk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Co,{})})})}var wk="Label",am=h.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())}}));am.displayName=wk;var lm=am;const bk=Dr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),cm=h.forwardRef(({className:e,...t},n)=>u.jsx(lm,{ref:n,className:te(bk(),e),...t}));cm.displayName=lm.displayName;function um(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var dm=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"}),yk="VisuallyHidden",Zs=h.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...dm,...e.style}}));Zs.displayName=yk;var Sk=Zs,Ck=[" ","Enter","ArrowUp","ArrowDown"],Tk=[" ","Enter"],ir="Select",[Qs,ei,kk]=Ko(ir),[Rr,p1]=sn(ir,[kk,yr]),ti=yr(),[Ek,Un]=Rr(ir),[Ik,Nk]=Rr(ir),fm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ti(t),[x,y]=h.useState(null),[b,S]=h.useState(null),[k,T]=h.useState(!1),C=qo(c),[E,N]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[O,$]=_n({prop:i,defaultProp:a,onChange:l,caller:ir}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[U,I]=h.useState(new Set),W=Array.from(U).map(_=>_.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(Ek,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:At(),value:O,onValueChange:$,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Qs.Provider,{scope:t,children:u.jsx(Ik,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(_=>{I(D=>new Set(D).add(_))},[]),onNativeOptionRemove:h.useCallback(_=>{I(D=>{const P=new Set(D);return P.delete(_),P})},[]),children:n})}),K?u.jsxs(Dm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:O,onChange:_=>$(_.target.value),disabled:m,form:v,children:[O===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},W):null]})})};fm.displayName=ir;var pm="SelectTrigger",hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ti(n),i=Un(pm,n),a=i.disabled||r,l=Oe(t,i.onTriggerChange),c=ei(n),d=h.useRef("touch"),[p,m,f]=$m(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Fm(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(ta,{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":Lm(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=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Ck.includes(g.key)&&(v(),g.preventDefault())})})})});hm.displayName=pm;var mm="SelectValue",gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(mm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Oe(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:p,style:{pointerEvents:"none"},children:Lm(l.value)?u.jsx(u.Fragment,{children:i}):s})});gm.displayName=mm;var Ak="SelectIcon",xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});xm.displayName=Ak;var jk="SelectPortal",vm=e=>u.jsx(to,{asChild:!0,...e});vm.displayName=jk;var ar="SelectContent",wm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(bm,{scope:e.__scopeSelect,children:u.jsx(Qs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(ym,{...e,ref:t})});wm.displayName=ar;var fn=10,[bm,Wn]=Rr(ar),_k="SelectContentImpl",Pk=qt.createSlot("SelectContent.RemoveScroll"),ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Un(ar,n),[S,k]=h.useState(null),[T,C]=h.useState(null),E=Oe(t,V=>k(V)),[N,O]=h.useState(null),[$,H]=h.useState(null),K=ei(n),[U,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const _=h.useCallback(V=>{const[L,...X]=K().map(F=>F.ref.current),[Z]=X.slice(-1),ce=document.activeElement;for(const F of V)if(F===ce||(F==null||F.scrollIntoView({block:"nearest"}),F===L&&T&&(T.scrollTop=0),F===Z&&T&&(T.scrollTop=T.scrollHeight),F==null||F.focus(),document.activeElement!==ce))return},[K,T]),D=h.useCallback(()=>_([N,S]),[_,N,S]);h.useEffect(()=>{U&&D()},[U,D]);const{onOpenChange:P,triggerPointerDownPosRef:j}=b;h.useEffect(()=>{if(S){let V={x:0,y:0};const L=Z=>{var ce,F;V={x:Math.abs(Math.round(Z.pageX)-(((ce=j.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((F=j.current)==null?void 0:F.y)??0))}},X=Z=>{V.x<=10&&V.y<=10?Z.preventDefault():S.contains(Z.target)||P(!1),document.removeEventListener("pointermove",L),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,j]),h.useEffect(()=>{const V=()=>P(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[P]);const[G,J]=$m(V=>{const L=K().filter(ce=>!ce.disabled),X=L.find(ce=>ce.ref.current===document.activeElement),Z=Fm(L,V,X);Z&&setTimeout(()=>Z.ref.current.focus())}),R=h.useCallback((V,L,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===L||Z)&&(O(V),Z&&(W.current=!0))},[b.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),q=h.useCallback((V,L,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===L||Z)&&H(V)},[b.value]),Y=r==="popper"?jl:Sm,oe=Y===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(bm,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:R,selectedItem:N,onItemLeave:M,itemTextRefCallback:q,focusSelectedItem:D,selectedItemText:$,position:r,isPositioned:U,searchRef:G,children:u.jsx(ps,{as:Pk,allowPinchZoom:!0,children:u.jsx(Go,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ae(o,V=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...y,...oe,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,V=>{const L=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!L&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Z=K().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ce=V.target,F=Z.indexOf(ce);Z=Z.slice(F+1)}setTimeout(()=>_(Z)),V.preventDefault()}})})})})})})});ym.displayName=_k;var Rk="SelectItemAlignedPosition",Sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Oe(t,E=>d(E)),m=ei(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const ce=$.left-N.left,F=O.left-ce,re=E.left-F,ue=E.width+re,le=Math.max(ue,N.width),xe=window.innerWidth-fn,Ne=Sl(F,[fn,Math.max(fn,xe-le)]);a.style.minWidth=ue+"px",a.style.left=Ne+"px"}else{const ce=N.right-$.right,F=window.innerWidth-O.right-ce,re=window.innerWidth-E.right-F,ue=E.width+re,le=Math.max(ue,N.width),xe=window.innerWidth-fn,Ne=Sl(F,[fn,Math.max(fn,xe-le)]);a.style.minWidth=ue+"px",a.style.right=Ne+"px"}const H=m(),K=window.innerHeight-fn*2,U=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),_=parseInt(I.paddingTop,10),D=parseInt(I.borderBottomWidth,10),P=parseInt(I.paddingBottom,10),j=W+_+U+P+D,G=Math.min(x.offsetHeight*5,j),J=window.getComputedStyle(g),R=parseInt(J.paddingTop,10),M=parseInt(J.paddingBottom,10),q=E.top+E.height/2-fn,Y=K-q,oe=x.offsetHeight/2,V=x.offsetTop+oe,L=W+_+V,X=j-L;if(L<=q){const ce=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(Y,oe+(ce?M:0)+F+D),ue=L+re;a.style.height=ue+"px"}else{const ce=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(q,W+g.offsetTop+(ce?R:0)+oe)+X;a.style.height=re+"px",g.scrollTop=L-q+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"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,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=h.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Ok,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Sm.displayName=Rk;var Mk="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ti(n);return u.jsx(na,{...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)"}})});jl.displayName=Mk;var[Ok,_l]=Rr(ar,{}),Pl="SelectViewport",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Pl,n),i=_l(Pl,n),a=Oe(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Qs.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:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Cm.displayName=Pl;var Tm="SelectGroup",[Dk,Lk]=Rr(Tm),$k=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(Dk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});$k.displayName=Tm;var km="SelectLabel",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Lk(km,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Em.displayName=km;var ni="SelectItem",[Fk,Im]=Rr(ni),Nm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ni,n),l=Wn(ni,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=Oe(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=At(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Fk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Qs.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===" "||(Tk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Nm.displayName=ni;var Eo="SelectItemText",Am=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(Eo,n),a=Wn(Eo,n),l=Im(Eo,n),c=Nk(Eo,n),[d,p]=h.useState(null),m=Oe(t,y=>p(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=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});Am.displayName=Eo;var jm="SelectItemIndicator",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Im(jm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});_m.displayName=jm;var Rl="SelectScrollUpButton",Pm=h.forwardRef((e,t)=>{const n=Wn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=Oe(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(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Pm.displayName=Rl;var Ml="SelectScrollDownButton",Rm=h.forwardRef((e,t)=>{const n=Wn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=Oe(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(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Rm.displayName=Ml;var Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=ei(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(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()})})}),Bk="SelectSeparator",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});Om.displayName=Bk;var Ol="SelectArrow",zk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ti(n),s=Un(Ol,n),i=Wn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});zk.displayName=Ol;var Hk="SelectBubbleInput",Dm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Oe(r,o),i=um(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(ve.select,{...n,style:{...dm,...n.style},ref:s,defaultValue:t})});Dm.displayName=Hk;function Lm(e){return e===""||e===void 0}function $m(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Fm(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=Uk(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 Uk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Wk=fm,Bm=hm,Vk=gm,Kk=xm,qk=vm,zm=wm,Gk=Cm,Hm=Em,Um=Nm,Yk=Am,Xk=_m,Wm=Pm,Vm=Rm,Km=Om;const Jk=Wk,Zk=Vk,qm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bm,{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(Kk,{asChild:!0,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qm.displayName=Bm.displayName;const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));Gm.displayName=Wm.displayName;const Ym=h.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4"})}));Ym.displayName=Vm.displayName;const Xm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(qk,{children:u.jsxs(zm,{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(Gm,{}),u.jsx(Gk,{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(Ym,{})]})}));Xm.displayName=zm.displayName;const Qk=h.forwardRef(({className:e,...t},n)=>u.jsx(Hm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Qk.displayName=Hm.displayName;const Jm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{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(Xk,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),u.jsx(Yk,{children:t})]}));Jm.displayName=Um.displayName;const eE=h.forwardRef(({className:e,...t},n)=>u.jsx(Km,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));eE.displayName=Km.displayName;var tE="Separator",Zm="horizontal",nE=["horizontal","vertical"],Qm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Zm,...o}=e,s=rE(r)?r:Zm,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})});Qm.displayName=tE;function rE(e){return nE.includes(e)}var eg=Qm;const tg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(eg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));tg.displayName=eg.displayName;var ri="Switch",[oE,h1]=sn(ri),[sE,iE]=oE(ri),ng=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=Oe(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=_n({prop:o,defaultProp:s??!1,onChange:c,caller:ri});return u.jsxs(sE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":ig(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(sg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ng.displayName=ri;var rg="SwitchThumb",og=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=iE(rg,n);return u.jsx(ve.span,{"data-state":ig(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});og.displayName=rg;var aE="SwitchBubbleInput",sg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Oe(i,s),l=um(n),c=md(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});sg.displayName=aE;function ig(e){return e?"checked":"unchecked"}var ag=ng,lE=og;const lg=h.forwardRef(({className:e,...t},n)=>u.jsx(ag,{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(lE,{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")})}));lg.displayName=ag.displayName;const cE=qa,uE=eT,dE=Ga,cg=h.forwardRef(({className:e,...t},n)=>u.jsx(bo,{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}));cg.displayName=bo.displayName;const fE=Dr.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"}}),ug=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(dE,{children:[u.jsx(cg,{}),u.jsxs(yo,{ref:o,className:te(fE({side:e}),t),...r,children:[n,u.jsxs(th,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ug.displayName=yo.displayName;const dg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});dg.displayName="SheetHeader";const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));fg.displayName=rr.displayName;const pg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ds,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));pg.displayName=Ds.displayName;var[oi,m1]=sn("Tooltip",[yr]),si=yr(),hg="TooltipProvider",pE=700,Dl="tooltip.open",[hE,Ll]=oi(hg),mg=e=>{const{__scopeTooltip:t,delayDuration:n=pE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(hE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};mg.displayName=hg;var Io="Tooltip",[mE,ii]=oi(Io),gg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Io,e.__scopeTooltip),c=si(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=_n({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Io}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(mE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?C():k()},[l.isOpenDelayedRef,C,k]),onTriggerLeave:h.useCallback(()=>{v?T():(window.clearTimeout(f.current),f.current=0)},[T,v]),onOpen:k,onClose:T,disableHoverableContent:v,children:n})})};gg.displayName=Io;var $l="TooltipTrigger",xg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ii($l,n),s=Ll($l,n),i=si(n),a=h.useRef(null),l=Oe(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{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",p,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});xg.displayName=$l;var gE="TooltipPortal",[g1,xE]=oi(gE,{forceMount:void 0}),Mr="TooltipContent",vg=h.forwardRef((e,t)=>{const n=xE(Mr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ii(Mr,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(wg,{side:o,...s,ref:t}):u.jsx(vE,{side:o,...s,ref:t})})}),vE=h.forwardRef((e,t)=>{const n=ii(Mr,e.__scopeTooltip),r=Ll(Mr,e.__scopeTooltip),o=h.useRef(null),s=Oe(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=CE(y,x.getBoundingClientRect()),S=TE(y,b),k=kE(g.getBoundingClientRect()),T=IE([...S,...k]);a(T),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!EE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(wg,{...e,ref:s})}),[wE,bE]=oi(Io,{isInside:!1}),yE=qt.createSlottable("TooltipContent"),wg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ii(Mr,n),c=si(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"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(yE,{children:r}),u.jsx(wE,{scope:n,isInside:!0,children:u.jsx(Sk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});vg.displayName=Mr;var bg="TooltipArrow",SE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si(n);return bE(bg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});SE.displayName=bg;function CE(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 TE(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 kE(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 EE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function IE(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),NE(t)}function NE(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 AE=mg,jE=gg,_E=xg,yg=vg;const PE=AE,RE=jE,ME=_E,Sg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(yg,{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}));Sg.displayName=yg.displayName;var Fl="ToastProvider",[Bl,OE,DE]=Ko("Toast"),[Cg,x1]=sn("Toast",[DE]),[LE,ai]=Cg(Fl),Tg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(LE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Tg.displayName=Fl;var kg="ToastViewport",$E=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",Eg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=$E,label:o="Notifications ({hotkey})",...s}=e,i=ai(kg,n),a=OE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Oe(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const C=new CustomEvent(zl);y.dispatchEvent(C),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const C=new CustomEvent(Hl);y.dispatchEvent(C),i.isClosePausedRef.current=!1}},k=C=>{!x.contains(C.relatedTarget)&&S()},T=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",T),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",T),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,T=[k,...JE(k)];return x==="forwards"?T:T.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var T,C,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,O=b.shiftKey;if(b.target===x&&O){(T=c.current)==null||T.focus();return}const K=g({tabbingDirection:O?"backwards":"forwards"}),U=K.findIndex(I=>I===N);Vl(K.slice(U+1))?b.preventDefault():O?(C=c.current)==null||C.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Nw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});Eg.displayName=kg;var Ig="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ai(Ig,n);return u.jsx(Zs,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=Ig;var No="Toast",FE="toast.swipeStart",BE="toast.swipeMove",zE="toast.swipeCancel",HE="toast.swipeEnd",Ng=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=_n({prop:r,defaultProp:o??!0,onChange:s,caller:No});return u.jsx(zt,{present:n||a,children:u.jsx(VE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel: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:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ng.displayName=No;var[UE,WE]=Cg(No,{onClose(){}}),VE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ai(No,n),[x,y]=h.useState(null),b=Oe(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),T=o||g.duration,C=h.useRef(0),E=h.useRef(T),N=h.useRef(0),{onToastAdd:O,onToastRemove:$}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(N.current),C.current=new Date().getTime(),N.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},_=()=>{const D=new Date().getTime()-C.current;E.current=E.current-D,window.clearTimeout(N.current),l==null||l()};return I.addEventListener(zl,_),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,_),I.removeEventListener(Hl,W)}}},[g.viewport,T,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(T)},[s,T,g.isClosePausedRef,K]),h.useEffect(()=>(O(),()=>$()),[O,$]);const U=h.useMemo(()=>x?Og(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(KE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(UE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(Iw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),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,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ae(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ae(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,_=I.clientY-S.current.y,D=!!k.current,P=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=P?j(0,W):0,J=P?0:j(0,_),R=I.pointerType==="touch"?10:2,M={x:G,y:J},q={originalEvent:I,delta:M};D?(k.current=M,li(BE,p,q,{discrete:!1})):Dg(M,g.swipeDirection,R)?(k.current=M,li(FE,d,q,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>R||Math.abs(_)>R)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,I=>{const W=k.current,_=I.target;if(_.hasPointerCapture(I.pointerId)&&_.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const D=I.currentTarget,P={originalEvent:I,delta:W};Dg(W,g.swipeDirection,g.swipeThreshold)?li(HE,f,P,{discrete:!0}):li(zE,m,P,{discrete:!0}),D.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),KE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ai(No,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return YE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(to,{asChild:!0,children:u.jsx(Zs,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},qE="ToastTitle",Ag=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Ag.displayName=qE;var GE="ToastDescription",jg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});jg.displayName=GE;var _g="ToastAction",Pg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Mg,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${_g}\`. Expected non-empty \`string\`.`),null)});Pg.displayName=_g;var Rg="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=WE(Rg,n);return u.jsx(Mg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Wl.displayName=Rg;var Mg=h.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 Og(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),XE(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(...Og(r))}}),t}function li(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?Oi(o,s):o.dispatchEvent(s)}var Dg=(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 YE(e=()=>{}){const t=mt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function XE(e){return e.nodeType===e.ELEMENT_NODE}function JE(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var ZE=Tg,Lg=Eg,$g=Ng,Fg=Ag,Bg=jg,zg=Pg,Hg=Wl;const QE=ZE,Ug=h.forwardRef(({className:e,...t},n)=>u.jsx(Lg,{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}));Ug.displayName=Lg.displayName;const eI=Dr.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"}}),Wg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx($g,{ref:r,className:te(eI({variant:t}),e),...n}));Wg.displayName=$g.displayName;const tI=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{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}));tI.displayName=zg.displayName;const Vg=h.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{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(fe.X,{className:"h-4 w-4"})}));Vg.displayName=Hg.displayName;const Kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{ref:n,className:te("text-sm font-semibold",e),...t}));Kg.displayName=Fg.displayName;const qg=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("text-sm opacity-90",e),...t}));qg.displayName=Bg.displayName;function nI(){const{toasts:e}=Za();return u.jsxs(QE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Wg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Kg,{children:n}),r&&u.jsx(qg,{children:r})]}),o,u.jsx(Vg,{})]},t)}),u.jsx(Ug,{})]})}var rI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},oI=h.createContext(void 0),sI={setTheme:e=>{},themes:[]},iI=()=>{var e;return(e=h.useContext(oI))!=null?e:sI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${rI.toString()})(${d})`}})});var aI=e=>{switch(e){case"success":return uI;case"info":return fI;case"warning":return dI;case"error":return pI;default:return null}},lI=Array(12).fill(0),cI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},lI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),uI=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"})),dI=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"})),fI=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"})),pI=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"})),hI=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"})),mI=()=>{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},Kl=1,gI=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:Kl++,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(vI(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)||Kl++;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}},Wt=new gI,xI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Wt.addToast({title:e,...t,id:n}),n},vI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",wI=xI,bI=()=>Wt.toasts,yI=()=>Wt.getActiveToasts();Object.assign(wI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:bI,getToasts:yI});function SI(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))}SI(`: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 ci(e){return e.label!==void 0}var CI=3,TI="32px",kI="16px",Gg=4e3,EI=356,II=14,NI=20,AI=200;function pn(...e){return e.filter(Boolean).join(" ")}function jI(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,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:S,toasts:k,expanded:T,removeToast:C,defaultRichColors:E,closeButton:N,style:O,cancelButtonStyle:$,actionButtonStyle:H,className:K="",descriptionClassName:U="",duration:I,position:W,gap:_,loadingIcon:D,expandByDefault:P,classNames:j,icons:G,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:R}=e,[M,q]=w.useState(null),[Y,oe]=w.useState(null),[V,L]=w.useState(!1),[X,Z]=w.useState(!1),[ce,F]=w.useState(!1),[re,ue]=w.useState(!1),[le,xe]=w.useState(!1),[Ne,$e]=w.useState(0),[Fe,Ae]=w.useState(0),Be=w.useRef(f.duration||I||Gg),tt=w.useRef(null),qe=w.useRef(null),ze=S===0,it=S+1<=y,nt=f.type,Ze=f.dismissible!==!1,St=f.className||"",xt=f.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(we=>we.toastId===f.id)||0,[b,f.id]),Rt=w.useMemo(()=>{var we;return(we=f.closeButton)!=null?we:N},[f.closeButton,N]),Mt=w.useMemo(()=>f.duration||I||Gg,[f.duration,I]),Ct=w.useRef(0),Tt=w.useRef(0),kt=w.useRef(0),Ve=w.useRef(null),[ge,He]=W.split("-"),Ye=w.useMemo(()=>b.reduce((we,Re,Ue)=>Ue>=at?we:we+Re.height,0),[b,at]),vt=mI(),$t=f.invert||m,ne=nt==="loading";Tt.current=w.useMemo(()=>at*_+Ye,[at,Ye]),w.useEffect(()=>{Be.current=Mt},[Mt]),w.useEffect(()=>{L(!0)},[]),w.useEffect(()=>{let we=qe.current;if(we){let Re=we.getBoundingClientRect().height;return Ae(Re),x(Ue=>[{toastId:f.id,height:Re,position:f.position},...Ue]),()=>x(Ue=>Ue.filter(Et=>Et.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!V)return;let we=qe.current,Re=we.style.height;we.style.height="auto";let Ue=we.getBoundingClientRect().height;we.style.height=Re,Ae(Ue),x(Et=>Et.find(Ke=>Ke.toastId===f.id)?Et.map(Ke=>Ke.toastId===f.id?{...Ke,height:Ue}:Ke):[{toastId:f.id,height:Ue,position:f.position},...Et])},[V,f.title,f.description,x,f.id]);let Se=w.useCallback(()=>{Z(!0),$e(Tt.current),x(we=>we.filter(Re=>Re.toastId!==f.id)),setTimeout(()=>{C(f)},AI)},[f,C,x,Tt]);w.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let we;return T||g||R&&vt?(()=>{if(kt.current<Ct.current){let Re=new Date().getTime()-Ct.current;Be.current=Be.current-Re}kt.current=new Date().getTime()})():Be.current!==1/0&&(Ct.current=new Date().getTime(),we=setTimeout(()=>{var Re;(Re=f.onAutoClose)==null||Re.call(f,f),Se()},Be.current)),()=>clearTimeout(we)},[T,g,f,nt,R,vt,Se]),w.useEffect(()=>{f.delete&&Se()},[Se,f.delete]);function dt(){var we,Re,Ue;return G!=null&&G.loading?w.createElement("div",{className:pn(j==null?void 0:j.loader,(we=f==null?void 0:f.classNames)==null?void 0:we.loader,"sonner-loader"),"data-visible":nt==="loading"},G.loading):D?w.createElement("div",{className:pn(j==null?void 0:j.loader,(Re=f==null?void 0:f.classNames)==null?void 0:Re.loader,"sonner-loader"),"data-visible":nt==="loading"},D):w.createElement(cI,{className:pn(j==null?void 0:j.loader,(Ue=f==null?void 0:f.classNames)==null?void 0:Ue.loader),visible:nt==="loading"})}return w.createElement("li",{tabIndex:0,ref:qe,className:pn(K,St,j==null?void 0:j.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,j==null?void 0:j.default,j==null?void 0:j[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":le,"data-removed":X,"data-visible":it,"data-y-position":ge,"data-x-position":He,"data-index":S,"data-front":ze,"data-swiping":ce,"data-dismissible":Ze,"data-type":nt,"data-invert":$t,"data-swipe-out":re,"data-swipe-direction":Y,"data-expanded":!!(T||P&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ne:Tt.current}px`,"--initial-height":P?"auto":`${Fe}px`,...O,...f.style},onDragEnd:()=>{F(!1),q(null),Ve.current=null},onPointerDown:we=>{ne||!Ze||(tt.current=new Date,$e(Tt.current),we.target.setPointerCapture(we.pointerId),we.target.tagName!=="BUTTON"&&(F(!0),Ve.current={x:we.clientX,y:we.clientY}))},onPointerUp:()=>{var we,Re,Ue,Et;if(re||!Ze)return;Ve.current=null;let Ke=Number(((we=qe.current)==null?void 0:we.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),wt=Number(((Re=qe.current)==null?void 0:Re.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Ue=tt.current)==null?void 0:Ue.getTime()),Xe=M==="x"?Ke:wt,Vt=Math.abs(Xe)/Le;if(Math.abs(Xe)>=NI||Vt>.11){$e(Tt.current),(Et=f.onDismiss)==null||Et.call(f,f),oe(M==="x"?Ke>0?"right":"left":wt>0?"down":"up"),Se(),ue(!0),xe(!1);return}F(!1),q(null)},onPointerMove:we=>{var Re,Ue,Et,Ke;if(!Ve.current||!Ze||((Re=window.getSelection())==null?void 0:Re.toString().length)>0)return;let wt=we.clientY-Ve.current.y,Le=we.clientX-Ve.current.x,Xe=(Ue=e.swipeDirections)!=null?Ue:jI(W);!M&&(Math.abs(Le)>1||Math.abs(wt)>1)&&q(Math.abs(Le)>Math.abs(wt)?"x":"y");let Vt={x:0,y:0};M==="y"?(Xe.includes("top")||Xe.includes("bottom"))&&(Xe.includes("top")&&wt<0||Xe.includes("bottom")&&wt>0)&&(Vt.y=wt):M==="x"&&(Xe.includes("left")||Xe.includes("right"))&&(Xe.includes("left")&&Le<0||Xe.includes("right")&&Le>0)&&(Vt.x=Le),(Math.abs(Vt.x)>0||Math.abs(Vt.y)>0)&&xe(!0),(Et=qe.current)==null||Et.style.setProperty("--swipe-amount-x",`${Vt.x}px`),(Ke=qe.current)==null||Ke.style.setProperty("--swipe-amount-y",`${Vt.y}px`)}},Rt&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Ze?()=>{}:()=>{var we;Se(),(we=f.onDismiss)==null||we.call(f,f)},className:pn(j==null?void 0:j.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:hI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,nt||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:pn(j==null?void 0:j.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||dt():null,f.type!=="loading"?f.icon||(G==null?void 0:G[nt])||aI(nt):null):null,w.createElement("div",{"data-content":"",className:pn(j==null?void 0:j.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:pn(j==null?void 0:j.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:pn(U,xt,j==null?void 0:j.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&&ci(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:we=>{var Re,Ue;ci(f.cancel)&&Ze&&((Ue=(Re=f.cancel).onClick)==null||Ue.call(Re,we),Se())},className:pn(j==null?void 0:j.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&&ci(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:we=>{var Re,Ue;ci(f.action)&&((Ue=(Re=f.action).onClick)==null||Ue.call(Re,we),!we.defaultPrevented&&Se())},className:pn(j==null?void 0:j.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Yg(){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 PI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?kI:TI;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 RI=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:p,duration:m,style:f,visibleToasts:v=CI,toastOptions:g,dir:x=Yg(),gap:y=II,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:T}=e,[C,E]=w.useState([]),N=w.useMemo(()=>Array.from(new Set([r].concat(C.filter(R=>R.position).map(R=>R.position)))),[C,r]),[O,$]=w.useState([]),[H,K]=w.useState(!1),[U,I]=w.useState(!1),[W,_]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=w.useRef(null),G=w.useRef(!1),J=w.useCallback(R=>{E(M=>{var q;return(q=M.find(Y=>Y.id===R.id))!=null&&q.delete||Wt.dismiss(R.id),M.filter(({id:Y})=>Y!==R.id)})},[]);return w.useEffect(()=>Wt.subscribe(R=>{if(R.dismiss){E(M=>M.map(q=>q.id===R.id?{...q,delete:!0}:q));return}setTimeout(()=>{Ao.flushSync(()=>{E(M=>{let q=M.findIndex(Y=>Y.id===R.id);return q!==-1?[...M.slice(0,q),{...M[q],...R},...M.slice(q+1)]:[R,...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 R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:M})=>{_(M?"dark":"light")})}catch{R.addListener(({matches:q})=>{try{_(q?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),w.useEffect(()=>{C.length<=1&&K(!1)},[C]),w.useEffect(()=>{let R=M=>{var q,Y;o.every(oe=>M[oe]||M.code===oe)&&(K(!0),(q=D.current)==null||q.focus()),M.code==="Escape"&&(document.activeElement===D.current||(Y=D.current)!=null&&Y.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[o]),w.useEffect(()=>{if(D.current)return()=>{j.current&&(j.current.focus({preventScroll:!0}),j.current=null,G.current=!1)}},[D.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((R,M)=>{var q;let[Y,oe]=R.split("-");return C.length?w.createElement("ol",{key:R,dir:x==="auto"?Yg():x,tabIndex:-1,ref:D,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":Y,"data-lifted":H&&C.length>1&&!s,"data-x-position":oe,style:{"--front-toast-height":`${((q=O[0])==null?void 0:q.height)||0}px`,"--width":`${EI}px`,"--gap":`${y}px`,...f,...PI(l,c)},onBlur:V=>{G.current&&!V.currentTarget.contains(V.relatedTarget)&&(G.current=!1,j.current&&(j.current.focus({preventScroll:!0}),j.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||G.current||(G.current=!0,j.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{U||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},C.filter(V=>!V.position&&M===0||V.position===R).map((V,L)=>{var X,Z;return w.createElement(_I,{key:V.id,icons:S,index:L,toast:V,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:U,position:R,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:C.filter(ce=>ce.position==V.position),heights:O.filter(ce=>ce.position==V.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:H,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const MI=({...e})=>{const{theme:t="system"}=iI();return u.jsx(RI,{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=Pv,B.ApiClient=_v,B.ApiProvider=tu,B.ArtifactRenderer=bh,B.Badge=$p,B.Button=lt,B.Card=tl,B.CardContent=sl,B.CardDescription=ol,B.CardHeader=nl,B.CardTitle=rl,B.ChatApi=Uo,B.ChatApp=xk,B.ChatInput=Ff,B.ChatInterface=Co,B.ChatProviders=Xr,B.Command=gl,B.CommandEmpty=wl,B.CommandGroup=bl,B.CommandInput=xl,B.CommandItem=yl,B.CommandList=vl,B.DEFAULT_TIMEOUT_MS=Yc,B.Dialog=Ya,B.DialogContent=Ls,B.DialogHeader=$s,B.DialogTitle=Fs,B.DropdownMenu=ws,B.DropdownMenuContent=lo,B.DropdownMenuItem=On,B.DropdownMenuTrigger=bs,B.FileViewerModal=oh,B.HISTORY_TIMEOUT_MS=Xc,B.Input=Nl,B.InterruptPartRenderer=Sh,B.Label=cm,B.MarkdownContent=Ar,B.MessageBody=Ih,B.MessageComponent=Ks,B.MessageList=cl,B.MessageRow=ll,B.PlotArtifact=vh,B.ResearchTaskArtifact=wh,B.SETTINGS_STORAGE_KEY=Mi,B.ScrollArea=Il,B.Select=Jk,B.SelectContent=Xm,B.SelectItem=Jm,B.SelectTrigger=qm,B.SelectValue=Zk,B.Separator=tg,B.Sheet=cE,B.SheetContent=ug,B.SheetDescription=pg,B.SheetHeader=dg,B.SheetTitle=fg,B.SheetTrigger=uE,B.SimpleChat=vk,B.SimpleJsonView=il,B.Sonner=MI,B.StreamProgress=Ch,B.Switch=lg,B.Textarea=ba,B.ThinkingIndicator=kh,B.ThreadListItem=rm,B.ThreadManager=Al,B.ThreadStateProvider=Su,B.ThreadsProvider=au,B.TimelineColumn=lx,B.Toaster=nI,B.ToolComponent=Th,B.Tooltip=RE,B.TooltipContent=Sg,B.TooltipProvider=PE,B.TooltipTrigger=ME,B.UserTextContent=Eh,B.applySettings=dw,B.buildCheckpointIndex=Ql,B.buildCheckpointPreviewMap=tx,B.chatApiClient=An,B.del=ki,B.downloadFileById=Zc,B.extractConfigFields=di,B.fileToBase64=nu,B.get=Yt,B.getChatToken=qc,B.getCheckpointForMessage=nx,B.getCurrentSettings=uw,B.getDefaultApiConfig=ju,B.getDefaultChatSettings=_u,B.getFileContent=Ii,B.getFileInfo=Mv,B.getMessageAttemptInfo=ec,B.getMessageDomKey=al,B.getPreviewForMessage=ui,B.httpClient=Gt,B.hydrateHistorySnapshots=Nn,B.isEnvelope=ou,B.listFiles=Qc,B.loadStoredSettings=Pu,B.onChatTokenChanged=Gc,B.post=Ho,B.processAttachments=ru,B.put=Jc,B.readNumber=nc,B.readString=Vn,B.resolveChatBaseUrl=mn,B.saveSettings=Ru,B.setChatToken=zo,B.toPlainObject=cr,B.unwrap=Ot,B.useApi=Vr,B.useCheckpointIndex=tc,B.useFilePreview=Nh,B.useHasChatSession=aw,B.useParsedMessageContent=Ah,B.useShallowStableValue=Eu,B.useStream=Ri,B.useStreamingHook=Ri,B.useThreadHistoryState=vu,B.useThreadManagerViewState=im,B.useThreadState=Yr,B.useThreadStateUpdater=yu,B.useThreads=pr,B.useThreadsState=su,B.viewFileById=Rv,Object.defineProperty(B,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=dh(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=dh(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 gh{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 xh{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 Un{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new el,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new gh,this.slugger=new xh}static parse(t,n){return new Un(n).parse(t)}static parseInline(t,n){return new Un(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,b,S,k,T,C;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]&&(C=this.options.extensions.renderers[f.type].call({parser:this},f),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=C||"";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,uh(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)b=f.items[s],S=b.checked,k=b.task,y="",b.task&&(T=this.renderer.checkbox(S),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+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=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):y+=T),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 Vs{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}Jg(Vs,"passThroughHooks",new Set(["preprocess","postprocess"]));function NT(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>"+Pt(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 vh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=NT(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(kT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(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 vh(Hn.lex,Un.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},fT(ye.defaults),ye},ye.getDefaults=ih,ye.defaults=sr,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 el;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 Qa;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 Vs;for(const s in n.hooks){const i=o[s];Vs.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=vh(Hn.lexInline,Un.parseInline),ye.Parser=Un,ye.parser=Un.parse,ye.Renderer=el,ye.TextRenderer=gh,ye.Lexer=Hn,ye.lexer=Hn.lex,ye.Tokenizer=Qa,ye.Slugger=xh,ye.Hooks=Vs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Un.parse,Hn.lex;function Ar({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{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 wh({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 bh({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(fe.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(fe.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(fe.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(fe.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(fe.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(fe.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(Ar,{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(fe.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 yh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>qv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(bh,{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(wh,{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 tl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));tl.displayName="Card";const nl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));nl.displayName="CardHeader";const rl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));rl.displayName="CardTitle";const ol=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ol.displayName="CardDescription";const sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));sl.displayName="CardContent";const Sh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));Sh.displayName="CardFooter";function Ch({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=hr(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(tl,{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(nl,{className:"pb-3",children:[u.jsx(rl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ol,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(sl,{className:"pt-0 pb-3",children:a}),u.jsx(Sh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(lt,{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(lt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const AT="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 il({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:AT,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:hr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)})}function Th({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(fe.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 kh({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx(il,{data:c});const d=typeof c=="string"?c:(()=>{try{return hr(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}=Bv(l);return d?u.jsx(Ar,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.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=Kr(l),d=qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Th,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Eh({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 Ih({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(Ar,{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(lt,{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(fe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(fe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Nh({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:T,setIsUserExpanded:C,isCompactLayout:E,activeInterruptId:N,activeInterruptValue:O,iconForeground:$}){const H=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=w.useCallback(({part:I,i:W})=>{if(I.type==="text"){const _=I.text??"",D=_.trim(),P=Ni(D);return P&&b!=="tool"?u.jsx(il,{data:P},W):b==="user"&&S&&D.length>k?u.jsx(Ih,{text:D,expanded:T,onExpandedChange:C,previewLength:k,isCompact:E},W):u.jsx(Ar,{content:_,allowHtml:!1},W)}if(I.type==="image_url"){const _=I;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(I.type==="file"){const _=I,D=_.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(fe.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[D,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const _=I,D=Vo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id)),P=!!(N&&D&&D===N),j=P?O??(_==null?void 0:_.value):_==null?void 0:_.value,G=D?{..._,id:D,interrupt_id:D}:_;return u.jsx(Ch,{interruptPart:G,onApprove:g,onReject:x,disabled:y,isActive:P,payload:j},W)}return null},[f,v,g,x,b,S,k,T,E,N,O,y]),U=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!U&&!p)return null;if(t)return!n&&r?null:n?u.jsx(kh,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,_)=>u.jsx(K,{part:W,i:_},_))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(Eh,{className:$})]}):I}return null}function Ah(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),p=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],T=v.name||`file_${k}`,C=v.mimeType||"application/octet-stream";p({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){f.preventDefault(),s(T=>({...T,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await Qc(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.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(!(C!=null&&C.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");p({id:C.id,name:v.name||C.filename||`file_${C.id}`,mimeType:v.mimeType||C.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function jh(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:zv(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Hv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ks=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:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:T=1,attemptIndex:C=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[O,$]=w.useState(!1),[H,K]=w.useState("preview"),[U,I]=w.useState(!1),{currentThreadId:W}=pr(),{respondToInterrupt:_}=Yr(),D=l==="phone"||l==="half-screen",P=t.role,j=P==="tool",G=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),Z=!!G,R=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:q,fileViewerOpen:X,currentFileInfo:oe,closeFileViewer:V}=Ah({allowFileOpen:R,currentThreadId:W}),L=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]),Y=jh(t,G),{contentParts:J,imageParts:ce,fileParts:F,interruptParts:re,textContent:ue,toolMeta:le,toolRaw:xe,isToolStreaming:Ne}=Y,_e=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),De=Vo(_e),Ae=y==null?void 0:y.value,Be=w.useMemo(()=>G||!m?null:t.artifact||null,[G,t,m]),tt=w.useCallback(async()=>{const ge=j?xe:ue;async function He(Ye){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ye);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const vt=new Blob([Ye],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":vt})]);return}throw new Error("Clipboard API not supported in this context.")}try{await He(ge),$(!0),setTimeout(()=>$(!1),2e3),x==null||x(ge)}catch(Ye){console.error("Failed to copy:",Ye)}},[j,xe,ue,x]),qe=w.useCallback(()=>{if(!v||!t.id)return;const ge=(j?xe:ue)??"",He="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,ge,He)},[v,t.id,j,xe,ue,t]),ze=w.useCallback(()=>{g==null||g(n)},[g,n]),it=w.useCallback(()=>{const He=te(D?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",L);switch(P){case"user":return u.jsx(fe.User,{className:He});case"assistant":return u.jsx(fe.Bot,{className:He});case"tool":return u.jsx(fe.Wrench,{className:He});default:return u.jsx(fe.Bot,{className:He})}},[D,L,P]),nt=w.useCallback(()=>{const ge="group relative mb-4 flex w-full";switch(P){case"user":return te(ge,"justify-end");case"assistant":case"tool":case"system":return te(ge,"justify-start");default:return ge}},[P]),Ze=w.useCallback(()=>{const ge=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",D&&"px-3 py-2 text-sm");if(Z)return te(ge,"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(ge,"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(ge,"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(ge,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(ge,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(ge,"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")}},[D,Z,P]),St=w.useCallback(async ge=>{if(b)return;const He=Vo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id));if(!He){console.warn("Interrupt part missing id",ge);return}try{S==null||S(),await _(He,!0)}catch(Ye){console.error("Failed to approve interrupt:",Ye)}finally{k==null||k()}},[b,k,S,_]),xt=w.useCallback(async ge=>{if(b)return;const He=Vo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id));if(!He){console.warn("Interrupt part missing id",ge);return}try{S==null||S(),await _(He,!1)}catch(Ye){console.error("Failed to reject interrupt:",Ye)}finally{k==null||k()}},[b,k,S,_]),at=w.useMemo(()=>G?"Assistant":Uv(t),[G,t]),Rt=P==="user"&&(T??1)>1&&typeof E=="function",Mt=(N==null?void 0:N.length)??0,Ct=Mt>0&&C<Mt-1?N[C+1]:void 0,Tt=Mt>0&&C>0?N[C-1]:void 0,kt=w.useCallback(()=>{!Ct||!E||E(Ct.id,void 0,!!Ct.isLatestAttempt)},[Ct,E]),Ve=w.useCallback(()=>{!Tt||!E||E(Tt.id,void 0,!!Tt.isLatestAttempt)},[Tt,E]);return j&&!p&&!Be?null:Z&&G?u.jsx("div",{className:te(nt(),f.container),children:u.jsxs("div",{className:te(Ze(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(fe.Bot,{className:te("h-4 w-4",L)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:G.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(nt(),f.container),children:u.jsxs("div",{className:te(Ze(),f.content),children:[(i||a||j)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",D&&"mb-1 pb-1",L,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[it(),a&&at&&u.jsx("span",{className:te("font-medium",D?"text-xs":"text-sm"),children:at}),j&&u.jsxs(Fp,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",L,"border border-current/40",D&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":H==="expanded",onClick:()=>K(ge=>ge==="expanded"?"preview":"expanded"),onKeyDown:ge=>{(ge.key==="Enter"||ge.key===" ")&&(ge.preventDefault(),K(He=>He==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:le.name??"Tool Output"}),le.toolCallId&&u.jsx("span",{className:"opacity-70",children:le.toolCallId.slice(0,8)}),H==="expanded"?u.jsx(fe.ChevronUp,{className:"h-3 w-3"}):u.jsx(fe.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Rt&&T>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",C<T-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C>=T-1||kt()},"aria-label":"Older attempt (back in time)",disabled:C>=T-1,children:u.jsx(fe.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[T-C," / ",T]})}),u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",C>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C<=0||Ve()},"aria-label":"Newer attempt (forward in time)",disabled:C<=0,children:u.jsx(fe.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",L,D&&"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(lt,{variant:"ghost",size:"sm",onClick:()=>tt(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(fe.Copy,{className:te(O?"text-success":L,D?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:qe,className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(fe.Edit,{className:te(L,D?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:ze,className:te("h-6 w-6 p-0 hover:bg-foreground/10",L,D&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(fe.RotateCcw,{className:te(L,D?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Nh,{message:t,isToolMessage:j,showToolMessages:p,artifactToRender:Be,toolViewMode:H,isToolStreaming:Ne,contentParts:J,textContent:ue,imageParts:ce,fileParts:F,interruptParts:re,isStreamingMessage:r,defaultMessage:G,handleFileClick:q,uploadingFiles:M,handleInterruptApprove:St,handleInterruptReject:xt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:I,isCompactLayout:D,activeInterruptId:De,activeInterruptValue:Ae,iconForeground:L}),m&&Be&&u.jsx("div",{className:"mt-3",children:u.jsx(yh,{artifact:Be,idx:0})})]}),j&&H==="expanded"&&(le.toolCallId||le.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",D&&"text-xs"),children:[le.name&&u.jsxs("div",{children:["Function: ",le.name]}),le.toolCallId&&u.jsxs("div",{children:["Call ID: ",le.toolCallId]})]}),!(i||a||j)&&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(lt,{variant:"ghost",size:"sm",onClick:()=>tt(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.Copy,{className:te(O?"text-success":"text-current",D?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:qe,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.Edit,{className:te("text-current",D?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(lt,{variant:"ghost",size:"sm",onClick:ze,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",D&&"h-5 w-5"),children:u.jsx(fe.RotateCcw,{className:te("text-current",D?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(sh,{isOpen:X,onClose:V,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&cu(e.message)===cu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=uu(e.message),a=uu(t.message);return i.length===a.length});Ks.displayName="MessageComponent";const jT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=al(t,n),T="type"in t&&t.type==="default_message",E=!!t.__syntheticStreaming,N=b??jT,O=!T&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:$,attemptIndex:H,attempts:K}=w.useMemo(()=>ec(t.id,O,N),[t.id,O,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(Ks,{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:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:$,attemptIndex:H,attemptMetas:K,onSelectCheckpoint:S})})});ll.displayName="MessageRow";const cl=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:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:O,onSelectCheckpoint:$,createSyntheticThinkingMessage:H=!0},K)=>{const U=w.useRef(null),I=w.useRef(null),W=w.useRef(!1),_=w.useRef(!1),[D,P]=w.useState(!0),j=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(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===b.id)):!1,[b,e]),G=w.useMemo(()=>{if(!b||j)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let re;const ue=b.value;if(ue&&typeof ue=="object"&&!Array.isArray(ue)){const le=ue.title;typeof le=="string"&&le.trim()&&(re=le.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:ue,title:re}]}},[b,j]),Z=w.useMemo(()=>G?[...e,G]:e,[e,G]),R=w.useMemo(()=>!H||!t?Z:!Z.some(re=>re.role==="assistant")&&Z.length>0?[...Z,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Z,[Z,t,H]),M=w.useMemo(()=>C?R:R.filter(F=>(F==null?void 0:F.role)!=="tool"),[R,C]),q=w.useCallback(F=>{P(F),x&&x(!F),y&&y(F)},[x,y]),X=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:D?"auto":!1,[D,v,g]),V=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return F?{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}:null},[f]),L=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),Y=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ks,{message:V,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!"}),J=M.length,ce=J>0;return w.useEffect(()=>{var F,re;if(J===0){_.current=!1;return}if(!_.current)if(_.current=!0,U.current&&M.length>0){const ue=M.length-1;(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:ue,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[J,M.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var F,re;if(U.current&&M.length>0){const ue=M.length-1;(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:ue,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var F,re;U.current&&M.length>0?(re=(F=U.current).scrollToIndex)==null||re.call(F,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ce?u.jsx(RC,{ref:F=>{U.current=F},scrollerRef:F=>{I.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:q,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,re)=>al(re,F),itemContent:(F,re)=>u.jsx(ll,{message:re,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:T,showToolMessages:C,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:O,onSelectCheckpoint:$})}):Y()})})});cl.displayName="MessageList";const _h={value:""};function Co({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:T,navigateToCheckpoint:C,returnToLatest:E,checkpoint:N,checkpoints:O,interrupt:$,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:U,error:I,connectionState:W,submit:_,stop:D}=Ri(),P=b??y??null,j=(N==null?void 0:N.id)??null,G=(N==null?void 0:N.namespace)??null,[Z,R]=w.useState(null),M=(H==null?void 0:H.assemblingMessageId)??(U&&Z?Z:null),q=$,[X,oe]=w.useState(!1);w.useEffect(()=>{q||oe(!1)},[q]);const V=w.useCallback(()=>{oe(!0)},[]),L=w.useCallback(()=>{oe(!1)},[]),Y=!!q||X,[J,ce]=w.useState(null),[F,re]=w.useState(""),[ue,le]=w.useState(null),[xe,Ne]=w.useState(null),[_e,De]=w.useState([]),[Ae,Be]=w.useState(0),[tt,qe]=w.useState(0),[ze,it]=w.useState(!1),[nt,Ze]=w.useState(null),[St,xt]=w.useState(null),[at,Rt]=w.useState(!1),[Mt,Ct]=w.useState(null),Tt=w.useRef(!1),[kt,Ve]=w.useState(()=>_h.value),ge=w.useRef(kt),He=w.useRef(null),Ye=w.useCallback(ie=>{_h.value=ie,Ve(ie)},[]),[vt,$t]=w.useState(!1),ne=w.useRef(null),Se=w.useRef(null),dt=w.useRef(null),we=w.useCallback(()=>{Se.current&&(Se.current.value=""),dt.current&&(dt.current.value=""),Be(ie=>ie+1),qe(ie=>ie+1)},[]),Me=w.useCallback(ie=>{Ye(ie)},[Ye]),Ue=w.useRef(!1);w.useEffect(()=>{Ue.current&&!U&&(De([]),we()),Ue.current=U},[U,we]),w.useEffect(()=>{U||R(null)},[U]);const[Et,Ke]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const de=window.innerWidth;Ke(de<640?"phone":de<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{Tt.current=!1},[P]),w.useEffect(()=>{ge.current=kt},[kt]),w.useEffect(()=>{if(!J){He.current=null;return}He.current===null&&(He.current=ge.current),Ye(F??"")},[F,J,Ye]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){Ct(null);return}try{const Ee=(await x.getAgent("default")).uiDefaultMessage||"";Ct(Ee||null)}catch(de){console.warn("Failed to fetch default message:",de),Ct(null)}})()},[x.baseUrl]),w.useEffect(()=>{I&&!at&&(g==null||g(I))},[I,at,g]);const wt=async ie=>{const de=ie.trim();if(!de&&_e.length===0)return;const Ee=J;try{const Oe=J?(ue==null?void 0:ue.checkpointId)??j??void 0:j??void 0,et=J?(ue==null?void 0:ue.checkpointNs)??G??void 0:G??void 0;await _({text:de||"",attachments:_e},{checkpointId:Oe,checkpointNs:et,edit:!!J,originalMessageId:J??void 0}),f==null||f(de),Ee&&R(Ee),Ye(""),Ne(null),De([]),we(),ce(null),re(""),le(null)}catch(Oe){const et=(Oe==null?void 0:Oe.message)||"Failed to send message";Ne(et),g==null||g(et)}},Fe=w.useCallback((ie,de,Ee)=>{c&&(He.current=kt,ce(ie),re(de),Ye(de),Ne(null),le({checkpointId:(Ee==null?void 0:Ee.checkpointId)??null,checkpointNs:(Ee==null?void 0:Ee.checkpointNs)??null}))},[kt,c,Ye]),Xe=w.useCallback(()=>{ce(null),re(""),le(null),Ne(null),Ye(He.current??kt),He.current=null,R(null)},[kt,Ye]),Vt=w.useCallback((ie,de,Ee)=>{Fe(ie,de,Ee)},[Fe]),ql=w.useCallback(ie=>{let de=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){de=S[pt];break}if(!de)return;const Ee=Array.isArray(de.content)?de.content:[],et=Ee.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ee,null,2)}catch{return String(Ee)}})();et&&_({text:et},{checkpointId:j??void 0,checkpointNs:G??void 0,edit:!0,originalMessageId:de.id})},[S,_,j,G]),Gl=ie=>{const de=Array.from(ie.target.files||[]);De(Ee=>[...Ee,...de]),ie.target.value=""},Yl=ie=>{De(de=>{const Ee=de.filter((Oe,et)=>ie!==et);return Ee.length===0&&we(),Ee})},A=async ie=>{const de=(ie.target.files||[])[0];if(de){Ze(null),xt(null),it(!0);try{await _({attachments:[de]},{checkpointId:j??void 0,checkpointNs:G??void 0});const Ee=`Uploaded ${de.name} - processing through chat stream`;xt(Ee)}catch(Ee){const Oe=Ee instanceof Error?Ee.message:"Failed to upload Excel file";console.error("Excel upload failed",Ee),Ze(Oe),g==null||g(Oe)}finally{it(!1),ie.target.value="",we()}}},ee=async ie=>{if(y){$t(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Oe;(Oe=ne.current)==null||Oe.scrollToLatest()});return}const de=O.find(Oe=>Oe.checkpointId===ie),Ee=(de==null?void 0:de.checkpointNs)??null;await C(ie,Ee),requestAnimationFrame(()=>{var Oe;(Oe=ne.current)==null||Oe.scrollToTop()})}finally{$t(!1)}}},pe=w.useCallback(async(ie,de,Ee)=>{await ee(Ee?null:ie)},[ee]),ke=`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||""}`,rt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ke,children:[!!I&&!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:I}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>Rt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(fe.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:ne,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:J,onEdit:Vt,onRegenerate:ql,onCancelEdit:Xe,emptyMessage:Mt??void 0,isNavigatingCheckpoint:vt,activeInterrupt:q,disableInterruptActions:X,onInterruptActionStart:V,onInterruptActionEnd:L,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:pe,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(fe.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"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||vt)&&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(fe.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:rt,children:[J&&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(fe.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:Xe,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(fe.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:Se,type:"file",multiple:!0,onChange:ie=>Gl(ie),className:"hidden"},Ae),_e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:_e.map((ie,de)=>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(fe.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ie.name}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>Yl(de),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(fe.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:dt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},tt),ze&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),St&&!ze&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:St}),nt&&!ze&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:nt})]})]}),xe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:xe}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{type:"button",size:"icon",variant:"outline",disabled:U||Y,title:"More input actions",className:m.moreButton||"",children:u.jsx(fe.Plus,{size:16})})}),u.jsxs(lo,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Ln,{onClick:()=>{var ie;return(ie=Se.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Ln,{onClick:()=>{var ie;ze||(ie=dt.current)==null||ie.click()},className:`cursor-pointer ${ze?"opacity-60 pointer-events-none":""}`,children:[u.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(CS,{initialValue:F,editingMessageId:J,value:kt,onValueChange:Me,placeholder:J?"Edit your message...":t,isStreaming:U,disabled:Y,onSend:wt,onCancelEdit:Xe,onStop:D,allowEmptySend:_e.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${J?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${xe?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Ph=1,_T=.9,PT=.8,RT=.17,ul=.1,dl=.999,MT=.9999,OT=.99,DT=/[\\\/_+.#"@\[\(\{&]/,LT=/[\\\/_+.#"@\[\(\{&]/g,$T=/[\s-]/,Rh=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Ph: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,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Ph:DT.test(e.charAt(c-1))?(p*=PT,f=e.slice(o,c-1).match(LT),f&&o>0&&(p*=Math.pow(dl,f.length))):$T.test(e.charAt(c-1))?(p*=_T,v=e.slice(o,c-1).match(Rh),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=RT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=MT)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Mh(e){return e.toLowerCase().replace(Rh," ")}function FT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,Mh(e),Mh(t),0,0,{})}var To='[cmdk-group=""]',pl='[cmdk-group-items=""]',BT='[cmdk-group-heading=""]',Oh='[cmdk-item=""]',Dh=`${Oh}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",zT=(e,t,n)=>FT(e,t,n),Lh=h.createContext(void 0),ko=()=>h.useContext(Lh),$h=h.createContext(void 0),ml=()=>h.useContext($h),Fh=h.createContext(void 0),Bh=h.forwardRef((e,t)=>{let n=_r(()=>{var R,M;return{search:"",value:(M=(R=e.value)!=null?R:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=zh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=At(),S=At(),k=At(),T=h.useRef(null),C=ZT();ir(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),ir(()=>{C(6,U)},[]);let E=h.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,M,q)=>{var X,oe,V,L;if(!Object.is(n.current[R],M)){if(n.current[R]=M,R==="search")K(),$(),C(1,H);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(k);Y?Y.focus():(X=document.getElementById(b))==null||X.focus()}if(C(7,()=>{var Y;n.current.selectedItemId=(Y=I())==null?void 0:Y.id,E.emit()}),q||C(5,U),((oe=a.current)==null?void 0:oe.value)!==void 0){let Y=M??"";(L=(V=a.current).onValueChange)==null||L.call(V,Y);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),N=h.useMemo(()=>({value:(R,M,q)=>{var X;M!==((X=s.current.get(R))==null?void 0:X.value)&&(s.current.set(R,{value:M,keywords:q}),n.current.filtered.items.set(R,O(M,q)),C(2,()=>{$(),E.emit()}))},item:(R,M)=>(r.current.add(R),M&&(o.current.has(M)?o.current.get(M).add(R):o.current.set(M,new Set([R]))),C(3,()=>{K(),$(),n.current.value||H(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let q=I();C(4,()=>{K(),(q==null?void 0:q.getAttribute("id"))===R&&H(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:T}),[]);function O(R,M){var q,X;let oe=(X=(q=a.current)==null?void 0:q.filter)!=null?X:zT;return R?oe(R,n.current.search,M):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(X=>{let oe=o.current.get(X),V=0;oe.forEach(L=>{let Y=R.get(L);V=Math.max(Y,V)}),M.push([X,V])});let q=T.current;W().sort((X,oe)=>{var V,L;let Y=X.getAttribute("id"),J=oe.getAttribute("id");return((V=R.get(J))!=null?V:0)-((L=R.get(Y))!=null?L:0)}).forEach(X=>{let oe=X.closest(pl);oe?oe.appendChild(X.parentElement===oe?X:X.closest(`${pl} > *`)):q.appendChild(X.parentElement===q?X:X.closest(`${pl} > *`))}),M.sort((X,oe)=>oe[1]-X[1]).forEach(X=>{var oe;let V=(oe=T.current)==null?void 0:oe.querySelector(`${To}[${jr}="${encodeURIComponent(X[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let R=W().find(q=>q.getAttribute("aria-disabled")!=="true"),M=R==null?void 0:R.getAttribute(jr);E.setState("value",M||void 0)}function K(){var R,M,q,X;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 V of r.current){let L=(M=(R=s.current.get(V))==null?void 0:R.value)!=null?M:"",Y=(X=(q=s.current.get(V))==null?void 0:q.keywords)!=null?X:[],J=O(L,Y);n.current.filtered.items.set(V,J),J>0&&oe++}for(let[V,L]of o.current)for(let Y of L)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=oe}function U(){var R,M,q;let X=I();X&&(((R=X.parentElement)==null?void 0:R.firstChild)===X&&((q=(M=X.closest(To))==null?void 0:M.querySelector(BT))==null||q.scrollIntoView({block:"nearest"})),X.scrollIntoView({block:"nearest"}))}function I(){var R;return(R=T.current)==null?void 0:R.querySelector(`${Oh}[aria-selected="true"]`)}function W(){var R;return Array.from(((R=T.current)==null?void 0:R.querySelectorAll(Dh))||[])}function _(R){let M=W()[R];M&&E.setState("value",M.getAttribute(jr))}function D(R){var M;let q=I(),X=W(),oe=X.findIndex(L=>L===q),V=X[oe+R];(M=a.current)!=null&&M.loop&&(V=oe+R<0?X[X.length-1]:oe+R===X.length?X[0]:X[oe+R]),V&&E.setState("value",V.getAttribute(jr))}function P(R){let M=I(),q=M==null?void 0:M.closest(To),X;for(;q&&!X;)q=R>0?XT(q,To):JT(q,To),X=q==null?void 0:q.querySelector(Dh);X?E.setState("value",X.getAttribute(jr)):D(R)}let j=()=>_(W().length-1),G=R=>{R.preventDefault(),R.metaKey?j():R.altKey?P(1):D(1)},Z=R=>{R.preventDefault(),R.metaKey?_(0):R.altKey?P(-1):D(-1)};return h.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var M;(M=y.onKeyDown)==null||M.call(y,R);let q=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||q))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&G(R);break}case"ArrowDown":{G(R);break}case"p":case"k":{x&&R.ctrlKey&&Z(R);break}case"ArrowUp":{Z(R);break}case"Home":{R.preventDefault(),_(0);break}case"End":{R.preventDefault(),j();break}case"Enter":{R.preventDefault();let X=I();if(X){let oe=new Event(hl);X.dispatchEvent(oe)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:ek},l),qs(e,R=>h.createElement($h.Provider,{value:E},h.createElement(Lh.Provider,{value:N},R))))}),HT=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext(Fh),a=ko(),l=zh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ir(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Hh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Wn(C=>C.value&&C.value===d.current),f=Wn(C=>c||a.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);h.useEffect(()=>{let C=s.current;if(!(!C||e.disabled))return C.addEventListener(hl,v),()=>C.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var C,E;g(),(E=(C=l.current).onSelect)==null||E.call(C,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...T}=e;return h.createElement(ve.div,{ref:Pn(s,t),...T,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=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=ko(),p=Wn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ir(()=>d.group(i),[]),Hh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(ve.div,{ref:Pn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),qs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Fh.Provider,{value:m},f))))}),WT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Wn(i=>!i.search);return!n&&!s?null:h.createElement(ve.div,{ref:Pn(o,t),...r,"cmdk-separator":"",role:"separator"})}),VT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Wn(c=>c.search),a=Wn(c=>c.selectedItemId),l=ko();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.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=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Wn(c=>c.selectedItemId),l=ko();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(ve.div,{ref:Pn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},qs(e,c=>h.createElement("div",{ref:Pn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),qT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(bo,{"cmdk-overlay":"",className:o}),h.createElement(yo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Bh,{ref:t,...a}))))}),GT=h.forwardRef((e,t)=>Wn(n=>n.filtered.count===0)?h.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),YT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Bh,{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 zh(e){let t=h.useRef(e);return ir(()=>{t.current=e}),t}var ir=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Wn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Hh(e,t,n,r=[]){let o=h.useRef(),s=ko();return ir(()=>{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(jr,a),o.current=a}),o}var ZT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return ir(()=>{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 qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.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 gl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=Ut.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(fe.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.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})]}));xl.displayName=Ut.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=Ut.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=Ut.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));bl.displayName=Ut.Group.displayName;const tk=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));tk.displayName=Ut.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.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}));yl.displayName=Ut.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function nk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[Uh,gN]=sn(Cl),[rk,rn]=Uh(Cl),Wh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[S,k]=h.useState(0),[T,C]=h.useState(!1),[E,N]=h.useState(!1),O=Le(t,H=>l(H)),$=qo(o);return u.jsx(rk,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:$,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Wh.displayName=Cl;var Vh="ScrollAreaViewport",Kh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Vh,n),a=h.useRef(null),l=Le(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})})]})});Kh.displayName=Vh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(ok,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(sk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(qh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var ok=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(qh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),sk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Js(()=>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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),qh=h.forwardRef((e,t)=>{const n=rn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Js(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Zh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return 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=Qh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(ak,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Qh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ik=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Le(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Yh,{"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":Xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),tm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Ys(i.paddingLeft),paddingEnd:Ys(i.paddingRight)}})}})}),ak=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Le(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Yh,{"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":Xs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),tm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Ys(i.paddingTop),paddingEnd:Ys(i.paddingBottom)}})}})}),[lk,Gh]=Uh(Tn),Yh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=rn(Tn,n),[v,g]=h.useState(null),x=Le(t,O=>g(O)),y=h.useRef(null),b=h.useRef(""),S=f.viewport,k=r.content-r.viewport,T=mt(d),C=mt(l),E=Js(p,10);function N(O){if(y.current){const $=O.clientX-y.current.left,H=O.clientY-y.current.top;c({x:$,y:H})}}return h.useEffect(()=>{const O=$=>{const H=$.target;(v==null?void 0:v.contains(H))&&T($,k)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,v,k,T]),h.useEffect(C,[r,C]),Pr(v,E),Pr(f.content,E),u.jsx(lk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:C,onThumbPointerDown:mt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(O))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,O=>{const $=O.target;$.hasPointerCapture(O.pointerId)&&$.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Gs="ScrollAreaThumb",Xh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gh(Gs,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(ck,{ref:t,...r})})}),ck=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(Gs,n),i=Gh(Gs,n),{onThumbPositionChange:a}=i,l=Le(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Js(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=fk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.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,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Xh.displayName=Gs;var El="ScrollAreaCorner",Jh=h.forwardRef((e,t)=>{const n=rn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(uk,{...e,ref:t}):null});Jh.displayName=El;var uk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.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 Ys(e){return e?parseInt(e,10):0}function Zh(e,t){const n=e/t;return isNaN(n)?0:n}function Xs(e){const t=Zh(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=Xs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return em([l,c],p)(e)}function Qh(e,t,n="ltr"){const r=Xs(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=Sl(e,l);return em([0,i],[0,a])(c)}function em(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 tm(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 Js(e,t){const n=mt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Pr(e,t){const n=mt(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 nm=Wh,pk=Kh,hk=Jh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(nm,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(pk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(rm,{}),u.jsx(hk,{})]}));Il.displayName=nm.displayName;const rm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{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(Xh,{className:"relative flex-1 rounded-full bg-border"})}));rm.displayName=Tl.displayName;const Nl=h.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}));Nl.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 om({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??xk}`:`${x??gk}`,k=T=>{T.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:T=>T.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:T=>i(T.target.value),onKeyDown:T=>{T.key==="Enter"?a(e.threadId):T.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(fe.Check,{size:12})}),u.jsx(lt,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(fe.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(fe.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(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(fe.MoreHorizontal,{size:12})})}),u.jsxs(lo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Ln,{onClick:T=>{T.preventDefault(),c(e.threadId)},children:[u.jsx(fe.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Ln,{onClick:T=>{T.preventDefault(),s(e,T)},children:[u.jsx(fe.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Ln,{className:"text-red-400 hover:text-red-300",onClick:T=>{T.preventDefault(),d(e.threadId,T)},children:[u.jsx(fe.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 sm=25,im="thread-manager-view",vk=e=>e==="default"||e==="shared",wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(im);if(vk(e))return e}catch{}return null};function am({defaultView:e}={}){const[t,n]=w.useState(()=>wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(im,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 Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:T,currentThreadId:C,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:O,actions:$,shareInFlight:H,shareStatus:K,clearShareStatus:U}=pr(),{createThread:I,deleteThread:W,renameThread:_,shareThread:D}=$,{loadThread:P}=Yr(),j=i??C,[G,Z]=w.useState(Array.isArray(k)?k:[]),R=w.useRef(G.length>0),M=w.useRef(null),q=w.useRef(0),[X,oe]=w.useState(null),[V,L]=w.useState(""),[Y,J]=w.useState(!1),[ce,F]=w.useState(!1),[re,ue]=w.useState(null),[le,xe]=w.useState(""),Ne=v&&v.length>0?v:bk,_e=am({defaultView:m}),De=g??_e,Ae=p??De.view,Be=w.useCallback(ne=>{p||De.setView(ne),f==null||f(ne)},[p,f,De]),tt=Ne.find(ne=>ne.key===Ae)??Ne[0],qe=ne=>{ue(ne),xe(""),F(!0)},ze=()=>{F(!1),ue(null),xe(""),U()},it=w.useCallback(async ne=>{if(!(!re||H)&&ne.id)try{await D(re,ne.id),setTimeout(()=>ze(),600)}catch(Se){console.error("Failed to share thread:",Se)}},[ze,H,re,D]),nt=w.useMemo(()=>{const ne=y??[],Se=le.trim().toLowerCase();return Se?S?ne.filter(dt=>S(dt,Se)):ne.filter(dt=>`${dt.label} ${dt.secondaryLabel??""}`.toLowerCase().includes(Se)):ne},[y,le,S]),Ze=Ae==="shared",St=Ze?T:G,xt=Ze?O:N,at=Ze?"No shared conversations yet":"No conversations yet",Rt=ne=>{const Se=ne.sharedAt?` • ${Ye(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${Se}`},Mt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){R.current=!0,Z(ne);return}N||(R.current=!1,Z(ne))},[k,N]),w.useEffect(()=>{if(!M.current)return;const ne=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let Se=null,dt=null;return Se=requestAnimationFrame(()=>{dt=requestAnimationFrame(()=>{ne.scrollTop=q.current})}),()=>{Se!==null&&cancelAnimationFrame(Se),dt!==null&&cancelAnimationFrame(dt)}},[G]);const Ct=async ne=>{try{E(ne),await P(ne),a==null||a(ne),l==null||l(ne)}catch(Se){console.error("Failed to select thread:",Se)}},Tt=async()=>{try{J(!0);const ne=await I();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{J(!1)}},kt=async(ne,Se)=>{if(Se.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const dt=M.current.querySelector("[data-radix-scroll-area-viewport]");dt&&(q.current=dt.scrollTop)}try{await W(ne),d==null||d(ne)}catch(dt){console.error("Failed to delete thread:",dt)}}},Ve=(ne,Se)=>{Se.stopPropagation(),oe(ne.threadId),L(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},ge=async ne=>{if(V.trim())try{await _(ne,V.trim()),oe(null),L("")}catch(Se){console.error("Failed to update title:",Se)}},He=()=>{oe(null),L("")},Ye=ne=>{if(!ne)return"";try{const Se=new Date(ne),we=new Date().getTime()-Se.getTime(),Me=Math.floor(we/(1e3*60*60*24));return Me===0?Se.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Me===1?"Yesterday":Me<7?`${Me} days ago`:Se.toLocaleDateString()}catch{return""}},vt=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,$t=ne=>{const Se=vt(ne);return Se.length<=sm?Se:`${Se.slice(0,sm)}...`};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(lt,{onClick:Tt,disabled:Y||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Y?"Creating...":"New Chat",children:[u.jsx(fe.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(ws,{children:[u.jsx(bs,{asChild:!0,children:u.jsx(lt,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:tt.label})}),u.jsx(lo,{align:"start",sideOffset:6,className:"w-40",children:Ne.map(ne=>u.jsxs(Ln,{className:"justify-between text-[12px]",onClick:Se=>{Se.preventDefault(),Be(ne.key)},children:[u.jsx("span",{children:ne.label}),Ae===ne.key&&u.jsx(fe.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(Il,{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:xt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):St.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(fe.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})]}):St.slice().sort((ne,Se)=>new Date(Se.updatedAt||Se.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(om,{thread:ne,isActive:j===ne.threadId,editingThreadId:X,editingTitle:V,onSelect:Ct,onStartEditing:Ve,onEditingTitleChange:Se=>L(Se),onSaveEditing:ge,onCancelEditing:He,onShare:()=>qe(ne.threadId),onDelete:kt,showEditTitle:r,showDeleteButton:n,formatDate:Ye,getDisplayThreadTitle:$t,secondaryLine:Ze&&Mt(ne)?Rt(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(Ya,{open:ce,onOpenChange:ne=>!ne&&ze(),children:u.jsxs(Ls,{className:"max-w-md p-0",children:[u.jsx($s,{children:u.jsx(Fs,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:le,onValueChange:ne=>xe(ne),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(wl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(ne=>u.jsx(yl,{onSelect:()=>it(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.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(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Co,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...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(Al,{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(Co,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...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(Al,{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(Co,{onError:s.onError,enableFileUpload:!0})})]})})}function Sk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Co,{})})})}var Ck="Label",lm=h.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())}}));lm.displayName=Ck;var cm=lm;const Tk=Dr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),um=h.forwardRef(({className:e,...t},n)=>u.jsx(cm,{ref:n,className:te(Tk(),e),...t}));um.displayName=cm.displayName;function dm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var fm=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"}),kk="VisuallyHidden",Zs=h.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...fm,...e.style}}));Zs.displayName=kk;var Ek=Zs,Ik=[" ","Enter","ArrowUp","ArrowDown"],Nk=[" ","Enter"],ar="Select",[Qs,ei,Ak]=Ko(ar),[Rr,xN]=sn(ar,[Ak,yr]),ti=yr(),[jk,Vn]=Rr(ar),[_k,Pk]=Rr(ar),pm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ti(t),[x,y]=h.useState(null),[b,S]=h.useState(null),[k,T]=h.useState(!1),C=qo(c),[E,N]=Rn({prop:r,defaultProp:o??!1,onChange:s,caller:ar}),[O,$]=Rn({prop:i,defaultProp:a,onChange:l,caller:ar}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[U,I]=h.useState(new Set),W=Array.from(U).map(_=>_.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(jk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:At(),value:O,onValueChange:$,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Qs.Provider,{scope:t,children:u.jsx(_k,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(_=>{I(D=>new Set(D).add(_))},[]),onNativeOptionRemove:h.useCallback(_=>{I(D=>{const P=new Set(D);return P.delete(_),P})},[]),children:n})}),K?u.jsxs(Lm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:O,onChange:_=>$(_.target.value),disabled:m,form:v,children:[O===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},W):null]})})};pm.displayName=ar;var hm="SelectTrigger",mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ti(n),i=Vn(hm,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=ei(n),d=h.useRef("touch"),[p,m,f]=Fm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Bm(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(ta,{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":$m(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=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Ik.includes(g.key)&&(v(),g.preventDefault())})})})});mm.displayName=hm;var gm="SelectValue",xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Vn(gm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Le(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:p,style:{pointerEvents:"none"},children:$m(l.value)?u.jsx(u.Fragment,{children:i}):s})});xm.displayName=gm;var Rk="SelectIcon",vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});vm.displayName=Rk;var Mk="SelectPortal",wm=e=>u.jsx(to,{asChild:!0,...e});wm.displayName=Mk;var lr="SelectContent",bm=h.forwardRef((e,t)=>{const n=Vn(lr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(ym,{scope:e.__scopeSelect,children:u.jsx(Qs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Sm,{...e,ref:t})});bm.displayName=lr;var fn=10,[ym,Kn]=Rr(lr),Ok="SelectContentImpl",Dk=qt.createSlot("SelectContent.RemoveScroll"),Sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Vn(lr,n),[S,k]=h.useState(null),[T,C]=h.useState(null),E=Le(t,V=>k(V)),[N,O]=h.useState(null),[$,H]=h.useState(null),K=ei(n),[U,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const _=h.useCallback(V=>{const[L,...Y]=K().map(F=>F.ref.current),[J]=Y.slice(-1),ce=document.activeElement;for(const F of V)if(F===ce||(F==null||F.scrollIntoView({block:"nearest"}),F===L&&T&&(T.scrollTop=0),F===J&&T&&(T.scrollTop=T.scrollHeight),F==null||F.focus(),document.activeElement!==ce))return},[K,T]),D=h.useCallback(()=>_([N,S]),[_,N,S]);h.useEffect(()=>{U&&D()},[U,D]);const{onOpenChange:P,triggerPointerDownPosRef:j}=b;h.useEffect(()=>{if(S){let V={x:0,y:0};const L=J=>{var ce,F;V={x:Math.abs(Math.round(J.pageX)-(((ce=j.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(J.pageY)-(((F=j.current)==null?void 0:F.y)??0))}},Y=J=>{V.x<=10&&V.y<=10?J.preventDefault():S.contains(J.target)||P(!1),document.removeEventListener("pointermove",L),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Y,{capture:!0})}}},[S,P,j]),h.useEffect(()=>{const V=()=>P(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[P]);const[G,Z]=Fm(V=>{const L=K().filter(ce=>!ce.disabled),Y=L.find(ce=>ce.ref.current===document.activeElement),J=Bm(L,V,Y);J&&setTimeout(()=>J.ref.current.focus())}),R=h.useCallback((V,L,Y)=>{const J=!W.current&&!Y;(b.value!==void 0&&b.value===L||J)&&(O(V),J&&(W.current=!0))},[b.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),q=h.useCallback((V,L,Y)=>{const J=!W.current&&!Y;(b.value!==void 0&&b.value===L||J)&&H(V)},[b.value]),X=r==="popper"?jl:Cm,oe=X===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(ym,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:R,selectedItem:N,onItemLeave:M,itemTextRefCallback:q,focusSelectedItem:D,selectedItemText:$,position:r,isPositioned:U,searchRef:G,children:u.jsx(ps,{as:Dk,allowPinchZoom:!0,children:u.jsx(Go,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ae(o,V=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(X,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...y,...oe,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,V=>{const L=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!L&&V.key.length===1&&Z(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let J=K().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(V.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ce=V.target,F=J.indexOf(ce);J=J.slice(F+1)}setTimeout(()=>_(J)),V.preventDefault()}})})})})})})});Sm.displayName=Ok;var Lk="SelectItemAlignedPosition",Cm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Vn(lr,n),i=Kn(lr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Le(t,E=>d(E)),m=ei(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const ce=$.left-N.left,F=O.left-ce,re=E.left-F,ue=E.width+re,le=Math.max(ue,N.width),xe=window.innerWidth-fn,Ne=Sl(F,[fn,Math.max(fn,xe-le)]);a.style.minWidth=ue+"px",a.style.left=Ne+"px"}else{const ce=N.right-$.right,F=window.innerWidth-O.right-ce,re=window.innerWidth-E.right-F,ue=E.width+re,le=Math.max(ue,N.width),xe=window.innerWidth-fn,Ne=Sl(F,[fn,Math.max(fn,xe-le)]);a.style.minWidth=ue+"px",a.style.right=Ne+"px"}const H=m(),K=window.innerHeight-fn*2,U=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),_=parseInt(I.paddingTop,10),D=parseInt(I.borderBottomWidth,10),P=parseInt(I.paddingBottom,10),j=W+_+U+P+D,G=Math.min(x.offsetHeight*5,j),Z=window.getComputedStyle(g),R=parseInt(Z.paddingTop,10),M=parseInt(Z.paddingBottom,10),q=E.top+E.height/2-fn,X=K-q,oe=x.offsetHeight/2,V=x.offsetTop+oe,L=W+_+V,Y=j-L;if(L<=q){const ce=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(X,oe+(ce?M:0)+F+D),ue=L+re;a.style.height=ue+"px"}else{const ce=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(q,W+g.offsetTop+(ce?R:0)+oe)+Y;a.style.height=re+"px",g.scrollTop=L-q+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"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,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=h.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Fk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Cm.displayName=Lk;var $k="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ti(n);return u.jsx(na,{...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)"}})});jl.displayName=$k;var[Fk,_l]=Rr(lr,{}),Pl="SelectViewport",Tm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Kn(Pl,n),i=_l(Pl,n),a=Le(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Qs.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:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Tm.displayName=Pl;var km="SelectGroup",[Bk,zk]=Rr(km),Hk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(Bk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Hk.displayName=km;var Em="SelectLabel",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=zk(Em,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Im.displayName=Em;var ni="SelectItem",[Uk,Nm]=Rr(ni),Am=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Vn(ni,n),l=Kn(ni,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=Le(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=At(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Uk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Qs.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===" "||(Nk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Am.displayName=ni;var Eo="SelectItemText",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Vn(Eo,n),a=Kn(Eo,n),l=Nm(Eo,n),c=Pk(Eo,n),[d,p]=h.useState(null),m=Le(t,y=>p(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=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});jm.displayName=Eo;var _m="SelectItemIndicator",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Nm(_m,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Pm.displayName=_m;var Rl="SelectScrollUpButton",Rm=h.forwardRef((e,t)=>{const n=Kn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(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(Om,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Rm.displayName=Rl;var Ml="SelectScrollDownButton",Mm=h.forwardRef((e,t)=>{const n=Kn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(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(Om,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Mm.displayName=Ml;var Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Kn("SelectScrollButton",n),i=h.useRef(null),a=ei(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(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()})})}),Wk="SelectSeparator",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});Dm.displayName=Wk;var Ol="SelectArrow",Vk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ti(n),s=Vn(Ol,n),i=Kn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});Vk.displayName=Ol;var Kk="SelectBubbleInput",Lm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Le(r,o),i=dm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(ve.select,{...n,style:{...fm,...n.style},ref:s,defaultValue:t})});Lm.displayName=Kk;function $m(e){return e===""||e===void 0}function Fm(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Bm(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=qk(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 qk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Gk=pm,zm=mm,Yk=xm,Xk=vm,Jk=wm,Hm=bm,Zk=Tm,Um=Im,Wm=Am,Qk=jm,eE=Pm,Vm=Rm,Km=Mm,qm=Dm;const tE=Gk,nE=Yk,Gm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(zm,{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(Xk,{asChild:!0,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Gm.displayName=zm.displayName;const Ym=h.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));Ym.displayName=Vm.displayName;const Xm=h.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(fe.ChevronDown,{className:"h-4 w-4"})}));Xm.displayName=Km.displayName;const Jm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Jk,{children:u.jsxs(Hm,{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(Ym,{}),u.jsx(Zk,{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(Xm,{})]})}));Jm.displayName=Hm.displayName;const rE=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));rE.displayName=Um.displayName;const Zm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wm,{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(eE,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),u.jsx(Qk,{children:t})]}));Zm.displayName=Wm.displayName;const oE=h.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));oE.displayName=qm.displayName;var sE="Separator",Qm="horizontal",iE=["horizontal","vertical"],eg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Qm,...o}=e,s=aE(r)?r:Qm,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})});eg.displayName=sE;function aE(e){return iE.includes(e)}var tg=eg;const ng=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(tg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ng.displayName=tg.displayName;var ri="Switch",[lE,vN]=sn(ri),[cE,uE]=lE(ri),rg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=Le(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Rn({prop:o,defaultProp:s??!1,onChange:c,caller:ri});return u.jsxs(cE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":ag(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(ig,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});rg.displayName=ri;var og="SwitchThumb",sg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=uE(og,n);return u.jsx(ve.span,{"data-state":ag(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});sg.displayName=og;var dE="SwitchBubbleInput",ig=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Le(i,s),l=dm(n),c=gd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ig.displayName=dE;function ag(e){return e?"checked":"unchecked"}var lg=rg,fE=sg;const cg=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{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(fE,{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")})}));cg.displayName=lg.displayName;const pE=qa,hE=oT,mE=Ga,ug=h.forwardRef(({className:e,...t},n)=>u.jsx(bo,{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}));ug.displayName=bo.displayName;const gE=Dr.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"}}),dg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(mE,{children:[u.jsx(ug,{}),u.jsxs(yo,{ref:o,className:te(gE({side:e}),t),...r,children:[n,u.jsxs(nh,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));dg.displayName=yo.displayName;const fg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});fg.displayName="SheetHeader";const pg=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));pg.displayName=or.displayName;const hg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ds,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));hg.displayName=Ds.displayName;var[oi,wN]=sn("Tooltip",[yr]),si=yr(),mg="TooltipProvider",xE=700,Dl="tooltip.open",[vE,Ll]=oi(mg),gg=e=>{const{__scopeTooltip:t,delayDuration:n=xE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(vE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};gg.displayName=mg;var Io="Tooltip",[wE,ii]=oi(Io),xg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Io,e.__scopeTooltip),c=si(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=Rn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Io}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(wE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?C():k()},[l.isOpenDelayedRef,C,k]),onTriggerLeave:h.useCallback(()=>{v?T():(window.clearTimeout(f.current),f.current=0)},[T,v]),onOpen:k,onClose:T,disableHoverableContent:v,children:n})})};xg.displayName=Io;var $l="TooltipTrigger",vg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ii($l,n),s=Ll($l,n),i=si(n),a=h.useRef(null),l=Le(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{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",p,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});vg.displayName=$l;var bE="TooltipPortal",[bN,yE]=oi(bE,{forceMount:void 0}),Mr="TooltipContent",wg=h.forwardRef((e,t)=>{const n=yE(Mr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ii(Mr,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(bg,{side:o,...s,ref:t}):u.jsx(SE,{side:o,...s,ref:t})})}),SE=h.forwardRef((e,t)=>{const n=ii(Mr,e.__scopeTooltip),r=Ll(Mr,e.__scopeTooltip),o=h.useRef(null),s=Le(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=IE(y,x.getBoundingClientRect()),S=NE(y,b),k=AE(g.getBoundingClientRect()),T=_E([...S,...k]);a(T),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!jE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(bg,{...e,ref:s})}),[CE,TE]=oi(Io,{isInside:!1}),kE=qt.createSlottable("TooltipContent"),bg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ii(Mr,n),c=si(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"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(kE,{children:r}),u.jsx(CE,{scope:n,isInside:!0,children:u.jsx(Ek,{id:l.contentId,role:"tooltip",children:o||r})})]})})});wg.displayName=Mr;var yg="TooltipArrow",EE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si(n);return TE(yg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});EE.displayName=yg;function IE(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 NE(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 AE(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 jE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function _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),PE(t)}function PE(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 RE=gg,ME=xg,OE=vg,Sg=wg;const DE=RE,LE=ME,$E=OE,Cg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Sg,{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}));Cg.displayName=Sg.displayName;var Fl="ToastProvider",[Bl,FE,BE]=Ko("Toast"),[Tg,yN]=sn("Toast",[BE]),[zE,ai]=Tg(Fl),kg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(zE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};kg.displayName=Fl;var Eg="ToastViewport",HE=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",Ig=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=HE,label:o="Notifications ({hotkey})",...s}=e,i=ai(Eg,n),a=FE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Le(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const C=new CustomEvent(zl);y.dispatchEvent(C),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const C=new CustomEvent(Hl);y.dispatchEvent(C),i.isClosePausedRef.current=!1}},k=C=>{!x.contains(C.relatedTarget)&&S()},T=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",T),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",T),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,T=[k,...tI(k)];return x==="forwards"?T:T.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var T,C,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,O=b.shiftKey;if(b.target===x&&O){(T=c.current)==null||T.focus();return}const K=g({tabbingDirection:O?"backwards":"forwards"}),U=K.findIndex(I=>I===N);Vl(K.slice(U+1))?b.preventDefault():O?(C=c.current)==null||C.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(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});Ig.displayName=Eg;var Ng="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ai(Ng,n);return u.jsx(Zs,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=Ng;var No="Toast",UE="toast.swipeStart",WE="toast.swipeMove",VE="toast.swipeCancel",KE="toast.swipeEnd",Ag=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Rn({prop:r,defaultProp:o??!0,onChange:s,caller:No});return u.jsx(zt,{present:n||a,children:u.jsx(YE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel: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:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ag.displayName=No;var[qE,GE]=Tg(No,{onClose(){}}),YE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ai(No,n),[x,y]=h.useState(null),b=Le(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),T=o||g.duration,C=h.useRef(0),E=h.useRef(T),N=h.useRef(0),{onToastAdd:O,onToastRemove:$}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(N.current),C.current=new Date().getTime(),N.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},_=()=>{const D=new Date().getTime()-C.current;E.current=E.current-D,window.clearTimeout(N.current),l==null||l()};return I.addEventListener(zl,_),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,_),I.removeEventListener(Hl,W)}}},[g.viewport,T,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(T)},[s,T,g.isClosePausedRef,K]),h.useEffect(()=>(O(),()=>$()),[O,$]);const U=h.useMemo(()=>x?Dg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(XE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(qE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(_w,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),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,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ae(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ae(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,_=I.clientY-S.current.y,D=!!k.current,P=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=P?j(0,W):0,Z=P?0:j(0,_),R=I.pointerType==="touch"?10:2,M={x:G,y:Z},q={originalEvent:I,delta:M};D?(k.current=M,li(WE,p,q,{discrete:!1})):Lg(M,g.swipeDirection,R)?(k.current=M,li(UE,d,q,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>R||Math.abs(_)>R)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,I=>{const W=k.current,_=I.target;if(_.hasPointerCapture(I.pointerId)&&_.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const D=I.currentTarget,P={originalEvent:I,delta:W};Lg(W,g.swipeDirection,g.swipeThreshold)?li(KE,f,P,{discrete:!0}):li(VE,m,P,{discrete:!0}),D.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),XE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ai(No,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return QE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(to,{asChild:!0,children:u.jsx(Zs,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},JE="ToastTitle",jg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});jg.displayName=JE;var ZE="ToastDescription",_g=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});_g.displayName=ZE;var Pg="ToastAction",Rg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Og,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Pg}\`. Expected non-empty \`string\`.`),null)});Rg.displayName=Pg;var Mg="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=GE(Mg,n);return u.jsx(Og,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Wl.displayName=Mg;var Og=h.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 Dg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),eI(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(...Dg(r))}}),t}function li(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?Oi(o,s):o.dispatchEvent(s)}var Lg=(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 QE(e=()=>{}){const t=mt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function eI(e){return e.nodeType===e.ELEMENT_NODE}function tI(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var nI=kg,$g=Ig,Fg=Ag,Bg=jg,zg=_g,Hg=Rg,Ug=Wl;const rI=nI,Wg=h.forwardRef(({className:e,...t},n)=>u.jsx($g,{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}));Wg.displayName=$g.displayName;const oI=Dr.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"}}),Vg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Fg,{ref:r,className:te(oI({variant:t}),e),...n}));Vg.displayName=Fg.displayName;const sI=h.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{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}));sI.displayName=Hg.displayName;const Kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{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(fe.X,{className:"h-4 w-4"})}));Kg.displayName=Ug.displayName;const qg=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("text-sm font-semibold",e),...t}));qg.displayName=Bg.displayName;const Gg=h.forwardRef(({className:e,...t},n)=>u.jsx(zg,{ref:n,className:te("text-sm opacity-90",e),...t}));Gg.displayName=zg.displayName;function iI(){const{toasts:e}=Za();return u.jsxs(rI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Vg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(qg,{children:n}),r&&u.jsx(Gg,{children:r})]}),o,u.jsx(Kg,{})]},t)}),u.jsx(Wg,{})]})}var aI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},lI=h.createContext(void 0),cI={setTheme:e=>{},themes:[]},uI=()=>{var e;return(e=h.useContext(lI))!=null?e:cI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${aI.toString()})(${d})`}})});var dI=e=>{switch(e){case"success":return hI;case"info":return gI;case"warning":return mI;case"error":return xI;default:return null}},fI=Array(12).fill(0),pI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},fI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),hI=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"})),mI=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"})),gI=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"})),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:"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"})),vI=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"})),wI=()=>{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},Kl=1,bI=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:Kl++,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(SI(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)||Kl++;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}},Wt=new bI,yI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Wt.addToast({title:e,...t,id:n}),n},SI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",CI=yI,TI=()=>Wt.toasts,kI=()=>Wt.getActiveToasts();Object.assign(CI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:TI,getToasts:kI});function EI(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))}EI(`: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 ci(e){return e.label!==void 0}var II=3,NI="32px",AI="16px",Yg=4e3,jI=356,_I=14,PI=20,RI=200;function pn(...e){return e.filter(Boolean).join(" ")}function MI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var OI=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:S,toasts:k,expanded:T,removeToast:C,defaultRichColors:E,closeButton:N,style:O,cancelButtonStyle:$,actionButtonStyle:H,className:K="",descriptionClassName:U="",duration:I,position:W,gap:_,loadingIcon:D,expandByDefault:P,classNames:j,icons:G,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:R}=e,[M,q]=w.useState(null),[X,oe]=w.useState(null),[V,L]=w.useState(!1),[Y,J]=w.useState(!1),[ce,F]=w.useState(!1),[re,ue]=w.useState(!1),[le,xe]=w.useState(!1),[Ne,_e]=w.useState(0),[De,Ae]=w.useState(0),Be=w.useRef(f.duration||I||Yg),tt=w.useRef(null),qe=w.useRef(null),ze=S===0,it=S+1<=y,nt=f.type,Ze=f.dismissible!==!1,St=f.className||"",xt=f.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(we=>we.toastId===f.id)||0,[b,f.id]),Rt=w.useMemo(()=>{var we;return(we=f.closeButton)!=null?we:N},[f.closeButton,N]),Mt=w.useMemo(()=>f.duration||I||Yg,[f.duration,I]),Ct=w.useRef(0),Tt=w.useRef(0),kt=w.useRef(0),Ve=w.useRef(null),[ge,He]=W.split("-"),Ye=w.useMemo(()=>b.reduce((we,Me,Ue)=>Ue>=at?we:we+Me.height,0),[b,at]),vt=wI(),$t=f.invert||m,ne=nt==="loading";Tt.current=w.useMemo(()=>at*_+Ye,[at,Ye]),w.useEffect(()=>{Be.current=Mt},[Mt]),w.useEffect(()=>{L(!0)},[]),w.useEffect(()=>{let we=qe.current;if(we){let Me=we.getBoundingClientRect().height;return Ae(Me),x(Ue=>[{toastId:f.id,height:Me,position:f.position},...Ue]),()=>x(Ue=>Ue.filter(Et=>Et.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!V)return;let we=qe.current,Me=we.style.height;we.style.height="auto";let Ue=we.getBoundingClientRect().height;we.style.height=Me,Ae(Ue),x(Et=>Et.find(Ke=>Ke.toastId===f.id)?Et.map(Ke=>Ke.toastId===f.id?{...Ke,height:Ue}:Ke):[{toastId:f.id,height:Ue,position:f.position},...Et])},[V,f.title,f.description,x,f.id]);let Se=w.useCallback(()=>{J(!0),_e(Tt.current),x(we=>we.filter(Me=>Me.toastId!==f.id)),setTimeout(()=>{C(f)},RI)},[f,C,x,Tt]);w.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let we;return T||g||R&&vt?(()=>{if(kt.current<Ct.current){let Me=new Date().getTime()-Ct.current;Be.current=Be.current-Me}kt.current=new Date().getTime()})():Be.current!==1/0&&(Ct.current=new Date().getTime(),we=setTimeout(()=>{var Me;(Me=f.onAutoClose)==null||Me.call(f,f),Se()},Be.current)),()=>clearTimeout(we)},[T,g,f,nt,R,vt,Se]),w.useEffect(()=>{f.delete&&Se()},[Se,f.delete]);function dt(){var we,Me,Ue;return G!=null&&G.loading?w.createElement("div",{className:pn(j==null?void 0:j.loader,(we=f==null?void 0:f.classNames)==null?void 0:we.loader,"sonner-loader"),"data-visible":nt==="loading"},G.loading):D?w.createElement("div",{className:pn(j==null?void 0:j.loader,(Me=f==null?void 0:f.classNames)==null?void 0:Me.loader,"sonner-loader"),"data-visible":nt==="loading"},D):w.createElement(pI,{className:pn(j==null?void 0:j.loader,(Ue=f==null?void 0:f.classNames)==null?void 0:Ue.loader),visible:nt==="loading"})}return w.createElement("li",{tabIndex:0,ref:qe,className:pn(K,St,j==null?void 0:j.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,j==null?void 0:j.default,j==null?void 0:j[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":le,"data-removed":Y,"data-visible":it,"data-y-position":ge,"data-x-position":He,"data-index":S,"data-front":ze,"data-swiping":ce,"data-dismissible":Ze,"data-type":nt,"data-invert":$t,"data-swipe-out":re,"data-swipe-direction":X,"data-expanded":!!(T||P&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Y?Ne:Tt.current}px`,"--initial-height":P?"auto":`${De}px`,...O,...f.style},onDragEnd:()=>{F(!1),q(null),Ve.current=null},onPointerDown:we=>{ne||!Ze||(tt.current=new Date,_e(Tt.current),we.target.setPointerCapture(we.pointerId),we.target.tagName!=="BUTTON"&&(F(!0),Ve.current={x:we.clientX,y:we.clientY}))},onPointerUp:()=>{var we,Me,Ue,Et;if(re||!Ze)return;Ve.current=null;let Ke=Number(((we=qe.current)==null?void 0:we.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),wt=Number(((Me=qe.current)==null?void 0:Me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((Ue=tt.current)==null?void 0:Ue.getTime()),Xe=M==="x"?Ke:wt,Vt=Math.abs(Xe)/Fe;if(Math.abs(Xe)>=PI||Vt>.11){_e(Tt.current),(Et=f.onDismiss)==null||Et.call(f,f),oe(M==="x"?Ke>0?"right":"left":wt>0?"down":"up"),Se(),ue(!0),xe(!1);return}F(!1),q(null)},onPointerMove:we=>{var Me,Ue,Et,Ke;if(!Ve.current||!Ze||((Me=window.getSelection())==null?void 0:Me.toString().length)>0)return;let wt=we.clientY-Ve.current.y,Fe=we.clientX-Ve.current.x,Xe=(Ue=e.swipeDirections)!=null?Ue:MI(W);!M&&(Math.abs(Fe)>1||Math.abs(wt)>1)&&q(Math.abs(Fe)>Math.abs(wt)?"x":"y");let Vt={x:0,y:0};M==="y"?(Xe.includes("top")||Xe.includes("bottom"))&&(Xe.includes("top")&&wt<0||Xe.includes("bottom")&&wt>0)&&(Vt.y=wt):M==="x"&&(Xe.includes("left")||Xe.includes("right"))&&(Xe.includes("left")&&Fe<0||Xe.includes("right")&&Fe>0)&&(Vt.x=Fe),(Math.abs(Vt.x)>0||Math.abs(Vt.y)>0)&&xe(!0),(Et=qe.current)==null||Et.style.setProperty("--swipe-amount-x",`${Vt.x}px`),(Ke=qe.current)==null||Ke.style.setProperty("--swipe-amount-y",`${Vt.y}px`)}},Rt&&!f.jsx?w.createElement("button",{"aria-label":Z,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Ze?()=>{}:()=>{var we;Se(),(we=f.onDismiss)==null||we.call(f,f)},className:pn(j==null?void 0:j.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:vI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,nt||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:pn(j==null?void 0:j.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||dt():null,f.type!=="loading"?f.icon||(G==null?void 0:G[nt])||dI(nt):null):null,w.createElement("div",{"data-content":"",className:pn(j==null?void 0:j.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:pn(j==null?void 0:j.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:pn(U,xt,j==null?void 0:j.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&&ci(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:we=>{var Me,Ue;ci(f.cancel)&&Ze&&((Ue=(Me=f.cancel).onClick)==null||Ue.call(Me,we),Se())},className:pn(j==null?void 0:j.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&&ci(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:we=>{var Me,Ue;ci(f.action)&&((Ue=(Me=f.action).onClick)==null||Ue.call(Me,we),!we.defaultPrevented&&Se())},className:pn(j==null?void 0:j.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Xg(){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 DI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?AI:NI;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 LI=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:p,duration:m,style:f,visibleToasts:v=II,toastOptions:g,dir:x=Xg(),gap:y=_I,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:T}=e,[C,E]=w.useState([]),N=w.useMemo(()=>Array.from(new Set([r].concat(C.filter(R=>R.position).map(R=>R.position)))),[C,r]),[O,$]=w.useState([]),[H,K]=w.useState(!1),[U,I]=w.useState(!1),[W,_]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=w.useRef(null),G=w.useRef(!1),Z=w.useCallback(R=>{E(M=>{var q;return(q=M.find(X=>X.id===R.id))!=null&&q.delete||Wt.dismiss(R.id),M.filter(({id:X})=>X!==R.id)})},[]);return w.useEffect(()=>Wt.subscribe(R=>{if(R.dismiss){E(M=>M.map(q=>q.id===R.id?{...q,delete:!0}:q));return}setTimeout(()=>{Ao.flushSync(()=>{E(M=>{let q=M.findIndex(X=>X.id===R.id);return q!==-1?[...M.slice(0,q),{...M[q],...R},...M.slice(q+1)]:[R,...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 R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:M})=>{_(M?"dark":"light")})}catch{R.addListener(({matches:q})=>{try{_(q?"dark":"light")}catch(X){console.error(X)}})}},[d]),w.useEffect(()=>{C.length<=1&&K(!1)},[C]),w.useEffect(()=>{let R=M=>{var q,X;o.every(oe=>M[oe]||M.code===oe)&&(K(!0),(q=D.current)==null||q.focus()),M.code==="Escape"&&(document.activeElement===D.current||(X=D.current)!=null&&X.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[o]),w.useEffect(()=>{if(D.current)return()=>{j.current&&(j.current.focus({preventScroll:!0}),j.current=null,G.current=!1)}},[D.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((R,M)=>{var q;let[X,oe]=R.split("-");return C.length?w.createElement("ol",{key:R,dir:x==="auto"?Xg():x,tabIndex:-1,ref:D,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":X,"data-lifted":H&&C.length>1&&!s,"data-x-position":oe,style:{"--front-toast-height":`${((q=O[0])==null?void 0:q.height)||0}px`,"--width":`${jI}px`,"--gap":`${y}px`,...f,...DI(l,c)},onBlur:V=>{G.current&&!V.currentTarget.contains(V.relatedTarget)&&(G.current=!1,j.current&&(j.current.focus({preventScroll:!0}),j.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||G.current||(G.current=!0,j.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{U||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},C.filter(V=>!V.position&&M===0||V.position===R).map((V,L)=>{var Y,J;return w.createElement(OI,{key:V.id,icons:S,index:L,toast:V,defaultRichColors:p,duration:(Y=g==null?void 0:g.duration)!=null?Y:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:U,position:R,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:Z,toasts:C.filter(ce=>ce.position==V.position),heights:O.filter(ce=>ce.position==V.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:H,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const $I=({...e})=>{const{theme:t="system"}=uI();return u.jsx(LI,{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=Rv,B.ApiClient=Pv,B.ApiProvider=tu,B.ArtifactRenderer=yh,B.Badge=Fp,B.Button=lt,B.Card=tl,B.CardContent=sl,B.CardDescription=ol,B.CardHeader=nl,B.CardTitle=rl,B.ChatApi=Uo,B.ChatApp=yk,B.ChatInput=Bf,B.ChatInterface=Co,B.ChatProviders=Xr,B.Command=gl,B.CommandEmpty=wl,B.CommandGroup=bl,B.CommandInput=xl,B.CommandItem=yl,B.CommandList=vl,B.DEFAULT_TIMEOUT_MS=Yc,B.Dialog=Ya,B.DialogContent=Ls,B.DialogHeader=$s,B.DialogTitle=Fs,B.DropdownMenu=ws,B.DropdownMenuContent=lo,B.DropdownMenuItem=Ln,B.DropdownMenuTrigger=bs,B.FileViewerModal=sh,B.HISTORY_TIMEOUT_MS=Xc,B.Input=Nl,B.InterruptPartRenderer=Ch,B.Label=um,B.MarkdownContent=Ar,B.MessageBody=Nh,B.MessageComponent=Ks,B.MessageList=cl,B.MessageRow=ll,B.PlotArtifact=wh,B.ResearchTaskArtifact=bh,B.SETTINGS_STORAGE_KEY=Mi,B.ScrollArea=Il,B.Select=tE,B.SelectContent=Jm,B.SelectItem=Zm,B.SelectTrigger=Gm,B.SelectValue=nE,B.Separator=ng,B.Sheet=pE,B.SheetContent=dg,B.SheetDescription=hg,B.SheetHeader=fg,B.SheetTitle=pg,B.SheetTrigger=hE,B.SimpleChat=Sk,B.SimpleJsonView=il,B.Sonner=$I,B.StreamProgress=Th,B.Switch=cg,B.Textarea=ba,B.ThinkingIndicator=Eh,B.ThreadListItem=om,B.ThreadManager=Al,B.ThreadStateProvider=Su,B.ThreadsProvider=au,B.TimelineColumn=cx,B.Toaster=iI,B.ToolComponent=kh,B.Tooltip=LE,B.TooltipContent=Cg,B.TooltipProvider=DE,B.TooltipTrigger=$E,B.UserTextContent=Ih,B.applySettings=mw,B.buildCheckpointIndex=Ql,B.buildCheckpointPreviewMap=nx,B.chatApiClient=_n,B.del=ki,B.downloadFileById=Zc,B.extractConfigFields=di,B.fileToBase64=nu,B.get=Yt,B.getChatToken=qc,B.getCheckpointForMessage=rx,B.getCurrentSettings=hw,B.getDefaultApiConfig=_u,B.getDefaultChatSettings=Pu,B.getFileContent=Ii,B.getFileInfo=Ov,B.getMessageAttemptInfo=ec,B.getMessageDomKey=al,B.getPreviewForMessage=ui,B.httpClient=Gt,B.hydrateHistorySnapshots=jn,B.isEnvelope=ou,B.listFiles=Qc,B.loadStoredSettings=Ru,B.onChatTokenChanged=Gc,B.post=Ho,B.processAttachments=ru,B.put=Jc,B.readNumber=nc,B.readString=An,B.resolveChatBaseUrl=mn,B.saveSettings=Mu,B.setChatToken=zo,B.toPlainObject=Nn,B.unwrap=Ot,B.useApi=Vr,B.useCheckpointIndex=tc,B.useFilePreview=Ah,B.useHasChatSession=dw,B.useParsedMessageContent=jh,B.useShallowStableValue=Iu,B.useStream=Ri,B.useStreamingHook=Ri,B.useThreadHistoryState=vu,B.useThreadManagerViewState=am,B.useThreadState=Yr,B.useThreadStateUpdater=yu,B.useThreads=pr,B.useThreadsState=su,B.viewFileById=Mv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|