teodor-new-chat-ui 4.3.28 → 4.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1178 -1151
- package/dist/index.umd.js +20 -20
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Ne,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(Ne=typeof globalThis<"u"?globalThis:Ne||self,w(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,w,
|
|
1
|
+
(function(Ne,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(Ne=typeof globalThis<"u"?globalThis:Ne||self,w(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,w,ue,ir,Po,km,Em,di){"use strict";var PT=Object.defineProperty;var OT=(Ne,w,ue)=>w in Ne?PT(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:ue}):Ne[w]=ue;var Cm=(Ne,w,ue)=>OT(Ne,typeof w!="symbol"?w+"":w,ue);function Cl(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 m=Cl(w),Oo=Cl(di);var fi={exports:{}},Gr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -14,28 +14,28 @@
|
|
|
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 kl;function Nm(){return kl||(kl=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"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var
|
|
18
|
-
`+
|
|
17
|
+
*/var kl;function Nm(){return kl||(kl=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"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var H=v&&k[v]||k[x];return typeof H=="function"?H:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(k){{for(var H=arguments.length,se=new Array(H>1?H-1:0),Ce=1;Ce<H;Ce++)se[Ce-1]=arguments[Ce];S("error",k,se)}}function S(k,H,se){{var Ce=y.ReactDebugCurrentFrame,Ge=Ce.getStackAddendum();Ge!==""&&(H+="%s",se=se.concat([Ge]));var Qe=se.map(function(He){return String(He)});Qe.unshift("Warning: "+H),Function.prototype.apply.call(console[k],console,Qe)}}var E=!1,C=!1,T=!1,I=!1,_=!1,R;R=Symbol.for("react.module.reference");function j(k){return!!(typeof k=="string"||typeof k=="function"||k===r||k===s||_||k===o||k===u||k===d||I||k===p||E||C||T||typeof k=="object"&&k!==null&&(k.$$typeof===h||k.$$typeof===f||k.$$typeof===i||k.$$typeof===a||k.$$typeof===l||k.$$typeof===R||k.getModuleId!==void 0))}function z(k,H,se){var Ce=k.displayName;if(Ce)return Ce;var Ge=H.displayName||H.name||"";return Ge!==""?se+"("+Ge+")":se}function L(k){return k.displayName||"Context"}function B(k){if(k==null)return null;if(typeof k.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof k=="object")switch(k.$$typeof){case a:var H=k;return L(H)+".Consumer";case i:var se=k;return L(se._context)+".Provider";case l:return z(k,k.render,"ForwardRef");case f:var Ce=k.displayName||null;return Ce!==null?Ce:B(k.type)||"Memo";case h:{var Ge=k,Qe=Ge._payload,He=Ge._init;try{return B(He(Qe))}catch{return null}}}return null}var M=Object.assign,q=0,U,te,$,F,ie,O,G;function ce(){}ce.__reactDisabledLog=!0;function be(){{if(q===0){U=console.log,te=console.info,$=console.warn,F=console.error,ie=console.group,O=console.groupCollapsed,G=console.groupEnd;var k={configurable:!0,enumerable:!0,value:ce,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}q++}}function ge(){{if(q--,q===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},k,{value:U}),info:M({},k,{value:te}),warn:M({},k,{value:$}),error:M({},k,{value:F}),group:M({},k,{value:ie}),groupCollapsed:M({},k,{value:O}),groupEnd:M({},k,{value:G})})}q<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=y.ReactCurrentDispatcher,V;function D(k,H,se){{if(V===void 0)try{throw Error()}catch(Ge){var Ce=Ge.stack.trim().match(/\n( *(at )?)/);V=Ce&&Ce[1]||""}return`
|
|
18
|
+
`+V+k}}var X=!1,Z;{var fe=typeof WeakMap=="function"?WeakMap:Map;Z=new fe}function ae(k,H){if(!k||X)return"";{var se=Z.get(k);if(se!==void 0)return se}var Ce;X=!0;var Ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Qe;Qe=ye.current,ye.current=null,be();try{if(H){var He=function(){throw Error()};if(Object.defineProperty(He.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(He,[])}catch(jt){Ce=jt}Reflect.construct(k,[],He)}else{try{He.call()}catch(jt){Ce=jt}k.call(He.prototype)}}else{try{throw Error()}catch(jt){Ce=jt}k()}}catch(jt){if(jt&&Ce&&typeof jt.stack=="string"){for(var Ae=jt.stack.split(`
|
|
19
19
|
`),Nt=Ce.stack.split(`
|
|
20
20
|
`),pt=Ae.length-1,gt=Nt.length-1;pt>=1&>>=0&&Ae[pt]!==Nt[gt];)gt--;for(;pt>=1&>>=0;pt--,gt--)if(Ae[pt]!==Nt[gt]){if(pt!==1||gt!==1)do if(pt--,gt--,gt<0||Ae[pt]!==Nt[gt]){var Ht=`
|
|
21
|
-
`+Ae[pt].replace(" at new "," at ");return k.displayName&&Ht.includes("<anonymous>")&&(Ht=Ht.replace("<anonymous>",k.displayName)),typeof k=="function"&&Z.set(k,Ht),Ht}while(pt>=1&>>=0);break}}}finally{X=!1,ye.current=Qe,ge(),Error.prepareStackTrace=Ge}var Un=k?k.displayName||k.name:"",en=Un?D(Un):"";return typeof k=="function"&&Z.set(k,en),en}function Q(k,
|
|
21
|
+
`+Ae[pt].replace(" at new "," at ");return k.displayName&&Ht.includes("<anonymous>")&&(Ht=Ht.replace("<anonymous>",k.displayName)),typeof k=="function"&&Z.set(k,Ht),Ht}while(pt>=1&>>=0);break}}}finally{X=!1,ye.current=Qe,ge(),Error.prepareStackTrace=Ge}var Un=k?k.displayName||k.name:"",en=Un?D(Un):"";return typeof k=="function"&&Z.set(k,en),en}function Q(k,H,se){return ae(k,!1)}function tt(k){var H=k.prototype;return!!(H&&H.isReactComponent)}function Ze(k,H,se){if(k==null)return"";if(typeof k=="function")return ae(k,tt(k));if(typeof k=="string")return D(k);switch(k){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case l:return Q(k.render);case f:return Ze(k.type,H,se);case h:{var Ce=k,Ge=Ce._payload,Qe=Ce._init;try{return Ze(Qe(Ge),H,se)}catch{}}}return""}var Re=Object.prototype.hasOwnProperty,ze={},nt=y.ReactDebugCurrentFrame;function rt(k){if(k){var H=k._owner,se=Ze(k.type,k._source,H?H.type:null);nt.setExtraStackFrame(se)}else nt.setExtraStackFrame(null)}function Pe(k,H,se,Ce,Ge){{var Qe=Function.call.bind(Re);for(var He in k)if(Qe(k,He)){var Ae=void 0;try{if(typeof k[He]!="function"){var Nt=Error((Ce||"React class")+": "+se+" type `"+He+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof k[He]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Nt.name="Invariant Violation",Nt}Ae=k[He](H,He,Ce,se,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pt){Ae=pt}Ae&&!(Ae instanceof Error)&&(rt(Ge),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).",Ce||"React class",se,He,typeof Ae),rt(null)),Ae instanceof Error&&!(Ae.message in ze)&&(ze[Ae.message]=!0,rt(Ge),b("Failed %s type: %s",se,Ae.message),rt(null))}}}var St=Array.isArray;function Ct(k){return St(k)}function kt(k){{var H=typeof Symbol=="function"&&Symbol.toStringTag,se=H&&k[Symbol.toStringTag]||k.constructor.name||"Object";return se}}function ut(k){try{return et(k),!1}catch{return!0}}function et(k){return""+k}function Be(k){if(ut(k))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kt(k)),et(k)}var dt=y.ReactCurrentOwner,re={key:!0,ref:!0,__self:!0,__source:!0},oe,xe;function Me(k){if(Re.call(k,"ref")){var H=Object.getOwnPropertyDescriptor(k,"ref").get;if(H&&H.isReactWarning)return!1}return k.ref!==void 0}function Le(k){if(Re.call(k,"key")){var H=Object.getOwnPropertyDescriptor(k,"key").get;if(H&&H.isReactWarning)return!1}return k.key!==void 0}function qe(k,H){typeof k.ref=="string"&&dt.current}function bt(k,H){{var se=function(){oe||(oe=!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)",H))};se.isReactWarning=!0,Object.defineProperty(k,"key",{get:se,configurable:!0})}}function ot(k,H){{var se=function(){xe||(xe=!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)",H))};se.isReactWarning=!0,Object.defineProperty(k,"ref",{get:se,configurable:!0})}}var ht=function(k,H,se,Ce,Ge,Qe,He){var Ae={$$typeof:t,type:k,key:H,ref:se,props:He,_owner:Qe};return Ae._store={},Object.defineProperty(Ae._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ae,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ce}),Object.defineProperty(Ae,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ge}),Object.freeze&&(Object.freeze(Ae.props),Object.freeze(Ae)),Ae};function Kt(k,H,se,Ce,Ge){{var Qe,He={},Ae=null,Nt=null;se!==void 0&&(Be(se),Ae=""+se),Le(H)&&(Be(H.key),Ae=""+H.key),Me(H)&&(Nt=H.ref,qe(H,Ge));for(Qe in H)Re.call(H,Qe)&&!re.hasOwnProperty(Qe)&&(He[Qe]=H[Qe]);if(k&&k.defaultProps){var pt=k.defaultProps;for(Qe in pt)He[Qe]===void 0&&(He[Qe]=pt[Qe])}if(Ae||Nt){var gt=typeof k=="function"?k.displayName||k.name||"Unknown":k;Ae&&bt(He,gt),Nt&&ot(He,gt)}return ht(k,Ae,Nt,Ge,Ce,dt.current,He)}}var Qt=y.ReactCurrentOwner,Er=y.ReactDebugCurrentFrame;function Hn(k){if(k){var H=k._owner,se=Ze(k.type,k._source,H?H.type:null);Er.setExtraStackFrame(se)}else Er.setExtraStackFrame(null)}var Ir;Ir=!1;function Pn(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function Et(){{if(Qt.current){var k=B(Qt.current.type);if(k)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+k+"`."}return""}}function _o(k){return""}var rr={};function It(k){{var
|
|
23
|
+
Check the render method of \``+k+"`."}return""}}function _o(k){return""}var rr={};function It(k){{var H=Et();if(!H){var se=typeof k=="string"?k:k.displayName||k.name;se&&(H=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+se+">.")}return
|
|
25
|
+
Check the top-level render call using <`+se+">.")}return H}}function yn(k,H){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var se=It(H);if(rr[se])return;rr[se]=!0;var Ce="";k&&k._owner&&k._owner!==Qt.current&&(Ce=" It was passed a child from "+B(k._owner.type)+"."),Hn(k),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',se,Ce),Hn(null)}}function On(k,H){{if(typeof k!="object")return;if(Ct(k))for(var se=0;se<k.length;se++){var Ce=k[se];Pn(Ce)&&yn(Ce,H)}else if(Pn(k))k._store&&(k._store.validated=!0);else if(k){var Ge=g(k);if(typeof Ge=="function"&&Ge!==k.entries)for(var Qe=Ge.call(k),He;!(He=Qe.next()).done;)Pn(He.value)&&yn(He.value,H)}}}function Kr(k){{var H=k.type;if(H==null||typeof H=="string")return;var se;if(typeof H=="function")se=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))se=H.propTypes;else return;if(se){var Ce=B(H);Pe(se,k.props,"prop",Ce,k)}else if(H.PropTypes!==void 0&&!Ir){Ir=!0;var Ge=B(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ge||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function cn(k){{for(var H=Object.keys(k.props),se=0;se<H.length;se++){var Ce=H[se];if(Ce!=="children"&&Ce!=="key"){Hn(k),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),Hn(null);break}}k.ref!==null&&(Hn(k),b("Invalid attribute `ref` supplied to `React.Fragment`."),Hn(null))}}var or={};function vn(k,H,se,Ce,Ge,Qe){{var He=j(k);if(!He){var Ae="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(Ae+=" 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 Nt=_o();Nt?Ae+=Nt:Ae+=Et();var pt;k===null?pt="null":Ct(k)?pt="array":k!==void 0&&k.$$typeof===t?(pt="<"+(B(k.type)||"Unknown")+" />",Ae=" Did you accidentally export a JSX literal instead of a component?"):pt=typeof k,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pt,Ae)}var gt=Kt(k,H,se,Ge,Qe);if(gt==null)return gt;if(He){var Ht=H.children;if(Ht!==void 0)if(Ce)if(Ct(Ht)){for(var Un=0;Un<Ht.length;Un++)On(Ht[Un],k);Object.freeze&&Object.freeze(Ht)}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 On(Ht,k)}if(Re.call(H,"key")){var en=B(k),jt=Object.keys(H).filter(function(bl){return bl!=="key"}),jo=jt.length>0?"{key: someKey, "+jt.join(": ..., ")+": ...}":"{key: someKey}";if(!or[en+jo]){var vl=jt.length>0?"{"+jt.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} />`,jo,en,vl,en),or[en+jo]=!0}}return k===r?cn(gt):Kr(gt),gt}}function Mn(k,B,se){return vn(k,B,se,!0)}function pe(k,B,se){return vn(k,B,se,!1)}var Ie=pe,Xe=Mn;Yr.Fragment=r,Yr.jsx=Ie,Yr.jsxs=Xe}()),Yr}process.env.NODE_ENV==="production"?fi.exports=Im():fi.exports=Nm();var c=fi.exports;function El(e,t){return function(){return e.apply(t,arguments)}}const{toString:Am}=Object.prototype,{getPrototypeOf:hi}=Object,{iterator:Mo,toStringTag:Il}=Symbol,Do=(e=>t=>{const n=Am.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),un=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:Ar}=Array,_r=Lo("undefined");function Xr(e){return e!==null&&!_r(e)&&e.constructor!==null&&!_r(e.constructor)&&Ut(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Nl=un("ArrayBuffer");function _m(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Nl(e.buffer),t}const jm=Lo("string"),Ut=Lo("function"),Al=Lo("number"),Jr=e=>e!==null&&typeof e=="object",Rm=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=hi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Il in e)&&!(Mo in e)},Pm=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Om=un("Date"),Mm=un("File"),Dm=un("Blob"),Lm=un("FileList"),$m=e=>Jr(e)&&Ut(e.pipe),Fm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ut(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ut(e.toString)&&e.toString()==="[object FormData]"))},zm=un("URLSearchParams"),[Bm,Hm,Um,Wm]=["ReadableStream","Request","Response","Headers"].map(un),Vm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Ar(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 _l(e,t){if(Xr(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 ar=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jl=e=>!_r(e)&&e!==ar;function pi(){const{caseless:e,skipUndefined:t}=jl(this)&&this||{},n={},r=(o,s)=>{const i=e&&_l(n,s)||s;$o(n[i])&&$o(o)?n[i]=pi(n[i],o):$o(o)?n[i]=pi({},o):Ar(o)?n[i]=o.slice():(!t||!_r(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const Km=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Ut(o)?e[s]=El(o,n):e[s]=o},{allOwnKeys:r}),e),qm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gm=(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)},Ym=(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&&hi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xm=(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},Jm=e=>{if(!e)return null;if(Ar(e))return e;let t=e.length;if(!Al(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hi(Uint8Array)),Qm=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},eg=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tg=un("HTMLFormElement"),ng=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Rl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rg=un("RegExp"),Pl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},og=e=>{Pl(e,(t,n)=>{if(Ut(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ut(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+"'")})}})},sg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Ar(e)?r(e):r(String(e).split(t)),n},ig=()=>{},ag=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lg(e){return!!(e&&Ut(e.append)&&e[Il]==="FormData"&&e[Mo])}const cg=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Ar(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!_r(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ug=un("AsyncFunction"),dg=e=>e&&(Jr(e)||Ut(e))&&Ut(e.then)&&Ut(e.catch),Ol=((e,t)=>e?setImmediate:t?((n,r)=>(ar.addEventListener("message",({source:o,data:s})=>{o===ar&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ar.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ut(ar.postMessage)),fg=typeof queueMicrotask<"u"?queueMicrotask.bind(ar):typeof process<"u"&&process.nextTick||Ol,P={isArray:Ar,isArrayBuffer:Nl,isBuffer:Xr,isFormData:Fm,isArrayBufferView:_m,isString:jm,isNumber:Al,isBoolean:Rm,isObject:Jr,isPlainObject:$o,isEmptyObject:Pm,isReadableStream:Bm,isRequest:Hm,isResponse:Um,isHeaders:Wm,isUndefined:_r,isDate:Om,isFile:Mm,isBlob:Dm,isRegExp:rg,isFunction:Ut,isStream:$m,isURLSearchParams:zm,isTypedArray:Zm,isFileList:Lm,forEach:Zr,merge:pi,extend:Km,trim:Vm,stripBOM:qm,inherits:Gm,toFlatObject:Ym,kindOf:Do,kindOfTest:un,endsWith:Xm,toArray:Jm,forEachEntry:Qm,matchAll:eg,isHTMLForm:tg,hasOwnProperty:Rl,hasOwnProp:Rl,reduceDescriptors:Pl,freezeMethods:og,toObjectSet:sg,toCamelCase:ng,noop:ig,toFiniteNumber:ag,findKey:_l,global:ar,isContextDefined:jl,isSpecCompliantForm:lg,toJSONObject:cg,isAsyncFn:ug,isThenable:dg,setImmediate:Ol,asap:fg,isIterable:e=>e!=null&&Ut(e[Mo])};function je(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)}P.inherits(je,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:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ml=je.prototype,Dl={};["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=>{Dl[e]={value:e}}),Object.defineProperties(je,Dl),Object.defineProperty(Ml,"isAxiosError",{value:!0}),je.from=(e,t,n,r,o,s)=>{const i=Object.create(Ml);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return je.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 hg=null;function mi(e){return P.isPlainObject(e)||P.isArray(e)}function Ll(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function $l(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ll(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pg(e){return P.isArray(e)&&!e.some(mi)}const mg=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!P.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(P.isDate(v))return v.toISOString();if(P.isBoolean(v))return v.toString();if(!l&&P.isBlob(v))throw new je("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(v)||P.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(P.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(P.isArray(v)&&pg(v)||(P.isFileList(v)||P.endsWith(x,"[]"))&&(y=P.toArray(v)))return x=Ll(x),y.forEach(function(S,E){!(P.isUndefined(S)||S===null)&&t.append(i===!0?$l([x],E,s):i===null?x:x+"[]",u(S))}),!1}return mi(v)?!0:(t.append($l(g,x,s),u(v)),!1)}const f=[],h=Object.assign(mg,{defaultVisitor:d,convertValue:u,isVisitable:mi});function p(v,x){if(!P.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),P.forEach(v,function(y,b){(!(P.isUndefined(y)||y===null)&&o.call(t,y,P.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Fl(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&&Fo(e,this,t)}const zl=gi.prototype;zl.append=function(t,n){this._pairs.push([t,n])},zl.toString=function(t){const n=t?function(r){return t.call(this,r,Fl)}:Fl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function gg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Bl(e,t,n){if(!t)return e;const r=n&&n.encode||gg;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.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 Hl{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){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ul={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xg={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",yi=typeof navigator=="object"&&navigator||void 0,yg=xi&&(!yi||["ReactNative","NativeScript","NS"].indexOf(yi.product)<0),vg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bg=xi&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:vg,navigator:yi,origin:bg},Symbol.toStringTag,{value:"Module"})),...xg};function wg(e,t){return Fo(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sg(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cg(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 Wl(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&&P.isArray(o)?o.length:i,l?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=Cg(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(Sg(r),o,n,0)}),n}return null}function Tg(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Qr={transitional:Ul,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(Wl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.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 wg(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Tg(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.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"?je.from(a,je.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:Mt.classes.FormData,Blob:Mt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{Qr.headers[e]={}});const kg=P.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"]),Eg=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,jo,en,vl,en),or[en+jo]=!0}}return k===r?cn(gt):Kr(gt),gt}}function Mn(k,H,se){return vn(k,H,se,!0)}function me(k,H,se){return vn(k,H,se,!1)}var Ie=me,Xe=Mn;Yr.Fragment=r,Yr.jsx=Ie,Yr.jsxs=Xe}()),Yr}process.env.NODE_ENV==="production"?fi.exports=Im():fi.exports=Nm();var c=fi.exports;function El(e,t){return function(){return e.apply(t,arguments)}}const{toString:Am}=Object.prototype,{getPrototypeOf:hi}=Object,{iterator:Mo,toStringTag:Il}=Symbol,Do=(e=>t=>{const n=Am.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),un=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:Ar}=Array,_r=Lo("undefined");function Xr(e){return e!==null&&!_r(e)&&e.constructor!==null&&!_r(e.constructor)&&Ut(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Nl=un("ArrayBuffer");function _m(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Nl(e.buffer),t}const jm=Lo("string"),Ut=Lo("function"),Al=Lo("number"),Jr=e=>e!==null&&typeof e=="object",Rm=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=hi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Il in e)&&!(Mo in e)},Pm=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Om=un("Date"),Mm=un("File"),Dm=un("Blob"),Lm=un("FileList"),$m=e=>Jr(e)&&Ut(e.pipe),Fm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ut(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ut(e.toString)&&e.toString()==="[object FormData]"))},zm=un("URLSearchParams"),[Bm,Hm,Um,Wm]=["ReadableStream","Request","Response","Headers"].map(un),Vm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Ar(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 _l(e,t){if(Xr(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 ar=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,jl=e=>!_r(e)&&e!==ar;function pi(){const{caseless:e,skipUndefined:t}=jl(this)&&this||{},n={},r=(o,s)=>{const i=e&&_l(n,s)||s;$o(n[i])&&$o(o)?n[i]=pi(n[i],o):$o(o)?n[i]=pi({},o):Ar(o)?n[i]=o.slice():(!t||!_r(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const Km=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Ut(o)?e[s]=El(o,n):e[s]=o},{allOwnKeys:r}),e),qm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Gm=(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)},Ym=(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&&hi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Xm=(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},Jm=e=>{if(!e)return null;if(Ar(e))return e;let t=e.length;if(!Al(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Zm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hi(Uint8Array)),Qm=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},eg=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},tg=un("HTMLFormElement"),ng=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Rl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),rg=un("RegExp"),Pl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},og=e=>{Pl(e,(t,n)=>{if(Ut(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ut(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+"'")})}})},sg=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Ar(e)?r(e):r(String(e).split(t)),n},ig=()=>{},ag=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lg(e){return!!(e&&Ut(e.append)&&e[Il]==="FormData"&&e[Mo])}const cg=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Ar(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!_r(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ug=un("AsyncFunction"),dg=e=>e&&(Jr(e)||Ut(e))&&Ut(e.then)&&Ut(e.catch),Ol=((e,t)=>e?setImmediate:t?((n,r)=>(ar.addEventListener("message",({source:o,data:s})=>{o===ar&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ar.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ut(ar.postMessage)),fg=typeof queueMicrotask<"u"?queueMicrotask.bind(ar):typeof process<"u"&&process.nextTick||Ol,P={isArray:Ar,isArrayBuffer:Nl,isBuffer:Xr,isFormData:Fm,isArrayBufferView:_m,isString:jm,isNumber:Al,isBoolean:Rm,isObject:Jr,isPlainObject:$o,isEmptyObject:Pm,isReadableStream:Bm,isRequest:Hm,isResponse:Um,isHeaders:Wm,isUndefined:_r,isDate:Om,isFile:Mm,isBlob:Dm,isRegExp:rg,isFunction:Ut,isStream:$m,isURLSearchParams:zm,isTypedArray:Zm,isFileList:Lm,forEach:Zr,merge:pi,extend:Km,trim:Vm,stripBOM:qm,inherits:Gm,toFlatObject:Ym,kindOf:Do,kindOfTest:un,endsWith:Xm,toArray:Jm,forEachEntry:Qm,matchAll:eg,isHTMLForm:tg,hasOwnProperty:Rl,hasOwnProp:Rl,reduceDescriptors:Pl,freezeMethods:og,toObjectSet:sg,toCamelCase:ng,noop:ig,toFiniteNumber:ag,findKey:_l,global:ar,isContextDefined:jl,isSpecCompliantForm:lg,toJSONObject:cg,isAsyncFn:ug,isThenable:dg,setImmediate:Ol,asap:fg,isIterable:e=>e!=null&&Ut(e[Mo])};function je(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)}P.inherits(je,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:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ml=je.prototype,Dl={};["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=>{Dl[e]={value:e}}),Object.defineProperties(je,Dl),Object.defineProperty(Ml,"isAxiosError",{value:!0}),je.from=(e,t,n,r,o,s)=>{const i=Object.create(Ml);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return je.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 hg=null;function mi(e){return P.isPlainObject(e)||P.isArray(e)}function Ll(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function $l(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ll(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function pg(e){return P.isArray(e)&&!e.some(mi)}const mg=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!P.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(P.isDate(v))return v.toISOString();if(P.isBoolean(v))return v.toString();if(!l&&P.isBlob(v))throw new je("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(v)||P.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,x,g){let y=v;if(v&&!g&&typeof v=="object"){if(P.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(P.isArray(v)&&pg(v)||(P.isFileList(v)||P.endsWith(x,"[]"))&&(y=P.toArray(v)))return x=Ll(x),y.forEach(function(S,E){!(P.isUndefined(S)||S===null)&&t.append(i===!0?$l([x],E,s):i===null?x:x+"[]",u(S))}),!1}return mi(v)?!0:(t.append($l(g,x,s),u(v)),!1)}const f=[],h=Object.assign(mg,{defaultVisitor:d,convertValue:u,isVisitable:mi});function p(v,x){if(!P.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(v),P.forEach(v,function(y,b){(!(P.isUndefined(y)||y===null)&&o.call(t,y,P.isString(b)?b.trim():b,x,h))===!0&&p(y,x?x.concat(b):[b])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Fl(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&&Fo(e,this,t)}const zl=gi.prototype;zl.append=function(t,n){this._pairs.push([t,n])},zl.toString=function(t){const n=t?function(r){return t.call(this,r,Fl)}:Fl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function gg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Bl(e,t,n){if(!t)return e;const r=n&&n.encode||gg;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.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 Hl{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){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ul={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xg={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",yi=typeof navigator=="object"&&navigator||void 0,yg=xi&&(!yi||["ReactNative","NativeScript","NS"].indexOf(yi.product)<0),vg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",bg=xi&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:yg,hasStandardBrowserWebWorkerEnv:vg,navigator:yi,origin:bg},Symbol.toStringTag,{value:"Module"})),...xg};function wg(e,t){return Fo(e,new Mt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Mt.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Sg(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Cg(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 Wl(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&&P.isArray(o)?o.length:i,l?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=Cg(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(Sg(r),o,n,0)}),n}return null}function Tg(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Qr={transitional:Ul,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(Wl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.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 wg(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Tg(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.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"?je.from(a,je.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:Mt.classes.FormData,Blob:Mt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{Qr.headers[e]={}});const kg=P.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"]),Eg=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
31
|
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&kg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Vl=Symbol("internals");function eo(e){return e&&String(e).trim().toLowerCase()}function zo(e){return e===!1||e==null?e:P.isArray(e)?e.map(zo):String(e)}function Ig(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 Ng=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vi(e,t,n,r,o){if(P.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!P.isString(t)){if(P.isString(r))return t.indexOf(r)!==-1;if(P.isRegExp(r))return r.test(t)}}function Ag(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function _g(e,t){const n=P.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 Wt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=eo(l);if(!d)throw new Error("header name must be a non-empty string");const f=P.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=zo(a))}const i=(a,l)=>P.forEach(a,(u,d)=>s(u,d,l));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!Ng(t))i(Eg(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},l,u;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?P.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=eo(t),t){const r=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ig(o);if(P.isFunction(n))return n.call(this,o,r);if(P.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=eo(t),t){const r=P.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||vi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=eo(i),i){const a=P.findKey(r,i);a&&(!n||vi(r,r[a],a,n))&&(delete r[a],o=!0)}}return P.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||vi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return P.forEach(this,(o,s)=>{const i=P.findKey(r,s);if(i){n[i]=zo(o),delete n[s];return}const a=t?Ag(s):String(s).trim();a!==s&&delete n[s],n[a]=zo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return P.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&P.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[Vl]=this[Vl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(_g(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};Wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(Wt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(Wt);function bi(e,t){const n=this||Qr,r=t||n,o=Wt.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Kl(e){return!!(e&&e.__CANCEL__)}function jr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(jr,je,{__CANCEL__:!0});function ql(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function jg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Rg(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 u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Pg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Bo=(e,t,n=3)=>{let r=0;const o=Rg(50,250);return Pg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Gl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Yl=e=>(...t)=>P.asap(()=>e(...t)),Og=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,Mg=Mt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.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 Dg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Lg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Xl(e,t,n){let r=!Dg(t);return e&&(r||n==!1)?Lg(e,t):t}const Jl=e=>e instanceof Wt?{...e}:e;function lr(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}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:(u,d,f)=>o(Jl(u),Jl(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Zl=e=>{const t=lr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Wt.from(i),t.url=Bl(Xl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(Mt.hasStandardBrowserEnv||Mt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&Og(t.url))){const l=o&&s&&Mg.read(s);l&&i.set(o,l)}return t},$g=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Zl(e);let s=o.data;const i=Wt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;const S=Wt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};ql(function(I){n(I),x()},function(I){r(I),x()},C),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new je("Request aborted",je.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new je(C,je.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Ul;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new je(E,C.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Bo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Bo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new jr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=jg(o.url);if(b&&Mt.protocols.indexOf(b)===-1){r(new je("Unsupported protocol "+b+":",je.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Fg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof je?d:new jr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>P.asap(a),l}},zg=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},Bg=async function*(e,t){for await(const n of Hg(e))yield*zg(n,t)},Hg=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()}},Ql=(e,t,n,r)=>{const o=Bg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},ec=64*1024,{isFunction:Ho}=P,Ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:tc,TextEncoder:nc}=P.global,rc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wg=e=>{e=P.merge.call({skipUndefined:!0},Ug,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(tc),l=o&&(typeof nc=="function"?(v=>x=>v.encode(x))(new nc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&rc(()=>{let v=!1;const x=new n(Mt.origin,{body:new tc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&rc(()=>P.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new je(`Response type '${v}' is not supported`,je.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(P.isBlob(v))return v.size;if(P.isSpecCompliantForm(v))return(await new n(Mt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(P.isArrayBufferView(v)||P.isArrayBuffer(v))return v.byteLength;if(P.isURLSearchParams(v)&&(v=v+""),P.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=P.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:_,withCredentials:R="same-origin",fetchOptions:j}=Zl(v),$=t||fetch;I=I?(I+"").toLowerCase():"text";let L=Fg([b,S&&S.toAbortSignal()],E),F=null;const M=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let H;try{if(T&&u&&g!=="get"&&g!=="head"&&(H=await p(_,y))!==0){let O=new n(x,{method:"POST",body:y,duplex:"half"}),G;if(P.isFormData(y)&&(G=O.headers.get("content-type"))&&_.setContentType(G),O.body){const[le,be]=Gl(H,Bo(Yl(T)));y=Ql(O.body,ec,le,be)}}P.isString(R)||(R=R?"include":"omit");const z=s&&"credentials"in n.prototype,te={...j,signal:L,method:g.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:z?R:void 0};F=s&&new n(x,te);let V=await(s?$(F,j):$(x,te));const U=d&&(I==="stream"||I==="response");if(d&&(C||U&&M)){const O={};["status","statusText","headers"].forEach(ge=>{O[ge]=V[ge]});const G=P.toFiniteNumber(V.headers.get("content-length")),[le,be]=C&&Gl(G,Bo(Yl(C),!0))||[];V=new r(Ql(V.body,ec,le,()=>{be&&be(),M&&M()}),O)}I=I||"text";let me=await f[P.findKey(f,I)||"text"](V,v);return!U&&M&&M(),await new Promise((O,G)=>{ql(O,G,{data:me,headers:Wt.from(V.headers),status:V.status,statusText:V.statusText,config:v,request:F})})}catch(z){throw M&&M(),z&&z.name==="TypeError"&&/Load failed|fetch/i.test(z.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,v,F),{cause:z.cause||z}):je.from(z,z&&z.code,v,F)}}},Vg=new Map,oc=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,u,d=Vg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Wg(t)),d=u;return u};oc();const wi={http:hg,xhr:$g,fetch:{get:oc}};P.forEach(wi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const sc=e=>`- ${e}`,Kg=e=>P.isFunction(e)||e===null||e===!1,ic={getAdapter:(e,t)=>{e=P.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,!Kg(r)&&(o=wi[(a=String(r)).toLowerCase()],o===void 0))throw new je(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
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[Vl]=this[Vl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(_g(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};Wt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(Wt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(Wt);function bi(e,t){const n=this||Qr,r=t||n,o=Wt.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Kl(e){return!!(e&&e.__CANCEL__)}function jr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(jr,je,{__CANCEL__:!0});function ql(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function jg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Rg(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 u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Pg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Bo=(e,t,n=3)=>{let r=0;const o=Rg(50,250);return Pg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Gl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Yl=e=>(...t)=>P.asap(()=>e(...t)),Og=Mt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Mt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Mt.origin),Mt.navigator&&/(msie|trident)/i.test(Mt.navigator.userAgent)):()=>!0,Mg=Mt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.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 Dg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Lg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Xl(e,t,n){let r=!Dg(t);return e&&(r||n==!1)?Lg(e,t):t}const Jl=e=>e instanceof Wt?{...e}:e;function lr(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}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:(u,d,f)=>o(Jl(u),Jl(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Zl=e=>{const t=lr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Wt.from(i),t.url=Bl(Xl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(Mt.hasStandardBrowserEnv||Mt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&Og(t.url))){const l=o&&s&&Mg.read(s);l&&i.set(o,l)}return t},$g=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Zl(e);let s=o.data;const i=Wt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function x(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;const S=Wt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};ql(function(I){n(I),x()},function(I){r(I),x()},C),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(r(new je("Request aborted",je.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new je(C,je.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Ul;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new je(E,C.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Bo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Bo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new jr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=jg(o.url);if(b&&Mt.protocols.indexOf(b)===-1){r(new je("Unsupported protocol "+b+":",je.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Fg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof je?d:new jr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>P.asap(a),l}},zg=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},Bg=async function*(e,t){for await(const n of Hg(e))yield*zg(n,t)},Hg=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()}},Ql=(e,t,n,r)=>{const o=Bg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},ec=64*1024,{isFunction:Ho}=P,Ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:tc,TextEncoder:nc}=P.global,rc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Wg=e=>{e=P.merge.call({skipUndefined:!0},Ug,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(tc),l=o&&(typeof nc=="function"?(v=>x=>v.encode(x))(new nc):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&rc(()=>{let v=!1;const x=new n(Mt.origin,{body:new tc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&rc(()=>P.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(x,g)=>{let y=x&&x[v];if(y)return y.call(x);throw new je(`Response type '${v}' is not supported`,je.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(P.isBlob(v))return v.size;if(P.isSpecCompliantForm(v))return(await new n(Mt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(P.isArrayBufferView(v)||P.isArrayBuffer(v))return v.byteLength;if(P.isURLSearchParams(v)&&(v=v+""),P.isString(v))return(await l(v)).byteLength},p=async(v,x)=>{const g=P.toFiniteNumber(v.getContentLength());return g??h(x)};return async v=>{let{url:x,method:g,data:y,signal:b,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:_,withCredentials:R="same-origin",fetchOptions:j}=Zl(v),z=t||fetch;I=I?(I+"").toLowerCase():"text";let L=Fg([b,S&&S.toAbortSignal()],E),B=null;const M=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let q;try{if(T&&u&&g!=="get"&&g!=="head"&&(q=await p(_,y))!==0){let O=new n(x,{method:"POST",body:y,duplex:"half"}),G;if(P.isFormData(y)&&(G=O.headers.get("content-type"))&&_.setContentType(G),O.body){const[ce,be]=Gl(q,Bo(Yl(T)));y=Ql(O.body,ec,ce,be)}}P.isString(R)||(R=R?"include":"omit");const U=s&&"credentials"in n.prototype,te={...j,signal:L,method:g.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:U?R:void 0};B=s&&new n(x,te);let $=await(s?z(B,j):z(x,te));const F=d&&(I==="stream"||I==="response");if(d&&(C||F&&M)){const O={};["status","statusText","headers"].forEach(ge=>{O[ge]=$[ge]});const G=P.toFiniteNumber($.headers.get("content-length")),[ce,be]=C&&Gl(G,Bo(Yl(C),!0))||[];$=new r(Ql($.body,ec,ce,()=>{be&&be(),M&&M()}),O)}I=I||"text";let ie=await f[P.findKey(f,I)||"text"]($,v);return!F&&M&&M(),await new Promise((O,G)=>{ql(O,G,{data:ie,headers:Wt.from($.headers),status:$.status,statusText:$.statusText,config:v,request:B})})}catch(U){throw M&&M(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,v,B),{cause:U.cause||U}):je.from(U,U&&U.code,v,B)}}},Vg=new Map,oc=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,u,d=Vg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Wg(t)),d=u;return u};oc();const wi={http:hg,xhr:$g,fetch:{get:oc}};P.forEach(wi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const sc=e=>`- ${e}`,Kg=e=>P.isFunction(e)||e===null||e===!1,ic={getAdapter:(e,t)=>{e=P.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,!Kg(r)&&(o=wi[(a=String(r)).toLowerCase()],o===void 0))throw new je(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(sc).join(`
|
|
34
34
|
`):" "+sc(i[0]):"as no adapter specified";throw new je("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:wi};function Si(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new jr(null,e)}function ac(e){return Si(e),e.headers=Wt.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),ic.getAdapter(e.adapter||Qr.adapter,e)(e).then(function(r){return Si(e),r.data=bi.call(e,e.transformResponse,r),r.headers=Wt.from(r.headers),r},function(r){return Kl(r)||(Si(e),r&&r.response&&(r.response.data=bi.call(e,e.transformResponse,r.response),r.response.headers=Wt.from(r.response.headers))),Promise.reject(r)})}const lc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const cc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+lc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new je(o(i," has been removed"+(n?" in "+n:"")),je.ERR_DEPRECATED);return n&&!cc[i]&&(cc[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}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function qg(e,t,n){if(typeof e!="object")throw new je("options must be an object",je.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 je("option "+s+" must be "+l,je.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new je("Unknown option "+s,je.ERR_BAD_OPTION)}}const Wo={assertOptions:qg,validators:Uo},bn=Wo.validators;let cr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Hl,response:new Hl}}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=lr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.assertOptions(r,{silentJSONParsing:bn.transitional(bn.boolean),forcedJSONParsing:bn.transitional(bn.boolean),clarifyTimeoutError:bn.transitional(bn.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:bn.function,serialize:bn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:bn.spelling("baseURL"),withXsrfToken:bn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Wt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[ac.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=ac.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=lr(this.defaults,t);const n=Xl(t.baseURL,t.url,t.allowAbsoluteUrls);return Bl(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){cr.prototype[t]=function(n,r){return this.request(lr(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(lr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}cr.prototype[t]=n(),cr.prototype[t+"Form"]=n(!0)});let Gg=class Tm{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 jr(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 Tm(function(o){t=o}),cancel:t}}};function Yg(e){return function(n){return e.apply(null,n)}}function Xg(e){return P.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 uc(e){const t=new cr(e),n=El(cr.prototype.request,t);return P.extend(n,cr.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return uc(lr(e,o))},n}const xt=uc(Qr);xt.Axios=cr,xt.CanceledError=jr,xt.CancelToken=Gg,xt.isCancel=Kl,xt.VERSION=lc,xt.toFormData=Fo,xt.AxiosError=je,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Yg,xt.isAxiosError=Xg,xt.mergeConfig=lr,xt.AxiosHeaders=Wt,xt.formToJSON=e=>Wl(P.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=ic.getAdapter,xt.HttpStatusCode=Ci,xt.default=xt;const{Axios:BT,AxiosError:HT,CanceledError:UT,isCancel:WT,CancelToken:VT,VERSION:KT,all:qT,Cancel:GT,isAxiosError:YT,spread:XT,toFormData:JT,AxiosHeaders:ZT,HttpStatusCode:QT,formToJSON:ek,getAdapter:tk,mergeConfig:nk}=xt,dc=typeof window<"u"?window.__API_BASE_URL__:void 0,fc=dc?$n(dc):void 0;function $n(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const Ti=new Set;function hc(){return Vo}function ki(e){Vo=e,Ti.forEach(t=>t(e))}function pc(e){return Ti.add(e),()=>Ti.delete(e)}const tn=xt.create({...fc?{baseURL:fc}:{},timeout:3e4,withCredentials:!0});tn.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),tn.interceptors.response.use(e=>e,e=>Promise.reject(e));async function dn(e,t){return tn.defaults.baseURL?(await tn.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function mc(e,t,n){return tn.defaults.baseURL?(await tn.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t,n){return tn.defaults.baseURL?(await tn.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function xc(e,t){return tn.defaults.baseURL?(await tn.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function wn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class yc{get baseUrl(){const t=tn.defaults.baseURL;return t?$n(String(t)):""}updateConfig(t){t.baseUrl&&(tn.defaults.baseURL=$n(String(t.baseUrl))),t.authToken!==void 0&&ki(t.authToken)}getAuthToken(){return hc()}setAuthToken(t){ki(t)}onTokenChange(t){return pc(t)}async listThreads(){const t=await dn("/threads"),n=wn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await mc("/threads",t?{title:t}:void 0);return wn(r)}async updateThread(t,n){const r=await gc(`/threads/${t}`,{title:n});return wn(r)}async deleteThread(t){const n=await xc(`/threads/${t}`);return wn(n)}async threadInfo(t){const n=await dn(`/threads/${t}/info`);return wn(n)}async listAgents(){const t=await dn("/agents"),n=wn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await dn(`/agents/${t}`);return wn(n)}async getAgentSchema(t){const n=await dn(`/agents/${t}/schema`);return wn(n)}async getState(t){const n=await dn(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return wn(n)}async getStateHistory(t){const n=await dn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return wn(n)}}const Wn=new yc,vc=w.createContext(null);function Jg({children:e,apiConfig:t}){const n=Wn;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 c.jsx(vc.Provider,{value:r,children:e})}function Ei(){const e=w.useContext(vc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zg(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 Qg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Zg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ex={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Ii(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function to(e,t){return`${e??""}::${t??""}`}function bc(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!Ii(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=nx(t),i=wc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function wc(e,t){var C,T;if(!Ii(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((I,_)=>ax(I,_)).filter(I=>!!I),i=qt((C=e.config)==null?void 0:C.configurable),a=mt(i,["checkpoint_id","checkpointId"]),l=mt(i,["checkpoint_ns","checkpointNs"]),u=qt((T=e.parentConfig)==null?void 0:T.configurable),d=mt(u,["checkpoint_id","checkpointId"])??null,f=mt(u,["checkpoint_ns","checkpointNs"])??null,h=e==null?void 0:e.createdAt,p=typeof h=="string"&&h.trim()?h:new Date(Date.now()-t).toISOString(),v=rx(s),x=s[s.length-1]??null,g=qt(e==null?void 0:e.metadata),y=mt(g,["branch_label","branchLabel"]),b=qt(e==null?void 0:e.parentConfig),S=qt(b==null?void 0:b.configurable),E=mt(S,["checkpoint_id","checkpointId"]);return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:tx(o,s,t),createdAt:p,preview:v??null,role:(x==null?void 0:x.role)??null,parentId:E??null,branchLabel:y??null,lastMessageId:(x==null?void 0:x.id)??null,hasMessages:s.length>0,messagesLen:s.length}}function tx(e,t,n){const r=sx(e,n);return r||ox(t,n)}function nx(e){const t=new Map;e.forEach((o,s)=>{if(!Ii(o))return;const i=wc(o,s);if(!(i!=null&&i.checkpointId))return;const a=to(i.checkpointId,i.checkpointNs??null);t.has(a)||t.set(a,i)});const n=Array.from(t.values());n.sort((o,s)=>Cc(s.createdAt??"")-Cc(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function rx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function ox(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 sx(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=ix(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=no(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=no(r.state,`${o}-state`);if(s)return s}}return null}function ix(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=qt(e);if(!n)return null;const r=mt(n,["id","task_id","taskId"])??t,o=mt(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function no(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=Sc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=no(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=no(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=no(l,t,n+1,r);if(u)return u}}return null}function Sc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=mt(n,["type","event","kind"]),o=mt(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=Sc(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Cc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function ax(e,t){if(!e||typeof e!="object")return null;const n=e,r=qt(e)??{},o=qt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=ex[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=qt(o.additional_kwargs)??qt(o.additionalKwargs),d=qt(o.response_metadata)??qt(o.responseMetadata),f=mt(u,["createdAt","created_at"])??mt(o,["created_at","createdAt"]),h=mt(u,["checkpointId","checkpoint_id"]),p=mt(u,["checkpointNs","checkpoint_ns"]),v=lx(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=hx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=cx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const S=dx(o,x.content);S&&(x.content=S)}return x}function lx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Tc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Tc(e);return t?[t]:[]}return[]}function Tc(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=mt(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=mt(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return ux(t)??null;if(n==="tool_end"){const o=mt(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=mt(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function cx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=mt(r,["id","call_id"]),s=qt(r.function),i=mt(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=kc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function ux(e){const t=mt(e,["id","call_id"]),n=mt(e,["name"]);if(!t||!n)return null;const r=kc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function dx(e,t){const n=mt(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?fx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function kc(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function fx(e){try{return JSON.parse(e)}catch{return e}}function qt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function mt(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function hx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function px(e){return e.type!=="thread_info"&&e.type!=="token"}const mx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function gx(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ni(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ni(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),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ni(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return Ic(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ic(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Ec(e=[]){const[t,n]=w.useReducer(gx,{...mx,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 u=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Ic(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=vx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ai(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Rc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=xx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Nc(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Ai(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?_c(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=yx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ai(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:_c(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Ac(e.messages,l,f=>({...f,content:jc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ni(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function Nc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ai(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Ac(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function _c(e,t,n){return Ac(e,t,r=>({...r,content:jc(r.content,n)}))}function jc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Oc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Rc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xx(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(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??Rc(e);let l="",u=e.slice();if(s){const f=Oc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Pc(e){return e.replace(/\s+/g," ").trim()}function Oc(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=Pc(e),o=Pc(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 yx(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 Nc(e,r,s)}return e}function vx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Mc(e={}){const t=w.useMemo(()=>$n(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),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),E=w.useRef(!0),C=w.useRef(0),T=w.useCallback(j=>{o(j)},[]),I=w.useCallback(()=>{var j;(j=S.current)==null||j.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),_=w.useCallback(()=>{h(""),v(null),d(null)},[]),R=w.useCallback((j,$,L)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const F=new AbortController;return S.current=F,(async()=>{var H,z,te,V,U,me,O,G;const M=le=>{var be;try{const ge=JSON.parse(JSON.stringify(le));return(be=ge==null?void 0:ge.payload)!=null&&be.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),ge}catch{return le}};try{let le={};try{if(r)le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,nt=((H=window.localStorage)==null?void 0:H.getItem("authToken"))||null;let rt=null;try{const St=(z=window.localStorage)==null?void 0:z.getItem("chat-settings");St&&(rt=((te=JSON.parse(St))==null?void 0:te.apiKey)||null)}catch{}const Pe=ze||nt||rt||null;Pe&&(le={Authorization:`Bearer ${Pe}`})}}catch{}console.debug("[use-chat] POST",t+n,M(j));const be=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...le,...s.current},body:JSON.stringify(j),signal:F.signal,credentials:i});if(!be.ok||!be.body){const Re=await be.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",be.status,Re==null?void 0:Re.slice(0,500)),new Error(`stream ${be.status}${Re?": "+Re:""}`)}b(!0);const ge=be.body.getReader(),ye=new TextDecoder;let K="",D=[];C.current=0,g(0);let X=0,Z=null;const de=()=>{if(D.length){const Re=D.join("");D=[],E.current&&h(ze=>ze+Re)}Z=null},ie=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(de))};let Q=Date.now();const tt=setInterval(()=>{var Re;if(Date.now()-Q>6e4){const ze="Stream idle timeout";d(ze),F.abort(),(Re=L==null?void 0:L.onError)==null||Re.call(L,ze)}},5e3),Ze=1024*1024;try{const Re=be.headers.get("X-Thread-Id")||be.headers.get("x-thread-id"),ze=be.headers.get("X-Thread-Created")||be.headers.get("x-thread-created"),nt=Re??null,rt=String(ze??"").toLowerCase()==="true";for((V=L==null?void 0:L.onOpen)==null||V.call(L,{threadId:nt,created:rt});;){const{value:Pe,done:St}=await ge.read();if(St)break;K+=ye.decode(Pe,{stream:!0}),K.length>Ze&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let Ct;for(;(Ct=K.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=lr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.assertOptions(r,{silentJSONParsing:bn.transitional(bn.boolean),forcedJSONParsing:bn.transitional(bn.boolean),clarifyTimeoutError:bn.transitional(bn.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.assertOptions(o,{encode:bn.function,serialize:bn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wo.assertOptions(n,{baseUrl:bn.spelling("baseURL"),withXsrfToken:bn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Wt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const v=[ac.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],x=a[f++];try{p=v(p)}catch(g){x.call(this,g);break}}try{d=ac.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=lr(this.defaults,t);const n=Xl(t.baseURL,t.url,t.allowAbsoluteUrls);return Bl(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){cr.prototype[t]=function(n,r){return this.request(lr(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(lr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}cr.prototype[t]=n(),cr.prototype[t+"Form"]=n(!0)});let Gg=class Tm{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 jr(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 Tm(function(o){t=o}),cancel:t}}};function Yg(e){return function(n){return e.apply(null,n)}}function Xg(e){return P.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 uc(e){const t=new cr(e),n=El(cr.prototype.request,t);return P.extend(n,cr.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return uc(lr(e,o))},n}const xt=uc(Qr);xt.Axios=cr,xt.CanceledError=jr,xt.CancelToken=Gg,xt.isCancel=Kl,xt.VERSION=lc,xt.toFormData=Fo,xt.AxiosError=je,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Yg,xt.isAxiosError=Xg,xt.mergeConfig=lr,xt.AxiosHeaders=Wt,xt.formToJSON=e=>Wl(P.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=ic.getAdapter,xt.HttpStatusCode=Ci,xt.default=xt;const{Axios:BT,AxiosError:HT,CanceledError:UT,isCancel:WT,CancelToken:VT,VERSION:KT,all:qT,Cancel:GT,isAxiosError:YT,spread:XT,toFormData:JT,AxiosHeaders:ZT,HttpStatusCode:QT,formToJSON:ek,getAdapter:tk,mergeConfig:nk}=xt,dc=typeof window<"u"?window.__API_BASE_URL__:void 0,fc=dc?$n(dc):void 0;function $n(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Vo=null;const Ti=new Set;function hc(){return Vo}function ki(e){Vo=e,Ti.forEach(t=>t(e))}function pc(e){return Ti.add(e),()=>Ti.delete(e)}const tn=xt.create({...fc?{baseURL:fc}:{},timeout:3e4,withCredentials:!0});tn.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),tn.interceptors.response.use(e=>e,e=>Promise.reject(e));async function dn(e,t){return tn.defaults.baseURL?(await tn.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function mc(e,t,n){return tn.defaults.baseURL?(await tn.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function gc(e,t,n){return tn.defaults.baseURL?(await tn.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function xc(e,t){return tn.defaults.baseURL?(await tn.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function wn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class yc{get baseUrl(){const t=tn.defaults.baseURL;return t?$n(String(t)):""}updateConfig(t){t.baseUrl&&(tn.defaults.baseURL=$n(String(t.baseUrl))),t.authToken!==void 0&&ki(t.authToken)}getAuthToken(){return hc()}setAuthToken(t){ki(t)}onTokenChange(t){return pc(t)}async listThreads(){const t=await dn("/threads"),n=wn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await mc("/threads",t?{title:t}:void 0);return wn(r)}async updateThread(t,n){const r=await gc(`/threads/${t}`,{title:n});return wn(r)}async deleteThread(t){const n=await xc(`/threads/${t}`);return wn(n)}async threadInfo(t){const n=await dn(`/threads/${t}/info`);return wn(n)}async listAgents(){const t=await dn("/agents"),n=wn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await dn(`/agents/${t}`);return wn(n)}async getAgentSchema(t){const n=await dn(`/agents/${t}/schema`);return wn(n)}async getState(t){const n=await dn(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return wn(n)}async getStateHistory(t){const n=await dn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return wn(n)}}const Wn=new yc,vc=w.createContext(null);function Jg({children:e,apiConfig:t}){const n=Wn;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 c.jsx(vc.Provider,{value:r,children:e})}function Ei(){const e=w.useContext(vc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zg(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 Qg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Zg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const ex={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Ii(e){if(!e||typeof e!="object")return!1;const t=e;return"values"in t&&"config"in t&&typeof t.values=="object"&&t.values!==null&&typeof t.config=="object"&&t.config!==null}function to(e,t){return`${e??""}::${t??""}`}function bc(e){const t=Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[],n=(e==null?void 0:e.threadId)??"",r=t[0];if(!Ii(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=nx(t),i=wc(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function wc(e,t){var C,T;if(!Ii(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((I,_)=>ax(I,_)).filter(I=>!!I),i=qt((C=e.config)==null?void 0:C.configurable),a=mt(i,["checkpoint_id","checkpointId"]),l=mt(i,["checkpoint_ns","checkpointNs"]),u=qt((T=e.parentConfig)==null?void 0:T.configurable),d=mt(u,["checkpoint_id","checkpointId"])??null,f=mt(u,["checkpoint_ns","checkpointNs"])??null,h=e==null?void 0:e.createdAt,p=typeof h=="string"&&h.trim()?h:new Date(Date.now()-t).toISOString(),v=rx(s),x=s[s.length-1]??null,g=qt(e==null?void 0:e.metadata),y=mt(g,["branch_label","branchLabel"]),b=qt(e==null?void 0:e.parentConfig),S=qt(b==null?void 0:b.configurable),E=mt(S,["checkpoint_id","checkpointId"]);return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:tx(o,s,t),createdAt:p,preview:v??null,role:(x==null?void 0:x.role)??null,parentId:E??null,branchLabel:y??null,lastMessageId:(x==null?void 0:x.id)??null,hasMessages:s.length>0,messagesLen:s.length}}function tx(e,t,n){const r=sx(e,n);return r||ox(t,n)}function nx(e){const t=new Map;e.forEach((o,s)=>{if(!Ii(o))return;const i=wc(o,s);if(!(i!=null&&i.checkpointId))return;const a=to(i.checkpointId,i.checkpointNs??null);t.has(a)||t.set(a,i)});const n=Array.from(t.values());n.sort((o,s)=>Cc(s.createdAt??"")-Cc(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function rx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function ox(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 sx(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=ix(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=no(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=no(r.state,`${o}-state`);if(s)return s}}return null}function ix(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,v=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:v,interrupts:x,state:g!==void 0?g:f}}const n=qt(e);if(!n)return null;const r=mt(n,["id","task_id","taskId"])??t,o=mt(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function no(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=Sc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=no(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=no(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=no(l,t,n+1,r);if(u)return u}}return null}function Sc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=mt(n,["type","event","kind"]),o=mt(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=Sc(e[n],t);if(r)return r}return e.length>=2&&typeof e[0]=="string"&&e[0].trim()?{id:e[0],value:e[1]}:null}if(typeof e=="string"){const n=e.trim();return n?{id:t||n,value:n}:null}return null}function Cc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function ax(e,t){if(!e||typeof e!="object")return null;const n=e,r=qt(e)??{},o=qt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=ex[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=qt(o.additional_kwargs)??qt(o.additionalKwargs),d=qt(o.response_metadata)??qt(o.responseMetadata),f=mt(u,["createdAt","created_at"])??mt(o,["created_at","createdAt"]),h=mt(u,["checkpointId","checkpoint_id"]),p=mt(u,["checkpointNs","checkpoint_ns"]),v=lx(o.content),x={id:l,role:i,content:v};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=hx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),y=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),y&&Object.keys(y).length&&(x.responseMetadata=y);const b=cx((u==null?void 0:u.tool_calls)??o.tool_calls);if(b.length&&(x.content=[...x.content,...b]),i==="tool"){const S=dx(o,x.content);S&&(x.content=S)}return x}function lx(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Tc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Tc(e);return t?[t]:[]}return[]}function Tc(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=mt(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=mt(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return ux(t)??null;if(n==="tool_end"){const o=mt(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=mt(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function cx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=mt(r,["id","call_id"]),s=qt(r.function),i=mt(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=kc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function ux(e){const t=mt(e,["id","call_id"]),n=mt(e,["name"]);if(!t||!n)return null;const r=kc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function dx(e,t){const n=mt(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?fx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function kc(e){if(!e)return{};if(typeof e=="string")try{const t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{raw:e}}catch{return{raw:e}}return typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function fx(e){try{return JSON.parse(e)}catch{return e}}function qt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function mt(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function hx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function px(e){return e.type!=="thread_info"&&e.type!=="token"}const mx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function gx(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ni(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ni(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),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ni(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return Ic(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ic(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Ec(e=[]){const[t,n]=w.useReducer(gx,{...mx,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 u=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Ic(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=vx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ai(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Rc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:v,changed:x}=xx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},y=Nc(a,l,g),b={...d,[i]:v};return{...e,messages:y,messagesStreamMeta:b}}if(t.type==="message_end"){const i=e.assemblingId??Ai(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?_c(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=yx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ai(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:_c(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Ac(e.messages,l,f=>({...f,content:jc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ni(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function Nc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ai(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Ac(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function _c(e,t,n){return Ac(e,t,r=>({...r,content:jc(r.content,n)}))}function jc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Oc(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Rc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xx(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(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??Rc(e);let l="",u=e.slice();if(s){const f=Oc(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Pc(e){return e.replace(/\s+/g," ").trim()}function Oc(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=Pc(e),o=Pc(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 yx(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 Nc(e,r,s)}return e}function vx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Mc(e={}){const t=w.useMemo(()=>$n(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),[u,d]=w.useState(null),[f,h]=w.useState(""),[p,v]=w.useState(null),[x,g]=w.useState(0),[y,b]=w.useState(!1),S=w.useRef(null),E=w.useRef(!0),C=w.useRef(0),T=w.useCallback(j=>{o(j)},[]),I=w.useCallback(()=>{var j;(j=S.current)==null||j.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),_=w.useCallback(()=>{h(""),v(null),d(null)},[]),R=w.useCallback((j,z,L)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const B=new AbortController;return S.current=B,(async()=>{var q,U,te,$,F,ie,O,G;const M=ce=>{var be;try{const ge=JSON.parse(JSON.stringify(ce));return(be=ge==null?void 0:ge.payload)!=null&&be.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(ye=>({...ye,data:ye!=null&&ye.data?`<base64 ${String(ye.data).length} chars>`:ye==null?void 0:ye.data}))),ge}catch{return ce}};try{let ce={};try{if(r)ce={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,nt=((q=window.localStorage)==null?void 0:q.getItem("authToken"))||null;let rt=null;try{const St=(U=window.localStorage)==null?void 0:U.getItem("chat-settings");St&&(rt=((te=JSON.parse(St))==null?void 0:te.apiKey)||null)}catch{}const Pe=ze||nt||rt||null;Pe&&(ce={Authorization:`Bearer ${Pe}`})}}catch{}console.debug("[use-chat] POST",t+n,M(j));const be=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ce,...s.current},body:JSON.stringify(j),signal:B.signal,credentials:i});if(!be.ok||!be.body){const Re=await be.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",be.status,Re==null?void 0:Re.slice(0,500)),new Error(`stream ${be.status}${Re?": "+Re:""}`)}b(!0);const ge=be.body.getReader(),ye=new TextDecoder;let V="",D=[];C.current=0,g(0);let X=0,Z=null;const fe=()=>{if(D.length){const Re=D.join("");D=[],E.current&&h(ze=>ze+Re)}Z=null},ae=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(fe))};let Q=Date.now();const tt=setInterval(()=>{var Re;if(Date.now()-Q>6e4){const ze="Stream idle timeout";d(ze),B.abort(),(Re=L==null?void 0:L.onError)==null||Re.call(L,ze)}},5e3),Ze=1024*1024;try{const Re=be.headers.get("X-Thread-Id")||be.headers.get("x-thread-id"),ze=be.headers.get("X-Thread-Created")||be.headers.get("x-thread-created"),nt=Re??null,rt=String(ze??"").toLowerCase()==="true";for(($=L==null?void 0:L.onOpen)==null||$.call(L,{threadId:nt,created:rt});;){const{value:Pe,done:St}=await ge.read();if(St)break;V+=ye.decode(Pe,{stream:!0}),V.length>Ze&&(V="",console.warn("Stream buffer reset: exceeded 1MB"));let Ct;for(;(Ct=V.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const kt=
|
|
38
|
-
`)}function Sx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(px(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Mc({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function nn(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[];return{checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,preview:(e==null?void 0:e.preview)??null,role:(e==null?void 0:e.role)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null}}function Cx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Dc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const Ko=300;function Lc(e,t=Ko){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function ur(){return typeof window<"u"&&typeof window.localStorage<"u"}function _i(e){if(!ur())return null;try{return window.localStorage.getItem(e)}catch{return null}}function ji(e,t){if(!ur())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Ri(e){if(ur())try{window.localStorage.removeItem(e)}catch{}}const Tx="cachedThreads",kx="v1",Pi=200;function Ex(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Oi(e,t){return`cachedThreads:v1:${e}:${Ex(t||"anon")}`}function Ix(){const e=_i(Tx);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function Nx(e){const t=_i(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function Mi(e,t){ji(e,JSON.stringify(t))}function Di(e){const t=Nx(e);if(t.length>0)return t;const n=Ix();if(n.length>0)try{Mi(e,n.slice(0,Pi))}catch{}return n}function qo(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Li(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function $i(e,t){return`${e}${t}`}function Ax(e,t){const n=_i($i(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:nn(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function _x(e,t,n=100){if(!ur())return;const r=nn(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)},updatedAt:Date.now()},s=$i(e,t.threadId),i=JSON.stringify(o);if(!ji(s,i))try{const a=[];for(let l=0;l<window.localStorage.length;l++){const u=window.localStorage.key(l);if(!u||u===s||!u.startsWith(e))continue;const d=window.localStorage.getItem(u);if(!d){a.push({key:u,updatedAt:0});continue}try{const f=JSON.parse(d),h=typeof(f==null?void 0:f.updatedAt)=="number"&&Number.isFinite(f.updatedAt)?f.updatedAt:0;a.push({key:u,updatedAt:h})}catch{a.push({key:u,updatedAt:0})}}a.sort((l,u)=>l.updatedAt-u.updatedAt);for(const l of a)if(window.localStorage.removeItem(l.key),ji(s,i))break}catch{}}function jx(e,t){Ri($i(e,t))}function Rx(e){if(ur())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const $c=w.createContext(null),Fc=w.createContext(null),zc=w.createContext(null),Px=w.createContext(!1),Bc=50,Ox=750;function Hc(e,t,n){return`${e}__${t??""}__${n??""}`}function Mx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ei(),d=w.useMemo(()=>$n(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${kx}:${f}:`,[f]),p=w.useCallback(N=>Ax(h,N),[h]),v=w.useCallback((N,A=100)=>{_x(h,N,A)},[h]),x=w.useCallback(N=>{jx(h,N)},[h]),g=w.useCallback(()=>{Rx(h)},[h]),[y,b]=w.useState(()=>{var N;return Oi(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[S,E]=w.useState(()=>{var A;const N=Di(Oi(f,(A=l.getAuthToken)==null?void 0:A.call(l)));return qo(N)}),C=w.useMemo(()=>Li(S),[S]),[T,I]=w.useState(t),[_,R]=w.useState(!1),[j,$]=w.useState(!1),[L,F]=w.useState(null),[M,H]=w.useState(null),[z,te]=w.useState(null),[V,U]=w.useState([]),me=w.useCallback(()=>{const N=Di(y);w.startTransition(()=>{E(qo(N))})},[y]),[O,G]=w.useState(!1),[le,be]=w.useState(!1),[ge,ye]=w.useState(null),[K,D]=w.useState(void 0),[X,Z]=w.useState(void 0),[de,ie]=w.useState(void 0),{state:Q,dispatch:tt,seed:Ze,prepend:Re,pushUser:ze,onEvent:nt,reset:rt}=Ec(),Pe=w.useRef(T);w.useEffect(()=>{Pe.current=T},[T]);const St=w.useRef(!1),Ct=w.useRef([]),kt=w.useRef(null),ut=w.useRef(null),et=w.useRef(new Map),Be=w.useRef(T),dt=w.useRef(!1),re=w.useRef(null),oe=w.useRef(new Map),xe=w.useRef(new Map),Me=w.useRef(new Map),Le=w.useRef(new Map),qe=w.useCallback(N=>{if(!N){U([]);return}const A=oe.current.get(N);if(!A||!A.length){U([]);return}U(A.map(q=>nn(q,{cloneMessages:!0})))},[]);w.useEffect(()=>{qe(T)},[T,qe]);const bt=w.useCallback(()=>{var ee;const N=Le.current;if(N.size<=Bc)return;const A=Array.from(N.entries()).sort((ae,J)=>ae[1].timestamp-J[1].timestamp),q=N.size-Bc;for(let ae=0;ae<q;ae++){const J=(ee=A[ae])==null?void 0:ee[0];J&&N.delete(J)}},[]),ot=w.useCallback((N,A,q)=>{if(!N)return;const ee=q==="replace"?[]:oe.current.get(N)??[],ae=q==="replace"?A:[...A,...ee];if(!ae.length){q==="replace"&&oe.current.set(N,[]);return}const J=new Map;for(const Ue of ae){if(!(Ue!=null&&Ue.checkpointId))continue;const $e=`${Ue.checkpointId}::${Ue.checkpointNs??""}`;J.has($e)||J.set($e,nn(Ue,{cloneMessages:!0}))}const Fe=Array.from(J.values()).sort((Ue,$e)=>{const at=Number.isFinite(Date.parse(Ue.createdAt??""))?Date.parse(Ue.createdAt??""):0;return(Number.isFinite(Date.parse($e.createdAt??""))?Date.parse($e.createdAt??""):0)-at});oe.current.set(N,Fe),N===Pe.current&&qe(N)},[qe]),ht=w.useCallback((N,A,q)=>{if(!N)return;const ee=xe.current.get(N),ae=q==="replace"||!ee?new Map:new Map(ee);if(A&&typeof A=="object")for(const[J,Fe]of Object.entries(A)){if(!(Fe!=null&&Fe.checkpointId))continue;const Ue=J||to(Fe.checkpointId,Fe.checkpointNs??null);ae.set(Ue,nn(Fe,{cloneMessages:!0}))}xe.current.set(N,ae)},[]),Kt=w.useCallback((N,A)=>{const{threadId:q,checkpointId:ee=null,checkpointNs:ae=null}=N,J=Hc(q,ee,ae);if(A!=null&&A.force)Me.current.delete(J),Le.current.delete(J);else{if(A!=null&&A.preferCache){const at=Le.current.get(J);if(at)return Promise.resolve(at.payload)}const $e=Me.current.get(J);if($e)return $e}const Ue=l.getStateHistory({threadId:q,checkpointId:ee??void 0,checkpointNs:ae??void 0}).then($e=>(Le.current.set(J,{payload:$e,timestamp:Date.now()}),bt(),$e)).finally(()=>{Me.current.get(J)===Ue&&Me.current.delete(J)});return Me.current.set(J,Ue),Ue},[l,bt]),Qt=w.useCallback((N,A)=>new Promise((q,ee)=>{const ae=async()=>{St.current=!0;try{await N(),q()}catch(J){ee(J)}finally{St.current=!1;const J=Ct.current.shift();J&&J().catch(()=>{})}};St.current?Ct.current.push(ae):ae().catch(J=>{ee(J)})}),[]),Er=w.useRef(C.length),[Hn,Ir]=w.useState(!1),Pn=w.useRef(!1);w.useEffect(()=>{Er.current=C.length},[C.length]),w.useEffect(()=>{const N=Q.pendingInterrupt??Cx(Q.messages);Dc(z,N)||te(N??null)},[z,Q.messages,Q.pendingInterrupt]);const Et=w.useCallback(async()=>{const N=Er.current>0;N||R(!0);try{const A=await l.listThreads();w.startTransition(()=>{E(q=>{const ee=Fe=>Fe.map(Ue=>`${Ue.threadId}:${Ue.updatedAt??""}:${Ue.messageCount??""}`).join("|"),ae=Li(q);return ee(ae)===ee(A)||A.length===0&&ae.length>0&&!Pn.current?q:qo(A)})}),F(null),Pn.current||(Pn.current=!0,Ir(!0))}catch(A){i==null||i(String(A)),console.error("[ChatSessionProvider] Failed to refresh threads:",A),F(String(A))}finally{N||R(!1)}},[l,i]),_o=w.useRef(!1),rr=w.useRef(null),It=w.useRef(null),yn=w.useRef(""),On=w.useCallback((N,A)=>{if(!ur())return;It.current!==null&&(window.clearTimeout(It.current),It.current=null);const q=N.map(ae=>`${ae.threadId}:${ae.updatedAt??""}:${ae.messageCount??""}`).join("|");if(N.length===0){try{Ri(y)}catch{}yn.current="";return}if(q===yn.current)return;const ee=()=>{try{const ae=N.slice(0,Pi);Mi(y,ae),yn.current=q}catch{}finally{It.current=null}};if(A!=null&&A.immediate){ee();return}It.current=window.setTimeout(()=>{Lc(ee)},Ko)},[y]),Kr=w.useCallback(()=>{On(C,{immediate:!0})},[On,C]),cn=w.useCallback((N,A,q,ee)=>{var wl;const ae=q??Pe.current;if(!ae)return;const J=nn(N),Fe=ae===Pe.current,Ue=(ee==null?void 0:ee.persist)!==!1;if(A==="replace"){if(Ue){const At={threadId:ae,snapshot:nn(N,{cloneMessages:!0})};et.current.set(ae,At),Be.current=ae}if(!Fe)return;Ze(J.messages,{checkpointId:J.checkpointId??null,checkpointNs:J.checkpointNs??null,pendingInterrupt:J.interrupt??null}),te(J.interrupt??null),ye(J.nextCursor??null),G(!!J.nextCursor),D(J.checkpointId??void 0),Z(J.checkpointNs??void 0),ie(J.nextCursorNs??void 0);return}const $e=et.current.get(ae),at=($e==null?void 0:$e.snapshot)??null,Rt=Array.isArray(at==null?void 0:at.messages)?at.messages:[],Ft=nn(at),Dn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Pt=new Set,Ot=[...Dn,...Rt].filter(At=>{const Sl=At==null?void 0:At.id;return Sl?Pt.has(Sl)?!1:(Pt.add(Sl),!0):!0}),Ro={checkpointId:Ft.checkpointId??J.checkpointId??null,checkpointNs:Ft.checkpointNs??J.checkpointNs??null,createdAt:J.createdAt??Ft.createdAt??null,preview:J.preview??Ft.preview??null,role:J.role??Ft.role??null,parentId:J.parentId??Ft.parentId??null,branchLabel:J.branchLabel??Ft.branchLabel??null,lastMessageId:((wl=Ot[Ot.length-1])==null?void 0:wl.id)??null,messagesLen:Ot.length,hasMessages:Ot.length>0,messages:Ot,nextCursor:J.nextCursor??Ft.nextCursor??null,nextCursorNs:J.nextCursorNs??Ft.nextCursorNs??null,interrupt:Ft.interrupt??J.interrupt??null};if(et.current.set(ae,{threadId:ae,snapshot:nn(Ro,{cloneMessages:!0})}),!Fe)return;Dn.length&&Re(Dn);const qr=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,Ln=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,Nr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,sr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;ye(At=>Nr!==void 0?Nr??At??null:At??null),G(At=>Nr!==void 0?!!Nr:At),D(At=>qr!==void 0?qr??At??void 0:At??void 0),Z(At=>Ln!==void 0?Ln??At??void 0:At??void 0),ie(At=>sr!==void 0?sr??void 0:At)},[Re,Ze,te]),or=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Pe.current)return;const A=nn(N.snapshot,{cloneMessages:!0});Ze(A.messages,{checkpointId:A.checkpointId??null,checkpointNs:A.checkpointNs??null,pendingInterrupt:A.interrupt??null}),te(A.interrupt??null),ye(A.nextCursor??null),G(!!A.nextCursor),D(A.checkpointId??void 0),Z(A.checkpointNs??void 0),ie(A.nextCursorNs??void 0),Be.current=N.threadId,qe(N.threadId??Pe.current??null)},[Ze,te,qe]),vn=w.useCallback(N=>{if(!N)return;et.current.delete(N),x(N),oe.current.delete(N),xe.current.delete(N),N===Pe.current&&U([]);const A=`${N}__`;for(const q of Me.current.keys())q.startsWith(A)&&Me.current.delete(q);for(const q of Le.current.keys())q.startsWith(A)&&Le.current.delete(q);Be.current===N&&(Be.current=null)},[x]),Mn=w.useCallback(()=>{const N=Pe.current;N&&vn(N),rt([]),G(!1),be(!1),ye(null),D(void 0),Z(void 0),ie(void 0)},[vn,rt]),pe=w.useCallback(({from:N,to:A})=>{const q=Pe.current;q&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${A}) for thread ${q}`)},[]),Ie=w.useCallback(N=>{const A=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:A,title:N.title,created:N.created,currentThreads:C.length});const q={threadId:A,title:N.title||`Thread ${A.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Pe.current!==A&&(!Pe.current&&Q.messages.length<=1&&(ut.current=A),I(A)),w.startTransition(()=>{E(ee=>{const ae=ee.byId[A];return ae?ae.title===q.title&&ae.updatedAt===q.updatedAt&&ae.messageCount===q.messageCount?ee:{byId:{...ee.byId,[A]:q},order:ee.order}:{byId:{...ee.byId,[A]:q},order:[A,...ee.order]}})})},[Q.messages.length]),{startStream:Xe,stop:k,isStreaming:B,error:se,setAuthToken:Ce}=Sx({baseUrl:d,onThreadInfo:Ie,onMessageEvent:nt,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:pe});w.useEffect(()=>{_o.current=B},[B]),w.useEffect(()=>{if(!ur())return;It.current!==null&&(window.clearTimeout(It.current),It.current=null);const N=C.map(q=>`${q.threadId}:${q.updatedAt??""}:${q.messageCount??""}`).join("|");if(C.length===0){try{Ri(y)}catch{}yn.current="";return}if(N===yn.current)return;const A=()=>{try{const q=C.slice(0,Pi);Mi(y,q),yn.current=N}catch{}finally{It.current=null}};return It.current=window.setTimeout(()=>{Lc(A),It.current=null},Ko),()=>{It.current!==null&&(window.clearTimeout(It.current),It.current=null)}},[C,On]),w.useEffect(()=>{var ee;const N=l.getAuthToken();Ce(N);const A=ae=>{const J=Oi(f,ae);re.current!==J&&(re.current=J,dt.current=!1),b(J);const Fe=Di(J);w.startTransition(()=>{E(qo(Fe))}),dt.current||(dt.current=!0,Et().catch(()=>{}))};A(N);const q=(ee=l.onTokenChange)==null?void 0:ee.call(l,ae=>{Ce(ae),g(),Me.current.clear(),Le.current.clear(),A(ae)});return()=>{q==null||q()}},[l,f,Ce,g,Et]);const Ge=w.useCallback(async N=>{var ee;const A=`Thread ${(ee=crypto.randomUUID)==null?void 0:ee.call(crypto)}`,q={threadId:A,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(ae=>({byId:{...ae.byId,[A]:q},order:[A,...ae.order]})),I(A);try{const ae=await l.createThread(N),J=typeof ae=="string"?ae:ae.threadId;return E(Fe=>{const Ue=Fe.byId[A];if(!Ue)return Fe;const $e={...Fe.byId};delete $e[A],$e[J]={...Ue,threadId:J};const at=Fe.order.map(Rt=>Rt===A?J:Rt);return{byId:$e,order:at}}),I(J),setTimeout(()=>Et(),10),F(null),J}catch(ae){throw E(J=>{if(!J.byId[A])return J;const Fe={...J.byId};delete Fe[A];const Ue=J.order.filter($e=>$e!==A);return{byId:Fe,order:Ue}}),I(null),F(String(ae)),ae}},[l,Et]),Qe=w.useCallback(async N=>{try{await l.deleteThread(N);let A=null;E(q=>{if(!q.byId[N])return q;const ee={...q.byId};delete ee[N];const ae=q.order.filter(Fe=>Fe!==N),J={byId:ee,order:ae};return A=Li(J),J}),A&&On(A,{immediate:!0}),vn(N),Pe.current===N&&(ut.current=N,I(null),Pe.current=null,Be.current=null,Mn()),await Et(),F(null)}catch(A){throw F(String(A)),A}},[l,Mn,vn,Et,On]),He=w.useCallback(async(N,A)=>{try{await l.updateThread(N,A),E(q=>{const ee=q.byId[N];return ee?{byId:{...q.byId,[N]:{...ee,title:A}},order:q.order}:q}),F(null)}catch(q){throw await Et(),F(String(q)),q}},[l,Et]),Ae=w.useCallback(async(N,A,q,ee=!1)=>{await Qt(async()=>{if(ut.current===N&&!ee){ut.current=null;return}if(kt.current===N&&!ee)return;I(Pt=>Pt===N?Pt:N),Pe.current=N;const Fe=Hc(N,A??null,q??null),Ue=Le.current.get(Fe),$e=!ee&&!A&&!q&&Ue&&Date.now()-Ue.timestamp<Ox,at=!ee&&!A&&!q;let Rt=!1;if(at){const Pt=et.current.get(N);if(Pt)or(Pt),Rt=!0;else{const Ot=p(N);Ot&&(et.current.set(N,Ot),or(Ot),Rt=!0)}}const Ft=ee||!Rt||!!A||!!q,Dn=async Pt=>{Pt&&$(!0),kt.current=N;try{const Ot=await Kt({threadId:N,checkpointId:A,checkpointNs:q},{force:ee}),{latest:Ro,checkpoints:qr,snapshots:Ln}=bc(Ot);cn(Ro,"replace",N),ot(N,qr,"replace"),ht(N,Ln,"replace"),H(null)}catch(Ot){throw(!Rt||ee||Pt)&&(i==null||i(String(Ot))),H(String(Ot)),Ot}finally{kt.current=null,Pt&&$(!1)}};Ft?await Dn(!0):at&&Rt&&!$e&&Dn(!1).catch(Pt=>{console.warn("[ChatSessionProvider] Background refresh failed:",Pt)})},`loadThread-${N}`)},[or,cn,Qt,Kt,i,ot,ht]),Nt=w.useCallback(async()=>{await Qt(async()=>{const N=Pe.current;N&&vn(N),ut.current=null,I(null),Pe.current=null,Be.current=null,Mn(),D(void 0),Z(void 0),ie(void 0),U([]);try{localStorage.removeItem("lastThreadId")}catch(A){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",A)}},"clearCurrentThread")},[Mn,vn,Qt]),pt=w.useCallback(async(N,A)=>{var J;const q=Pe.current;if(!q)throw new Error("No active thread");const ee=to(N,A??null),ae=(J=xe.current.get(q))==null?void 0:J.get(ee);if(ae){await Qt(async()=>{cn(ae,"replace",q,{persist:!1})},`navigateToCheckpoint-${q}-${ee}`);return}await Ae(q,N,A??void 0,!0)},[cn,Qt,Ae]),gt=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");await Ae(Pe.current,void 0,void 0,!0)},[Ae]),Ht=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");if(le||!O)return;const N=ge;if(N){be(!0);try{const A=Pe.current,q=await Kt({threadId:A,checkpointId:N??K??null,checkpointNs:de??X??null}),{latest:ee,checkpoints:ae,snapshots:J}=bc(q),Fe=A?xe.current.get(A):null;let Ue=ae.length>0;if(Ue&&Fe&&Fe.size>0&&(Ue=ae.some($e=>{if(!($e!=null&&$e.checkpointId))return!1;const at=to($e.checkpointId,$e.checkpointNs??null);return!Fe.has(at)})),!Ue){ye(null),ie(void 0),G(!1),H(null);return}cn(ee,"prepend",A??void 0),A&&(ot(A,ae,"prepend"),ht(A,J,"prepend")),H(null)}catch(A){throw H(String(A)),A}finally{be(!1)}}},[cn,Kt,O,K,X,de,ge,le,ot,ht]),Un=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const A=to(N.checkpointId,N.checkpointNs??null),q=nn({...N,interrupt:N.interrupt??null},{cloneMessages:!0});ht(N.threadId,{[A]:q},"prepend")}cn(N,"replace",N.threadId)}},[cn,ht]),en=w.useCallback(async(N,A)=>{var Nr;const q=Pe.current,ee=(N==null?void 0:N.text)??"",ae=(N==null?void 0:N.attachments)??[],J=ae.length?ae:(A==null?void 0:A.attachments)??[],Fe={...(A==null?void 0:A.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!q&&!Object.keys(Fe).length&&J.length===0&&!ee.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!q&&!Fe.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ue,filesInfo:$e}=await Qg(l,J),at=[...Ue];ee&&ee.trim()&&at.push({type:"text",text:ee.trim()});const Rt=!!q,Ft=Rt?(A==null?void 0:A.checkpointId)??Q.lastCheckpointId??void 0:void 0,Dn=Rt?(A==null?void 0:A.checkpointNs)??Q.lastCheckpointNs??void 0:void 0,Pt={id:((Nr=crypto.randomUUID)==null?void 0:Nr.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),...Ft!=null?{checkpointId:Ft}:{},...Dn!=null?{checkpointNs:Dn}:{}};at.length>0&&ze(Pt);const Ot={...Pt,content:at},Ro=J.length>0,qr={messages:at.length>0?[Ot]:[],files_info:$e,...o&&Ro&&s?{active_agent:s}:{},...Fe},Ln={threadId:q??null,payload:qr,checkpointId:Ft??null,checkpointNs:Dn??null,nodeFilter:(A==null?void 0:A.nodeFilter)??null,config:A==null?void 0:A.config,command:(A==null?void 0:A.command)??null};Ln.threadId||delete Ln.threadId,Ln.command||delete Ln.command,Xe(Ln,{onError:sr=>{console.warn("[ChatSessionProvider] Stream error:",sr)},onOpen:({threadId:sr})=>{!Pe.current&&sr&&(Q.messages.length<=1&&(ut.current=sr),I(sr))},onGap:pe})},[l,o,s,pe,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages.length,ze,Xe]),jt=w.useCallback(async(N,A,q)=>{if(!Pe.current)throw new Error("No active thread to handle interrupt");const ae=A?q??!0:!1;try{try{tt({type:"interrupt_response",payload:{interruptId:N}})}catch(J){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",J)}await en({payload:{}},{checkpointId:Q.lastCheckpointId??void 0,checkpointNs:Q.lastCheckpointNs??void 0,command:{kind:"resume",value:ae}}),te(null)}catch(J){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,J),J}},[tt,Q.lastCheckpointId,Q.lastCheckpointNs,en]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[T,a]),w.useEffect(()=>((async()=>{try{if(Et().catch(A=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",A),i==null||i(String(A))}),!r&&!t)try{const A=localStorage.getItem("lastThreadId");A&&(I(A),n&&await Ae(A))}catch(A){console.warn("[ChatSessionProvider] Failed to restore last thread:",A)}else t&&n&&await Ae(t)}catch(A){console.error("[ChatSessionProvider] Initialization failed:",A),i==null||i(String(A))}})(),()=>{}),[]),w.useEffect(()=>{const N=Pe.current;if(!N||Be.current!==N)return;Q.messages.length&&Q.messages[Q.messages.length-1];const A=nn({checkpointId:Q.lastCheckpointId??null,checkpointNs:Q.lastCheckpointNs??null,messages:Q.messages.slice(),nextCursor:ge??null,nextCursorNs:de??null,interrupt:Q.pendingInterrupt??z??null}),q=et.current.get(N),ee=q==null?void 0:q.snapshot,ae=!ee||ee.messages.length!==A.messages.length||ee.messages.some(($e,at)=>{var Rt;return($e==null?void 0:$e.id)!==((Rt=A.messages[at])==null?void 0:Rt.id)}),J=((ee==null?void 0:ee.checkpointId)??null)!==A.checkpointId||((ee==null?void 0:ee.checkpointNs)??null)!==A.checkpointNs,Fe=((ee==null?void 0:ee.nextCursor)??null)!==A.nextCursor||((ee==null?void 0:ee.nextCursorNs)??null)!==A.nextCursorNs,Ue=!Dc((ee==null?void 0:ee.interrupt)??null,A.interrupt??null);if(ae||J||Fe||Ue){const $e={threadId:N,snapshot:A};et.current.set(N,$e),rr.current&&window.clearTimeout(rr.current),rr.current=window.setTimeout(()=>{try{v($e,100)}catch(at){console.warn("[ChatSessionProvider] Failed to persist thread payload:",at)}},Ko)}},[ge,de,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages,Q.pendingInterrupt,z,v]);const jo=w.useMemo(()=>({threads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:_,error:L,actions:{createThread:Ge,deleteThread:Qe,renameThread:He,refreshThreads:()=>Et()},persistThreadsCache:Kr,hydrateFromCache:me}),[C,T,_,L,Ge,Qe,He,Et,Kr,me,I]),vl=w.useMemo(()=>{const N=Q.lastBranch??null,A=Q.assemblingId??null,q=N||A?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:A}:null;return{threadId:T,messages:Q.messages,interrupt:z,checkpoint:{id:Q.lastCheckpointId??null,namespace:Q.lastCheckpointNs??null},checkpoints:V,metadata:q,isLoading:j,isHistoryLoading:le,error:M,hasMore:O,loadOlder:Ht,seedFromSnapshot:Un,clearState:Mn,navigateToCheckpoint:pt,returnToLatest:gt,loadThread:Ae,clearThread:Nt,respondToInterrupt:jt}},[Nt,Mn,T,z,O,le,j,Ht,Ae,Q.assemblingId,Q.lastBranch,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages,pt,jt,gt,Un,M,V]),bl=w.useMemo(()=>({isStreaming:B,error:se,submit:en,send:en,stop:k,setAuthToken:Ce}),[B,se,en,k,Ce]);return c.jsx(Px.Provider,{value:!0,children:c.jsx(zc.Provider,{value:bl,children:c.jsx($c.Provider,{value:jo,children:c.jsx(Fc.Provider,{value:vl,children:e})})})})}function Go(){const e=w.useContext($c);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Yo(){const e=w.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Uc(){const e=w.useContext(zc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Xo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Jg,{apiConfig:t,children:c.jsx(Mx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ne(...e){return Em.twMerge(km.clsx(e))}const Dx=Po.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"}}),Ke=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?ir.Slot:"button";return c.jsx(i,{className:ne(Dx({variant:t,size:n,className:e})),ref:s,...o})});Ke.displayName="Button";const Wc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Wc.displayName="Textarea";function Lx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null),y=w.useRef(0),b=w.useRef(null);w.useEffect(()=>{p(e??""),b.current=null,g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const S=w.useCallback(()=>{const j=g.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{S()},[S]);const E=w.useCallback(async j=>{j&&j.preventDefault();const $=(h??"").trim();if(!$&&!f)return;const L=++y.current;b.current={id:L,shouldClear:!0},x(()=>{var F,M,H;try{const z=i($);z&&typeof z.then=="function"?z.then(()=>{var te,V;((te=b.current)==null?void 0:te.id)===L&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),((V=b.current)==null?void 0:V.id)===L&&(b.current=null)}).catch(()=>{var te;((te=b.current)==null?void 0:te.id)===L&&(b.current=null)}):(((F=b.current)==null?void 0:F.id)===L&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),((M=b.current)==null?void 0:M.id)===L&&(b.current=null))}catch{((H=b.current)==null?void 0:H.id)===L&&(b.current=null)}})},[h,i,f]),C=w.useCallback(j=>{p(j.target.value),b.current&&(b.current.shouldClear=!1),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),T=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),E()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[E,t,a]),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))]":""} ${d}`;return c.jsx("form",{onSubmit:j=>void E(j),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Wc,{ref:g,value:h,onChange:C,onKeyDown:T,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ke,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ce.Square,{size:16})}):c.jsx(Ke,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ce.Send,{size:16})})})]})})}const $x=w.memo(Lx),Jo=0,Vn=1,Rr=2,Vc=4;function Kc(e){return()=>e}function Fx(e){e()}function qc(e,t){return n=>e(t(n))}function Gc(e,t){return()=>e(t)}function zx(e,t){return n=>e(t,n)}function Fi(e){return e!==void 0}function Bx(...e){return()=>{e.map(Fx)}}function Pr(){}function Zo(e,t){return t(e),e}function Hx(e,t){return t(e)}function lt(...e){return e}function Je(e,t){return e(Vn,t)}function Oe(e,t){e(Jo,t)}function zi(e){e(Rr)}function yt(e){return e(Vc)}function ve(e,t){return Je(e,zx(t,Jo))}function fn(e,t){const n=e(Vn,r=>{n(),t(r)});return n}function Yc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xc(e,t){return e===t}function ct(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>qc(t,e)}function Sn(e){return t=>()=>{t(e)}}function W(e,...t){const n=Ux(...t);return(r,o)=>{switch(r){case Rr:zi(e);return;case Vn:return Je(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function dr(e){return t=>n=>{e>0?e--:t(n)}}function Fn(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);Je(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Ux(...e){return t=>e.reduceRight(Hx,t)}function Wx(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Vn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),Pr);case Rr:r(),n=null;return}}}function Y(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case Jo:t=o;break;case Vn:{o(t);break}case Vc:return t}return n(r,o)}}function Dt(e,t){return Zo(Y(t),n=>ve(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case Jo:e.slice().forEach(r=>{r(n)});return;case Rr:e.splice(0,e.length);return;case Vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Gt(e){return Zo(Ve(),t=>ve(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Vx(),singleton:n}}const Vx=()=>Symbol();function Kx(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 vt(...e){const t=Ve(),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);Je(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Rr:{zi(t);return}case Vn:return r===o&&i(n),Je(t,i)}}}function Te(e,t=Xc){return W(e,ct(t))}function Bi(...e){return function(t,n){switch(t){case Rr:return;case Vn:return Bx(...e.map(r=>Je(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const qx={0:"debug",3:"error",1:"log",2:"warn"},Gx=()=>typeof globalThis>"u"?window:globalThis,Kn=Ye(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=Gx().VIRTUOSO_LOG_LEVEL)!=null?o:yt(e);r>=s&&console[qx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function fr(e,t,n){return Hi(e,t,n).callbackRef}function Hi(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 Yx(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=Xx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?Jc("column-gap",getComputedStyle(d).columnGap,o):Jc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Hi(u,n,l)}function Xx(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),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zc(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Hi(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const zt=Ye(()=>{const e=Ve(),t=Ve(),n=Y(0),r=Ve(),o=Y(0),s=Ve(),i=Ve(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=Ve(),h=Ve(),p=Y(!1),v=Y(!1),x=Y(!1);return ve(W(e,ue(({scrollTop:g})=>g)),t),ve(W(e,ue(({scrollHeight:g})=>g)),i),ve(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),ro={lvl:0};function Qc(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function st(e){return e===ro}function oo(e,t){if(!st(e))return t===e.k?e.v:t<e.k?oo(e.l,t):oo(e.r,t)}function hn(e,t,n="k"){if(st(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=hn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return hn(e.l,t,n)}function Yt(e,t,n){return st(e)?nu(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?ru(wt(e,{l:Yt(e.l,t,n)})):ru(wt(e,{r:Yt(e.r,t,n)}))}function Or(){return ro}function Qo(e,t,n){if(st(e))return[];const r=hn(e,t)[0];return Jx(Wi(e,r,n))}function Ui(e,t){if(st(e))return ro;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=tu(r);return es(wt(e,{k:s,l:eu(r),v:i}))}}else return t<n?es(wt(e,{l:Ui(r,t)})):es(wt(e,{r:Ui(o,t)}))}function hr(e){return st(e)?[]:[...hr(e.l),{k:e.k,v:e.v},...hr(e.r)]}function Wi(e,t,n){if(st(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Wi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Wi(s,t,n))),a}function es(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(Vi(t))return ou(wt(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Vi(e))return Ki(wt(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=Vi(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ki(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return nu(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 eu(e){return st(e.r)?e.l:es(wt(e,{r:eu(e.r)}))}function Vi(e){return st(e)||e.lvl>e.r.lvl}function tu(e){return st(e.r)?[e.k,e.v]:tu(e.r)}function nu(e,t,n,r=ro,o=ro){return{k:e,l:r,lvl:n,r:o,v:t}}function ru(e){return Ki(ou(e))}function ou(e){const{l:t}=e;return!st(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Ki(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function Jx(e){return Qc(e,({k:t,v:n})=>({index:t,value:n}))}function su(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function so(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const qi=Ye(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function iu(e,t,n){return e[ts(e,t,n)]}function ts(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 Zx(e,t,n,r){const o=ts(e,t,r),s=ts(e,n,r,o);return e.slice(o,s+1)}function qn(e,t){return Math.round(e.getBoundingClientRect()[t])}function ns(e){return!st(e.groupOffsetTree)}function Gi({index:e},t){return t===e?0:t<e?-1:1}function Qx(){return{groupIndices:[],groupOffsetTree:Or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Or()}}function ey(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=Yt(e,0,s);continue}const a=Qo(e,i-1,o+1);if(a.some(ay(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ui(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Yt(e,o+1,h));u&&(e=Yt(e,i,s))}return[e,n]}function ty(e){return typeof e.groupIndex<"u"}function ny({offset:e},t){return t===e?0:t<e?-1:1}function io(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=iu(t,e,Gi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function au(e,t){if(!ns(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lu(e,t,n){if(ty(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=au(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function ry(e,t,n,r=0){return r>0&&(t=Math.max(t,iu(e,r,Gi).offset)),Qc(Zx(e,t,n,ny),iy)}function oy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&st(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>Yt(Yt(v,x,h),x+1,p),i)}else[i,a]=ey(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Yi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Yt(h,p,io(p,f,o)),Or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function sy(e){return hr(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 cu(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 Yi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ts(o,t-1,Gi),a=o[l].offset;const u=hn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Qo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function iy(e){return{index:e.index,value:e}}function ay(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 ly={offsetHeight:"height",offsetWidth:"width"},Tn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Dt(r,0),s=Ve(),i=Ve(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((C,T)=>qn(C,ly[T])),h=Y(void 0),p=Y(0),v=Qx(),x=Dt(W(n,De(l,e,p),Cn(oy,v),ct()),v),g=Dt(W(l,ct(),Cn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);ve(W(l,ke(C=>C.length>0),De(x,p),ue(([C,T,I])=>{const _=C.reduce((R,j,$)=>Yt(R,j,io(j,T.offsetTree,I)||$),Or());return{...T,groupIndices:C,groupOffsetTree:_}})),x),ve(W(r,De(x),ke(([C,{lastIndex:T}])=>C<T),ue(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ve(u,d);const y=Dt(W(u,ue(C=>C===void 0)),!0);ve(W(d,ke(C=>C!==void 0&&st(yt(x).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Gt(W(n,De(x),Cn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),ue(C=>C.changed)));Je(W(a,Cn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:T}=yt(x);if(C>0)Oe(t,!0),Oe(s,C+cu(C,T));else if(C<0){const I=yt(g);I.length>0&&(C-=cu(-C,I)),Oe(i,C)}}),Je(W(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=Gt(s);ve(W(s,De(x),ue(([C,T])=>{const I=T.groupIndices.length>0,_=[],R=T.lastSize;if(I){const j=oo(T.sizeTree,0);let $=0,L=0;for(;$<C;){const M=T.groupIndices[L],H=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-M-1;_.push({endIndex:M,size:j,startIndex:M}),_.push({endIndex:M+1+H-1,size:R,startIndex:M+1}),L++,$+=H+1}const F=hr(T.sizeTree);return $!==C&&F.shift(),F.reduce((M,{k:H,v:z})=>{let te=M.ranges;return M.prevSize!==0&&(te=[...M.ranges,{endIndex:H+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:H+C,prevSize:z,ranges:te}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return hr(T.sizeTree).reduce((j,{k:$,v:L})=>({prevIndex:$+C,prevSize:L,ranges:[...j.ranges,{endIndex:$+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=Gt(W(i,De(x,p),ue(([C,{offsetTree:T},I])=>{const _=-C;return io(_,T,I)})));return ve(W(i,De(x,p),ue(([C,T,I])=>{if(T.groupIndices.length>0){if(st(T.sizeTree))return T;let _=Or();const R=yt(g);let j=0,$=0,L=0;for(;j<-C;){L=R[$];const F=R[$+1]-L-1;$++,j+=F+1}if(_=hr(T.sizeTree).reduce((F,{k:M,v:H})=>Yt(F,Math.max(0,M+C),H),_),j!==-C){const F=oo(T.sizeTree,L);_=Yt(_,0,F);const M=hn(T.sizeTree,-C+1)[1];_=Yt(_,1,M)}return{...T,sizeTree:_,...Yi(T.offsetTree,0,_,I)}}else{const _=hr(T.sizeTree).reduce((R,{k:j,v:$})=>Yt(R,Math.max(0,j+C),$),Or());return{...T,sizeTree:_,...Yi(T.offsetTree,0,_,I)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Kn,qi),{singleton:!0});function cy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uu=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Gt(W(s,ue(cy)));return ve(W(a,ue(l=>l.totalCount)),n),ve(W(a,ue(l=>l.groupIndices)),e),ve(W(vt(o,t,r),ke(([l,u])=>ns(u)),ue(([l,u,d])=>hn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(Tn,zt)),Gn=Ye(([{log:e}])=>{const t=Y(!1),n=Gt(W(t,ke(r=>r),ct()));return Je(t,r=>{r&&yt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},lt(Kn),{singleton:!0}),uy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function du(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!uy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ao=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ve(),v=Ve(),x=Y(0);let g=null,y=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Oe(l,!1)}return ve(W(p,De(n,f,r,x,a,i,h),De(e,s,o),ue(([[E,C,T,I,_,R,j,$],L,F,M])=>{const H=du(E),{align:z,behavior:te,offset:V}=H,U=I-1,me=lu(H,C,U);let O=io(me,C.offsetTree,L)+R;z==="end"?(O+=F+hn(C.sizeTree,me)[1]-T+M,me===U&&(O+=j)):z==="center"?O+=(F+hn(C.sizeTree,me)[1]-T+M)/2:O-=_,V&&(O+=V);const G=le=>{S(),le?($("retrying to scroll to",{location:E},Vt.DEBUG),Oe(p,E)):(Oe(v,!0),$("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),te==="smooth"){let le=!1;b=Je(t,be=>{le=le||be}),g=fn(d,()=>{G(le)})}else g=fn(W(t,dy(150)),G);return y=setTimeout(()=>{S()},1200),Oe(l,!0),$("scrolling from index to",{behavior:te,index:me,top:O},Vt.DEBUG),{behavior:te,top:O}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},lt(Tn,zt,Kn),{singleton:!0});function dy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Xi(e,t){e==0?t():requestAnimationFrame(()=>{Xi(e-1,t)})}function Ji(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const lo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),u=Y(!0);return ve(W(i,De(l),ke(([d,f])=>!!f),Sn(!1)),a),ve(W(i,De(l),ke(([d,f])=>!!f),Sn(!1)),u),Je(W(vt(t,i),De(a,n,e,u),ke(([[,d],f,{sizeTree:h},p,v])=>d&&(!st(h)||Fi(p))&&!f&&!v),De(l)),([,d])=>{fn(o,()=>{Oe(u,!0)}),Xi(4,()=>{fn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(Tn,zt,ao,Gn),{singleton:!0});function fu(e,t){return Math.abs(e-t)<1.01}const co="up",uo="down",fy="none",hy={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},py=0,fo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ve(),u=Ve(),d=Y(4),f=Y(py),h=Dt(W(Bi(W(Te(o),dr(1),Sn(!0)),W(Te(o),dr(1),Sn(!1),Yc(100))),ct()),!1),p=Dt(W(Bi(W(n,Sn(!0)),W(n,Sn(!1),Yc(200))),ct()),!1);ve(W(vt(Te(o),Te(f)),ue(([b,S])=>b<=S),ct()),a),ve(W(a,Fn(50)),u);const v=Gt(W(vt(r,Te(s),Te(t),Te(e),Te(d)),Cn((b,[{scrollHeight:S,scrollTop:E},C,T,I,_])=>{const R=E+C-S>-_,j={scrollHeight:S,scrollTop:E,viewportHeight:C};if(R){let L,F;return E>b.state.scrollTop?(L="SCROLLED_DOWN",F=b.state.scrollTop-E):(L="SIZE_DECREASED",F=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:F,state:j}}let $;return j.scrollHeight>b.state.scrollHeight?$="SIZE_INCREASED":C<b.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:j}},hy),ct((b,S)=>b&&b.atBottom===S.atBottom))),x=Dt(W(r,Cn((b,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(fu(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const T=S-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(b=>b.changed),ue(b=>b.jump)),0);ve(W(v,ue(b=>b.atBottom)),i),ve(W(i,Fn(50)),l);const g=Y(uo);ve(W(r,ue(({scrollTop:b})=>b),ct(),Cn((b,S)=>yt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?co:uo,prevScrollTop:S},{direction:uo,prevScrollTop:0}),ue(b=>b.direction)),g),ve(W(r,Fn(50),Sn(fy)),g);const y=Y(0);return ve(W(h,ke(b=>!b),Sn(0)),y),ve(W(o,Fn(100),De(h),ke(([b,S])=>!!S),Cn(([b,S],[E])=>[S,E],[0,0]),ue(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},lt(zt)),rs="top",os="bottom",hu="none";function pu(e,t,n){return typeof e=="number"?n===co&&t===rs||n===uo&&t===os?e:0:n===co?t===rs?e.main:e.reverse:t===os?e.main:e.reverse}function mu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Zi=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=Y(0),a=Y(0),l=Y(0),u=Dt(W(vt(Te(r),Te(o),Te(n),Te(s,so),Te(l),Te(i),Te(t),Te(e),Te(a)),ue(([d,f,h,[p,v],x,g,y,b,S])=>{const E=d-b,C=g+y,T=Math.max(h-E,0);let I=hu;const _=mu(S,rs),R=mu(S,os);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+C-_&&(I=co),v<d-T+f+R&&(I=uo),I!==hu?[Math.max(E-h-pu(x,rs,I)-_,0),E-T-y+f+pu(x,os,I)+R]:null}),ke(d=>d!=null),ct(so)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},lt(zt),{singleton:!0});function my(e,t,n){if(ns(t)){const r=au(e,t);return[{index:hn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Qi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ss(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:xu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function gu(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=Ji(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ss(u,[],a,o,n,r)}function xu(e,t,n){if(e.length===0)return[];if(!ns(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Qo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const pr=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=Y([]),g=Y(0),y=Ve();ve(s.topItemsIndexes,x);const b=Dt(W(vt(p,v,Te(l,so),Te(o),Te(r),Te(u),d,Te(x),Te(t),Te(n),e),ke(([T,I,,_,,,,,,,R])=>{const j=R&&R.length!==_;return T&&!I&&!j}),ue(([,,[T,I],_,R,j,$,L,F,M,H])=>{const z=R,{offsetTree:te,sizeTree:V}=z,U=yt(g);if(_===0)return{...Qi,totalCount:_};if(T===0&&I===0)return U===0?{...Qi,totalCount:_}:gu(U,j,R,F,M,H||[]);if(st(V))return U>0?null:ss(my(Ji(j,_),z,H),[],_,M,z,F);const me=[];if(L.length>0){const ge=L[0],ye=L[L.length-1];let K=0;for(const D of Qo(V,ge,ye)){const X=D.value,Z=Math.max(D.start,ge),de=Math.min(D.end,ye);for(let ie=Z;ie<=de;ie++)me.push({data:H==null?void 0:H[ie],index:ie,offset:K,size:X}),K+=X}}if(!$)return ss([],me,_,M,z,F);const O=L.length>0?L[L.length-1]+1:0,G=ry(te,T,I,O);if(G.length===0)return null;const le=_-1,be=Zo([],ge=>{for(const ye of G){const K=ye.value;let D=K.offset,X=ye.start;const Z=K.size;if(K.offset<T){X+=Math.floor((T-K.offset+M)/(Z+M));const ie=X-ye.start;D+=ie*Z+ie*M}X<O&&(D+=(O-X)*Z,X=O);const de=Math.min(ye.end,le);for(let ie=X;ie<=de&&!(D>=I);ie++)ge.push({data:H==null?void 0:H[ie],index:ie,offset:D,size:Z}),D+=Z+M}});return ss(be,me,_,M,z,F)}),ke(T=>T!==null),ct()),Qi);ve(W(e,ke(Fi),ue(T=>T==null?void 0:T.length)),o),ve(W(b,ue(T=>T.topListHeight)),f),ve(f,a),ve(W(b,ue(T=>[T.top,T.bottom])),i),ve(W(b,ue(T=>T.items)),y);const S=Gt(W(b,ke(({items:T})=>T.length>0),De(o,e),ke(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ue(([,T,I])=>[T-1,I]),ct(so),ue(([T])=>T))),E=Gt(W(b,Fn(200),ke(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ue(({items:T})=>T[0].index),ct())),C=Gt(W(b,ke(({items:T})=>T.length>0),ue(({items:T})=>{let I=0,_=T.length-1;for(;T[I].type==="group"&&I<_;)I++;for(;T[_].type==="group"&&_>I;)_--;return{endIndex:T[_].index,startIndex:T[I].index}}),ct(su)));return{endReached:S,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:x,...h}},lt(Tn,uu,Zi,lo,ao,fo,Gn,qi),{singleton:!0}),yu=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Dt(W(vt(n,e,r,t,o),ue(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(zt,pr),{singleton:!0}),gy=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=Dt(W(vt(n,e,t),ke(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),Fn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(zt,yu),{singleton:!0}),vu=Ye(()=>({context:Y(null)})),xy=({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,bu=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ve();return ve(W(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,h,p,v,x,g,y,b],S])=>{const{align:E,behavior:C,calculateViewLocation:T=xy,done:I,..._}=f,R=lu(f,h,v-1),j=io(R,h.offsetTree,S)+x+g,$=j+hn(h.sizeTree,R)[1],L=b+g,F=b+p-y,M=T({itemBottom:$,itemTop:j,locationParams:{align:E,behavior:C,..._},viewportBottom:F,viewportTop:L});return M?I&&fn(W(i,ke(H=>!H),dr(yt(i)?1:2)),I):I&&I(),M}),ke(f=>f!==null)),u),{scrollIntoView:d}},lt(Tn,zt,ao,pr,Kn),{singleton:!0});function wu(e){return e?e==="smooth"?"smooth":"auto":!1}const yy=(e,t)=>typeof e=="function"?wu(e(t)):t&&wu(e),vy=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=Y(!1),x=Ve();let g=null;function y(C){Oe(i,{align:"end",behavior:C,index:"LAST"})}Je(W(vt(W(Te(t),dr(1)),l),De(Te(v),s,a,f),ue(([[C,T],I,_,R,j])=>{let $=T&&R,L="auto";return $&&(L=yy(I,_||j),$=$&&!!L),{followOutputBehavior:L,shouldFollow:$,totalCount:C}}),ke(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),yt(n)?requestAnimationFrame(()=>{yt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):g=fn(e,()=>{yt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),g=null})});function b(C){const T=fn(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(yt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Je(W(vt(Te(v),t,u),ke(([C,,T])=>C&&T),Cn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),ke(({refreshed:C})=>C),De(v,t)),([,C])=>{yt(a)&&b(C!==!1)}),Je(x,()=>{b(yt(v)!==!1)}),Je(vt(Te(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=Y(null),E=Ve();return ve(Bi(W(Te(r),ue(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),W(Te(t))),E),Je(W(vt(W(E,dr(1)),l),De(Te(S),a,f,h),ue(([[C,T],I,_,R,j])=>T&&_&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:R}))),ke(C=>!!C),Fn(0)),C=>{g&&(g(),g=null),yt(n)?requestAnimationFrame(()=>{yt(d)("scrolling into view",{}),Oe(p,C)}):g=fn(e,()=>{yt(d)("scrolling into view",{}),Oe(p,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},lt(Tn,fo,ao,lo,Gn,Kn,zt,vu,bu)),by=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(W(a,De(s),ke(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],u,d,f,h,p=[]])=>gu(l,u,d,f,h,p))),i),{}),lt(Tn,lo,pr,Gn),{singleton:!0}),wy=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Je(W(e,De(r),ke(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(W(n,dr(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},lt(Gn,zt,pr),{singleton:!0}),Su=Ye(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ve(),r=Y(!1);return ve(W(e,De(r,t,n),ke(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Je(W(vt(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}},lt(fo),{singleton:!0}),ea=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=Y(!1),i=Y(void 0);return ve(W(vt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(W(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(zt)),Sy=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ve(),d=Y(void 0),f=Y(null),h=Y(null);return ve(a,f),ve(l,h),Je(W(u,De(t,r,i,f,h,n)),([p,v,x,g,y,b,S])=>{const E=sy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=S,p({ranges:E,scrollTop:x})}),ve(W(d,ke(Fi),ue(Cy)),o),ve(W(s,De(d),ke(([,p])=>p!==void 0),ct(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},lt(Tn,zt,lo,Gn,ea));function Cy(e){return{align:"start",index:0,offset:e.scrollTop}}const Ty=Ye(([{topItemsIndexes:e}])=>{const t=Y(0);return ve(W(t,ke(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(pr));function Cu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ky=Cu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ey=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Gt(W(l,De(i),Cn(([,y,b,S],[{bottom:E,items:C,offsetBottom:T,totalCount:I},_])=>{const R=E+T;let j=0;return b===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(j=R-S,j!==0&&(j+=_))),[j,C,I,R]},[0,[],0,0]),ke(([y])=>y!==0),De(r,a,n,o,p,v),ke(([,y,b,S,,,E])=>!E&&!S&&y!==0&&b===co),ue(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function g(y){y>0?(Oe(t,{behavior:"auto",top:-y}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-y}))}return Je(W(x,De(e,s)),([y,b,S])=>{S&&ky()?Oe(e,b-y):g(-y)}),Je(W(vt(Dt(s,!1),e,v),ke(([y,b,S])=>!y&&!S&&b!==0),ue(([y,b])=>b),Fn(1)),g),ve(W(f,ue(y=>({top:-y}))),t),Je(W(u,De(h,d),ue(([y,{groupIndices:b,lastSize:S,sizeTree:E},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(y);{let I=0;const _=oo(E,0);let R=0,j=0;for(;R<y;){R++,I+=_;let $=b.length===j+1?1/0:b[j+1]-b[j]-1;R+$>y&&(I-=_,$=y-R+1),R+=$,I+=T($),j++}return I}})),y=>{Oe(e,y),requestAnimationFrame(()=>{Oe(t,{top:y}),requestAnimationFrame(()=>{Oe(e,0),Oe(v,!1)})})}),{deviation:e}},lt(zt,fo,pr,Tn,Kn,qi)),Iy=Ye(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),lt(Zi,by,Gn,Su,yu,wy,gy,ea,bu,Kn,vu)),Tu=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:S,...E},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:_},R])=>(ve(E.rangeChanged,R.scrollSeekRangeChanged),ve(W(R.windowViewportRect,ue(j=>j.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...R,...x,sizes:l,...g}),lt(Tn,lo,zt,Sy,vy,pr,ao,Ey,Ty,uu,Iy));function Ny(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 is=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ku(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(g,y){g.propsReady&&Oe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Oe(S,y[b])}for(const b of o)if(b in y){const S=g[t.optional[b]];Oe(S,y[b])}g.propsReady&&Oe(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=S=>{const E=g[t.methods[b]];Oe(E,S)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=Wx(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...S}=g,[E]=w.useState(()=>Zo(Kx(e),I=>{l(I,S)})),[C]=w.useState(Gc(d,E));is(()=>{for(const I of i)I in S&&Je(C[I],S[I]);return()=>{Object.values(C).map(zi)}},[S,C,E]),is(()=>{l(E,S)}),w.useImperativeHandle(y,Kc(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...Ny([...r,...o,...i],S),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Oe(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(S=>Je(y,S),[y]);return w.useSyncExternalStore(b,()=>yt(y),()=>yt(y))},v=g=>{const y=w.useContext(a)[g],[b,S]=w.useState(Gc(yt,y));return is(()=>Je(y,E=>{E!==b&&S(Kc(E))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];is(()=>Je(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const Eu=w.createContext(void 0),Iu=w.createContext(void 0),Nu=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ta(e){return"self"in e}function Ay(e){return"body"in e}function Au(e,t,n,r=Pr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Ay(g)||ta(g)){const b=ta(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():di.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;ta(p)?(g=Math.max(qn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=qn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),fu(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const na="-webkit-sticky",_u="sticky",ra=Cu(()=>{if(typeof document>"u")return _u;const e=document.createElement("div");return e.style.position=na,e.style.position===na?na:_u});function oa(e){return e}const _y=Ye(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(oa),o=Y("div"),s=Y(Pr),i=(a,l=null)=>Dt(W(n,ue(u=>u[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),jy=Ye(([e,t])=>({...e,...t}),lt(Tu,_y)),Ry=({height:e})=>c.jsx("div",{style:{height:e}}),Py={overflowAnchor:"none",position:ra(),zIndex:1},ju={overflowAnchor:"none"},Oy={...ju,display:"inline-block",height:"100%"},Ru=w.memo(function({showTopList:e=!1}){const t=_e("listState"),n=rn("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),v=rn("gap"),x=_e("horizontalDirection"),{callbackRef:g}=Yx(n,h,f,e?Pr:a,p,v,o,x,_e("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);sa("deviation",M=>{y!==M&&b(M)});const S=_e("EmptyPlaceholder"),E=_e("ScrollSeekPlaceholder")||Ry,C=_e("ListComponent"),T=_e("ItemComponent"),I=_e("GroupComponent"),_=_e("computeItemKey"),R=_e("isSeeking"),j=_e("groupIndices").length>0,$=_e("alignToBottom"),L=_e("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Lt(S,u)}):c.jsx(C,{...Lt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:F,children:(e?t.topItems:t.items).map(M=>{const H=M.originalIndex,z=_(H+t.firstItemIndex,M.data,u);return R?w.createElement(E,{...Lt(E,u),height:M.size,index:M.index,key:z,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(I,{...Lt(I,u),"data-index":H,"data-item-index":M.index,"data-known-size":M.size,key:z,style:Py},d(M.index,u)):w.createElement(T,{...Lt(T,u),...$y(T,M.data),"data-index":H,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:z,style:x?Oy:ju},j?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),My={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Dy={outline:"none",overflowX:"auto",position:"relative"},as=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ly={position:ra(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function $y(e,t){return{item:typeof e=="string"?void 0:t}}const Fy=w.memo(function(){const e=_e("HeaderComponent"),t=rn("headerHeight"),n=_e("HeaderFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),zy=w.memo(function(){const e=_e("FooterComponent"),t=rn("footerHeight"),n=_e("HeaderFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null});function Pu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Au(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Dy:My,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function Ou({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Au(a,u,l,v,h);return Nu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const By=({children:e})=>{const t=w.useContext(Eu),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=w.useMemo(()=>qc(n,l=>qn(l,s?"width":"height")),[n,s]),a=fr(i,!0,_e("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:as(o),children:e})},Hy=({children:e})=>{const t=w.useContext(Eu),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=_e("customScrollParent"),s=Zc(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:as(i),children:e})},Uy=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...Ly,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,...Lt(t,o),children:e})},Wy=w.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return c.jsxs(r||t?qy:Ky,{...e,context:o,children:[n&&c.jsx(Uy,{children:c.jsx(Ru,{showTopList:!0})}),c.jsxs(r||t?Hy:By,{children:[c.jsx(Fy,{}),c.jsx(Ru,{}),c.jsx(zy,{})]})]})}),{Component:Vy,useEmitter:sa,useEmitterValue:_e,usePublisher:rn}=ku(jy,{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"}},Wy),Ky=Pu({useEmitter:sa,useEmitterValue:_e,usePublisher:rn}),qy=Ou({useEmitter:sa,useEmitterValue:_e,usePublisher:rn}),Gy=Vy;lt(Tu,Ye(()=>{const e=Y(u=>c.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(oa),a=Y(Pr),l=(u,d=null)=>Dt(W(s,ue(f=>f[u]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),ra();const Mu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Yy={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Du,floor:ls,max:ho,min:ia,round:Lu}=Math;function $u(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Xy(e){return{...Yy,items:e}}function cs(e,t){return e&&e.width===t.width&&e.height===t.height}function Jy(e,t){return e&&e.column===t.column&&e.row===t.row}const Zy=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E},C])=>{const T=Y(0),I=Y(0),_=Y(Mu),R=Y({height:0,width:0}),j=Y({height:0,width:0}),$=Ve(),L=Ve(),F=Y(0),M=Y(null),H=Y({column:0,row:0}),z=Ve(),te=Ve(),V=Y(!1),U=Y(0),me=Y(!0),O=Y(!1),G=Y(!1);Je(W(v,De(U),ke(([D,X])=>!!X)),()=>{Oe(me,!1)}),Je(W(vt(v,me,j,R,U,O),ke(([D,X,Z,de,,ie])=>D&&!X&&Z.height!==0&&de.height!==0&&!ie)),([,,,,D])=>{Oe(O,!0),Xi(1,()=>{Oe($,D)}),fn(W(u),()=>{Oe(t,[0,0]),Oe(me,!0)})}),ve(W(te,ke(D=>D!=null&&D.scrollTop>0),Sn(0)),I),Je(W(v,De(te),ke(([,D])=>D!=null)),([,D])=>{D&&(Oe(R,D.viewport),Oe(j,D.item),Oe(H,D.gap),D.scrollTop>0&&(Oe(V,!0),fn(W(u,dr(1)),X=>{Oe(V,!1)}),Oe(l,{top:D.scrollTop})))}),ve(W(R,ue(({height:D})=>D)),f),ve(W(vt(Te(R,cs),Te(j,cs),Te(H,(D,X)=>D&&D.column===X.column&&D.row===X.row),Te(u)),ue(([D,X,Z,de])=>({gap:Z,item:X,scrollTop:de,viewport:D}))),z),ve(W(vt(Te(T),r,Te(H,Jy),Te(j,cs),Te(R,cs),Te(M),Te(I),Te(V),Te(me),Te(U)),ke(([,,,,,,,D])=>!D),ue(([D,[X,Z],de,ie,Q,tt,Ze,,Re,ze])=>{const{column:nt,row:rt}=de,{height:Pe,width:St}=ie,{width:Ct}=Q;if(Ze===0&&(D===0||Ct===0))return Mu;if(St===0){const Me=Ji(ze,D),Le=Me+Math.max(Ze-1,0);return Xy($u(Me,Le,tt))}const kt=Fu(Ct,St,nt);let ut,et;Re?X===0&&Z===0&&Ze>0?(ut=0,et=Ze-1):(ut=kt*ls((X+rt)/(Pe+rt)),et=kt*Du((Z+rt)/(Pe+rt))-1,et=ia(D-1,ho(et,kt-1)),ut=ia(et,ho(0,ut))):(ut=0,et=-1);const Be=$u(ut,et,tt),{bottom:dt,top:re}=zu(Q,de,ie,Be),oe=Du(D/kt),xe=oe*Pe+(oe-1)*rt-dt;return{bottom:dt,itemHeight:Pe,items:Be,itemWidth:St,offsetBottom:xe,offsetTop:re,top:re}})),_),ve(W(M,ke(D=>D!==null),ue(D=>D.length)),T),ve(W(vt(R,j,_,H),ke(([D,X,{items:Z}])=>Z.length>0&&X.height!==0&&D.height!==0),ue(([D,X,{items:Z},de])=>{const{bottom:ie,top:Q}=zu(D,de,X,Z);return[Q,ie]}),ct(so)),t);const le=Y(!1);ve(W(u,De(le),ue(([D,X])=>X||D!==0)),le);const be=Gt(W(vt(_,T),ke(([{items:D}])=>D.length>0),De(le),ke(([[D,X],Z])=>{const de=D.items[D.items.length-1].index===X-1;return(Z||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&de}),ue(([[,D]])=>D-1),ct())),ge=Gt(W(Te(_),ke(({items:D})=>D.length>0&&D[0].index===0),Sn(0),ct())),ye=Gt(W(Te(_),De(V),ke(([{items:D},X])=>D.length>0&&!X),ue(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ct(su),Fn(0)));ve(ye,p.scrollSeekRangeChanged),ve(W($,De(R,j,T,H),ue(([D,X,Z,de,ie])=>{const Q=du(D),{align:tt,behavior:Ze,offset:Re}=Q;let ze=Q.index;ze==="LAST"&&(ze=de-1),ze=ho(0,ze,ia(de-1,ze));let nt=aa(X,ie,Z,ze);return tt==="end"?nt=Lu(nt-X.height+Z.height):tt==="center"&&(nt=Lu(nt-X.height/2+Z.height/2)),Re&&(nt+=Re),{behavior:Ze,top:nt}})),l);const K=Dt(W(_,ue(D=>D.offsetBottom+D.bottom)),0);return ve(W(E,ue(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:g,data:M,deviation:F,footerHeight:o,gap:H,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:te,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:$,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E,...p,gridState:_,horizontalDirection:G,initialTopMostItemIndex:U,totalListHeight:K,...h,endReached:be,propsReady:x,rangeChanged:ye,startReached:ge,stateChanged:z,stateRestoreInProgress:V,...C}},lt(Zi,zt,fo,Su,Gn,ea,Kn));function Fu(e,t,n){return ho(1,ls((e+n)/(ls(t)+n)))}function zu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=aa(e,t,n,r[0].index);return{bottom:aa(e,t,n,r[r.length-1].index)+o,top:s}}function aa(e,t,n,r){const o=Fu(e.width,n.width,t.column),s=ls(r/o),i=s*n.height+ho(0,s-1)*t.row;return i>0?i+t.row:i}const Qy=Ye(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(oa),i=Y("div"),a=Y(Pr),l=(f,h=null)=>Dt(W(t,ue(p=>p[f]),ct()),h),u=Y(!1),d=Y(!1);return ve(Te(d),u),{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:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),ev=Ye(([e,t])=>({...e,...t}),lt(Zy,Qy)),tv=w.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=on("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=on("itemDimensions"),h=on("gap"),p=ft("log"),v=ft("stateRestoreInProgress"),x=on("reportReadyState"),g=fr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();f({height:E,width:C})}h({column:Hu("column-gap",getComputedStyle(y).columnGap,p),row:Hu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Nu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Lt(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?c.jsx(u,{...Lt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Lt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),nv=w.memo(function(){const e=ft("HeaderComponent"),t=on("headerHeight"),n=ft("headerFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),rv=w.memo(function(){const e=ft("FooterComponent"),t=on("footerHeight"),n=ft("headerFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),ov=({children:e})=>{const t=w.useContext(Iu),n=on("itemDimensions"),r=on("viewportDimensions"),o=fr(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]),c.jsx("div",{ref:o,style:as(!1),children:e})},sv=({children:e})=>{const t=w.useContext(Iu),n=on("windowViewportRect"),r=on("itemDimensions"),o=ft("customScrollParent"),s=Zc(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]),c.jsx("div",{ref:s,style:as(!1),children:e})},iv=w.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?lv:av,o=n||t?sv:ov,s=ft("context");return c.jsx(r,{...e,...Lt(r,s),children:c.jsxs(o,{children:[c.jsx(nv,{}),c.jsx(tv,{}),c.jsx(rv,{})]})})}),{useEmitter:Bu,useEmitterValue:ft,usePublisher:on}=ku(ev,{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"}},iv),av=Pu({useEmitter:Bu,useEmitterValue:ft,usePublisher:on}),lv=Ou({useEmitter:Bu,useEmitterValue:ft,usePublisher:on});function Hu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const cv=Po.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 la({className:e,variant:t,...n}){return c.jsx("div",{className:ne(cv({variant:t}),e),...n})}function he(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 uv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.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 kn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,dv(o,...t)]}function dv(...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:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},fv=m[" useInsertionEffect ".trim().toString()]||Tt;function mr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=hv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"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 u=m.useCallback(d=>{var f;if(a){const h=pv(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function hv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return fv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function pv(e){return typeof e=="function"}function Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ca(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Uu(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():Uu(e[o],null)}}}}function We(...e){return m.useCallback(ca(...e),e)}var mv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=mv.reduce((e,t)=>{const n=ir.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wu(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function gv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=xv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,yv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function xv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=gv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=us(r.current);s.current=a==="mounted"?u:"none"},[a]),Tt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=us(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=us(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=us(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function us(e){return(e==null?void 0:e.animationName)||"none"}function yv(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 vv=m[" useId ".trim().toString()]||(()=>{}),bv=0;function En(e){const[t,n]=m.useState(vv());return Tt(()=>{n(r=>r??String(bv++))},[e]),e||(t?`radix-${t}`:"")}var ds="Collapsible",[wv,ok]=kn(ds),[Sv,ua]=wv(ds),Vu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=mr({prop:r,defaultProp:o??!1,onChange:i,caller:ds});return c.jsx(Sv,{scope:n,disabled:s,contentId:En(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ee.div,{"data-state":fa(l),"data-disabled":s?"":void 0,...a,ref:t})})});Vu.displayName=ds;var Ku="CollapsibleTrigger",qu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ua(Ku,n);return c.jsx(Ee.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":fa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:he(e.onClick,o.onOpenToggle)})});qu.displayName=Ku;var da="CollapsibleContent",Cv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ua(da,e.__scopeCollapsible);return c.jsx(Xt,{present:n||o.open,children:({present:s})=>c.jsx(Tv,{...r,ref:t,present:s})})});Cv.displayName=da;var Tv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ua(da,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),Tt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ee.div,{"data-state":fa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function fa(e){return e?"open":"closed"}var kv=Vu;const Gu=kv,Yu=qu,po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));po.displayName="Card";const mo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));mo.displayName="CardHeader";const go=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));go.displayName="CardTitle";const Xu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Xu.displayName="CardDescription";const xo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));xo.displayName="CardContent";const Ju=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Ju.displayName="CardFooter";function Zu(){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 gr=Zu();function Ev(e){gr=e}const Qu=/[&<>"']/,Iv=new RegExp(Qu.source,"g"),ed=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Nv=new RegExp(ed.source,"g"),Av={"&":"&","<":"<",">":">",'"':""","'":"'"},td=e=>Av[e];function $t(e,t){if(t){if(Qu.test(e))return e.replace(Iv,td)}else if(ed.test(e))return e.replace(Nv,td);return e}const _v=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function nd(e){return e.replace(_v,(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 jv=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(jv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Rv=/[^\w:]/g,Pv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rd(e,t,n){if(e){let r;try{r=decodeURIComponent(nd(n)).replace(Rv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Pv.test(n)&&(n=Lv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const fs={},Ov=/^[^:]+:\/*[^/]*$/,Mv=/^([^:]+:)[\s\S]*$/,Dv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Lv(e,t){fs[" "+e]||(Ov.test(e)?fs[" "+e]=e+"/":fs[" "+e]=ps(e,"/",!0)),e=fs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Mv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Dv,"$1")+t:e+t}const hs={exec:function(){}};function od(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)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 ps(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 $v(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 Fv(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 sd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function id(e,t,n,r){const o=t.href,s=t.title?$t(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:$t(i)}}function zv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
37
|
+
`))>=0;){const kt=V.slice(0,Ct);V=V.slice(Ct+2);const ut=wx(kt);if(!ut)continue;let et;try{et=JSON.parse(ut)}catch{console.debug("[use-chat] malformed SSE:",ut.slice(0,200));continue}const Be=bx(et)?et.data:et;Q=Date.now();const dt=Be.seq;if(dt!==void 0){if(dt<=X){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:dt,lastProcessedSeq:X,type:Be.type});continue}X>0&&dt>X+1&&((F=L==null?void 0:L.onGap)==null||F.call(L,{from:X,to:dt})),X=dt,C.current=dt,g(dt)}if(console.debug("[use-chat] received event",{seq:Be.seq,type:Be.type,preview:(()=>{var re;try{return Be.type==="message_delta"?{deltaTypes:(re=Be.delta)==null?void 0:re.map(oe=>oe.type),textLen:(Be.delta||[]).filter(oe=>oe.type==="text").map(oe=>String(oe.text||"").length)}:Be.content||Be.delta?{hasContent:!0}:{}}catch(oe){return{err:String(oe)}}})()}),z==null||z(Be),Be.type==="token"&&e.autoAppendAssistant!==!1)D.push(Be.content),ae();else if(Be.type==="message_delta"){const re=Be.delta.filter(oe=>oe.type==="text").map(oe=>oe.text).join("");re&&e.autoAppendAssistant!==!1&&(D.push(re),ae())}else Be.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(Z!==null&&cancelAnimationFrame(Z),fe(),Be.type==="checkpoint"?v(Be.checkpointId):Be.type==="error"&&d(Be.message))}}fe()}catch(Re){if(Re.name!=="AbortError"){const ze=Re.message||String(Re);d(ze),(ie=L==null?void 0:L.onError)==null||ie.call(L,ze)}}finally{try{await ge.cancel()}catch{}finally{(O=ge.releaseLock)==null||O.call(ge)}Z!==null&&typeof window<"u"&&window.cancelAnimationFrame(Z),clearInterval(tt),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(ce){if(ce.name!=="AbortError"){const be=ce.message||String(ce);d(be),(G=L==null?void 0:L.onError)==null||G.call(L,be)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var j;E.current=!1,(j=S.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:y,stream:R,stop:I,clear:_,setToken:T}}function bx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function wx(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
38
|
+
`)}function Sx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=w.useRef(null),i=w.useCallback(p=>{const v=p.seq??null;if(v!==null){const x=s.current;if(x!==null){if(v<=x)return;v>x+1&&(o==null||o({from:x,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(px(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Mc({baseUrl:e,token:null}),h=w.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:x=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,x)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return w.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}function nn(e,t={}){const n=t.cloneMessages??!1,r=Array.isArray(e==null?void 0:e.messages)?e.messages:[];return{checkpointId:(e==null?void 0:e.checkpointId)??null,checkpointNs:(e==null?void 0:e.checkpointNs)??null,createdAt:(e==null?void 0:e.createdAt)??null,preview:(e==null?void 0:e.preview)??null,role:(e==null?void 0:e.role)??null,parentId:(e==null?void 0:e.parentId)??null,branchLabel:(e==null?void 0:e.branchLabel)??null,lastMessageId:(e==null?void 0:e.lastMessageId)??null,messagesLen:typeof(e==null?void 0:e.messagesLen)=="number"?e.messagesLen:r.length,hasMessages:typeof(e==null?void 0:e.hasMessages)=="boolean"?e.hasMessages:r.length>0,messages:n?r.slice():r,nextCursor:(e==null?void 0:e.nextCursor)??null,nextCursorNs:(e==null?void 0:e.nextCursorNs)??null,interrupt:(e==null?void 0:e.interrupt)??null}}function Cx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Dc(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}const Ko=300;function Lc(e,t=Ko){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:t});return}catch{}window.setTimeout(e,t)}function ur(){return typeof window<"u"&&typeof window.localStorage<"u"}function _i(e){if(!ur())return null;try{return window.localStorage.getItem(e)}catch{return null}}function ji(e,t){if(!ur())return!1;try{return window.localStorage.setItem(e,t),!0}catch{return!1}}function Ri(e){if(ur())try{window.localStorage.removeItem(e)}catch{}}const Tx="cachedThreads",kx="v1",Pi=200;function Ex(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Oi(e,t){return`cachedThreads:v1:${e}:${Ex(t||"anon")}`}function Ix(){const e=_i(Tx);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function Nx(e){const t=_i(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function Mi(e,t){ji(e,JSON.stringify(t))}function Di(e){const t=Nx(e);if(t.length>0)return t;const n=Ix();if(n.length>0)try{Mi(e,n.slice(0,Pi))}catch{}return n}function qo(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Li(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function $i(e,t){return`${e}${t}`}function Ax(e,t){const n=_i($i(e,t));if(!n)return null;try{const r=JSON.parse(n);return typeof(r==null?void 0:r.threadId)!="string"?null:{threadId:r.threadId,snapshot:nn(r.snapshot,{cloneMessages:!0}),updatedAt:typeof r.updatedAt=="number"?r.updatedAt:void 0}}catch{return null}}function _x(e,t,n=100){if(!ur())return;const r=nn(t.snapshot,{cloneMessages:!0}),o={threadId:t.threadId,snapshot:{...r,messages:r.messages.slice(-n)},updatedAt:Date.now()},s=$i(e,t.threadId),i=JSON.stringify(o);if(!ji(s,i))try{const a=[];for(let l=0;l<window.localStorage.length;l++){const u=window.localStorage.key(l);if(!u||u===s||!u.startsWith(e))continue;const d=window.localStorage.getItem(u);if(!d){a.push({key:u,updatedAt:0});continue}try{const f=JSON.parse(d),h=typeof(f==null?void 0:f.updatedAt)=="number"&&Number.isFinite(f.updatedAt)?f.updatedAt:0;a.push({key:u,updatedAt:h})}catch{a.push({key:u,updatedAt:0})}}a.sort((l,u)=>l.updatedAt-u.updatedAt);for(const l of a)if(window.localStorage.removeItem(l.key),ji(s,i))break}catch{}}function jx(e,t){Ri($i(e,t))}function Rx(e){if(ur())try{for(let t=0;t<window.localStorage.length;t++){const n=window.localStorage.key(t);n&&n.startsWith(e)&&window.localStorage.removeItem(n)}}catch{}}const $c=w.createContext(null),Fc=w.createContext(null),zc=w.createContext(null),Px=w.createContext(!1),Bc=50,Ox=750;function Hc(e,t,n){return`${e}__${t??""}__${n??""}`}function Mx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ei(),d=w.useMemo(()=>$n(u),[u]),f=w.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=w.useMemo(()=>`threadPayload:${kx}:${f}:`,[f]),p=w.useCallback(N=>Ax(h,N),[h]),v=w.useCallback((N,A=100)=>{_x(h,N,A)},[h]),x=w.useCallback(N=>{jx(h,N)},[h]),g=w.useCallback(()=>{Rx(h)},[h]),[y,b]=w.useState(()=>{var N;return Oi(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[S,E]=w.useState(()=>{var A;const N=Di(Oi(f,(A=l.getAuthToken)==null?void 0:A.call(l)));return qo(N)}),C=w.useMemo(()=>Li(S),[S]),[T,I]=w.useState(t),[_,R]=w.useState(!1),[j,z]=w.useState(!1),[L,B]=w.useState(null),[M,q]=w.useState(null),[U,te]=w.useState(null),[$,F]=w.useState([]),ie=w.useCallback(()=>{const N=Di(y);w.startTransition(()=>{E(qo(N))})},[y]),[O,G]=w.useState(!1),[ce,be]=w.useState(!1),[ge,ye]=w.useState(null),[V,D]=w.useState(void 0),[X,Z]=w.useState(void 0),[fe,ae]=w.useState(void 0),{state:Q,dispatch:tt,seed:Ze,prepend:Re,pushUser:ze,onEvent:nt,reset:rt}=Ec(),Pe=w.useRef(T);w.useEffect(()=>{Pe.current=T},[T]);const St=w.useRef(!1),Ct=w.useRef([]),kt=w.useRef(null),ut=w.useRef(null),et=w.useRef(new Map),Be=w.useRef(T),dt=w.useRef(!1),re=w.useRef(null),oe=w.useRef(new Map),xe=w.useRef(new Map),Me=w.useRef(new Map),Le=w.useRef(new Map),qe=w.useCallback(N=>{if(!N){F([]);return}const A=oe.current.get(N);if(!A||!A.length){F([]);return}F(A.map(K=>nn(K,{cloneMessages:!0})))},[]);w.useEffect(()=>{qe(T)},[T,qe]);const bt=w.useCallback(()=>{var ee;const N=Le.current;if(N.size<=Bc)return;const A=Array.from(N.entries()).sort((le,J)=>le[1].timestamp-J[1].timestamp),K=N.size-Bc;for(let le=0;le<K;le++){const J=(ee=A[le])==null?void 0:ee[0];J&&N.delete(J)}},[]),ot=w.useCallback((N,A,K)=>{if(!N)return;const ee=K==="replace"?[]:oe.current.get(N)??[],le=K==="replace"?A:[...A,...ee];if(!le.length){K==="replace"&&oe.current.set(N,[]);return}const J=new Map;for(const Ue of le){if(!(Ue!=null&&Ue.checkpointId))continue;const $e=`${Ue.checkpointId}::${Ue.checkpointNs??""}`;J.has($e)||J.set($e,nn(Ue,{cloneMessages:!0}))}const Fe=Array.from(J.values()).sort((Ue,$e)=>{const at=Number.isFinite(Date.parse(Ue.createdAt??""))?Date.parse(Ue.createdAt??""):0;return(Number.isFinite(Date.parse($e.createdAt??""))?Date.parse($e.createdAt??""):0)-at});oe.current.set(N,Fe),N===Pe.current&&qe(N)},[qe]),ht=w.useCallback((N,A,K)=>{if(!N)return;const ee=xe.current.get(N),le=K==="replace"||!ee?new Map:new Map(ee);if(A&&typeof A=="object")for(const[J,Fe]of Object.entries(A)){if(!(Fe!=null&&Fe.checkpointId))continue;const Ue=J||to(Fe.checkpointId,Fe.checkpointNs??null);le.set(Ue,nn(Fe,{cloneMessages:!0}))}xe.current.set(N,le)},[]),Kt=w.useCallback((N,A)=>{const{threadId:K,checkpointId:ee=null,checkpointNs:le=null}=N,J=Hc(K,ee,le);if(A!=null&&A.force)Me.current.delete(J),Le.current.delete(J);else{if(A!=null&&A.preferCache){const at=Le.current.get(J);if(at)return Promise.resolve(at.payload)}const $e=Me.current.get(J);if($e)return $e}const Ue=l.getStateHistory({threadId:K,checkpointId:ee??void 0,checkpointNs:le??void 0}).then($e=>(Le.current.set(J,{payload:$e,timestamp:Date.now()}),bt(),$e)).finally(()=>{Me.current.get(J)===Ue&&Me.current.delete(J)});return Me.current.set(J,Ue),Ue},[l,bt]),Qt=w.useCallback((N,A)=>new Promise((K,ee)=>{const le=async()=>{St.current=!0;try{await N(),K()}catch(J){ee(J)}finally{St.current=!1;const J=Ct.current.shift();J&&J().catch(()=>{})}};St.current?Ct.current.push(le):le().catch(J=>{ee(J)})}),[]),Er=w.useRef(C.length),[Hn,Ir]=w.useState(!1),Pn=w.useRef(!1);w.useEffect(()=>{Er.current=C.length},[C.length]),w.useEffect(()=>{const N=Q.pendingInterrupt??Cx(Q.messages);Dc(U,N)||te(N??null)},[U,Q.messages,Q.pendingInterrupt]);const Et=w.useCallback(async()=>{const N=Er.current>0;N||R(!0);try{const A=await l.listThreads();w.startTransition(()=>{E(K=>{const ee=Fe=>Fe.map(Ue=>`${Ue.threadId}:${Ue.updatedAt??""}:${Ue.messageCount??""}`).join("|"),le=Li(K);return ee(le)===ee(A)||A.length===0&&le.length>0&&!Pn.current?K:qo(A)})}),B(null),Pn.current||(Pn.current=!0,Ir(!0))}catch(A){i==null||i(String(A)),console.error("[ChatSessionProvider] Failed to refresh threads:",A),B(String(A))}finally{N||R(!1)}},[l,i]),_o=w.useRef(!1),rr=w.useRef(null),It=w.useRef(null),yn=w.useRef(""),On=w.useCallback((N,A)=>{if(!ur())return;It.current!==null&&(window.clearTimeout(It.current),It.current=null);const K=N.map(le=>`${le.threadId}:${le.updatedAt??""}:${le.messageCount??""}`).join("|");if(N.length===0){try{Ri(y)}catch{}yn.current="";return}if(K===yn.current)return;const ee=()=>{try{const le=N.slice(0,Pi);Mi(y,le),yn.current=K}catch{}finally{It.current=null}};if(A!=null&&A.immediate){ee();return}It.current=window.setTimeout(()=>{Lc(ee)},Ko)},[y]),Kr=w.useCallback(()=>{On(C,{immediate:!0})},[On,C]),cn=w.useCallback((N,A,K,ee)=>{var wl;const le=K??Pe.current;if(!le)return;const J=nn(N),Fe=le===Pe.current,Ue=(ee==null?void 0:ee.persist)!==!1;if(A==="replace"){if(Ue){const At={threadId:le,snapshot:nn(N,{cloneMessages:!0})};et.current.set(le,At),Be.current=le}if(!Fe)return;Ze(J.messages,{checkpointId:J.checkpointId??null,checkpointNs:J.checkpointNs??null,pendingInterrupt:J.interrupt??null}),te(J.interrupt??null),ye(J.nextCursor??null),G(!!J.nextCursor),D(J.checkpointId??void 0),Z(J.checkpointNs??void 0),ae(J.nextCursorNs??void 0);return}const $e=et.current.get(le),at=($e==null?void 0:$e.snapshot)??null,Rt=Array.isArray(at==null?void 0:at.messages)?at.messages:[],Ft=nn(at),Dn=Array.isArray(N==null?void 0:N.messages)?N.messages:[],Pt=new Set,Ot=[...Dn,...Rt].filter(At=>{const Sl=At==null?void 0:At.id;return Sl?Pt.has(Sl)?!1:(Pt.add(Sl),!0):!0}),Ro={checkpointId:Ft.checkpointId??J.checkpointId??null,checkpointNs:Ft.checkpointNs??J.checkpointNs??null,createdAt:J.createdAt??Ft.createdAt??null,preview:J.preview??Ft.preview??null,role:J.role??Ft.role??null,parentId:J.parentId??Ft.parentId??null,branchLabel:J.branchLabel??Ft.branchLabel??null,lastMessageId:((wl=Ot[Ot.length-1])==null?void 0:wl.id)??null,messagesLen:Ot.length,hasMessages:Ot.length>0,messages:Ot,nextCursor:J.nextCursor??Ft.nextCursor??null,nextCursorNs:J.nextCursorNs??Ft.nextCursorNs??null,interrupt:Ft.interrupt??J.interrupt??null};if(et.current.set(le,{threadId:le,snapshot:nn(Ro,{cloneMessages:!0})}),!Fe)return;Dn.length&&Re(Dn);const qr=N&&Object.prototype.hasOwnProperty.call(N,"checkpointId")?N.checkpointId:void 0,Ln=N&&Object.prototype.hasOwnProperty.call(N,"checkpointNs")?N.checkpointNs:void 0,Nr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursor")?N.nextCursor:void 0,sr=N&&Object.prototype.hasOwnProperty.call(N,"nextCursorNs")?N.nextCursorNs:void 0;ye(At=>Nr!==void 0?Nr??At??null:At??null),G(At=>Nr!==void 0?!!Nr:At),D(At=>qr!==void 0?qr??At??void 0:At??void 0),Z(At=>Ln!==void 0?Ln??At??void 0:At??void 0),ae(At=>sr!==void 0?sr??void 0:At)},[Re,Ze,te]),or=w.useCallback(N=>{if(N.threadId!=null&&N.threadId!==Pe.current)return;const A=nn(N.snapshot,{cloneMessages:!0});Ze(A.messages,{checkpointId:A.checkpointId??null,checkpointNs:A.checkpointNs??null,pendingInterrupt:A.interrupt??null}),te(A.interrupt??null),ye(A.nextCursor??null),G(!!A.nextCursor),D(A.checkpointId??void 0),Z(A.checkpointNs??void 0),ae(A.nextCursorNs??void 0),Be.current=N.threadId,qe(N.threadId??Pe.current??null)},[Ze,te,qe]),vn=w.useCallback(N=>{if(!N)return;et.current.delete(N),x(N),oe.current.delete(N),xe.current.delete(N),N===Pe.current&&F([]);const A=`${N}__`;for(const K of Me.current.keys())K.startsWith(A)&&Me.current.delete(K);for(const K of Le.current.keys())K.startsWith(A)&&Le.current.delete(K);Be.current===N&&(Be.current=null)},[x]),Mn=w.useCallback(()=>{const N=Pe.current;N&&vn(N),rt([]),G(!1),be(!1),ye(null),D(void 0),Z(void 0),ae(void 0)},[vn,rt]),me=w.useCallback(({from:N,to:A})=>{const K=Pe.current;K&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${A}) for thread ${K}`)},[]),Ie=w.useCallback(N=>{const A=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:A,title:N.title,created:N.created,currentThreads:C.length});const K={threadId:A,title:N.title||`Thread ${A.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};Pe.current!==A&&(!Pe.current&&Q.messages.length<=1&&(ut.current=A),I(A)),w.startTransition(()=>{E(ee=>{const le=ee.byId[A];return le?le.title===K.title&&le.updatedAt===K.updatedAt&&le.messageCount===K.messageCount?ee:{byId:{...ee.byId,[A]:K},order:ee.order}:{byId:{...ee.byId,[A]:K},order:[A,...ee.order]}})})},[Q.messages.length]),{startStream:Xe,stop:k,isStreaming:H,error:se,setAuthToken:Ce}=Sx({baseUrl:d,onThreadInfo:Ie,onMessageEvent:nt,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:me});w.useEffect(()=>{_o.current=H},[H]),w.useEffect(()=>{if(!ur())return;It.current!==null&&(window.clearTimeout(It.current),It.current=null);const N=C.map(K=>`${K.threadId}:${K.updatedAt??""}:${K.messageCount??""}`).join("|");if(C.length===0){try{Ri(y)}catch{}yn.current="";return}if(N===yn.current)return;const A=()=>{try{const K=C.slice(0,Pi);Mi(y,K),yn.current=N}catch{}finally{It.current=null}};return It.current=window.setTimeout(()=>{Lc(A),It.current=null},Ko),()=>{It.current!==null&&(window.clearTimeout(It.current),It.current=null)}},[C,On]),w.useEffect(()=>{var ee;const N=l.getAuthToken();Ce(N);const A=le=>{const J=Oi(f,le);re.current!==J&&(re.current=J,dt.current=!1),b(J);const Fe=Di(J);w.startTransition(()=>{E(qo(Fe))}),dt.current||(dt.current=!0,Et().catch(()=>{}))};A(N);const K=(ee=l.onTokenChange)==null?void 0:ee.call(l,le=>{Ce(le),g(),Me.current.clear(),Le.current.clear(),A(le)});return()=>{K==null||K()}},[l,f,Ce,g,Et]);const Ge=w.useCallback(async N=>{var ee;const A=`Thread ${(ee=crypto.randomUUID)==null?void 0:ee.call(crypto)}`,K={threadId:A,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};E(le=>({byId:{...le.byId,[A]:K},order:[A,...le.order]})),I(A);try{const le=await l.createThread(N),J=typeof le=="string"?le:le.threadId;return E(Fe=>{const Ue=Fe.byId[A];if(!Ue)return Fe;const $e={...Fe.byId};delete $e[A],$e[J]={...Ue,threadId:J};const at=Fe.order.map(Rt=>Rt===A?J:Rt);return{byId:$e,order:at}}),I(J),setTimeout(()=>Et(),10),B(null),J}catch(le){throw E(J=>{if(!J.byId[A])return J;const Fe={...J.byId};delete Fe[A];const Ue=J.order.filter($e=>$e!==A);return{byId:Fe,order:Ue}}),I(null),B(String(le)),le}},[l,Et]),Qe=w.useCallback(async N=>{try{await l.deleteThread(N);let A=null;E(K=>{if(!K.byId[N])return K;const ee={...K.byId};delete ee[N];const le=K.order.filter(Fe=>Fe!==N),J={byId:ee,order:le};return A=Li(J),J}),A&&On(A,{immediate:!0}),vn(N),Pe.current===N&&(ut.current=N,I(null),Pe.current=null,Be.current=null,Mn()),await Et(),B(null)}catch(A){throw B(String(A)),A}},[l,Mn,vn,Et,On]),He=w.useCallback(async(N,A)=>{try{await l.updateThread(N,A),E(K=>{const ee=K.byId[N];return ee?{byId:{...K.byId,[N]:{...ee,title:A}},order:K.order}:K}),B(null)}catch(K){throw await Et(),B(String(K)),K}},[l,Et]),Ae=w.useCallback(async(N,A,K,ee=!1)=>{await Qt(async()=>{if(ut.current===N&&!ee){ut.current=null;return}if(kt.current===N&&!ee)return;I(Pt=>Pt===N?Pt:N),Pe.current=N;const Fe=Hc(N,A??null,K??null),Ue=Le.current.get(Fe),$e=!ee&&!A&&!K&&Ue&&Date.now()-Ue.timestamp<Ox,at=!ee&&!A&&!K;let Rt=!1;if(at){const Pt=et.current.get(N);if(Pt)or(Pt),Rt=!0;else{const Ot=p(N);Ot&&(et.current.set(N,Ot),or(Ot),Rt=!0)}}const Ft=ee||!Rt||!!A||!!K,Dn=async Pt=>{Pt&&z(!0),kt.current=N;try{const Ot=await Kt({threadId:N,checkpointId:A,checkpointNs:K},{force:ee}),{latest:Ro,checkpoints:qr,snapshots:Ln}=bc(Ot);cn(Ro,"replace",N),ot(N,qr,"replace"),ht(N,Ln,"replace"),q(null)}catch(Ot){throw(!Rt||ee||Pt)&&(i==null||i(String(Ot))),q(String(Ot)),Ot}finally{kt.current=null,Pt&&z(!1)}};Ft?await Dn(!0):at&&Rt&&!$e&&Dn(!1).catch(Pt=>{console.warn("[ChatSessionProvider] Background refresh failed:",Pt)})},`loadThread-${N}`)},[or,cn,Qt,Kt,i,ot,ht]),Nt=w.useCallback(async()=>{await Qt(async()=>{const N=Pe.current;N&&vn(N),ut.current=null,I(null),Pe.current=null,Be.current=null,Mn(),D(void 0),Z(void 0),ae(void 0),F([]);try{localStorage.removeItem("lastThreadId")}catch(A){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",A)}},"clearCurrentThread")},[Mn,vn,Qt]),pt=w.useCallback(async(N,A)=>{var J;const K=Pe.current;if(!K)throw new Error("No active thread");const ee=to(N,A??null),le=(J=xe.current.get(K))==null?void 0:J.get(ee);if(le){await Qt(async()=>{cn(le,"replace",K,{persist:!1})},`navigateToCheckpoint-${K}-${ee}`);return}await Ae(K,N,A??void 0,!0)},[cn,Qt,Ae]),gt=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");await Ae(Pe.current,void 0,void 0,!0)},[Ae]),Ht=w.useCallback(async()=>{if(!Pe.current)throw new Error("No active thread");if(ce||!O)return;const N=ge;if(N){be(!0);try{const A=Pe.current,K=await Kt({threadId:A,checkpointId:N??V??null,checkpointNs:fe??X??null}),{latest:ee,checkpoints:le,snapshots:J}=bc(K),Fe=A?xe.current.get(A):null;let Ue=le.length>0;if(Ue&&Fe&&Fe.size>0&&(Ue=le.some($e=>{if(!($e!=null&&$e.checkpointId))return!1;const at=to($e.checkpointId,$e.checkpointNs??null);return!Fe.has(at)})),!Ue){ye(null),ae(void 0),G(!1),q(null);return}cn(ee,"prepend",A??void 0),A&&(ot(A,le,"prepend"),ht(A,J,"prepend")),q(null)}catch(A){throw q(String(A)),A}finally{be(!1)}}},[cn,Kt,O,V,X,fe,ge,ce,ot,ht]),Un=w.useCallback(N=>{if(N!=null&&N.threadId){if(N.checkpointId){const A=to(N.checkpointId,N.checkpointNs??null),K=nn({...N,interrupt:N.interrupt??null},{cloneMessages:!0});ht(N.threadId,{[A]:K},"prepend")}cn(N,"replace",N.threadId)}},[cn,ht]),en=w.useCallback(async(N,A)=>{var Nr;const K=Pe.current,ee=(N==null?void 0:N.text)??"",le=(N==null?void 0:N.attachments)??[],J=le.length?le:(A==null?void 0:A.attachments)??[],Fe={...(A==null?void 0:A.payloadExtras)??{},...(N==null?void 0:N.payload)??{}};if(!K&&!Object.keys(Fe).length&&J.length===0&&!ee.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!K&&!Fe.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ue,filesInfo:$e}=await Qg(l,J),at=[...Ue];ee&&ee.trim()&&at.push({type:"text",text:ee.trim()});const Rt=!!K,Ft=Rt?(A==null?void 0:A.checkpointId)??Q.lastCheckpointId??void 0:void 0,Dn=Rt?(A==null?void 0:A.checkpointNs)??Q.lastCheckpointNs??void 0:void 0,Pt={id:((Nr=crypto.randomUUID)==null?void 0:Nr.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),...Ft!=null?{checkpointId:Ft}:{},...Dn!=null?{checkpointNs:Dn}:{}};at.length>0&&ze(Pt);const Ot={...Pt,content:at},Ro=J.length>0,qr={messages:at.length>0?[Ot]:[],files_info:$e,...o&&Ro&&s?{active_agent:s}:{},...Fe},Ln={threadId:K??null,payload:qr,checkpointId:Ft??null,checkpointNs:Dn??null,nodeFilter:(A==null?void 0:A.nodeFilter)??null,config:A==null?void 0:A.config,command:(A==null?void 0:A.command)??null};Ln.threadId||delete Ln.threadId,Ln.command||delete Ln.command,Xe(Ln,{onError:sr=>{console.warn("[ChatSessionProvider] Stream error:",sr)},onOpen:({threadId:sr})=>{!Pe.current&&sr&&(Q.messages.length<=1&&(ut.current=sr),I(sr))},onGap:me})},[l,o,s,me,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages.length,ze,Xe]),jt=w.useCallback(async(N,A,K)=>{if(!Pe.current)throw new Error("No active thread to handle interrupt");const le=A?K??!0:!1;try{try{tt({type:"interrupt_response",payload:{interruptId:N}})}catch(J){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",J)}await en({payload:{}},{checkpointId:Q.lastCheckpointId??void 0,checkpointNs:Q.lastCheckpointNs??void 0,command:{kind:"resume",value:le}}),te(null)}catch(J){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,J),J}},[tt,Q.lastCheckpointId,Q.lastCheckpointNs,en]);w.useEffect(()=>{if(a==null||a(T),T)try{localStorage.setItem("lastThreadId",T)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[T,a]),w.useEffect(()=>((async()=>{try{if(Et().catch(A=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",A),i==null||i(String(A))}),!r&&!t)try{const A=localStorage.getItem("lastThreadId");A&&(I(A),n&&await Ae(A))}catch(A){console.warn("[ChatSessionProvider] Failed to restore last thread:",A)}else t&&n&&await Ae(t)}catch(A){console.error("[ChatSessionProvider] Initialization failed:",A),i==null||i(String(A))}})(),()=>{}),[]),w.useEffect(()=>{const N=Pe.current;if(!N||Be.current!==N)return;Q.messages.length&&Q.messages[Q.messages.length-1];const A=nn({checkpointId:Q.lastCheckpointId??null,checkpointNs:Q.lastCheckpointNs??null,messages:Q.messages.slice(),nextCursor:ge??null,nextCursorNs:fe??null,interrupt:Q.pendingInterrupt??U??null}),K=et.current.get(N),ee=K==null?void 0:K.snapshot,le=!ee||ee.messages.length!==A.messages.length||ee.messages.some(($e,at)=>{var Rt;return($e==null?void 0:$e.id)!==((Rt=A.messages[at])==null?void 0:Rt.id)}),J=((ee==null?void 0:ee.checkpointId)??null)!==A.checkpointId||((ee==null?void 0:ee.checkpointNs)??null)!==A.checkpointNs,Fe=((ee==null?void 0:ee.nextCursor)??null)!==A.nextCursor||((ee==null?void 0:ee.nextCursorNs)??null)!==A.nextCursorNs,Ue=!Dc((ee==null?void 0:ee.interrupt)??null,A.interrupt??null);if(le||J||Fe||Ue){const $e={threadId:N,snapshot:A};et.current.set(N,$e),rr.current&&window.clearTimeout(rr.current),rr.current=window.setTimeout(()=>{try{v($e,100)}catch(at){console.warn("[ChatSessionProvider] Failed to persist thread payload:",at)}},Ko)}},[ge,fe,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages,Q.pendingInterrupt,U,v]);const jo=w.useMemo(()=>({threads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:_,error:L,actions:{createThread:Ge,deleteThread:Qe,renameThread:He,refreshThreads:()=>Et()},persistThreadsCache:Kr,hydrateFromCache:ie}),[C,T,_,L,Ge,Qe,He,Et,Kr,ie,I]),vl=w.useMemo(()=>{const N=Q.lastBranch??null,A=Q.assemblingId??null,K=N||A?{branchLabel:(N==null?void 0:N.branchLabel)??null,lastBranch:N,assemblingMessageId:A}:null;return{threadId:T,messages:Q.messages,interrupt:U,checkpoint:{id:Q.lastCheckpointId??null,namespace:Q.lastCheckpointNs??null},checkpoints:$,metadata:K,isLoading:j,isHistoryLoading:ce,error:M,hasMore:O,loadOlder:Ht,seedFromSnapshot:Un,clearState:Mn,navigateToCheckpoint:pt,returnToLatest:gt,loadThread:Ae,clearThread:Nt,respondToInterrupt:jt}},[Nt,Mn,T,U,O,ce,j,Ht,Ae,Q.assemblingId,Q.lastBranch,Q.lastCheckpointId,Q.lastCheckpointNs,Q.messages,pt,jt,gt,Un,M,$]),bl=w.useMemo(()=>({isStreaming:H,error:se,submit:en,send:en,stop:k,setAuthToken:Ce}),[H,se,en,k,Ce]);return c.jsx(Px.Provider,{value:!0,children:c.jsx(zc.Provider,{value:bl,children:c.jsx($c.Provider,{value:jo,children:c.jsx(Fc.Provider,{value:vl,children:e})})})})}function Go(){const e=w.useContext($c);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Yo(){const e=w.useContext(Fc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Uc(){const e=w.useContext(zc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Xo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Jg,{apiConfig:t,children:c.jsx(Mx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ne(...e){return Em.twMerge(km.clsx(e))}const Dx=Po.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"}}),Ke=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?ir.Slot:"button";return c.jsx(i,{className:ne(Dx({variant:t,size:n,className:e})),ref:s,...o})});Ke.displayName="Button";const Wc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Wc.displayName="Textarea";function Lx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=w.useState(e),[v,x]=w.useTransition(),g=w.useRef(null),y=w.useRef(0),b=w.useRef(null);w.useEffect(()=>{p(e??""),b.current=null,g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const S=w.useCallback(()=>{const j=g.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{S()},[S]);const E=w.useCallback(async j=>{j&&j.preventDefault();const z=(h??"").trim();if(!z&&!f)return;const L=++y.current;b.current={id:L,shouldClear:!0},x(()=>{var B,M,q;try{const U=i(z);U&&typeof U.then=="function"?U.then(()=>{var te,$;((te=b.current)==null?void 0:te.id)===L&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),(($=b.current)==null?void 0:$.id)===L&&(b.current=null)}).catch(()=>{var te;((te=b.current)==null?void 0:te.id)===L&&(b.current=null)}):(((B=b.current)==null?void 0:B.id)===L&&b.current.shouldClear&&(p(""),g.current&&(g.current.style.height="auto")),((M=b.current)==null?void 0:M.id)===L&&(b.current=null))}catch{((q=b.current)==null?void 0:q.id)===L&&(b.current=null)}})},[h,i,f]),C=w.useCallback(j=>{p(j.target.value),b.current&&(b.current.shouldClear=!1),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),T=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),E()):j.key==="Escape"&&t&&(j.preventDefault(),a==null||a())},[E,t,a]),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))]":""} ${d}`;return c.jsx("form",{onSubmit:j=>void E(j),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Wc,{ref:g,value:h,onChange:C,onKeyDown:T,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ke,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ue.Square,{size:16})}):c.jsx(Ke,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(ue.Send,{size:16})})})]})})}const $x=w.memo(Lx),Jo=0,Vn=1,Rr=2,Vc=4;function Kc(e){return()=>e}function Fx(e){e()}function qc(e,t){return n=>e(t(n))}function Gc(e,t){return()=>e(t)}function zx(e,t){return n=>e(t,n)}function Fi(e){return e!==void 0}function Bx(...e){return()=>{e.map(Fx)}}function Pr(){}function Zo(e,t){return t(e),e}function Hx(e,t){return t(e)}function lt(...e){return e}function Je(e,t){return e(Vn,t)}function Oe(e,t){e(Jo,t)}function zi(e){e(Rr)}function yt(e){return e(Vc)}function ve(e,t){return Je(e,zx(t,Jo))}function fn(e,t){const n=e(Vn,r=>{n(),t(r)});return n}function Yc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xc(e,t){return e===t}function ct(e=Xc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function de(e){return t=>qc(t,e)}function Sn(e){return t=>()=>{t(e)}}function W(e,...t){const n=Ux(...t);return(r,o)=>{switch(r){case Rr:zi(e);return;case Vn:return Je(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function dr(e){return t=>n=>{e>0?e--:t(n)}}function Fn(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);Je(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Ux(...e){return t=>e.reduceRight(Hx,t)}function Wx(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Vn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),Pr);case Rr:r(),n=null;return}}}function Y(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case Jo:t=o;break;case Vn:{o(t);break}case Vc:return t}return n(r,o)}}function Dt(e,t){return Zo(Y(t),n=>ve(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case Jo:e.slice().forEach(r=>{r(n)});return;case Rr:e.splice(0,e.length);return;case Vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Gt(e){return Zo(Ve(),t=>ve(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Vx(),singleton:n}}const Vx=()=>Symbol();function Kx(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 vt(...e){const t=Ve(),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);Je(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Rr:{zi(t);return}case Vn:return r===o&&i(n),Je(t,i)}}}function Te(e,t=Xc){return W(e,ct(t))}function Bi(...e){return function(t,n){switch(t){case Rr:return;case Vn:return Bx(...e.map(r=>Je(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const qx={0:"debug",3:"error",1:"log",2:"warn"},Gx=()=>typeof globalThis>"u"?window:globalThis,Kn=Ye(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=Gx().VIRTUOSO_LOG_LEVEL)!=null?o:yt(e);r>=s&&console[qx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function fr(e,t,n){return Hi(e,t,n).callbackRef}function Hi(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 Yx(e,t,n,r,o,s,i,a,l){const u=w.useCallback(d=>{const f=Xx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),s==null||s(a?Jc("column-gap",getComputedStyle(d).columnGap,o):Jc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Hi(u,n,l)}function Xx(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),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zc(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Hi(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const zt=Ye(()=>{const e=Ve(),t=Ve(),n=Y(0),r=Ve(),o=Y(0),s=Ve(),i=Ve(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=Ve(),h=Ve(),p=Y(!1),v=Y(!1),x=Y(!1);return ve(W(e,de(({scrollTop:g})=>g)),t),ve(W(e,de(({scrollHeight:g})=>g)),i),ve(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),ro={lvl:0};function Qc(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function st(e){return e===ro}function oo(e,t){if(!st(e))return t===e.k?e.v:t<e.k?oo(e.l,t):oo(e.r,t)}function hn(e,t,n="k"){if(st(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=hn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return hn(e.l,t,n)}function Yt(e,t,n){return st(e)?nu(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?ru(wt(e,{l:Yt(e.l,t,n)})):ru(wt(e,{r:Yt(e.r,t,n)}))}function Or(){return ro}function Qo(e,t,n){if(st(e))return[];const r=hn(e,t)[0];return Jx(Wi(e,r,n))}function Ui(e,t){if(st(e))return ro;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=tu(r);return es(wt(e,{k:s,l:eu(r),v:i}))}}else return t<n?es(wt(e,{l:Ui(r,t)})):es(wt(e,{r:Ui(o,t)}))}function hr(e){return st(e)?[]:[...hr(e.l),{k:e.k,v:e.v},...hr(e.r)]}function Wi(e,t,n){if(st(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Wi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Wi(s,t,n))),a}function es(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(Vi(t))return ou(wt(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Vi(e))return Ki(wt(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=Vi(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ki(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return nu(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 eu(e){return st(e.r)?e.l:es(wt(e,{r:eu(e.r)}))}function Vi(e){return st(e)||e.lvl>e.r.lvl}function tu(e){return st(e.r)?[e.k,e.v]:tu(e.r)}function nu(e,t,n,r=ro,o=ro){return{k:e,l:r,lvl:n,r:o,v:t}}function ru(e){return Ki(ou(e))}function ou(e){const{l:t}=e;return!st(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Ki(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function Jx(e){return Qc(e,({k:t,v:n})=>({index:t,value:n}))}function su(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function so(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const qi=Ye(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function iu(e,t,n){return e[ts(e,t,n)]}function ts(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 Zx(e,t,n,r){const o=ts(e,t,r),s=ts(e,n,r,o);return e.slice(o,s+1)}function qn(e,t){return Math.round(e.getBoundingClientRect()[t])}function ns(e){return!st(e.groupOffsetTree)}function Gi({index:e},t){return t===e?0:t<e?-1:1}function Qx(){return{groupIndices:[],groupOffsetTree:Or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Or()}}function ey(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=Yt(e,0,s);continue}const a=Qo(e,i-1,o+1);if(a.some(ay(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Ui(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Yt(e,o+1,h));u&&(e=Yt(e,i,s))}return[e,n]}function ty(e){return typeof e.groupIndex<"u"}function ny({offset:e},t){return t===e?0:t<e?-1:1}function io(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=iu(t,e,Gi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function au(e,t){if(!ns(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lu(e,t,n){if(ty(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=au(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function ry(e,t,n,r=0){return r>0&&(t=Math.max(t,iu(e,r,Gi).offset)),Qc(Zx(e,t,n,ny),iy)}function oy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&st(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,x)=>Yt(Yt(v,x,h),x+1,p),i)}else[i,a]=ey(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Yi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Yt(h,p,io(p,f,o)),Or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function sy(e){return hr(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 cu(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 Yi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ts(o,t-1,Gi),a=o[l].offset;const u=hn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Qo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function iy(e){return{index:e.index,value:e}}function ay(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 ly={offsetHeight:"height",offsetWidth:"width"},Tn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Dt(r,0),s=Ve(),i=Ve(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((C,T)=>qn(C,ly[T])),h=Y(void 0),p=Y(0),v=Qx(),x=Dt(W(n,De(l,e,p),Cn(oy,v),ct()),v),g=Dt(W(l,ct(),Cn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),de(({prev:C})=>C)),[]);ve(W(l,ke(C=>C.length>0),De(x,p),de(([C,T,I])=>{const _=C.reduce((R,j,z)=>Yt(R,j,io(j,T.offsetTree,I)||z),Or());return{...T,groupIndices:C,groupOffsetTree:_}})),x),ve(W(r,De(x),ke(([C,{lastIndex:T}])=>C<T),de(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ve(u,d);const y=Dt(W(u,de(C=>C===void 0)),!0);ve(W(d,ke(C=>C!==void 0&&st(yt(x).sizeTree)),de(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Gt(W(n,De(x),Cn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),de(C=>C.changed)));Je(W(a,Cn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),de(C=>C.diff)),C=>{const{groupIndices:T}=yt(x);if(C>0)Oe(t,!0),Oe(s,C+cu(C,T));else if(C<0){const I=yt(g);I.length>0&&(C-=cu(-C,I)),Oe(i,C)}}),Je(W(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=Gt(s);ve(W(s,De(x),de(([C,T])=>{const I=T.groupIndices.length>0,_=[],R=T.lastSize;if(I){const j=oo(T.sizeTree,0);let z=0,L=0;for(;z<C;){const M=T.groupIndices[L],q=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-M-1;_.push({endIndex:M,size:j,startIndex:M}),_.push({endIndex:M+1+q-1,size:R,startIndex:M+1}),L++,z+=q+1}const B=hr(T.sizeTree);return z!==C&&B.shift(),B.reduce((M,{k:q,v:U})=>{let te=M.ranges;return M.prevSize!==0&&(te=[...M.ranges,{endIndex:q+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:q+C,prevSize:U,ranges:te}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return hr(T.sizeTree).reduce((j,{k:z,v:L})=>({prevIndex:z+C,prevSize:L,ranges:[...j.ranges,{endIndex:z+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=Gt(W(i,De(x,p),de(([C,{offsetTree:T},I])=>{const _=-C;return io(_,T,I)})));return ve(W(i,De(x,p),de(([C,T,I])=>{if(T.groupIndices.length>0){if(st(T.sizeTree))return T;let _=Or();const R=yt(g);let j=0,z=0,L=0;for(;j<-C;){L=R[z];const B=R[z+1]-L-1;z++,j+=B+1}if(_=hr(T.sizeTree).reduce((B,{k:M,v:q})=>Yt(B,Math.max(0,M+C),q),_),j!==-C){const B=oo(T.sizeTree,L);_=Yt(_,0,B);const M=hn(T.sizeTree,-C+1)[1];_=Yt(_,1,M)}return{...T,sizeTree:_,...Yi(T.offsetTree,0,_,I)}}else{const _=hr(T.sizeTree).reduce((R,{k:j,v:z})=>Yt(R,Math.max(0,j+C),z),Or());return{...T,sizeTree:_,...Yi(T.offsetTree,0,_,I)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Kn,qi),{singleton:!0});function cy(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uu=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Gt(W(s,de(cy)));return ve(W(a,de(l=>l.totalCount)),n),ve(W(a,de(l=>l.groupIndices)),e),ve(W(vt(o,t,r),ke(([l,u])=>ns(u)),de(([l,u,d])=>hn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),de(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(Tn,zt)),Gn=Ye(([{log:e}])=>{const t=Y(!1),n=Gt(W(t,ke(r=>r),ct()));return Je(t,r=>{r&&yt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},lt(Kn),{singleton:!0}),uy=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function du(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!uy)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ao=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ve(),v=Ve(),x=Y(0);let g=null,y=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Oe(l,!1)}return ve(W(p,De(n,f,r,x,a,i,h),De(e,s,o),de(([[E,C,T,I,_,R,j,z],L,B,M])=>{const q=du(E),{align:U,behavior:te,offset:$}=q,F=I-1,ie=lu(q,C,F);let O=io(ie,C.offsetTree,L)+R;U==="end"?(O+=B+hn(C.sizeTree,ie)[1]-T+M,ie===F&&(O+=j)):U==="center"?O+=(B+hn(C.sizeTree,ie)[1]-T+M)/2:O-=_,$&&(O+=$);const G=ce=>{S(),ce?(z("retrying to scroll to",{location:E},Vt.DEBUG),Oe(p,E)):(Oe(v,!0),z("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),te==="smooth"){let ce=!1;b=Je(t,be=>{ce=ce||be}),g=fn(d,()=>{G(ce)})}else g=fn(W(t,dy(150)),G);return y=setTimeout(()=>{S()},1200),Oe(l,!0),z("scrolling from index to",{behavior:te,index:ie,top:O},Vt.DEBUG),{behavior:te,top:O}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:x}},lt(Tn,zt,Kn),{singleton:!0});function dy(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Xi(e,t){e==0?t():requestAnimationFrame(()=>{Xi(e-1,t)})}function Ji(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const lo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),u=Y(!0);return ve(W(i,De(l),ke(([d,f])=>!!f),Sn(!1)),a),ve(W(i,De(l),ke(([d,f])=>!!f),Sn(!1)),u),Je(W(vt(t,i),De(a,n,e,u),ke(([[,d],f,{sizeTree:h},p,v])=>d&&(!st(h)||Fi(p))&&!f&&!v),De(l)),([,d])=>{fn(o,()=>{Oe(u,!0)}),Xi(4,()=>{fn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(Tn,zt,ao,Gn),{singleton:!0});function fu(e,t){return Math.abs(e-t)<1.01}const co="up",uo="down",fy="none",hy={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},py=0,fo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ve(),u=Ve(),d=Y(4),f=Y(py),h=Dt(W(Bi(W(Te(o),dr(1),Sn(!0)),W(Te(o),dr(1),Sn(!1),Yc(100))),ct()),!1),p=Dt(W(Bi(W(n,Sn(!0)),W(n,Sn(!1),Yc(200))),ct()),!1);ve(W(vt(Te(o),Te(f)),de(([b,S])=>b<=S),ct()),a),ve(W(a,Fn(50)),u);const v=Gt(W(vt(r,Te(s),Te(t),Te(e),Te(d)),Cn((b,[{scrollHeight:S,scrollTop:E},C,T,I,_])=>{const R=E+C-S>-_,j={scrollHeight:S,scrollTop:E,viewportHeight:C};if(R){let L,B;return E>b.state.scrollTop?(L="SCROLLED_DOWN",B=b.state.scrollTop-E):(L="SIZE_DECREASED",B=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:B,state:j}}let z;return j.scrollHeight>b.state.scrollHeight?z="SIZE_INCREASED":C<b.state.viewportHeight?z="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?z="SCROLLING_UPWARDS":z="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:z,state:j}},hy),ct((b,S)=>b&&b.atBottom===S.atBottom))),x=Dt(W(r,Cn((b,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(fu(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const T=S-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(b=>b.changed),de(b=>b.jump)),0);ve(W(v,de(b=>b.atBottom)),i),ve(W(i,Fn(50)),l);const g=Y(uo);ve(W(r,de(({scrollTop:b})=>b),ct(),Cn((b,S)=>yt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?co:uo,prevScrollTop:S},{direction:uo,prevScrollTop:0}),de(b=>b.direction)),g),ve(W(r,Fn(50),Sn(fy)),g);const y=Y(0);return ve(W(h,ke(b=>!b),Sn(0)),y),ve(W(o,Fn(100),De(h),ke(([b,S])=>!!S),Cn(([b,S],[E])=>[S,E],[0,0]),de(([b,S])=>S-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:y}},lt(zt)),rs="top",os="bottom",hu="none";function pu(e,t,n){return typeof e=="number"?n===co&&t===rs||n===uo&&t===os?e:0:n===co?t===rs?e.main:e.reverse:t===os?e.main:e.reverse}function mu(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Zi=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=Y(0),a=Y(0),l=Y(0),u=Dt(W(vt(Te(r),Te(o),Te(n),Te(s,so),Te(l),Te(i),Te(t),Te(e),Te(a)),de(([d,f,h,[p,v],x,g,y,b,S])=>{const E=d-b,C=g+y,T=Math.max(h-E,0);let I=hu;const _=mu(S,rs),R=mu(S,os);return p-=b,p+=h+y,v+=h+y,v-=b,p>d+C-_&&(I=co),v<d-T+f+R&&(I=uo),I!==hu?[Math.max(E-h-pu(x,rs,I)-_,0),E-T-y+f+pu(x,os,I)+R]:null}),ke(d=>d!=null),ct(so)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},lt(zt),{singleton:!0});function my(e,t,n){if(ns(t)){const r=au(e,t);return[{index:hn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Qi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ss(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:xu(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:xu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function gu(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=Ji(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ss(u,[],a,o,n,r)}function xu(e,t,n){if(e.length===0)return[];if(!ns(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Qo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const pr=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const x=Y([]),g=Y(0),y=Ve();ve(s.topItemsIndexes,x);const b=Dt(W(vt(p,v,Te(l,so),Te(o),Te(r),Te(u),d,Te(x),Te(t),Te(n),e),ke(([T,I,,_,,,,,,,R])=>{const j=R&&R.length!==_;return T&&!I&&!j}),de(([,,[T,I],_,R,j,z,L,B,M,q])=>{const U=R,{offsetTree:te,sizeTree:$}=U,F=yt(g);if(_===0)return{...Qi,totalCount:_};if(T===0&&I===0)return F===0?{...Qi,totalCount:_}:gu(F,j,R,B,M,q||[]);if(st($))return F>0?null:ss(my(Ji(j,_),U,q),[],_,M,U,B);const ie=[];if(L.length>0){const ge=L[0],ye=L[L.length-1];let V=0;for(const D of Qo($,ge,ye)){const X=D.value,Z=Math.max(D.start,ge),fe=Math.min(D.end,ye);for(let ae=Z;ae<=fe;ae++)ie.push({data:q==null?void 0:q[ae],index:ae,offset:V,size:X}),V+=X}}if(!z)return ss([],ie,_,M,U,B);const O=L.length>0?L[L.length-1]+1:0,G=ry(te,T,I,O);if(G.length===0)return null;const ce=_-1,be=Zo([],ge=>{for(const ye of G){const V=ye.value;let D=V.offset,X=ye.start;const Z=V.size;if(V.offset<T){X+=Math.floor((T-V.offset+M)/(Z+M));const ae=X-ye.start;D+=ae*Z+ae*M}X<O&&(D+=(O-X)*Z,X=O);const fe=Math.min(ye.end,ce);for(let ae=X;ae<=fe&&!(D>=I);ae++)ge.push({data:q==null?void 0:q[ae],index:ae,offset:D,size:Z}),D+=Z+M}});return ss(be,ie,_,M,U,B)}),ke(T=>T!==null),ct()),Qi);ve(W(e,ke(Fi),de(T=>T==null?void 0:T.length)),o),ve(W(b,de(T=>T.topListHeight)),f),ve(f,a),ve(W(b,de(T=>[T.top,T.bottom])),i),ve(W(b,de(T=>T.items)),y);const S=Gt(W(b,ke(({items:T})=>T.length>0),De(o,e),ke(([{items:T},I])=>T[T.length-1].originalIndex===I-1),de(([,T,I])=>[T-1,I]),ct(so),de(([T])=>T))),E=Gt(W(b,Fn(200),ke(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),de(({items:T})=>T[0].index),ct())),C=Gt(W(b,ke(({items:T})=>T.length>0),de(({items:T})=>{let I=0,_=T.length-1;for(;T[I].type==="group"&&I<_;)I++;for(;T[_].type==="group"&&_>I;)_--;return{endIndex:T[_].index,startIndex:T[I].index}}),ct(su)));return{endReached:S,initialItemCount:g,itemsRendered:y,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:x,...h}},lt(Tn,uu,Zi,lo,ao,fo,Gn,qi),{singleton:!0}),yu=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Dt(W(vt(n,e,r,t,o),de(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(zt,pr),{singleton:!0}),gy=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=Dt(W(vt(n,e,t),ke(([o])=>o),de(([,o,s])=>Math.max(0,o-s)),Fn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(zt,yu),{singleton:!0}),vu=Ye(()=>({context:Y(null)})),xy=({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,bu=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ve();return ve(W(d,De(t,l,n,s,o,r,a),De(e),de(([[f,h,p,v,x,g,y,b],S])=>{const{align:E,behavior:C,calculateViewLocation:T=xy,done:I,..._}=f,R=lu(f,h,v-1),j=io(R,h.offsetTree,S)+x+g,z=j+hn(h.sizeTree,R)[1],L=b+g,B=b+p-y,M=T({itemBottom:z,itemTop:j,locationParams:{align:E,behavior:C,..._},viewportBottom:B,viewportTop:L});return M?I&&fn(W(i,ke(q=>!q),dr(yt(i)?1:2)),I):I&&I(),M}),ke(f=>f!==null)),u),{scrollIntoView:d}},lt(Tn,zt,ao,pr,Kn),{singleton:!0});function wu(e){return e?e==="smooth"?"smooth":"auto":!1}const yy=(e,t)=>typeof e=="function"?wu(e(t)):t&&wu(e),vy=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=Y(!1),x=Ve();let g=null;function y(C){Oe(i,{align:"end",behavior:C,index:"LAST"})}Je(W(vt(W(Te(t),dr(1)),l),De(Te(v),s,a,f),de(([[C,T],I,_,R,j])=>{let z=T&&R,L="auto";return z&&(L=yy(I,_||j),z=z&&!!L),{followOutputBehavior:L,shouldFollow:z,totalCount:C}}),ke(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),yt(n)?requestAnimationFrame(()=>{yt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):g=fn(e,()=>{yt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),g=null})});function b(C){const T=fn(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(yt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Je(W(vt(Te(v),t,u),ke(([C,,T])=>C&&T),Cn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),ke(({refreshed:C})=>C),De(v,t)),([,C])=>{yt(a)&&b(C!==!1)}),Je(x,()=>{b(yt(v)!==!1)}),Je(vt(Te(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=Y(null),E=Ve();return ve(Bi(W(Te(r),de(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),W(Te(t))),E),Je(W(vt(W(E,dr(1)),l),De(Te(S),a,f,h),de(([[C,T],I,_,R,j])=>T&&_&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:R}))),ke(C=>!!C),Fn(0)),C=>{g&&(g(),g=null),yt(n)?requestAnimationFrame(()=>{yt(d)("scrolling into view",{}),Oe(p,C)}):g=fn(e,()=>{yt(d)("scrolling into view",{}),Oe(p,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},lt(Tn,fo,ao,lo,Gn,Kn,zt,vu,bu)),by=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(W(a,De(s),ke(([,l])=>l!==0),De(o,r,t,n,e),de(([[,l],u,d,f,h,p=[]])=>gu(l,u,d,f,h,p))),i),{}),lt(Tn,lo,pr,Gn),{singleton:!0}),wy=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Je(W(e,De(r),ke(([,o])=>o!==0),de(([,o])=>({top:o}))),o=>{fn(W(n,dr(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},lt(Gn,zt,pr),{singleton:!0}),Su=Ye(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ve(),r=Y(!1);return ve(W(e,De(r,t,n),ke(([o,s])=>!!s),de(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Je(W(vt(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}},lt(fo),{singleton:!0}),ea=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=Y(!1),i=Y(void 0);return ve(W(vt(n,r),de(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ve(W(t,De(r),de(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(zt)),Sy=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ve(),d=Y(void 0),f=Y(null),h=Y(null);return ve(a,f),ve(l,h),Je(W(u,De(t,r,i,f,h,n)),([p,v,x,g,y,b,S])=>{const E=sy(v.sizeTree);g&&y!==null&&b!==null&&(x=y.scrollTop-b.offsetTop),x-=S,p({ranges:E,scrollTop:x})}),ve(W(d,ke(Fi),de(Cy)),o),ve(W(s,De(d),ke(([,p])=>p!==void 0),ct(),de(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},lt(Tn,zt,lo,Gn,ea));function Cy(e){return{align:"start",index:0,offset:e.scrollTop}}const Ty=Ye(([{topItemsIndexes:e}])=>{const t=Y(0);return ve(W(t,ke(n=>n>=0),de(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(pr));function Cu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ky=Cu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ey=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const x=Gt(W(l,De(i),Cn(([,y,b,S],[{bottom:E,items:C,offsetBottom:T,totalCount:I},_])=>{const R=E+T;let j=0;return b===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(j=R-S,j!==0&&(j+=_))),[j,C,I,R]},[0,[],0,0]),ke(([y])=>y!==0),De(r,a,n,o,p,v),ke(([,y,b,S,,,E])=>!E&&!S&&y!==0&&b===co),de(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function g(y){y>0?(Oe(t,{behavior:"auto",top:-y}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-y}))}return Je(W(x,De(e,s)),([y,b,S])=>{S&&ky()?Oe(e,b-y):g(-y)}),Je(W(vt(Dt(s,!1),e,v),ke(([y,b,S])=>!y&&!S&&b!==0),de(([y,b])=>b),Fn(1)),g),ve(W(f,de(y=>({top:-y}))),t),Je(W(u,De(h,d),de(([y,{groupIndices:b,lastSize:S,sizeTree:E},C])=>{function T(I){return I*(S+C)}if(b.length===0)return T(y);{let I=0;const _=oo(E,0);let R=0,j=0;for(;R<y;){R++,I+=_;let z=b.length===j+1?1/0:b[j+1]-b[j]-1;R+z>y&&(I-=_,z=y-R+1),R+=z,I+=T(z),j++}return I}})),y=>{Oe(e,y),requestAnimationFrame(()=>{Oe(t,{top:y}),requestAnimationFrame(()=>{Oe(e,0),Oe(v,!1)})})}),{deviation:e}},lt(zt,fo,pr,Tn,Kn,qi)),Iy=Ye(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),lt(Zi,by,Gn,Su,yu,wy,gy,ea,bu,Kn,vu)),Tu=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},x,g,y,{listState:b,topItemsIndexes:S,...E},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:_},R])=>(ve(E.rangeChanged,R.scrollSeekRangeChanged),ve(W(R.windowViewportRect,de(j=>j.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...R,...x,sizes:l,...g}),lt(Tn,lo,zt,Sy,vy,pr,ao,Ey,Ty,uu,Iy));function Ny(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 is=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ku(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(g,y){g.propsReady&&Oe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Oe(S,y[b])}for(const b of o)if(b in y){const S=g[t.optional[b]];Oe(S,y[b])}g.propsReady&&Oe(g.propsReady,!0)}function u(g){return s.reduce((y,b)=>(y[b]=S=>{const E=g[t.methods[b]];Oe(E,S)},y),{})}function d(g){return i.reduce((y,b)=>(y[b]=Wx(g[t.events[b]]),y),{})}const f=w.forwardRef((g,y)=>{const{children:b,...S}=g,[E]=w.useState(()=>Zo(Kx(e),I=>{l(I,S)})),[C]=w.useState(Gc(d,E));is(()=>{for(const I of i)I in S&&Je(C[I],S[I]);return()=>{Object.values(C).map(zi)}},[S,C,E]),is(()=>{l(E,S)}),w.useImperativeHandle(y,Kc(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...Ny([...r,...o,...i],S),children:b}):b})}),h=g=>{const y=w.useContext(a);return w.useCallback(b=>{Oe(y[g],b)},[y,g])},p=g=>{const y=w.useContext(a)[g],b=w.useCallback(S=>Je(y,S),[y]);return w.useSyncExternalStore(b,()=>yt(y),()=>yt(y))},v=g=>{const y=w.useContext(a)[g],[b,S]=w.useState(Gc(yt,y));return is(()=>Je(y,E=>{E!==b&&S(Kc(E))}),[y,b]),b},x=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,y)=>{const b=w.useContext(a)[g];is(()=>Je(b,y),[y,b])},useEmitterValue:x,usePublisher:h}}const Eu=w.createContext(void 0),Iu=w.createContext(void 0),Nu=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ta(e){return"self"in e}function Ay(e){return"body"in e}function Au(e,t,n,r=Pr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),u=w.useCallback(h=>{let p,v,x;const g=h.target;if(Ay(g)||ta(g)){const b=ta(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:v})};h.suppressFlushSync?y():di.flushSync(y),a.current!==null&&(x===a.current||x<=0||x===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let x,g,y;ta(p)?(g=Math.max(qn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=qn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),fu(x,g)||h.top===y){e({scrollHeight:g,scrollTop:y,viewportHeight:x}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const na="-webkit-sticky",_u="sticky",ra=Cu(()=>{if(typeof document>"u")return _u;const e=document.createElement("div");return e.style.position=na,e.style.position===na?na:_u});function oa(e){return e}const _y=Ye(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(oa),o=Y("div"),s=Y(Pr),i=(a,l=null)=>Dt(W(n,de(u=>u[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),jy=Ye(([e,t])=>({...e,...t}),lt(Tu,_y)),Ry=({height:e})=>c.jsx("div",{style:{height:e}}),Py={overflowAnchor:"none",position:ra(),zIndex:1},ju={overflowAnchor:"none"},Oy={...ju,display:"inline-block",height:"100%"},Ru=w.memo(function({showTopList:e=!1}){const t=_e("listState"),n=rn("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),v=rn("gap"),x=_e("horizontalDirection"),{callbackRef:g}=Yx(n,h,f,e?Pr:a,p,v,o,x,_e("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);sa("deviation",M=>{y!==M&&b(M)});const S=_e("EmptyPlaceholder"),E=_e("ScrollSeekPlaceholder")||Ry,C=_e("ListComponent"),T=_e("ItemComponent"),I=_e("GroupComponent"),_=_e("computeItemKey"),R=_e("isSeeking"),j=_e("groupIndices").length>0,z=_e("alignToBottom"),L=_e("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:y!==0?y:z?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:z?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Lt(S,u)}):c.jsx(C,{...Lt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:B,children:(e?t.topItems:t.items).map(M=>{const q=M.originalIndex,U=_(q+t.firstItemIndex,M.data,u);return R?w.createElement(E,{...Lt(E,u),height:M.size,index:M.index,key:U,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?w.createElement(I,{...Lt(I,u),"data-index":q,"data-item-index":M.index,"data-known-size":M.size,key:U,style:Py},d(M.index,u)):w.createElement(T,{...Lt(T,u),...$y(T,M.data),"data-index":q,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:U,style:x?Oy:ju},j?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),My={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Dy={outline:"none",overflowX:"auto",position:"relative"},as=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ly={position:ra(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function $y(e,t){return{item:typeof e=="string"?void 0:t}}const Fy=w.memo(function(){const e=_e("HeaderComponent"),t=rn("headerHeight"),n=_e("HeaderFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),zy=w.memo(function(){const e=_e("FooterComponent"),t=rn("footerHeight"),n=_e("HeaderFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null});function Pu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=Au(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Dy:My,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function Ou({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Au(a,u,l,v,h);return Nu(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",y),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const By=({children:e})=>{const t=w.useContext(Eu),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=w.useMemo(()=>qc(n,l=>qn(l,s?"width":"height")),[n,s]),a=fr(i,!0,_e("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:as(o),children:e})},Hy=({children:e})=>{const t=w.useContext(Eu),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=_e("customScrollParent"),s=Zc(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:as(i),children:e})},Uy=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...Ly,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,...Lt(t,o),children:e})},Wy=w.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return c.jsxs(r||t?qy:Ky,{...e,context:o,children:[n&&c.jsx(Uy,{children:c.jsx(Ru,{showTopList:!0})}),c.jsxs(r||t?Hy:By,{children:[c.jsx(Fy,{}),c.jsx(Ru,{}),c.jsx(zy,{})]})]})}),{Component:Vy,useEmitter:sa,useEmitterValue:_e,usePublisher:rn}=ku(jy,{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"}},Wy),Ky=Pu({useEmitter:sa,useEmitterValue:_e,usePublisher:rn}),qy=Ou({useEmitter:sa,useEmitterValue:_e,usePublisher:rn}),Gy=Vy;lt(Tu,Ye(()=>{const e=Y(u=>c.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(oa),a=Y(Pr),l=(u,d=null)=>Dt(W(s,de(f=>f[u]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),ra();const Mu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Yy={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Du,floor:ls,max:ho,min:ia,round:Lu}=Math;function $u(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Xy(e){return{...Yy,items:e}}function cs(e,t){return e&&e.width===t.width&&e.height===t.height}function Jy(e,t){return e&&e.column===t.column&&e.row===t.row}const Zy=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E},C])=>{const T=Y(0),I=Y(0),_=Y(Mu),R=Y({height:0,width:0}),j=Y({height:0,width:0}),z=Ve(),L=Ve(),B=Y(0),M=Y(null),q=Y({column:0,row:0}),U=Ve(),te=Ve(),$=Y(!1),F=Y(0),ie=Y(!0),O=Y(!1),G=Y(!1);Je(W(v,De(F),ke(([D,X])=>!!X)),()=>{Oe(ie,!1)}),Je(W(vt(v,ie,j,R,F,O),ke(([D,X,Z,fe,,ae])=>D&&!X&&Z.height!==0&&fe.height!==0&&!ae)),([,,,,D])=>{Oe(O,!0),Xi(1,()=>{Oe(z,D)}),fn(W(u),()=>{Oe(t,[0,0]),Oe(ie,!0)})}),ve(W(te,ke(D=>D!=null&&D.scrollTop>0),Sn(0)),I),Je(W(v,De(te),ke(([,D])=>D!=null)),([,D])=>{D&&(Oe(R,D.viewport),Oe(j,D.item),Oe(q,D.gap),D.scrollTop>0&&(Oe($,!0),fn(W(u,dr(1)),X=>{Oe($,!1)}),Oe(l,{top:D.scrollTop})))}),ve(W(R,de(({height:D})=>D)),f),ve(W(vt(Te(R,cs),Te(j,cs),Te(q,(D,X)=>D&&D.column===X.column&&D.row===X.row),Te(u)),de(([D,X,Z,fe])=>({gap:Z,item:X,scrollTop:fe,viewport:D}))),U),ve(W(vt(Te(T),r,Te(q,Jy),Te(j,cs),Te(R,cs),Te(M),Te(I),Te($),Te(ie),Te(F)),ke(([,,,,,,,D])=>!D),de(([D,[X,Z],fe,ae,Q,tt,Ze,,Re,ze])=>{const{column:nt,row:rt}=fe,{height:Pe,width:St}=ae,{width:Ct}=Q;if(Ze===0&&(D===0||Ct===0))return Mu;if(St===0){const Me=Ji(ze,D),Le=Me+Math.max(Ze-1,0);return Xy($u(Me,Le,tt))}const kt=Fu(Ct,St,nt);let ut,et;Re?X===0&&Z===0&&Ze>0?(ut=0,et=Ze-1):(ut=kt*ls((X+rt)/(Pe+rt)),et=kt*Du((Z+rt)/(Pe+rt))-1,et=ia(D-1,ho(et,kt-1)),ut=ia(et,ho(0,ut))):(ut=0,et=-1);const Be=$u(ut,et,tt),{bottom:dt,top:re}=zu(Q,fe,ae,Be),oe=Du(D/kt),xe=oe*Pe+(oe-1)*rt-dt;return{bottom:dt,itemHeight:Pe,items:Be,itemWidth:St,offsetBottom:xe,offsetTop:re,top:re}})),_),ve(W(M,ke(D=>D!==null),de(D=>D.length)),T),ve(W(vt(R,j,_,q),ke(([D,X,{items:Z}])=>Z.length>0&&X.height!==0&&D.height!==0),de(([D,X,{items:Z},fe])=>{const{bottom:ae,top:Q}=zu(D,fe,X,Z);return[Q,ae]}),ct(so)),t);const ce=Y(!1);ve(W(u,De(ce),de(([D,X])=>X||D!==0)),ce);const be=Gt(W(vt(_,T),ke(([{items:D}])=>D.length>0),De(ce),ke(([[D,X],Z])=>{const fe=D.items[D.items.length-1].index===X-1;return(Z||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&fe}),de(([[,D]])=>D-1),ct())),ge=Gt(W(Te(_),ke(({items:D})=>D.length>0&&D[0].index===0),Sn(0),ct())),ye=Gt(W(Te(_),De($),ke(([{items:D},X])=>D.length>0&&!X),de(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ct(su),Fn(0)));ve(ye,p.scrollSeekRangeChanged),ve(W(z,De(R,j,T,q),de(([D,X,Z,fe,ae])=>{const Q=du(D),{align:tt,behavior:Ze,offset:Re}=Q;let ze=Q.index;ze==="LAST"&&(ze=fe-1),ze=ho(0,ze,ia(fe-1,ze));let nt=aa(X,ae,Z,ze);return tt==="end"?nt=Lu(nt-X.height+Z.height):tt==="center"&&(nt=Lu(nt-X.height/2+Z.height/2)),Re&&(nt+=Re),{behavior:Ze,top:nt}})),l);const V=Dt(W(_,de(D=>D.offsetBottom+D.bottom)),0);return ve(W(E,de(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:g,data:M,deviation:B,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:te,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:z,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E,...p,gridState:_,horizontalDirection:G,initialTopMostItemIndex:F,totalListHeight:V,...h,endReached:be,propsReady:x,rangeChanged:ye,startReached:ge,stateChanged:U,stateRestoreInProgress:$,...C}},lt(Zi,zt,fo,Su,Gn,ea,Kn));function Fu(e,t,n){return ho(1,ls((e+n)/(ls(t)+n)))}function zu(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=aa(e,t,n,r[0].index);return{bottom:aa(e,t,n,r[r.length-1].index)+o,top:s}}function aa(e,t,n,r){const o=Fu(e.width,n.width,t.column),s=ls(r/o),i=s*n.height+ho(0,s-1)*t.row;return i>0?i+t.row:i}const Qy=Ye(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(oa),i=Y("div"),a=Y(Pr),l=(f,h=null)=>Dt(W(t,de(p=>p[f]),ct()),h),u=Y(!1),d=Y(!1);return ve(Te(d),u),{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:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),ev=Ye(([e,t])=>({...e,...t}),lt(Zy,Qy)),tv=w.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=on("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=on("itemDimensions"),h=on("gap"),p=ft("log"),v=ft("stateRestoreInProgress"),x=on("reportReadyState"),g=fr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const S=y.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();f({height:E,width:C})}h({column:Hu("column-gap",getComputedStyle(y).columnGap,p),row:Hu("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,h,p]),!0,!1);return Nu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Lt(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?c.jsx(u,{...Lt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Lt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),nv=w.memo(function(){const e=ft("HeaderComponent"),t=on("headerHeight"),n=ft("headerFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),rv=w.memo(function(){const e=ft("FooterComponent"),t=on("footerHeight"),n=ft("headerFooterTag"),r=fr(w.useMemo(()=>s=>{t(qn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Lt(e,o)})}):null}),ov=({children:e})=>{const t=w.useContext(Iu),n=on("itemDimensions"),r=on("viewportDimensions"),o=fr(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]),c.jsx("div",{ref:o,style:as(!1),children:e})},sv=({children:e})=>{const t=w.useContext(Iu),n=on("windowViewportRect"),r=on("itemDimensions"),o=ft("customScrollParent"),s=Zc(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]),c.jsx("div",{ref:s,style:as(!1),children:e})},iv=w.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?lv:av,o=n||t?sv:ov,s=ft("context");return c.jsx(r,{...e,...Lt(r,s),children:c.jsxs(o,{children:[c.jsx(nv,{}),c.jsx(tv,{}),c.jsx(rv,{})]})})}),{useEmitter:Bu,useEmitterValue:ft,usePublisher:on}=ku(ev,{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"}},iv),av=Pu({useEmitter:Bu,useEmitterValue:ft,usePublisher:on}),lv=Ou({useEmitter:Bu,useEmitterValue:ft,usePublisher:on});function Hu(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}const cv=Po.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 la({className:e,variant:t,...n}){return c.jsx("div",{className:ne(cv({variant:t}),e),...n})}function pe(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 uv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.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 kn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:h,children:p,...v}=f,x=((y=h==null?void 0:h[e])==null?void 0:y[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,dv(o,...t)]}function dv(...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:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},fv=m[" useInsertionEffect ".trim().toString()]||Tt;function mr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=hv({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"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 u=m.useCallback(d=>{var f;if(a){const h=pv(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function hv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return fv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function pv(e){return typeof e=="function"}function Uu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ca(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Uu(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():Uu(e[o],null)}}}}function We(...e){return m.useCallback(ca(...e),e)}var mv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ee=mv.reduce((e,t)=>{const n=ir.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Wu(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function gv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=xv(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=We(r.ref,yv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function xv(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=gv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=us(r.current);s.current=a==="mounted"?u:"none"},[a]),Tt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=us(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=us(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=us(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function us(e){return(e==null?void 0:e.animationName)||"none"}function yv(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 vv=m[" useId ".trim().toString()]||(()=>{}),bv=0;function En(e){const[t,n]=m.useState(vv());return Tt(()=>{n(r=>r??String(bv++))},[e]),e||(t?`radix-${t}`:"")}var ds="Collapsible",[wv,ok]=kn(ds),[Sv,ua]=wv(ds),Vu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=mr({prop:r,defaultProp:o??!1,onChange:i,caller:ds});return c.jsx(Sv,{scope:n,disabled:s,contentId:En(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ee.div,{"data-state":fa(l),"data-disabled":s?"":void 0,...a,ref:t})})});Vu.displayName=ds;var Ku="CollapsibleTrigger",qu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ua(Ku,n);return c.jsx(Ee.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":fa(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:pe(e.onClick,o.onOpenToggle)})});qu.displayName=Ku;var da="CollapsibleContent",Cv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ua(da,e.__scopeCollapsible);return c.jsx(Xt,{present:n||o.open,children:({present:s})=>c.jsx(Tv,{...r,ref:t,present:s})})});Cv.displayName=da;var Tv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ua(da,n),[a,l]=m.useState(r),u=m.useRef(null),d=We(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,x=i.open||a,g=m.useRef(x),y=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),Tt(()=>{const b=u.current;if(b){y.current=y.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=y.current.transitionDuration,b.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(Ee.div,{"data-state":fa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:x&&o})});function fa(e){return e?"open":"closed"}var kv=Vu;const Gu=kv,Yu=qu,po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));po.displayName="Card";const mo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));mo.displayName="CardHeader";const go=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));go.displayName="CardTitle";const Xu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Xu.displayName="CardDescription";const xo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));xo.displayName="CardContent";const Ju=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Ju.displayName="CardFooter";function Zu(){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 gr=Zu();function Ev(e){gr=e}const Qu=/[&<>"']/,Iv=new RegExp(Qu.source,"g"),ed=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Nv=new RegExp(ed.source,"g"),Av={"&":"&","<":"<",">":">",'"':""","'":"'"},td=e=>Av[e];function $t(e,t){if(t){if(Qu.test(e))return e.replace(Iv,td)}else if(ed.test(e))return e.replace(Nv,td);return e}const _v=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function nd(e){return e.replace(_v,(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 jv=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(jv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Rv=/[^\w:]/g,Pv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rd(e,t,n){if(e){let r;try{r=decodeURIComponent(nd(n)).replace(Rv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Pv.test(n)&&(n=Lv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const fs={},Ov=/^[^:]+:\/*[^/]*$/,Mv=/^([^:]+:)[\s\S]*$/,Dv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Lv(e,t){fs[" "+e]||(Ov.test(e)?fs[" "+e]=e+"/":fs[" "+e]=ps(e,"/",!0)),e=fs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Mv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Dv,"$1")+t:e+t}const hs={exec:function(){}};function od(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)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 ps(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 $v(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 Fv(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 sd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function id(e,t,n,r){const o=t.href,s=t.title?$t(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:$t(i)}}function zv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
39
39
|
`).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(`
|
|
40
40
|
`)}class ha{constructor(t){this.options=t||gr}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:ps(r,`
|
|
41
41
|
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zv(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=ps(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,u,d,f,h,p,v,x=n[1].trim();const g=x.length>1,y={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\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(`
|
|
@@ -48,7 +48,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
48
48
|
`,t=t.substring(h.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.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 E=y.items[a].tokens.filter(T=>T.type==="space"),C=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):$t(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:od(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
49
49
|
`):[]};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]=od(r.rows[s],r.header.length).map(u=>({text:u}));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)===`
|
|
50
50
|
`?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:$t(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]):$t(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=ps(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=$v(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)),id(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 id(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,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.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]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}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=$t(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=$t(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=$t(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=$t(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=$t(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]):$t(r[0]):r[0]:o=$t(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={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:hs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=it(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=it(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=it(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._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",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=it(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=it(we._paragraph).replace("hr",we.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",we._tag).getRegex(),we.blockquote=it(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=it(we.gfm.table).replace("hr",we.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",we._tag).getRegex(),we.gfm.paragraph=it(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.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",we._tag).getRegex(),we.pedantic={...we.normal,html:it(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._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:hs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:it(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
|
|
51
|
-
]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const
|
|
51
|
+
]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:hs,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:hs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=it(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=it(we._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=it(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=it(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=it(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,he.autolink=it(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=it(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=it(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=it(he.reflink).replace("label",he._label).replace("ref",we._label).getRegex(),he.nolink=it(he.nolink).replace("ref",we._label).getRegex(),he.reflinkSearch=it(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:it(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:it(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:it(he.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=it(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:it(he.br).replace("{2,}","*").getRegex(),text:it(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Bv(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 ad(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 Yn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||gr,this.options.tokenizer=this.options.tokenizer||new ha,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:we.normal,inline:he.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:he}}static lex(t,n){return new Yn(n).lex(t)}static lexInline(t,n){return new Yn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
52
52
|
`),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,u)=>l+" ".repeat(u.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+=`
|
|
53
53
|
`: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+=`
|
|
54
54
|
`+r.raw,o.text+=`
|
|
@@ -80,7 +80,7 @@ ${t}</tr>
|
|
|
80
80
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
81
81
|
`}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=rd(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=rd(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 ld{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 cd{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 Xn{constructor(t){this.options=t||gr,this.options.renderer=this.options.renderer||new pa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ld,this.slugger=new cd}static parse(t,n){return new Xn(n).parse(t)}static parseInline(t,n){return new Xn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,x,g,y,b,S,E,C,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,nd(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,E=b.task,y="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.tokens,g),h+=this.renderer.listitem(y,E,S);r+=this.renderer.list(h,v,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
82
82
|
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const _='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}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 ms{constructor(t){this.options=t||gr}preprocess(t){return t}postprocess(t){return t}}Cm(ms,"passThroughHooks",new Set(["preprocess","postprocess"]));function Hv(e,t,n){return r=>{if(r.message+=`
|
|
83
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+$t(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 ud(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=Hv(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(Fv(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(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Se.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();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(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return ud(Yn.lex,Xn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},Ev(Se.defaults),Se},Se.getDefaults=Zu,Se.defaults=gr,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new pa;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=Se.defaults.tokenizer||new ha;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=Se.defaults.hooks||new ms;for(const s in n.hooks){const i=o[s];ms.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));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=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=ud(Yn.lexInline,Xn.parseInline),Se.Parser=Xn,Se.parser=Xn.parse,Se.Renderer=pa,Se.TextRenderer=ld,Se.Lexer=Yn,Se.lexer=Yn.lex,Se.Tokenizer=ha,Se.Slugger=cd,Se.Hooks=ms,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Xn.parse,Yn.lex;function ma({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 Se.parse(i)}return Se.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:ne("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function dd(e,t){return await dn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function fd(e,t){return await(await dd(`/files/${e}/view`,t)).text()}async function Uv(e,t){const n=await dd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await dn(`/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 Wv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await dn("/files",{params:r})}const Vv=1,Kv=1e6;let ga=0;function qv(){return ga=(ga+1)%Number.MAX_SAFE_INTEGER,ga.toString()}const xa=new Map,hd=e=>{if(xa.has(e))return;const t=setTimeout(()=>{xa.delete(e),yo({type:"REMOVE_TOAST",toastId:e})},Kv);xa.set(e,t)},Gv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Vv)};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?hd(n):e.toasts.forEach(r=>{hd(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)}}},gs=[];let xs={toasts:[]};function yo(e){xs=Gv(xs,e),gs.forEach(t=>{t(xs)})}function Yv({...e}){const t=qv(),n=o=>yo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>yo({type:"DISMISS_TOAST",toastId:t});return yo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ya(){const[e,t]=m.useState(xs);return m.useEffect(()=>(gs.push(t),()=>{const n=gs.indexOf(t);n>-1&&gs.splice(n,1)}),[e]),{...e,toast:Yv,dismiss:n=>yo({type:"DISMISS_TOAST",toastId:n})}}function _t(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Xv(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e);m.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 Jv="DismissableLayer",va="dismissableLayer.update",Zv="dismissableLayer.pointerDownOutside",Qv="dismissableLayer.focusOutside",pd,md=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ys=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(md),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,C=nb(I=>{const _=I.target,R=[...u.branches].some(j=>j.contains(_));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=rb(I=>{const _=I.target;[...u.branches].some(j=>j.contains(_))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Xv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(pd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),gd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=pd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),gd())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(va,I),()=>document.removeEventListener(va,I)},[]),c.jsx(Ee.div,{...l,ref:v,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,T.onFocusCapture),onBlurCapture:he(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,C.onPointerDownCapture)})});ys.displayName=Jv;var eb="DismissableLayerBranch",tb=m.forwardRef((e,t)=>{const n=m.useContext(md),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ee.div,{...e,ref:o})});tb.displayName=eb;function nb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){xd(Zv,n,u,{discrete:!0})};const u={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 rb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&xd(Qv,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 gd(){const e=new CustomEvent(va);document.dispatchEvent(e)}function xd(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?Wu(o,s):o.dispatchEvent(s)}var ba="focusScope.autoFocusOnMount",wa="focusScope.autoFocusOnUnmount",yd={bubbles:!1,cancelable:!0},ob="FocusScope",vs=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=_t(o),d=_t(s),f=m.useRef(null),h=We(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const E=S.target;a.contains(E)?f.current=E:Jn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Jn(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Jn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){wd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(ba,yd);a.addEventListener(ba,u),a.dispatchEvent(y),y.defaultPrevented||(sb(ub(vd(a)),{select:!0}),document.activeElement===x&&Jn(a))}return()=>{a.removeEventListener(ba,u),setTimeout(()=>{const y=new CustomEvent(wa,yd);a.addEventListener(wa,d),a.dispatchEvent(y),y.defaultPrevented||Jn(x??document.body,{select:!0}),a.removeEventListener(wa,d),wd.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[S,E]=ib(b);S&&E?!x.shiftKey&&y===E?(x.preventDefault(),n&&Jn(S,{select:!0})):x.shiftKey&&y===S&&(x.preventDefault(),n&&Jn(E,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ee.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});vs.displayName=ob;function sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Jn(r,{select:t}),document.activeElement!==n)return}function ib(e){const t=vd(e),n=bd(t,e),r=bd(t.reverse(),e);return[n,r]}function vd(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 bd(e,t){for(const n of e)if(!ab(n,{upTo:t}))return n}function ab(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 lb(e){return e instanceof HTMLInputElement&&"select"in e}function Jn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&lb(e)&&t&&e.select()}}var wd=cb();function cb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sd(e,t),e.unshift(t)},remove(t){var n;e=Sd(e,t),(n=e[0])==null||n.resume()}}}function Sd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ub(e){return e.filter(t=>t.tagName!=="A")}var db="Portal",bs=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?di.createPortal(c.jsx(Ee.div,{...r,ref:t}),i):null});bs.displayName=db;var Sa=0;function Ca(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Cd()),document.body.insertAdjacentElement("beforeend",e[1]??Cd()),Sa++,()=>{Sa===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Sa--}},[])}function Cd(){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 In=function(){return In=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},In.apply(this,arguments)};function Td(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 fb(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 ws="right-scroll-bar-position",Ss="width-before-scroll-bar",hb="with-scroll-bars-hidden",pb="--removed-body-scroll-bar-size";function Ta(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mb(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 gb=typeof window<"u"?m.useLayoutEffect:m.useEffect,kd=new WeakMap;function xb(e,t){var n=mb(null,function(r){return e.forEach(function(o){return Ta(o,r)})});return gb(function(){var r=kd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ta(a,null)}),s.forEach(function(a){o.has(a)||Ta(a,i)})}kd.set(n,e)},[e]),n}function yb(e){return e}function vb(e,t){t===void 0&&(t=yb);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)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function bb(e){e===void 0&&(e={});var t=vb(null);return t.options=In({async:!0,ssr:!1},e),t}var Ed=function(e){var t=e.sideCar,n=Td(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 m.createElement(r,In({},n))};Ed.isSideCarExport=!0;function wb(e,t){return e.useMedium(t),Ed}var Id=bb(),ka=function(){},Cs=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ka,onWheelCapture:ka,onTouchMoveCapture:ka}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,E=Td(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=xb([n,t]),I=In(In({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Id,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),In(In({},I),{ref:T})):m.createElement(b,In({},I,{className:l,ref:T}),a))});Cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Cs.classNames={fullWidth:Ss,zeroRight:ws};var Sb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Cb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Sb();return t&&e.setAttribute("nonce",t),e}function Tb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function kb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Eb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Cb())&&(Tb(t,n),kb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ib=function(){var e=Eb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Nd=function(){var e=Ib(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Nb={left:0,top:0,right:0,gap:0},Ea=function(e){return parseInt(e||"",10)||0},Ab=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[Ea(n),Ea(r),Ea(o)]},_b=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Nb;var t=Ab(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])}},jb=Nd(),Mr="data-scroll-locked",Rb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
83
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+$t(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 ud(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=Hv(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(Fv(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(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Se.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();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(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return ud(Yn.lex,Xn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},Ev(Se.defaults),Se},Se.getDefaults=Zu,Se.defaults=gr,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new pa;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=Se.defaults.tokenizer||new ha;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=Se.defaults.hooks||new ms;for(const s in n.hooks){const i=o[s];ms.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));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=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=ud(Yn.lexInline,Xn.parseInline),Se.Parser=Xn,Se.parser=Xn.parse,Se.Renderer=pa,Se.TextRenderer=ld,Se.Lexer=Yn,Se.lexer=Yn.lex,Se.Tokenizer=ha,Se.Slugger=cd,Se.Hooks=ms,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,Xn.parse,Yn.lex;function ma({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 Se.parse(i)}return Se.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:ne("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function dd(e,t){return await dn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function fd(e,t){return await(await dd(`/files/${e}/view`,t)).text()}async function Uv(e,t){const n=await dd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await dn(`/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 Wv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await dn("/files",{params:r})}const Vv=1,Kv=1e6;let ga=0;function qv(){return ga=(ga+1)%Number.MAX_SAFE_INTEGER,ga.toString()}const xa=new Map,hd=e=>{if(xa.has(e))return;const t=setTimeout(()=>{xa.delete(e),yo({type:"REMOVE_TOAST",toastId:e})},Kv);xa.set(e,t)},Gv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Vv)};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?hd(n):e.toasts.forEach(r=>{hd(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)}}},gs=[];let xs={toasts:[]};function yo(e){xs=Gv(xs,e),gs.forEach(t=>{t(xs)})}function Yv({...e}){const t=qv(),n=o=>yo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>yo({type:"DISMISS_TOAST",toastId:t});return yo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ya(){const[e,t]=m.useState(xs);return m.useEffect(()=>(gs.push(t),()=>{const n=gs.indexOf(t);n>-1&&gs.splice(n,1)}),[e]),{...e,toast:Yv,dismiss:n=>yo({type:"DISMISS_TOAST",toastId:n})}}function _t(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Xv(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e);m.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 Jv="DismissableLayer",va="dismissableLayer.update",Zv="dismissableLayer.pointerDownOutside",Qv="dismissableLayer.focusOutside",pd,md=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ys=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(md),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=We(t,I=>f(I)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,C=nb(I=>{const _=I.target,R=[...u.branches].some(j=>j.contains(_));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=rb(I=>{const _=I.target;[...u.branches].some(j=>j.contains(_))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Xv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(pd=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),gd(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=pd)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),gd())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(va,I),()=>document.removeEventListener(va,I)},[]),c.jsx(Ee.div,{...l,ref:v,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,C.onPointerDownCapture)})});ys.displayName=Jv;var eb="DismissableLayerBranch",tb=m.forwardRef((e,t)=>{const n=m.useContext(md),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ee.div,{...e,ref:o})});tb.displayName=eb;function nb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){xd(Zv,n,u,{discrete:!0})};const u={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 rb(e,t=globalThis==null?void 0:globalThis.document){const n=_t(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&xd(Qv,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 gd(){const e=new CustomEvent(va);document.dispatchEvent(e)}function xd(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?Wu(o,s):o.dispatchEvent(s)}var ba="focusScope.autoFocusOnMount",wa="focusScope.autoFocusOnUnmount",yd={bubbles:!1,cancelable:!0},ob="FocusScope",vs=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=_t(o),d=_t(s),f=m.useRef(null),h=We(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const E=S.target;a.contains(E)?f.current=E:Jn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Jn(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Jn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){wd.add(p);const x=document.activeElement;if(!a.contains(x)){const y=new CustomEvent(ba,yd);a.addEventListener(ba,u),a.dispatchEvent(y),y.defaultPrevented||(sb(ub(vd(a)),{select:!0}),document.activeElement===x&&Jn(a))}return()=>{a.removeEventListener(ba,u),setTimeout(()=>{const y=new CustomEvent(wa,yd);a.addEventListener(wa,d),a.dispatchEvent(y),y.defaultPrevented||Jn(x??document.body,{select:!0}),a.removeEventListener(wa,d),wd.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,y=document.activeElement;if(g&&y){const b=x.currentTarget,[S,E]=ib(b);S&&E?!x.shiftKey&&y===E?(x.preventDefault(),n&&Jn(S,{select:!0})):x.shiftKey&&y===S&&(x.preventDefault(),n&&Jn(E,{select:!0})):y===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(Ee.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});vs.displayName=ob;function sb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Jn(r,{select:t}),document.activeElement!==n)return}function ib(e){const t=vd(e),n=bd(t,e),r=bd(t.reverse(),e);return[n,r]}function vd(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 bd(e,t){for(const n of e)if(!ab(n,{upTo:t}))return n}function ab(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 lb(e){return e instanceof HTMLInputElement&&"select"in e}function Jn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&lb(e)&&t&&e.select()}}var wd=cb();function cb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Sd(e,t),e.unshift(t)},remove(t){var n;e=Sd(e,t),(n=e[0])==null||n.resume()}}}function Sd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ub(e){return e.filter(t=>t.tagName!=="A")}var db="Portal",bs=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?di.createPortal(c.jsx(Ee.div,{...r,ref:t}),i):null});bs.displayName=db;var Sa=0;function Ca(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Cd()),document.body.insertAdjacentElement("beforeend",e[1]??Cd()),Sa++,()=>{Sa===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Sa--}},[])}function Cd(){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 In=function(){return In=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},In.apply(this,arguments)};function Td(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 fb(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 ws="right-scroll-bar-position",Ss="width-before-scroll-bar",hb="with-scroll-bars-hidden",pb="--removed-body-scroll-bar-size";function Ta(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mb(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 gb=typeof window<"u"?m.useLayoutEffect:m.useEffect,kd=new WeakMap;function xb(e,t){var n=mb(null,function(r){return e.forEach(function(o){return Ta(o,r)})});return gb(function(){var r=kd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ta(a,null)}),s.forEach(function(a){o.has(a)||Ta(a,i)})}kd.set(n,e)},[e]),n}function yb(e){return e}function vb(e,t){t===void 0&&(t=yb);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)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function bb(e){e===void 0&&(e={});var t=vb(null);return t.options=In({async:!0,ssr:!1},e),t}var Ed=function(e){var t=e.sideCar,n=Td(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 m.createElement(r,In({},n))};Ed.isSideCarExport=!0;function wb(e,t){return e.useMedium(t),Ed}var Id=bb(),ka=function(){},Cs=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ka,onWheelCapture:ka,onTouchMoveCapture:ka}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,E=Td(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=xb([n,t]),I=In(In({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Id,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),In(In({},I),{ref:T})):m.createElement(b,In({},I,{className:l,ref:T}),a))});Cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Cs.classNames={fullWidth:Ss,zeroRight:ws};var Sb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Cb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Sb();return t&&e.setAttribute("nonce",t),e}function Tb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function kb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Eb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Cb())&&(Tb(t,n),kb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ib=function(){var e=Eb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Nd=function(){var e=Ib(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Nb={left:0,top:0,right:0,gap:0},Ea=function(e){return parseInt(e||"",10)||0},Ab=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[Ea(n),Ea(r),Ea(o)]},_b=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Nb;var t=Ab(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])}},jb=Nd(),Mr="data-scroll-locked",Rb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
84
84
|
.`.concat(hb,` {
|
|
85
85
|
overflow: hidden `).concat(r,`;
|
|
86
86
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -120,15 +120,15 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
120
120
|
`)},Ad=function(){var e=parseInt(document.body.getAttribute(Mr)||"0",10);return isFinite(e)?e:0},Pb=function(){m.useEffect(function(){return document.body.setAttribute(Mr,(Ad()+1).toString()),function(){var e=Ad()-1;e<=0?document.body.removeAttribute(Mr):document.body.setAttribute(Mr,e.toString())}},[])},Ob=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Pb();var s=m.useMemo(function(){return _b(o)},[o]);return m.createElement(jb,{styles:Rb(s,!t,o,n?"":"!important")})},Ia=!1;if(typeof window<"u")try{var Ts=Object.defineProperty({},"passive",{get:function(){return Ia=!0,!0}});window.addEventListener("test",Ts,Ts),window.removeEventListener("test",Ts,Ts)}catch{Ia=!1}var Dr=Ia?{passive:!1}:!1,Mb=function(e){return e.tagName==="TEXTAREA"},_d=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Mb(e)&&n[t]==="visible")},Db=function(e){return _d(e,"overflowY")},Lb=function(e){return _d(e,"overflowX")},jd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Rd(e,r);if(o){var s=Pd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},$b=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Fb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Rd=function(e,t){return e==="v"?Db(t):Lb(t)},Pd=function(e,t){return e==="v"?$b(t):Fb(t)},zb=function(e,t){return e==="h"&&t==="rtl"?-1:1},Bb=function(e,t,n,r,o){var s=zb(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Pd(e,a),v=p[0],x=p[1],g=p[2],y=x-g-s*v;(v||y)&&Rd(e,a)&&(f+=y,h+=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(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},ks=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Od=function(e){return[e.deltaX,e.deltaY]},Md=function(e){return e&&"current"in e?e.current:e},Hb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ub=function(e){return`
|
|
121
121
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
122
122
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
123
|
-
`)},Wb=0,Lr=[];function Vb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Wb++)[0],s=m.useState(Nd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=fb([e.lockRef.current],(e.shards||[]).map(Md),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=ks(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-y[0],E="deltaY"in x?x.deltaY:b[1]-y[1],C,T=x.target,I=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in x&&I==="h"&&T.type==="range")return!1;var _=jd(I,T);if(!_)return!0;if(_?C=I:(C=I==="v"?"h":"v",_=jd(I,T)),!_)return!1;if(!r.current&&"changedTouches"in x&&(S||E)&&(r.current=C),!C)return!0;var R=r.current||C;return Bb(R,g,x,R==="h"?S:E)},[]),l=m.useCallback(function(x){var g=x;if(!(!Lr.length||Lr[Lr.length-1]!==s)){var y="deltaY"in g?Od(g):ks(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Hb(C.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Md).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=S.length>0?a(g,S[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var S={name:x,delta:g,target:y,should:b,shadowParent:Kb(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=m.useCallback(function(x){n.current=ks(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Od(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,ks(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Lr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Dr),document.addEventListener("touchmove",l,Dr),document.addEventListener("touchstart",d,Dr),function(){Lr=Lr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Dr),document.removeEventListener("touchmove",l,Dr),document.removeEventListener("touchstart",d,Dr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:Ub(o)}):null,p?m.createElement(Ob,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qb=wb(Id,Vb);var Es=m.forwardRef(function(e,t){return m.createElement(Cs,In({},e,{ref:t,sideCar:qb}))});Es.classNames=Cs.classNames;var Gb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},$r=new WeakMap,Is=new WeakMap,Ns={},Na=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Yb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Dd(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})},Xb=function(e,t,n,r){var o=Yb(t,Array.isArray(e)?e:[e]);Ns[n]||(Ns[n]=new WeakMap);var s=Ns[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=($r.get(h)||0)+1,g=(s.get(h)||0)+1;$r.set(h,x),s.set(h,g),i.push(h),x===1&&v&&Is.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),Na++,function(){i.forEach(function(f){var h=$r.get(f)-1,p=s.get(f)-1;$r.set(f,h),s.set(f,p),h||(Is.has(f)||f.removeAttribute(r),Is.delete(f)),p||f.removeAttribute(n)}),Na--,Na||($r=new WeakMap,$r=new WeakMap,Is=new WeakMap,Ns={})}},Aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Gb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Xb(r,o,n,"aria-hidden")):function(){return null}},As="Dialog",[Ld,sk]=kn(As),[Jb,pn]=Ld(As),$d=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=mr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return c.jsx(Jb,{scope:t,triggerRef:a,contentRef:l,contentId:En(),titleId:En(),descriptionId:En(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};$d.displayName=As;var Fd="DialogTrigger",zd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Fd,n),s=We(t,o.triggerRef);return c.jsx(Ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ra(o.open),...r,ref:s,onClick:
|
|
123
|
+
`)},Wb=0,Lr=[];function Vb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Wb++)[0],s=m.useState(Nd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=fb([e.lockRef.current],(e.shards||[]).map(Md),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var y=ks(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-y[0],E="deltaY"in x?x.deltaY:b[1]-y[1],C,T=x.target,I=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in x&&I==="h"&&T.type==="range")return!1;var _=jd(I,T);if(!_)return!0;if(_?C=I:(C=I==="v"?"h":"v",_=jd(I,T)),!_)return!1;if(!r.current&&"changedTouches"in x&&(S||E)&&(r.current=C),!C)return!0;var R=r.current||C;return Bb(R,g,x,R==="h"?S:E)},[]),l=m.useCallback(function(x){var g=x;if(!(!Lr.length||Lr[Lr.length-1]!==s)){var y="deltaY"in g?Od(g):ks(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Hb(C.delta,y)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Md).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=S.length>0?a(g,S[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,y,b){var S={name:x,delta:g,target:y,should:b,shadowParent:Kb(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=m.useCallback(function(x){n.current=ks(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Od(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,ks(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Lr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Dr),document.addEventListener("touchmove",l,Dr),document.addEventListener("touchstart",d,Dr),function(){Lr=Lr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Dr),document.removeEventListener("touchmove",l,Dr),document.removeEventListener("touchstart",d,Dr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:Ub(o)}):null,p?m.createElement(Ob,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const qb=wb(Id,Vb);var Es=m.forwardRef(function(e,t){return m.createElement(Cs,In({},e,{ref:t,sideCar:qb}))});Es.classNames=Cs.classNames;var Gb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},$r=new WeakMap,Is=new WeakMap,Ns={},Na=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Yb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Dd(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})},Xb=function(e,t,n,r){var o=Yb(t,Array.isArray(e)?e:[e]);Ns[n]||(Ns[n]=new WeakMap);var s=Ns[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",x=($r.get(h)||0)+1,g=(s.get(h)||0)+1;$r.set(h,x),s.set(h,g),i.push(h),x===1&&v&&Is.set(h,!0),g===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(t),a.clear(),Na++,function(){i.forEach(function(f){var h=$r.get(f)-1,p=s.get(f)-1;$r.set(f,h),s.set(f,p),h||(Is.has(f)||f.removeAttribute(r),Is.delete(f)),p||f.removeAttribute(n)}),Na--,Na||($r=new WeakMap,$r=new WeakMap,Is=new WeakMap,Ns={})}},Aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Gb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Xb(r,o,n,"aria-hidden")):function(){return null}},As="Dialog",[Ld,sk]=kn(As),[Jb,pn]=Ld(As),$d=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=mr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return c.jsx(Jb,{scope:t,triggerRef:a,contentRef:l,contentId:En(),titleId:En(),descriptionId:En(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};$d.displayName=As;var Fd="DialogTrigger",zd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Fd,n),s=We(t,o.triggerRef);return c.jsx(Ee.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ra(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});zd.displayName=Fd;var _a="DialogPortal",[Zb,Bd]=Ld(_a,{forceMount:void 0}),Hd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(_a,t);return c.jsx(Zb,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Xt,{present:n||s.open,children:c.jsx(bs,{asChild:!0,container:o,children:i})}))})};Hd.displayName=_a;var _s="DialogOverlay",Ud=m.forwardRef((e,t)=>{const n=Bd(_s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(_s,e.__scopeDialog);return s.modal?c.jsx(Xt,{present:r||s.open,children:c.jsx(ew,{...o,ref:t})}):null});Ud.displayName=_s;var Qb=ir.createSlot("DialogOverlay.RemoveScroll"),ew=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(_s,n);return c.jsx(Es,{as:Qb,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ee.div,{"data-state":Ra(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),xr="DialogContent",Wd=m.forwardRef((e,t)=>{const n=Bd(xr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(xr,e.__scopeDialog);return c.jsx(Xt,{present:r||s.open,children:s.modal?c.jsx(tw,{...o,ref:t}):c.jsx(nw,{...o,ref:t})})});Wd.displayName=xr;var tw=m.forwardRef((e,t)=>{const n=pn(xr,e.__scopeDialog),r=m.useRef(null),o=We(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Aa(s)},[]),c.jsx(Vd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),nw=m.forwardRef((e,t)=>{const n=pn(xr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Vd,{...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,u;(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;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Vd=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(xr,n),l=m.useRef(null),u=We(t,l);return Ca(),c.jsxs(c.Fragment,{children:[c.jsx(vs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(ys,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ra(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(rw,{titleId:a.titleId}),c.jsx(sw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),ja="DialogTitle",Kd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(ja,n);return c.jsx(Ee.h2,{id:o.titleId,...r,ref:t})});Kd.displayName=ja;var qd="DialogDescription",Gd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(qd,n);return c.jsx(Ee.p,{id:o.descriptionId,...r,ref:t})});Gd.displayName=qd;var Yd="DialogClose",Xd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Yd,n);return c.jsx(Ee.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Xd.displayName=Yd;function Ra(e){return e?"open":"closed"}var Jd="DialogTitleWarning",[ik,Zd]=uv(Jd,{contentName:xr,titleName:ja,docsSlug:"dialog"}),rw=({titleId:e})=>{const t=Zd(Jd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
124
124
|
|
|
125
125
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
126
126
|
|
|
127
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ow="DialogDescriptionWarning",sw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zd(ow).contentName}}.`;return m.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},Qd=$d,iw=zd,ef=Hd,js=Ud,Rs=Wd,yr=Kd,Ps=Gd,tf=Xd;const aw=Qd,lw=ef,nf=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));nf.displayName=js.displayName;const rf=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===yr||(u==null?void 0:u.displayName)===yr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(lw,{children:[c.jsx(nf,{}),c.jsxs(Rs,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(yr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(tf,{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:[c.jsx(
|
|
128
|
-
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function mw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function gw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uf(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function xw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const df=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",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C}){const[T,I]=w.useState(!1),[_,R]=w.useState("collapsed"),[j
|
|
129
|
-
… [truncated ${Q.length-vr} chars]`,[Q]),Ze=w.useCallback(async(re="all")=>{const xe=re==="visible"&&
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[
|
|
131
|
-
… [truncated ${Le.length-vr} chars]`:Le,bt=_==="expanded";return c.jsxs(Gu,{open:bt,onOpenChange:ot=>R(ot?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(la,{variant:"outline",children:(xe.name??"tool")+(xe.toolCallId?` • ${xe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:bt?qe:qe.slice(0,d)+(qe.length>d?"...":"")})}),c.jsx(Yu,{asChild:!0,children:c.jsx(Ke,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:bt?c.jsxs(c.Fragment,{children:[" ",c.jsx(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Me)})})}if(!le){const oe=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Me)=>c.jsx(ut,{part:xe,i:Me},Me))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[oe,c.jsx(xw,{className:ge})]}):oe}},[ye,D.length,X.length,Z.length,r,t.model,le,K.name,Q,_,u,et,ge]),dt=w.useMemo(()=>gw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ne(Pe(),p.container),children:c.jsxs("div",{className:ne(St(),p.content),children:[(i||a||le)&&c.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",ge,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&dt&&c.jsx("span",{className:ne("font-medium",O?"text-xs":"text-sm"),children:dt}),le&&K.name&&c.jsxs(la,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer",ge,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":_!=="collapsed",onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),R(oe=>oe==="collapsed"?"preview":"collapsed"))},onClick:()=>R(re=>re==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:K.name}),c.jsx("span",{className:"inline-flex items-center",children:_!=="collapsed"?c.jsx(ce.ChevronUp,{className:"h-3 w-3"}):c.jsx(ce.ChevronDown,{className:"h-3 w-3"})})]}),le&&!K.name&&c.jsx(Ke,{variant:"ghost",size:"sm",className:ne("h-6 px-1",ge,"hover:bg-foreground/10"),onClick:()=>R(re=>re==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",_!=="collapsed"?c.jsx(ce.ChevronUp,{className:"h-3 w-3"}):c.jsx(ce.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:ne("text-xs opacity-60",ge,O&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze(le?"visible":"all"),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":le?"Copy visible":"Copy message",title:le?"Copy visible portion":"Copy message",children:c.jsx(ce.Copy,{className:ne(T?"text-success":ge,O?"h-3 w-3":"h-4 w-4")})}),le&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze("all"),className:ne("h-6 px-1 text-xs hover:bg-foreground/10",ge),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),G==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Re,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ce.Edit,{className:ne(ge,O?"h-3 w-3":"h-4 w-4")})}),G==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:ze,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ce.RotateCcw,{className:ne(ge,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Be()}),le&&_==="expanded"&&(K.toolCallId||K.name)&&c.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[K.name&&c.jsxs("div",{children:["Function: ",K.name]}),K.toolCallId&&c.jsxs("div",{children:["Call ID: ",K.toolCallId]})]}),!(i||a||le)&&s&&!o&&c.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ce.Copy,{className:ne(T?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),G==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Re,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ce.Edit,{className:ne("text-current",O?"h-3 w-3":"h-4 w-4")})}),G==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:ze,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ce.RotateCcw,{className:ne("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),U&&c.jsx(uw,{isOpen:te,onClose:()=>{V(!1),me(null)},fileId:U.id,fileName:U.name,mimeType:U.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uf(e.message)===uf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function yw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ms,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Os(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:Ms,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Ms,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:vw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Os(e)})}function vw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(vo(e))})}catch{return String(e)}}function bw({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=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=Os(s);a=c.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:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(po,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(mo,{className:"pb-3",children:[c.jsx(go,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(Xu,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(xo,{className:"pt-0 pb-3",children:a}),c.jsx(Ju,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ke,{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"}),c.jsx(Ke,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function ww({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Sw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Ms,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ff=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Pa=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C},T)=>{const I=w.useRef(null),_=w.useRef(null),R=w.useRef(!1),[j,$]=w.useState(!0),L=w.useCallback(H=>{$(H),g&&g(!H),y&&y(H)},[g,y]),F=w.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),M=w.useMemo(()=>!v||x?!1:j?"auto":!1,[j,v,x]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Gy,{ref:H=>{I.current=H},scrollerRef:H=>{_.current=H instanceof HTMLDivElement?H:null},data:e,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{F&&F()},atBottomStateChange:L,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(H,z)=>ff(z,H),itemContent:(H,z)=>{const te=ff(z,H);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":te,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(df,{message:z,messageIndex:H,isStreamingMessage:t&&n===z.id,streamingDebounceMs:r,isEditing:i===z.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(H),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:E,onInterruptActionEnd:C})})}})})});Pa.displayName="MessageList";const Ds=1e4;function Cw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
127
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ow="DialogDescriptionWarning",sw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zd(ow).contentName}}.`;return m.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},Qd=$d,iw=zd,ef=Hd,js=Ud,Rs=Wd,yr=Kd,Ps=Gd,tf=Xd;const aw=Qd,lw=ef,nf=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));nf.displayName=js.displayName;const rf=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===yr||(u==null?void 0:u.displayName)===yr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(lw,{children:[c.jsx(nf,{}),c.jsxs(Rs,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(yr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(tf,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});rf.displayName=Rs.displayName;const of=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});of.displayName="DialogHeader";const sf=m.forwardRef(({className:e,...t},n)=>c.jsx(yr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));sf.displayName=yr.displayName;const cw=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));cw.displayName=Ps.displayName;function uw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[u,d]=w.useState(null),{toast:f}=ya(),h=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await fd(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&&h()},[e,n,h]);const p=async()=>{if(n)try{await Uv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await fd(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),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Ke,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ue.Image,{className:"h-5 w-5"}):c.jsx(ue.FileText,{className:"h-5 w-5"});return c.jsx(aw,{open:e,onOpenChange:t,children:c.jsxs(rf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(of,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(sf,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ke,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ke,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function af(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 lf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function vo(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(vo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(lf(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=vo(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 Os(e){if(typeof e=="string")return e;if(lf(e))return"";try{const t=vo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function cf(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return cf(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ms="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",vr=1e5;function dw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function fw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function hw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function pw(e){const t=(r,o=vr)=>{try{const s=vo(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
|
|
128
|
+
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function mw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function gw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uf(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function xw({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const df=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",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:x,onCancelEdit:g,onCopy:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C}){const[T,I]=w.useState(!1),[_,R]=w.useState("collapsed"),[j,z]=w.useState(!1),{currentThreadId:L}=Go(),{respondToInterrupt:B}=Yo(),{toast:M}=ya(),[q,U]=w.useState({}),[te,$]=w.useState(!1),[F,ie]=w.useState(null),O=l==="phone"||l==="half-screen",G=t.role,ce=G==="tool",be=!(r&&G!=="user"),ge=w.useMemo(()=>{switch(G){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))]"}},[G]),ye=w.useMemo(()=>dw(t.content),[t.content]),V=w.useMemo(()=>fw(t.content),[t.content]),D=w.useMemo(()=>t.content.filter(re=>re.type==="image_url"),[t.content]),X=w.useMemo(()=>t.content.filter(re=>re.type==="file"),[t.content]),Z=w.useMemo(()=>t.content.filter(re=>re.type==="interrupt"),[t.content]),fe=(b==null?void 0:b.id)??null,ae=b==null?void 0:b.value,Q=w.useMemo(()=>pw(t.content),[t.content]);w.useMemo(()=>mw(t.content),[t.content]);const tt=w.useMemo(()=>Q.length<=vr?Q:`${Q.slice(0,vr)}
|
|
129
|
+
… [truncated ${Q.length-vr} chars]`,[Q]),Ze=w.useCallback(async(re="all")=>{const xe=re==="visible"&&ce?tt:ce?Q:ye;async function Me(Le){try{await navigator.clipboard.writeText(Le)}catch{try{const qe=document.createElement("textarea");qe.value=Le,qe.setAttribute("readonly",""),qe.style.position="absolute",qe.style.left="-9999px",document.body.appendChild(qe),qe.select(),document.execCommand("copy"),document.body.removeChild(qe)}catch(qe){throw console.error("Failed to copy:",qe),qe}}}try{await Me(xe),I(!0),setTimeout(()=>I(!1),2e3),y==null||y(xe)}catch(Le){console.error("Failed to copy:",Le)}},[ce,Q,ye,tt,y]),Re=w.useCallback(()=>{if(!v)return;const re=ce?Q:ye;v(t.id,re)},[v,t.id,ce,Q,ye]),ze=w.useCallback(()=>{x==null||x(n)},[x,n]),nt=w.useCallback(async(re,oe,xe)=>{if(!be){re.preventDefault();return}if(q[xe]){re.preventDefault();return}try{const Me=String(oe.url??""),Le=Me.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Le){re.preventDefault();const qe=Le[1],bt=oe.name||`file_${qe}`,ot=oe.mimeType||"application/octet-stream";ie({id:qe,name:bt,mimeType:ot}),$(!0);return}if(Me.startsWith("data:")){re.preventDefault(),U(ot=>({...ot,[xe]:!0}));const qe=`${oe.name}_${oe.size}_${Date.now()}`,bt=M({title:"Fetching file...",description:"",open:!0});try{const ot=await Wv(L??void 0);if(!ot||!Array.isArray(ot))throw new Error("Invalid file list response");const ht=ot.find(Kt=>!Kt||typeof Kt!="object"||!((Kt.filename??"")===(oe.name??""))?!1:typeof oe.size=="number"&&typeof Kt.size=="number"?Kt.size===oe.size:!0);if(!(ht!=null&&ht.id))throw new Error(`File "${oe.name}" is not yet available on the server`);if(!ht.id||!ht.filename)throw new Error("Invalid file data received from server");ie({id:ht.id,name:oe.name||ht.filename||`file_${ht.id}`,mimeType:oe.mimeType||ht.mime_type||"application/octet-stream"}),$(!0),bt.update({id:bt.id,title:"Success",description:`Opened ${oe.name}`,open:!0})}catch(ot){console.error("Failed to fetch server file:",ot);const ht=ot instanceof Error?ot.message:"Unknown error occurred";bt.update({id:bt.id,title:"Failed",description:ht}),M({title:"Failed to fetch file",description:ht,open:!0})}finally{U(ot=>({...ot,[xe]:!1}))}}}catch(Me){console.error("File click error:",Me),U(Le=>({...Le,[xe]:!1}))}},[be,q,M,L]),rt=w.useCallback(()=>{const oe=ne(O?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ge);switch(G){case"user":return c.jsx(ue.User,{className:oe});case"assistant":return c.jsx(ue.Bot,{className:oe});case"tool":return c.jsx(ue.Wrench,{className:oe});default:return c.jsx(ue.Bot,{className:oe})}},[O,ge,G]),Pe=w.useCallback(()=>{const re="group relative mb-4 flex w-full";switch(G){case"user":return ne(re,"justify-end");case"assistant":case"tool":case"system":return ne(re,"justify-start");default:return re}},[G]),St=w.useCallback(()=>{const re=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",O&&"px-3 py-2 text-sm");switch(G){case"user":return ne(re,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(re,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(re,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(re,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(re,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[O,G]),Ct=w.useCallback(async re=>{if(S)return;const oe=(re==null?void 0:re.id)||(re==null?void 0:re.interrupt_id);if(!oe){console.warn("Interrupt part missing id",re);return}try{E==null||E(),await B(oe,!0)}catch(xe){console.error("Failed to approve interrupt:",xe)}finally{C==null||C()}},[S,C,E,B]),kt=w.useCallback(async re=>{if(S)return;const oe=(re==null?void 0:re.id)||(re==null?void 0:re.interrupt_id);if(!oe){console.warn("Interrupt part missing id",re);return}try{E==null||E(),await B(oe,!1)}catch(xe){console.error("Failed to reject interrupt:",xe)}finally{C==null||C()}},[S,C,E,B]),ut=w.useCallback(({part:re,i:oe})=>{if(re.type==="text"){const xe=re.text??"",Me=xe.trim(),Le=af(Me);return Le&&G!=="tool"?c.jsx(yw,{data:Le},oe):G==="user"&&f&&Me.length>h?c.jsxs(Gu,{open:j,onOpenChange:z,children:[c.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",O&&"text-xs"),children:j?c.jsx(ma,{content:Me,allowHtml:!1}):c.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",O&&"text-xs"),children:[Me.substring(0,h),"..."]})}),c.jsx(Yu,{asChild:!0,children:c.jsx(Ke,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:j?c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Me.length-h," chars)"]})})})]},oe):c.jsx(ma,{content:xe,allowHtml:!1},oe)}if(re.type==="image_url"){const xe=re;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:xe.url,alt:xe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},oe)}if(re.type==="file"){const xe=re,Me=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:Le=>nt(Le,xe,oe),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
130
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[q[oe]?c.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Me,q[oe]?" (processing)":""]})]},oe)}if(re.type==="interrupt"){const xe=re,Me=b?fe?(xe==null?void 0:xe.id)===fe:!0:!1,Le=Me?ae??(xe==null?void 0:xe.value):xe==null?void 0:xe.value;return c.jsx(bw,{interruptPart:xe,onApprove:Ct,onReject:kt,disabled:S,isActive:Me,payload:Le},oe)}return null},[nt,q,Ct,kt,G,f,h,j,O,fe,ae,b,S,Z]),et=w.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Be=w.useCallback(()=>{const re=ye.trim().length>0||D.length>0||X.length>0||Z.length>0;if(!ce&&!re&&!r)return et();if(t.model==="reflection"){const oe=ye.trim(),xe=af(oe);if(xe&&typeof xe=="object")return c.jsx(ww,{data:xe})}if(ce&&V.name==="get_issues"){const oe=t.content.find(Le=>Le.type==="tool_end"),xe=(oe==null?void 0:oe.output)??Q,Me=cf(xe);if(Me)return c.jsx(Sw,{issues:Me})}if(ce){const oe=hw(t.content);if(oe.length>0)return c.jsx("div",{className:"space-y-2",children:oe.map((xe,Me)=>{const Le=typeof xe.output=="string"?xe.output:Os(xe.output),qe=Le.length>vr?`${Le.slice(0,vr)}
|
|
131
|
+
… [truncated ${Le.length-vr} chars]`:Le,bt=_==="expanded";return c.jsxs(Gu,{open:bt,onOpenChange:ot=>R(ot?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(la,{variant:"outline",children:(xe.name??"tool")+(xe.toolCallId?` • ${xe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:bt?qe:qe.slice(0,d)+(qe.length>d?"...":"")})}),c.jsx(Yu,{asChild:!0,children:c.jsx(Ke,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:bt?c.jsxs(c.Fragment,{children:[" ",c.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Me)})})}if(!ce){const oe=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Me)=>c.jsx(ut,{part:xe,i:Me},Me))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[oe,c.jsx(xw,{className:ge})]}):oe}},[ye,D.length,X.length,Z.length,r,t.model,ce,V.name,Q,_,u,et,ge]),dt=w.useMemo(()=>gw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ne(Pe(),p.container),children:c.jsxs("div",{className:ne(St(),p.content),children:[(i||a||ce)&&c.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",ge,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&dt&&c.jsx("span",{className:ne("font-medium",O?"text-xs":"text-sm"),children:dt}),ce&&V.name&&c.jsxs(la,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer",ge,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":_!=="collapsed",onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),R(oe=>oe==="collapsed"?"preview":"collapsed"))},onClick:()=>R(re=>re==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:V.name}),c.jsx("span",{className:"inline-flex items-center",children:_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})})]}),ce&&!V.name&&c.jsx(Ke,{variant:"ghost",size:"sm",className:ne("h-6 px-1",ge,"hover:bg-foreground/10"),onClick:()=>R(re=>re==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",_!=="collapsed"?c.jsx(ue.ChevronUp,{className:"h-3 w-3"}):c.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:ne("text-xs opacity-60",ge,O&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze(ce?"visible":"all"),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":ce?"Copy visible":"Copy message",title:ce?"Copy visible portion":"Copy message",children:c.jsx(ue.Copy,{className:ne(T?"text-success":ge,O?"h-3 w-3":"h-4 w-4")})}),ce&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze("all"),className:ne("h-6 px-1 text-xs hover:bg-foreground/10",ge),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),G==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Re,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ue.Edit,{className:ne(ge,O?"h-3 w-3":"h-4 w-4")})}),G==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:ze,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",ge,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ue.RotateCcw,{className:ne(ge,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Be()}),ce&&_==="expanded"&&(V.toolCallId||V.name)&&c.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[V.name&&c.jsxs("div",{children:["Function: ",V.name]}),V.toolCallId&&c.jsxs("div",{children:["Call ID: ",V.toolCallId]})]}),!(i||a||ce)&&s&&!o&&c.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>Ze(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ue.Copy,{className:ne(T?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),G==="user"&&v&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Re,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ue.Edit,{className:ne("text-current",O?"h-3 w-3":"h-4 w-4")})}),G==="assistant"&&x&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:ze,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:c.jsx(ue.RotateCcw,{className:ne("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),F&&c.jsx(uw,{isOpen:te,onClose:()=>{$(!1),ie(null)},fileId:F.id,fileName:F.name,mimeType:F.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uf(e.message)===uf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function yw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ms,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Os(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:Ms,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Ms,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:vw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Os(e)})}function vw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(vo(e))})}catch{return String(e)}}function bw({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=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=Os(s);a=c.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:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(po,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(mo,{className:"pb-3",children:[c.jsx(go,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(Xu,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(xo,{className:"pt-0 pb-3",children:a}),c.jsx(Ju,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ke,{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"}),c.jsx(Ke,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function ww({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Sw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Ms,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const ff=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Pa=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:E,onInterruptActionEnd:C},T)=>{const I=w.useRef(null),_=w.useRef(null),R=w.useRef(!1),[j,z]=w.useState(!0),L=w.useMemo(()=>b?e.some($=>Array.isArray($==null?void 0:$.content)&&$.content.some(F=>F&&F.type==="interrupt"&&(F.id??F.interrupt_id)===b.id)):!1,[b,e]),B=w.useMemo(()=>{if(!b||L)return null;const $=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let F;const ie=b.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const O=ie.title;typeof O=="string"&&O.trim()&&(F=O.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:ie,title:F}]}},[b,L]),M=w.useMemo(()=>B?[...e,B]:e,[e,B]),q=w.useCallback($=>{z($),g&&g(!$),y&&y($)},[g,y]),U=w.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),te=w.useMemo(()=>!v||x?!1:j?"auto":!1,[j,v,x]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Gy,{ref:$=>{I.current=$},scrollerRef:$=>{_.current=$ instanceof HTMLDivElement?$:null},data:M,followOutput:te,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{U&&U()},atBottomStateChange:q,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,F)=>ff(F,$),itemContent:($,F)=>{const ie=ff(F,$);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":ie,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(df,{message:F,messageIndex:$,isStreamingMessage:t&&n===F.id,streamingDebounceMs:r,isEditing:i===F.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u($),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:E,onInterruptActionEnd:C})})}})})});Pa.displayName="MessageList";const Ds=1e4;function Cw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
132
132
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
133
133
|
|
|
134
134
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
136
136
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
137
137
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
138
138
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
139
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Tw(e,t=Ds){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function kw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Tw(t),Cw(t)}function Oa(e){const t=e+"CollectionProvider",[n,r]=kn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=ir.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),E=We(g,S.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=ir.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,E=w.useRef(null),C=We(g,E),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(E,{ref:E,...S}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Ew=m.createContext(void 0);function Ls(e){const t=m.useContext(Ew);return e||t||"ltr"}const Iw=["top","right","bottom","left"],Zn=Math.min,Jt=Math.max,$s=Math.round,Fs=Math.floor,Nn=e=>({x:e,y:e}),Nw={left:"right",right:"left",bottom:"top",top:"bottom"},Aw={start:"end",end:"start"};function Ma(e,t,n){return Jt(e,Zn(t,n))}function zn(e,t){return typeof e=="function"?e(t):e}function Bn(e){return e.split("-")[0]}function Fr(e){return e.split("-")[1]}function Da(e){return e==="x"?"y":"x"}function La(e){return e==="y"?"height":"width"}const _w=new Set(["top","bottom"]);function An(e){return _w.has(Bn(e))?"y":"x"}function $a(e){return Da(An(e))}function jw(e,t,n){n===void 0&&(n=!1);const r=Fr(e),o=$a(e),s=La(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=zs(i)),[i,zs(i)]}function Rw(e){const t=zs(e);return[Fa(e),t,Fa(t)]}function Fa(e){return e.replace(/start|end/g,t=>Aw[t])}const hf=["left","right"],pf=["right","left"],Pw=["top","bottom"],Ow=["bottom","top"];function Mw(e,t,n){switch(e){case"top":case"bottom":return n?t?pf:hf:t?hf:pf;case"left":case"right":return t?Pw:Ow;default:return[]}}function Dw(e,t,n,r){const o=Fr(e);let s=Mw(Bn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Fa)))),s}function zs(e){return e.replace(/left|right|bottom|top/g,t=>Nw[t])}function Lw(e){return{top:0,right:0,bottom:0,left:0,...e}}function mf(e){return typeof e!="number"?Lw(e):{top:e,right:e,bottom:e,left:e}}function Bs(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 gf(e,t,n){let{reference:r,floating:o}=e;const s=An(t),i=$a(t),a=La(i),l=Bn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const $w=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 u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=gf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:E,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...E}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=gf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function bo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=zn(t,e),v=mf(p),g=a[h?f==="floating"?"reference":"floating":f],y=Bs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="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)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Bs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/E.y,bottom:(C.bottom-y.bottom+v.bottom)/E.y,left:(y.left-C.left+v.left)/E.x,right:(C.right-y.right+v.right)/E.x}}const Fw=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:u,padding:d=0}=zn(e,t)||{};if(u==null)return{};const f=mf(d),h={x:n,y:r},p=$a(o),v=La(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[v]);const _=E/2-C/2,R=I/2-x[v]/2-1,j=Zn(f[y],R),$=Zn(f[b],R),L=j,F=I-x[v]-$,M=I/2-x[v]/2+_,H=Ma(L,M,F),z=!l.arrow&&Fr(o)!=null&&M!==H&&s.reference[v]/2-(M<L?j:$)-x[v]/2<0,te=z?M<L?M-L:M-F:0;return{[p]:h[p]+te,data:{[p]:H,centerOffset:M-H-te,...z&&{alignmentOffset:te}},reset:z}}}),zw=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:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=zn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Bn(o),b=An(a),S=Bn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[zs(a)]:Rw(a)),T=v!=="none";!h&&T&&C.push(...Dw(a,x,v,E));const I=[a,...C],_=await bo(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),f){const M=jw(o,i,E);R.push(_[M[0]],_[M[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(M=>M<=0)){var $,L;const M=((($=s.flip)==null?void 0:$.index)||0)+1,H=I[M];if(H&&(!(f==="alignment"?b!==An(H):!1)||j.every(V=>An(V.placement)===b?V.overflows[0]>0:!0)))return{data:{index:M,overflows:j},reset:{placement:H}};let z=(L=j.filter(te=>te.overflows[0]<=0).sort((te,V)=>te.overflows[1]-V.overflows[1])[0])==null?void 0:L.placement;if(!z)switch(p){case"bestFit":{var F;const te=(F=j.filter(V=>{if(T){const U=An(V.placement);return U===b||U==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(U=>U>0).reduce((U,me)=>U+me,0)]).sort((V,U)=>V[1]-U[1])[0])==null?void 0:F[0];te&&(z=te);break}case"initialPlacement":z=a;break}if(o!==z)return{reset:{placement:z}}}return{}}}};function xf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yf(e){return Iw.some(t=>e[t]>=0)}const Bw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=zn(e,t);switch(r){case"referenceHidden":{const s=await bo(t,{...o,elementContext:"reference"}),i=xf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:yf(i)}}}case"escaped":{const s=await bo(t,{...o,altBoundary:!0}),i=xf(s,n.floating);return{data:{escapedOffsets:i,escaped:yf(i)}}}default:return{}}}}},vf=new Set(["left","top"]);async function Hw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Bn(n),a=Fr(n),l=An(n)==="y",u=vf.has(i)?-1:1,d=s&&l?-1:1,f=zn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Uw=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 Hw(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}}}}},Ww=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:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=zn(e,t),u={x:n,y:r},d=await bo(t,l),f=An(Bn(o)),h=Da(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Ma(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Ma(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Vw=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:u=!0}=zn(e,t),d={x:n,y:r},f=An(o),h=Da(f);let p=d[h],v=d[f];const x=zn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",E=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",E=vf.has(Bn(o)),C=s.reference[f]-s.floating[S]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},Kw=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=()=>{},...u}=zn(e,t),d=await bo(t,u),f=Bn(o),h=Fr(o),p=An(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,E=Zn(x-d[g],b),C=Zn(v-d[y],S),T=!t.middlewareData.shift;let I=E,_=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Jt(d.left,0),$=Jt(d.right,0),L=Jt(d.top,0),F=Jt(d.bottom,0);p?_=v-2*(j!==0||$!==0?j+$:Jt(d.left,d.right)):I=x-2*(L!==0||F!==0?L+F:Jt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||x!==R.height?{reset:{rects:!0}}:{}}}};function Hs(){return typeof window<"u"}function zr(e){return bf(e)?(e.nodeName||"").toLowerCase():"#document"}function Zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _n(e){var t;return(t=(bf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bf(e){return Hs()?e instanceof Node||e instanceof Zt(e).Node:!1}function mn(e){return Hs()?e instanceof Element||e instanceof Zt(e).Element:!1}function jn(e){return Hs()?e instanceof HTMLElement||e instanceof Zt(e).HTMLElement:!1}function wf(e){return!Hs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zt(e).ShadowRoot}const qw=new Set(["inline","contents"]);function wo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=gn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qw.has(o)}const Gw=new Set(["table","td","th"]);function Yw(e){return Gw.has(zr(e))}const Xw=[":popover-open",":modal"];function Us(e){return Xw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Jw=["transform","translate","scale","rotate","perspective"],Zw=["transform","translate","scale","rotate","perspective","filter"],Qw=["paint","layout","strict","content"];function za(e){const t=Ba(),n=mn(e)?gn(e):e;return Jw.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)||Zw.some(r=>(n.willChange||"").includes(r))||Qw.some(r=>(n.contain||"").includes(r))}function e0(e){let t=Qn(e);for(;jn(t)&&!Br(t);){if(za(t))return t;if(Us(t))return null;t=Qn(t)}return null}function Ba(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const t0=new Set(["html","body","#document"]);function Br(e){return t0.has(zr(e))}function gn(e){return Zt(e).getComputedStyle(e)}function Ws(e){return mn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||wf(e)&&e.host||_n(e);return wf(t)?t.host:t}function Sf(e){const t=Qn(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:jn(t)&&wo(t)?t:Sf(t)}function So(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Zt(o);if(s){const a=Ha(i);return t.concat(i,i.visualViewport||[],wo(o)?o:[],a&&n?So(a):[])}return t.concat(o,So(o,[],n))}function Ha(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Cf(e){const t=gn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=jn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=$s(n)!==s||$s(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ua(e){return mn(e)?e:e.contextElement}function Hr(e){const t=Ua(e);if(!jn(t))return Nn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Cf(t);let i=(s?$s(n.width):n.width)/r,a=(s?$s(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const n0=Nn(0);function Tf(e){const t=Zt(e);return!Ba()||!t.visualViewport?n0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function r0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Zt(e)?!1:t}function br(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ua(e);let i=Nn(1);t&&(r?mn(r)&&(i=Hr(r)):i=Hr(e));const a=r0(s,n,r)?Tf(s):Nn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Zt(s),p=r&&mn(r)?Zt(r):r;let v=h,x=Ha(v);for(;x&&r&&p!==v;){const g=Hr(x),y=x.getBoundingClientRect(),b=gn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,E=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=E,v=Zt(x),x=Ha(v)}}return Bs({width:d,height:f,x:l,y:u})}function Vs(e,t){const n=Ws(e).scrollLeft;return t?t.left+n:br(_n(e)).left+n}function kf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Vs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function o0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=_n(r),a=t?Us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Nn(1);const d=Nn(0),f=jn(r);if((f||!f&&!s)&&((zr(r)!=="body"||wo(i))&&(l=Ws(r)),jn(r))){const p=br(r);u=Hr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?kf(i,l):Nn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function s0(e){return Array.from(e.getClientRects())}function i0(e){const t=_n(e),n=Ws(e),r=e.ownerDocument.body,o=Jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Vs(e);const a=-n.scrollTop;return gn(r).direction==="rtl"&&(i+=Jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ef=25;function a0(e,t){const n=Zt(e),r=_n(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=Ba();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Vs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ef&&(s-=v)}else u<=Ef&&(s+=u);return{width:s,height:i,x:a,y:l}}const l0=new Set(["absolute","fixed"]);function c0(e,t){const n=br(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=jn(e)?Hr(e):Nn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function If(e,t,n){let r;if(t==="viewport")r=a0(e,n);else if(t==="document")r=i0(_n(e));else if(mn(t))r=c0(t,n);else{const o=Tf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Bs(r)}function Nf(e,t){const n=Qn(e);return n===t||!mn(n)||Br(n)?!1:gn(n).position==="fixed"||Nf(n,t)}function u0(e,t){const n=t.get(e);if(n)return n;let r=So(e,[],!1).filter(a=>mn(a)&&zr(a)!=="body"),o=null;const s=gn(e).position==="fixed";let i=s?Qn(e):e;for(;mn(i)&&!Br(i);){const a=gn(i),l=za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&l0.has(o.position)||wo(i)&&!l&&Nf(e,i))?r=r.filter(d=>d!==i):o=a,i=Qn(i)}return t.set(e,r),r}function d0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Us(t)?[]:u0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=If(t,d,o);return u.top=Jt(f.top,u.top),u.right=Zn(f.right,u.right),u.bottom=Zn(f.bottom,u.bottom),u.left=Jt(f.left,u.left),u},If(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function f0(e){const{width:t,height:n}=Cf(e);return{width:t,height:n}}function h0(e,t,n){const r=jn(t),o=_n(t),s=n==="fixed",i=br(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Nn(0);function u(){l.x=Vs(o)}if(r||!r&&!s)if((zr(t)!=="body"||wo(o))&&(a=Ws(t)),r){const p=br(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?kf(o,a):Nn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Wa(e){return gn(e).position==="static"}function Af(e,t){if(!jn(e)||gn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _n(e)===n&&(n=n.ownerDocument.body),n}function _f(e,t){const n=Zt(e);if(Us(e))return n;if(!jn(e)){let o=Qn(e);for(;o&&!Br(o);){if(mn(o)&&!Wa(o))return o;o=Qn(o)}return n}let r=Af(e,t);for(;r&&Yw(r)&&Wa(r);)r=Af(r,t);return r&&Br(r)&&Wa(r)&&!za(r)?n:r||e0(e)||n}const p0=async function(e){const t=this.getOffsetParent||_f,n=this.getDimensions,r=await n(e.floating);return{reference:h0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function m0(e){return gn(e).direction==="rtl"}const g0={convertOffsetParentRelativeRectToViewportRelativeRect:o0,getDocumentElement:_n,getClippingRect:d0,getOffsetParent:_f,getElementRects:p0,getClientRects:s0,getDimensions:f0,getScale:Hr,isElement:mn,isRTL:m0};function jf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function x0(e,t){let n=null,r;const o=_n(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 u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Fs(f),x=Fs(o.clientWidth-(d+h)),g=Fs(o.clientHeight-(f+p)),y=Fs(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Jt(0,Zn(1,l))||1};let E=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!jf(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function y0(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,u=Ua(e),d=o||s?[...u?So(u):[],...So(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?x0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?br(e):null;l&&g();function g(){const y=br(e);x&&!jf(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const v0=Uw,b0=Ww,w0=zw,S0=Kw,C0=Bw,Rf=Fw,T0=Vw,k0=(e,t,n)=>{const r=new Map,o={platform:g0,...n},s={...o.platform,_c:r};return $w(e,t,{...o,platform:s})};var E0=typeof document<"u",I0=function(){},Ks=E0?w.useLayoutEffect:I0;function qs(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(!qs(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)&&!qs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Pf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Of(e,t){const n=Pf(e);return Math.round(t*n)/n}function Va(e){const t=m.useRef(e);return Ks(()=>{t.current=e}),t}function N0(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:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);qs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback(V=>{V!==T.current&&(T.current=V,x(V))},[]),S=m.useCallback(V=>{V!==I.current&&(I.current=V,y(V))},[]),E=s||v,C=i||g,T=m.useRef(null),I=m.useRef(null),_=m.useRef(d),R=l!=null,j=Va(l),$=Va(o),L=Va(u),F=m.useCallback(()=>{if(!T.current||!I.current)return;const V={placement:t,strategy:n,middleware:h};$.current&&(V.platform=$.current),k0(T.current,I.current,V).then(U=>{const me={...U,isPositioned:L.current!==!1};M.current&&!qs(_.current,me)&&(_.current=me,Oo.flushSync(()=>{f(me)}))})},[h,t,n,$,L]);Ks(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f(V=>({...V,isPositioned:!1})))},[u]);const M=m.useRef(!1);Ks(()=>(M.current=!0,()=>{M.current=!1}),[]),Ks(()=>{if(E&&(T.current=E),C&&(I.current=C),E&&C){if(j.current)return j.current(E,C,F);F()}},[E,C,F,j,R]);const H=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),z=m.useMemo(()=>({reference:E,floating:C}),[E,C]),te=m.useMemo(()=>{const V={position:n,left:0,top:0};if(!z.floating)return V;const U=Of(z.floating,d.x),me=Of(z.floating,d.y);return a?{...V,transform:"translate("+U+"px, "+me+"px)",...Pf(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:U,top:me}},[n,a,z.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:F,refs:H,elements:z,floatingStyles:te}),[d,F,H,z,te])}const A0=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?Rf({element:r.current,padding:o}).fn(n):{}:r?Rf({element:r,padding:o}).fn(n):{}}}},_0=(e,t)=>({...v0(e),options:[e,t]}),j0=(e,t)=>({...b0(e),options:[e,t]}),R0=(e,t)=>({...T0(e),options:[e,t]}),P0=(e,t)=>({...w0(e),options:[e,t]}),O0=(e,t)=>({...S0(e),options:[e,t]}),M0=(e,t)=>({...C0(e),options:[e,t]}),D0=(e,t)=>({...A0(e),options:[e,t]});var L0="Arrow",Mf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ee.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Mf.displayName=L0;var $0=Mf;function Df(e){const[t,n]=m.useState(void 0);return Tt(()=>{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,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.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 Ka="Popper",[Lf,Gs]=kn(Ka),[F0,$f]=Lf(Ka),Ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(F0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ff.displayName=Ka;var zf="PopperAnchor",Bf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$f(zf,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ee.div,{...o,ref:a})});Bf.displayName=zf;var qa="PopperContent",[z0,B0]=Lf(qa),Hf=m.forwardRef((e,t)=>{var K,D,X,Z,de,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=$f(qa,n),[y,b]=m.useState(null),S=We(t,Q=>b(Q)),[E,C]=m.useState(null),T=Df(E),I=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(u)?u:[u],L=$.length>0,F={padding:j,boundary:$.filter(U0),altBoundary:L},{refs:M,floatingStyles:H,placement:z,isPositioned:te,middlewareData:V}=N0({strategy:"fixed",placement:R,whileElementsMounted:(...Q)=>y0(...Q,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[_0({mainAxis:o+_,alignmentAxis:i}),l&&j0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?R0():void 0,...F}),l&&P0({...F}),O0({...F,apply:({elements:Q,rects:tt,availableWidth:Ze,availableHeight:Re})=>{const{width:ze,height:nt}=tt.reference,rt=Q.floating.style;rt.setProperty("--radix-popper-available-width",`${Ze}px`),rt.setProperty("--radix-popper-available-height",`${Re}px`),rt.setProperty("--radix-popper-anchor-width",`${ze}px`),rt.setProperty("--radix-popper-anchor-height",`${nt}px`)}}),E&&D0({element:E,padding:a}),W0({arrowWidth:I,arrowHeight:_}),h&&M0({strategy:"referenceHidden",...F})]}),[U,me]=Vf(z),O=_t(v);Tt(()=>{te&&(O==null||O())},[te,O]);const G=(K=V.arrow)==null?void 0:K.x,le=(D=V.arrow)==null?void 0:D.y,be=((X=V.arrow)==null?void 0:X.centerOffset)!==0,[ge,ye]=m.useState();return Tt(()=>{y&&ye(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:te?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Z=V.transformOrigin)==null?void 0:Z.x,(de=V.transformOrigin)==null?void 0:de.y].join(" "),...((ie=V.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(z0,{scope:n,placedSide:U,onArrowChange:C,arrowX:G,arrowY:le,shouldHideArrow:be,children:c.jsx(Ee.div,{"data-side":U,"data-align":me,...x,ref:S,style:{...x.style,animation:te?void 0:"none"}})})})});Hf.displayName=qa;var Uf="PopperArrow",H0={top:"bottom",right:"left",bottom:"top",left:"right"},Wf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=B0(Uf,r),i=H0[s.placedSide];return c.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:c.jsx($0,{...o,ref:n,style:{...o.style,display:"block"}})})});Wf.displayName=Uf;function U0(e){return e!==null}var W0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Vf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Vf(e){const[t,n="center"]=e.split("-");return[t,n]}var Kf=Ff,qf=Bf,Gf=Hf,Yf=Wf,Ga="rovingFocusGroup.onEntryFocus",V0={bubbles:!1,cancelable:!0},Co="RovingFocusGroup",[Ya,Xf,K0]=Oa(Co),[q0,Jf]=kn(Co,[K0]),[G0,Y0]=q0(Co),Zf=m.forwardRef((e,t)=>c.jsx(Ya.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ya.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(X0,{...e,ref:t})})}));Zf.displayName=Co;var X0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),v=Ls(s),[x,g]=mr({prop:i,defaultProp:a??null,onChange:l,caller:Co}),[y,b]=m.useState(!1),S=_t(u),E=Xf(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const _=h.current;if(_)return _.addEventListener(Ga,S),()=>_.removeEventListener(Ga,S)},[S]),c.jsx(G0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(_=>g(_),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:m.useCallback(()=>I(_=>_-1),[]),children:c.jsx(Ee.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{C.current=!0}),onFocus:he(e.onFocus,_=>{const R=!C.current;if(_.target===_.currentTarget&&R&&!y){const j=new CustomEvent(Ga,V0);if(_.currentTarget.dispatchEvent(j),!j.defaultPrevented){const $=E().filter(z=>z.focusable),L=$.find(z=>z.active),F=$.find(z=>z.id===x),H=[L,F,...$].filter(Boolean).map(z=>z.ref.current);th(H,d)}}C.current=!1}),onBlur:he(e.onBlur,()=>b(!1))})})}),Qf="RovingFocusGroupItem",eh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=En(),u=s||l,d=Y0(Qf,n),f=d.currentTabStopId===u,h=Xf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Ya.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ee.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:he(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:he(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:he(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=Q0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const E=S.indexOf(g.currentTarget);S=d.loop?eS(S,E+1):S.slice(E+1)}setTimeout(()=>th(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});eh.displayName=Qf;var J0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q0(e,t,n){const r=Z0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return J0[r]}function th(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function eS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tS=Zf,nS=eh,Xa=["Enter"," "],rS=["ArrowDown","PageUp","Home"],nh=["ArrowUp","PageDown","End"],oS=[...rS,...nh],sS={ltr:[...Xa,"ArrowRight"],rtl:[...Xa,"ArrowLeft"]},iS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},To="Menu",[ko,aS,lS]=Oa(To),[wr,rh]=kn(To,[lS,Gs,Jf]),Ys=Gs(),oh=Jf(),[cS,Sr]=wr(To),[uS,Eo]=wr(To),sh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ys(t),[l,u]=m.useState(null),d=m.useRef(!1),f=_t(s),h=Ls(o);return m.useEffect(()=>{const p=()=>{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",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Kf,{...a,children:c.jsx(cS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(uS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};sh.displayName=To;var dS="MenuAnchor",Ja=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ys(n);return c.jsx(qf,{...o,...r,ref:t})});Ja.displayName=dS;var Za="MenuPortal",[fS,ih]=wr(Za,{forceMount:void 0}),ah=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Sr(Za,t);return c.jsx(fS,{scope:t,forceMount:n,children:c.jsx(Xt,{present:n||s.open,children:c.jsx(bs,{asChild:!0,container:o,children:r})})})};ah.displayName=Za;var sn="MenuContent",[hS,Qa]=wr(sn),lh=m.forwardRef((e,t)=>{const n=ih(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Sr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu);return c.jsx(ko.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(ko.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(pS,{...o,ref:t}):c.jsx(mS,{...o,ref:t})})})})}),pS=m.forwardRef((e,t)=>{const n=Sr(sn,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Aa(s)},[]),c.jsx(el,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),mS=m.forwardRef((e,t)=>{const n=Sr(sn,e.__scopeMenu);return c.jsx(el,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gS=ir.createSlot("MenuContent.ScrollLock"),el=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=Sr(sn,n),y=Eo(sn,n),b=Ys(n),S=oh(n),E=aS(n),[C,T]=m.useState(null),I=m.useRef(null),_=We(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),$=m.useRef(0),L=m.useRef(null),F=m.useRef("right"),M=m.useRef(0),H=v?Es:m.Fragment,z=v?{as:gS,allowPinchZoom:!0}:void 0,te=U=>{var K,D;const me=j.current+U,O=E().filter(X=>!X.disabled),G=document.activeElement,le=(K=O.find(X=>X.ref.current===G))==null?void 0:K.textValue,be=O.map(X=>X.textValue),ge=NS(be,me,le),ye=(D=O.find(X=>X.textValue===ge))==null?void 0:D.ref.current;(function X(Z){j.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(me),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Ca();const V=m.useCallback(U=>{var O,G;return F.current===((O=L.current)==null?void 0:O.side)&&_S(U,(G=L.current)==null?void 0:G.area)},[]);return c.jsx(hS,{scope:n,searchRef:j,onItemEnter:m.useCallback(U=>{V(U)&&U.preventDefault()},[V]),onItemLeave:m.useCallback(U=>{var me;V(U)||((me=I.current)==null||me.focus(),T(null))},[V]),onTriggerLeave:m.useCallback(U=>{V(U)&&U.preventDefault()},[V]),pointerGraceTimerRef:$,onPointerGraceIntentChange:m.useCallback(U=>{L.current=U},[]),children:c.jsx(H,{...z,children:c.jsx(vs,{asChild:!0,trapped:o,onMountAutoFocus:he(s,U=>{var me;U.preventDefault(),(me=I.current)==null||me.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(ys,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(tS,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:he(l,U=>{y.isUsingKeyboardRef.current||U.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Gf,{role:"menu","aria-orientation":"vertical","data-state":kh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:he(x.onKeyDown,U=>{const O=U.target.closest("[data-radix-menu-content]")===U.currentTarget,G=U.ctrlKey||U.altKey||U.metaKey,le=U.key.length===1;O&&(U.key==="Tab"&&U.preventDefault(),!G&&le&&te(U.key));const be=I.current;if(U.target!==be||!oS.includes(U.key))return;U.preventDefault();const ye=E().filter(K=>!K.disabled).map(K=>K.ref.current);nh.includes(U.key)&&ye.reverse(),ES(ye)}),onBlur:he(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:he(e.onPointerMove,No(U=>{const me=U.target,O=M.current!==U.clientX;if(U.currentTarget.contains(me)&&O){const G=U.clientX>M.current?"right":"left";F.current=G,M.current=U.clientX}}))})})})})})})});lh.displayName=sn;var xS="MenuGroup",tl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"group",...r,ref:t})});tl.displayName=xS;var yS="MenuLabel",ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{...r,ref:t})});ch.displayName=yS;var Xs="MenuItem",uh="menu.itemSelect",Js=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Eo(Xs,e.__scopeMenu),a=Qa(Xs,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(uh,{bubbles:!0,cancelable:!0});f.addEventListener(uh,p=>r==null?void 0:r(p),{once:!0}),Wu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(dh,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:he(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:he(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Xa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Js.displayName=Xs;var dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Qa(Xs,n),a=oh(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(ko.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(nS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ee.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:he(e.onPointerMove,No(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,No(v=>i.onItemLeave(v))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),vS="MenuCheckboxItem",fh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(xh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Js,{role:"menuitemcheckbox","aria-checked":Zs(n)?"mixed":n,...o,ref:t,"data-state":rl(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(Zs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});fh.displayName=vS;var hh="MenuRadioGroup",[bS,wS]=wr(hh,{value:void 0,onValueChange:()=>{}}),ph=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=_t(r);return c.jsx(bS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(tl,{...o,ref:t})})});ph.displayName=hh;var mh="MenuRadioItem",gh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=wS(mh,e.__scopeMenu),s=n===o.value;return c.jsx(xh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Js,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":rl(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});gh.displayName=mh;var nl="MenuItemIndicator",[xh,SS]=wr(nl,{checked:!1}),yh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=SS(nl,n);return c.jsx(Xt,{present:r||Zs(s.checked)||s.checked===!0,children:c.jsx(Ee.span,{...o,ref:t,"data-state":rl(s.checked)})})});yh.displayName=nl;var CS="MenuSeparator",vh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});vh.displayName=CS;var TS="MenuArrow",bh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ys(n);return c.jsx(Yf,{...o,...r,ref:t})});bh.displayName=TS;var kS="MenuSub",[ak,wh]=wr(kS),Io="MenuSubTrigger",Sh=m.forwardRef((e,t)=>{const n=Sr(Io,e.__scopeMenu),r=Eo(Io,e.__scopeMenu),o=wh(Io,e.__scopeMenu),s=Qa(Io,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ja,{asChild:!0,...u,children:c.jsx(dh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":kh(n.open),...e,ref:ca(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:he(e.onPointerMove,No(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:he(e.onPointerLeave,No(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:he(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||sS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Sh.displayName=Io;var Ch="MenuSubContent",Th=m.forwardRef((e,t)=>{const n=ih(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Sr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu),a=wh(Ch,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(ko.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(ko.Slot,{scope:e.__scopeMenu,children:c.jsx(el,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:he(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:he(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:he(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=iS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Th.displayName=Ch;function kh(e){return e?"open":"closed"}function Zs(e){return e==="indeterminate"}function rl(e){return Zs(e)?"indeterminate":e?"checked":"unchecked"}function ES(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function IS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function NS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=IS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function AS(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],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function _S(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return AS(n,t)}function No(e){return t=>t.pointerType==="mouse"?e(t):void 0}var jS=sh,RS=Ja,PS=ah,OS=lh,MS=tl,DS=ch,LS=Js,$S=fh,FS=ph,zS=gh,BS=yh,HS=vh,US=bh,WS=Sh,VS=Th,Qs="DropdownMenu",[KS,lk]=kn(Qs,[rh]),Bt=rh(),[qS,Eh]=KS(Qs),Ih=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Bt(t),u=m.useRef(null),[d,f]=mr({prop:o,defaultProp:s??!1,onChange:i,caller:Qs});return c.jsx(qS,{scope:t,triggerId:En(),triggerRef:u,contentId:En(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(jS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ih.displayName=Qs;var Nh="DropdownMenuTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Eh(Nh,n),i=Bt(n);return c.jsx(RS,{asChild:!0,...i,children:c.jsx(Ee.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:ca(t,s.triggerRef),onPointerDown:he(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:he(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ah.displayName=Nh;var GS="DropdownMenuPortal",_h=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bt(t);return c.jsx(PS,{...r,...n})};_h.displayName=GS;var jh="DropdownMenuContent",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Eh(jh,n),s=Bt(n),i=m.useRef(!1);return c.jsx(OS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:he(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:he(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!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)"}})});Rh.displayName=jh;var YS="DropdownMenuGroup",XS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(MS,{...o,...r,ref:t})});XS.displayName=YS;var JS="DropdownMenuLabel",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(DS,{...o,...r,ref:t})});Ph.displayName=JS;var ZS="DropdownMenuItem",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(LS,{...o,...r,ref:t})});Oh.displayName=ZS;var QS="DropdownMenuCheckboxItem",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx($S,{...o,...r,ref:t})});Mh.displayName=QS;var eC="DropdownMenuRadioGroup",tC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(FS,{...o,...r,ref:t})});tC.displayName=eC;var nC="DropdownMenuRadioItem",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(zS,{...o,...r,ref:t})});Dh.displayName=nC;var rC="DropdownMenuItemIndicator",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(BS,{...o,...r,ref:t})});Lh.displayName=rC;var oC="DropdownMenuSeparator",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(HS,{...o,...r,ref:t})});$h.displayName=oC;var sC="DropdownMenuArrow",iC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(US,{...o,...r,ref:t})});iC.displayName=sC;var aC="DropdownMenuSubTrigger",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(WS,{...o,...r,ref:t})});Fh.displayName=aC;var lC="DropdownMenuSubContent",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(VS,{...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)"}})});zh.displayName=lC;var cC=Ih,uC=Ah,dC=_h,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=$h,Gh=Fh,Yh=zh;const fC=cC,hC=uC,pC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Gh,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));pC.displayName=Gh.displayName;const mC=m.forwardRef(({className:e,...t},n)=>c.jsx(Yh,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));mC.displayName=Yh.displayName;const Xh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(dC,{children:c.jsx(Bh,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Xh.displayName=Bh.displayName;const ol=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Uh,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ol.displayName=Uh.displayName;const gC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Wh,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Kh,{children:c.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));gC.displayName=Wh.displayName;const xC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Vh,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Kh,{children:c.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xC.displayName=Vh.displayName;const yC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));yC.displayName=Hh.displayName;const vC=m.forwardRef(({className:e,...t},n)=>c.jsx(qh,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));vC.displayName=qh.displayName;function ei({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:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=Ei(),{currentThreadId:x}=Go(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:E,loadOlder:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:_,checkpoints:R,interrupt:j,metadata:$}=Yo(),{isStreaming:L,error:F,submit:M,stop:H}=Uc(),z=g??x??null,te=(_==null?void 0:_.id)??null,V=(_==null?void 0:_.namespace)??null,U=($==null?void 0:$.assemblingMessageId)??null,me=j,[O,G]=w.useState(!1);w.useEffect(()=>{me||G(!1)},[me]);const le=w.useCallback(()=>{G(!0)},[]),be=w.useCallback(()=>{G(!1)},[]),ge=!!me||O,[ye,K]=w.useState(null),[D,X]=w.useState(""),[Z,de]=w.useState(null),[ie,Q]=w.useState([]),[tt,Ze]=w.useState(0),[Re,ze]=w.useState(0),[nt,rt]=w.useState(!1),[Pe,St]=w.useState(null),[Ct,kt]=w.useState(null),[ut,et]=w.useState(!1),[Be,dt]=w.useState(null),[re,oe]=w.useState(!1),xe=w.useRef(!1),[Me,Le]=w.useState(!1),qe=w.useRef(null),bt=w.useRef(null),ot=w.useCallback(()=>{qe.current&&(qe.current.value=""),bt.current&&(bt.current.value=""),Ze(pe=>pe+1),ze(pe=>pe+1)},[]),ht=w.useRef(!1);w.useEffect(()=>{ht.current&&!L&&(Q([]),ot()),ht.current=L},[L,ot]);const[Kt,Qt]=w.useState("desktop");w.useEffect(()=>{const pe=()=>{const Ie=window.innerWidth;Qt(Ie<640?"phone":Ie<1024?"tablet":"desktop")};return pe(),window.addEventListener("resize",pe),()=>window.removeEventListener("resize",pe)},[]),w.useEffect(()=>{oe(!1),xe.current=!1},[z]);const Er=w.useCallback(async()=>{if(!(!b||S||!re))try{await C()}catch(pe){console.warn("loadOlder failed",pe)}},[b,re,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){dt(null);return}try{const Ie=await v.getAgent("default");dt(Ie.uiDefaultMessage||null)}catch(Ie){console.warn("Failed to fetch default message:",Ie),dt(null)}})()},[v]),w.useEffect(()=>{F&&!ut&&(p==null||p(F))},[F,ut,p]);const Hn=pe=>{if(pe.length>Ds)return`Message too long (${pe.length}/${Ds} characters)`;try{return kw(pe),null}catch(Ie){return(Ie==null?void 0:Ie.message)||"Invalid message"}},Ir=async pe=>{const Ie=pe.trim();if(!(!Ie&&ie.length===0)){if(Ie){const Xe=Hn(Ie);if(Xe){de(Xe);return}}try{await M({text:Ie||"",attachments:ie,payload:ye?{edit:!0,originalMessageId:ye}:void 0},{checkpointId:te??void 0,checkpointNs:V??void 0}),f==null||f(Ie),de(null),Q([]),ot(),K(null),X("")}catch(Xe){const k=(Xe==null?void 0:Xe.message)||"Failed to send message";de(k),p==null||p(k)}}},Pn=w.useCallback((pe,Ie)=>{u&&(K(pe),X(Ie),de(null))},[u]),Et=w.useCallback(()=>{K(null),X(""),de(null)},[]),_o=w.useCallback((pe,Ie)=>{Pn(pe,Ie)},[Pn]),rr=w.useCallback(pe=>{const Ie=Xe=>{const k=Xe.content||[],B=k.filter(se=>se.type==="text").map(se=>se.text).join("");if(B)return B;try{return JSON.stringify(k,null,2)}catch{return String(k)}};for(let Xe=pe-1;Xe>=0;Xe--)if(y[Xe].role==="user"){const k=Ie(y[Xe]);k&&M({text:k},{checkpointId:te??void 0,checkpointNs:V??void 0});break}},[y,M,te,V]),It=pe=>{const Ie=Array.from(pe.target.files||[]);Q(Xe=>[...Xe,...Ie]),pe.target.value=""},yn=pe=>{Q(Ie=>{const Xe=Ie.filter((k,B)=>pe!==B);return Xe.length===0&&ot(),Xe})},On=async pe=>{const Ie=(pe.target.files||[])[0];if(Ie){St(null),kt(null),rt(!0);try{await M({attachments:[Ie]},{checkpointId:te??void 0,checkpointNs:V??void 0});const Xe=`Uploaded ${Ie.name} - processing through chat stream`;kt(Xe)}catch(Xe){const k=Xe instanceof Error?Xe.message:"Failed to upload Excel file";console.error("Excel upload failed",Xe),St(k),p==null||p(k)}finally{rt(!1),pe.target.value="",ot()}}},Kr=pe=>{if(!pe)return"Unknown";const Ie=Date.parse(pe);return Number.isNaN(Ie)?pe:new Date(Ie).toLocaleString()},cn=async pe=>{if(x){Le(!0);try{if(!pe){await I();return}const Ie=R.find(k=>k.checkpointId===pe),Xe=(Ie==null?void 0:Ie.checkpointNs)??null;await T(pe,Xe)}finally{Le(!1)}}},or=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,vn=`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 ${d.messagesArea||""}`,Mn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:or,children:[!!F&&!ut&&c.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:[c.jsx("span",{children:F}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>et(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ce.X,{size:16})})]}),x&&R.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:te??"",onChange:pe=>{const Ie=pe.target.value||null;cn(Ie)},children:[c.jsx("option",{value:"",children:"Latest"}),R.map(pe=>c.jsxs("option",{value:pe.checkpointId,children:[Kr(pe.createdAt),pe.preview?` — ${pe.preview.slice(0,40)}`:""]},pe.checkpointId))]})]}),c.jsxs("div",{className:`relative ${vn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Pa,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:U,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Kt,enableMessageEditing:u,editingMessageId:ye,onStartReached:()=>{re&&Er()},onScrollAway:pe=>{if(!xe.current){xe.current=!0;return}pe&&oe(!0)},onEdit:_o,onRegenerate:rr,onCancelEdit:Et,emptyMessage:Be??void 0,isNavigatingCheckpoint:Me,activeInterrupt:me,disableInterruptActions:O,onInterruptActionStart:le,onInterruptActionEnd:be}),E&&c.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:[c.jsx(ce.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Mn,children:[ye&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ce.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ce.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:qe,type:"file",multiple:!0,onChange:pe=>It(pe),className:"hidden"},tt),ie.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map((pe,Ie)=>c.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:[c.jsx(ce.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:pe.name}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>yn(Ie),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 ${pe.name}`,children:c.jsx(ce.X,{size:12})})]},Ie))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:bt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:On,className:"hidden"},Re),nt&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Ct&&!nt&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Ct}),Pe&&!nt&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Pe})]})]}),Z&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Z}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(fC,{children:[c.jsx(hC,{asChild:!0,children:c.jsx(Ke,{type:"button",size:"icon",variant:"outline",disabled:L||ge,title:"More input actions",className:d.moreButton||"",children:c.jsx(ce.Plus,{size:16})})}),c.jsxs(Xh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(ol,{onClick:()=>{var pe;return(pe=qe.current)==null?void 0:pe.click()},className:"cursor-pointer",children:[c.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(ol,{onClick:()=>{var pe;nt||(pe=bt.current)==null||pe.click()},className:`cursor-pointer ${nt?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx($x,{initialValue:D,editingMessageId:ye,placeholder:ye?"Edit your message...":t,isStreaming:L,disabled:ge,maxLength:Ds,onSend:Ir,onCancelEdit:Et,onStop:H,allowEmptySend:ie.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ye?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Z?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const ti=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ti.displayName="Input";function sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function bC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var il="ScrollArea",[Jh,ck]=kn(il),[wC,an]=Jh(il),Zh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,E]=m.useState(0),[C,T]=m.useState(!1),[I,_]=m.useState(!1),R=We(t,$=>l($)),j=Ls(o);return c.jsx(wC,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ee.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Zh.displayName=il;var Qh="ScrollAreaViewport",ep=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(Qh,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Ee.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});ep.displayName=Qh;var Rn="ScrollAreaScrollbar",al=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(SC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(CC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(tp,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(ll,{...r,ref:t}):null});al.displayName=Rn;var SC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Xt,{present:n||s,children:c.jsx(tp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),CC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=bC("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 m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Xt,{present:n||a!=="hidden",children:c.jsx(ll,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:he(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:he(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tp=m.forwardRef((e,t)=>{const n=an(Rn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Ur(n.viewport,l),Ur(n.content,l),c.jsx(Xt,{present:r||s,children:c.jsx(ll,{"data-state":s?"visible":"hidden",...o,ref:t})})}),ll=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(Rn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=ip(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return AC(h,i.current,a,p)}return n==="horizontal"?c.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ap(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(kC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ap(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),TC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(Rn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"data-orientation":"horizontal",...o,ref:u,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),cp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),kC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(Rn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"data-orientation":"vertical",...o,ref:u,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),cp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[EC,np]=Jh(Rn),rp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=an(Rn,n),[v,x]=m.useState(null),g=We(t,R=>x(R)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,E=r.content-r.viewport,C=_t(d),T=_t(l),I=si(f,10);function _(R){if(y.current){const j=R.clientX-y.current.left,$=R.clientY-y.current.top;u({x:j,y:$})}}return m.useEffect(()=>{const R=j=>{const $=j.target;(v==null?void 0:v.contains($))&&C(j,E)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,E,C]),m.useEffect(T,[r,T]),Ur(v,I),Ur(p.content,I),c.jsx(EC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:_t(s),onThumbPointerUp:_t(i),onThumbPositionChange:T,onThumbPointerDown:_t(a),children:c.jsx(Ee.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:he(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:he(e.onPointerMove,_),onPointerUp:he(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",op=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=np(ni,e.__scopeScrollArea);return c.jsx(Xt,{present:n||o.hasThumb,children:c.jsx(IC,{ref:t,...r})})}),IC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ni,n),i=np(ni,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=si(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=_C(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ee.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:he(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:he(e.onPointerUp,i.onThumbPointerUp)})});op.displayName=ni;var cl="ScrollAreaCorner",sp=m.forwardRef((e,t)=>{const n=an(cl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(NC,{...e,ref:t}):null});sp.displayName=cl;var NC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(cl,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ee.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 ri(e){return e?parseInt(e,10):0}function ip(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=ip(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function AC(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return lp([l,u],f)(e)}function ap(e,t,n="ltr"){const r=oi(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],u=sl(e,l);return lp([0,i],[0,a])(u)}function lp(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 cp(e,t){return e>0&&e<t}var _C=(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 si(e,t){const n=_t(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=_t(t);Tt(()=>{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 up=Zh,jC=ep,RC=sp;const dp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(up,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[c.jsx(jC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(fp,{}),c.jsx(RC,{})]}));dp.displayName=up.displayName;const fp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(al,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(op,{className:"relative flex-1 rounded-full bg-border"})}));fp.displayName=al.displayName;function ul({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Go(),{loadThread:x}=Yo(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,E]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,I]=w.useState(null),[_,R]=w.useState(""),[j,$]=w.useState(!1);w.useEffect(()=>{const O=Array.isArray(f)?f:[];if(O.length>0){C.current=!0,E(O);return}p||(C.current=!1,E(O))},[f,p]);const L=async O=>{try{await x(O),a==null||a(O),l==null||l(O)}catch(G){console.error("Failed to select thread:",G)}},F=async()=>{try{$(!0);const O=await g();u==null||u(O),a==null||a(O)}catch(O){console.error("Failed to create thread:",O)}finally{$(!1)}},M=async(O,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await y(O),d==null||d(O)}catch(le){console.error("Failed to delete thread:",le)}},H=(O,G)=>{G.stopPropagation(),I(O.threadId),R(O.title||`Thread ${O.threadId.slice(0,8)}`)},z=async O=>{if(_.trim())try{await b(O,_.trim()),I(null),R("")}catch(G){console.error("Failed to update title:",G)}},te=()=>{I(null),R("")},V=(O,G)=>{O.key==="Enter"?z(G):O.key==="Escape"&&te()},U=O=>{if(!O)return"";try{const G=new Date(O),be=new Date().getTime()-G.getTime(),ge=Math.floor(be/(1e3*60*60*24));return ge===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ge===1?"Yesterday":ge<7?`${ge} days ago`:G.toLocaleDateString()}catch{return""}},me=O=>O.title||`Thread ${O.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ke,{onClick:F,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(ce.MessageSquarePlus,{size:20})})}),c.jsx(dp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ce.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ce.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((O,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date(O.updatedAt||O.createdAt||"").getTime()).map(O=>c.jsxs("div",{onClick:()=>L(O.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===O.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===O.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[c.jsx(ti,{value:_,onChange:G=>R(G.target.value),onKeyDown:G=>V(G,O.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>z(O.threadId),className:"h-6 w-6 p-0",children:c.jsx(ce.Check,{size:12})}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:te,className:"h-6 w-6 p-0",children:c.jsx(ce.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:me(O)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ce.Calendar,{size:10}),c.jsx("span",{children:U(O.updatedAt||O.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==O.threadId&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:G=>H(O,G),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ce.Edit3,{size:12})}),n&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:G=>M(O.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ce.Trash2,{size:12})})]})]}),i===O.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},O.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function PC(e){if(typeof e!="string")return;const t=e.trim();if(t)return $n(t)}function hp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=PC(t);if(n)return n}}function pp(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function mp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return $n(t);return $n()}function gp(){const e={},t=hp(),n=pp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function xp(){const e=gp(),t=Wn.getAuthToken(),n=hp();return{apiBaseUrl:mp(e.baseUrl,Wn.baseUrl,n),apiKey:t||e.apiKey||pp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const yp="chat-settings";function OC(){try{const e=localStorage.getItem(yp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function MC(e){try{const t={...e,apiBaseUrl:$n(e.apiBaseUrl)};localStorage.setItem(yp,JSON.stringify(t)),t.apiKey&&Wn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function DC(){const e=xp(),t=OC(),n=Wn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:mp(Wn.baseUrl,r,e.apiBaseUrl)}}function LC(e){Wn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),MC(e)}var $C="Label",vp=m.forwardRef((e,t)=>c.jsx(Ee.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())}}));vp.displayName=$C;var bp=vp;const FC=Po.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ln=m.forwardRef(({className:e,...t},n)=>c.jsx(bp,{ref:n,className:ne(FC(),e),...t}));ln.displayName=bp.displayName;function wp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ii="Switch",[zC,uk]=kn(ii),[BC,HC]=zC(ii),Sp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=We(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=mr({prop:o,defaultProp:s??!1,onChange:u,caller:ii});return c.jsxs(BC,{scope:n,checked:y,disabled:a,children:[c.jsx(Ee.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ep(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:he(e.onClick,S=>{b(E=>!E),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(kp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sp.displayName=ii;var Cp="SwitchThumb",Tp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=HC(Cp,n);return c.jsx(Ee.span,{"data-state":Ep(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tp.displayName=Cp;var UC="SwitchBubbleInput",kp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=wp(n),u=Df(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kp.displayName=UC;function Ep(e){return e?"checked":"unchecked"}var Ip=Sp,WC=Tp;const er=m.forwardRef(({className:e,...t},n)=>c.jsx(Ip,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(WC,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));er.displayName=Ip.displayName;var Np=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"}),VC="VisuallyHidden",KC=m.forwardRef((e,t)=>c.jsx(Ee.span,{...e,ref:t,style:{...Np,...e.style}}));KC.displayName=VC;var qC=[" ","Enter","ArrowUp","ArrowDown"],GC=[" ","Enter"],Cr="Select",[ai,li,YC]=Oa(Cr),[Vr,dk]=kn(Cr,[YC,Gs]),ci=Gs(),[XC,tr]=Vr(Cr),[JC,ZC]=Vr(Cr),Ap=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=ci(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[E,C]=m.useState(!1),T=Ls(u),[I,_]=mr({prop:r,defaultProp:o??!1,onChange:s,caller:Cr}),[R,j]=mr({prop:i,defaultProp:a,onChange:l,caller:Cr}),$=m.useRef(null),L=g?v||!!g.closest("form"):!0,[F,M]=m.useState(new Set),H=Array.from(F).map(z=>z.props.value).join(";");return c.jsx(Kf,{...x,children:c.jsxs(XC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:En(),value:R,onValueChange:j,open:I,onOpenChange:_,dir:T,triggerPointerDownPosRef:$,disabled:h,children:[c.jsx(ai.Provider,{scope:t,children:c.jsx(JC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(z=>{M(te=>new Set(te).add(z))},[]),onNativeOptionRemove:m.useCallback(z=>{M(te=>{const V=new Set(te);return V.delete(z),V})},[]),children:n})}),L?c.jsxs(Qp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:z=>j(z.target.value),disabled:h,form:v,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(F)]},H):null]})})};Ap.displayName=Cr;var _p="SelectTrigger",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=tr(_p,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=li(n),d=m.useRef("touch"),[f,h,p]=tm(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=nm(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(qf,{asChild:!0,...s,children:c.jsx(Ee.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":em(i.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:he(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:he(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&qC.includes(x.key)&&(v(),x.preventDefault())})})})});jp.displayName=_p;var Rp="SelectValue",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=tr(Rp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return Tt(()=>{u(d)},[u,d]),c.jsx(Ee.span,{...a,ref:f,style:{pointerEvents:"none"},children:em(l.value)?c.jsx(c.Fragment,{children:i}):s})});Pp.displayName=Rp;var QC="SelectIcon",Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ee.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Op.displayName=QC;var eT="SelectPortal",Mp=e=>c.jsx(bs,{asChild:!0,...e});Mp.displayName=eT;var Tr="SelectContent",Dp=m.forwardRef((e,t)=>{const n=tr(Tr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Oo.createPortal(c.jsx(Lp,{scope:e.__scopeSelect,children:c.jsx(ai.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx($p,{...e,ref:t})});Dp.displayName=Tr;var xn=10,[Lp,nr]=Vr(Tr),tT="SelectContentImpl",nT=ir.createSlot("SelectContent.RemoveScroll"),$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=tr(Tr,n),[S,E]=m.useState(null),[C,T]=m.useState(null),I=We(t,K=>E(K)),[_,R]=m.useState(null),[j,$]=m.useState(null),L=li(n),[F,M]=m.useState(!1),H=m.useRef(!1);m.useEffect(()=>{if(S)return Aa(S)},[S]),Ca();const z=m.useCallback(K=>{const[D,...X]=L().map(ie=>ie.ref.current),[Z]=X.slice(-1),de=document.activeElement;for(const ie of K)if(ie===de||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===D&&C&&(C.scrollTop=0),ie===Z&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==de))return},[L,C]),te=m.useCallback(()=>z([_,S]),[z,_,S]);m.useEffect(()=>{F&&te()},[F,te]);const{onOpenChange:V,triggerPointerDownPosRef:U}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const D=Z=>{var de,ie;K={x:Math.abs(Math.round(Z.pageX)-(((de=U.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ie=U.current)==null?void 0:ie.y)??0))}},X=Z=>{K.x<=10&&K.y<=10?Z.preventDefault():S.contains(Z.target)||V(!1),document.removeEventListener("pointermove",D),U.current=null};return U.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,V,U]),m.useEffect(()=>{const K=()=>V(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[V]);const[me,O]=tm(K=>{const D=L().filter(de=>!de.disabled),X=D.find(de=>de.ref.current===document.activeElement),Z=nm(D,K,X);Z&&setTimeout(()=>Z.ref.current.focus())}),G=m.useCallback((K,D,X)=>{const Z=!H.current&&!X;(b.value!==void 0&&b.value===D||Z)&&(R(K),Z&&(H.current=!0))},[b.value]),le=m.useCallback(()=>S==null?void 0:S.focus(),[S]),be=m.useCallback((K,D,X)=>{const Z=!H.current&&!X;(b.value!==void 0&&b.value===D||Z)&&$(K)},[b.value]),ge=r==="popper"?dl:Fp,ye=ge===dl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Lp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:G,selectedItem:_,onItemLeave:le,itemTextRefCallback:be,focusSelectedItem:te,selectedItemText:j,position:r,isPositioned:F,searchRef:me,children:c.jsx(Es,{as:nT,allowPinchZoom:!0,children:c.jsx(vs,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:he(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(ys,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...ye,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:he(y.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&O(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let Z=L().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(K.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const de=K.target,ie=Z.indexOf(de);Z=Z.slice(ie+1)}setTimeout(()=>z(Z)),K.preventDefault()}})})})})})})});$p.displayName=tT;var rT="SelectItemAlignedPosition",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=tr(Tr,n),i=nr(Tr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,I=>d(I)),h=li(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=j.left-_.left,ie=R.left-de,Q=I.left-ie,tt=I.width+Q,Ze=Math.max(tt,_.width),Re=window.innerWidth-xn,ze=sl(ie,[xn,Math.max(xn,Re-Ze)]);a.style.minWidth=tt+"px",a.style.left=ze+"px"}else{const de=_.right-j.right,ie=window.innerWidth-R.right-de,Q=window.innerWidth-I.right-ie,tt=I.width+Q,Ze=Math.max(tt,_.width),Re=window.innerWidth-xn,ze=sl(ie,[xn,Math.max(xn,Re-Ze)]);a.style.minWidth=tt+"px",a.style.right=ze+"px"}const $=h(),L=window.innerHeight-xn*2,F=x.scrollHeight,M=window.getComputedStyle(u),H=parseInt(M.borderTopWidth,10),z=parseInt(M.paddingTop,10),te=parseInt(M.borderBottomWidth,10),V=parseInt(M.paddingBottom,10),U=H+z+F+V+te,me=Math.min(g.offsetHeight*5,U),O=window.getComputedStyle(x),G=parseInt(O.paddingTop,10),le=parseInt(O.paddingBottom,10),be=I.top+I.height/2-xn,ge=L-be,ye=g.offsetHeight/2,K=g.offsetTop+ye,D=H+z+K,X=U-D;if(D<=be){const de=$.length>0&&g===$[$.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-x.offsetTop-x.offsetHeight,Q=Math.max(ge,ye+(de?le:0)+ie+te),tt=D+Q;a.style.height=tt+"px"}else{const de=$.length>0&&g===$[0].ref.current;a.style.top="0px";const Q=Math.max(be,H+x.offsetTop+(de?G:0)+ye)+X;a.style.height=Q+"px",x.scrollTop=D-be+x.offsetTop}a.style.margin=`${xn}px 0`,a.style.minHeight=me+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);Tt(()=>S(),[S]);const[E,C]=m.useState();Tt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(sT,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Ee.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fp.displayName=rT;var oT="SelectPopperPosition",dl=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=xn,...s}=e,i=ci(n);return c.jsx(Gf,{...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)"}})});dl.displayName=oT;var[sT,fl]=Vr(Tr,{}),hl="SelectViewport",zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=nr(hl,n),i=fl(hl,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(ai.Slot,{scope:n,children:c.jsx(Ee.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:he(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-xn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),E=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});zp.displayName=hl;var Bp="SelectGroup",[iT,aT]=Vr(Bp),lT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=En();return c.jsx(iT,{scope:n,id:o,children:c.jsx(Ee.div,{role:"group","aria-labelledby":o,...r,ref:t})})});lT.displayName=Bp;var Hp="SelectLabel",Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aT(Hp,n);return c.jsx(Ee.div,{id:o.id,...r,ref:t})});Up.displayName=Hp;var ui="SelectItem",[cT,Wp]=Vr(ui),Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=tr(ui,n),l=nr(ui,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=En(),g=m.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 c.jsx(cT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ai.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ee.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:he(i.onFocus,()=>p(!0)),onBlur:he(i.onBlur,()=>p(!1)),onClick:he(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:he(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:he(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:he(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:he(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(GC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Vp.displayName=ui;var Ao="SelectItemText",Kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=tr(Ao,n),a=nr(Ao,n),l=Wp(Ao,n),u=ZC(Ao,n),[d,f]=m.useState(null),h=We(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Tt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ee.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Oo.createPortal(s.children,i.valueNode):null]})});Kp.displayName=Ao;var qp="SelectItemIndicator",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wp(qp,n).isSelected?c.jsx(Ee.span,{"aria-hidden":!0,...r,ref:t}):null});Gp.displayName=qp;var pl="SelectScrollUpButton",Yp=m.forwardRef((e,t)=>{const n=nr(pl,e.__scopeSelect),r=fl(pl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Yp.displayName=pl;var ml="SelectScrollDownButton",Xp=m.forwardRef((e,t)=>{const n=nr(ml,e.__scopeSelect),r=fl(ml,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Xp.displayName=ml;var Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=nr("SelectScrollButton",n),i=m.useRef(null),a=li(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(Ee.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:he(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:he(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),uT="SelectSeparator",Zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ee.div,{"aria-hidden":!0,...r,ref:t})});Zp.displayName=uT;var gl="SelectArrow",dT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ci(n),s=tr(gl,n),i=nr(gl,n);return s.open&&i.position==="popper"?c.jsx(Yf,{...o,...r,ref:t}):null});dT.displayName=gl;var fT="SelectBubbleInput",Qp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=wp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ee.select,{...n,style:{...Np,...n.style},ref:s,defaultValue:t})});Qp.displayName=fT;function em(e){return e===""||e===void 0}function tm(e){const t=_t(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function nm(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=hT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function hT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pT=Ap,rm=jp,mT=Pp,gT=Op,xT=Mp,om=Dp,yT=zp,sm=Up,im=Vp,vT=Kp,bT=Gp,am=Yp,lm=Xp,cm=Zp;const um=pT,dm=mT,xl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(rm,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(gT,{asChild:!0,children:c.jsx(ce.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));xl.displayName=rm.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const hm=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ce.ChevronDown,{className:"h-4 w-4"})}));hm.displayName=lm.displayName;const yl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(xT,{children:c.jsxs(om,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(fm,{}),c.jsx(yT,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(hm,{})]})}));yl.displayName=om.displayName;const wT=m.forwardRef(({className:e,...t},n)=>c.jsx(sm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));wT.displayName=sm.displayName;const kr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(im,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(bT,{children:c.jsx(ce.Check,{className:"h-4 w-4"})})}),c.jsx(vT,{children:t})]}));kr.displayName=im.displayName;const ST=m.forwardRef(({className:e,...t},n)=>c.jsx(cm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));ST.displayName=cm.displayName;var CT="Separator",pm="horizontal",TT=["horizontal","vertical"],mm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=pm,...o}=e,s=kT(r)?r:pm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ee.div,{"data-orientation":s,...a,...o,ref:t})});mm.displayName=CT;function kT(e){return TT.includes(e)}var gm=mm;const xm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(gm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));xm.displayName=gm.displayName;const ET=Qd,IT=iw,NT=ef,ym=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));ym.displayName=js.displayName;const AT=Po.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"}}),vm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(NT,{children:[c.jsx(ym,{}),c.jsxs(Rs,{ref:o,className:ne(AT({side:e}),t),...r,children:[n,c.jsxs(tf,{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:[c.jsx(ce.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vm.displayName=Rs.displayName;const bm=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});bm.displayName="SheetHeader";const wm=m.forwardRef(({className:e,...t},n)=>c.jsx(yr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));wm.displayName=yr.displayName;const Sm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Sm.displayName=Ps.displayName;const _T={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function jT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=ya();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(_T),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(ET,{open:r,onOpenChange:o,children:[c.jsx(IT,{asChild:!0,children:c.jsxs(Ke,{variant:"outline",size:"sm",className:n,children:[c.jsx(ce.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(la,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(vm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(bm,{children:[c.jsx(wm,{children:"Chat Settings"}),c.jsx(Sm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ce.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ti,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ke,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(er,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ti,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ke,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ce.EyeOff,{className:"h-4 w-4"}):c.jsx(ce.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ce.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(um,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(xl,{children:c.jsx(dm,{})}),c.jsxs(yl,{children:[c.jsx(kr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(kr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(kr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"theme",children:"Theme"}),c.jsxs(um,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(xl,{children:c.jsx(dm,{})}),c.jsxs(yl,{children:[c.jsx(kr,{value:"light",children:"Light"}),c.jsx(kr,{value:"dark",children:"Dark"}),c.jsx(kr,{value:"system",children:"System"})]})]})]}),c.jsx(xm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(er,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(er,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(er,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ce.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(er,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(er,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(er,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ke,{variant:"outline",onClick:p,children:[c.jsx(ce.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ke,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ke,{onClick:h,disabled:!u,children:[c.jsx(ce.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function RT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){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=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ei,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ul,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ei,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Xo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ul,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ei,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=yc,Ne.ChatInterface=ei,Ne.ChatProviders=Xo,Ne.ChatSettings=jT,Ne.MarkdownContent=ma,Ne.MessageComponent=df,Ne.MessageList=Pa,Ne.ThreadManager=ul,Ne.applySettings=LC,Ne.chatApiClient=Wn,Ne.default=RT,Ne.del=xc,Ne.get=dn,Ne.getChatToken=hc,Ne.getCurrentSettings=DC,Ne.getDefaultApiConfig=gp,Ne.getDefaultChatSettings=xp,Ne.onChatTokenChanged=pc,Ne.post=mc,Ne.put=gc,Ne.setChatToken=ki,Ne.useApi=Ei,Ne.useChatStream=Mc,Ne.useMessagesReducer=Ec,Ne.useStream=Uc,Ne.useThreadState=Yo,Ne.useThreads=Go,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
139
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Tw(e,t=Ds){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function kw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Tw(t),Cw(t)}function Oa(e){const t=e+"CollectionProvider",[n,r]=kn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=ir.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),E=We(g,S.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=ir.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,E=w.useRef(null),C=We(g,E),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(E,{ref:E,...S}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Ew=m.createContext(void 0);function Ls(e){const t=m.useContext(Ew);return e||t||"ltr"}const Iw=["top","right","bottom","left"],Zn=Math.min,Jt=Math.max,$s=Math.round,Fs=Math.floor,Nn=e=>({x:e,y:e}),Nw={left:"right",right:"left",bottom:"top",top:"bottom"},Aw={start:"end",end:"start"};function Ma(e,t,n){return Jt(e,Zn(t,n))}function zn(e,t){return typeof e=="function"?e(t):e}function Bn(e){return e.split("-")[0]}function Fr(e){return e.split("-")[1]}function Da(e){return e==="x"?"y":"x"}function La(e){return e==="y"?"height":"width"}const _w=new Set(["top","bottom"]);function An(e){return _w.has(Bn(e))?"y":"x"}function $a(e){return Da(An(e))}function jw(e,t,n){n===void 0&&(n=!1);const r=Fr(e),o=$a(e),s=La(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=zs(i)),[i,zs(i)]}function Rw(e){const t=zs(e);return[Fa(e),t,Fa(t)]}function Fa(e){return e.replace(/start|end/g,t=>Aw[t])}const hf=["left","right"],pf=["right","left"],Pw=["top","bottom"],Ow=["bottom","top"];function Mw(e,t,n){switch(e){case"top":case"bottom":return n?t?pf:hf:t?hf:pf;case"left":case"right":return t?Pw:Ow;default:return[]}}function Dw(e,t,n,r){const o=Fr(e);let s=Mw(Bn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Fa)))),s}function zs(e){return e.replace(/left|right|bottom|top/g,t=>Nw[t])}function Lw(e){return{top:0,right:0,bottom:0,left:0,...e}}function mf(e){return typeof e!="number"?Lw(e):{top:e,right:e,bottom:e,left:e}}function Bs(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 gf(e,t,n){let{reference:r,floating:o}=e;const s=An(t),i=$a(t),a=La(i),l=Bn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const $w=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 u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=gf(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:E,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...E}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=gf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function bo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=zn(t,e),v=mf(p),g=a[h?f==="floating"?"reference":"floating":f],y=Bs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="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)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Bs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/E.y,bottom:(C.bottom-y.bottom+v.bottom)/E.y,left:(y.left-C.left+v.left)/E.x,right:(C.right-y.right+v.right)/E.x}}const Fw=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:u,padding:d=0}=zn(e,t)||{};if(u==null)return{};const f=mf(d),h={x:n,y:r},p=$a(o),v=La(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[v]);const _=E/2-C/2,R=I/2-x[v]/2-1,j=Zn(f[y],R),z=Zn(f[b],R),L=j,B=I-x[v]-z,M=I/2-x[v]/2+_,q=Ma(L,M,B),U=!l.arrow&&Fr(o)!=null&&M!==q&&s.reference[v]/2-(M<L?j:z)-x[v]/2<0,te=U?M<L?M-L:M-B:0;return{[p]:h[p]+te,data:{[p]:q,centerOffset:M-q-te,...U&&{alignmentOffset:te}},reset:U}}}),zw=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:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=zn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Bn(o),b=An(a),S=Bn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[zs(a)]:Rw(a)),T=v!=="none";!h&&T&&C.push(...Dw(a,x,v,E));const I=[a,...C],_=await bo(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),f){const M=jw(o,i,E);R.push(_[M[0]],_[M[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(M=>M<=0)){var z,L;const M=(((z=s.flip)==null?void 0:z.index)||0)+1,q=I[M];if(q&&(!(f==="alignment"?b!==An(q):!1)||j.every($=>An($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:M,overflows:j},reset:{placement:q}};let U=(L=j.filter(te=>te.overflows[0]<=0).sort((te,$)=>te.overflows[1]-$.overflows[1])[0])==null?void 0:L.placement;if(!U)switch(p){case"bestFit":{var B;const te=(B=j.filter($=>{if(T){const F=An($.placement);return F===b||F==="y"}return!0}).map($=>[$.placement,$.overflows.filter(F=>F>0).reduce((F,ie)=>F+ie,0)]).sort(($,F)=>$[1]-F[1])[0])==null?void 0:B[0];te&&(U=te);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function xf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yf(e){return Iw.some(t=>e[t]>=0)}const Bw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=zn(e,t);switch(r){case"referenceHidden":{const s=await bo(t,{...o,elementContext:"reference"}),i=xf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:yf(i)}}}case"escaped":{const s=await bo(t,{...o,altBoundary:!0}),i=xf(s,n.floating);return{data:{escapedOffsets:i,escaped:yf(i)}}}default:return{}}}}},vf=new Set(["left","top"]);async function Hw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Bn(n),a=Fr(n),l=An(n)==="y",u=vf.has(i)?-1:1,d=s&&l?-1:1,f=zn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Uw=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 Hw(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}}}}},Ww=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:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=zn(e,t),u={x:n,y:r},d=await bo(t,l),f=An(Bn(o)),h=Da(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Ma(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Ma(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Vw=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:u=!0}=zn(e,t),d={x:n,y:r},f=An(o),h=Da(f);let p=d[h],v=d[f];const x=zn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",E=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",E=vf.has(Bn(o)),C=s.reference[f]-s.floating[S]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},Kw=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=()=>{},...u}=zn(e,t),d=await bo(t,u),f=Bn(o),h=Fr(o),p=An(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,E=Zn(x-d[g],b),C=Zn(v-d[y],S),T=!t.middlewareData.shift;let I=E,_=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Jt(d.left,0),z=Jt(d.right,0),L=Jt(d.top,0),B=Jt(d.bottom,0);p?_=v-2*(j!==0||z!==0?j+z:Jt(d.left,d.right)):I=x-2*(L!==0||B!==0?L+B:Jt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||x!==R.height?{reset:{rects:!0}}:{}}}};function Hs(){return typeof window<"u"}function zr(e){return bf(e)?(e.nodeName||"").toLowerCase():"#document"}function Zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _n(e){var t;return(t=(bf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function bf(e){return Hs()?e instanceof Node||e instanceof Zt(e).Node:!1}function mn(e){return Hs()?e instanceof Element||e instanceof Zt(e).Element:!1}function jn(e){return Hs()?e instanceof HTMLElement||e instanceof Zt(e).HTMLElement:!1}function wf(e){return!Hs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zt(e).ShadowRoot}const qw=new Set(["inline","contents"]);function wo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=gn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!qw.has(o)}const Gw=new Set(["table","td","th"]);function Yw(e){return Gw.has(zr(e))}const Xw=[":popover-open",":modal"];function Us(e){return Xw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Jw=["transform","translate","scale","rotate","perspective"],Zw=["transform","translate","scale","rotate","perspective","filter"],Qw=["paint","layout","strict","content"];function za(e){const t=Ba(),n=mn(e)?gn(e):e;return Jw.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)||Zw.some(r=>(n.willChange||"").includes(r))||Qw.some(r=>(n.contain||"").includes(r))}function e0(e){let t=Qn(e);for(;jn(t)&&!Br(t);){if(za(t))return t;if(Us(t))return null;t=Qn(t)}return null}function Ba(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const t0=new Set(["html","body","#document"]);function Br(e){return t0.has(zr(e))}function gn(e){return Zt(e).getComputedStyle(e)}function Ws(e){return mn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qn(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||wf(e)&&e.host||_n(e);return wf(t)?t.host:t}function Sf(e){const t=Qn(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:jn(t)&&wo(t)?t:Sf(t)}function So(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Zt(o);if(s){const a=Ha(i);return t.concat(i,i.visualViewport||[],wo(o)?o:[],a&&n?So(a):[])}return t.concat(o,So(o,[],n))}function Ha(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Cf(e){const t=gn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=jn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=$s(n)!==s||$s(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ua(e){return mn(e)?e:e.contextElement}function Hr(e){const t=Ua(e);if(!jn(t))return Nn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Cf(t);let i=(s?$s(n.width):n.width)/r,a=(s?$s(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const n0=Nn(0);function Tf(e){const t=Zt(e);return!Ba()||!t.visualViewport?n0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function r0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Zt(e)?!1:t}function br(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ua(e);let i=Nn(1);t&&(r?mn(r)&&(i=Hr(r)):i=Hr(e));const a=r0(s,n,r)?Tf(s):Nn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Zt(s),p=r&&mn(r)?Zt(r):r;let v=h,x=Ha(v);for(;x&&r&&p!==v;){const g=Hr(x),y=x.getBoundingClientRect(),b=gn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,E=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=E,v=Zt(x),x=Ha(v)}}return Bs({width:d,height:f,x:l,y:u})}function Vs(e,t){const n=Ws(e).scrollLeft;return t?t.left+n:br(_n(e)).left+n}function kf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Vs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function o0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=_n(r),a=t?Us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Nn(1);const d=Nn(0),f=jn(r);if((f||!f&&!s)&&((zr(r)!=="body"||wo(i))&&(l=Ws(r)),jn(r))){const p=br(r);u=Hr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?kf(i,l):Nn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function s0(e){return Array.from(e.getClientRects())}function i0(e){const t=_n(e),n=Ws(e),r=e.ownerDocument.body,o=Jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Vs(e);const a=-n.scrollTop;return gn(r).direction==="rtl"&&(i+=Jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ef=25;function a0(e,t){const n=Zt(e),r=_n(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=Ba();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Vs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ef&&(s-=v)}else u<=Ef&&(s+=u);return{width:s,height:i,x:a,y:l}}const l0=new Set(["absolute","fixed"]);function c0(e,t){const n=br(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=jn(e)?Hr(e):Nn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function If(e,t,n){let r;if(t==="viewport")r=a0(e,n);else if(t==="document")r=i0(_n(e));else if(mn(t))r=c0(t,n);else{const o=Tf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Bs(r)}function Nf(e,t){const n=Qn(e);return n===t||!mn(n)||Br(n)?!1:gn(n).position==="fixed"||Nf(n,t)}function u0(e,t){const n=t.get(e);if(n)return n;let r=So(e,[],!1).filter(a=>mn(a)&&zr(a)!=="body"),o=null;const s=gn(e).position==="fixed";let i=s?Qn(e):e;for(;mn(i)&&!Br(i);){const a=gn(i),l=za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&l0.has(o.position)||wo(i)&&!l&&Nf(e,i))?r=r.filter(d=>d!==i):o=a,i=Qn(i)}return t.set(e,r),r}function d0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Us(t)?[]:u0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=If(t,d,o);return u.top=Jt(f.top,u.top),u.right=Zn(f.right,u.right),u.bottom=Zn(f.bottom,u.bottom),u.left=Jt(f.left,u.left),u},If(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function f0(e){const{width:t,height:n}=Cf(e);return{width:t,height:n}}function h0(e,t,n){const r=jn(t),o=_n(t),s=n==="fixed",i=br(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Nn(0);function u(){l.x=Vs(o)}if(r||!r&&!s)if((zr(t)!=="body"||wo(o))&&(a=Ws(t)),r){const p=br(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?kf(o,a):Nn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Wa(e){return gn(e).position==="static"}function Af(e,t){if(!jn(e)||gn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _n(e)===n&&(n=n.ownerDocument.body),n}function _f(e,t){const n=Zt(e);if(Us(e))return n;if(!jn(e)){let o=Qn(e);for(;o&&!Br(o);){if(mn(o)&&!Wa(o))return o;o=Qn(o)}return n}let r=Af(e,t);for(;r&&Yw(r)&&Wa(r);)r=Af(r,t);return r&&Br(r)&&Wa(r)&&!za(r)?n:r||e0(e)||n}const p0=async function(e){const t=this.getOffsetParent||_f,n=this.getDimensions,r=await n(e.floating);return{reference:h0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function m0(e){return gn(e).direction==="rtl"}const g0={convertOffsetParentRelativeRectToViewportRelativeRect:o0,getDocumentElement:_n,getClippingRect:d0,getOffsetParent:_f,getElementRects:p0,getClientRects:s0,getDimensions:f0,getScale:Hr,isElement:mn,isRTL:m0};function jf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function x0(e,t){let n=null,r;const o=_n(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 u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Fs(f),x=Fs(o.clientWidth-(d+h)),g=Fs(o.clientHeight-(f+p)),y=Fs(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Jt(0,Zn(1,l))||1};let E=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!jf(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function y0(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,u=Ua(e),d=o||s?[...u?So(u):[],...So(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?x0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?br(e):null;l&&g();function g(){const y=br(e);x&&!jf(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const v0=Uw,b0=Ww,w0=zw,S0=Kw,C0=Bw,Rf=Fw,T0=Vw,k0=(e,t,n)=>{const r=new Map,o={platform:g0,...n},s={...o.platform,_c:r};return $w(e,t,{...o,platform:s})};var E0=typeof document<"u",I0=function(){},Ks=E0?w.useLayoutEffect:I0;function qs(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(!qs(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)&&!qs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Pf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Of(e,t){const n=Pf(e);return Math.round(t*n)/n}function Va(e){const t=m.useRef(e);return Ks(()=>{t.current=e}),t}function N0(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:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);qs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback($=>{$!==T.current&&(T.current=$,x($))},[]),S=m.useCallback($=>{$!==I.current&&(I.current=$,y($))},[]),E=s||v,C=i||g,T=m.useRef(null),I=m.useRef(null),_=m.useRef(d),R=l!=null,j=Va(l),z=Va(o),L=Va(u),B=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};z.current&&($.platform=z.current),k0(T.current,I.current,$).then(F=>{const ie={...F,isPositioned:L.current!==!1};M.current&&!qs(_.current,ie)&&(_.current=ie,Oo.flushSync(()=>{f(ie)}))})},[h,t,n,z,L]);Ks(()=>{u===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);Ks(()=>(M.current=!0,()=>{M.current=!1}),[]),Ks(()=>{if(E&&(T.current=E),C&&(I.current=C),E&&C){if(j.current)return j.current(E,C,B);B()}},[E,C,B,j,R]);const q=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:S}),[b,S]),U=m.useMemo(()=>({reference:E,floating:C}),[E,C]),te=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!U.floating)return $;const F=Of(U.floating,d.x),ie=Of(U.floating,d.y);return a?{...$,transform:"translate("+F+"px, "+ie+"px)",...Pf(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:ie}},[n,a,U.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:B,refs:q,elements:U,floatingStyles:te}),[d,B,q,U,te])}const A0=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?Rf({element:r.current,padding:o}).fn(n):{}:r?Rf({element:r,padding:o}).fn(n):{}}}},_0=(e,t)=>({...v0(e),options:[e,t]}),j0=(e,t)=>({...b0(e),options:[e,t]}),R0=(e,t)=>({...T0(e),options:[e,t]}),P0=(e,t)=>({...w0(e),options:[e,t]}),O0=(e,t)=>({...S0(e),options:[e,t]}),M0=(e,t)=>({...C0(e),options:[e,t]}),D0=(e,t)=>({...A0(e),options:[e,t]});var L0="Arrow",Mf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ee.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Mf.displayName=L0;var $0=Mf;function Df(e){const[t,n]=m.useState(void 0);return Tt(()=>{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,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.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 Ka="Popper",[Lf,Gs]=kn(Ka),[F0,$f]=Lf(Ka),Ff=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(F0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ff.displayName=Ka;var zf="PopperAnchor",Bf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$f(zf,n),i=m.useRef(null),a=We(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(Ee.div,{...o,ref:a})});Bf.displayName=zf;var qa="PopperContent",[z0,B0]=Lf(qa),Hf=m.forwardRef((e,t)=>{var V,D,X,Z,fe,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=$f(qa,n),[y,b]=m.useState(null),S=We(t,Q=>b(Q)),[E,C]=m.useState(null),T=Df(E),I=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},z=Array.isArray(u)?u:[u],L=z.length>0,B={padding:j,boundary:z.filter(U0),altBoundary:L},{refs:M,floatingStyles:q,placement:U,isPositioned:te,middlewareData:$}=N0({strategy:"fixed",placement:R,whileElementsMounted:(...Q)=>y0(...Q,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[_0({mainAxis:o+_,alignmentAxis:i}),l&&j0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?R0():void 0,...B}),l&&P0({...B}),O0({...B,apply:({elements:Q,rects:tt,availableWidth:Ze,availableHeight:Re})=>{const{width:ze,height:nt}=tt.reference,rt=Q.floating.style;rt.setProperty("--radix-popper-available-width",`${Ze}px`),rt.setProperty("--radix-popper-available-height",`${Re}px`),rt.setProperty("--radix-popper-anchor-width",`${ze}px`),rt.setProperty("--radix-popper-anchor-height",`${nt}px`)}}),E&&D0({element:E,padding:a}),W0({arrowWidth:I,arrowHeight:_}),h&&M0({strategy:"referenceHidden",...B})]}),[F,ie]=Vf(U),O=_t(v);Tt(()=>{te&&(O==null||O())},[te,O]);const G=(V=$.arrow)==null?void 0:V.x,ce=(D=$.arrow)==null?void 0:D.y,be=((X=$.arrow)==null?void 0:X.centerOffset)!==0,[ge,ye]=m.useState();return Tt(()=>{y&&ye(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:te?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Z=$.transformOrigin)==null?void 0:Z.x,(fe=$.transformOrigin)==null?void 0:fe.y].join(" "),...((ae=$.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(z0,{scope:n,placedSide:F,onArrowChange:C,arrowX:G,arrowY:ce,shouldHideArrow:be,children:c.jsx(Ee.div,{"data-side":F,"data-align":ie,...x,ref:S,style:{...x.style,animation:te?void 0:"none"}})})})});Hf.displayName=qa;var Uf="PopperArrow",H0={top:"bottom",right:"left",bottom:"top",left:"right"},Wf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=B0(Uf,r),i=H0[s.placedSide];return c.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:c.jsx($0,{...o,ref:n,style:{...o.style,display:"block"}})})});Wf.displayName=Uf;function U0(e){return e!==null}var W0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Vf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Vf(e){const[t,n="center"]=e.split("-");return[t,n]}var Kf=Ff,qf=Bf,Gf=Hf,Yf=Wf,Ga="rovingFocusGroup.onEntryFocus",V0={bubbles:!1,cancelable:!0},Co="RovingFocusGroup",[Ya,Xf,K0]=Oa(Co),[q0,Jf]=kn(Co,[K0]),[G0,Y0]=q0(Co),Zf=m.forwardRef((e,t)=>c.jsx(Ya.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ya.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(X0,{...e,ref:t})})}));Zf.displayName=Co;var X0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=We(t,h),v=Ls(s),[x,g]=mr({prop:i,defaultProp:a??null,onChange:l,caller:Co}),[y,b]=m.useState(!1),S=_t(u),E=Xf(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const _=h.current;if(_)return _.addEventListener(Ga,S),()=>_.removeEventListener(Ga,S)},[S]),c.jsx(G0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(_=>g(_),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(_=>_+1),[]),onFocusableItemRemove:m.useCallback(()=>I(_=>_-1),[]),children:c.jsx(Ee.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{C.current=!0}),onFocus:pe(e.onFocus,_=>{const R=!C.current;if(_.target===_.currentTarget&&R&&!y){const j=new CustomEvent(Ga,V0);if(_.currentTarget.dispatchEvent(j),!j.defaultPrevented){const z=E().filter(U=>U.focusable),L=z.find(U=>U.active),B=z.find(U=>U.id===x),q=[L,B,...z].filter(Boolean).map(U=>U.ref.current);th(q,d)}}C.current=!1}),onBlur:pe(e.onBlur,()=>b(!1))})})}),Qf="RovingFocusGroupItem",eh=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=En(),u=s||l,d=Y0(Qf,n),f=d.currentTabStopId===u,h=Xf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Ya.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ee.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=Q0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const E=S.indexOf(g.currentTarget);S=d.loop?eS(S,E+1):S.slice(E+1)}setTimeout(()=>th(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});eh.displayName=Qf;var J0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Z0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q0(e,t,n){const r=Z0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return J0[r]}function th(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function eS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tS=Zf,nS=eh,Xa=["Enter"," "],rS=["ArrowDown","PageUp","Home"],nh=["ArrowUp","PageDown","End"],oS=[...rS,...nh],sS={ltr:[...Xa,"ArrowRight"],rtl:[...Xa,"ArrowLeft"]},iS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},To="Menu",[ko,aS,lS]=Oa(To),[wr,rh]=kn(To,[lS,Gs,Jf]),Ys=Gs(),oh=Jf(),[cS,Sr]=wr(To),[uS,Eo]=wr(To),sh=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ys(t),[l,u]=m.useState(null),d=m.useRef(!1),f=_t(s),h=Ls(o);return m.useEffect(()=>{const p=()=>{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",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Kf,{...a,children:c.jsx(cS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(uS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};sh.displayName=To;var dS="MenuAnchor",Ja=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ys(n);return c.jsx(qf,{...o,...r,ref:t})});Ja.displayName=dS;var Za="MenuPortal",[fS,ih]=wr(Za,{forceMount:void 0}),ah=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Sr(Za,t);return c.jsx(fS,{scope:t,forceMount:n,children:c.jsx(Xt,{present:n||s.open,children:c.jsx(bs,{asChild:!0,container:o,children:r})})})};ah.displayName=Za;var sn="MenuContent",[hS,Qa]=wr(sn),lh=m.forwardRef((e,t)=>{const n=ih(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Sr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu);return c.jsx(ko.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(ko.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(pS,{...o,ref:t}):c.jsx(mS,{...o,ref:t})})})})}),pS=m.forwardRef((e,t)=>{const n=Sr(sn,e.__scopeMenu),r=m.useRef(null),o=We(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Aa(s)},[]),c.jsx(el,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),mS=m.forwardRef((e,t)=>{const n=Sr(sn,e.__scopeMenu);return c.jsx(el,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gS=ir.createSlot("MenuContent.ScrollLock"),el=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=Sr(sn,n),y=Eo(sn,n),b=Ys(n),S=oh(n),E=aS(n),[C,T]=m.useState(null),I=m.useRef(null),_=We(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),z=m.useRef(0),L=m.useRef(null),B=m.useRef("right"),M=m.useRef(0),q=v?Es:m.Fragment,U=v?{as:gS,allowPinchZoom:!0}:void 0,te=F=>{var V,D;const ie=j.current+F,O=E().filter(X=>!X.disabled),G=document.activeElement,ce=(V=O.find(X=>X.ref.current===G))==null?void 0:V.textValue,be=O.map(X=>X.textValue),ge=NS(be,ie,ce),ye=(D=O.find(X=>X.textValue===ge))==null?void 0:D.ref.current;(function X(Z){j.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(ie),ye&&setTimeout(()=>ye.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Ca();const $=m.useCallback(F=>{var O,G;return B.current===((O=L.current)==null?void 0:O.side)&&_S(F,(G=L.current)==null?void 0:G.area)},[]);return c.jsx(hS,{scope:n,searchRef:j,onItemEnter:m.useCallback(F=>{$(F)&&F.preventDefault()},[$]),onItemLeave:m.useCallback(F=>{var ie;$(F)||((ie=I.current)==null||ie.focus(),T(null))},[$]),onTriggerLeave:m.useCallback(F=>{$(F)&&F.preventDefault()},[$]),pointerGraceTimerRef:z,onPointerGraceIntentChange:m.useCallback(F=>{L.current=F},[]),children:c.jsx(q,{...U,children:c.jsx(vs,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,F=>{var ie;F.preventDefault(),(ie=I.current)==null||ie.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(ys,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(tS,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:pe(l,F=>{y.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Gf,{role:"menu","aria-orientation":"vertical","data-state":kh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:_,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,F=>{const O=F.target.closest("[data-radix-menu-content]")===F.currentTarget,G=F.ctrlKey||F.altKey||F.metaKey,ce=F.key.length===1;O&&(F.key==="Tab"&&F.preventDefault(),!G&&ce&&te(F.key));const be=I.current;if(F.target!==be||!oS.includes(F.key))return;F.preventDefault();const ye=E().filter(V=>!V.disabled).map(V=>V.ref.current);nh.includes(F.key)&&ye.reverse(),ES(ye)}),onBlur:pe(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:pe(e.onPointerMove,No(F=>{const ie=F.target,O=M.current!==F.clientX;if(F.currentTarget.contains(ie)&&O){const G=F.clientX>M.current?"right":"left";B.current=G,M.current=F.clientX}}))})})})})})})});lh.displayName=sn;var xS="MenuGroup",tl=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"group",...r,ref:t})});tl.displayName=xS;var yS="MenuLabel",ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{...r,ref:t})});ch.displayName=yS;var Xs="MenuItem",uh="menu.itemSelect",Js=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Eo(Xs,e.__scopeMenu),a=Qa(Xs,e.__scopeMenu),l=We(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(uh,{bubbles:!0,cancelable:!0});f.addEventListener(uh,p=>r==null?void 0:r(p),{once:!0}),Wu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(dh,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Xa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Js.displayName=Xs;var dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Qa(Xs,n),a=oh(n),l=m.useRef(null),u=We(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(ko.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(nS,{asChild:!0,...a,focusable:!r,children:c.jsx(Ee.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:pe(e.onPointerMove,No(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,No(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),vS="MenuCheckboxItem",fh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(xh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Js,{role:"menuitemcheckbox","aria-checked":Zs(n)?"mixed":n,...o,ref:t,"data-state":rl(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(Zs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});fh.displayName=vS;var hh="MenuRadioGroup",[bS,wS]=wr(hh,{value:void 0,onValueChange:()=>{}}),ph=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=_t(r);return c.jsx(bS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(tl,{...o,ref:t})})});ph.displayName=hh;var mh="MenuRadioItem",gh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=wS(mh,e.__scopeMenu),s=n===o.value;return c.jsx(xh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Js,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":rl(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});gh.displayName=mh;var nl="MenuItemIndicator",[xh,SS]=wr(nl,{checked:!1}),yh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=SS(nl,n);return c.jsx(Xt,{present:r||Zs(s.checked)||s.checked===!0,children:c.jsx(Ee.span,{...o,ref:t,"data-state":rl(s.checked)})})});yh.displayName=nl;var CS="MenuSeparator",vh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ee.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});vh.displayName=CS;var TS="MenuArrow",bh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ys(n);return c.jsx(Yf,{...o,...r,ref:t})});bh.displayName=TS;var kS="MenuSub",[ak,wh]=wr(kS),Io="MenuSubTrigger",Sh=m.forwardRef((e,t)=>{const n=Sr(Io,e.__scopeMenu),r=Eo(Io,e.__scopeMenu),o=wh(Io,e.__scopeMenu),s=Qa(Io,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ja,{asChild:!0,...u,children:c.jsx(dh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":kh(n.open),...e,ref:ca(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:pe(e.onPointerMove,No(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:pe(e.onPointerLeave,No(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||sS[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Sh.displayName=Io;var Ch="MenuSubContent",Th=m.forwardRef((e,t)=>{const n=ih(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Sr(sn,e.__scopeMenu),i=Eo(sn,e.__scopeMenu),a=wh(Ch,e.__scopeMenu),l=m.useRef(null),u=We(t,l);return c.jsx(ko.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(ko.Slot,{scope:e.__scopeMenu,children:c.jsx(el,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=iS[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Th.displayName=Ch;function kh(e){return e?"open":"closed"}function Zs(e){return e==="indeterminate"}function rl(e){return Zs(e)?"indeterminate":e?"checked":"unchecked"}function ES(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function IS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function NS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=IS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function AS(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],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function _S(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return AS(n,t)}function No(e){return t=>t.pointerType==="mouse"?e(t):void 0}var jS=sh,RS=Ja,PS=ah,OS=lh,MS=tl,DS=ch,LS=Js,$S=fh,FS=ph,zS=gh,BS=yh,HS=vh,US=bh,WS=Sh,VS=Th,Qs="DropdownMenu",[KS,lk]=kn(Qs,[rh]),Bt=rh(),[qS,Eh]=KS(Qs),Ih=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Bt(t),u=m.useRef(null),[d,f]=mr({prop:o,defaultProp:s??!1,onChange:i,caller:Qs});return c.jsx(qS,{scope:t,triggerId:En(),triggerRef:u,contentId:En(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(jS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ih.displayName=Qs;var Nh="DropdownMenuTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Eh(Nh,n),i=Bt(n);return c.jsx(RS,{asChild:!0,...i,children:c.jsx(Ee.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:ca(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ah.displayName=Nh;var GS="DropdownMenuPortal",_h=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bt(t);return c.jsx(PS,{...r,...n})};_h.displayName=GS;var jh="DropdownMenuContent",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Eh(jh,n),s=Bt(n),i=m.useRef(!1);return c.jsx(OS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!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)"}})});Rh.displayName=jh;var YS="DropdownMenuGroup",XS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(MS,{...o,...r,ref:t})});XS.displayName=YS;var JS="DropdownMenuLabel",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(DS,{...o,...r,ref:t})});Ph.displayName=JS;var ZS="DropdownMenuItem",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(LS,{...o,...r,ref:t})});Oh.displayName=ZS;var QS="DropdownMenuCheckboxItem",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx($S,{...o,...r,ref:t})});Mh.displayName=QS;var eC="DropdownMenuRadioGroup",tC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(FS,{...o,...r,ref:t})});tC.displayName=eC;var nC="DropdownMenuRadioItem",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(zS,{...o,...r,ref:t})});Dh.displayName=nC;var rC="DropdownMenuItemIndicator",Lh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(BS,{...o,...r,ref:t})});Lh.displayName=rC;var oC="DropdownMenuSeparator",$h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(HS,{...o,...r,ref:t})});$h.displayName=oC;var sC="DropdownMenuArrow",iC=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(US,{...o,...r,ref:t})});iC.displayName=sC;var aC="DropdownMenuSubTrigger",Fh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(WS,{...o,...r,ref:t})});Fh.displayName=aC;var lC="DropdownMenuSubContent",zh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return c.jsx(VS,{...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)"}})});zh.displayName=lC;var cC=Ih,uC=Ah,dC=_h,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh,Kh=Lh,qh=$h,Gh=Fh,Yh=zh;const fC=cC,hC=uC,pC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Gh,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));pC.displayName=Gh.displayName;const mC=m.forwardRef(({className:e,...t},n)=>c.jsx(Yh,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));mC.displayName=Yh.displayName;const Xh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(dC,{children:c.jsx(Bh,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Xh.displayName=Bh.displayName;const ol=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Uh,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ol.displayName=Uh.displayName;const gC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Wh,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Kh,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));gC.displayName=Wh.displayName;const xC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Vh,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Kh,{children:c.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));xC.displayName=Vh.displayName;const yC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Hh,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));yC.displayName=Hh.displayName;const vC=m.forwardRef(({className:e,...t},n)=>c.jsx(qh,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));vC.displayName=qh.displayName;function ei({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:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=Ei(),{currentThreadId:x}=Go(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:E,loadOlder:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:_,checkpoints:R,interrupt:j,metadata:z}=Yo(),{isStreaming:L,error:B,submit:M,stop:q}=Uc(),U=g??x??null,te=(_==null?void 0:_.id)??null,$=(_==null?void 0:_.namespace)??null,F=(z==null?void 0:z.assemblingMessageId)??null,ie=j,[O,G]=w.useState(!1);w.useEffect(()=>{ie||G(!1)},[ie]);const ce=w.useCallback(()=>{G(!0)},[]),be=w.useCallback(()=>{G(!1)},[]),ge=!!ie||O,[ye,V]=w.useState(null),[D,X]=w.useState(""),[Z,fe]=w.useState(null),[ae,Q]=w.useState([]),[tt,Ze]=w.useState(0),[Re,ze]=w.useState(0),[nt,rt]=w.useState(!1),[Pe,St]=w.useState(null),[Ct,kt]=w.useState(null),[ut,et]=w.useState(!1),[Be,dt]=w.useState(null),[re,oe]=w.useState(!1),xe=w.useRef(!1),[Me,Le]=w.useState(!1),qe=w.useRef(null),bt=w.useRef(null),ot=w.useCallback(()=>{qe.current&&(qe.current.value=""),bt.current&&(bt.current.value=""),Ze(me=>me+1),ze(me=>me+1)},[]),ht=w.useRef(!1);w.useEffect(()=>{ht.current&&!L&&(Q([]),ot()),ht.current=L},[L,ot]);const[Kt,Qt]=w.useState("desktop");w.useEffect(()=>{const me=()=>{const Ie=window.innerWidth;Qt(Ie<640?"phone":Ie<1024?"tablet":"desktop")};return me(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)},[]),w.useEffect(()=>{oe(!1),xe.current=!1},[U]);const Er=w.useCallback(async()=>{if(!(!b||S||!re))try{await C()}catch(me){console.warn("loadOlder failed",me)}},[b,re,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){dt(null);return}try{const Ie=await v.getAgent("default");dt(Ie.uiDefaultMessage||null)}catch(Ie){console.warn("Failed to fetch default message:",Ie),dt(null)}})()},[v]),w.useEffect(()=>{B&&!ut&&(p==null||p(B))},[B,ut,p]);const Hn=me=>{if(me.length>Ds)return`Message too long (${me.length}/${Ds} characters)`;try{return kw(me),null}catch(Ie){return(Ie==null?void 0:Ie.message)||"Invalid message"}},Ir=async me=>{const Ie=me.trim();if(!(!Ie&&ae.length===0)){if(Ie){const Xe=Hn(Ie);if(Xe){fe(Xe);return}}try{await M({text:Ie||"",attachments:ae,payload:ye?{edit:!0,originalMessageId:ye}:void 0},{checkpointId:te??void 0,checkpointNs:$??void 0}),f==null||f(Ie),fe(null),Q([]),ot(),V(null),X("")}catch(Xe){const k=(Xe==null?void 0:Xe.message)||"Failed to send message";fe(k),p==null||p(k)}}},Pn=w.useCallback((me,Ie)=>{u&&(V(me),X(Ie),fe(null))},[u]),Et=w.useCallback(()=>{V(null),X(""),fe(null)},[]),_o=w.useCallback((me,Ie)=>{Pn(me,Ie)},[Pn]),rr=w.useCallback(me=>{const Ie=Xe=>{const k=Xe.content||[],H=k.filter(se=>se.type==="text").map(se=>se.text).join("");if(H)return H;try{return JSON.stringify(k,null,2)}catch{return String(k)}};for(let Xe=me-1;Xe>=0;Xe--)if(y[Xe].role==="user"){const k=Ie(y[Xe]);k&&M({text:k},{checkpointId:te??void 0,checkpointNs:$??void 0});break}},[y,M,te,$]),It=me=>{const Ie=Array.from(me.target.files||[]);Q(Xe=>[...Xe,...Ie]),me.target.value=""},yn=me=>{Q(Ie=>{const Xe=Ie.filter((k,H)=>me!==H);return Xe.length===0&&ot(),Xe})},On=async me=>{const Ie=(me.target.files||[])[0];if(Ie){St(null),kt(null),rt(!0);try{await M({attachments:[Ie]},{checkpointId:te??void 0,checkpointNs:$??void 0});const Xe=`Uploaded ${Ie.name} - processing through chat stream`;kt(Xe)}catch(Xe){const k=Xe instanceof Error?Xe.message:"Failed to upload Excel file";console.error("Excel upload failed",Xe),St(k),p==null||p(k)}finally{rt(!1),me.target.value="",ot()}}},Kr=me=>{if(!me)return"Unknown";const Ie=Date.parse(me);return Number.isNaN(Ie)?me:new Date(Ie).toLocaleString()},cn=async me=>{if(x){Le(!0);try{if(!me){await I();return}const Ie=R.find(k=>k.checkpointId===me),Xe=(Ie==null?void 0:Ie.checkpointNs)??null;await T(me,Xe)}finally{Le(!1)}}},or=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,vn=`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 ${d.messagesArea||""}`,Mn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:or,children:[!!B&&!ut&&c.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:[c.jsx("span",{children:B}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>et(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ue.X,{size:16})})]}),x&&R.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:te??"",onChange:me=>{const Ie=me.target.value||null;cn(Ie)},children:[c.jsx("option",{value:"",children:"Latest"}),R.map(me=>c.jsxs("option",{value:me.checkpointId,children:[Kr(me.createdAt),me.preview?` — ${me.preview.slice(0,40)}`:""]},me.checkpointId))]})]}),c.jsxs("div",{className:`relative ${vn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Pa,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Kt,enableMessageEditing:u,editingMessageId:ye,onStartReached:()=>{re&&Er()},onScrollAway:me=>{if(!xe.current){xe.current=!0;return}me&&oe(!0)},onEdit:_o,onRegenerate:rr,onCancelEdit:Et,emptyMessage:Be??void 0,isNavigatingCheckpoint:Me,activeInterrupt:ie,disableInterruptActions:O,onInterruptActionStart:ce,onInterruptActionEnd:be}),E&&c.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:[c.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Mn,children:[ye&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ue.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:qe,type:"file",multiple:!0,onChange:me=>It(me),className:"hidden"},tt),ae.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map((me,Ie)=>c.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:[c.jsx(ue.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:me.name}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>yn(Ie),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 ${me.name}`,children:c.jsx(ue.X,{size:12})})]},Ie))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:bt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:On,className:"hidden"},Re),nt&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Ct&&!nt&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Ct}),Pe&&!nt&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Pe})]})]}),Z&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Z}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(fC,{children:[c.jsx(hC,{asChild:!0,children:c.jsx(Ke,{type:"button",size:"icon",variant:"outline",disabled:L||ge,title:"More input actions",className:d.moreButton||"",children:c.jsx(ue.Plus,{size:16})})}),c.jsxs(Xh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(ol,{onClick:()=>{var me;return(me=qe.current)==null?void 0:me.click()},className:"cursor-pointer",children:[c.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(ol,{onClick:()=>{var me;nt||(me=bt.current)==null||me.click()},className:`cursor-pointer ${nt?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx($x,{initialValue:D,editingMessageId:ye,placeholder:ye?"Edit your message...":t,isStreaming:L,disabled:ge,maxLength:Ds,onSend:Ir,onCancelEdit:Et,onStop:q,allowEmptySend:ae.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ye?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Z?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const ti=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ti.displayName="Input";function sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function bC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var il="ScrollArea",[Jh,ck]=kn(il),[wC,an]=Jh(il),Zh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,E]=m.useState(0),[C,T]=m.useState(!1),[I,_]=m.useState(!1),R=We(t,z=>l(z)),j=Ls(o);return c.jsx(wC,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:_,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ee.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Zh.displayName=il;var Qh="ScrollAreaViewport",ep=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(Qh,n),a=m.useRef(null),l=We(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(Ee.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});ep.displayName=Qh;var Rn="ScrollAreaScrollbar",al=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(SC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(CC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(tp,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(ll,{...r,ref:t}):null});al.displayName=Rn;var SC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Xt,{present:n||s,children:c.jsx(tp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),CC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(Rn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=si(()=>l("SCROLL_END"),100),[a,l]=bC("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 m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Xt,{present:n||a!=="hidden",children:c.jsx(ll,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),tp=m.forwardRef((e,t)=>{const n=an(Rn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=si(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Ur(n.viewport,l),Ur(n.content,l),c.jsx(Xt,{present:r||s,children:c.jsx(ll,{"data-state":s?"visible":"hidden",...o,ref:t})})}),ll=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(Rn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=ip(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return AC(h,i.current,a,p)}return n==="horizontal"?c.jsx(TC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ap(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(kC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ap(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),TC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(Rn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"data-orientation":"horizontal",...o,ref:u,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),cp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ri(i.paddingLeft),paddingEnd:ri(i.paddingRight)}})}})}),kC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(Rn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=We(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(rp,{"data-orientation":"vertical",...o,ref:u,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":oi(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),cp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ri(i.paddingTop),paddingEnd:ri(i.paddingBottom)}})}})}),[EC,np]=Jh(Rn),rp=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=an(Rn,n),[v,x]=m.useState(null),g=We(t,R=>x(R)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,E=r.content-r.viewport,C=_t(d),T=_t(l),I=si(f,10);function _(R){if(y.current){const j=R.clientX-y.current.left,z=R.clientY-y.current.top;u({x:j,y:z})}}return m.useEffect(()=>{const R=j=>{const z=j.target;(v==null?void 0:v.contains(z))&&C(j,E)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,E,C]),m.useEffect(T,[r,T]),Ur(v,I),Ur(p.content,I),c.jsx(EC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:_t(s),onThumbPointerUp:_t(i),onThumbPositionChange:T,onThumbPointerDown:_t(a),children:c.jsx(Ee.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:pe(e.onPointerMove,_),onPointerUp:pe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ni="ScrollAreaThumb",op=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=np(ni,e.__scopeScrollArea);return c.jsx(Xt,{present:n||o.hasThumb,children:c.jsx(IC,{ref:t,...r})})}),IC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ni,n),i=np(ni,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=si(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=_C(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ee.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:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});op.displayName=ni;var cl="ScrollAreaCorner",sp=m.forwardRef((e,t)=>{const n=an(cl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(NC,{...e,ref:t}):null});sp.displayName=cl;var NC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(cl,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ee.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 ri(e){return e?parseInt(e,10):0}function ip(e,t){const n=e/t;return isNaN(n)?0:n}function oi(e){const t=ip(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function AC(e,t,n,r="ltr"){const o=oi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return lp([l,u],f)(e)}function ap(e,t,n="ltr"){const r=oi(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],u=sl(e,l);return lp([0,i],[0,a])(u)}function lp(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 cp(e,t){return e>0&&e<t}var _C=(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 si(e,t){const n=_t(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=_t(t);Tt(()=>{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 up=Zh,jC=ep,RC=sp;const dp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(up,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[c.jsx(jC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(fp,{}),c.jsx(RC,{})]}));dp.displayName=up.displayName;const fp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(al,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(op,{className:"relative flex-1 rounded-full bg-border"})}));fp.displayName=al.displayName;function ul({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Go(),{loadThread:x}=Yo(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,E]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,I]=w.useState(null),[_,R]=w.useState(""),[j,z]=w.useState(!1);w.useEffect(()=>{const O=Array.isArray(f)?f:[];if(O.length>0){C.current=!0,E(O);return}p||(C.current=!1,E(O))},[f,p]);const L=async O=>{try{await x(O),a==null||a(O),l==null||l(O)}catch(G){console.error("Failed to select thread:",G)}},B=async()=>{try{z(!0);const O=await g();u==null||u(O),a==null||a(O)}catch(O){console.error("Failed to create thread:",O)}finally{z(!1)}},M=async(O,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await y(O),d==null||d(O)}catch(ce){console.error("Failed to delete thread:",ce)}},q=(O,G)=>{G.stopPropagation(),I(O.threadId),R(O.title||`Thread ${O.threadId.slice(0,8)}`)},U=async O=>{if(_.trim())try{await b(O,_.trim()),I(null),R("")}catch(G){console.error("Failed to update title:",G)}},te=()=>{I(null),R("")},$=(O,G)=>{O.key==="Enter"?U(G):O.key==="Escape"&&te()},F=O=>{if(!O)return"";try{const G=new Date(O),be=new Date().getTime()-G.getTime(),ge=Math.floor(be/(1e3*60*60*24));return ge===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ge===1?"Yesterday":ge<7?`${ge} days ago`:G.toLocaleDateString()}catch{return""}},ie=O=>O.title||`Thread ${O.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ke,{onClick:B,disabled:j||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:j?"Creating...":"New Chat",children:c.jsx(ue.MessageSquarePlus,{size:20})})}),c.jsx(dp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((O,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date(O.updatedAt||O.createdAt||"").getTime()).map(O=>c.jsxs("div",{onClick:()=>L(O.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===O.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===O.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[c.jsx(ti,{value:_,onChange:G=>R(G.target.value),onKeyDown:G=>$(G,O.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:()=>U(O.threadId),className:"h-6 w-6 p-0",children:c.jsx(ue.Check,{size:12})}),c.jsx(Ke,{variant:"ghost",size:"sm",onClick:te,className:"h-6 w-6 p-0",children:c.jsx(ue.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ie(O)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ue.Calendar,{size:10}),c.jsx("span",{children:F(O.updatedAt||O.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==O.threadId&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:G=>q(O,G),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ue.Edit3,{size:12})}),n&&c.jsx(Ke,{variant:"ghost",size:"sm",onClick:G=>M(O.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ue.Trash2,{size:12})})]})]}),i===O.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},O.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function PC(e){if(typeof e!="string")return;const t=e.trim();if(t)return $n(t)}function hp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=PC(t);if(n)return n}}function pp(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function mp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return $n(t);return $n()}function gp(){const e={},t=hp(),n=pp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function xp(){const e=gp(),t=Wn.getAuthToken(),n=hp();return{apiBaseUrl:mp(e.baseUrl,Wn.baseUrl,n),apiKey:t||e.apiKey||pp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const yp="chat-settings";function OC(){try{const e=localStorage.getItem(yp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function MC(e){try{const t={...e,apiBaseUrl:$n(e.apiBaseUrl)};localStorage.setItem(yp,JSON.stringify(t)),t.apiKey&&Wn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function DC(){const e=xp(),t=OC(),n=Wn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:mp(Wn.baseUrl,r,e.apiBaseUrl)}}function LC(e){Wn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),MC(e)}var $C="Label",vp=m.forwardRef((e,t)=>c.jsx(Ee.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())}}));vp.displayName=$C;var bp=vp;const FC=Po.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ln=m.forwardRef(({className:e,...t},n)=>c.jsx(bp,{ref:n,className:ne(FC(),e),...t}));ln.displayName=bp.displayName;function wp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ii="Switch",[zC,uk]=kn(ii),[BC,HC]=zC(ii),Sp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=We(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=mr({prop:o,defaultProp:s??!1,onChange:u,caller:ii});return c.jsxs(BC,{scope:n,checked:y,disabled:a,children:[c.jsx(Ee.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ep(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:pe(e.onClick,S=>{b(E=>!E),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(kp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sp.displayName=ii;var Cp="SwitchThumb",Tp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=HC(Cp,n);return c.jsx(Ee.span,{"data-state":Ep(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tp.displayName=Cp;var UC="SwitchBubbleInput",kp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=We(i,s),l=wp(n),u=Df(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kp.displayName=UC;function Ep(e){return e?"checked":"unchecked"}var Ip=Sp,WC=Tp;const er=m.forwardRef(({className:e,...t},n)=>c.jsx(Ip,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(WC,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));er.displayName=Ip.displayName;var Np=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"}),VC="VisuallyHidden",KC=m.forwardRef((e,t)=>c.jsx(Ee.span,{...e,ref:t,style:{...Np,...e.style}}));KC.displayName=VC;var qC=[" ","Enter","ArrowUp","ArrowDown"],GC=[" ","Enter"],Cr="Select",[ai,li,YC]=Oa(Cr),[Vr,dk]=kn(Cr,[YC,Gs]),ci=Gs(),[XC,tr]=Vr(Cr),[JC,ZC]=Vr(Cr),Ap=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=ci(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[E,C]=m.useState(!1),T=Ls(u),[I,_]=mr({prop:r,defaultProp:o??!1,onChange:s,caller:Cr}),[R,j]=mr({prop:i,defaultProp:a,onChange:l,caller:Cr}),z=m.useRef(null),L=g?v||!!g.closest("form"):!0,[B,M]=m.useState(new Set),q=Array.from(B).map(U=>U.props.value).join(";");return c.jsx(Kf,{...x,children:c.jsxs(XC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:En(),value:R,onValueChange:j,open:I,onOpenChange:_,dir:T,triggerPointerDownPosRef:z,disabled:h,children:[c.jsx(ai.Provider,{scope:t,children:c.jsx(JC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(U=>{M(te=>new Set(te).add(U))},[]),onNativeOptionRemove:m.useCallback(U=>{M(te=>{const $=new Set(te);return $.delete(U),$})},[]),children:n})}),L?c.jsxs(Qp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:U=>j(U.target.value),disabled:h,form:v,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(B)]},q):null]})})};Ap.displayName=Cr;var _p="SelectTrigger",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=tr(_p,n),a=i.disabled||r,l=We(t,i.onTriggerChange),u=li(n),d=m.useRef("touch"),[f,h,p]=tm(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=nm(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(qf,{asChild:!0,...s,children:c.jsx(Ee.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":em(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&qC.includes(x.key)&&(v(),x.preventDefault())})})})});jp.displayName=_p;var Rp="SelectValue",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=tr(Rp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return Tt(()=>{u(d)},[u,d]),c.jsx(Ee.span,{...a,ref:f,style:{pointerEvents:"none"},children:em(l.value)?c.jsx(c.Fragment,{children:i}):s})});Pp.displayName=Rp;var QC="SelectIcon",Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ee.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Op.displayName=QC;var eT="SelectPortal",Mp=e=>c.jsx(bs,{asChild:!0,...e});Mp.displayName=eT;var Tr="SelectContent",Dp=m.forwardRef((e,t)=>{const n=tr(Tr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Oo.createPortal(c.jsx(Lp,{scope:e.__scopeSelect,children:c.jsx(ai.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx($p,{...e,ref:t})});Dp.displayName=Tr;var xn=10,[Lp,nr]=Vr(Tr),tT="SelectContentImpl",nT=ir.createSlot("SelectContent.RemoveScroll"),$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=tr(Tr,n),[S,E]=m.useState(null),[C,T]=m.useState(null),I=We(t,V=>E(V)),[_,R]=m.useState(null),[j,z]=m.useState(null),L=li(n),[B,M]=m.useState(!1),q=m.useRef(!1);m.useEffect(()=>{if(S)return Aa(S)},[S]),Ca();const U=m.useCallback(V=>{const[D,...X]=L().map(ae=>ae.ref.current),[Z]=X.slice(-1),fe=document.activeElement;for(const ae of V)if(ae===fe||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===D&&C&&(C.scrollTop=0),ae===Z&&C&&(C.scrollTop=C.scrollHeight),ae==null||ae.focus(),document.activeElement!==fe))return},[L,C]),te=m.useCallback(()=>U([_,S]),[U,_,S]);m.useEffect(()=>{B&&te()},[B,te]);const{onOpenChange:$,triggerPointerDownPosRef:F}=b;m.useEffect(()=>{if(S){let V={x:0,y:0};const D=Z=>{var fe,ae;V={x:Math.abs(Math.round(Z.pageX)-(((fe=F.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ae=F.current)==null?void 0:ae.y)??0))}},X=Z=>{V.x<=10&&V.y<=10?Z.preventDefault():S.contains(Z.target)||$(!1),document.removeEventListener("pointermove",D),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,$,F]),m.useEffect(()=>{const V=()=>$(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[$]);const[ie,O]=tm(V=>{const D=L().filter(fe=>!fe.disabled),X=D.find(fe=>fe.ref.current===document.activeElement),Z=nm(D,V,X);Z&&setTimeout(()=>Z.ref.current.focus())}),G=m.useCallback((V,D,X)=>{const Z=!q.current&&!X;(b.value!==void 0&&b.value===D||Z)&&(R(V),Z&&(q.current=!0))},[b.value]),ce=m.useCallback(()=>S==null?void 0:S.focus(),[S]),be=m.useCallback((V,D,X)=>{const Z=!q.current&&!X;(b.value!==void 0&&b.value===D||Z)&&z(V)},[b.value]),ge=r==="popper"?dl:Fp,ye=ge===dl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Lp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:G,selectedItem:_,onItemLeave:ce,itemTextRefCallback:be,focusSelectedItem:te,selectedItemText:j,position:r,isPositioned:B,searchRef:ie,children:c.jsx(Es,{as:nT,allowPinchZoom:!0,children:c.jsx(vs,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:pe(o,V=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:c.jsx(ys,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...y,...ye,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:pe(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&O(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Z=L().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const fe=V.target,ae=Z.indexOf(fe);Z=Z.slice(ae+1)}setTimeout(()=>U(Z)),V.preventDefault()}})})})})})})});$p.displayName=tT;var rT="SelectItemAlignedPosition",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=tr(Tr,n),i=nr(Tr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=We(t,I=>d(I)),h=li(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const I=s.trigger.getBoundingClientRect(),_=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=y.getBoundingClientRect();if(s.dir!=="rtl"){const fe=j.left-_.left,ae=R.left-fe,Q=I.left-ae,tt=I.width+Q,Ze=Math.max(tt,_.width),Re=window.innerWidth-xn,ze=sl(ae,[xn,Math.max(xn,Re-Ze)]);a.style.minWidth=tt+"px",a.style.left=ze+"px"}else{const fe=_.right-j.right,ae=window.innerWidth-R.right-fe,Q=window.innerWidth-I.right-ae,tt=I.width+Q,Ze=Math.max(tt,_.width),Re=window.innerWidth-xn,ze=sl(ae,[xn,Math.max(xn,Re-Ze)]);a.style.minWidth=tt+"px",a.style.right=ze+"px"}const z=h(),L=window.innerHeight-xn*2,B=x.scrollHeight,M=window.getComputedStyle(u),q=parseInt(M.borderTopWidth,10),U=parseInt(M.paddingTop,10),te=parseInt(M.borderBottomWidth,10),$=parseInt(M.paddingBottom,10),F=q+U+B+$+te,ie=Math.min(g.offsetHeight*5,F),O=window.getComputedStyle(x),G=parseInt(O.paddingTop,10),ce=parseInt(O.paddingBottom,10),be=I.top+I.height/2-xn,ge=L-be,ye=g.offsetHeight/2,V=g.offsetTop+ye,D=q+U+V,X=F-D;if(D<=be){const fe=z.length>0&&g===z[z.length-1].ref.current;a.style.bottom="0px";const ae=u.clientHeight-x.offsetTop-x.offsetHeight,Q=Math.max(ge,ye+(fe?ce:0)+ae+te),tt=D+Q;a.style.height=tt+"px"}else{const fe=z.length>0&&g===z[0].ref.current;a.style.top="0px";const Q=Math.max(be,q+x.offsetTop+(fe?G:0)+ye)+X;a.style.height=Q+"px",x.scrollTop=D-be+x.offsetTop}a.style.margin=`${xn}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);Tt(()=>S(),[S]);const[E,C]=m.useState();Tt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(sT,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Ee.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fp.displayName=rT;var oT="SelectPopperPosition",dl=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=xn,...s}=e,i=ci(n);return c.jsx(Gf,{...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)"}})});dl.displayName=oT;var[sT,fl]=Vr(Tr,{}),hl="SelectViewport",zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=nr(hl,n),i=fl(hl,n),a=We(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.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}),c.jsx(ai.Slot,{scope:n,children:c.jsx(Ee.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-xn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),E=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});zp.displayName=hl;var Bp="SelectGroup",[iT,aT]=Vr(Bp),lT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=En();return c.jsx(iT,{scope:n,id:o,children:c.jsx(Ee.div,{role:"group","aria-labelledby":o,...r,ref:t})})});lT.displayName=Bp;var Hp="SelectLabel",Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aT(Hp,n);return c.jsx(Ee.div,{id:o.id,...r,ref:t})});Up.displayName=Hp;var ui="SelectItem",[cT,Wp]=Vr(ui),Vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=tr(ui,n),l=nr(ui,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=We(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=En(),g=m.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 c.jsx(cT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ai.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ee.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:pe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:pe(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:pe(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(GC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Vp.displayName=ui;var Ao="SelectItemText",Kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=tr(Ao,n),a=nr(Ao,n),l=Wp(Ao,n),u=ZC(Ao,n),[d,f]=m.useState(null),h=We(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Tt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(Ee.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Oo.createPortal(s.children,i.valueNode):null]})});Kp.displayName=Ao;var qp="SelectItemIndicator",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wp(qp,n).isSelected?c.jsx(Ee.span,{"aria-hidden":!0,...r,ref:t}):null});Gp.displayName=qp;var pl="SelectScrollUpButton",Yp=m.forwardRef((e,t)=>{const n=nr(pl,e.__scopeSelect),r=fl(pl,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Yp.displayName=pl;var ml="SelectScrollDownButton",Xp=m.forwardRef((e,t)=>{const n=nr(ml,e.__scopeSelect),r=fl(ml,e.__scopeSelect),[o,s]=m.useState(!1),i=We(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Jp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Xp.displayName=ml;var Jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=nr("SelectScrollButton",n),i=m.useRef(null),a=li(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(Ee.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),uT="SelectSeparator",Zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ee.div,{"aria-hidden":!0,...r,ref:t})});Zp.displayName=uT;var gl="SelectArrow",dT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ci(n),s=tr(gl,n),i=nr(gl,n);return s.open&&i.position==="popper"?c.jsx(Yf,{...o,...r,ref:t}):null});dT.displayName=gl;var fT="SelectBubbleInput",Qp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=We(r,o),i=wp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(Ee.select,{...n,style:{...Np,...n.style},ref:s,defaultValue:t})});Qp.displayName=fT;function em(e){return e===""||e===void 0}function tm(e){const t=_t(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function nm(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=hT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function hT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pT=Ap,rm=jp,mT=Pp,gT=Op,xT=Mp,om=Dp,yT=zp,sm=Up,im=Vp,vT=Kp,bT=Gp,am=Yp,lm=Xp,cm=Zp;const um=pT,dm=mT,xl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(rm,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(gT,{asChild:!0,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));xl.displayName=rm.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(am,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));fm.displayName=am.displayName;const hm=m.forwardRef(({className:e,...t},n)=>c.jsx(lm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));hm.displayName=lm.displayName;const yl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(xT,{children:c.jsxs(om,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(fm,{}),c.jsx(yT,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(hm,{})]})}));yl.displayName=om.displayName;const wT=m.forwardRef(({className:e,...t},n)=>c.jsx(sm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));wT.displayName=sm.displayName;const kr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(im,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(bT,{children:c.jsx(ue.Check,{className:"h-4 w-4"})})}),c.jsx(vT,{children:t})]}));kr.displayName=im.displayName;const ST=m.forwardRef(({className:e,...t},n)=>c.jsx(cm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));ST.displayName=cm.displayName;var CT="Separator",pm="horizontal",TT=["horizontal","vertical"],mm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=pm,...o}=e,s=kT(r)?r:pm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ee.div,{"data-orientation":s,...a,...o,ref:t})});mm.displayName=CT;function kT(e){return TT.includes(e)}var gm=mm;const xm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(gm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));xm.displayName=gm.displayName;const ET=Qd,IT=iw,NT=ef,ym=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));ym.displayName=js.displayName;const AT=Po.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"}}),vm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(NT,{children:[c.jsx(ym,{}),c.jsxs(Rs,{ref:o,className:ne(AT({side:e}),t),...r,children:[n,c.jsxs(tf,{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:[c.jsx(ue.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vm.displayName=Rs.displayName;const bm=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});bm.displayName="SheetHeader";const wm=m.forwardRef(({className:e,...t},n)=>c.jsx(yr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));wm.displayName=yr.displayName;const Sm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ps,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Sm.displayName=Ps.displayName;const _T={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function jT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=ya();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(_T),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(ET,{open:r,onOpenChange:o,children:[c.jsx(IT,{asChild:!0,children:c.jsxs(Ke,{variant:"outline",size:"sm",className:n,children:[c.jsx(ue.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(la,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(vm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(bm,{children:[c.jsx(wm,{children:"Chat Settings"}),c.jsx(Sm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ti,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ke,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(er,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ti,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ke,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ue.EyeOff,{className:"h-4 w-4"}):c.jsx(ue.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(um,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(xl,{children:c.jsx(dm,{})}),c.jsxs(yl,{children:[c.jsx(kr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(kr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(kr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(ln,{htmlFor:"theme",children:"Theme"}),c.jsxs(um,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(xl,{children:c.jsx(dm,{})}),c.jsxs(yl,{children:[c.jsx(kr,{value:"light",children:"Light"}),c.jsx(kr,{value:"dark",children:"Dark"}),c.jsx(kr,{value:"system",children:"System"})]})]})]}),c.jsx(xm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(er,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(er,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(ln,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(er,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(po,{children:[c.jsx(mo,{className:"pb-3",children:c.jsxs(go,{className:"text-lg flex items-center gap-2",children:[c.jsx(ue.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(xo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(er,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(er,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(ln,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(er,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ke,{variant:"outline",onClick:p,children:[c.jsx(ue.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ke,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Ke,{onClick:h,disabled:!u,children:[c.jsx(ue.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function RT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){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=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ei,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ul,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ei,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Xo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ul,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(ei,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=yc,Ne.ChatInterface=ei,Ne.ChatProviders=Xo,Ne.ChatSettings=jT,Ne.MarkdownContent=ma,Ne.MessageComponent=df,Ne.MessageList=Pa,Ne.ThreadManager=ul,Ne.applySettings=LC,Ne.chatApiClient=Wn,Ne.default=RT,Ne.del=xc,Ne.get=dn,Ne.getChatToken=hc,Ne.getCurrentSettings=DC,Ne.getDefaultApiConfig=gp,Ne.getDefaultChatSettings=xp,Ne.onChatTokenChanged=pc,Ne.post=mc,Ne.put=gc,Ne.setChatToken=ki,Ne.useApi=Ei,Ne.useChatStream=Mc,Ne.useMessagesReducer=Ec,Ne.useStream=Uc,Ne.useThreadState=Yo,Ne.useThreads=Go,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|