teodor-new-chat-ui 4.3.231 → 4.3.232
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 +993 -956
- package/dist/index.umd.js +33 -33
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Te,b){typeof exports=="object"&&typeof module<"u"?b(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"],b):(Te=typeof globalThis<"u"?globalThis:Te||self,b(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,b,se,Yn,xo,
|
|
1
|
+
(function(Te,b){typeof exports=="object"&&typeof module<"u"?b(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"],b):(Te=typeof globalThis<"u"?globalThis:Te||self,b(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,b,se,Yn,xo,Gp,Yp,Js){"use strict";var KC=Object.defineProperty;var qC=(Te,b,se)=>b in Te?KC(Te,b,{enumerable:!0,configurable:!0,writable:!0,value:se}):Te[b]=se;var Kp=(Te,b,se)=>qC(Te,typeof b!="symbol"?b+"":b,se);function Qa(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 v=Qa(b),yo=Qa(Js);var Zs={exports:{}},Rr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var el;function
|
|
9
|
+
*/var el;function Xp(){if(el)return Rr;el=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,f={},h=null,p=null;c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Rr.Fragment=n,Rr.jsx=i,Rr.jsxs=i,Rr}var Pr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -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 tl;function
|
|
18
|
-
`+
|
|
17
|
+
*/var tl;function Jp(){return tl||(tl=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),m=Symbol.iterator,x="@@iterator";function y(I){if(I===null||typeof I!="object")return null;var q=m&&I[m]||I[x];return typeof q=="function"?q:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var q=arguments.length,ae=new Array(q>1?q-1:0),we=1;we<q;we++)ae[we-1]=arguments[we];S("error",I,ae)}}function S(I,q,ae){{var we=g.ReactDebugCurrentFrame,Je=we.getStackAddendum();Je!==""&&(q+="%s",ae=ae.concat([Je]));var it=ae.map(function(Ue){return String(Ue)});it.unshift("Warning: "+q),Function.prototype.apply.call(console[I],console,it)}}var k=!1,T=!1,C=!1,E=!1,j=!1,N;N=Symbol.for("react.module.reference");function A(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||j||I===o||I===c||I===d||E||I===p||k||T||C||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===N||I.getModuleId!==void 0))}function M(I,q,ae){var we=I.displayName;if(we)return we;var Je=q.displayName||q.name||"";return Je!==""?ae+"("+Je+")":ae}function F(I){return I.displayName||"Context"}function $(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var q=I;return F(q)+".Consumer";case i:var ae=I;return F(ae._context)+".Provider";case l:return M(I,I.render,"ForwardRef");case f:var we=I.displayName||null;return we!==null?we:$(I.type)||"Memo";case h:{var Je=I,it=Je._payload,Ue=Je._init;try{return $(Ue(it))}catch{return null}}}return null}var R=Object.assign,z=0,_,B,L,D,Z,J,pe;function Ee(){}Ee.__reactDisabledLog=!0;function Ne(){{if(z===0){_=console.log,B=console.info,L=console.warn,D=console.error,Z=console.group,J=console.groupCollapsed,pe=console.groupEnd;var I={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}z++}}function V(){{if(z--,z===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},I,{value:_}),info:R({},I,{value:B}),warn:R({},I,{value:L}),error:R({},I,{value:D}),group:R({},I,{value:Z}),groupCollapsed:R({},I,{value:J}),groupEnd:R({},I,{value:pe})})}z<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=g.ReactCurrentDispatcher,U;function O(I,q,ae){{if(U===void 0)try{throw Error()}catch(Je){var we=Je.stack.trim().match(/\n( *(at )?)/);U=we&&we[1]||""}return`
|
|
18
|
+
`+U+I}}var H=!1,te;{var ie=typeof WeakMap=="function"?WeakMap:Map;te=new ie}function ne(I,q){if(!I||H)return"";{var ae=te.get(I);if(ae!==void 0)return ae}var we;H=!0;var Je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var it;it=ee.current,ee.current=null,Ne();try{if(q){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch($t){we=$t}Reflect.construct(I,[],Ue)}else{try{Ue.call()}catch($t){we=$t}I.call(Ue.prototype)}}else{try{throw Error()}catch($t){we=$t}I()}}catch($t){if($t&&we&&typeof $t.stack=="string"){for(var ze=$t.stack.split(`
|
|
19
19
|
`),Pt=we.stack.split(`
|
|
20
|
-
`),vt
|
|
21
|
-
|
|
20
|
+
`),vt=ze.length-1,yt=Pt.length-1;vt>=1&&yt>=0&&ze[vt]!==Pt[yt];)yt--;for(;vt>=1&&yt>=0;vt--,yt--)if(ze[vt]!==Pt[yt]){if(vt!==1||yt!==1)do if(vt--,yt--,yt<0||ze[vt]!==Pt[yt]){var qt=`
|
|
21
|
+
`+ze[vt].replace(" at new "," at ");return I.displayName&&qt.includes("<anonymous>")&&(qt=qt.replace("<anonymous>",I.displayName)),typeof I=="function"&&te.set(I,qt),qt}while(vt>=1&&yt>=0);break}}}finally{H=!1,ee.current=it,V(),Error.prepareStackTrace=Je}var Gn=I?I.displayName||I.name:"",Rn=Gn?O(Gn):"";return typeof I=="function"&&te.set(I,Rn),Rn}function Fe(I,q,ae){return ne(I,!1)}function Y(I){var q=I.prototype;return!!(q&&q.isReactComponent)}function fe(I,q,ae){if(I==null)return"";if(typeof I=="function")return ne(I,Y(I));if(typeof I=="string")return O(I);switch(I){case c:return O("Suspense");case d:return O("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Fe(I.render);case f:return fe(I.type,q,ae);case h:{var we=I,Je=we._payload,it=we._init;try{return fe(it(Je),q,ae)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,je={},Be=g.ReactDebugCurrentFrame;function He(I){if(I){var q=I._owner,ae=fe(I.type,I._source,q?q.type:null);Be.setExtraStackFrame(ae)}else Be.setExtraStackFrame(null)}function Ke(I,q,ae,we,Je){{var it=Function.call.bind(ke);for(var Ue in I)if(it(I,Ue)){var ze=void 0;try{if(typeof I[Ue]!="function"){var Pt=Error((we||"React class")+": "+ae+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pt.name="Invariant Violation",Pt}ze=I[Ue](q,Ue,we,ae,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(vt){ze=vt}ze&&!(ze instanceof Error)&&(He(Je),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",we||"React class",ae,Ue,typeof ze),He(null)),ze instanceof Error&&!(ze.message in je)&&(je[ze.message]=!0,He(Je),w("Failed %s type: %s",ae,ze.message),He(null))}}}var qe=Array.isArray;function Ge(I){return qe(I)}function tt(I){{var q=typeof Symbol=="function"&&Symbol.toStringTag,ae=q&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ae}}function Qe(I){try{return st(I),!1}catch{return!0}}function st(I){return""+I}function St(I){if(Qe(I))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tt(I)),st(I)}var mt=g.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0},Ct,de;function re(I){if(ke.call(I,"ref")){var q=Object.getOwnPropertyDescriptor(I,"ref").get;if(q&&q.isReactWarning)return!1}return I.ref!==void 0}function Ye(I){if(ke.call(I,"key")){var q=Object.getOwnPropertyDescriptor(I,"key").get;if(q&&q.isReactWarning)return!1}return I.key!==void 0}function De(I,q){typeof I.ref=="string"&&mt.current}function Xe(I,q){{var ae=function(){Ct||(Ct=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ae.isReactWarning=!0,Object.defineProperty(I,"key",{get:ae,configurable:!0})}}function Re(I,q){{var ae=function(){de||(de=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ae.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ae,configurable:!0})}}var $e=function(I,q,ae,we,Je,it,Ue){var ze={$$typeof:t,type:I,key:q,ref:ae,props:Ue,_owner:it};return ze._store={},Object.defineProperty(ze._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ze,"_self",{configurable:!1,enumerable:!1,writable:!1,value:we}),Object.defineProperty(ze,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Je}),Object.freeze&&(Object.freeze(ze.props),Object.freeze(ze)),ze};function Me(I,q,ae,we,Je){{var it,Ue={},ze=null,Pt=null;ae!==void 0&&(St(ae),ze=""+ae),Ye(q)&&(St(q.key),ze=""+q.key),re(q)&&(Pt=q.ref,De(q,Je));for(it in q)ke.call(q,it)&&!at.hasOwnProperty(it)&&(Ue[it]=q[it]);if(I&&I.defaultProps){var vt=I.defaultProps;for(it in vt)Ue[it]===void 0&&(Ue[it]=vt[it])}if(ze||Pt){var yt=typeof I=="function"?I.displayName||I.name||"Unknown":I;ze&&Xe(Ue,yt),Pt&&Re(Ue,yt)}return $e(I,ze,Pt,Je,we,mt.current,Ue)}}var jt=g.ReactCurrentOwner,At=g.ReactDebugCurrentFrame;function K(I){if(I){var q=I._owner,ae=fe(I.type,I._source,q?q.type:null);At.setExtraStackFrame(ae)}else At.setExtraStackFrame(null)}var ve;ve=!1;function xe(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ft(){{if(jt.current){var I=$(jt.current.type);if(I)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+I+"`."}return""}}function gt(I){return""}var Tt={};function Pe(I){{var
|
|
23
|
+
Check the render method of \``+I+"`."}return""}}function gt(I){return""}var Tt={};function Pe(I){{var q=ft();if(!q){var ae=typeof I=="string"?I:I.displayName||I.name;ae&&(q=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ae+">.")}return
|
|
25
|
+
Check the top-level render call using <`+ae+">.")}return q}}function Kt(I,q){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ae=Pe(q);if(Tt[ae])return;Tt[ae]=!0;var we="";I&&I._owner&&I._owner!==jt.current&&(we=" It was passed a child from "+$(I._owner.type)+"."),K(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ae,we),K(null)}}function lt(I,q){{if(typeof I!="object")return;if(Ge(I))for(var ae=0;ae<I.length;ae++){var we=I[ae];xe(we)&&Kt(we,q)}else if(xe(I))I._store&&(I._store.validated=!0);else if(I){var Je=y(I);if(typeof Je=="function"&&Je!==I.entries)for(var it=Je.call(I),Ue;!(Ue=it.next()).done;)xe(Ue.value)&&Kt(Ue.value,q)}}}function kt(I){{var q=I.type;if(q==null||typeof q=="string")return;var ae;if(typeof q=="function")ae=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===l||q.$$typeof===f))ae=q.propTypes;else return;if(ae){var we=$(q);Ke(ae,I.props,"prop",we,I)}else if(q.PropTypes!==void 0&&!ve){ve=!0;var Je=$(q);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Je||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Kn(I){{for(var q=Object.keys(I.props),ae=0;ae<q.length;ae++){var we=q[ae];if(we!=="children"&&we!=="key"){K(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",we),K(null);break}}I.ref!==null&&(K(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}var fr={};function qn(I,q,ae,we,Je,it){{var Ue=A(I);if(!Ue){var ze="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(ze+=" 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 Pt=gt();Pt?ze+=Pt:ze+=ft();var vt;I===null?vt="null":Ge(I)?vt="array":I!==void 0&&I.$$typeof===t?(vt="<"+($(I.type)||"Unknown")+" />",ze=" Did you accidentally export a JSX literal instead of a component?"):vt=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",vt,ze)}var yt=Me(I,q,ae,Je,it);if(yt==null)return yt;if(Ue){var qt=q.children;if(qt!==void 0)if(we)if(Ge(qt)){for(var Gn=0;Gn<qt.length;Gn++)lt(qt[Gn],I);Object.freeze&&Object.freeze(qt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else lt(qt,I)}if(ke.call(q,"key")){var Rn=$(I),$t=Object.keys(q).filter(function(oe){return oe!=="key"}),go=$t.length>0?"{key: someKey, "+$t.join(": ..., ")+": ...}":"{key: someKey}";if(!fr[Rn+go]){var G=$t.length>0?"{"+$t.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,go,Rn,G,Rn),fr[Rn+go]=!0}}return I===r?Kn(yt):kt(yt),yt}}function Ya(I,K,ae){return qn(I,K,ae,!0)}function Xs(I,K,ae){return qn(I,K,ae,!1)}var Xa=Xs,Ja=Ya;Pr.Fragment=r,Pr.jsx=Xa,Pr.jsxs=Ja}()),Pr}process.env.NODE_ENV==="production"?Zs.exports=Xh():Zs.exports=Jh();var u=Zs.exports;function nl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Zh}=Object.prototype,{getPrototypeOf:Qs}=Object,{iterator:vo,toStringTag:rl}=Symbol,wo=(e=>t=>{const n=Zh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>wo(t)===e),bo=e=>t=>typeof t===e,{isArray:hr}=Array,mr=bo("undefined");function Or(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ol=cn("ArrayBuffer");function Qh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ol(e.buffer),t}const em=bo("string"),Ht=bo("function"),sl=bo("number"),Mr=e=>e!==null&&typeof e=="object",tm=e=>e===!0||e===!1,So=e=>{if(wo(e)!=="object")return!1;const t=Qs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(rl in e)&&!(vo in e)},nm=e=>{if(!Mr(e)||Or(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rm=cn("Date"),om=cn("File"),sm=cn("Blob"),im=cn("FileList"),am=e=>Mr(e)&&Ht(e.pipe),lm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=wo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},cm=cn("URLSearchParams"),[um,dm,fm,pm]=["ReadableStream","Request","Response","Headers"].map(cn),hm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Dr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Or(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 il(e,t){if(Or(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,al=e=>!mr(e)&&e!==Xn;function ei(){const{caseless:e,skipUndefined:t}=al(this)&&this||{},n={},r=(o,s)=>{const i=e&&il(n,s)||s;So(n[i])&&So(o)?n[i]=ei(n[i],o):So(o)?n[i]=ei({},o):hr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Dr(arguments[o],r);return n}const mm=(e,t,n,{allOwnKeys:r}={})=>(Dr(t,(o,s)=>{n&&Ht(o)?e[s]=nl(o,n):e[s]=o},{allOwnKeys:r}),e),gm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),xm=(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&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vm=(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},wm=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!sl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},bm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Qs(Uint8Array)),Sm=(e,t)=>{const r=(e&&e[vo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Cm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Tm=cn("HTMLFormElement"),km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ll=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Em=cn("RegExp"),cl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Dr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Im=e=>{cl(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Nm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},Am=()=>{},jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _m(e){return!!(e&&Ht(e.append)&&e[rl]==="FormData"&&e[vo])}const Rm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(Or(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return Dr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Pm=cn("AsyncFunction"),Om=e=>e&&(Mr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),ul=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||ul,P={isArray:hr,isArrayBuffer:ol,isBuffer:Or,isFormData:lm,isArrayBufferView:Qh,isString:em,isNumber:sl,isBoolean:tm,isObject:Mr,isPlainObject:So,isEmptyObject:nm,isReadableStream:um,isRequest:dm,isResponse:fm,isHeaders:pm,isUndefined:mr,isDate:rm,isFile:om,isBlob:sm,isRegExp:Em,isFunction:Ht,isStream:am,isURLSearchParams:cm,isTypedArray:bm,isFileList:im,forEach:Dr,merge:ei,extend:mm,trim:hm,stripBOM:gm,inherits:xm,toFlatObject:ym,kindOf:wo,kindOfTest:cn,endsWith:vm,toArray:wm,forEachEntry:Sm,matchAll:Cm,isHTMLForm:Tm,hasOwnProperty:ll,hasOwnProp:ll,reduceDescriptors:cl,freezeMethods:Im,toObjectSet:Nm,toCamelCase:km,noop:Am,toFiniteNumber:jm,findKey:il,global:Xn,isContextDefined:al,isSpecCompliantForm:_m,toJSONObject:Rm,isAsyncFn:Pm,isThenable:Om,setImmediate:ul,asap:Mm,isIterable:e=>e!=null&&Ht(e[vo])};function _e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(_e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const dl=_e.prototype,fl={};["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=>{fl[e]={value:e}}),Object.defineProperties(_e,fl),Object.defineProperty(dl,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(dl);P.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return _e.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Dm=null;function ti(e){return P.isPlainObject(e)||P.isArray(e)}function pl(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function hl(e,t,n){return e?e.concat(t).map(function(o,s){return o=pl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Lm(e){return P.isArray(e)&&!e.some(ti)}const Fm=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(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,y){return!P.isUndefined(y[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 c(m){if(m===null)return"";if(P.isDate(m))return m.toISOString();if(P.isBoolean(m))return m.toString();if(!l&&P.isBlob(m))throw new _e("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(m)||P.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function d(m,x,y){let g=m;if(m&&!y&&typeof m=="object"){if(P.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(P.isArray(m)&&Lm(m)||(P.isFileList(m)||P.endsWith(x,"[]"))&&(g=P.toArray(m)))return x=pl(x),g.forEach(function(S,k){!(P.isUndefined(S)||S===null)&&t.append(i===!0?hl([x],k,s):i===null?x:x+"[]",c(S))}),!1}return ti(m)?!0:(t.append(hl(y,x,s),c(m)),!1)}const f=[],p=Object.assign(Fm,{defaultVisitor:d,convertValue:c,isVisitable:ti});function h(m,x){if(!P.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(m),P.forEach(m,function(g,w){(!(P.isUndefined(g)||g===null)&&o.call(t,g,P.isString(w)?w.trim():w,x,p))===!0&&h(g,x?x.concat(w):[w])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return h(e),t}function ml(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ni(e,t){this._pairs=[],e&&Co(e,this,t)}const gl=ni.prototype;gl.append=function(t,n){this._pairs.push([t,n])},gl.toString=function(t){const n=t?function(r){return t.call(this,r,ml)}:ml;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function $m(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xl(e,t,n){if(!t)return e;const r=n&&n.encode||$m;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 ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class yl{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 vl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ri=typeof window<"u"&&typeof document<"u",oi=typeof navigator=="object"&&navigator||void 0,Bm=ri&&(!oi||["ReactNative","NativeScript","NS"].indexOf(oi.product)<0),Hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Um=ri&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ri,hasStandardBrowserEnv:Bm,hasStandardBrowserWebWorkerEnv:Hm,navigator:oi,origin:Um},Symbol.toStringTag,{value:"Module"})),...zm};function Wm(e,t){return Co(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 Vm(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Km(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]=Km(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(Vm(r),o,n,0)}),n}return null}function qm(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 Lr={transitional:vl,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 Wm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Co(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),qm(t)):t}],transformResponse:[function(t){const n=this.transitional||Lr.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"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData: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=>{Lr.headers[e]={}});const Gm=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"]),Ym=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,go,Rn,G,Rn),fr[Rn+go]=!0}}return I===r?Kn(yt):kt(yt),yt}}function Ya(I,q,ae){return qn(I,q,ae,!0)}function Xs(I,q,ae){return qn(I,q,ae,!1)}var Xa=Xs,Ja=Ya;Pr.Fragment=r,Pr.jsx=Xa,Pr.jsxs=Ja}()),Pr}process.env.NODE_ENV==="production"?Zs.exports=Xp():Zs.exports=Jp();var u=Zs.exports;function nl(e,t){return function(){return e.apply(t,arguments)}}const{toString:Zp}=Object.prototype,{getPrototypeOf:Qs}=Object,{iterator:vo,toStringTag:rl}=Symbol,wo=(e=>t=>{const n=Zp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>wo(t)===e),bo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=bo("undefined");function Or(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ol=cn("ArrayBuffer");function Qp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ol(e.buffer),t}const em=bo("string"),Ht=bo("function"),sl=bo("number"),Mr=e=>e!==null&&typeof e=="object",tm=e=>e===!0||e===!1,So=e=>{if(wo(e)!=="object")return!1;const t=Qs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(rl in e)&&!(vo in e)},nm=e=>{if(!Mr(e)||Or(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rm=cn("Date"),om=cn("File"),sm=cn("Blob"),im=cn("FileList"),am=e=>Mr(e)&&Ht(e.pipe),lm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=wo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},cm=cn("URLSearchParams"),[um,dm,fm,hm]=["ReadableStream","Request","Response","Headers"].map(cn),pm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Dr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Or(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 il(e,t){if(Or(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,al=e=>!mr(e)&&e!==Xn;function ei(){const{caseless:e,skipUndefined:t}=al(this)&&this||{},n={},r=(o,s)=>{const i=e&&il(n,s)||s;So(n[i])&&So(o)?n[i]=ei(n[i],o):So(o)?n[i]=ei({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Dr(arguments[o],r);return n}const mm=(e,t,n,{allOwnKeys:r}={})=>(Dr(t,(o,s)=>{n&&Ht(o)?e[s]=nl(o,n):e[s]=o},{allOwnKeys:r}),e),gm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),xm=(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&&Qs(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},vm=(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},wm=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!sl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},bm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Qs(Uint8Array)),Sm=(e,t)=>{const r=(e&&e[vo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Cm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Tm=cn("HTMLFormElement"),km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ll=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Em=cn("RegExp"),cl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Dr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Im=e=>{cl(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Nm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Am=()=>{},jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _m(e){return!!(e&&Ht(e.append)&&e[rl]==="FormData"&&e[vo])}const Rm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(Or(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Dr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Pm=cn("AsyncFunction"),Om=e=>e&&(Mr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),ul=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||ul,P={isArray:pr,isArrayBuffer:ol,isBuffer:Or,isFormData:lm,isArrayBufferView:Qp,isString:em,isNumber:sl,isBoolean:tm,isObject:Mr,isPlainObject:So,isEmptyObject:nm,isReadableStream:um,isRequest:dm,isResponse:fm,isHeaders:hm,isUndefined:mr,isDate:rm,isFile:om,isBlob:sm,isRegExp:Em,isFunction:Ht,isStream:am,isURLSearchParams:cm,isTypedArray:bm,isFileList:im,forEach:Dr,merge:ei,extend:mm,trim:pm,stripBOM:gm,inherits:xm,toFlatObject:ym,kindOf:wo,kindOfTest:cn,endsWith:vm,toArray:wm,forEachEntry:Sm,matchAll:Cm,isHTMLForm:Tm,hasOwnProperty:ll,hasOwnProp:ll,reduceDescriptors:cl,freezeMethods:Im,toObjectSet:Nm,toCamelCase:km,noop:Am,toFiniteNumber:jm,findKey:il,global:Xn,isContextDefined:al,isSpecCompliantForm:_m,toJSONObject:Rm,isAsyncFn:Pm,isThenable:Om,setImmediate:ul,asap:Mm,isIterable:e=>e!=null&&Ht(e[vo])};function _e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(_e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const dl=_e.prototype,fl={};["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=>{fl[e]={value:e}}),Object.defineProperties(_e,fl),Object.defineProperty(dl,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(dl);P.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return _e.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Dm=null;function ti(e){return P.isPlainObject(e)||P.isArray(e)}function hl(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function pl(e,t,n){return e?e.concat(t).map(function(o,s){return o=hl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Lm(e){return P.isArray(e)&&!e.some(ti)}const Fm=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(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,y){return!P.isUndefined(y[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 c(m){if(m===null)return"";if(P.isDate(m))return m.toISOString();if(P.isBoolean(m))return m.toString();if(!l&&P.isBlob(m))throw new _e("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(m)||P.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function d(m,x,y){let g=m;if(m&&!y&&typeof m=="object"){if(P.endsWith(x,"{}"))x=r?x:x.slice(0,-2),m=JSON.stringify(m);else if(P.isArray(m)&&Lm(m)||(P.isFileList(m)||P.endsWith(x,"[]"))&&(g=P.toArray(m)))return x=hl(x),g.forEach(function(S,k){!(P.isUndefined(S)||S===null)&&t.append(i===!0?pl([x],k,s):i===null?x:x+"[]",c(S))}),!1}return ti(m)?!0:(t.append(pl(y,x,s),c(m)),!1)}const f=[],h=Object.assign(Fm,{defaultVisitor:d,convertValue:c,isVisitable:ti});function p(m,x){if(!P.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(m),P.forEach(m,function(g,w){(!(P.isUndefined(g)||g===null)&&o.call(t,g,P.isString(w)?w.trim():w,x,h))===!0&&p(g,x?x.concat(w):[w])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return p(e),t}function ml(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ni(e,t){this._pairs=[],e&&Co(e,this,t)}const gl=ni.prototype;gl.append=function(t,n){this._pairs.push([t,n])},gl.toString=function(t){const n=t?function(r){return t.call(this,r,ml)}:ml;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function $m(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function xl(e,t,n){if(!t)return e;const r=n&&n.encode||$m;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 ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class yl{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 vl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ri=typeof window<"u"&&typeof document<"u",oi=typeof navigator=="object"&&navigator||void 0,Bm=ri&&(!oi||["ReactNative","NativeScript","NS"].indexOf(oi.product)<0),Hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Um=ri&&window.location.href||"http://localhost",Mt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ri,hasStandardBrowserEnv:Bm,hasStandardBrowserWebWorkerEnv:Hm,navigator:oi,origin:Um},Symbol.toStringTag,{value:"Module"})),...zm};function Wm(e,t){return Co(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 Vm(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Km(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]=Km(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(Vm(r),o,n,0)}),n}return null}function qm(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 Lr={transitional:vl,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 Wm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Co(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),qm(t)):t}],transformResponse:[function(t){const n=this.transitional||Lr.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"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData: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=>{Lr.headers[e]={}});const Gm=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"]),Ym=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]&&Gm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},bl=Symbol("internals");function Fr(e){return e&&String(e).trim().toLowerCase()}function To(e){return e===!1||e==null?e:P.isArray(e)?e.map(To):String(e)}function Xm(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 Jm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function si(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 Zm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Qm(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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Fr(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||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=To(a))}const i=(a,l)=>P.forEach(a,(c,d)=>s(c,d,l));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!Jm(t))i(Ym(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},l,c;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?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=Fr(t),t){const r=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Xm(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=Fr(t),t){const r=P.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||si(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Fr(i),i){const a=P.findKey(r,i);a&&(!n||si(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||si(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]=To(o),delete n[s];return}const a=t?Zm(s):String(s).trim();a!==s&&delete n[s],n[a]=To(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[bl]=this[bl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Fr(i);r[a]||(Qm(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(Ut);function ii(e,t){const n=this||Lr,r=t||n,o=Ut.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 Sl(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(gr,_e,{__CANCEL__:!0});function Cl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function eg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function tg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,p=0;for(;f!==o;)p+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const h=d&&c-d;return h?Math.round(p*1e3/h):void 0}}function ng(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ko=(e,t,n=3)=>{let r=0;const o=tg(50,250);return ng(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Tl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kl=e=>(...t)=>P.asap(()=>e(...t)),rg=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,og=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 sg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function El(e,t,n){let r=!sg(t);return e&&(r||n==!1)?ig(e,t):t}const Il=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,p){return P.isPlainObject(c)&&P.isPlainObject(d)?P.merge.call({caseless:p},c,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(c,d,f,p){if(P.isUndefined(d)){if(!P.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}function s(c,d){if(!P.isUndefined(d))return r(void 0,d)}function i(c,d){if(P.isUndefined(d)){if(!P.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(Il(c),Il(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,p=f(e[d],t[d],d);P.isUndefined(p)&&f!==a||(n[d]=p)}),n}const Nl=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=xl(El(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(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&rg(t.url))){const l=o&&s&&og.read(s);l&&i.set(o,l)}return t},ag=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Nl(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,p,h,m;function x(){h&&h(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function g(){if(!y)return;const S=Ut.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:S,config:e,request:y};Cl(function(E){n(E),x()},function(E){r(E),x()},T),y=null}"onloadend"in y?y.onloadend=g:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(g)},y.onabort=function(){y&&(r(new _e("Request aborted",_e.ECONNABORTED,e,y)),y=null)},y.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new _e(T,_e.ERR_NETWORK,e,y);C.event=k||null,r(C),y=null},y.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||vl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new _e(k,T.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&P.forEach(i.toJSON(),function(k,T){y.setRequestHeader(T,k)}),P.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([p,m]=ko(c,!0),y.addEventListener("progress",p)),l&&y.upload&&([f,h]=ko(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{y&&(r(!S||S.type?new gr(null,e,y):S),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=eg(o.url);if(w&&Mt.protocols.indexOf(w)===-1){r(new _e("Unsupported protocol "+w+":",_e.ERR_BAD_REQUEST,e));return}y.send(s||null)})},lg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof _e?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>P.asap(a),l}},cg=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},ug=async function*(e,t){for await(const n of dg(e))yield*cg(n,t)},dg=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()}},Al=(e,t,n,r)=>{const o=ug(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let p=s+=f;n(p)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},jl=64*1024,{isFunction:Eo}=P,fg=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:_l,TextEncoder:Rl}=P.global,Pl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},pg=e=>{e=P.merge.call({skipUndefined:!0},fg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Eo(t):typeof fetch=="function",s=Eo(n),i=Eo(r);if(!o)return!1;const a=o&&Eo(_l),l=o&&(typeof Rl=="function"?(m=>x=>m.encode(x))(new Rl):async m=>new Uint8Array(await new n(m).arrayBuffer())),c=s&&a&&Pl(()=>{let m=!1;const x=new n(Mt.origin,{body:new _l,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!x}),d=i&&a&&Pl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(x,y)=>{let g=x&&x[m];if(g)return g.call(x);throw new _e(`Response type '${m}' is not supported`,_e.ERR_NOT_SUPPORT,y)})});const p=async m=>{if(m==null)return 0;if(P.isBlob(m))return m.size;if(P.isSpecCompliantForm(m))return(await new n(Mt.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(P.isArrayBufferView(m)||P.isArrayBuffer(m))return m.byteLength;if(P.isURLSearchParams(m)&&(m=m+""),P.isString(m))return(await l(m)).byteLength},h=async(m,x)=>{const y=P.toFiniteNumber(m.getContentLength());return y??p(x)};return async m=>{let{url:x,method:y,data:g,signal:w,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:j,withCredentials:N="same-origin",fetchOptions:A}=Nl(m),M=t||fetch;E=E?(E+"").toLowerCase():"text";let F=lg([w,S&&S.toAbortSignal()],k),$=null;const R=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let z;try{if(C&&c&&y!=="get"&&y!=="head"&&(z=await h(j,g))!==0){let J=new n(x,{method:"POST",body:g,duplex:"half"}),he;if(P.isFormData(g)&&(he=J.headers.get("content-type"))&&j.setContentType(he),J.body){const[Ee,Ne]=Tl(z,ko(kl(C)));g=Al(J.body,jl,Ee,Ne)}}P.isString(N)||(N=N?"include":"omit");const _=s&&"credentials"in n.prototype,B={...A,signal:F,method:y.toUpperCase(),headers:j.normalize().toJSON(),body:g,duplex:"half",credentials:_?N:void 0};$=s&&new n(x,B);let L=await(s?M($,A):M(x,B));const D=d&&(E==="stream"||E==="response");if(d&&(T||D&&R)){const J={};["status","statusText","headers"].forEach(W=>{J[W]=L[W]});const he=P.toFiniteNumber(L.headers.get("content-length")),[Ee,Ne]=T&&Tl(he,ko(kl(T),!0))||[];L=new r(Al(L.body,jl,Ee,()=>{Ne&&Ne(),R&&R()}),J)}E=E||"text";let Z=await f[P.findKey(f,E)||"text"](L,m);return!D&&R&&R(),await new Promise((J,he)=>{Cl(J,he,{data:Z,headers:Ut.from(L.headers),status:L.status,statusText:L.statusText,config:m,request:$})})}catch(_){throw R&&R(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,m,$),{cause:_.cause||_}):_e.from(_,_&&_.code,m,$)}}},hg=new Map,Ol=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=hg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:pg(t)),d=c;return c};Ol();const ai={http:Dm,xhr:ag,fetch:{get:Ol}};P.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ml=e=>`- ${e}`,mg=e=>P.isFunction(e)||e===null||e===!1,Dl={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,!mg(r)&&(o=ai[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`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,c])=>`adapter ${l} `+(c===!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[bl]=this[bl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Fr(i);r[a]||(Qm(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(Ut);function ii(e,t){const n=this||Lr,r=t||n,o=Ut.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 Sl(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(gr,_e,{__CANCEL__:!0});function Cl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function eg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function tg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(h*1e3/p):void 0}}function ng(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ko=(e,t,n=3)=>{let r=0;const o=tg(50,250);return ng(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Tl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},kl=e=>(...t)=>P.asap(()=>e(...t)),rg=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,og=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 sg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function El(e,t,n){let r=!sg(t);return e&&(r||n==!1)?ig(e,t):t}const Il=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,h){return P.isPlainObject(c)&&P.isPlainObject(d)?P.merge.call({caseless:h},c,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(c,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(c))return r(void 0,c,f,h)}else return r(c,d,f,h)}function s(c,d){if(!P.isUndefined(d))return r(void 0,d)}function i(c,d){if(P.isUndefined(d)){if(!P.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,f)=>o(Il(c),Il(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 Nl=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=xl(El(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(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Mt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&rg(t.url))){const l=o&&s&&og.read(s);l&&i.set(o,l)}return t},ag=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Nl(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,h,p,m;function x(){p&&p(),m&&m(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function g(){if(!y)return;const S=Ut.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:S,config:e,request:y};Cl(function(E){n(E),x()},function(E){r(E),x()},T),y=null}"onloadend"in y?y.onloadend=g:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(g)},y.onabort=function(){y&&(r(new _e("Request aborted",_e.ECONNABORTED,e,y)),y=null)},y.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new _e(T,_e.ERR_NETWORK,e,y);C.event=k||null,r(C),y=null},y.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||vl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new _e(k,T.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&P.forEach(i.toJSON(),function(k,T){y.setRequestHeader(T,k)}),P.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([h,m]=ko(c,!0),y.addEventListener("progress",h)),l&&y.upload&&([f,p]=ko(l),y.upload.addEventListener("progress",f),y.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{y&&(r(!S||S.type?new gr(null,e,y):S),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=eg(o.url);if(w&&Mt.protocols.indexOf(w)===-1){r(new _e("Unsupported protocol "+w+":",_e.ERR_BAD_REQUEST,e));return}y.send(s||null)})},lg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof _e?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>P.asap(a),l}},cg=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},ug=async function*(e,t){for await(const n of dg(e))yield*cg(n,t)},dg=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()}},Al=(e,t,n,r)=>{const o=ug(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},jl=64*1024,{isFunction:Eo}=P,fg=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:_l,TextEncoder:Rl}=P.global,Pl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},hg=e=>{e=P.merge.call({skipUndefined:!0},fg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Eo(t):typeof fetch=="function",s=Eo(n),i=Eo(r);if(!o)return!1;const a=o&&Eo(_l),l=o&&(typeof Rl=="function"?(m=>x=>m.encode(x))(new Rl):async m=>new Uint8Array(await new n(m).arrayBuffer())),c=s&&a&&Pl(()=>{let m=!1;const x=new n(Mt.origin,{body:new _l,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!x}),d=i&&a&&Pl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(m=>m.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(x,y)=>{let g=x&&x[m];if(g)return g.call(x);throw new _e(`Response type '${m}' is not supported`,_e.ERR_NOT_SUPPORT,y)})});const h=async m=>{if(m==null)return 0;if(P.isBlob(m))return m.size;if(P.isSpecCompliantForm(m))return(await new n(Mt.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(P.isArrayBufferView(m)||P.isArrayBuffer(m))return m.byteLength;if(P.isURLSearchParams(m)&&(m=m+""),P.isString(m))return(await l(m)).byteLength},p=async(m,x)=>{const y=P.toFiniteNumber(m.getContentLength());return y??h(x)};return async m=>{let{url:x,method:y,data:g,signal:w,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:j,withCredentials:N="same-origin",fetchOptions:A}=Nl(m),M=t||fetch;E=E?(E+"").toLowerCase():"text";let F=lg([w,S&&S.toAbortSignal()],k),$=null;const R=F&&F.unsubscribe&&(()=>{F.unsubscribe()});let z;try{if(C&&c&&y!=="get"&&y!=="head"&&(z=await p(j,g))!==0){let J=new n(x,{method:"POST",body:g,duplex:"half"}),pe;if(P.isFormData(g)&&(pe=J.headers.get("content-type"))&&j.setContentType(pe),J.body){const[Ee,Ne]=Tl(z,ko(kl(C)));g=Al(J.body,jl,Ee,Ne)}}P.isString(N)||(N=N?"include":"omit");const _=s&&"credentials"in n.prototype,B={...A,signal:F,method:y.toUpperCase(),headers:j.normalize().toJSON(),body:g,duplex:"half",credentials:_?N:void 0};$=s&&new n(x,B);let L=await(s?M($,A):M(x,B));const D=d&&(E==="stream"||E==="response");if(d&&(T||D&&R)){const J={};["status","statusText","headers"].forEach(V=>{J[V]=L[V]});const pe=P.toFiniteNumber(L.headers.get("content-length")),[Ee,Ne]=T&&Tl(pe,ko(kl(T),!0))||[];L=new r(Al(L.body,jl,Ee,()=>{Ne&&Ne(),R&&R()}),J)}E=E||"text";let Z=await f[P.findKey(f,E)||"text"](L,m);return!D&&R&&R(),await new Promise((J,pe)=>{Cl(J,pe,{data:Z,headers:Ut.from(L.headers),status:L.status,statusText:L.statusText,config:m,request:$})})}catch(_){throw R&&R(),_&&_.name==="TypeError"&&/Load failed|fetch/i.test(_.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,m,$),{cause:_.cause||_}):_e.from(_,_&&_.code,m,$)}}},pg=new Map,Ol=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=pg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:hg(t)),d=c;return c};Ol();const ai={http:Dm,xhr:ag,fetch:{get:Ol}};P.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ml=e=>`- ${e}`,mg=e=>P.isFunction(e)||e===null||e===!1,Dl={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,!mg(r)&&(o=ai[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`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,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Ml).join(`
|
|
34
34
|
`):" "+Ml(i[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ai};function li(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Ll(e){return li(e),e.headers=Ut.from(e.headers),e.data=ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Dl.getAdapter(e.adapter||Lr.adapter,e)(e).then(function(r){return li(e),r.data=ii.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Sl(r)||(li(e),r&&r.response&&(r.response.data=ii.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const Fl="1.12.2",Io={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Io[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $l={};Io.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Fl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new _e(o(i," has been removed"+(n?" in "+n:"")),_e.ERR_DEPRECATED);return n&&!$l[i]&&($l[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}},Io.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function gg(e,t,n){if(typeof e!="object")throw new _e("options must be an object",_e.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 _e("option "+s+" must be "+l,_e.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new _e("Unknown option "+s,_e.ERR_BAD_OPTION)}}const No={assertOptions:gg,validators:Io},gn=No.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new yl,response:new yl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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"],m=>{delete s[m]}),n.headers=Ut.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 c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let d,f=0,p;if(!l){const m=[Ll.bind(this),void 0];for(m.unshift(...a),m.push(...c),p=m.length,d=Promise.resolve(n);f<p;)d=d.then(m[f++],m[f++]);return d}p=a.length;let h=n;for(;f<p;){const m=a[f++],x=a[f++];try{h=m(h)}catch(y){x.call(this,y);break}}try{d=Ll.call(this,h)}catch(m){return Promise.reject(m)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=El(t.baseURL,t.url,t.allowAbsoluteUrls);return xl(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let xg=class qh{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new qh(function(o){t=o}),cancel:t}}};function yg(e){return function(n){return e.apply(null,n)}}function vg(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 zl(e){const t=new Zn(e),n=nl(Zn.prototype.request,t);return P.extend(n,Zn.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zl(Jn(e,o))},n}const wt=zl(Lr);wt.Axios=Zn,wt.CanceledError=gr,wt.CancelToken=xg,wt.isCancel=Sl,wt.VERSION=Fl,wt.toFormData=Co,wt.AxiosError=_e,wt.Cancel=wt.CanceledError,wt.all=function(t){return Promise.all(t)},wt.spread=yg,wt.isAxiosError=vg,wt.mergeConfig=Jn,wt.AxiosHeaders=Ut,wt.formToJSON=e=>wl(P.isHTMLForm(e)?new FormData(e):e),wt.getAdapter=Dl.getAdapter,wt.HttpStatusCode=ci,wt.default=wt;const{Axios:eT,AxiosError:tT,CanceledError:nT,isCancel:rT,CancelToken:oT,VERSION:sT,all:iT,Cancel:aT,isAxiosError:lT,spread:cT,toFormData:uT,AxiosHeaders:dT,HttpStatusCode:fT,formToJSON:pT,getAdapter:hT,mergeConfig:mT}=wt,Bl=typeof window<"u"?window.__API_BASE_URL__:void 0,Hl=Bl?En(Bl):void 0;function En(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const ui=new Set;function Ul(){return Ao}function jo(e){Ao=e,ui.forEach(t=>t(e))}function Wl(e){return ui.add(e),()=>ui.delete(e)}const wg=3e4,bg=9e4,Zt=wt.create({...Hl?{baseURL:Hl}:{},timeout:wg,withCredentials:!0});Zt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Zt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),jo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Qt(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vl(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Kl(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function en(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ql{get baseUrl(){const t=Zt.defaults.baseURL;return t?En(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=En(String(t.baseUrl))),t.authToken!==void 0&&jo(t.authToken)}getAuthToken(){return Ul()}setAuthToken(t){jo(t)}onTokenChange(t){return Wl(t)}async listThreads(){const t=await Qt("/threads"),n=en(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await di("/threads",t?{title:t}:void 0);return en(r)}async updateThread(t,n){const r=await Vl(`/threads/${t}`,{title:n});return en(r)}async deleteThread(t){const n=await Kl(`/threads/${t}`);return en(n)}async threadInfo(t){const n=await Qt(`/threads/${t}/info`);return en(n)}async listAgents(){const t=await Qt("/agents"),n=en(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Qt(`/agents/${t}`);return en(n)}async getAgentSchema(t){const n=await Qt(`/agents/${t}/schema`);return en(n)}async getState(t){const n=await Qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return en(n)}async getStateHistory(t){const n=await Qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:bg});return en(n)}async cancelRun(t){const n=await di("/runs/cancel",{threadId:t});return en(n)}async listCheckpointSummaries(t){const n=await Qt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=en(n);return(r==null?void 0:r.items)??[]}}const Pn=new ql,Gl=b.createContext(null);function Sg({children:e,apiConfig:t}){const n=Pn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(Gl.Provider,{value:r,children:e})}function fi(){const e=b.useContext(Gl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Cg(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 Tg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Cg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const kg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function pi(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 Eg(e,t){return`${e??""}::${t??""}`}function $r(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(!pi(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Ng(t),i=Yl(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Yl(e,t){if(!pi(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(N=>!!N&&typeof N=="object").map(N=>({...N})):a===null?null:void 0,c=r.map((N,A)=>Mg(N,A)).filter(N=>!!N),d=Wt(e.config),f=Wt(d==null?void 0:d.configurable),p=Et(f,["checkpoint_id","checkpointId"]),h=Et(f,["checkpoint_ns","checkpointNs"]),m=Wt(e==null?void 0:e.parentConfig),x=Wt(m==null?void 0:m.configurable),y=Et(x,["checkpoint_id","checkpointId"])??null,g=Et(x,["checkpoint_ns","checkpointNs"])??null,w=e==null?void 0:e.createdAt,S=typeof w=="string"&&w.trim()?w:new Date(Date.now()-t).toISOString(),k=c[c.length-1]??null,T=Wt(e==null?void 0:e.metadata),C=Et(T,["branch_label","branchLabel"]),E=Et(x,["checkpoint_id","checkpointId"]),j=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:p??null,checkpointNs:h??null,nextCursor:y,nextCursorNs:g,interrupt:Ig(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:m??null,next:j??null,tasks:l??null,values:i??null}}function Ig(e,t,n){const r=Pg(e,n);return r||Rg(t,n)}function Ng(e){const t=new Map;e.forEach((o,s)=>{if(!pi(o))return;const i=Yl(o,s);if(!(i!=null&&i.checkpointId))return;const a=Eg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Ag(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Jl(s.createdAt??"")-Jl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ag(e,t){return{...e,metadata:_o(e.metadata,t.metadata)??null,config:_o(e.config,t.config)??null,parentConfig:_o(e.parentConfig,t.parentConfig)??null,next:jg(e.next,t.next)??null,tasks:_g(e.tasks,t.tasks)??null,values:_o(e.values,t.values)??null}}function _o(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?e:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function jg(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function _g(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function Rg(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 Pg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Og(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=zr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=zr(r.state,`${o}-state`);if(s)return s}}return null}function Og(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...p]=e,h=typeof a=="string"&&a.trim()?a:t,m=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",x=Array.isArray(d)?d:void 0,y=p.length?p[p.length-1]:void 0;return{id:h,name:m,interrupts:x,state:y!==void 0?y:f}}const n=Wt(e);if(!n)return null;const r=Et(n,["id","task_id","taskId"])??t,o=Et(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 zr(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=Xl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=zr(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=zr(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 c=zr(l,t,n+1,r);if(c)return c}}return null}function Xl(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=Et(n,["type","event","kind"]),o=Et(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=Xl(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 Jl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Mg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Wt(e)??{},o=Wt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=kg[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}`,c=Wt(o.additional_kwargs)??Wt(o.additionalKwargs),d=Wt(o.response_metadata)??Wt(o.responseMetadata),f=Et(c,["createdAt","created_at"])??Et(o,["created_at","createdAt"]),p=Et(c,["checkpointId","checkpoint_id"]),h=Et(c,["checkpointNs","checkpoint_ns"]),m=Dg(o.content),x={id:l,role:i,content:m};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),p&&(x.checkpointId=p),h&&(x.checkpointNs=h);const y=zg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;y&&Object.keys(y).length&&(x.additionalKwargs=y),g&&Object.keys(g).length&&(x.responseMetadata=g);const w=Lg((c==null?void 0:c.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=Fg(o,x.content);S&&(x.content=S)}return x}function Dg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Zl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Zl(e);return t?[t]:[]}return[]}function Zl(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=Et(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=Et(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 Ql(t)??null;if(n==="tool_end"){const o="output"in t?t.output:t.content;return o?{type:"text",text:typeof o=="string"?o:JSON.stringify(o)}:null}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=Et(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 Ql(e,t){var s;const n=Et(e,["id","call_id"])??t,r=Et(e,["name"])??Et(Wt(e.function),["name"]);if(!n||!r)return null;const o=$g(e.args??e.arguments??((s=Wt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Lg(e){return Array.isArray(e)?e.map((t,n)=>Ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Fg(e,t){const n=e.content??e.output;if(!n)return t;const o={type:"text",text:typeof n=="string"?n:JSON.stringify(n)};return[...t,o]}function $g(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 Wt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Et(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function zg(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 Bg(){const e=b.useRef(new Map),t=b.useCallback((a,l)=>{const c=e.current.get(a),d=new Map;c&&c.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),l.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),e.current.set(a,Array.from(d.values()))},[]),n=b.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=b.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=b.useCallback(a=>e.current.get(a),[]),s=b.useCallback(a=>{e.current.delete(a)},[]),i=b.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}function Hg(e){return e.type!=="thread_info"&&e.type!=="token"}const Ug={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Wg(e,t){var n;switch(t.type){case"reset":return{messages:hi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=hi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=hi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return s.length?{...e,messages:[...s,...e.messages]}: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 tc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>tc(o,s),e):e}case"interrupt_response":return{...e,messages:nc(e.messages),pendingInterrupt:null};default:return e}}function ec(e=[]){const[t,n]=b.useReducer(Wg,{...Ug,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,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,...c}}function tc(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=Gg(t.model);if(e.messages.some(f=>f.id===a)){const f=e.messagesStreamMeta??{},p={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:p}}const d={id:a,role:"assistant",name:l||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:a,messages:[...e.messages,d]}}if(t.type==="message_delta"){const a=e.assemblingId??rc(e.messages);if(!a)return e;const l=e.messages,c=l.findIndex(k=>k.id===a&&k.role==="assistant");if(c===-1)return e;const d=l[c],f=e.messagesStreamMeta??{},p=f[a]??{lastSeq:null,lastText:ic(d.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof p.lastSeq=="number"&&h<=p.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:p.lastSeq}),e;const{newParts:m,newMeta:x,changed:y}=Vg(d.content,t.delta,p,h);if(!y)return e;const g={...d,content:m},w=Ro(l,c,g),S={...f,[a]:x};return{...e,messages:w,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??rc(e.messages);if(!a)return{...e,assemblingId:null};const l=e.messages,c=l.findIndex(d=>d.id===a&&d.role==="assistant");if(c>=0){const d=l[c];if(!((n=d.content)==null?void 0:n.some(p=>{var h;return(p==null?void 0:p.type)==="text"&&((h=p.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=d.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 p=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:p}}}return e}if(t.type==="tool_start"){const a=oc(t),l=a[0]??(typeof t.id=="string"?t.id:null)??(typeof t.call_id=="string"?t.call_id:null),c=t.name??t.tool??"tool";!l&&a.length===0&&a.push(`${c}-${Date.now()}`);const d=a.length?a:l?[l]:[],f=sc(e,d,c),p=f>=0?e.messages[f]:null,h=l??d[0]??`${c}-${Date.now()}`,m=(p==null?void 0:p.id)??`tool-${h}`,x=d[0]??h,y={type:"tool_call",id:x,name:c,args:t.args};if(p){const S=gi(p,d,c,t.args),k={...p,name:p.name??c,additionalKwargs:S},T=f,C=T>=0?Ro(e.messages,T,k):e.messages,E=Po(k,d),j=xi(e.toolIndex,m,E);return{...e,messages:C,toolIndex:j}}const g={id:m,role:"tool",name:c,createdAt:new Date().toISOString(),content:[y],additionalKwargs:gi(void 0,d.length?d:[x],c,t.args)},w=Po(g,d.length?d:[x]);return{...e,messages:[...e.messages,g],toolIndex:xi(e.toolIndex,m,w)}}if(t.type==="tool_end"){const a=oc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=sc(e,a,l),d=c>=0?e.messages[c]:null,f=l??(d==null?void 0:d.name)??((s=d==null?void 0:d.additionalKwargs)==null?void 0:s.toolName)??"tool",p=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,h=(d==null?void 0:d.id)??`tool-${p}`,m=Po(d,a);let x=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(x=JSON.parse(C))}catch{x=t.output}const y={type:"text",text:typeof x=="string"?x:JSON.stringify(x)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),w=gi(d??void 0,m.length?m:a,f),S={id:h,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[y],createdAt:g,additionalKwargs:w},k=c>=0?Ro(e.messages,c,S):[...e.messages,S],T=Po(S,a.length?a:m);return{...e,messages:k,toolIndex:xi(e.toolIndex,h,T)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=qg(e.messages,t.checkpointId,a);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:a,messages:l}}if(t.type==="branch"){const a=t.checkpointId??e.lastCheckpointId,l=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:a??null,lastCheckpointNs:l??null}}if(t.type==="error"){const a={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,a]}}if(t.type==="state_history"){const a=$r(t),l=a.interrupt,c=a.latest,d=l===null?nc(e.messages):e.messages;return{...e,messages:d,pendingInterrupt:l,lastCheckpointId:(c==null?void 0:c.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(c==null?void 0:c.checkpointNs)??e.lastCheckpointNs}}return e}function hi(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 Ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function nc(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function rc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function oc(e){const t=new Set,n=r=>{typeof r=="string"&&r.trim()&&t.add(r.trim())};return n(e.id),n(e==null?void 0:e.call_id),n(e==null?void 0:e.callId),Array.from(t)}function mi(e){if(!e)return[];const t=new Set,n=o=>{typeof o=="string"&&o.trim()&&t.add(o.trim())},r=e.additionalKwargs;if(r){n(r.toolCallId);const o=r.toolCallIds;if(Array.isArray(o))for(const s of o)n(s)}for(const o of e.content??[])(o==null?void 0:o.type)==="tool_call"&&n(o.id);return Array.from(t)}function gi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=mi(e);for(const c of l)s(c)}for(const l of t)s(l);const i=Array.from(o),a={...(e==null?void 0:e.additionalKwargs)??{}};if(i.length){a.toolCallIds=i;const l=typeof a.toolCallId=="string"?a.toolCallId.trim():null;a.toolCallId=l&&o.has(l)?l:i[0]}return n&&(a.toolName=n),r!==void 0&&(a.toolArgs=r),a}function Po(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=mi(e);for(const o of r)n.add(o);return Array.from(n)}function xi(e,t,n){if(!n.length)return e;let r=!1;const o={...e};for(const s of n)s&&o[s]!==t&&(o[s]=t,r=!0);return r?o:e}function sc(e,t,n){var o,s;const r=new Set(t.filter(i=>typeof i=="string"&&i.trim()));for(const i of r){const a=e.toolIndex[i];if(a){const l=e.messages.findIndex(c=>c.id===a);if(l!==-1)return l}}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(mi(a).some(c=>r.has(c)))return i}if(typeof n=="string"&&n.trim())for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool"||a.name&&a.name!==n)continue;if(!((o=a.content)==null?void 0:o.some(c=>c.type!=="tool_call")))return i}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(!((s=a.content)==null?void 0:s.some(c=>c.type!=="tool_call")))return i}return-1}function ic(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Vg(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??ic(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const p=c[c.length-1];if((p==null?void 0:p.type)==="text"){const h=p.text??"",m={...p,text:h+l};c=[...c.slice(0,c.length-1),m]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function ac(e){return e.replace(/\s+/g," ").trim()}function Kg(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=ac(e),o=ac(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 qg(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 Ro(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function lc(e={}){const t=b.useMemo(()=>En(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,p]=b.useState(""),[h,m]=b.useState(null),[x,y]=b.useState(0),[g,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),T=b.useRef(0),C=b.useRef(null),E=b.useRef(null),j=b.useRef(null),N=b.useRef(null),A=b.useCallback(R=>{o(R)},[]),M=b.useCallback(()=>{p(""),m(null),d(null),E.current=null,j.current=null,N.current=null},[]),F=b.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=S.current)==null||R.abort(),S.current=null,C.current=null,l(!1),w(!1),T.current=0,y(0)},[]),$=b.useCallback((R,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),m(null),E.current=null,j.current=null,N.current=null;const B=new AbortController;S.current=B;let L=null,D=null,Z=!1;return C.current={threadId:R.threadId??null,headers:{}},(async()=>{var he,Ee,Ne,W,ee,q,O,H,te,ie,ne,De,Y,fe,ke,je,ze,Be;const J=Ve=>{var Ke;try{const qe=JSON.parse(JSON.stringify(Ve));return(Ke=qe==null?void 0:qe.payload)!=null&&Ke.files_info&&Array.isArray(qe.payload.files_info)&&(qe.payload.files_info=qe.payload.files_info.map(Ze=>({...Ze,data:Ze!=null&&Ze.data?`<base64 ${String(Ze.data).length} chars>`:Ze==null?void 0:Ze.data}))),qe}catch{return Ve}};try{let Ve={};try{if(r)Ve={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Fe=window.__AUTH_TOKEN__,jt=((he=window.localStorage)==null?void 0:he.getItem("authToken"))||null;let At=null;try{const ve=(Ee=window.localStorage)==null?void 0:Ee.getItem("chat-settings");ve&&(At=((Ne=JSON.parse(ve))==null?void 0:Ne.apiKey)||null)}catch{}const V=Fe||jt||At||null;V&&(Ve={Authorization:`Bearer ${V}`})}}catch{}console.debug("[use-chat] POST",t+n,J(R));let Ke={};if(typeof window<"u")try{const et=(W=window.localStorage)==null?void 0:W.getItem("authSessionId");et&&(Ke={"X-Session-Id":et})}catch{}const qe={...Ve,...Ke,...s.current},Ze={"Content-Type":"application/json",Accept:"text/event-stream",...qe},Xe=await fetch(t+n,{method:"POST",headers:Ze,body:JSON.stringify(R),signal:B.signal,credentials:i});if(C.current&&(C.current.headers=qe),!Xe.ok||!Xe.body){const et=await Xe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Xe.status,et==null?void 0:et.slice(0,500));const Fe=`stream ${Xe.status}${et?": "+et:""}`;throw(ee=_==null?void 0:_.onConnectionError)==null||ee.call(_,Fe),Z=!0,L="error",D=Fe,new Error(Fe)}w(!0);const ot=Xe.body.getReader(),St=new TextDecoder;let mt="",it=[];T.current=0,y(0);let Ct=0,de=null;const re=()=>{if(it.length){const et=it.join("");it=[],k.current&&p(Fe=>Fe+et)}de=null},Qe=()=>{typeof window<"u"&&de==null&&(de=requestAnimationFrame(re))};let Re=Date.now();const Le=setInterval(()=>{var et;if(Date.now()-Re>18e5){const Fe="Stream idle timeout";d(Fe),L="error",D=Fe,B.abort(),(et=_==null?void 0:_.onError)==null||et.call(_,Fe)}},5e3),ut=1024*1024;try{const et=Xe.headers.get("X-Thread-Id")||Xe.headers.get("x-thread-id"),Fe=Xe.headers.get("X-Thread-Created")||Xe.headers.get("x-thread-created"),jt=et??null,At=String(Fe??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:jt}),(q=_==null?void 0:_.onOpen)==null||q.call(_,{threadId:jt,created:At});;){const{value:V,done:ve}=await ot.read();if(ve)break;mt+=St.decode(V,{stream:!0}),mt.length>ut&&(mt="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=mt.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.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"],m=>{delete s[m]}),n.headers=Ut.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 c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const m=[Ll.bind(this),void 0];for(m.unshift(...a),m.push(...c),h=m.length,d=Promise.resolve(n);f<h;)d=d.then(m[f++],m[f++]);return d}h=a.length;let p=n;for(;f<h;){const m=a[f++],x=a[f++];try{p=m(p)}catch(y){x.call(this,y);break}}try{d=Ll.call(this,p)}catch(m){return Promise.reject(m)}for(f=0,h=c.length;f<h;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=El(t.baseURL,t.url,t.allowAbsoluteUrls);return xl(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let xg=class qp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new qp(function(o){t=o}),cancel:t}}};function yg(e){return function(n){return e.apply(null,n)}}function vg(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 zl(e){const t=new Zn(e),n=nl(Zn.prototype.request,t);return P.extend(n,Zn.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zl(Jn(e,o))},n}const wt=zl(Lr);wt.Axios=Zn,wt.CanceledError=gr,wt.CancelToken=xg,wt.isCancel=Sl,wt.VERSION=Fl,wt.toFormData=Co,wt.AxiosError=_e,wt.Cancel=wt.CanceledError,wt.all=function(t){return Promise.all(t)},wt.spread=yg,wt.isAxiosError=vg,wt.mergeConfig=Jn,wt.AxiosHeaders=Ut,wt.formToJSON=e=>wl(P.isHTMLForm(e)?new FormData(e):e),wt.getAdapter=Dl.getAdapter,wt.HttpStatusCode=ci,wt.default=wt;const{Axios:eT,AxiosError:tT,CanceledError:nT,isCancel:rT,CancelToken:oT,VERSION:sT,all:iT,Cancel:aT,isAxiosError:lT,spread:cT,toFormData:uT,AxiosHeaders:dT,HttpStatusCode:fT,formToJSON:hT,getAdapter:pT,mergeConfig:mT}=wt,Bl=typeof window<"u"?window.__API_BASE_URL__:void 0,Hl=Bl?En(Bl):void 0;function En(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const ui=new Set;function Ul(){return Ao}function jo(e){Ao=e,ui.forEach(t=>t(e))}function Wl(e){return ui.add(e),()=>ui.delete(e)}const wg=3e4,bg=9e4,Zt=wt.create({...Hl?{baseURL:Hl}:{},timeout:wg,withCredentials:!0});Zt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Zt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),jo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Qt(e,t){return Zt.defaults.baseURL?(await Zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function di(e,t,n){return Zt.defaults.baseURL?(await Zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vl(e,t,n){return Zt.defaults.baseURL?(await Zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Kl(e,t){return Zt.defaults.baseURL?(await Zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function en(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class ql{get baseUrl(){const t=Zt.defaults.baseURL;return t?En(String(t)):""}updateConfig(t){t.baseUrl&&(Zt.defaults.baseURL=En(String(t.baseUrl))),t.authToken!==void 0&&jo(t.authToken)}getAuthToken(){return Ul()}setAuthToken(t){jo(t)}onTokenChange(t){return Wl(t)}async listThreads(){const t=await Qt("/threads"),n=en(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await di("/threads",t?{title:t}:void 0);return en(r)}async updateThread(t,n){const r=await Vl(`/threads/${t}`,{title:n});return en(r)}async deleteThread(t){const n=await Kl(`/threads/${t}`);return en(n)}async threadInfo(t){const n=await Qt(`/threads/${t}/info`);return en(n)}async listAgents(){const t=await Qt("/agents"),n=en(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Qt(`/agents/${t}`);return en(n)}async getAgentSchema(t){const n=await Qt(`/agents/${t}/schema`);return en(n)}async getState(t){const n=await Qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return en(n)}async getStateHistory(t){const n=await Qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:bg});return en(n)}async cancelRun(t){const n=await di("/runs/cancel",{threadId:t});return en(n)}async listCheckpointSummaries(t){const n=await Qt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=en(n);return(r==null?void 0:r.items)??[]}}const Pn=new ql,Gl=b.createContext(null);function Sg({children:e,apiConfig:t}){const n=Pn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(Gl.Provider,{value:r,children:e})}function fi(){const e=b.useContext(Gl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Cg(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 Tg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Cg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const kg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function hi(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 Eg(e,t){return`${e??""}::${t??""}`}function $r(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(!hi(r))return{threadId:n,latest:null,checkpoints:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Ng(t),i=Yl(r,0);return{threadId:n,latest:i,checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Yl(e,t){if(!hi(e))return null;const n=e.values??{messages:[]},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],{messages:o,...s}=n,i=Object.keys(s).length?s:null,a=e.tasks,l=Array.isArray(a)?a.filter(N=>!!N&&typeof N=="object").map(N=>({...N})):a===null?null:void 0,c=r.map((N,A)=>Mg(N,A)).filter(N=>!!N),d=Wt(e.config),f=Wt(d==null?void 0:d.configurable),h=Et(f,["checkpoint_id","checkpointId"]),p=Et(f,["checkpoint_ns","checkpointNs"]),m=Wt(e==null?void 0:e.parentConfig),x=Wt(m==null?void 0:m.configurable),y=Et(x,["checkpoint_id","checkpointId"])??null,g=Et(x,["checkpoint_ns","checkpointNs"])??null,w=e==null?void 0:e.createdAt,S=typeof w=="string"&&w.trim()?w:new Date(Date.now()-t).toISOString(),k=c[c.length-1]??null,T=Wt(e==null?void 0:e.metadata),C=Et(T,["branch_label","branchLabel"]),E=Et(x,["checkpoint_id","checkpointId"]),j=Array.isArray(e.next)?[...e.next]:(e==null?void 0:e.next)===null?null:void 0;return{messages:c,checkpointId:h??null,checkpointNs:p??null,nextCursor:y,nextCursorNs:g,interrupt:Ig(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:m??null,next:j??null,tasks:l??null,values:i??null}}function Ig(e,t,n){const r=Pg(e,n);return r||Rg(t,n)}function Ng(e){const t=new Map;e.forEach((o,s)=>{if(!hi(o))return;const i=Yl(o,s);if(!(i!=null&&i.checkpointId))return;const a=Eg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,Ag(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Jl(s.createdAt??"")-Jl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ag(e,t){return{...e,metadata:_o(e.metadata,t.metadata)??null,config:_o(e.config,t.config)??null,parentConfig:_o(e.parentConfig,t.parentConfig)??null,next:jg(e.next,t.next)??null,tasks:_g(e.tasks,t.tasks)??null,values:_o(e.values,t.values)??null}}function _o(e,t){return t&&typeof t=="object"?{...e&&typeof e=="object"?e:{},...t}:t===null?e&&typeof e=="object"?{...e}:e??null:e&&typeof e=="object"?{...e}:e??void 0}function jg(e,t){return Array.isArray(t)?t.slice():t===null?Array.isArray(e)?e.slice():e??null:Array.isArray(e)?e.slice():e??void 0}function _g(e,t){return Array.isArray(t)?t.map(n=>({...n})):t===null?Array.isArray(e)?e.map(n=>({...n})):e??null:Array.isArray(e)?e.map(n=>({...n})):e??void 0}function Rg(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 Pg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Og(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=zr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=zr(r.state,`${o}-state`);if(s)return s}}return null}function Og(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,c,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,m=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",x=Array.isArray(d)?d:void 0,y=h.length?h[h.length-1]:void 0;return{id:p,name:m,interrupts:x,state:y!==void 0?y:f}}const n=Wt(e);if(!n)return null;const r=Et(n,["id","task_id","taskId"])??t,o=Et(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 zr(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=Xl(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=zr(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=zr(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 c=zr(l,t,n+1,r);if(c)return c}}return null}function Xl(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=Et(n,["type","event","kind"]),o=Et(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=Xl(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 Jl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Mg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Wt(e)??{},o=Wt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=kg[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}`,c=Wt(o.additional_kwargs)??Wt(o.additionalKwargs),d=Wt(o.response_metadata)??Wt(o.responseMetadata),f=Et(c,["createdAt","created_at"])??Et(o,["created_at","createdAt"]),h=Et(c,["checkpointId","checkpoint_id"]),p=Et(c,["checkpointNs","checkpoint_ns"]),m=Dg(o.content),x={id:l,role:i,content:m};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 y=zg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),g=d?{...d}:void 0;y&&Object.keys(y).length&&(x.additionalKwargs=y),g&&Object.keys(g).length&&(x.responseMetadata=g);const w=Lg((c==null?void 0:c.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=Fg(o,x.content);S&&(x.content=S)}return x}function Dg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Zl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Zl(e);return t?[t]:[]}return[]}function Zl(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=Et(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=Et(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 Ql(t)??null;if(n==="tool_end"){const o="output"in t?t.output:t.content;return o?{type:"text",text:typeof o=="string"?o:JSON.stringify(o)}:null}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=Et(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 Ql(e,t){var s;const n=Et(e,["id","call_id"])??t,r=Et(e,["name"])??Et(Wt(e.function),["name"]);if(!n||!r)return null;const o=$g(e.args??e.arguments??((s=Wt(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Lg(e){return Array.isArray(e)?e.map((t,n)=>Ql(t,`tool_call_${n}`)).filter(t=>!!t):[]}function Fg(e,t){const n=e.content??e.output;if(!n)return t;const o={type:"text",text:typeof n=="string"?n:JSON.stringify(n)};return[...t,o]}function $g(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 Wt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Et(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function zg(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 Bg(){const e=b.useRef(new Map),t=b.useCallback((a,l)=>{const c=e.current.get(a),d=new Map;c&&c.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),l.forEach(f=>{d.set(`${f.checkpointId}::${f.checkpointNs}`,f)}),e.current.set(a,Array.from(d.values()))},[]),n=b.useCallback((a,l)=>{const c=e.current.get(a);return c==null?void 0:c.find(d=>d.checkpointId===l)},[]),r=b.useCallback((a,l)=>{const c=e.current.get(a);return(c==null?void 0:c.some(d=>d.checkpointId===l))??!1},[]),o=b.useCallback(a=>e.current.get(a),[]),s=b.useCallback(a=>{e.current.delete(a)},[]),i=b.useCallback(()=>{e.current.clear()},[]);return{cache:e.current,setCacheForThread:t,getCachedMetadata:n,checkpointExists:r,getThreadMetadata:o,clearThreadCache:s,clearAllCache:i}}function Hg(e){return e.type!=="thread_info"&&e.type!=="token"}const Ug={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Wg(e,t){var n;switch(t.type){case"reset":return{messages:pi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=pi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=pi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return s.length?{...e,messages:[...s,...e.messages]}: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 tc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>tc(o,s),e):e}case"interrupt_response":return{...e,messages:nc(e.messages),pendingInterrupt:null};default:return e}}function ec(e=[]){const[t,n]=b.useReducer(Wg,{...Ug,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,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,...c}}function tc(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=Gg(t.model);if(e.messages.some(f=>f.id===a)){const f=e.messagesStreamMeta??{},h={...f,[a]:f[a]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:a,messagesStreamMeta:h}}const d={id:a,role:"assistant",name:l||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:a,messages:[...e.messages,d]}}if(t.type==="message_delta"){const a=e.assemblingId??rc(e.messages);if(!a)return e;const l=e.messages,c=l.findIndex(k=>k.id===a&&k.role==="assistant");if(c===-1)return e;const d=l[c],f=e.messagesStreamMeta??{},h=f[a]??{lastSeq:null,lastText:ic(d.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:m,newMeta:x,changed:y}=Vg(d.content,t.delta,h,p);if(!y)return e;const g={...d,content:m},w=Ro(l,c,g),S={...f,[a]:x};return{...e,messages:w,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??rc(e.messages);if(!a)return{...e,assemblingId:null};const l=e.messages,c=l.findIndex(d=>d.id===a&&d.role==="assistant");if(c>=0){const d=l[c];if(!((n=d.content)==null?void 0:n.some(h=>{var p;return(h==null?void 0:h.type)==="text"&&((p=h.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:d.id,contentTypes:(r=d.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=d.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const h=[...l.slice(0,c),...l.slice(c+1)];return{...e,assemblingId:null,messages:h}}}return e}if(t.type==="tool_start"){const a=oc(t),l=a[0]??(typeof t.id=="string"?t.id:null)??(typeof t.call_id=="string"?t.call_id:null),c=t.name??t.tool??"tool";!l&&a.length===0&&a.push(`${c}-${Date.now()}`);const d=a.length?a:l?[l]:[],f=sc(e,d,c),h=f>=0?e.messages[f]:null,p=l??d[0]??`${c}-${Date.now()}`,m=(h==null?void 0:h.id)??`tool-${p}`,x=d[0]??p,y={type:"tool_call",id:x,name:c,args:t.args};if(h){const S=gi(h,d,c,t.args),k={...h,name:h.name??c,additionalKwargs:S},T=f,C=T>=0?Ro(e.messages,T,k):e.messages,E=Po(k,d),j=xi(e.toolIndex,m,E);return{...e,messages:C,toolIndex:j}}const g={id:m,role:"tool",name:c,createdAt:new Date().toISOString(),content:[y],additionalKwargs:gi(void 0,d.length?d:[x],c,t.args)},w=Po(g,d.length?d:[x]);return{...e,messages:[...e.messages,g],toolIndex:xi(e.toolIndex,m,w)}}if(t.type==="tool_end"){const a=oc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=sc(e,a,l),d=c>=0?e.messages[c]:null,f=l??(d==null?void 0:d.name)??((s=d==null?void 0:d.additionalKwargs)==null?void 0:s.toolName)??"tool",h=a[0]??((i=d==null?void 0:d.id)==null?void 0:i.replace(/^tool-/,""))??`${f}-${Date.now()}`,p=(d==null?void 0:d.id)??`tool-${h}`,m=Po(d,a);let x=t.output;if(typeof t.output=="string")try{const C=t.output.trim();(C.startsWith("{")||C.startsWith("["))&&(x=JSON.parse(C))}catch{x=t.output}const y={type:"text",text:typeof x=="string"?x:JSON.stringify(x)},g=(d==null?void 0:d.createdAt)??new Date().toISOString(),w=gi(d??void 0,m.length?m:a,f),S={id:p,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[y],createdAt:g,additionalKwargs:w},k=c>=0?Ro(e.messages,c,S):[...e.messages,S],T=Po(S,a.length?a:m);return{...e,messages:k,toolIndex:xi(e.toolIndex,p,T)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=qg(e.messages,t.checkpointId,a);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:a,messages:l}}if(t.type==="branch"){const a=t.checkpointId??e.lastCheckpointId,l=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:a??null,lastCheckpointNs:l??null}}if(t.type==="error"){const a={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,a]}}if(t.type==="state_history"){const a=$r(t),l=a.interrupt,c=a.latest,d=l===null?nc(e.messages):e.messages;return{...e,messages:d,pendingInterrupt:l,lastCheckpointId:(c==null?void 0:c.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(c==null?void 0:c.checkpointNs)??e.lastCheckpointNs}}return e}function pi(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 Ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function nc(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function rc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function oc(e){const t=new Set,n=r=>{typeof r=="string"&&r.trim()&&t.add(r.trim())};return n(e.id),n(e==null?void 0:e.call_id),n(e==null?void 0:e.callId),Array.from(t)}function mi(e){if(!e)return[];const t=new Set,n=o=>{typeof o=="string"&&o.trim()&&t.add(o.trim())},r=e.additionalKwargs;if(r){n(r.toolCallId);const o=r.toolCallIds;if(Array.isArray(o))for(const s of o)n(s)}for(const o of e.content??[])(o==null?void 0:o.type)==="tool_call"&&n(o.id);return Array.from(t)}function gi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=mi(e);for(const c of l)s(c)}for(const l of t)s(l);const i=Array.from(o),a={...(e==null?void 0:e.additionalKwargs)??{}};if(i.length){a.toolCallIds=i;const l=typeof a.toolCallId=="string"?a.toolCallId.trim():null;a.toolCallId=l&&o.has(l)?l:i[0]}return n&&(a.toolName=n),r!==void 0&&(a.toolArgs=r),a}function Po(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=mi(e);for(const o of r)n.add(o);return Array.from(n)}function xi(e,t,n){if(!n.length)return e;let r=!1;const o={...e};for(const s of n)s&&o[s]!==t&&(o[s]=t,r=!0);return r?o:e}function sc(e,t,n){var o,s;const r=new Set(t.filter(i=>typeof i=="string"&&i.trim()));for(const i of r){const a=e.toolIndex[i];if(a){const l=e.messages.findIndex(c=>c.id===a);if(l!==-1)return l}}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(mi(a).some(c=>r.has(c)))return i}if(typeof n=="string"&&n.trim())for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool"||a.name&&a.name!==n)continue;if(!((o=a.content)==null?void 0:o.some(c=>c.type!=="tool_call")))return i}for(let i=e.messages.length-1;i>=0;i--){const a=e.messages[i];if(a.role!=="tool")continue;if(!((s=a.content)==null?void 0:s.some(c=>c.type!=="tool_call")))return i}return-1}function ic(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Vg(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??ic(e);let l="",c=e.slice();if(s){const f=Kg(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=c[c.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",m={...h,text:p+l};c=[...c.slice(0,c.length-1),m]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function ac(e){return e.replace(/\s+/g," ").trim()}function Kg(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=ac(e),o=ac(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 qg(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 Ro(e,r,s)}return e}function Gg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function lc(e={}){const t=b.useMemo(()=>En(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[f,h]=b.useState(""),[p,m]=b.useState(null),[x,y]=b.useState(0),[g,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),T=b.useRef(0),C=b.useRef(null),E=b.useRef(null),j=b.useRef(null),N=b.useRef(null),A=b.useCallback(R=>{o(R)},[]),M=b.useCallback(()=>{h(""),m(null),d(null),E.current=null,j.current=null,N.current=null},[]),F=b.useCallback(()=>{var R;console.debug("[use-chat] stop() invoked - aborting stream"),(R=S.current)==null||R.abort(),S.current=null,C.current=null,l(!1),w(!1),T.current=0,y(0)},[]),$=b.useCallback((R,z,_)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),m(null),E.current=null,j.current=null,N.current=null;const B=new AbortController;S.current=B;let L=null,D=null,Z=!1;return C.current={threadId:R.threadId??null,headers:{}},(async()=>{var pe,Ee,Ne,V,ee,U,O,H,te,ie,ne,Fe,Y,fe,ke,je,Be,He;const J=Ke=>{var qe;try{const Ge=JSON.parse(JSON.stringify(Ke));return(qe=Ge==null?void 0:Ge.payload)!=null&&qe.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(tt=>({...tt,data:tt!=null&&tt.data?`<base64 ${String(tt.data).length} chars>`:tt==null?void 0:tt.data}))),Ge}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Me=window.__AUTH_TOKEN__,jt=((pe=window.localStorage)==null?void 0:pe.getItem("authToken"))||null;let At=null;try{const ve=(Ee=window.localStorage)==null?void 0:Ee.getItem("chat-settings");ve&&(At=((Ne=JSON.parse(ve))==null?void 0:Ne.apiKey)||null)}catch{}const K=Me||jt||At||null;K&&(Ke={Authorization:`Bearer ${K}`})}}catch{}console.debug("[use-chat] POST",t+n,J(R));let qe={};if(typeof window<"u")try{const $e=(V=window.localStorage)==null?void 0:V.getItem("authSessionId");$e&&(qe={"X-Session-Id":$e})}catch{}const Ge={...Ke,...qe,...s.current},tt={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},Qe=await fetch(t+n,{method:"POST",headers:tt,body:JSON.stringify(R),signal:B.signal,credentials:i});if(C.current&&(C.current.headers=Ge),!Qe.ok||!Qe.body){const $e=await Qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Qe.status,$e==null?void 0:$e.slice(0,500));const Me=`stream ${Qe.status}${$e?": "+$e:""}`;throw(ee=_==null?void 0:_.onConnectionError)==null||ee.call(_,Me),Z=!0,L="error",D=Me,new Error(Me)}w(!0);const st=Qe.body.getReader(),St=new TextDecoder;let mt="",at=[];T.current=0,y(0);let Ct=0,de=null;const re=()=>{if(at.length){const $e=at.join("");at=[],k.current&&h(Me=>Me+$e)}de=null},Ye=()=>{typeof window<"u"&&de==null&&(de=requestAnimationFrame(re))};let De=Date.now();const Xe=setInterval(()=>{var $e;if(Date.now()-De>18e5){const Me="Stream idle timeout";d(Me),L="error",D=Me,B.abort(),($e=_==null?void 0:_.onError)==null||$e.call(_,Me)}},5e3),Re=1024*1024;try{const $e=Qe.headers.get("X-Thread-Id")||Qe.headers.get("x-thread-id"),Me=Qe.headers.get("X-Thread-Created")||Qe.headers.get("x-thread-created"),jt=$e??null,At=String(Me??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:jt}),(U=_==null?void 0:_.onOpen)==null||U.call(_,{threadId:jt,created:At});;){const{value:K,done:ve}=await st.read();if(ve)break;mt+=St.decode(K,{stream:!0}),mt.length>Re&&(mt="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=mt.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const ft=mt.slice(0,xe);mt=mt.slice(xe+2);const gt=Xg(ft);if(!gt)continue;let Tt;try{Tt=JSON.parse(gt)}catch{console.debug("[use-chat] malformed SSE:",gt.slice(0,200));continue}const Pe=Yg(Tt)?Tt.data:Tt;
|
|
38
|
-
`)}const cc=200;function Jg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o,onStreamClosed:s,onConnectionError:i,onAuthError:a,onHeartbeat:l}){const c=b.useRef(null),d=b.useRef(null),f=b.useRef(new Map),p=b.useRef(null),h=b.useCallback(N=>{try{const A=globalThis.structuredClone;if(typeof A=="function")return A(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),m=b.useCallback((N,A)=>{if(!N)return;const M=f.current.get(N)??[],F=h(A),$=M.length>=cc?[...M.slice(M.length-cc+1),F]:[...M,F];f.current.set(N,$)},[h]),x=b.useCallback(N=>{N&&f.current.set(N,[])},[]),y=b.useCallback(N=>{const A=N??d.current;if(!A)return;const M=f.current.get(A);M!=null&&M.length&&M.forEach(F=>{try{n(F)}catch($){console.error("[useChatStreamingService] Failed to replay buffered event",$)}})},[n]),g=b.useCallback(N=>{var F,$,R,z,_;const A=N.seq??null;if(A!==null){const B=c.current;if(B!==null){if(A<=B)return;A>B+1&&(o==null||o({from:B,to:A}))}c.current=A}if(N.type==="thread_info"){d.current=N.threadId,p.current&&(p.current.threadIdGuess=N.threadId),x(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch(B){console.error("[useChatStreamingService] Error in onThreadInfo handler:",B)}return}if(N.type==="heartbeat"){try{l==null||l(N)}catch(B){console.error("[useChatStreamingService] Error in onHeartbeat handler:",B)}return}if(N.type==="error"){const B=N;if(B.error_type==="auth_error"||B.code==="TOKEN_EXPIRED"||((F=B.message)==null?void 0:F.includes("token"))||(($=B.message)==null?void 0:$.includes("401"))||((R=B.message)==null?void 0:R.includes("unauthorized"))||((z=B.message)==null?void 0:z.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",B.message);try{a==null||a(B.message)}catch(D){console.warn("[useChatStreamingService] onAuthError handler failed",D)}}}const M=N.threadId??(N.type==="state_history"?N.threadId:void 0)??d.current??((_=p.current)==null?void 0:_.threadIdGuess)??null;if(N.type==="state_history"&&(d.current=M??d.current),Hg(N)){N.type==="checkpoint"||N.type==="state_history"?x(M??null):m(M??null,N);try{n(N)}catch(B){console.error("[useChatStreamingService] Error in onMessageEvent handler:",B)}return}try{r==null||r(N)}catch(B){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",B)}},[m,x,n,o,t,r]),{stream:w,stop:S,isStreaming:k,error:T,setToken:C}=lc({baseUrl:e,token:void 0}),E=b.useCallback((N,A)=>{c.current=null,d.current=N.threadId??null,p.current={request:N,callbacks:A,manualStop:!1,threadIdGuess:N.threadId??null},w(N,g,{onOpen:A==null?void 0:A.onOpen,onError:M=>{var F;(F=A==null?void 0:A.onError)==null||F.call(A,M)},onGap:(A==null?void 0:A.onGap)??o,onConnectionError:M=>{var F;i==null||i(M),(F=A==null?void 0:A.onConnectionError)==null||F.call(A,M)},onAuthError:M=>{var F;a==null||a(M),(F=A==null?void 0:A.onAuthError)==null||F.call(A,M)},onHeartbeat:M=>{var F;try{l==null||l(M)}catch($){console.warn("[useChatStreamingService] onHeartbeat handler failed",$)}try{(F=A==null?void 0:A.onHeartbeat)==null||F.call(A,M)}catch($){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",$)}},onClosed:M=>{var z,_,B,L;const F=((z=p.current)==null?void 0:z.manualStop)??!1,$=d.current??((_=p.current)==null?void 0:_.threadIdGuess)??((B=M.lastStateHistory)==null?void 0:B.threadId)??null;(M.reason==="complete"||M.reason==="aborted"&&F)&&x($);const R={...M,threadId:$,manualStop:F};try{s==null||s(R)}catch(D){console.warn("[useChatStreamingService] onStreamClosed handler failed",D)}try{(L=A==null?void 0:A.onClosed)==null||L.call(A,R)}catch(D){console.warn("[useChatStreamingService] downstream onClosed handler failed",D)}p.current&&(p.current=null)}})},[x,g,a,i,l,o,s,w]),j=b.useCallback(()=>{p.current&&(p.current.manualStop=!0),S()},[S]);return b.useMemo(()=>({startStream:E,stop:j,isStreaming:k,error:T,setAuthToken:C,replayBufferedEvents:y}),[E,j,k,T,C,y])}const uc=b.createContext(null),dc=b.createContext(null),fc=b.createContext(null);b.createContext(!1);function Zg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,checkpointMetadataCache:l}){const{api:c,baseUrl:d}=fi(),f=b.useMemo(()=>En(d),[d]),[p,h]=b.useState([]),[m,x]=b.useState(t),[y,g]=b.useState(!1),[w,S]=b.useState(null),[k,T]=b.useState(!1),[C,E]=b.useState(null),{state:j,seed:N,prepend:A,pushUser:M,onEvent:F}=ec(),[$,R]=b.useState(!1),[z,_]=b.useState(!1),[B,L]=b.useState(null),[D,Z]=b.useState([]),[J,he]=b.useState(!1),Ee=l??Bg(),{setCacheForThread:Ne}=Ee,W=b.useRef(m),ee=b.useRef(null),q=b.useRef(!1);b.useEffect(()=>{W.current=m},[m]);const O=b.useRef(),{startStream:H,stop:te,isStreaming:ie,error:ne,setAuthToken:De}=Jg({baseUrl:f,onThreadInfo:de=>{if(console.log("[ChatSessionProvider] Thread info:",de.threadId),W.current===null){console.log("[ChatSessionProvider] Ignoring thread info: no active thread (new chat mode)");return}W.current!==de.threadId&&x(de.threadId)},onMessageEvent:F,onUnhandledEvent:de=>{console.warn("[ChatSessionProvider] Unhandled event:",de.type)},onAuthError:i}),Y=b.useCallback(async()=>{g(!0),S(null);try{const de=await c.listThreads();h(de??[])}catch(de){const re=String(de);S(re),s==null||s(re)}finally{g(!1)}},[c,s]),fe=b.useCallback(async de=>{try{const re=await c.createThread(de);return x(re.threadId),await Y(),re.threadId}catch(re){return s==null||s(String(re)),null}},[c,Y,s]),ke=b.useCallback(async de=>{try{await c.deleteThread(de),W.current===de&&(x(null),N([],{})),await Y()}catch(re){s==null||s(String(re))}},[c,Y,N,s]),je=b.useCallback(async(de,re)=>{try{await c.updateThread(de,re),await Y()}catch(Qe){s==null||s(String(Qe))}},[c,Y,s]),ze=b.useCallback((de,re,Qe)=>{const Re=re.filter(Le=>Le.checkpointId).map(Le=>({checkpointId:Le.checkpointId,checkpointNs:Le.checkpointNs??void 0,createdAt:Le.createdAt??""}));console.log(`[ChatSessionProvider] Cached metadata for ${Re.length} checkpoints from ${Qe}`),Ne(de,Re)},[Ne]),Be=b.useCallback(async(de,re)=>{if(de){T(!0),E(null);try{const Qe=await c.getStateHistory({threadId:de,checkpointId:re||void 0}),{checkpoints:Re}=$r(Qe);ze(de,Re,`thread load (requested: ${re})`);const Le=Re.find(ut=>ut.messages&&ut.messages.length>0)??(re?Re.find(ut=>ut.checkpointId===re):null)??Re[0];N((Le==null?void 0:Le.messages)??[],{checkpointId:(Le==null?void 0:Le.checkpointId)??null,checkpointNs:(Le==null?void 0:Le.checkpointNs)??null}),Z(Re),R(!!(Le!=null&&Le.nextCursor)),L((Le==null?void 0:Le.nextCursor)??null)}catch(Qe){const Re=String(Qe);E(Re),s==null||s(Re)}finally{T(!1)}}},[c,N,s,ze]);b.useEffect(()=>{O.current=Be},[Be]);const Ve=b.useCallback(async(de,re)=>{const Qe=W.current;if(Qe){he(!0);try{const Re=await c.getStateHistory({threadId:Qe,checkpointId:de,checkpointNs:re??void 0}),{checkpoints:Le}=$r(Re);ze(Qe,Le,"checkpoint navigation");const ut=Le.find(et=>et.checkpointId===de&&(re?et.checkpointNs===re:!0));if(!ut){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:de,checkpointNs:re});return}Z(Le),N(ut.messages??[],{checkpointId:ut.checkpointId??null,checkpointNs:ut.checkpointNs??null})}catch(Re){s==null||s(String(Re))}finally{he(!1)}}},[c,N,s,ze]),Ke=b.useCallback((de,re)=>{N(j.messages,{checkpointId:de??null,checkpointNs:re??null})},[N,j.messages]),qe=b.useCallback(async()=>{W.current&&await Be(W.current)},[Be]),Ze=b.useCallback(async()=>{if(!W.current||!B)return;if(q.current){console.log("[ChatSessionProvider] Skipping history load - thread cleanup in progress");return}_(!0);let de=!0;try{const re=await c.getStateHistory({threadId:W.current,checkpointId:B});if(q.current){console.log("[ChatSessionProvider] Discarding history fetch - thread was cleared"),de=!1;return}const{checkpoints:Qe}=$r(re);if(Qe.length>0){const Re=Qe[Qe.length-1];A((Re==null?void 0:Re.messages)??[]),R(!!(Re!=null&&Re.nextCursor)),L((Re==null?void 0:Re.nextCursor)??null)}}catch(re){q.current?(console.log("[ChatSessionProvider] Error during history fetch, but cleanup in progress - ignoring"),de=!1):s==null||s(String(re))}finally{de&&_(!1)}},[c,B,A,s]),Xe=b.useCallback(async()=>{q.current=!0,te(),W.current=null,ee.current=null,N([],{}),Z([]),R(!1),L(null),x(null),await Promise.resolve(),q.current=!1},[N,te]),ot=b.useCallback(async(de,re)=>{console.log("[ChatSessionProvider] Interrupt:",de,re)},[]);b.useEffect(()=>{Y()},[Y]),b.useEffect(()=>{var de,re;!o||!m||k||ee.current!==m&&(ee.current=m,n?(console.log("[ChatSessionProvider] Loading thread with checkpoint:",n),(de=O.current)==null||de.call(O,m,n)):(console.log("[ChatSessionProvider] Loading thread with latest checkpoint"),(re=O.current)==null||re.call(O,m)))},[o,m,k,n,r]),b.useEffect(()=>{a==null||a(m)},[m,a]);const St=b.useCallback(async(de,re)=>{const Qe=W.current,Re=(de==null?void 0:de.text)??"";if(!Qe&&!Re)return;if(!Qe){await fe("New Chat");return}const{contentParts:Le}=await Tg(c,(de==null?void 0:de.attachments)??[]),ut=[...Le];Re!=null&&Re.trim()&&ut.push({type:"text",text:Re});const et={id:`msg-${Date.now()}`,role:"user",content:ut,createdAt:new Date().toISOString()};M(et);const Fe={threadId:Qe,checkpointId:(re==null?void 0:re.checkpointId)??j.lastCheckpointId??void 0,checkpointNs:(re==null?void 0:re.checkpointNs)??j.lastCheckpointNs??void 0};H(Fe)},[c,fe,M,j,H]),mt=b.useMemo(()=>({threads:p,currentThreadId:m,setCurrentThreadId:x,isLoading:y,error:w,actions:{createThread:fe,deleteThread:ke,renameThread:je,refreshThreads:Y}}),[p,m,y,w,fe,ke,je,Y]),it=b.useMemo(()=>({threadId:m,messages:j.messages,interrupt:null,checkpoint:{id:j.lastCheckpointId??null,namespace:j.lastCheckpointNs??null},checkpoints:D,metadata:null,isLoading:k,isHistoryLoading:z,isLoadingCheckpoint:J,error:C,hasMore:$,loadOlder:Ze,clearState:Xe,navigateToCheckpoint:Ve,setCurrentCheckpointId:Ke,returnToLatest:qe,loadThread:Be,clearThread:Xe,respondToInterrupt:ot}),[m,j,D,k,z,J,C,$,Ze,Xe,Ve,Ke,qe,Be,ot]),Ct=b.useMemo(()=>({isStreaming:ie,error:ne,connectionState:ie?"connected":"idle",submit:St,send:St,stop:te,setAuthToken:De}),[ie,ne,St,te,De]);return u.jsx(uc.Provider,{value:mt,children:u.jsx(dc.Provider,{value:it,children:u.jsx(fc.Provider,{value:Ct,children:e})})})}function Oo(){const e=b.useContext(uc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Mo(){const e=b.useContext(dc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function pc(){const e=b.useContext(fc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Do({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c}){return u.jsx(Sg,{apiConfig:t,children:u.jsx(Zg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c,children:e})})}function Q(...e){return Yh.twMerge(Gh.clsx(e))}const Qg=xo.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"}}),nt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yn.Slot:"button";return u.jsx(i,{className:Q(Qg({variant:t,size:n,className:e})),ref:s,...o})});nt.displayName="Button";const hc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:Q("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}));hc.displayName="Textarea";function mc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:p="",allowEmptySend:h=!1}){const m=i!==void 0,[x,y]=b.useState(e),g=(m?i:x)??"",[w,S]=b.useTransition(),k=b.useRef(null),T=b.useRef(0),C=b.useRef(null);b.useEffect(()=>{m||(y(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,m]);const E=b.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);b.useEffect(()=>{E()},[E,g]);const j=b.useCallback((z,{fromUser:_})=>{m||y(z),_&&(a==null||a(z))},[m,a]),N=b.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!h)return;const B=++T.current;C.current={id:B,shouldClear:!0},S(()=>{var L,D,Z;try{const J=l(_);J&&typeof J.then=="function"?J.then(()=>{var he,Ee;((he=C.current)==null?void 0:he.id)===B&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Ee=C.current)==null?void 0:Ee.id)===B&&(C.current=null)}).catch(()=>{var he;((he=C.current)==null?void 0:he.id)===B&&(C.current=null)}):(((L=C.current)==null?void 0:L.id)===B&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((D=C.current)==null?void 0:D.id)===B&&(C.current=null))}catch{((Z=C.current)==null?void 0:Z.id)===B&&(C.current=null)}})},[g,l,h,m,a]),A=b.useCallback(z=>{const _=z.target.value;j(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[j]),M=b.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),N()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[N,t,c]),R=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${p}`;return u.jsx("form",{onSubmit:z=>void N(z),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(hc,{ref:k,value:g,onChange:A,onKeyDown:M,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(nt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(se.Square,{size:16})}):u.jsx(nt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!h||w,children:u.jsx(se.Send,{size:16})})})]})})}const ex=b.memo(mc);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 gc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=gc(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():gc(e[o],null)}}}}function Ue(...e){return v.useCallback(yi(...e),e)}function tx(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,l=v.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=v.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 In(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:p,children:h,...m}=f,x=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,y=v.useMemo(()=>m,Object.values(m));return u.jsx(x.Provider,{value:y,children:h})};c.displayName=s+"Provider";function d(f,p){var x;const h=((x=p==null?void 0:p[e])==null?void 0:x[l])||a,m=v.useContext(h);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,nx(o,...t)]}function nx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var _t=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},rx=v[" useInsertionEffect ".trim().toString()]||_t;function xr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ox({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=v.useRef(e!==void 0);v.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 c=v.useCallback(d=>{var f;if(a){const p=sx(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else s(d)},[a,e,s,i]);return[l,c]}function ox({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return rx(()=>{s.current=t},[t]),v.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function sx(e){return typeof e=="function"}var ix=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=ix.reduce((e,t)=>{const n=Yn.createSlot(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function xc(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function vi(e){const t=e+"CollectionProvider",[n,r]=In(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:y,children:g}=x,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:y,itemMap:S,collectionRef:w,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Yn.createSlot(a),c=b.forwardRef((x,y)=>{const{scope:g,children:w}=x,S=s(a,g),k=Ue(y,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Yn.createSlot(d),h=b.forwardRef((x,y)=>{const{scope:g,children:w,...S}=x,k=b.useRef(null),T=Ue(y,k),C=s(d,g);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(p,{[f]:"",ref:T,children:w})});h.displayName=d;function m(x){const y=s(e+"CollectionConsumer",x);return b.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},m,r]}var ax=v.createContext(void 0);function Lo(e){const t=v.useContext(ax);return e||t||"ltr"}function Rt(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e);v.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 cx="DismissableLayer",wi="dismissableLayer.update",ux="dismissableLayer.pointerDownOutside",dx="dismissableLayer.focusOutside",yc,vc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fo=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(vc),[d,f]=v.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=v.useState({}),m=Ue(t,E=>f(E)),x=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(y),w=d?x.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=g,T=hx(E=>{const j=E.target,N=[...c.branches].some(A=>A.contains(j));!k||N||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),C=mx(E=>{const j=E.target;[...c.branches].some(A=>A.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return lx(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),wc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=yc)}},[d,p,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),wc())},[d,c]),v.useEffect(()=>{const E=()=>h({});return document.addEventListener(wi,E),()=>document.removeEventListener(wi,E)},[]),u.jsx(Ae.div,{...l,ref:m,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,T.onPointerDownCapture)})});Fo.displayName=cx;var fx="DismissableLayerBranch",px=v.forwardRef((e,t)=>{const n=v.useContext(vc),r=v.useRef(null),o=Ue(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Ae.div,{...e,ref:o})});px.displayName=fx;function hx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){bc(ux,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&bc(dx,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 wc(){const e=new CustomEvent(wi);document.dispatchEvent(e)}function bc(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?xc(o,s):o.dispatchEvent(s)}var bi=0;function Si(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sc()),document.body.insertAdjacentElement("beforeend",e[1]??Sc()),bi++,()=>{bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bi--}},[])}function Sc(){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 Ci="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",Cc={bubbles:!1,cancelable:!0},gx="FocusScope",$o=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Rt(o),d=Rt(s),f=v.useRef(null),p=Ue(t,x=>l(x)),h=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let x=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:On(f.current,{select:!0})},y=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||On(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&On(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",y);const w=new MutationObserver(g);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",y),w.disconnect()}}},[r,a,h.paused]),v.useEffect(()=>{if(a){Ec.add(h);const x=document.activeElement;if(!a.contains(x)){const g=new CustomEvent(Ci,Cc);a.addEventListener(Ci,c),a.dispatchEvent(g),g.defaultPrevented||(xx(Sx(Tc(a)),{select:!0}),document.activeElement===x&&On(a))}return()=>{a.removeEventListener(Ci,c),setTimeout(()=>{const g=new CustomEvent(Ti,Cc);a.addEventListener(Ti,d),a.dispatchEvent(g),g.defaultPrevented||On(x??document.body,{select:!0}),a.removeEventListener(Ti,d),Ec.remove(h)},0)}}},[a,c,d,h]);const m=v.useCallback(x=>{if(!n&&!r||h.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(y&&g){const w=x.currentTarget,[S,k]=yx(w);S&&k?!x.shiftKey&&g===k?(x.preventDefault(),n&&On(S,{select:!0})):x.shiftKey&&g===S&&(x.preventDefault(),n&&On(k,{select:!0})):g===w&&x.preventDefault()}},[n,r,h.paused]);return u.jsx(Ae.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});$o.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(On(r,{select:t}),document.activeElement!==n)return}function yx(e){const t=Tc(e),n=kc(t,e),r=kc(t.reverse(),e);return[n,r]}function Tc(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 kc(e,t){for(const n of e)if(!vx(n,{upTo:t}))return n}function vx(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 wx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&wx(e)&&t&&e.select()}}var Ec=bx();function bx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ic(e,t),e.unshift(t)},remove(t){var n;e=Ic(e,t),(n=e[0])==null||n.resume()}}}function Ic(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var Cx=v[" useId ".trim().toString()]||(()=>{}),Tx=0;function Nn(e){const[t,n]=v.useState(Cx());return _t(()=>{n(r=>r??String(Tx++))},[e]),t?`radix-${t}`:""}const kx=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,zo=Math.round,Bo=Math.floor,xn=e=>({x:e,y:e}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"},Ix={start:"end",end:"start"};function ki(e,t,n){return Gt(e,Mn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ei(e){return e==="x"?"y":"x"}function Ii(e){return e==="y"?"height":"width"}const Nx=new Set(["top","bottom"]);function yn(e){return Nx.has(jn(e))?"y":"x"}function Ni(e){return Ei(yn(e))}function Ax(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Ni(e),s=Ii(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ho(i)),[i,Ho(i)]}function jx(e){const t=Ho(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.replace(/start|end/g,t=>Ix[t])}const Nc=["left","right"],Ac=["right","left"],_x=["top","bottom"],Rx=["bottom","top"];function Px(e,t,n){switch(e){case"top":case"bottom":return n?t?Ac:Nc:t?Nc:Ac;case"left":case"right":return t?_x:Rx;default:return[]}}function Ox(e,t,n,r){const o=yr(e);let s=Px(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ai)))),s}function Ho(e){return e.replace(/left|right|bottom|top/g,t=>Ex[t])}function Mx(e){return{top:0,right:0,bottom:0,left:0,...e}}function jc(e){return typeof e!="number"?Mx(e):{top:e,right:e,bottom:e,left:e}}function Uo(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 _c(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Ni(t),a=Ii(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,p=r[a]/2-o[a]/2;let h;switch(l){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(yr(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const Dx=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=_c(c,r,l),p=r,h={},m=0;for(let x=0;x<a.length;x++){const{name:y,fn:g}=a[x],{x:w,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:p,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,h={...h,[y]:{...h[y],...k}},T&&m<=50&&(m++,typeof T=="object"&&(T.placement&&(p=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=_c(c,p,l)),x=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:h}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=An(t,e),m=jc(h),y=a[p?f==="floating"?"reference":"floating":f],g=Uo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=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)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Uo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(g.top-T.top+m.top)/k.y,bottom:(T.bottom-g.bottom+m.bottom)/k.y,left:(g.left-T.left+m.left)/k.x,right:(T.right-g.right+m.right)/k.x}}const Lx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const f=jc(d),p={x:n,y:r},h=Ni(o),m=Ii(h),x=await i.getDimensions(c),y=h==="y",g=y?"top":"left",w=y?"bottom":"right",S=y?"clientHeight":"clientWidth",k=s.reference[m]+s.reference[h]-p[h]-s.floating[m],T=p[h]-s.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[m]);const j=k/2-T/2,N=E/2-x[m]/2-1,A=Mn(f[g],N),M=Mn(f[w],N),F=A,$=E-x[m]-M,R=E/2-x[m]/2+j,z=ki(F,R,$),_=!l.arrow&&yr(o)!=null&&R!==z&&s.reference[m]/2-(R<F?A:M)-x[m]/2<0,B=_?R<F?R-F:R-$:0;return{[h]:p[h]+B,data:{[h]:z,centerOffset:R-z-B,..._&&{alignmentOffset:B}},reset:_}}}),Fx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...y}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=jn(o),w=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(S||!x?[Ho(a)]:jx(a)),C=m!=="none";!p&&C&&T.push(...Ox(a,x,m,k));const E=[a,...T],j=await Br(t,y),N=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&N.push(j[g]),f){const R=Ax(o,i,k);N.push(j[R[0]],j[R[1]])}if(A=[...A,{placement:o,overflows:N}],!N.every(R=>R<=0)){var M,F;const R=(((M=s.flip)==null?void 0:M.index)||0)+1,z=E[R];if(z&&(!(f==="alignment"?w!==yn(z):!1)||A.every(L=>yn(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:R,overflows:A},reset:{placement:z}};let _=(F=A.filter(B=>B.overflows[0]<=0).sort((B,L)=>B.overflows[1]-L.overflows[1])[0])==null?void 0:F.placement;if(!_)switch(h){case"bestFit":{var $;const B=($=A.filter(L=>{if(C){const D=yn(L.placement);return D===w||D==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(D=>D>0).reduce((D,Z)=>D+Z,0)]).sort((L,D)=>L[1]-D[1])[0])==null?void 0:$[0];B&&(_=B);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pc(e){return kx.some(t=>e[t]>=0)}const $x=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Rc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Pc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Rc(s,n.floating);return{data:{escapedOffsets:i,escaped:Pc(i)}}}default:return{}}}}},Oc=new Set(["left","top"]);async function zx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=yr(n),l=yn(n)==="y",c=Oc.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(h=a==="end"?m*-1:m),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const Bx=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 zx(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}}}}},Hx=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:y=>{let{x:g,y:w}=y;return{x:g,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await Br(t,l),f=yn(jn(o)),p=Ei(f);let h=c[p],m=c[f];if(s){const y=p==="y"?"top":"left",g=p==="y"?"bottom":"right",w=h+d[y],S=h-d[g];h=ki(w,h,S)}if(i){const y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",w=m+d[y],S=m-d[g];m=ki(w,m,S)}const x=a.fn({...t,[p]:h,[f]:m});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[p]:s,[f]:i}}}}}},Ux=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},f=yn(o),p=Ei(f);let h=d[p],m=d[f];const x=An(a,t),y=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+y.mainAxis,T=s.reference[p]+s.reference[S]-y.mainAxis;h<k?h=k:h>T&&(h=T)}if(c){var g,w;const S=p==="y"?"width":"height",k=Oc.has(jn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:y.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?y.crossAxis:0);m<T?m=T:m>C&&(m=C)}return{[p]:h,[f]:m}}}},Wx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await Br(t,c),f=jn(o),p=yr(o),h=yn(o)==="y",{width:m,height:x}=s.floating;let y,g;f==="top"||f==="bottom"?(y=f,g=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,y=p==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=m-d.left-d.right,k=Mn(x-d[y],w),T=Mn(m-d[g],S),C=!t.middlewareData.shift;let E=k,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!p){const A=Gt(d.left,0),M=Gt(d.right,0),F=Gt(d.top,0),$=Gt(d.bottom,0);h?j=m-2*(A!==0||M!==0?A+M:Gt(d.left,d.right)):E=x-2*(F!==0||$!==0?F+$:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const N=await i.getDimensions(a.floating);return m!==N.width||x!==N.height?{reset:{rects:!0}}:{}}}};function Wo(){return typeof window<"u"}function vr(e){return Mc(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Mc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mc(e){return Wo()?e instanceof Node||e instanceof Yt(e).Node:!1}function un(e){return Wo()?e instanceof Element||e instanceof Yt(e).Element:!1}function wn(e){return Wo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Dc(e){return!Wo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const Vx=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Vx.has(o)}const Kx=new Set(["table","td","th"]);function qx(e){return Kx.has(vr(e))}const Gx=[":popover-open",":modal"];function Vo(e){return Gx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Yx=["transform","translate","scale","rotate","perspective"],Xx=["transform","translate","scale","rotate","perspective","filter"],Jx=["paint","layout","strict","content"];function ji(e){const t=_i(),n=un(e)?dn(e):e;return Yx.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)||Xx.some(r=>(n.willChange||"").includes(r))||Jx.some(r=>(n.contain||"").includes(r))}function Zx(e){let t=Dn(e);for(;wn(t)&&!wr(t);){if(ji(t))return t;if(Vo(t))return null;t=Dn(t)}return null}function _i(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qx=new Set(["html","body","#document"]);function wr(e){return Qx.has(vr(e))}function dn(e){return Yt(e).getComputedStyle(e)}function Ko(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dc(e)&&e.host||vn(e);return Dc(t)?t.host:t}function Lc(e){const t=Dn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Hr(t)?t:Lc(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Lc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fc(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=zo(n)!==s||zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Pi(e){return un(e)?e:e.contextElement}function br(e){const t=Pi(e);if(!wn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Fc(t);let i=(s?zo(n.width):n.width)/r,a=(s?zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ey=xn(0);function $c(e){const t=Yt(e);return!_i()||!t.visualViewport?ey:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=xn(1);t&&(r?un(r)&&(i=br(r)):i=br(e));const a=ty(s,n,r)?$c(s):xn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const p=Yt(s),h=r&&un(r)?Yt(r):r;let m=p,x=Ri(m);for(;x&&r&&h!==m;){const y=br(x),g=x.getBoundingClientRect(),w=dn(x),S=g.left+(x.clientLeft+parseFloat(w.paddingLeft))*y.x,k=g.top+(x.clientTop+parseFloat(w.paddingTop))*y.y;l*=y.x,c*=y.y,d*=y.x,f*=y.y,l+=S,c+=k,m=Yt(x),x=Ri(m)}}return Uo({width:d,height:f,x:l,y:c})}function qo(e,t){const n=Ko(e).scrollLeft;return t?t.left+n:Qn(vn(e)).left+n}function zc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ny(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Vo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),f=wn(r);if((f||!f&&!s)&&((vr(r)!=="body"||Hr(i))&&(l=Ko(r)),wn(r))){const h=Qn(r);c=br(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!s?zc(i,l):xn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function ry(e){return Array.from(e.getClientRects())}function oy(e){const t=vn(e),n=Ko(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qo(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Bc=25;function sy(e,t){const n=Yt(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=_i();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=qo(r);if(c<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-h);m<=Bc&&(s-=m)}else c<=Bc&&(s+=c);return{width:s,height:i,x:a,y:l}}const iy=new Set(["absolute","fixed"]);function ay(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):xn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Hc(e,t,n){let r;if(t==="viewport")r=sy(e,n);else if(t==="document")r=oy(vn(e));else if(un(t))r=ay(t,n);else{const o=$c(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Uo(r)}function Uc(e,t){const n=Dn(e);return n===t||!un(n)||wr(n)?!1:dn(n).position==="fixed"||Uc(n,t)}function ly(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>un(a)&&vr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Dn(e):e;for(;un(i)&&!wr(i);){const a=dn(i),l=ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&iy.has(o.position)||Hr(i)&&!l&&Uc(e,i))?r=r.filter(d=>d!==i):o=a,i=Dn(i)}return t.set(e,r),r}function cy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Vo(t)?[]:ly(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Hc(t,d,o);return c.top=Gt(f.top,c.top),c.right=Mn(f.right,c.right),c.bottom=Mn(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},Hc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uy(e){const{width:t,height:n}=Fc(e);return{width:t,height:n}}function dy(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=qo(o)}if(r||!r&&!s)if((vr(t)!=="body"||Hr(o))&&(a=Ko(t)),r){const h=Qn(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?zc(o,a):xn(0),f=i.left+a.scrollLeft-l.x-d.x,p=i.top+a.scrollTop-l.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function Oi(e){return dn(e).position==="static"}function Wc(e,t){if(!wn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function Vc(e,t){const n=Yt(e);if(Vo(e))return n;if(!wn(e)){let o=Dn(e);for(;o&&!wr(o);){if(un(o)&&!Oi(o))return o;o=Dn(o)}return n}let r=Wc(e,t);for(;r&&qx(r)&&Oi(r);)r=Wc(r,t);return r&&wr(r)&&Oi(r)&&!ji(r)?n:r||Zx(e)||n}const fy=async function(e){const t=this.getOffsetParent||Vc,n=this.getDimensions,r=await n(e.floating);return{reference:dy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function py(e){return dn(e).direction==="rtl"}const hy={convertOffsetParentRelativeRectToViewportRelativeRect:ny,getDocumentElement:vn,getClippingRect:cy,getOffsetParent:Vc,getElementRects:fy,getClientRects:ry,getDimensions:uy,getScale:br,isElement:un,isRTL:py};function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function my(e,t){let n=null,r;const o=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=c;if(a||t(),!p||!h)return;const m=Bo(f),x=Bo(o.clientWidth-(d+p)),y=Bo(o.clientHeight-(f+h)),g=Bo(d),S={rootMargin:-m+"px "+-x+"px "+-y+"px "+-g+"px",threshold:Gt(0,Mn(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Kc(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function gy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Pi(e),d=o||s?[...c?Ur(c):[],...Ur(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?my(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(g=>{let[w]=g;w&&w.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(t)})),n()}),c&&!l&&h.observe(c),h.observe(t));let m,x=l?Qn(e):null;l&&y();function y(){const g=Qn(e);x&&!Kc(x,g)&&n(),x=g,m=requestAnimationFrame(y)}return n(),()=>{var g;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(m)}}const xy=Bx,yy=Hx,vy=Fx,wy=Wx,by=$x,qc=Lx,Sy=Ux,Cy=(e,t,n)=>{const r=new Map,o={platform:hy,...n},s={...o.platform,_c:r};return Dx(e,t,{...o,platform:s})};var Ty=typeof document<"u",ky=function(){},Go=Ty?b.useLayoutEffect:ky;function Yo(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(!Yo(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)&&!Yo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Yc(e,t){const n=Gc(e);return Math.round(t*n)/n}function Mi(e){const t=v.useRef(e);return Go(()=>{t.current=e}),t}function Ey(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=v.useState(r);Yo(p,r)||h(r);const[m,x]=v.useState(null),[y,g]=v.useState(null),w=v.useCallback(L=>{L!==C.current&&(C.current=L,x(L))},[]),S=v.useCallback(L=>{L!==E.current&&(E.current=L,g(L))},[]),k=s||m,T=i||y,C=v.useRef(null),E=v.useRef(null),j=v.useRef(d),N=l!=null,A=Mi(l),M=Mi(o),F=Mi(c),$=v.useCallback(()=>{if(!C.current||!E.current)return;const L={placement:t,strategy:n,middleware:p};M.current&&(L.platform=M.current),Cy(C.current,E.current,L).then(D=>{const Z={...D,isPositioned:F.current!==!1};R.current&&!Yo(j.current,Z)&&(j.current=Z,yo.flushSync(()=>{f(Z)}))})},[p,t,n,M,F]);Go(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[c]);const R=v.useRef(!1);Go(()=>(R.current=!0,()=>{R.current=!1}),[]),Go(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(A.current)return A.current(k,T,$);$()}},[k,T,$,A,N]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),B=v.useMemo(()=>{const L={position:n,left:0,top:0};if(!_.floating)return L;const D=Yc(_.floating,d.x),Z=Yc(_.floating,d.y);return a?{...L,transform:"translate("+D+"px, "+Z+"px)",...Gc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:Z}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:$,refs:z,elements:_,floatingStyles:B}),[d,$,z,_,B])}const Iy=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?qc({element:r.current,padding:o}).fn(n):{}:r?qc({element:r,padding:o}).fn(n):{}}}},Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...yy(e),options:[e,t]}),jy=(e,t)=>({...Sy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...wy(e),options:[e,t]}),Py=(e,t)=>({...by(e),options:[e,t]}),Oy=(e,t)=>({...Iy(e),options:[e,t]});var My="Arrow",Xc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Ae.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Xc.displayName=My;var Dy=Xc;function Jc(e){const[t,n]=v.useState(void 0);return _t(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Di="Popper",[Zc,Xo]=In(Di),[Ly,Qc]=Zc(Di),eu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};eu.displayName=Di;var tu="PopperAnchor",nu=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Qc(tu,n),i=v.useRef(null),a=Ue(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(Ae.div,{...o,ref:a})});nu.displayName=tu;var Li="PopperContent",[Fy,$y]=Zc(Li),ru=v.forwardRef((e,t)=>{var q,O,H,te,ie,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:h="optimized",onPlaced:m,...x}=e,y=Qc(Li,n),[g,w]=v.useState(null),S=Ue(t,De=>w(De)),[k,T]=v.useState(null),C=Jc(k),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,N=r+(s!=="center"?"-"+s:""),A=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(c)?c:[c],F=M.length>0,$={padding:A,boundary:M.filter(By),altBoundary:F},{refs:R,floatingStyles:z,placement:_,isPositioned:B,middlewareData:L}=Ey({strategy:"fixed",placement:N,whileElementsMounted:(...De)=>gy(...De,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[Ny({mainAxis:o+j,alignmentAxis:i}),l&&Ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?jy():void 0,...$}),l&&_y({...$}),Ry({...$,apply:({elements:De,rects:Y,availableWidth:fe,availableHeight:ke})=>{const{width:je,height:ze}=Y.reference,Be=De.floating.style;Be.setProperty("--radix-popper-available-width",`${fe}px`),Be.setProperty("--radix-popper-available-height",`${ke}px`),Be.setProperty("--radix-popper-anchor-width",`${je}px`),Be.setProperty("--radix-popper-anchor-height",`${ze}px`)}}),k&&Oy({element:k,padding:a}),Hy({arrowWidth:E,arrowHeight:j}),p&&Py({strategy:"referenceHidden",...$})]}),[D,Z]=iu(_),J=Rt(m);_t(()=>{B&&(J==null||J())},[B,J]);const he=(q=L.arrow)==null?void 0:q.x,Ee=(O=L.arrow)==null?void 0:O.y,Ne=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[W,ee]=v.useState();return _t(()=>{g&&ee(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:B?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:W,"--radix-popper-transform-origin":[(te=L.transformOrigin)==null?void 0:te.x,(ie=L.transformOrigin)==null?void 0:ie.y].join(" "),...((ne=L.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Fy,{scope:n,placedSide:D,onArrowChange:T,arrowX:he,arrowY:Ee,shouldHideArrow:Ne,children:u.jsx(Ae.div,{"data-side":D,"data-align":Z,...x,ref:S,style:{...x.style,animation:B?void 0:"none"}})})})});ru.displayName=Li;var ou="PopperArrow",zy={top:"bottom",right:"left",bottom:"top",left:"right"},su=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(ou,r),i=zy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(Dy,{...o,ref:n,style:{...o.style,display:"block"}})})});su.displayName=ou;function By(e){return e!==null}var Hy=e=>({name:"transformOrigin",options:e,fn(t){var y,g,w;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=iu(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,h=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let m="",x="";return c==="bottom"?(m=i?f:`${p}px`,x=`${-l}px`):c==="top"?(m=i?f:`${p}px`,x=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,x=i?f:`${h}px`):c==="left"&&(m=`${r.floating.width+l}px`,x=i?f:`${h}px`),{data:{x:m,y:x}}}});function iu(e){const[t,n="center"]=e.split("-");return[t,n]}var au=eu,lu=nu,cu=ru,uu=su,Uy="Portal",Jo=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);_t(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Js.createPortal(u.jsx(Ae.div,{...r,ref:t}),i):null});Jo.displayName=Uy;function Wy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var tn=e=>{const{present:t,children:n}=e,r=Vy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=Ue(r.ref,Ky(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};tn.displayName="Presence";function Vy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Zo(r.current);s.current=a==="mounted"?c:"none"},[a]),_t(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,h=Zo(c);e?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),_t(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const x=Zo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&x&&(l("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=h=>{h.target===t&&(s.current=Zo(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Zo(e){return(e==null?void 0:e.animationName)||"none"}function Ky(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 Fi="rovingFocusGroup.onEntryFocus",qy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[$i,du,Gy]=vi(Wr),[Yy,fu]=In(Wr,[Gy]),[Xy,Jy]=Yy(Wr),pu=v.forwardRef((e,t)=>u.jsx($i.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx($i.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Zy,{...e,ref:t})})}));pu.displayName=Wr;var Zy=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,p=v.useRef(null),h=Ue(t,p),m=Lo(s),[x,y]=xr({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[g,w]=v.useState(!1),S=Rt(c),k=du(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=p.current;if(j)return j.addEventListener(Fi,S),()=>j.removeEventListener(Fi,S)},[S]),u.jsx(Xy,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:x,onItemFocus:v.useCallback(j=>y(j),[y]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:u.jsx(Ae.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{T.current=!0}),onFocus:pe(e.onFocus,j=>{const N=!T.current;if(j.target===j.currentTarget&&N&&!g){const A=new CustomEvent(Fi,qy);if(j.currentTarget.dispatchEvent(A),!A.defaultPrevented){const M=k().filter(_=>_.focusable),F=M.find(_=>_.active),$=M.find(_=>_.id===x),z=[F,$,...M].filter(Boolean).map(_=>_.ref.current);gu(z,d)}}T.current=!1}),onBlur:pe(e.onBlur,()=>w(!1))})})}),hu="RovingFocusGroupItem",mu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nn(),c=s||l,d=Jy(hu,n),f=d.currentTabStopId===c,p=du(n),{onFocusableItemAdd:h,onFocusableItemRemove:m,currentTabStopId:x}=d;return v.useEffect(()=>{if(r)return h(),()=>m()},[r,h,m]),u.jsx($i.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:pe(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=tv(y,d.orientation,d.dir);if(g!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let S=p().filter(k=>k.focusable).map(k=>k.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const k=S.indexOf(y.currentTarget);S=d.loop?nv(S,k+1):S.slice(k+1)}setTimeout(()=>gu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});mu.displayName=hu;var Qy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ev(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tv(e,t,n){const r=ev(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qy[r]}function gu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function nv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rv=pu,ov=mu,sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,Qo=new WeakMap,es={},zi=0,xu=function(e){return e&&(e.host||xu(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xu(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})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var s=es[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(p){if(a.has(p))d(p);else try{var h=p.getAttribute(r),m=h!==null&&h!=="false",x=(Sr.get(p)||0)+1,y=(s.get(p)||0)+1;Sr.set(p,x),s.set(p,y),i.push(p),x===1&&m&&Qo.set(p,!0),y===1&&p.setAttribute(n,"true"),m||p.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",p,g)}})};return d(t),a.clear(),zi++,function(){i.forEach(function(f){var p=Sr.get(f)-1,h=s.get(f)-1;Sr.set(f,p),s.set(f,h),p||(Qo.has(f)||f.removeAttribute(r),Qo.delete(f)),h||f.removeAttribute(n)}),zi--,zi||(Sr=new WeakMap,Sr=new WeakMap,Qo=new WeakMap,es={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},bn.apply(this,arguments)};function yu(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 lv(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 ts="right-scroll-bar-position",ns="width-before-scroll-bar",cv="with-scroll-bars-hidden",uv="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function dv(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var fv=typeof window<"u"?v.useLayoutEffect:v.useEffect,vu=new WeakMap;function pv(e,t){var n=dv(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return fv(function(){var r=vu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}vu.set(n,e)},[e]),n}function hv(e){return e}function mv(e,t){t===void 0&&(t=hv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function gv(e){e===void 0&&(e={});var t=mv(null);return t.options=bn({async:!0,ssr:!1},e),t}var wu=function(e){var t=e.sideCar,n=yu(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 v.createElement(r,bn({},n))};wu.isSideCarExport=!0;function xv(e,t){return e.useMedium(t),wu}var bu=gv(),Ui=function(){},rs=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,m=e.noIsolation,x=e.inert,y=e.allowPinchZoom,g=e.as,w=g===void 0?"div":g,S=e.gapMode,k=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=p,C=pv([n,t]),E=bn(bn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:bu,removeScrollBar:c,shards:f,noRelative:h,noIsolation:m,inert:x,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),bn(bn({},E),{ref:C})):v.createElement(w,bn({},E,{className:l,ref:C}),a))});rs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},rs.classNames={fullWidth:ns,zeroRight:ts};var yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yv();return t&&e.setAttribute("nonce",t),e}function wv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function bv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Sv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vv())&&(wv(t,n),bv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cv=function(){var e=Sv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Su=function(){var e=Cv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Tv={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},kv=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[Wi(n),Wi(r),Wi(o)]},Ev=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Tv;var t=kv(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])}},Iv=Su(),Cr="data-scroll-locked",Nv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const ft=mt.slice(0,xe);mt=mt.slice(xe+2);const gt=Xg(ft);if(!gt)continue;let Tt;try{Tt=JSON.parse(gt)}catch{console.debug("[use-chat] malformed SSE:",gt.slice(0,200));continue}const Pe=Yg(Tt)?Tt.data:Tt;De=Date.now();const Kt=Pe.seq;if(Kt!==void 0){if(Kt<=Ct){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Kt,lastProcessedSeq:Ct,type:Pe.type});continue}Ct>0&&Kt>Ct+1&&((O=_==null?void 0:_.onGap)==null||O.call(_,{from:Ct,to:Kt})),Ct=Kt,T.current=Kt,y(Kt)}if(console.debug("[use-chat] received event",{seq:Pe.seq,type:Pe.type,preview:(()=>{var lt;try{return Pe.type==="message_delta"?{deltaTypes:(lt=Pe.delta)==null?void 0:lt.map(kt=>kt.type),textLen:(Pe.delta||[]).filter(kt=>kt.type==="text").map(kt=>String(kt.text||"").length)}:Pe.content||Pe.delta?{hasContent:!0}:{}}catch(kt){return{err:String(kt)}}})()}),Pe.type==="checkpoint")E.current=Pe.checkpointId??null,j.current=Pe.checkpointNs??null,m(Pe.checkpointId??null);else if(Pe.type==="state_history"){N.current=Pe;try{const kt=$r(Pe).latest;kt&&(E.current=kt.checkpointId??null,j.current=kt.checkpointNs??null,m(kt.checkpointId??null))}catch(lt){console.warn("[use-chat] Failed to hydrate state_history payload",lt)}}try{z==null||z(Pe)}catch(lt){console.error("[use-chat] Error in onEvent callback:",lt,"for event:",Pe.type)}if(Pe.type==="token"&&e.autoAppendAssistant!==!1)at.push(Pe.content),Ye();else if(Pe.type==="message_delta"){const lt=Pe.delta.filter(kt=>kt.type==="text").map(kt=>kt.text).join("");lt&&e.autoAppendAssistant!==!1&&(at.push(lt),Ye())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(H=_==null?void 0:_.onHeartbeat)==null||H.call(_,Pe)}catch(lt){console.warn("[use-chat] heartbeat callback failed",lt)}}else if(de!==null&&cancelAnimationFrame(de),re(),Pe.type==="checkpoint")m(Pe.checkpointId);else if(Pe.type==="error"){const lt=Pe;if(d(lt.message),L="error",D=lt.message,lt.error_type==="auth_error"||lt.code==="TOKEN_EXPIRED"||((te=lt.message)==null?void 0:te.includes("token"))||((ie=lt.message)==null?void 0:ie.includes("401"))||((ne=lt.message)==null?void 0:ne.includes("unauthorized"))||((Fe=lt.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",lt.message);try{(Y=_==null?void 0:_.onAuthError)==null||Y.call(_,lt.message)}catch(Kn){console.warn("[use-chat] onAuthError handler failed",Kn)}B.abort()}}}}re(),L===null&&!B.signal.aborted&&(L="complete")}catch($e){if($e.name==="AbortError")L=L??"aborted";else{const Me=$e.message||String($e);L="error",D=Me,d(Me),(fe=_==null?void 0:_.onError)==null||fe.call(_,Me)}}finally{try{await st.cancel()}catch{}finally{(ke=st.releaseLock)==null||ke.call(st)}de!==null&&typeof window<"u"&&window.cancelAnimationFrame(de),clearInterval(Xe)}}catch(Ke){if(Ke.name==="AbortError")L=L??"aborted";else{const qe=Ke.message||String(Ke);L="error",D=qe,d(qe),(je=_==null?void 0:_.onError)==null||je.call(_,qe),Z||((Be=_==null?void 0:_.onConnectionError)==null||Be.call(_,qe),Z=!0)}}finally{const Ke=T.current,qe=E.current,Ge=j.current,tt=N.current,Qe=L??(B.signal.aborted?"aborted":D?"error":"complete");try{(He=_==null?void 0:_.onClosed)==null||He.call(_,{reason:Qe,lastSeq:Ke,lastCheckpointId:qe,lastCheckpointNs:Ge,lastStateHistory:tt,error:D})}catch(st){console.warn("[use-chat] onClosed callback failed",st)}l(!1),w(!1),S.current=null,T.current=0,y(0),C.current=null}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var R;k.current=!1,(R=S.current)==null||R.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:g,stream:$,stop:F,clear:M,setToken:A}}function Yg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Xg(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
|
+
`)}const cc=200;function Jg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o,onStreamClosed:s,onConnectionError:i,onAuthError:a,onHeartbeat:l}){const c=b.useRef(null),d=b.useRef(null),f=b.useRef(new Map),h=b.useRef(null),p=b.useCallback(N=>{try{const A=globalThis.structuredClone;if(typeof A=="function")return A(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),m=b.useCallback((N,A)=>{if(!N)return;const M=f.current.get(N)??[],F=p(A),$=M.length>=cc?[...M.slice(M.length-cc+1),F]:[...M,F];f.current.set(N,$)},[p]),x=b.useCallback(N=>{N&&f.current.set(N,[])},[]),y=b.useCallback(N=>{const A=N??d.current;if(!A)return;const M=f.current.get(A);M!=null&&M.length&&M.forEach(F=>{try{n(F)}catch($){console.error("[useChatStreamingService] Failed to replay buffered event",$)}})},[n]),g=b.useCallback(N=>{var F,$,R,z,_;const A=N.seq??null;if(A!==null){const B=c.current;if(B!==null){if(A<=B)return;A>B+1&&(o==null||o({from:B,to:A}))}c.current=A}if(N.type==="thread_info"){d.current=N.threadId,h.current&&(h.current.threadIdGuess=N.threadId),x(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch(B){console.error("[useChatStreamingService] Error in onThreadInfo handler:",B)}return}if(N.type==="heartbeat"){try{l==null||l(N)}catch(B){console.error("[useChatStreamingService] Error in onHeartbeat handler:",B)}return}if(N.type==="error"){const B=N;if(B.error_type==="auth_error"||B.code==="TOKEN_EXPIRED"||((F=B.message)==null?void 0:F.includes("token"))||(($=B.message)==null?void 0:$.includes("401"))||((R=B.message)==null?void 0:R.includes("unauthorized"))||((z=B.message)==null?void 0:z.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",B.message);try{a==null||a(B.message)}catch(D){console.warn("[useChatStreamingService] onAuthError handler failed",D)}}}const M=N.threadId??(N.type==="state_history"?N.threadId:void 0)??d.current??((_=h.current)==null?void 0:_.threadIdGuess)??null;if(N.type==="state_history"&&(d.current=M??d.current),Hg(N)){N.type==="checkpoint"||N.type==="state_history"?x(M??null):m(M??null,N);try{n(N)}catch(B){console.error("[useChatStreamingService] Error in onMessageEvent handler:",B)}return}try{r==null||r(N)}catch(B){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",B)}},[m,x,n,o,t,r]),{stream:w,stop:S,isStreaming:k,error:T,setToken:C}=lc({baseUrl:e,token:void 0}),E=b.useCallback((N,A)=>{c.current=null,d.current=N.threadId??null,h.current={request:N,callbacks:A,manualStop:!1,threadIdGuess:N.threadId??null},w(N,g,{onOpen:A==null?void 0:A.onOpen,onError:M=>{var F;(F=A==null?void 0:A.onError)==null||F.call(A,M)},onGap:(A==null?void 0:A.onGap)??o,onConnectionError:M=>{var F;i==null||i(M),(F=A==null?void 0:A.onConnectionError)==null||F.call(A,M)},onAuthError:M=>{var F;a==null||a(M),(F=A==null?void 0:A.onAuthError)==null||F.call(A,M)},onHeartbeat:M=>{var F;try{l==null||l(M)}catch($){console.warn("[useChatStreamingService] onHeartbeat handler failed",$)}try{(F=A==null?void 0:A.onHeartbeat)==null||F.call(A,M)}catch($){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",$)}},onClosed:M=>{var z,_,B,L;const F=((z=h.current)==null?void 0:z.manualStop)??!1,$=d.current??((_=h.current)==null?void 0:_.threadIdGuess)??((B=M.lastStateHistory)==null?void 0:B.threadId)??null;(M.reason==="complete"||M.reason==="aborted"&&F)&&x($);const R={...M,threadId:$,manualStop:F};try{s==null||s(R)}catch(D){console.warn("[useChatStreamingService] onStreamClosed handler failed",D)}try{(L=A==null?void 0:A.onClosed)==null||L.call(A,R)}catch(D){console.warn("[useChatStreamingService] downstream onClosed handler failed",D)}h.current&&(h.current=null)}})},[x,g,a,i,l,o,s,w]),j=b.useCallback(()=>{h.current&&(h.current.manualStop=!0),S()},[S]);return b.useMemo(()=>({startStream:E,stop:j,isStreaming:k,error:T,setAuthToken:C,replayBufferedEvents:y}),[E,j,k,T,C,y])}const uc=b.createContext(null),dc=b.createContext(null),fc=b.createContext(null);b.createContext(!1);function Zg({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,checkpointMetadataCache:l}){const{api:c,baseUrl:d}=fi(),f=b.useMemo(()=>En(d),[d]),[h,p]=b.useState([]),[m,x]=b.useState(t),[y,g]=b.useState(!1),[w,S]=b.useState(null),[k,T]=b.useState(!1),[C,E]=b.useState(null),{state:j,seed:N,prepend:A,pushUser:M,onEvent:F}=ec(),[$,R]=b.useState(!1),[z,_]=b.useState(!1),[B,L]=b.useState(null),[D,Z]=b.useState([]),[J,pe]=b.useState(!1),Ee=l??Bg(),{setCacheForThread:Ne}=Ee,V=b.useRef(m),ee=b.useRef(null),U=b.useRef(!1);b.useEffect(()=>{V.current=m},[m]);const O=b.useRef(),{startStream:H,stop:te,isStreaming:ie,error:ne,setAuthToken:Fe}=Jg({baseUrl:f,onThreadInfo:de=>{if(console.log("[ChatSessionProvider] Thread info:",de.threadId),V.current===null){console.log("[ChatSessionProvider] Ignoring thread info: no active thread (new chat mode)");return}V.current!==de.threadId&&x(de.threadId)},onMessageEvent:F,onUnhandledEvent:de=>{console.warn("[ChatSessionProvider] Unhandled event:",de.type)},onAuthError:i}),Y=b.useCallback(async()=>{g(!0),S(null);try{const de=await c.listThreads();p(de??[])}catch(de){const re=String(de);S(re),s==null||s(re)}finally{g(!1)}},[c,s]),fe=b.useCallback(async de=>{try{const re=await c.createThread(de);return x(re.threadId),await Y(),re.threadId}catch(re){return s==null||s(String(re)),null}},[c,Y,s]),ke=b.useCallback(async de=>{try{await c.deleteThread(de),V.current===de&&(x(null),N([],{})),await Y()}catch(re){s==null||s(String(re))}},[c,Y,N,s]),je=b.useCallback(async(de,re)=>{try{await c.updateThread(de,re),await Y()}catch(Ye){s==null||s(String(Ye))}},[c,Y,s]),Be=b.useCallback((de,re,Ye)=>{const De=re.filter(Xe=>Xe.checkpointId).map(Xe=>({checkpointId:Xe.checkpointId,checkpointNs:Xe.checkpointNs??void 0,createdAt:Xe.createdAt??""}));console.log(`[ChatSessionProvider] Cached metadata for ${De.length} checkpoints from ${Ye}`),Ne(de,De)},[Ne]),He=b.useCallback(async(de,re)=>{if(!de)return;if(U.current){console.log("[ChatSessionProvider] Skipping thread load - cleanup in progress");return}T(!0),E(null);let Ye=!0;try{const De=await c.getStateHistory({threadId:de,checkpointId:re||void 0});if(U.current){console.log("[ChatSessionProvider] Discarding thread load - thread was cleared"),Ye=!1;return}const{checkpoints:Xe}=$r(De);Be(de,Xe,`thread load (requested: ${re})`);const Re=Xe.find($e=>$e.messages&&$e.messages.length>0)??(re?Xe.find($e=>$e.checkpointId===re):null)??Xe[0];N((Re==null?void 0:Re.messages)??[],{checkpointId:(Re==null?void 0:Re.checkpointId)??null,checkpointNs:(Re==null?void 0:Re.checkpointNs)??null}),Z(Xe),R(!!(Re!=null&&Re.nextCursor)),L((Re==null?void 0:Re.nextCursor)??null)}catch(De){if(U.current)console.log("[ChatSessionProvider] Error during thread load, but cleanup in progress - ignoring"),Ye=!1;else{const Xe=String(De);E(Xe),s==null||s(Xe)}}finally{Ye&&T(!1)}},[c,N,s,Be]);b.useEffect(()=>{O.current=He},[He]);const Ke=b.useCallback(async(de,re)=>{const Ye=V.current;if(!Ye)return;if(U.current){console.log("[ChatSessionProvider] Skipping checkpoint navigation - cleanup in progress");return}pe(!0);let De=!0;try{const Xe=await c.getStateHistory({threadId:Ye,checkpointId:de,checkpointNs:re??void 0});if(U.current){console.log("[ChatSessionProvider] Discarding checkpoint navigation - thread was cleared"),De=!1;return}const{checkpoints:Re}=$r(Xe);Be(Ye,Re,"checkpoint navigation");const $e=Re.find(Me=>Me.checkpointId===de&&(re?Me.checkpointNs===re:!0));if(!$e){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:de,checkpointNs:re});return}Z(Re),N($e.messages??[],{checkpointId:$e.checkpointId??null,checkpointNs:$e.checkpointNs??null})}catch(Xe){U.current?(console.log("[ChatSessionProvider] Error during checkpoint navigation, but cleanup in progress - ignoring"),De=!1):s==null||s(String(Xe))}finally{De&&pe(!1)}},[c,N,s,Be]),qe=b.useCallback((de,re)=>{N(j.messages,{checkpointId:de??null,checkpointNs:re??null})},[N,j.messages]),Ge=b.useCallback(async()=>{V.current&&await He(V.current)},[He]),tt=b.useCallback(async()=>{if(!V.current||!B)return;if(U.current){console.log("[ChatSessionProvider] Skipping history load - thread cleanup in progress");return}_(!0);let de=!0;try{const re=await c.getStateHistory({threadId:V.current,checkpointId:B});if(U.current){console.log("[ChatSessionProvider] Discarding history fetch - thread was cleared"),de=!1;return}const{checkpoints:Ye}=$r(re);if(Ye.length>0){const De=Ye[Ye.length-1];A((De==null?void 0:De.messages)??[]),R(!!(De!=null&&De.nextCursor)),L((De==null?void 0:De.nextCursor)??null)}}catch(re){U.current?(console.log("[ChatSessionProvider] Error during history fetch, but cleanup in progress - ignoring"),de=!1):s==null||s(String(re))}finally{de&&_(!1)}},[c,B,A,s]),Qe=b.useCallback(async()=>{U.current=!0,te(),V.current=null,ee.current=null,N([],{}),Z([]),R(!1),L(null),x(null),await Promise.resolve(),U.current=!1},[N,te]),st=b.useCallback(async(de,re,Ye)=>{const De=V.current;if(!De)throw new Error("No active thread to handle interrupt");const Xe=re?Ye??!0:!1;try{const Re={threadId:De,checkpointId:j.lastCheckpointId??void 0,checkpointNs:j.lastCheckpointNs??void 0,command:{kind:"resume",value:Xe}};H(Re)}catch(Re){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${de}:`,Re),Re}},[j.lastCheckpointId,j.lastCheckpointNs,H]);b.useEffect(()=>{Y()},[Y]),b.useEffect(()=>{var de,re;!o||!m||k||ee.current!==m&&(ee.current=m,n?(console.log("[ChatSessionProvider] Loading thread with checkpoint:",n),(de=O.current)==null||de.call(O,m,n)):(console.log("[ChatSessionProvider] Loading thread with latest checkpoint"),(re=O.current)==null||re.call(O,m)))},[o,m,k,n,r]),b.useEffect(()=>{a==null||a(m)},[m,a]);const St=b.useCallback(async(de,re)=>{const Ye=V.current,De=(de==null?void 0:de.text)??"";if(!Ye&&!De)return;if(!Ye){await fe("New Chat");return}const{contentParts:Xe}=await Tg(c,(de==null?void 0:de.attachments)??[]),Re=[...Xe];De!=null&&De.trim()&&Re.push({type:"text",text:De});const $e={id:`msg-${Date.now()}`,role:"user",content:Re,createdAt:new Date().toISOString()};M($e);const Me={threadId:Ye,checkpointId:(re==null?void 0:re.checkpointId)??j.lastCheckpointId??void 0,checkpointNs:(re==null?void 0:re.checkpointNs)??j.lastCheckpointNs??void 0};H(Me)},[c,fe,M,j,H]),mt=b.useMemo(()=>({threads:h,currentThreadId:m,setCurrentThreadId:x,isLoading:y,error:w,actions:{createThread:fe,deleteThread:ke,renameThread:je,refreshThreads:Y}}),[h,m,y,w,fe,ke,je,Y]),at=b.useMemo(()=>({threadId:m,messages:j.messages,interrupt:null,checkpoint:{id:j.lastCheckpointId??null,namespace:j.lastCheckpointNs??null},checkpoints:D,metadata:null,isLoading:k,isHistoryLoading:z,isLoadingCheckpoint:J,error:C,hasMore:$,loadOlder:tt,clearState:Qe,navigateToCheckpoint:Ke,setCurrentCheckpointId:qe,returnToLatest:Ge,loadThread:He,clearThread:Qe,respondToInterrupt:st}),[m,j,D,k,z,J,C,$,tt,Qe,Ke,qe,Ge,He,st]),Ct=b.useMemo(()=>({isStreaming:ie,error:ne,connectionState:ie?"connected":"idle",submit:St,send:St,stop:te,setAuthToken:Fe}),[ie,ne,St,te,Fe]);return u.jsx(uc.Provider,{value:mt,children:u.jsx(dc.Provider,{value:at,children:u.jsx(fc.Provider,{value:Ct,children:e})})})}function Oo(){const e=b.useContext(uc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Mo(){const e=b.useContext(dc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function hc(){const e=b.useContext(fc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Do({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c}){return u.jsx(Sg,{apiConfig:t,children:u.jsx(Zg,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,checkpointMetadataCache:c,children:e})})}function Q(...e){return Yp.twMerge(Gp.clsx(e))}const Qg=xo.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"}}),rt=v.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yn.Slot:"button";return u.jsx(i,{className:Q(Qg({variant:t,size:n,className:e})),ref:s,...o})});rt.displayName="Button";const pc=v.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:Q("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}));pc.displayName="Textarea";function mc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1}){const m=i!==void 0,[x,y]=b.useState(e),g=(m?i:x)??"",[w,S]=b.useTransition(),k=b.useRef(null),T=b.useRef(0),C=b.useRef(null);b.useEffect(()=>{m||(y(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,m]);const E=b.useCallback(()=>{const z=k.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);b.useEffect(()=>{E()},[E,g]);const j=b.useCallback((z,{fromUser:_})=>{m||y(z),_&&(a==null||a(z))},[m,a]),N=b.useCallback(async z=>{z&&z.preventDefault();const _=(g??"").trim();if(!_&&!p)return;const B=++T.current;C.current={id:B,shouldClear:!0},S(()=>{var L,D,Z;try{const J=l(_);J&&typeof J.then=="function"?J.then(()=>{var pe,Ee;((pe=C.current)==null?void 0:pe.id)===B&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((Ee=C.current)==null?void 0:Ee.id)===B&&(C.current=null)}).catch(()=>{var pe;((pe=C.current)==null?void 0:pe.id)===B&&(C.current=null)}):(((L=C.current)==null?void 0:L.id)===B&&C.current.shouldClear&&(m||(y(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((D=C.current)==null?void 0:D.id)===B&&(C.current=null))}catch{((Z=C.current)==null?void 0:Z.id)===B&&(C.current=null)}})},[g,l,p,m,a]),A=b.useCallback(z=>{const _=z.target.value;j(_,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[j]),M=b.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),N()):z.key==="Escape"&&t&&(z.preventDefault(),c==null||c())},[N,t,c]),R=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${h}`;return u.jsx("form",{onSubmit:z=>void N(z),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(pc,{ref:k,value:g,onChange:A,onKeyDown:M,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(rt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(se.Square,{size:16})}):u.jsx(rt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!p||w,children:u.jsx(se.Send,{size:16})})})]})})}const ex=b.memo(mc);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 gc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=gc(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():gc(e[o],null)}}}}function We(...e){return v.useCallback(yi(...e),e)}function tx(e,t){const n=v.createContext(t),r=s=>{const{children:i,...a}=s,l=v.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=v.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 In(e,t=[]){let n=[];function r(s,i){const a=v.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:h,children:p,...m}=f,x=((g=h==null?void 0:h[e])==null?void 0:g[l])||a,y=v.useMemo(()=>m,Object.values(m));return u.jsx(x.Provider,{value:y,children:p})};c.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,m=v.useContext(p);if(m)return m;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>v.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return v.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,nx(o,...t)]}function nx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(s)[`__scope${c}`];return{...a,...f}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var _t=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},rx=v[" useInsertionEffect ".trim().toString()]||_t;function xr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ox({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=v.useRef(e!==void 0);v.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 c=v.useCallback(d=>{var f;if(a){const h=sx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,c]}function ox({defaultProp:e,onChange:t}){const[n,r]=v.useState(e),o=v.useRef(n),s=v.useRef(t);return rx(()=>{s.current=t},[t]),v.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function sx(e){return typeof e=="function"}var ix=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ae=ix.reduce((e,t)=>{const n=Yn.createSlot(`Primitive.${t}`),r=v.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function xc(e,t){e&&yo.flushSync(()=>e.dispatchEvent(t))}function vi(e){const t=e+"CollectionProvider",[n,r]=In(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:y,children:g}=x,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:y,itemMap:S,collectionRef:w,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Yn.createSlot(a),c=b.forwardRef((x,y)=>{const{scope:g,children:w}=x,S=s(a,g),k=We(y,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Yn.createSlot(d),p=b.forwardRef((x,y)=>{const{scope:g,children:w,...S}=x,k=b.useRef(null),T=We(y,k),C=s(d,g);return b.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=d;function m(x){const y=s(e+"CollectionConsumer",x);return b.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},m,r]}var ax=v.createContext(void 0);function Lo(e){const t=v.useContext(ax);return e||t||"ltr"}function Rt(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function lx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e);v.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 cx="DismissableLayer",wi="dismissableLayer.update",ux="dismissableLayer.pointerDownOutside",dx="dismissableLayer.focusOutside",yc,vc=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fo=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=v.useContext(vc),[d,f]=v.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=v.useState({}),m=We(t,E=>f(E)),x=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=x.indexOf(y),w=d?x.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=g,T=px(E=>{const j=E.target,N=[...c.branches].some(A=>A.contains(j));!k||N||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),C=mx(E=>{const j=E.target;[...c.branches].some(A=>A.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return lx(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),v.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),wc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yc)}},[d,h,n,c]),v.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),wc())},[d,c]),v.useEffect(()=>{const E=()=>p({});return document.addEventListener(wi,E),()=>document.removeEventListener(wi,E)},[]),u.jsx(Ae.div,{...l,ref:m,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:he(e.onFocusCapture,C.onFocusCapture),onBlurCapture:he(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:he(e.onPointerDownCapture,T.onPointerDownCapture)})});Fo.displayName=cx;var fx="DismissableLayerBranch",hx=v.forwardRef((e,t)=>{const n=v.useContext(vc),r=v.useRef(null),o=We(t,r);return v.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Ae.div,{...e,ref:o})});hx.displayName=fx;function px(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){bc(ux,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=v.useRef(!1);return v.useEffect(()=>{const o=s=>{s.target&&!r.current&&bc(dx,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 wc(){const e=new CustomEvent(wi);document.dispatchEvent(e)}function bc(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?xc(o,s):o.dispatchEvent(s)}var bi=0;function Si(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Sc()),document.body.insertAdjacentElement("beforeend",e[1]??Sc()),bi++,()=>{bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),bi--}},[])}function Sc(){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 Ci="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",Cc={bubbles:!1,cancelable:!0},gx="FocusScope",$o=v.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=v.useState(null),c=Rt(o),d=Rt(s),f=v.useRef(null),h=We(t,x=>l(x)),p=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:On(f.current,{select:!0})},y=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||On(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&On(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",y);const w=new MutationObserver(g);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",y),w.disconnect()}}},[r,a,p.paused]),v.useEffect(()=>{if(a){Ec.add(p);const x=document.activeElement;if(!a.contains(x)){const g=new CustomEvent(Ci,Cc);a.addEventListener(Ci,c),a.dispatchEvent(g),g.defaultPrevented||(xx(Sx(Tc(a)),{select:!0}),document.activeElement===x&&On(a))}return()=>{a.removeEventListener(Ci,c),setTimeout(()=>{const g=new CustomEvent(Ti,Cc);a.addEventListener(Ti,d),a.dispatchEvent(g),g.defaultPrevented||On(x??document.body,{select:!0}),a.removeEventListener(Ti,d),Ec.remove(p)},0)}}},[a,c,d,p]);const m=v.useCallback(x=>{if(!n&&!r||p.paused)return;const y=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,g=document.activeElement;if(y&&g){const w=x.currentTarget,[S,k]=yx(w);S&&k?!x.shiftKey&&g===k?(x.preventDefault(),n&&On(S,{select:!0})):x.shiftKey&&g===S&&(x.preventDefault(),n&&On(k,{select:!0})):g===w&&x.preventDefault()}},[n,r,p.paused]);return u.jsx(Ae.div,{tabIndex:-1,...i,ref:h,onKeyDown:m})});$o.displayName=gx;function xx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(On(r,{select:t}),document.activeElement!==n)return}function yx(e){const t=Tc(e),n=kc(t,e),r=kc(t.reverse(),e);return[n,r]}function Tc(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 kc(e,t){for(const n of e)if(!vx(n,{upTo:t}))return n}function vx(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 wx(e){return e instanceof HTMLInputElement&&"select"in e}function On(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&wx(e)&&t&&e.select()}}var Ec=bx();function bx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ic(e,t),e.unshift(t)},remove(t){var n;e=Ic(e,t),(n=e[0])==null||n.resume()}}}function Ic(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Sx(e){return e.filter(t=>t.tagName!=="A")}var Cx=v[" useId ".trim().toString()]||(()=>{}),Tx=0;function Nn(e){const[t,n]=v.useState(Cx());return _t(()=>{n(r=>r??String(Tx++))},[e]),t?`radix-${t}`:""}const kx=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,zo=Math.round,Bo=Math.floor,xn=e=>({x:e,y:e}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"},Ix={start:"end",end:"start"};function ki(e,t,n){return Gt(e,Mn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ei(e){return e==="x"?"y":"x"}function Ii(e){return e==="y"?"height":"width"}const Nx=new Set(["top","bottom"]);function yn(e){return Nx.has(jn(e))?"y":"x"}function Ni(e){return Ei(yn(e))}function Ax(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Ni(e),s=Ii(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ho(i)),[i,Ho(i)]}function jx(e){const t=Ho(e);return[Ai(e),t,Ai(t)]}function Ai(e){return e.replace(/start|end/g,t=>Ix[t])}const Nc=["left","right"],Ac=["right","left"],_x=["top","bottom"],Rx=["bottom","top"];function Px(e,t,n){switch(e){case"top":case"bottom":return n?t?Ac:Nc:t?Nc:Ac;case"left":case"right":return t?_x:Rx;default:return[]}}function Ox(e,t,n,r){const o=yr(e);let s=Px(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ai)))),s}function Ho(e){return e.replace(/left|right|bottom|top/g,t=>Ex[t])}function Mx(e){return{top:0,right:0,bottom:0,left:0,...e}}function jc(e){return typeof e!="number"?Mx(e):{top:e,right:e,bottom:e,left:e}}function Uo(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 _c(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=Ni(t),a=Ii(i),l=jn(t),c=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(yr(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const Dx=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=_c(c,r,l),h=r,p={},m=0;for(let x=0;x<a.length;x++){const{name:y,fn:g}=a[x],{x:w,y:S,data:k,reset:T}=await g({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[y]:{...p[y],...k}},T&&m<=50&&(m++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=_c(c,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=An(t,e),m=jc(p),y=a[h?f==="floating"?"reference":"floating":f],g=Uo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=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)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=Uo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(g.top-T.top+m.top)/k.y,bottom:(T.bottom-g.bottom+m.bottom)/k.y,left:(g.left-T.left+m.left)/k.x,right:(T.right-g.right+m.right)/k.x}}const Lx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const f=jc(d),h={x:n,y:r},p=Ni(o),m=Ii(p),x=await i.getDimensions(c),y=p==="y",g=y?"top":"left",w=y?"bottom":"right",S=y?"clientHeight":"clientWidth",k=s.reference[m]+s.reference[p]-h[p]-s.floating[m],T=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[m]);const j=k/2-T/2,N=E/2-x[m]/2-1,A=Mn(f[g],N),M=Mn(f[w],N),F=A,$=E-x[m]-M,R=E/2-x[m]/2+j,z=ki(F,R,$),_=!l.arrow&&yr(o)!=null&&R!==z&&s.reference[m]/2-(R<F?A:M)-x[m]/2<0,B=_?R<F?R-F:R-$:0;return{[p]:h[p]+B,data:{[p]:z,centerOffset:R-z-B,..._&&{alignmentOffset:B}},reset:_}}}),Fx=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:x=!0,...y}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=jn(o),w=yn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=h||(S||!x?[Ho(a)]:jx(a)),C=m!=="none";!h&&C&&T.push(...Ox(a,x,m,k));const E=[a,...T],j=await Br(t,y),N=[];let A=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&N.push(j[g]),f){const R=Ax(o,i,k);N.push(j[R[0]],j[R[1]])}if(A=[...A,{placement:o,overflows:N}],!N.every(R=>R<=0)){var M,F;const R=(((M=s.flip)==null?void 0:M.index)||0)+1,z=E[R];if(z&&(!(f==="alignment"?w!==yn(z):!1)||A.every(L=>yn(L.placement)===w?L.overflows[0]>0:!0)))return{data:{index:R,overflows:A},reset:{placement:z}};let _=(F=A.filter(B=>B.overflows[0]<=0).sort((B,L)=>B.overflows[1]-L.overflows[1])[0])==null?void 0:F.placement;if(!_)switch(p){case"bestFit":{var $;const B=($=A.filter(L=>{if(C){const D=yn(L.placement);return D===w||D==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(D=>D>0).reduce((D,Z)=>D+Z,0)]).sort((L,D)=>L[1]-D[1])[0])==null?void 0:$[0];B&&(_=B);break}case"initialPlacement":_=a;break}if(o!==_)return{reset:{placement:_}}}return{}}}};function Rc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pc(e){return kx.some(t=>e[t]>=0)}const $x=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Rc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Pc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Rc(s,n.floating);return{data:{escapedOffsets:i,escaped:Pc(i)}}}default:return{}}}}},Oc=new Set(["left","top"]);async function zx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=yr(n),l=yn(n)==="y",c=Oc.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*d,y:h*c}:{x:h*c,y:p*d}}const Bx=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 zx(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}}}}},Hx=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:y=>{let{x:g,y:w}=y;return{x:g,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await Br(t,l),f=yn(jn(o)),h=Ei(f);let p=c[h],m=c[f];if(s){const y=h==="y"?"top":"left",g=h==="y"?"bottom":"right",w=p+d[y],S=p-d[g];p=ki(w,p,S)}if(i){const y=f==="y"?"top":"left",g=f==="y"?"bottom":"right",w=m+d[y],S=m-d[g];m=ki(w,m,S)}const x=a.fn({...t,[h]:p,[f]:m});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Ux=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},f=yn(o),h=Ei(f);let p=d[h],m=d[f];const x=An(a,t),y=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",k=s.reference[h]-s.floating[S]+y.mainAxis,T=s.reference[h]+s.reference[S]-y.mainAxis;p<k?p=k:p>T&&(p=T)}if(c){var g,w;const S=h==="y"?"width":"height",k=Oc.has(jn(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:y.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?y.crossAxis:0);m<T?m=T:m>C&&(m=C)}return{[h]:p,[f]:m}}}},Wx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await Br(t,c),f=jn(o),h=yr(o),p=yn(o)==="y",{width:m,height:x}=s.floating;let y,g;f==="top"||f==="bottom"?(y=f,g=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,y=h==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=m-d.left-d.right,k=Mn(x-d[y],w),T=Mn(m-d[g],S),C=!t.middlewareData.shift;let E=k,j=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const A=Gt(d.left,0),M=Gt(d.right,0),F=Gt(d.top,0),$=Gt(d.bottom,0);p?j=m-2*(A!==0||M!==0?A+M:Gt(d.left,d.right)):E=x-2*(F!==0||$!==0?F+$:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const N=await i.getDimensions(a.floating);return m!==N.width||x!==N.height?{reset:{rects:!0}}:{}}}};function Wo(){return typeof window<"u"}function vr(e){return Mc(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Mc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Mc(e){return Wo()?e instanceof Node||e instanceof Yt(e).Node:!1}function un(e){return Wo()?e instanceof Element||e instanceof Yt(e).Element:!1}function wn(e){return Wo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Dc(e){return!Wo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const Vx=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Vx.has(o)}const Kx=new Set(["table","td","th"]);function qx(e){return Kx.has(vr(e))}const Gx=[":popover-open",":modal"];function Vo(e){return Gx.some(t=>{try{return e.matches(t)}catch{return!1}})}const Yx=["transform","translate","scale","rotate","perspective"],Xx=["transform","translate","scale","rotate","perspective","filter"],Jx=["paint","layout","strict","content"];function ji(e){const t=_i(),n=un(e)?dn(e):e;return Yx.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)||Xx.some(r=>(n.willChange||"").includes(r))||Jx.some(r=>(n.contain||"").includes(r))}function Zx(e){let t=Dn(e);for(;wn(t)&&!wr(t);){if(ji(t))return t;if(Vo(t))return null;t=Dn(t)}return null}function _i(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Qx=new Set(["html","body","#document"]);function wr(e){return Qx.has(vr(e))}function dn(e){return Yt(e).getComputedStyle(e)}function Ko(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Dn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dc(e)&&e.host||vn(e);return Dc(t)?t.host:t}function Lc(e){const t=Dn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Hr(t)?t:Lc(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Lc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Fc(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=zo(n)!==s||zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Pi(e){return un(e)?e:e.contextElement}function br(e){const t=Pi(e);if(!wn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Fc(t);let i=(s?zo(n.width):n.width)/r,a=(s?zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ey=xn(0);function $c(e){const t=Yt(e);return!_i()||!t.visualViewport?ey:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ty(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=xn(1);t&&(r?un(r)&&(i=br(r)):i=br(e));const a=ty(s,n,r)?$c(s):xn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Yt(s),p=r&&un(r)?Yt(r):r;let m=h,x=Ri(m);for(;x&&r&&p!==m;){const y=br(x),g=x.getBoundingClientRect(),w=dn(x),S=g.left+(x.clientLeft+parseFloat(w.paddingLeft))*y.x,k=g.top+(x.clientTop+parseFloat(w.paddingTop))*y.y;l*=y.x,c*=y.y,d*=y.x,f*=y.y,l+=S,c+=k,m=Yt(x),x=Ri(m)}}return Uo({width:d,height:f,x:l,y:c})}function qo(e,t){const n=Ko(e).scrollLeft;return t?t.left+n:Qn(vn(e)).left+n}function zc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ny(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Vo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),f=wn(r);if((f||!f&&!s)&&((vr(r)!=="body"||Hr(i))&&(l=Ko(r)),wn(r))){const p=Qn(r);c=br(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?zc(i,l):xn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-l.scrollTop*c.y+d.y+h.y}}function ry(e){return Array.from(e.getClientRects())}function oy(e){const t=vn(e),n=Ko(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qo(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Bc=25;function sy(e,t){const n=Yt(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=_i();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=qo(r);if(c<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Bc&&(s-=m)}else c<=Bc&&(s+=c);return{width:s,height:i,x:a,y:l}}const iy=new Set(["absolute","fixed"]);function ay(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):xn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Hc(e,t,n){let r;if(t==="viewport")r=sy(e,n);else if(t==="document")r=oy(vn(e));else if(un(t))r=ay(t,n);else{const o=$c(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Uo(r)}function Uc(e,t){const n=Dn(e);return n===t||!un(n)||wr(n)?!1:dn(n).position==="fixed"||Uc(n,t)}function ly(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>un(a)&&vr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Dn(e):e;for(;un(i)&&!wr(i);){const a=dn(i),l=ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&iy.has(o.position)||Hr(i)&&!l&&Uc(e,i))?r=r.filter(d=>d!==i):o=a,i=Dn(i)}return t.set(e,r),r}function cy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Vo(t)?[]:ly(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Hc(t,d,o);return c.top=Gt(f.top,c.top),c.right=Mn(f.right,c.right),c.bottom=Mn(f.bottom,c.bottom),c.left=Gt(f.left,c.left),c},Hc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function uy(e){const{width:t,height:n}=Fc(e);return{width:t,height:n}}function dy(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=qo(o)}if(r||!r&&!s)if((vr(t)!=="body"||Hr(o))&&(a=Ko(t)),r){const p=Qn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?zc(o,a):xn(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 Oi(e){return dn(e).position==="static"}function Wc(e,t){if(!wn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function Vc(e,t){const n=Yt(e);if(Vo(e))return n;if(!wn(e)){let o=Dn(e);for(;o&&!wr(o);){if(un(o)&&!Oi(o))return o;o=Dn(o)}return n}let r=Wc(e,t);for(;r&&qx(r)&&Oi(r);)r=Wc(r,t);return r&&wr(r)&&Oi(r)&&!ji(r)?n:r||Zx(e)||n}const fy=async function(e){const t=this.getOffsetParent||Vc,n=this.getDimensions,r=await n(e.floating);return{reference:dy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hy(e){return dn(e).direction==="rtl"}const py={convertOffsetParentRelativeRectToViewportRelativeRect:ny,getDocumentElement:vn,getClippingRect:cy,getOffsetParent:Vc,getElementRects:fy,getClientRects:ry,getDimensions:uy,getScale:br,isElement:un,isRTL:hy};function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function my(e,t){let n=null,r;const o=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const m=Bo(f),x=Bo(o.clientWidth-(d+h)),y=Bo(o.clientHeight-(f+p)),g=Bo(d),S={rootMargin:-m+"px "+-x+"px "+-y+"px "+-g+"px",threshold:Gt(0,Mn(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Kc(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function gy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Pi(e),d=o||s?[...c?Ur(c):[],...Ur(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?my(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(g=>{let[w]=g;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let m,x=l?Qn(e):null;l&&y();function y(){const g=Qn(e);x&&!Kc(x,g)&&n(),x=g,m=requestAnimationFrame(y)}return n(),()=>{var g;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(g=p)==null||g.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const xy=Bx,yy=Hx,vy=Fx,wy=Wx,by=$x,qc=Lx,Sy=Ux,Cy=(e,t,n)=>{const r=new Map,o={platform:py,...n},s={...o.platform,_c:r};return Dx(e,t,{...o,platform:s})};var Ty=typeof document<"u",ky=function(){},Go=Ty?b.useLayoutEffect:ky;function Yo(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(!Yo(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)&&!Yo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Gc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Yc(e,t){const n=Gc(e);return Math.round(t*n)/n}function Mi(e){const t=v.useRef(e);return Go(()=>{t.current=e}),t}function Ey(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=v.useState(r);Yo(h,r)||p(r);const[m,x]=v.useState(null),[y,g]=v.useState(null),w=v.useCallback(L=>{L!==C.current&&(C.current=L,x(L))},[]),S=v.useCallback(L=>{L!==E.current&&(E.current=L,g(L))},[]),k=s||m,T=i||y,C=v.useRef(null),E=v.useRef(null),j=v.useRef(d),N=l!=null,A=Mi(l),M=Mi(o),F=Mi(c),$=v.useCallback(()=>{if(!C.current||!E.current)return;const L={placement:t,strategy:n,middleware:h};M.current&&(L.platform=M.current),Cy(C.current,E.current,L).then(D=>{const Z={...D,isPositioned:F.current!==!1};R.current&&!Yo(j.current,Z)&&(j.current=Z,yo.flushSync(()=>{f(Z)}))})},[h,t,n,M,F]);Go(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[c]);const R=v.useRef(!1);Go(()=>(R.current=!0,()=>{R.current=!1}),[]),Go(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(A.current)return A.current(k,T,$);$()}},[k,T,$,A,N]);const z=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),_=v.useMemo(()=>({reference:k,floating:T}),[k,T]),B=v.useMemo(()=>{const L={position:n,left:0,top:0};if(!_.floating)return L;const D=Yc(_.floating,d.x),Z=Yc(_.floating,d.y);return a?{...L,transform:"translate("+D+"px, "+Z+"px)",...Gc(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:Z}},[n,a,_.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:$,refs:z,elements:_,floatingStyles:B}),[d,$,z,_,B])}const Iy=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?qc({element:r.current,padding:o}).fn(n):{}:r?qc({element:r,padding:o}).fn(n):{}}}},Ny=(e,t)=>({...xy(e),options:[e,t]}),Ay=(e,t)=>({...yy(e),options:[e,t]}),jy=(e,t)=>({...Sy(e),options:[e,t]}),_y=(e,t)=>({...vy(e),options:[e,t]}),Ry=(e,t)=>({...wy(e),options:[e,t]}),Py=(e,t)=>({...by(e),options:[e,t]}),Oy=(e,t)=>({...Iy(e),options:[e,t]});var My="Arrow",Xc=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Ae.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Xc.displayName=My;var Dy=Xc;function Jc(e){const[t,n]=v.useState(void 0);return _t(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Di="Popper",[Zc,Xo]=In(Di),[Ly,Qc]=Zc(Di),eu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return u.jsx(Ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};eu.displayName=Di;var tu="PopperAnchor",nu=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Qc(tu,n),i=v.useRef(null),a=We(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(Ae.div,{...o,ref:a})});nu.displayName=tu;var Li="PopperContent",[Fy,$y]=Zc(Li),ru=v.forwardRef((e,t)=>{var U,O,H,te,ie,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:m,...x}=e,y=Qc(Li,n),[g,w]=v.useState(null),S=We(t,Fe=>w(Fe)),[k,T]=v.useState(null),C=Jc(k),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,N=r+(s!=="center"?"-"+s:""),A=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(c)?c:[c],F=M.length>0,$={padding:A,boundary:M.filter(By),altBoundary:F},{refs:R,floatingStyles:z,placement:_,isPositioned:B,middlewareData:L}=Ey({strategy:"fixed",placement:N,whileElementsMounted:(...Fe)=>gy(...Fe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Ny({mainAxis:o+j,alignmentAxis:i}),l&&Ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?jy():void 0,...$}),l&&_y({...$}),Ry({...$,apply:({elements:Fe,rects:Y,availableWidth:fe,availableHeight:ke})=>{const{width:je,height:Be}=Y.reference,He=Fe.floating.style;He.setProperty("--radix-popper-available-width",`${fe}px`),He.setProperty("--radix-popper-available-height",`${ke}px`),He.setProperty("--radix-popper-anchor-width",`${je}px`),He.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),k&&Oy({element:k,padding:a}),Hy({arrowWidth:E,arrowHeight:j}),h&&Py({strategy:"referenceHidden",...$})]}),[D,Z]=iu(_),J=Rt(m);_t(()=>{B&&(J==null||J())},[B,J]);const pe=(U=L.arrow)==null?void 0:U.x,Ee=(O=L.arrow)==null?void 0:O.y,Ne=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[V,ee]=v.useState();return _t(()=>{g&&ee(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:B?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(te=L.transformOrigin)==null?void 0:te.x,(ie=L.transformOrigin)==null?void 0:ie.y].join(" "),...((ne=L.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Fy,{scope:n,placedSide:D,onArrowChange:T,arrowX:pe,arrowY:Ee,shouldHideArrow:Ne,children:u.jsx(Ae.div,{"data-side":D,"data-align":Z,...x,ref:S,style:{...x.style,animation:B?void 0:"none"}})})})});ru.displayName=Li;var ou="PopperArrow",zy={top:"bottom",right:"left",bottom:"top",left:"right"},su=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=$y(ou,r),i=zy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(Dy,{...o,ref:n,style:{...o.style,display:"block"}})})});su.displayName=ou;function By(e){return e!==null}var Hy=e=>({name:"transformOrigin",options:e,fn(t){var y,g,w;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=iu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let m="",x="";return c==="bottom"?(m=i?f:`${h}px`,x=`${-l}px`):c==="top"?(m=i?f:`${h}px`,x=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,x=i?f:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:m,y:x}}}});function iu(e){const[t,n="center"]=e.split("-");return[t,n]}var au=eu,lu=nu,cu=ru,uu=su,Uy="Portal",Jo=v.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=v.useState(!1);_t(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Js.createPortal(u.jsx(Ae.div,{...r,ref:t}),i):null});Jo.displayName=Uy;function Wy(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var tn=e=>{const{present:t,children:n}=e,r=Vy(t),o=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),s=We(r.ref,Ky(o));return typeof n=="function"||r.isPresent?v.cloneElement(o,{ref:s}):null};tn.displayName="Presence";function Vy(e){const[t,n]=v.useState(),r=v.useRef(null),o=v.useRef(e),s=v.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Zo(r.current);s.current=a==="mounted"?c:"none"},[a]),_t(()=>{const c=r.current,d=o.current;if(d!==e){const h=s.current,p=Zo(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),_t(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const x=Zo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=Zo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:v.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Zo(e){return(e==null?void 0:e.animationName)||"none"}function Ky(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 Fi="rovingFocusGroup.onEntryFocus",qy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[$i,du,Gy]=vi(Wr),[Yy,fu]=In(Wr,[Gy]),[Xy,Jy]=Yy(Wr),hu=v.forwardRef((e,t)=>u.jsx($i.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx($i.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Zy,{...e,ref:t})})}));hu.displayName=Wr;var Zy=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,h=v.useRef(null),p=We(t,h),m=Lo(s),[x,y]=xr({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[g,w]=v.useState(!1),S=Rt(c),k=du(n),T=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(Fi,S),()=>j.removeEventListener(Fi,S)},[S]),u.jsx(Xy,{scope:n,orientation:r,dir:m,loop:o,currentTabStopId:x,onItemFocus:v.useCallback(j=>y(j),[y]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:u.jsx(Ae.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:he(e.onMouseDown,()=>{T.current=!0}),onFocus:he(e.onFocus,j=>{const N=!T.current;if(j.target===j.currentTarget&&N&&!g){const A=new CustomEvent(Fi,qy);if(j.currentTarget.dispatchEvent(A),!A.defaultPrevented){const M=k().filter(_=>_.focusable),F=M.find(_=>_.active),$=M.find(_=>_.id===x),z=[F,$,...M].filter(Boolean).map(_=>_.ref.current);gu(z,d)}}T.current=!1}),onBlur:he(e.onBlur,()=>w(!1))})})}),pu="RovingFocusGroupItem",mu=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nn(),c=s||l,d=Jy(pu,n),f=d.currentTabStopId===c,h=du(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:x}=d;return v.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),u.jsx($i.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Ae.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:he(e.onMouseDown,y=>{r?d.onItemFocus(c):y.preventDefault()}),onFocus:he(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:he(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const g=tv(y,d.orientation,d.dir);if(g!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let S=h().filter(k=>k.focusable).map(k=>k.ref.current);if(g==="last")S.reverse();else if(g==="prev"||g==="next"){g==="prev"&&S.reverse();const k=S.indexOf(y.currentTarget);S=d.loop?nv(S,k+1):S.slice(k+1)}setTimeout(()=>gu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});mu.displayName=pu;var Qy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ev(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function tv(e,t,n){const r=ev(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Qy[r]}function gu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function nv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rv=hu,ov=mu,sv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,Qo=new WeakMap,es={},zi=0,xu=function(e){return e&&(e.host||xu(e.parentNode))},iv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=xu(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})},av=function(e,t,n,r){var o=iv(t,Array.isArray(e)?e:[e]);es[n]||(es[n]=new WeakMap);var s=es[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);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),m=p!==null&&p!=="false",x=(Sr.get(h)||0)+1,y=(s.get(h)||0)+1;Sr.set(h,x),s.set(h,y),i.push(h),x===1&&m&&Qo.set(h,!0),y===1&&h.setAttribute(n,"true"),m||h.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",h,g)}})};return d(t),a.clear(),zi++,function(){i.forEach(function(f){var h=Sr.get(f)-1,p=s.get(f)-1;Sr.set(f,h),s.set(f,p),h||(Qo.has(f)||f.removeAttribute(r),Qo.delete(f)),p||f.removeAttribute(n)}),zi--,zi||(Sr=new WeakMap,Sr=new WeakMap,Qo=new WeakMap,es={})}},Bi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=sv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),av(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},bn.apply(this,arguments)};function yu(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 lv(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 ts="right-scroll-bar-position",ns="width-before-scroll-bar",cv="with-scroll-bars-hidden",uv="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function dv(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var fv=typeof window<"u"?v.useLayoutEffect:v.useEffect,vu=new WeakMap;function hv(e,t){var n=dv(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return fv(function(){var r=vu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}vu.set(n,e)},[e]),n}function pv(e){return e}function mv(e,t){t===void 0&&(t=pv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function gv(e){e===void 0&&(e={});var t=mv(null);return t.options=bn({async:!0,ssr:!1},e),t}var wu=function(e){var t=e.sideCar,n=yu(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 v.createElement(r,bn({},n))};wu.isSideCarExport=!0;function xv(e,t){return e.useMedium(t),wu}var bu=gv(),Ui=function(){},rs=v.forwardRef(function(e,t){var n=v.useRef(null),r=v.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,m=e.noIsolation,x=e.inert,y=e.allowPinchZoom,g=e.as,w=g===void 0?"div":g,S=e.gapMode,k=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,C=hv([n,t]),E=bn(bn({},k),o);return v.createElement(v.Fragment,null,d&&v.createElement(T,{sideCar:bu,removeScrollBar:c,shards:f,noRelative:p,noIsolation:m,inert:x,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:S}),i?v.cloneElement(v.Children.only(a),bn(bn({},E),{ref:C})):v.createElement(w,bn({},E,{className:l,ref:C}),a))});rs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},rs.classNames={fullWidth:ns,zeroRight:ts};var yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function vv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=yv();return t&&e.setAttribute("nonce",t),e}function wv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function bv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Sv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vv())&&(wv(t,n),bv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cv=function(){var e=Sv();return function(t,n){v.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Su=function(){var e=Cv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Tv={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},kv=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[Wi(n),Wi(r),Wi(o)]},Ev=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Tv;var t=kv(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])}},Iv=Su(),Cr="data-scroll-locked",Nv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
39
39
|
.`.concat(cv,` {
|
|
40
40
|
overflow: hidden `).concat(r,`;
|
|
41
41
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -72,10 +72,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
72
72
|
body[`).concat(Cr,`] {
|
|
73
73
|
`).concat(uv,": ").concat(a,`px;
|
|
74
74
|
}
|
|
75
|
-
`)},Cu=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},Av=function(){v.useEffect(function(){return document.body.setAttribute(Cr,(Cu()+1).toString()),function(){var e=Cu()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},jv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Av();var s=v.useMemo(function(){return Ev(o)},[o]);return v.createElement(Iv,{styles:Nv(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var os=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Vi=!1}var Tr=Vi?{passive:!1}:!1,_v=function(e){return e.tagName==="TEXTAREA"},Tu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_v(e)&&n[t]==="visible")},Rv=function(e){return Tu(e,"overflowY")},Pv=function(e){return Tu(e,"overflowX")},ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Eu(e,r);if(o){var s=Iu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ov=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Mv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Eu=function(e,t){return e==="v"?Rv(t):Pv(t)},Iu=function(e,t){return e==="v"?Ov(t):Mv(t)},Dv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Lv=function(e,t,n,r,o){var s=Dv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,
|
|
75
|
+
`)},Cu=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},Av=function(){v.useEffect(function(){return document.body.setAttribute(Cr,(Cu()+1).toString()),function(){var e=Cu()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},jv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Av();var s=v.useMemo(function(){return Ev(o)},[o]);return v.createElement(Iv,{styles:Nv(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var os=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",os,os),window.removeEventListener("test",os,os)}catch{Vi=!1}var Tr=Vi?{passive:!1}:!1,_v=function(e){return e.tagName==="TEXTAREA"},Tu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_v(e)&&n[t]==="visible")},Rv=function(e){return Tu(e,"overflowY")},Pv=function(e){return Tu(e,"overflowX")},ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Eu(e,r);if(o){var s=Iu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ov=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Mv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Eu=function(e,t){return e==="v"?Rv(t):Pv(t)},Iu=function(e,t){return e==="v"?Ov(t):Mv(t)},Dv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Lv=function(e,t,n,r,o){var s=Dv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Iu(e,a),m=p[0],x=p[1],y=p[2],g=x-y-s*m;(m||g)&&Eu(e,a)&&(f+=g,h+=m);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(c=!0),c},ss=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Nu=function(e){return[e.deltaX,e.deltaY]},Au=function(e){return e&&"current"in e?e.current:e},Fv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},$v=function(e){return`
|
|
76
76
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
77
77
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
78
|
-
`)},zv=0,kr=[];function Bv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(zv++)[0],s=v.useState(Su)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=lv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(x,y){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var g=ss(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-g[0],k="deltaY"in x?x.deltaY:w[1]-g[1],T,C=x.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&E==="h"&&C.type==="range")return!1;var j=ku(E,C);if(!j)return!0;if(j?T=E:(T=E==="v"?"h":"v",j=ku(E,C)),!j)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=T),!T)return!0;var N=r.current||T;return Lv(N,y,x,N==="h"?S:k)},[]),l=v.useCallback(function(x){var y=x;if(!(!kr.length||kr[kr.length-1]!==s)){var g="deltaY"in y?Nu(y):ss(y),w=t.current.filter(function(T){return T.name===y.type&&(T.target===y.target||y.target===T.shadowParent)&&Fv(T.delta,g)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(T){return T.contains(y.target)}),k=S.length>0?a(y,S[0]):!i.current.noIsolation;k&&y.cancelable&&y.preventDefault()}}},[]),c=v.useCallback(function(x,y,g,w){var S={name:x,delta:y,target:g,should:w,shadowParent:Hv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(x){n.current=ss(x),r.current=void 0},[]),f=v.useCallback(function(x){c(x.type,Nu(x),x.target,a(x,e.lockRef.current))},[]),p=v.useCallback(function(x){c(x.type,ss(x),x.target,a(x,e.lockRef.current))},[]);v.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var h=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:$v(o)}):null,h?v.createElement(jv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Uv=xv(bu,Bv);var is=v.forwardRef(function(e,t){return v.createElement(rs,bn({},e,{ref:t,sideCar:Uv}))});is.classNames=rs.classNames;var Ki=["Enter"," "],Wv=["ArrowDown","PageUp","Home"],ju=["ArrowUp","PageDown","End"],Vv=[...Wv,...ju],Kv={ltr:[...Ki,"ArrowRight"],rtl:[...Ki,"ArrowLeft"]},qv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,Gv,Yv]=vi(Vr),[er,_u]=In(Vr,[Yv,Xo,fu]),as=Xo(),Ru=fu(),[Xv,tr]=er(Vr),[Jv,qr]=er(Vr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=as(t),[l,c]=v.useState(null),d=v.useRef(!1),f=Rt(s),p=Lo(o);return v.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(Xv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Jv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};Pu.displayName=Vr;var Zv="MenuAnchor",qi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(lu,{...o,...r,ref:t})});qi.displayName=Zv;var Gi="MenuPortal",[Qv,Ou]=er(Gi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Gi,t);return u.jsx(Qv,{scope:t,forceMount:n,children:u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:r})})})};Mu.displayName=Gi;var nn="MenuContent",[ew,Yi]=er(nn),Du=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(tw,{...o,ref:t}):u.jsx(nw,{...o,ref:t})})})})}),tw=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=v.useRef(null),o=Ue(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx(Xi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nw=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(Xi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rw=Yn.createSlot("MenuContent.ScrollLock"),Xi=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,disableOutsideScroll:m,...x}=e,y=tr(nn,n),g=qr(nn,n),w=as(n),S=Ru(n),k=Gv(n),[T,C]=v.useState(null),E=v.useRef(null),j=Ue(t,E,y.onContentChange),N=v.useRef(0),A=v.useRef(""),M=v.useRef(0),F=v.useRef(null),$=v.useRef("right"),R=v.useRef(0),z=m?is:v.Fragment,_=m?{as:rw,allowPinchZoom:!0}:void 0,B=D=>{var q,O;const Z=A.current+D,J=k().filter(H=>!H.disabled),he=document.activeElement,Ee=(q=J.find(H=>H.ref.current===he))==null?void 0:q.textValue,Ne=J.map(H=>H.textValue),W=mw(Ne,Z,Ee),ee=(O=J.find(H=>H.textValue===W))==null?void 0:O.ref.current;(function H(te){A.current=te,window.clearTimeout(N.current),te!==""&&(N.current=window.setTimeout(()=>H(""),1e3))})(Z),ee&&setTimeout(()=>ee.focus())};v.useEffect(()=>()=>window.clearTimeout(N.current),[]),Si();const L=v.useCallback(D=>{var J,he;return $.current===((J=F.current)==null?void 0:J.side)&&xw(D,(he=F.current)==null?void 0:he.area)},[]);return u.jsx(ew,{scope:n,searchRef:A,onItemEnter:v.useCallback(D=>{L(D)&&D.preventDefault()},[L]),onItemLeave:v.useCallback(D=>{var Z;L(D)||((Z=E.current)==null||Z.focus(),C(null))},[L]),onTriggerLeave:v.useCallback(D=>{L(D)&&D.preventDefault()},[L]),pointerGraceTimerRef:M,onPointerGraceIntentChange:v.useCallback(D=>{F.current=D},[]),children:u.jsx(z,{..._,children:u.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,D=>{var Z;D.preventDefault(),(Z=E.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(rv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:pe(l,D=>{g.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(y.open),"data-radix-menu-content":"",dir:g.dir,...w,...x,ref:j,style:{outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,D=>{const J=D.target.closest("[data-radix-menu-content]")===D.currentTarget,he=D.ctrlKey||D.altKey||D.metaKey,Ee=D.key.length===1;J&&(D.key==="Tab"&&D.preventDefault(),!he&&Ee&&B(D.key));const Ne=E.current;if(D.target!==Ne||!Vv.includes(D.key))return;D.preventDefault();const ee=k().filter(q=>!q.disabled).map(q=>q.ref.current);ju.includes(D.key)&&ee.reverse(),pw(ee)}),onBlur:pe(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:pe(e.onPointerMove,Yr(D=>{const Z=D.target,J=R.current!==D.clientX;if(D.currentTarget.contains(Z)&&J){const he=D.clientX>R.current?"right":"left";$.current=he,R.current=D.clientX}}))})})})})})})});Du.displayName=nn;var ow="MenuGroup",Ji=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{role:"group",...r,ref:t})});Ji.displayName=ow;var sw="MenuLabel",Lu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{...r,ref:t})});Lu.displayName=sw;var ls="MenuItem",Fu="menu.itemSelect",cs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=qr(ls,e.__scopeMenu),a=Yi(ls,e.__scopeMenu),l=Ue(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(Fu,{bubbles:!0,cancelable:!0});f.addEventListener(Fu,h=>r==null?void 0:r(h),{once:!0}),xc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx($u,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:pe(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Ki.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});cs.displayName=ls;var $u=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Yi(ls,n),a=Ru(n),l=v.useRef(null),c=Ue(t,l),[d,f]=v.useState(!1),[p,h]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&h((m.textContent??"").trim())},[s.children]),u.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(ov,{asChild:!0,...a,focusable:!r,children:u.jsx(Ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:pe(e.onPointerMove,Yr(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,Yr(m=>i.onItemLeave(m))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),iw="MenuCheckboxItem",zu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(cs,{role:"menuitemcheckbox","aria-checked":us(n)?"mixed":n,...o,ref:t,"data-state":Qi(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=iw;var Bu="MenuRadioGroup",[aw,lw]=er(Bu,{value:void 0,onValueChange:()=>{}}),Hu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(aw,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ji,{...o,ref:t})})});Hu.displayName=Bu;var Uu="MenuRadioItem",Wu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=lw(Uu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qi(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Uu;var Zi="MenuItemIndicator",[Vu,cw]=er(Zi,{checked:!1}),Ku=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=cw(Zi,n);return u.jsx(tn,{present:r||us(s.checked)||s.checked===!0,children:u.jsx(Ae.span,{...o,ref:t,"data-state":Qi(s.checked)})})});Ku.displayName=Zi;var uw="MenuSeparator",qu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=uw;var dw="MenuArrow",Gu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=dw;var fw="MenuSub",[gT,Yu]=er(fw),Gr="MenuSubTrigger",Xu=v.forwardRef((e,t)=>{const n=tr(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=Yu(Gr,e.__scopeMenu),s=Yi(Gr,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>d,[d]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(qi,{asChild:!0,...c,children:u.jsx($u,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:yi(t,o.onTriggerChange),onClick:f=>{var p;(p=e.onClick)==null||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:pe(e.onPointerMove,Yr(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,Yr(f=>{var h,m;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const x=(m=n.content)==null?void 0:m.dataset.side,y=x==="right",g=y?-5:5,w=p[y?"left":"right"],S=p[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:w,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:w,y:p.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 h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Kv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Xu.displayName=Gr;var Ju="MenuSubContent",Zu=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=v.useRef(null),c=Ue(t,l);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:u.jsx(Xi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var 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 h;const f=d.currentTarget.contains(d.target),p=qv[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function us(e){return e==="indeterminate"}function Qi(e){return us(e)?"indeterminate":e?"checked":"unchecked"}function pw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function hw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function mw(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=hw(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function gw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,p=l.y;d>r!=p>r&&n<(f-c)*(r-d)/(p-d)+c&&(o=!o)}return o}function xw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return gw(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var yw=Pu,vw=qi,ww=Mu,bw=Du,Sw=Ji,Cw=Lu,Tw=cs,kw=zu,Ew=Hu,Iw=Wu,Nw=Ku,Aw=qu,jw=Gu,_w=Xu,Rw=Zu,ds="DropdownMenu",[Pw,xT]=In(ds,[_u]),zt=_u(),[Ow,ed]=Pw(ds),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=v.useRef(null),[d,f]=xr({prop:o,defaultProp:s??!1,onChange:i,caller:ds});return u.jsx(Ow,{scope:t,triggerId:Nn(),triggerRef:c,contentId:Nn(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(yw,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=ds;var nd="DropdownMenuTrigger",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=zt(n);return u.jsx(vw,{asChild:!0,...i,children:u.jsx(Ae.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:yi(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())})})})});rd.displayName=nd;var Mw="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(ww,{...r,...n})};od.displayName=Mw;var sd="DropdownMenuContent",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=zt(n),i=v.useRef(!1);return u.jsx(bw,{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,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Dw="DropdownMenuGroup",Lw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Sw,{...o,...r,ref:t})});Lw.displayName=Dw;var Fw="DropdownMenuLabel",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Cw,{...o,...r,ref:t})});ad.displayName=Fw;var $w="DropdownMenuItem",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Tw,{...o,...r,ref:t})});ld.displayName=$w;var zw="DropdownMenuCheckboxItem",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(kw,{...o,...r,ref:t})});cd.displayName=zw;var Bw="DropdownMenuRadioGroup",Hw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ew,{...o,...r,ref:t})});Hw.displayName=Bw;var Uw="DropdownMenuRadioItem",ud=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Iw,{...o,...r,ref:t})});ud.displayName=Uw;var Ww="DropdownMenuItemIndicator",dd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Nw,{...o,...r,ref:t})});dd.displayName=Ww;var Vw="DropdownMenuSeparator",fd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Aw,{...o,...r,ref:t})});fd.displayName=Vw;var Kw="DropdownMenuArrow",qw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(jw,{...o,...r,ref:t})});qw.displayName=Kw;var Gw="DropdownMenuSubTrigger",pd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(_w,{...o,...r,ref:t})});pd.displayName=Gw;var Yw="DropdownMenuSubContent",hd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Rw,{...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)"}})});hd.displayName=Yw;var Xw=td,Jw=rd,Zw=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,wd=dd,bd=fd,Sd=pd,Cd=hd;const Qw=Xw,eb=Jw,tb=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tb.displayName=Sd.displayName;const nb=v.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:Q("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}));nb.displayName=Cd.displayName;const Td=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Zw,{children:u.jsx(md,{ref:r,sideOffset:t,className:Q("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})}));Td.displayName=md.displayName;const ea=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:Q("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}));ea.displayName=xd.displayName;const rb=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(wd,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));rb.displayName=yd.displayName;const ob=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(wd,{children:u.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ob.displayName=vd.displayName;const sb=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));sb.displayName=gd.displayName;const ib=v.forwardRef(({className:e,...t},n)=>u.jsx(bd,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));ib.displayName=bd.displayName;const fs=1e4;function ab(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,`
|
|
78
|
+
`)},zv=0,kr=[];function Bv(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),o=v.useState(zv++)[0],s=v.useState(Su)[0],i=v.useRef(e);v.useEffect(function(){i.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=lv([e.lockRef.current],(e.shards||[]).map(Au),!0).filter(Boolean);return x.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=v.useCallback(function(x,y){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var g=ss(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-g[0],k="deltaY"in x?x.deltaY:w[1]-g[1],T,C=x.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&E==="h"&&C.type==="range")return!1;var j=ku(E,C);if(!j)return!0;if(j?T=E:(T=E==="v"?"h":"v",j=ku(E,C)),!j)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=T),!T)return!0;var N=r.current||T;return Lv(N,y,x,N==="h"?S:k)},[]),l=v.useCallback(function(x){var y=x;if(!(!kr.length||kr[kr.length-1]!==s)){var g="deltaY"in y?Nu(y):ss(y),w=t.current.filter(function(T){return T.name===y.type&&(T.target===y.target||y.target===T.shadowParent)&&Fv(T.delta,g)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Au).filter(Boolean).filter(function(T){return T.contains(y.target)}),k=S.length>0?a(y,S[0]):!i.current.noIsolation;k&&y.cancelable&&y.preventDefault()}}},[]),c=v.useCallback(function(x,y,g,w){var S={name:x,delta:y,target:g,should:w,shadowParent:Hv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=v.useCallback(function(x){n.current=ss(x),r.current=void 0},[]),f=v.useCallback(function(x){c(x.type,Nu(x),x.target,a(x,e.lockRef.current))},[]),h=v.useCallback(function(x){c(x.type,ss(x),x.target,a(x,e.lockRef.current))},[]);v.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(s,{styles:$v(o)}):null,p?v.createElement(jv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Uv=xv(bu,Bv);var is=v.forwardRef(function(e,t){return v.createElement(rs,bn({},e,{ref:t,sideCar:Uv}))});is.classNames=rs.classNames;var Ki=["Enter"," "],Wv=["ArrowDown","PageUp","Home"],ju=["ArrowUp","PageDown","End"],Vv=[...Wv,...ju],Kv={ltr:[...Ki,"ArrowRight"],rtl:[...Ki,"ArrowLeft"]},qv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,Gv,Yv]=vi(Vr),[er,_u]=In(Vr,[Yv,Xo,fu]),as=Xo(),Ru=fu(),[Xv,tr]=er(Vr),[Jv,qr]=er(Vr),Pu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=as(t),[l,c]=v.useState(null),d=v.useRef(!1),f=Rt(s),h=Lo(o);return v.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),u.jsx(au,{...a,children:u.jsx(Xv,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(Jv,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Pu.displayName=Vr;var Zv="MenuAnchor",qi=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(lu,{...o,...r,ref:t})});qi.displayName=Zv;var Gi="MenuPortal",[Qv,Ou]=er(Gi,{forceMount:void 0}),Mu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Gi,t);return u.jsx(Qv,{scope:t,forceMount:n,children:u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:r})})})};Mu.displayName=Gi;var nn="MenuContent",[ew,Yi]=er(nn),Du=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(tw,{...o,ref:t}):u.jsx(nw,{...o,ref:t})})})})}),tw=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=v.useRef(null),o=We(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx(Xi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nw=v.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(Xi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rw=Yn.createSlot("MenuContent.ScrollLock"),Xi=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:m,...x}=e,y=tr(nn,n),g=qr(nn,n),w=as(n),S=Ru(n),k=Gv(n),[T,C]=v.useState(null),E=v.useRef(null),j=We(t,E,y.onContentChange),N=v.useRef(0),A=v.useRef(""),M=v.useRef(0),F=v.useRef(null),$=v.useRef("right"),R=v.useRef(0),z=m?is:v.Fragment,_=m?{as:rw,allowPinchZoom:!0}:void 0,B=D=>{var U,O;const Z=A.current+D,J=k().filter(H=>!H.disabled),pe=document.activeElement,Ee=(U=J.find(H=>H.ref.current===pe))==null?void 0:U.textValue,Ne=J.map(H=>H.textValue),V=mw(Ne,Z,Ee),ee=(O=J.find(H=>H.textValue===V))==null?void 0:O.ref.current;(function H(te){A.current=te,window.clearTimeout(N.current),te!==""&&(N.current=window.setTimeout(()=>H(""),1e3))})(Z),ee&&setTimeout(()=>ee.focus())};v.useEffect(()=>()=>window.clearTimeout(N.current),[]),Si();const L=v.useCallback(D=>{var J,pe;return $.current===((J=F.current)==null?void 0:J.side)&&xw(D,(pe=F.current)==null?void 0:pe.area)},[]);return u.jsx(ew,{scope:n,searchRef:A,onItemEnter:v.useCallback(D=>{L(D)&&D.preventDefault()},[L]),onItemLeave:v.useCallback(D=>{var Z;L(D)||((Z=E.current)==null||Z.focus(),C(null))},[L]),onTriggerLeave:v.useCallback(D=>{L(D)&&D.preventDefault()},[L]),pointerGraceTimerRef:M,onPointerGraceIntentChange:v.useCallback(D=>{F.current=D},[]),children:u.jsx(z,{..._,children:u.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:he(s,D=>{var Z;D.preventDefault(),(Z=E.current)==null||Z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:u.jsx(rv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:he(l,D=>{g.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(cu,{role:"menu","aria-orientation":"vertical","data-state":Qu(y.open),"data-radix-menu-content":"",dir:g.dir,...w,...x,ref:j,style:{outline:"none",...x.style},onKeyDown:he(x.onKeyDown,D=>{const J=D.target.closest("[data-radix-menu-content]")===D.currentTarget,pe=D.ctrlKey||D.altKey||D.metaKey,Ee=D.key.length===1;J&&(D.key==="Tab"&&D.preventDefault(),!pe&&Ee&&B(D.key));const Ne=E.current;if(D.target!==Ne||!Vv.includes(D.key))return;D.preventDefault();const ee=k().filter(U=>!U.disabled).map(U=>U.ref.current);ju.includes(D.key)&&ee.reverse(),hw(ee)}),onBlur:he(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(N.current),A.current="")}),onPointerMove:he(e.onPointerMove,Yr(D=>{const Z=D.target,J=R.current!==D.clientX;if(D.currentTarget.contains(Z)&&J){const pe=D.clientX>R.current?"right":"left";$.current=pe,R.current=D.clientX}}))})})})})})})});Du.displayName=nn;var ow="MenuGroup",Ji=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{role:"group",...r,ref:t})});Ji.displayName=ow;var sw="MenuLabel",Lu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{...r,ref:t})});Lu.displayName=sw;var ls="MenuItem",Fu="menu.itemSelect",cs=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=qr(ls,e.__scopeMenu),a=Yi(ls,e.__scopeMenu),l=We(t,s),c=v.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Fu,{bubbles:!0,cancelable:!0});f.addEventListener(Fu,p=>r==null?void 0:r(p),{once:!0}),xc(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx($u,{...o,ref:l,disabled:n,onClick:he(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:he(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:he(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Ki.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});cs.displayName=ls;var $u=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Yi(ls,n),a=Ru(n),l=v.useRef(null),c=We(t,l),[d,f]=v.useState(!1),[h,p]=v.useState("");return v.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),u.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:u.jsx(ov,{asChild:!0,...a,focusable:!r,children:u.jsx(Ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:he(e.onPointerMove,Yr(m=>{r?i.onItemLeave(m):(i.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:he(e.onPointerLeave,Yr(m=>i.onItemLeave(m))),onFocus:he(e.onFocus,()=>f(!0)),onBlur:he(e.onBlur,()=>f(!1))})})})}),iw="MenuCheckboxItem",zu=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Vu,{scope:e.__scopeMenu,checked:n,children:u.jsx(cs,{role:"menuitemcheckbox","aria-checked":us(n)?"mixed":n,...o,ref:t,"data-state":Qi(n),onSelect:he(o.onSelect,()=>r==null?void 0:r(us(n)?!0:!n),{checkForDefaultPrevented:!1})})})});zu.displayName=iw;var Bu="MenuRadioGroup",[aw,lw]=er(Bu,{value:void 0,onValueChange:()=>{}}),Hu=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(aw,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ji,{...o,ref:t})})});Hu.displayName=Bu;var Uu="MenuRadioItem",Wu=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=lw(Uu,e.__scopeMenu),s=n===o.value;return u.jsx(Vu,{scope:e.__scopeMenu,checked:s,children:u.jsx(cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Qi(s),onSelect:he(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Wu.displayName=Uu;var Zi="MenuItemIndicator",[Vu,cw]=er(Zi,{checked:!1}),Ku=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=cw(Zi,n);return u.jsx(tn,{present:r||us(s.checked)||s.checked===!0,children:u.jsx(Ae.span,{...o,ref:t,"data-state":Qi(s.checked)})})});Ku.displayName=Zi;var uw="MenuSeparator",qu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ae.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});qu.displayName=uw;var dw="MenuArrow",Gu=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=as(n);return u.jsx(uu,{...o,...r,ref:t})});Gu.displayName=dw;var fw="MenuSub",[gT,Yu]=er(fw),Gr="MenuSubTrigger",Xu=v.forwardRef((e,t)=>{const n=tr(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=Yu(Gr,e.__scopeMenu),s=Yi(Gr,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>d,[d]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(qi,{asChild:!0,...c,children:u.jsx($u,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Qu(n.open),...e,ref:yi(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,Yr(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,Yr(f=>{var p,m;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(m=n.content)==null?void 0:m.dataset.side,y=x==="right",g=y?-5:5,w=h[y?"left":"right"],S=h[y?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,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===" "||Kv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Xu.displayName=Gr;var Ju="MenuSubContent",Zu=v.forwardRef((e,t)=>{const n=Ou(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=qr(nn,e.__scopeMenu),a=Yu(Ju,e.__scopeMenu),l=v.useRef(null),c=We(t,l);return u.jsx(Kr.Provider,{scope:e.__scopeMenu,children:u.jsx(tn,{present:r||s.open,children:u.jsx(Kr.Slot,{scope:e.__scopeMenu,children:u.jsx(Xi,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var 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=qv[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Zu.displayName=Ju;function Qu(e){return e?"open":"closed"}function us(e){return e==="indeterminate"}function Qi(e){return us(e)?"indeterminate":e?"checked":"unchecked"}function hw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function pw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function mw(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=pw(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function gw(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-c)*(r-d)/(h-d)+c&&(o=!o)}return o}function xw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return gw(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var yw=Pu,vw=qi,ww=Mu,bw=Du,Sw=Ji,Cw=Lu,Tw=cs,kw=zu,Ew=Hu,Iw=Wu,Nw=Ku,Aw=qu,jw=Gu,_w=Xu,Rw=Zu,ds="DropdownMenu",[Pw,xT]=In(ds,[_u]),zt=_u(),[Ow,ed]=Pw(ds),td=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=v.useRef(null),[d,f]=xr({prop:o,defaultProp:s??!1,onChange:i,caller:ds});return u.jsx(Ow,{scope:t,triggerId:Nn(),triggerRef:c,contentId:Nn(),open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:a,children:u.jsx(yw,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};td.displayName=ds;var nd="DropdownMenuTrigger",rd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ed(nd,n),i=zt(n);return u.jsx(vw,{asChild:!0,...i,children:u.jsx(Ae.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:yi(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())})})})});rd.displayName=nd;var Mw="DropdownMenuPortal",od=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(ww,{...r,...n})};od.displayName=Mw;var sd="DropdownMenuContent",id=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ed(sd,n),s=zt(n),i=v.useRef(!1);return u.jsx(bw,{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,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});id.displayName=sd;var Dw="DropdownMenuGroup",Lw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Sw,{...o,...r,ref:t})});Lw.displayName=Dw;var Fw="DropdownMenuLabel",ad=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Cw,{...o,...r,ref:t})});ad.displayName=Fw;var $w="DropdownMenuItem",ld=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Tw,{...o,...r,ref:t})});ld.displayName=$w;var zw="DropdownMenuCheckboxItem",cd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(kw,{...o,...r,ref:t})});cd.displayName=zw;var Bw="DropdownMenuRadioGroup",Hw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Ew,{...o,...r,ref:t})});Hw.displayName=Bw;var Uw="DropdownMenuRadioItem",ud=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Iw,{...o,...r,ref:t})});ud.displayName=Uw;var Ww="DropdownMenuItemIndicator",dd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Nw,{...o,...r,ref:t})});dd.displayName=Ww;var Vw="DropdownMenuSeparator",fd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Aw,{...o,...r,ref:t})});fd.displayName=Vw;var Kw="DropdownMenuArrow",qw=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(jw,{...o,...r,ref:t})});qw.displayName=Kw;var Gw="DropdownMenuSubTrigger",hd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(_w,{...o,...r,ref:t})});hd.displayName=Gw;var Yw="DropdownMenuSubContent",pd=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(Rw,{...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)"}})});pd.displayName=Yw;var Xw=td,Jw=rd,Zw=od,md=id,gd=ad,xd=ld,yd=cd,vd=ud,wd=dd,bd=fd,Sd=hd,Cd=pd;const Qw=Xw,eb=Jw,tb=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Sd,{ref:o,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(se.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tb.displayName=Sd.displayName;const nb=v.forwardRef(({className:e,...t},n)=>u.jsx(Cd,{ref:n,className:Q("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}));nb.displayName=Cd.displayName;const Td=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Zw,{children:u.jsx(md,{ref:r,sideOffset:t,className:Q("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})}));Td.displayName=md.displayName;const ea=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(xd,{ref:r,className:Q("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}));ea.displayName=xd.displayName;const rb=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(yd,{ref:o,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(wd,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),t]}));rb.displayName=yd.displayName;const ob=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(vd,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(wd,{children:u.jsx(se.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ob.displayName=vd.displayName;const sb=v.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(gd,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));sb.displayName=gd.displayName;const ib=v.forwardRef(({className:e,...t},n)=>u.jsx(bd,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));ib.displayName=bd.displayName;const fs=1e4;function ab(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,`
|
|
79
79
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
80
80
|
|
|
81
81
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -83,24 +83,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
83
83
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
84
84
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
85
85
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
86
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function lb(e,t=fs){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 cb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),lb(t),ab(t)}const ps=0,Ln=1,Er=2,kd=4;function Ed(e){return()=>e}function ub(e){e()}function Id(e,t){return n=>e(t(n))}function Nd(e,t){return()=>e(t)}function db(e,t){return n=>e(t,n)}function ta(e){return e!==void 0}function fb(...e){return()=>{e.map(ub)}}function Ir(){}function hs(e,t){return t(e),e}function pb(e,t){return t(e)}function pt(...e){return e}function rt(e,t){return e(Ln,t)}function Oe(e,t){e(ps,t)}function na(e){e(Er)}function bt(e){return e(kd)}function me(e,t){return rt(e,db(t,ps))}function fn(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ad(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function jd(e,t){return e===t}function ht(e=jd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ce(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Id(t,e)}function Sn(e){return t=>()=>{t(e)}}function U(e,...t){const n=hb(...t);return(r,o)=>{switch(r){case Er:na(e);return;case Ln:return rt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Me(...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);rt(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function hb(...e){return t=>e.reduceRight(pb,t)}function mb(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=rt(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function X(e){let t=e;const n=We();return(r,o)=>{switch(r){case ps:t=o;break;case Ln:{o(t);break}case kd:return t}return n(r,o)}}function Dt(e,t){return hs(X(t),n=>me(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case ps:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return hs(We(),t=>me(e,t))}function Je(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:gb(),singleton:n}}const gb=()=>Symbol();function xb(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 It(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);rt(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Er:{na(t);return}case Ln:return r===o&&i(n),rt(t,i)}}}function Se(e,t=jd){return U(e,ht(t))}function ra(...e){return function(t,n){switch(t){case Er:return;case Ln:return fb(...e.map(r=>rt(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 yb={0:"debug",3:"error",1:"log",2:"warn"},vb=()=>typeof globalThis>"u"?window:globalThis,Fn=Je(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=vb().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[yb[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return oa(e,t,n).callbackRef}function oa(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function wb(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=bb(d.children,t,a?"offsetWidth":"offsetHeight",o);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const h=p.lastElementChild.dataset.viewportType==="window";let m;h&&(m=p.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:h?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,y=i?a?i.scrollWidth:i.scrollHeight:h?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:h?a?m.innerWidth:m.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:y,scrollTop:Math.max(x,0),viewportHeight:g}),s==null||s(a?_d("column-gap",getComputedStyle(d).columnGap,o):_d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return oa(c,n,l)}function bb(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===c)continue;const 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 _d(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 Rd(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(t){const h=t.getBoundingClientRect(),m=c.top-h.top;p=h.height-Math.max(0,m),f=m+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;p=h.innerHeight-Math.max(0,c.top),f=c.top+h.scrollY}r.current={offsetTop:f,visibleHeight:p,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=oa(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Bt=Je(()=>{const e=We(),t=We(),n=X(0),r=We(),o=X(0),s=We(),i=We(),a=X(0),l=X(0),c=X(0),d=X(0),f=We(),p=We(),h=X(!1),m=X(!1),x=X(!1);return me(U(e,ce(({scrollTop:y})=>y)),t),me(U(e,ce(({scrollHeight:y})=>y)),i),me(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:m,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Xr={lvl:0};function Pd(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 lt(e){return e===Xr}function Jr(e,t){if(!lt(e))return t===e.k?e.v:t<e.k?Jr(e.l,t):Jr(e.r,t)}function pn(e,t,n="k"){if(lt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Jt(e,t,n){return lt(e)?Dd(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Ld(Nt(e,{l:Jt(e.l,t,n)})):Ld(Nt(e,{r:Jt(e.r,t,n)}))}function Nr(){return Xr}function ms(e,t,n){if(lt(e))return[];const r=pn(e,t)[0];return Sb(ia(e,r,n))}function sa(e,t){if(lt(e))return Xr;const{k:n,l:r,r:o}=e;if(t===n){if(lt(r))return o;if(lt(o))return r;{const[s,i]=Md(r);return gs(Nt(e,{k:s,l:Od(r),v:i}))}}else return t<n?gs(Nt(e,{l:sa(r,t)})):gs(Nt(e,{r:sa(o,t)}))}function or(e){return lt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ia(e,t,n){if(lt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ia(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ia(s,t,n))),a}function gs(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(aa(t))return Fd(Nt(e,{lvl:n-1}));if(!lt(t)&&!lt(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(aa(e))return la(Nt(e,{lvl:n-1}));if(!lt(r)&&!lt(r.l)){const o=r.l,s=aa(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:la(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return Dd(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 Od(e){return lt(e.r)?e.l:gs(Nt(e,{r:Od(e.r)}))}function aa(e){return lt(e)||e.lvl>e.r.lvl}function Md(e){return lt(e.r)?[e.k,e.v]:Md(e.r)}function Dd(e,t,n,r=Xr,o=Xr){return{k:e,l:r,lvl:n,r:o,v:t}}function Ld(e){return la(Fd(e))}function Fd(e){const{l:t}=e;return!lt(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function la(e){const{lvl:t,r:n}=e;return!lt(n)&&!lt(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Sb(e){return Pd(e,({k:t,v:n})=>({index:t,value:n}))}function $d(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Zr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ca=Je(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function zd(e,t,n){return e[xs(e,t,n)]}function xs(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 Cb(e,t,n,r){const o=xs(e,t,r),s=xs(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ys(e){return!lt(e.groupOffsetTree)}function ua({index:e},t){return t===e?0:t<e?-1:1}function Tb(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function kb(e,t){let n=lt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),lt(e)){e=Jt(e,0,s);continue}const a=ms(e,i-1,o+1);if(a.some(Rb(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:p}of a)l?(o>=f||s===p)&&(e=sa(e,f)):(c=p!==s,l=!0),d>o&&o>=f&&p!==s&&(e=Jt(e,o+1,p));c&&(e=Jt(e,i,s))}return[e,n]}function Eb(e){return typeof e.groupIndex<"u"}function Ib({offset:e},t){return t===e?0:t<e?-1:1}function Qr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=zd(t,e,ua),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Bd(e,t){if(!ys(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Hd(e,t,n){if(Eb(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Bd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Nb(e,t,n,r=0){return r>0&&(t=Math.max(t,zd(e,r,ua).offset)),Pd(Cb(e,t,n,Ib),_b)}function Ab(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&<(s)&&t.length===2){const p=t[0].size,h=t[1].size;i=n.reduce((m,x)=>Jt(Jt(m,x,p),x+1,h),i)}else[i,a]=kb(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,h)=>Jt(p,h,Qr(h,f,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function jb(e){return or(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Ud(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 da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=xs(o,t-1,ua),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of ms(n,t,1/0)){const f=c-s,p=f*i+a+f*r;o.push({index:c,offset:p,size:d}),s=c,a=p,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function _b(e){return{index:e.index,value:e}}function Rb(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 Pb={offsetHeight:"height",offsetWidth:"width"},Tn=Je(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=Dt(r,0),s=We(),i=We(),a=X(0),l=X([]),c=X(void 0),d=X(void 0),f=X((T,C)=>$n(T,Pb[C])),p=X(void 0),h=X(0),m=Tb(),x=Dt(U(n,Me(l,e,h),Cn(Ab,m),ht()),m),y=Dt(U(l,ht(),Cn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ce(({prev:T})=>T)),[]);me(U(l,Ce(T=>T.length>0),Me(x,h),ce(([T,C,E])=>{const j=T.reduce((N,A,M)=>Jt(N,A,Qr(A,C.offsetTree,E)||M),Nr());return{...C,groupIndices:T,groupOffsetTree:j}})),x),me(U(r,Me(x),Ce(([T,{lastIndex:C}])=>T<C),ce(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),me(c,d);const g=Dt(U(c,ce(T=>T===void 0)),!0);me(U(d,Ce(T=>T!==void 0&<(bt(x).sizeTree)),ce(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Xt(U(n,Me(x),Cn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:m}),ce(T=>T.changed)));rt(U(a,Cn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ce(T=>T.diff)),T=>{const{groupIndices:C}=bt(x);if(T>0)Oe(t,!0),Oe(s,T+Ud(T,C));else if(T<0){const E=bt(y);E.length>0&&(T-=Ud(-T,E)),Oe(i,T)}}),rt(U(a,Me(e)),([T,C])=>{T<0&&C("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=Xt(s);me(U(s,Me(x),ce(([T,C])=>{const E=C.groupIndices.length>0,j=[],N=C.lastSize;if(E){const A=Jr(C.sizeTree,0);let M=0,F=0;for(;M<T;){const R=C.groupIndices[F],z=C.groupIndices.length===F+1?1/0:C.groupIndices[F+1]-R-1;j.push({endIndex:R,size:A,startIndex:R}),j.push({endIndex:R+1+z-1,size:N,startIndex:R+1}),F++,M+=z+1}const $=or(C.sizeTree);return M!==T&&$.shift(),$.reduce((R,{k:z,v:_})=>{let B=R.ranges;return R.prevSize!==0&&(B=[...R.ranges,{endIndex:z+T-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:B}},{prevIndex:T,prevSize:0,ranges:j}).ranges}return or(C.sizeTree).reduce((A,{k:M,v:F})=>({prevIndex:M+T,prevSize:F,ranges:[...A.ranges,{endIndex:M+T-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:N,ranges:[]}).ranges})),n);const k=Xt(U(i,Me(x,h),ce(([T,{offsetTree:C},E])=>{const j=-T;return Qr(j,C,E)})));return me(U(i,Me(x,h),ce(([T,C,E])=>{if(C.groupIndices.length>0){if(lt(C.sizeTree))return C;let j=Nr();const N=bt(y);let A=0,M=0,F=0;for(;A<-T;){F=N[M];const $=N[M+1]-F-1;M++,A+=$+1}if(j=or(C.sizeTree).reduce(($,{k:R,v:z})=>Jt($,Math.max(0,R+T),z),j),A!==-T){const $=Jr(C.sizeTree,F);j=Jt(j,0,$);const R=pn(C.sizeTree,-T+1)[1];j=Jt(j,1,R)}return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}else{const j=or(C.sizeTree).reduce((N,{k:A,v:M})=>Jt(N,Math.max(0,A+T),M),Nr());return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}})),x),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},pt(Fn,ca),{singleton:!0});function Ob(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Wd=Je(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=Xt(U(s,ce(Ob)));return me(U(a,ce(l=>l.totalCount)),n),me(U(a,ce(l=>l.groupIndices)),e),me(U(It(o,t,r),Ce(([l,c])=>ys(c)),ce(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ht(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},pt(Tn,Bt)),zn=Je(([{log:e}])=>{const t=X(!1),n=Xt(U(t,Ce(r=>r),ht()));return rt(t,r=>{r&&bt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},pt(Fn),{singleton:!0}),Mb=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Vd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Mb)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const eo=Je(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:p}])=>{const h=We(),m=We(),x=X(0);let y=null,g=null,w=null;function S(){y&&(y(),y=null),w&&(w(),w=null),g&&(clearTimeout(g),g=null),Oe(l,!1)}return me(U(h,Me(n,f,r,x,a,i,p),Me(e,s,o),ce(([[k,T,C,E,j,N,A,M],F,$,R])=>{const z=Vd(k),{align:_,behavior:B,offset:L}=z,D=E-1,Z=Hd(z,T,D);let J=Qr(Z,T.offsetTree,F)+N;_==="end"?(J+=$+pn(T.sizeTree,Z)[1]-C+R,Z===D&&(J+=A)):_==="center"?J+=($+pn(T.sizeTree,Z)[1]-C+R)/2:J-=j,L&&(J+=L);const he=Ee=>{S(),Ee?(M("retrying to scroll to",{location:k},Vt.DEBUG),Oe(h,k)):(Oe(m,!0),M("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),B==="smooth"){let Ee=!1;w=rt(t,Ne=>{Ee=Ee||Ne}),y=fn(d,()=>{he(Ee)})}else y=fn(U(t,Db(150)),he);return g=setTimeout(()=>{S()},1200),Oe(l,!0),M("scrolling from index to",{behavior:B,index:Z,top:J},Vt.DEBUG),{behavior:B,top:J}})),c),{scrollTargetReached:m,scrollToIndex:h,topListHeight:x}},pt(Tn,Bt,Fn),{singleton:!0});function Db(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function fa(e,t){e==0?t():requestAnimationFrame(()=>{fa(e-1,t)})}function pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const to=Je(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),c=X(!0);return me(U(i,Me(l),Ce(([d,f])=>!!f),Sn(!1)),a),me(U(i,Me(l),Ce(([d,f])=>!!f),Sn(!1)),c),rt(U(It(t,i),Me(a,n,e,c),Ce(([[,d],f,{sizeTree:p},h,m])=>d&&(!lt(p)||ta(h))&&!f&&!m),Me(l)),([,d])=>{fn(o,()=>{Oe(c,!0)}),fa(4,()=>{fn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},pt(Tn,Bt,eo,zn),{singleton:!0});function Kd(e,t){return Math.abs(e-t)<1.01}const no="up",ro="down",Lb="none",Fb={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$b=0,oo=Je(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=We(),c=We(),d=X(4),f=X($b),p=Dt(U(ra(U(Se(o),nr(1),Sn(!0)),U(Se(o),nr(1),Sn(!1),Ad(100))),ht()),!1),h=Dt(U(ra(U(n,Sn(!0)),U(n,Sn(!1),Ad(200))),ht()),!1);me(U(It(Se(o),Se(f)),ce(([w,S])=>w<=S),ht()),a),me(U(a,_n(50)),c);const m=Xt(U(It(r,Se(s),Se(t),Se(e),Se(d)),Cn((w,[{scrollHeight:S,scrollTop:k},T,C,E,j])=>{const N=k+T-S>-j,A={scrollHeight:S,scrollTop:k,viewportHeight:T};if(N){let F,$;return k>w.state.scrollTop?(F="SCROLLED_DOWN",$=w.state.scrollTop-k):(F="SIZE_DECREASED",$=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:$,state:A}}let M;return A.scrollHeight>w.state.scrollHeight?M="SIZE_INCREASED":T<w.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:A}},Fb),ht((w,S)=>w&&w.atBottom===S.atBottom))),x=Dt(U(r,Cn((w,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Kd(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return w.scrollTop!==k&&C?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ce(w=>w.changed),ce(w=>w.jump)),0);me(U(m,ce(w=>w.atBottom)),i),me(U(i,_n(50)),l);const y=X(ro);me(U(r,ce(({scrollTop:w})=>w),ht(),Cn((w,S)=>bt(h)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?no:ro,prevScrollTop:S},{direction:ro,prevScrollTop:0}),ce(w=>w.direction)),y),me(U(r,_n(50),Sn(Lb)),y);const g=X(0);return me(U(p,Ce(w=>!w),Sn(0)),g),me(U(o,_n(100),Me(p),Ce(([w,S])=>!!S),Cn(([w,S],[k])=>[S,k],[0,0]),ce(([w,S])=>S-w)),g),{atBottomState:m,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:x,scrollDirection:y,scrollVelocity:g}},pt(Bt)),vs="top",ws="bottom",qd="none";function Gd(e,t,n){return typeof e=="number"?n===no&&t===vs||n===ro&&t===ws?e:0:n===no?t===vs?e.main:e.reverse:t===ws?e.main:e.reverse}function Yd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ha=Je(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=X(0),a=X(0),l=X(0),c=Dt(U(It(Se(r),Se(o),Se(n),Se(s,Zr),Se(l),Se(i),Se(t),Se(e),Se(a)),ce(([d,f,p,[h,m],x,y,g,w,S])=>{const k=d-w,T=y+g,C=Math.max(p-k,0);let E=qd;const j=Yd(S,vs),N=Yd(S,ws);return h-=w,h+=p+g,m+=p+g,m-=w,h>d+T-j&&(E=no),m<d-C+f+N&&(E=ro),E!==qd?[Math.max(k-p-Gd(x,vs,E)-j,0),k-C-g+f+Gd(x,ws,E)+N]:null}),Ce(d=>d!=null),ht(Zr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},pt(Bt),{singleton:!0});function zb(e,t,n){if(ys(t)){const r=Bd(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const ma={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function bs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,p=a+f*l+(f-1)*r,h=c,m=p-d;return{bottom:d,firstItemIndex:s,items:Jd(e,o,s),offsetBottom:m,offsetTop:c,top:h,topItems:Jd(t,o,s),topListHeight:t.reduce((x,y)=>y.size+x,0),totalCount:n}}function Xd(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=pa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return bs(c,[],a,o,n,r)}function Jd(e,t,n){if(e.length===0)return[];if(!ys(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=ms(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const sr=Je(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},p,{didMount:h},{recalcInProgress:m}])=>{const x=X([]),y=X(0),g=We();me(s.topItemsIndexes,x);const w=Dt(U(It(h,m,Se(l,Zr),Se(o),Se(r),Se(c),d,Se(x),Se(t),Se(n),e),Ce(([C,E,,j,,,,,,,N])=>{const A=N&&N.length!==j;return C&&!E&&!A}),ce(([,,[C,E],j,N,A,M,F,$,R,z])=>{const _=N,{offsetTree:B,sizeTree:L}=_,D=bt(y);if(j===0)return{...ma,totalCount:j};if(C===0&&E===0)return D===0?{...ma,totalCount:j}:Xd(D,A,N,$,R,z||[]);if(lt(L))return D>0?null:bs(zb(pa(A,j),_,z),[],j,R,_,$);const Z=[];if(F.length>0){const W=F[0],ee=F[F.length-1];let q=0;for(const O of ms(L,W,ee)){const H=O.value,te=Math.max(O.start,W),ie=Math.min(O.end,ee);for(let ne=te;ne<=ie;ne++)Z.push({data:z==null?void 0:z[ne],index:ne,offset:q,size:H}),q+=H}}if(!M)return bs([],Z,j,R,_,$);const J=F.length>0?F[F.length-1]+1:0,he=Nb(B,C,E,J);if(he.length===0)return null;const Ee=j-1,Ne=hs([],W=>{for(const ee of he){const q=ee.value;let O=q.offset,H=ee.start;const te=q.size;if(q.offset<C){H+=Math.floor((C-q.offset+R)/(te+R));const ne=H-ee.start;O+=ne*te+ne*R}H<J&&(O+=(J-H)*te,H=J);const ie=Math.min(ee.end,Ee);for(let ne=H;ne<=ie&&!(O>=E);ne++)W.push({data:z==null?void 0:z[ne],index:ne,offset:O,size:te}),O+=te+R}});return bs(Ne,Z,j,R,_,$)}),Ce(C=>C!==null),ht()),ma);me(U(e,Ce(ta),ce(C=>C==null?void 0:C.length)),o),me(U(w,ce(C=>C.topListHeight)),f),me(f,a),me(U(w,ce(C=>[C.top,C.bottom])),i),me(U(w,ce(C=>C.items)),g);const S=Xt(U(w,Ce(({items:C})=>C.length>0),Me(o,e),Ce(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ce(([,C,E])=>[C-1,E]),ht(Zr),ce(([C])=>C))),k=Xt(U(w,_n(200),Ce(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ce(({items:C})=>C[0].index),ht())),T=Xt(U(w,Ce(({items:C})=>C.length>0),ce(({items:C})=>{let E=0,j=C.length-1;for(;C[E].type==="group"&&E<j;)E++;for(;C[j].type==="group"&&j>E;)j--;return{endIndex:C[j].index,startIndex:C[E].index}}),ht($d)));return{endReached:S,initialItemCount:y,itemsRendered:g,listState:w,rangeChanged:T,startReached:k,topItemsIndexes:x,...p}},pt(Tn,Wd,ha,to,eo,oo,zn,ca),{singleton:!0}),Zd=Je(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=Dt(U(It(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return me(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},pt(Bt,sr),{singleton:!0}),Bb=Je(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=Dt(U(It(n,e,t),Ce(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),_n(0),ht()),0);return{alignToBottom:n,paddingTopAddition:r}},pt(Bt,Zd),{singleton:!0}),Qd=Je(()=>({context:X(null)})),Hb=({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,ef=Je(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=We();return me(U(d,Me(t,l,n,s,o,r,a),Me(e),ce(([[f,p,h,m,x,y,g,w],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Hb,done:E,...j}=f,N=Hd(f,p,m-1),A=Qr(N,p.offsetTree,S)+x+y,M=A+pn(p.sizeTree,N)[1],F=w+y,$=w+h-g,R=C({itemBottom:M,itemTop:A,locationParams:{align:k,behavior:T,...j},viewportBottom:$,viewportTop:F});return R?E&&fn(U(i,Ce(z=>!z),nr(bt(i)?1:2)),E):E&&E(),R}),Ce(f=>f!==null)),c),{scrollIntoView:d}},pt(Tn,Bt,eo,sr,Fn),{singleton:!0});function tf(e){return e?e==="smooth"?"smooth":"auto":!1}const Ub=(e,t)=>typeof e=="function"?tf(e(t)):t&&tf(e),Wb=Je(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:p},{scrollIntoView:h}])=>{const m=X(!1),x=We();let y=null;function g(T){Oe(i,{align:"end",behavior:T,index:"LAST"})}rt(U(It(U(Se(t),nr(1)),l),Me(Se(m),s,a,f),ce(([[T,C],E,j,N,A])=>{let M=C&&N,F="auto";return M&&(F=Ub(E,j||A),M=M&&!!F),{followOutputBehavior:F,shouldFollow:M,totalCount:T}}),Ce(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{y&&(y(),y=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T)}):y=fn(e,()=>{bt(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T),y=null})});function w(T){const C=fn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(bt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),g("auto"))});setTimeout(C,100)}rt(U(It(Se(m),t,c),Ce(([T,,C])=>T&&C),Cn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ce(({refreshed:T})=>T),Me(m,t)),([,T])=>{bt(a)&&w(T!==!1)}),rt(x,()=>{w(bt(m)!==!1)}),rt(It(Se(m),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=X(null),k=We();return me(ra(U(Se(r),ce(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),U(Se(t))),k),rt(U(It(U(k,nr(1)),l),Me(Se(S),a,f,p),ce(([[T,C],E,j,N,A])=>C&&j&&(E==null?void 0:E({context:A,totalCount:T,scrollingInProgress:N}))),Ce(T=>!!T),_n(0)),T=>{y&&(y(),y=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),Oe(h,T)}):y=fn(e,()=>{bt(d)("scrolling into view",{}),Oe(h,T),y=null})}),{autoscrollToBottom:x,followOutput:m,scrollIntoViewOnChange:S}},pt(Tn,oo,eo,to,zn,Fn,Bt,Qd,ef)),Vb=Je(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(U(a,Me(s),Ce(([,l])=>l!==0),Me(o,r,t,n,e),ce(([[,l],c,d,f,p,h=[]])=>Xd(l,c,d,f,p,h))),i),{}),pt(Tn,to,sr,zn),{singleton:!0}),Kb=Je(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return rt(U(e,Me(r),Ce(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(U(n,nr(1),Ce(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},pt(zn,Bt,sr),{singleton:!0}),nf=Je(([{scrollVelocity:e}])=>{const t=X(!1),n=We(),r=X(!1);return me(U(e,Me(r,t,n),Ce(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ht()),t),rt(U(It(t,e,n),Me(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},pt(oo),{singleton:!0}),ga=Je(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=X(!1),i=X(void 0);return me(U(It(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),me(U(t,Me(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},pt(Bt)),qb=Je(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=We(),d=X(void 0),f=X(null),p=X(null);return me(a,f),me(l,p),rt(U(c,Me(t,r,i,f,p,n)),([h,m,x,y,g,w,S])=>{const k=jb(m.sizeTree);y&&g!==null&&w!==null&&(x=g.scrollTop-w.offsetTop),x-=S,h({ranges:k,scrollTop:x})}),me(U(d,Ce(ta),ce(Gb)),o),me(U(s,Me(d),Ce(([,h])=>h!==void 0),ht(),ce(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},pt(Tn,Bt,to,zn,ga));function Gb(e){return{align:"start",index:0,offset:e.scrollTop}}const Yb=Je(([{topItemsIndexes:e}])=>{const t=X(0);return me(U(t,Ce(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},pt(sr));function rf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Xb=rf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jb=Je(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:p},{log:h},{recalcInProgress:m}])=>{const x=Xt(U(l,Me(i),Cn(([,g,w,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},j])=>{const N=k+C;let A=0;return w===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(A=N-S,A!==0&&(A+=j))),[A,T,E,N]},[0,[],0,0]),Ce(([g])=>g!==0),Me(r,a,n,o,h,m),Ce(([,g,w,S,,,k])=>!k&&!S&&g!==0&&w===no),ce(([[g],,,,,w])=>(w("Upward scrolling compensation",{amount:g},Vt.DEBUG),g))));function y(g){g>0?(Oe(t,{behavior:"auto",top:-g}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-g}))}return rt(U(x,Me(e,s)),([g,w,S])=>{S&&Xb()?Oe(e,w-g):y(-g)}),rt(U(It(Dt(s,!1),e,m),Ce(([g,w,S])=>!g&&!S&&w!==0),ce(([g,w])=>w),_n(1)),y),me(U(f,ce(g=>({top:-g}))),t),rt(U(c,Me(p,d),ce(([g,{groupIndices:w,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(w.length===0)return C(g);{let E=0;const j=Jr(k,0);let N=0,A=0;for(;N<g;){N++,E+=j;let M=w.length===A+1?1/0:w[A+1]-w[A]-1;N+M>g&&(E-=j,M=g-N+1),N+=M,E+=C(M),A++}return E}})),g=>{Oe(e,g),requestAnimationFrame(()=>{Oe(t,{top:g}),requestAnimationFrame(()=>{Oe(e,0),Oe(m,!1)})})}),{deviation:e}},pt(Bt,oo,sr,Tn,Fn,ca)),Zb=Je(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),pt(ha,Vb,zn,nf,Zd,Kb,Bb,ga,ef,Fn,Qd)),of=Je(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:m},x,y,g,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:j},N])=>(me(k.rangeChanged,N.scrollSeekRangeChanged),me(U(N.windowViewportRect,ce(A=>A.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...N,...x,sizes:l,...y}),pt(Tn,to,Bt,qb,Wb,sr,eo,Jb,Yb,Wd,Zb));function Qb(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 Ss=typeof document<"u"?b.useLayoutEffect:b.useEffect;function sf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(y,g){y.propsReady&&Oe(y.propsReady,!1);for(const w of r){const S=y[t.required[w]];Oe(S,g[w])}for(const w of o)if(w in g){const S=y[t.optional[w]];Oe(S,g[w])}y.propsReady&&Oe(y.propsReady,!0)}function c(y){return s.reduce((g,w)=>(g[w]=S=>{const k=y[t.methods[w]];Oe(k,S)},g),{})}function d(y){return i.reduce((g,w)=>(g[w]=mb(y[t.events[w]]),g),{})}const f=b.forwardRef((y,g)=>{const{children:w,...S}=y,[k]=b.useState(()=>hs(xb(e),E=>{l(E,S)})),[T]=b.useState(Nd(d,k));Ss(()=>{for(const E of i)E in S&&rt(T[E],S[E]);return()=>{Object.values(T).map(na)}},[S,T,k]),Ss(()=>{l(k,S)}),b.useImperativeHandle(g,Ed(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Qb([...r,...o,...i],S),children:w}):w})}),p=y=>{const g=b.useContext(a);return b.useCallback(w=>{Oe(g[y],w)},[g,y])},h=y=>{const g=b.useContext(a)[y],w=b.useCallback(S=>rt(g,S),[g]);return b.useSyncExternalStore(w,()=>bt(g),()=>bt(g))},m=y=>{const g=b.useContext(a)[y],[w,S]=b.useState(Nd(bt,g));return Ss(()=>rt(g,k=>{k!==w&&S(Ed(k))}),[g,w]),w},x=b.version.startsWith("18")?h:m;return{Component:f,useEmitter:(y,g)=>{const w=b.useContext(a)[y];Ss(()=>rt(w,g),[g,w])},useEmitterValue:x,usePublisher:p}}const af=b.createContext(void 0),lf=b.createContext(void 0),cf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function xa(e){return"self"in e}function e0(e){return"body"in e}function uf(e,t,n,r=Ir,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(p=>{let h,m,x;const y=p.target;if(e0(y)||xa(y)){const w=xa(y)?y:y.defaultView;x=s?w.scrollX:w.scrollY,h=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,m=s?w.innerWidth:w.innerHeight}else x=s?y.scrollLeft:y.scrollTop,h=s?y.scrollWidth:y.scrollHeight,m=s?y.offsetWidth:y.offsetHeight;const g=()=>{e({scrollHeight:h,scrollTop:Math.max(x,0),viewportHeight:m})};p.suppressFlushSync?g():Js.flushSync(g),a.current!==null&&(x===a.current||x<=0||x===h-m)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const p=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(p){const h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const m=p.behavior==="smooth";let x,y,g;xa(h)?(y=Math.max($n(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),x=s?h.innerWidth:h.innerHeight,g=s?window.scrollX:window.scrollY):(y=h[s?"scrollWidth":"scrollHeight"],x=$n(h,s?"width":"height"),g=h[s?"scrollLeft":"scrollTop"]);const w=y-x;if(p.top=Math.ceil(Math.max(Math.min(w,p.top),0)),Kd(x,y)||p.top===g){e({scrollHeight:y,scrollTop:g,viewportHeight:x}),m&&t(!0);return}m?(a.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(p={behavior:p.behavior,left:p.top}),h.scrollTo(p)}function f(p){s&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ya="-webkit-sticky",df="sticky",va=rf(()=>{if(typeof document>"u")return df;const e=document.createElement("div");return e.style.position=ya,e.style.position===ya?ya:df});function wa(e){return e}const t0=Je(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(wa),o=X("div"),s=X(Ir),i=(a,l=null)=>Dt(U(n,ce(c=>c[a]),ht()),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")}}),n0=Je(([e,t])=>({...e,...t}),pt(of,t0)),r0=({height:e})=>u.jsx("div",{style:{height:e}}),o0={overflowAnchor:"none",position:va(),zIndex:1},ff={overflowAnchor:"none"},s0={...ff,display:"inline-block",height:"100%"},pf=b.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=rn("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),c=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),p=Ie("itemSize"),h=Ie("log"),m=rn("gap"),x=Ie("horizontalDirection"),{callbackRef:y}=wb(n,p,f,e?Ir:a,h,m,o,x,Ie("skipAnimationFrameInResizeObserver")),[g,w]=b.useState(0);ba("deviation",R=>{g!==R&&w(R)});const S=Ie("EmptyPlaceholder"),k=Ie("ScrollSeekPlaceholder")||r0,T=Ie("ListComponent"),C=Ie("ItemComponent"),E=Ie("GroupComponent"),j=Ie("computeItemKey"),N=Ie("isSeeking"),A=Ie("groupIndices").length>0,M=Ie("alignToBottom"),F=Ie("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:g!==0?g:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Lt(S,c)}):u.jsx(T,{...Lt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:$,children:(e?t.topItems:t.items).map(R=>{const z=R.originalIndex,_=j(z+t.firstItemIndex,R.data,c);return N?b.createElement(k,{...Lt(k,c),height:R.size,index:R.index,key:_,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?b.createElement(E,{...Lt(E,c),"data-index":z,"data-item-index":R.index,"data-known-size":R.size,key:_,style:o0},d(R.index,c)):b.createElement(C,{...Lt(C,c),...c0(C,R.data),"data-index":z,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:_,style:x?s0:ff},A?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),i0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a0={outline:"none",overflowX:"auto",position:"relative"},Cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),l0={position:va(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function c0(e,t){return{item:typeof e=="string"?void 0:t}}const u0=b.memo(function(){const e=Ie("HeaderComponent"),t=rn("headerHeight"),n=Ie("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),d0=b.memo(function(){const e=Ie("FooterComponent"),t=rn("footerHeight"),n=Ie("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null});function hf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:h,scrollToCallback:m}=uf(a,c,l,d,void 0,f);return e("scrollTo",m),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?a0:i0,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function mf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),p=t("customScrollParent"),h=b.useRef(null),m=t("scrollerRef"),{scrollByCallback:x,scrollerRef:y,scrollToCallback:g}=uf(a,c,l,m,p);return cf(()=>{var w;return y.current=p||((w=h.current)==null?void 0:w.ownerDocument.defaultView),()=>{y.current=null}},[y,p]),e("windowScrollTo",g),e("scrollBy",x),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const f0=({children:e})=>{const t=b.useContext(af),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=b.useMemo(()=>Id(n,l=>$n(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ie("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Cs(o),children:e})},p0=({children:e})=>{const t=b.useContext(af),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ie("customScrollParent"),s=Rd(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Cs(i),children:e})},h0=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...l0,marginTop:`${n}px`},o=Ie("context");return u.jsx(t,{style:r,...Lt(t,o),children:e})},m0=b.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return u.jsxs(r||t?y0:x0,{...e,context:o,children:[n&&u.jsx(h0,{children:u.jsx(pf,{showTopList:!0})}),u.jsxs(r||t?p0:f0,{children:[u.jsx(u0,{}),u.jsx(pf,{}),u.jsx(d0,{})]})]})}),{Component:g0,useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}=sf(n0,{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"}},m0),x0=hf({useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}),y0=mf({useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}),v0=g0;pt(of,Je(()=>{const e=X(c=>u.jsxs("td",{children:["Item $",c]})),t=X(null),n=X(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=X(null),o=X(null),s=X({}),i=X(wa),a=X(Ir),l=(c,d=null)=>Dt(U(s,ce(f=>f[c]),ht()),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")}})),va();const gf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},w0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:xf,floor:Ts,max:so,min:Sa,round:yf}=Math;function vf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function b0(e){return{...w0,items:e}}function ks(e,t){return e&&e.width===t.width&&e.height===t.height}function S0(e,t){return e&&e.column===t.column&&e.row===t.row}const C0=Je(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},p,h,{didMount:m,propsReady:x},{customScrollParent:y,useWindowScroll:g,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},T])=>{const C=X(0),E=X(0),j=X(gf),N=X({height:0,width:0}),A=X({height:0,width:0}),M=We(),F=We(),$=X(0),R=X(null),z=X({column:0,row:0}),_=We(),B=We(),L=X(!1),D=X(0),Z=X(!0),J=X(!1),he=X(!1);rt(U(m,Me(D),Ce(([O,H])=>!!H)),()=>{Oe(Z,!1)}),rt(U(It(m,Z,A,N,D,J),Ce(([O,H,te,ie,,ne])=>O&&!H&&te.height!==0&&ie.height!==0&&!ne)),([,,,,O])=>{Oe(J,!0),fa(1,()=>{Oe(M,O)}),fn(U(c),()=>{Oe(t,[0,0]),Oe(Z,!0)})}),me(U(B,Ce(O=>O!=null&&O.scrollTop>0),Sn(0)),E),rt(U(m,Me(B),Ce(([,O])=>O!=null)),([,O])=>{O&&(Oe(N,O.viewport),Oe(A,O.item),Oe(z,O.gap),O.scrollTop>0&&(Oe(L,!0),fn(U(c,nr(1)),H=>{Oe(L,!1)}),Oe(l,{top:O.scrollTop})))}),me(U(N,ce(({height:O})=>O)),f),me(U(It(Se(N,ks),Se(A,ks),Se(z,(O,H)=>O&&O.column===H.column&&O.row===H.row),Se(c)),ce(([O,H,te,ie])=>({gap:te,item:H,scrollTop:ie,viewport:O}))),_),me(U(It(Se(C),r,Se(z,S0),Se(A,ks),Se(N,ks),Se(R),Se(E),Se(L),Se(Z),Se(D)),Ce(([,,,,,,,O])=>!O),ce(([O,[H,te],ie,ne,De,Y,fe,,ke,je])=>{const{column:ze,row:Be}=ie,{height:Ve,width:Ke}=ne,{width:qe}=De;if(fe===0&&(O===0||qe===0))return gf;if(Ke===0){const re=pa(je,O),Qe=re+Math.max(fe-1,0);return b0(vf(re,Qe,Y))}const Ze=wf(qe,Ke,ze);let Xe,ot;ke?H===0&&te===0&&fe>0?(Xe=0,ot=fe-1):(Xe=Ze*Ts((H+Be)/(Ve+Be)),ot=Ze*xf((te+Be)/(Ve+Be))-1,ot=Sa(O-1,so(ot,Ze-1)),Xe=Sa(ot,so(0,Xe))):(Xe=0,ot=-1);const St=vf(Xe,ot,Y),{bottom:mt,top:it}=bf(De,ie,ne,St),Ct=xf(O/Ze),de=Ct*Ve+(Ct-1)*Be-mt;return{bottom:mt,itemHeight:Ve,items:St,itemWidth:Ke,offsetBottom:de,offsetTop:it,top:it}})),j),me(U(R,Ce(O=>O!==null),ce(O=>O.length)),C),me(U(It(N,A,j,z),Ce(([O,H,{items:te}])=>te.length>0&&H.height!==0&&O.height!==0),ce(([O,H,{items:te},ie])=>{const{bottom:ne,top:De}=bf(O,ie,H,te);return[De,ne]}),ht(Zr)),t);const Ee=X(!1);me(U(c,Me(Ee),ce(([O,H])=>H||O!==0)),Ee);const Ne=Xt(U(It(j,C),Ce(([{items:O}])=>O.length>0),Me(Ee),Ce(([[O,H],te])=>{const ie=O.items[O.items.length-1].index===H-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===H)&&ie}),ce(([[,O]])=>O-1),ht())),W=Xt(U(Se(j),Ce(({items:O})=>O.length>0&&O[0].index===0),Sn(0),ht())),ee=Xt(U(Se(j),Me(L),Ce(([{items:O},H])=>O.length>0&&!H),ce(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),ht($d),_n(0)));me(ee,h.scrollSeekRangeChanged),me(U(M,Me(N,A,C,z),ce(([O,H,te,ie,ne])=>{const De=Vd(O),{align:Y,behavior:fe,offset:ke}=De;let je=De.index;je==="LAST"&&(je=ie-1),je=so(0,je,Sa(ie-1,je));let ze=Ca(H,ne,te,je);return Y==="end"?ze=yf(ze-H.height+te.height):Y==="center"&&(ze=yf(ze-H.height/2+te.height/2)),ke&&(ze+=ke),{behavior:fe,top:ze}})),l);const q=Dt(U(j,ce(O=>O.offsetBottom+O.bottom)),0);return me(U(k,ce(O=>({height:O.visibleHeight,width:O.visibleWidth}))),N),{customScrollParent:y,data:R,deviation:$,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:A,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:M,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:N,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...h,gridState:j,horizontalDirection:he,initialTopMostItemIndex:D,totalListHeight:q,...p,endReached:Ne,propsReady:x,rangeChanged:ee,startReached:W,stateChanged:_,stateRestoreInProgress:L,...T}},pt(ha,Bt,oo,nf,zn,ga,Fn));function wf(e,t,n){return so(1,Ts((e+n)/(Ts(t)+n)))}function bf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ca(e,t,n,r[0].index);return{bottom:Ca(e,t,n,r[r.length-1].index)+o,top:s}}function Ca(e,t,n,r){const o=wf(e.width,n.width,t.column),s=Ts(r/o),i=s*n.height+so(0,s-1)*t.row;return i>0?i+t.row:i}const T0=Je(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(wa),i=X("div"),a=X(Ir),l=(f,p=null)=>Dt(U(t,ce(h=>h[f]),ht()),p),c=X(!1),d=X(!1);return me(Se(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),k0=Je(([e,t])=>({...e,...t}),pt(C0,T0)),E0=b.memo(function(){const e=xt("gridState"),t=xt("listClassName"),n=xt("itemClassName"),r=xt("itemContent"),o=xt("computeItemKey"),s=xt("isSeeking"),i=on("scrollHeight"),a=xt("ItemComponent"),l=xt("ListComponent"),c=xt("ScrollSeekPlaceholder"),d=xt("context"),f=on("itemDimensions"),p=on("gap"),h=xt("log"),m=xt("stateRestoreInProgress"),x=on("reportReadyState"),y=rr(b.useMemo(()=>g=>{const w=g.parentElement.parentElement.scrollHeight;i(w);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}p({column:Cf("column-gap",getComputedStyle(g).columnGap,h),row:Cf("row-gap",getComputedStyle(g).rowGap,h)})},[i,f,p,h]),!0,!1);return cf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),m?null:u.jsx(l,{className:t,ref:y,...Lt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const w=o(g.index,g.data,d);return s?u.jsx(c,{...Lt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},w):b.createElement(a,{...Lt(a,d),className:n,"data-index":g.index,key:w},r(g.index,g.data,d))})})}),I0=b.memo(function(){const e=xt("HeaderComponent"),t=on("headerHeight"),n=xt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),N0=b.memo(function(){const e=xt("FooterComponent"),t=on("footerHeight"),n=xt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),A0=({children:e})=>{const t=b.useContext(lf),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Cs(!1),children:e})},j0=({children:e})=>{const t=b.useContext(lf),n=on("windowViewportRect"),r=on("itemDimensions"),o=xt("customScrollParent"),s=Rd(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Cs(!1),children:e})},_0=b.memo(function({...e}){const t=xt("useWindowScroll"),n=xt("customScrollParent"),r=n||t?P0:R0,o=n||t?j0:A0,s=xt("context");return u.jsx(r,{...e,...Lt(r,s),children:u.jsxs(o,{children:[u.jsx(I0,{}),u.jsx(E0,{}),u.jsx(N0,{})]})})}),{useEmitter:Sf,useEmitterValue:xt,usePublisher:on}=sf(k0,{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"}},_0),R0=hf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on}),P0=mf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on});function Cf(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 O0=xo.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 Tf({className:e,variant:t,...n}){return u.jsx("div",{className:Q(O0({variant:t}),e),...n})}const io=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));io.displayName="Card";const ao=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));ao.displayName="CardHeader";const lo=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));lo.displayName="CardTitle";const kf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));kf.displayName="CardDescription";const co=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));co.displayName="CardContent";const Ef=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Ef.displayName="CardFooter";const M0=1,D0=1e6;let Ta=0;function L0(){return Ta=(Ta+1)%Number.MAX_SAFE_INTEGER,Ta.toString()}const ka=new Map,If=e=>{if(ka.has(e))return;const t=setTimeout(()=>{ka.delete(e),uo({type:"REMOVE_TOAST",toastId:e})},D0);ka.set(e,t)},F0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,M0)};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?If(n):e.toasts.forEach(r=>{If(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)}}},Es=[];let Is={toasts:[]};function uo(e){Is=F0(Is,e),Es.forEach(t=>{t(Is)})}function $0({...e}){const t=L0(),n=o=>uo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>uo({type:"DISMISS_TOAST",toastId:t});return uo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ea(){const[e,t]=v.useState(Is);return v.useEffect(()=>(Es.push(t),()=>{const n=Es.indexOf(t);n>-1&&Es.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>uo({type:"DISMISS_TOAST",toastId:n})}}async function Nf(e,t){return await Qt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Af(e,t){return await(await Nf(`/files/${e}/view`,t)).text()}async function z0(e,t){const n=await Nf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Qt(`/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 B0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Qt("/files",{params:r})}function Ia(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 jf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function fo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(fo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(jf(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=fo(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 po(e){if(typeof e=="string")return e;if(jf(e))return"";try{const t=fo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function H0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function U0(e){const t=po(e);return typeof e=="string"&&H0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Ns(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ia(t);if(n!==null)return Ns(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Ns(e.content):e}var As="Dialog",[_f,vT]=In(As),[W0,hn]=_f(As),Rf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=v.useRef(null),l=v.useRef(null),[c,d]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return u.jsx(W0,{scope:t,triggerRef:a,contentRef:l,contentId:Nn(),titleId:Nn(),descriptionId:Nn(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Rf.displayName=As;var Pf="DialogTrigger",Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Pf,n),s=Ue(t,o.triggerRef);return u.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ja(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Of.displayName=Pf;var Na="DialogPortal",[V0,Mf]=_f(Na,{forceMount:void 0}),Df=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Na,t);return u.jsx(V0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:i})}))})};Df.displayName=Na;var js="DialogOverlay",Lf=v.forwardRef((e,t)=>{const n=Mf(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(js,e.__scopeDialog);return s.modal?u.jsx(tn,{present:r||s.open,children:u.jsx(q0,{...o,ref:t})}):null});Lf.displayName=js;var K0=Yn.createSlot("DialogOverlay.RemoveScroll"),q0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(js,n);return u.jsx(is,{as:K0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Ae.div,{"data-state":ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Ff=v.forwardRef((e,t)=>{const n=Mf(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ir,e.__scopeDialog);return u.jsx(tn,{present:r||s.open,children:s.modal?u.jsx(G0,{...o,ref:t}):u.jsx(Y0,{...o,ref:t})})});Ff.displayName=ir;var G0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(null),o=Ue(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx($f,{...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())})}),Y0=v.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx($f,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),$f=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ir,n),l=v.useRef(null),c=Ue(t,l);return Si(),u.jsxs(u.Fragment,{children:[u.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Fo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(X0,{titleId:a.titleId}),u.jsx(Z0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Aa="DialogTitle",zf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Aa,n);return u.jsx(Ae.h2,{id:o.titleId,...r,ref:t})});zf.displayName=Aa;var Bf="DialogDescription",Hf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Bf,n);return u.jsx(Ae.p,{id:o.descriptionId,...r,ref:t})});Hf.displayName=Bf;var Uf="DialogClose",Wf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Uf,n);return u.jsx(Ae.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Wf.displayName=Uf;function ja(e){return e?"open":"closed"}var Vf="DialogTitleWarning",[wT,Kf]=tx(Vf,{contentName:ir,titleName:Aa,docsSlug:"dialog"}),X0=({titleId:e})=>{const t=Kf(Vf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
86
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function lb(e,t=fs){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 cb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),lb(t),ab(t)}const hs=0,Ln=1,Er=2,kd=4;function Ed(e){return()=>e}function ub(e){e()}function Id(e,t){return n=>e(t(n))}function Nd(e,t){return()=>e(t)}function db(e,t){return n=>e(t,n)}function ta(e){return e!==void 0}function fb(...e){return()=>{e.map(ub)}}function Ir(){}function ps(e,t){return t(e),e}function hb(e,t){return t(e)}function ht(...e){return e}function ot(e,t){return e(Ln,t)}function Oe(e,t){e(hs,t)}function na(e){e(Er)}function bt(e){return e(kd)}function me(e,t){return ot(e,db(t,hs))}function fn(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ad(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function jd(e,t){return e===t}function pt(e=jd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ce(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Id(t,e)}function Sn(e){return t=>()=>{t(e)}}function W(e,...t){const n=pb(...t);return(r,o)=>{switch(r){case Er:na(e);return;case Ln:return ot(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);ot(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function pb(...e){return t=>e.reduceRight(hb,t)}function mb(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=ot(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function X(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case hs:t=o;break;case Ln:{o(t);break}case kd:return t}return n(r,o)}}function Dt(e,t){return ps(X(t),n=>me(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case hs:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return ps(Ve(),t=>me(e,t))}function et(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:gb(),singleton:n}}const gb=()=>Symbol();function xb(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 It(...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);ot(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Er:{na(t);return}case Ln:return r===o&&i(n),ot(t,i)}}}function Se(e,t=jd){return W(e,pt(t))}function ra(...e){return function(t,n){switch(t){case Er:return;case Ln:return fb(...e.map(r=>ot(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 yb={0:"debug",3:"error",1:"log",2:"warn"},vb=()=>typeof globalThis>"u"?window:globalThis,Fn=et(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=vb().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[yb[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return oa(e,t,n).callbackRef}function oa(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function wb(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=bb(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 m;p&&(m=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?m.scrollX||m.document.documentElement.scrollLeft:m.scrollY||m.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,y=i?a?i.scrollWidth:i.scrollHeight:p?a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:p?a?m.innerWidth:m.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:y,scrollTop:Math.max(x,0),viewportHeight:g}),s==null||s(a?_d("column-gap",getComputedStyle(d).columnGap,o):_d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return oa(c,n,l)}function bb(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Vt.ERROR),d===c)continue;const 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 _d(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 Rd(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,h;if(t){const p=t.getBoundingClientRect(),m=c.top-p.top;h=p.height-Math.max(0,m),f=m+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=oa(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Bt=et(()=>{const e=Ve(),t=Ve(),n=X(0),r=Ve(),o=X(0),s=Ve(),i=Ve(),a=X(0),l=X(0),c=X(0),d=X(0),f=Ve(),h=Ve(),p=X(!1),m=X(!1),x=X(!1);return me(W(e,ce(({scrollTop:y})=>y)),t),me(W(e,ce(({scrollHeight:y})=>y)),i),me(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:m,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Xr={lvl:0};function Pd(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 ct(e){return e===Xr}function Jr(e,t){if(!ct(e))return t===e.k?e.v:t<e.k?Jr(e.l,t):Jr(e.r,t)}function hn(e,t,n="k"){if(ct(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 Jt(e,t,n){return ct(e)?Dd(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Ld(Nt(e,{l:Jt(e.l,t,n)})):Ld(Nt(e,{r:Jt(e.r,t,n)}))}function Nr(){return Xr}function ms(e,t,n){if(ct(e))return[];const r=hn(e,t)[0];return Sb(ia(e,r,n))}function sa(e,t){if(ct(e))return Xr;const{k:n,l:r,r:o}=e;if(t===n){if(ct(r))return o;if(ct(o))return r;{const[s,i]=Md(r);return gs(Nt(e,{k:s,l:Od(r),v:i}))}}else return t<n?gs(Nt(e,{l:sa(r,t)})):gs(Nt(e,{r:sa(o,t)}))}function or(e){return ct(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ia(e,t,n){if(ct(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ia(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ia(s,t,n))),a}function gs(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(aa(t))return Fd(Nt(e,{lvl:n-1}));if(!ct(t)&&!ct(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(aa(e))return la(Nt(e,{lvl:n-1}));if(!ct(r)&&!ct(r.l)){const o=r.l,s=aa(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:la(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return Dd(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 Od(e){return ct(e.r)?e.l:gs(Nt(e,{r:Od(e.r)}))}function aa(e){return ct(e)||e.lvl>e.r.lvl}function Md(e){return ct(e.r)?[e.k,e.v]:Md(e.r)}function Dd(e,t,n,r=Xr,o=Xr){return{k:e,l:r,lvl:n,r:o,v:t}}function Ld(e){return la(Fd(e))}function Fd(e){const{l:t}=e;return!ct(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function la(e){const{lvl:t,r:n}=e;return!ct(n)&&!ct(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Sb(e){return Pd(e,({k:t,v:n})=>({index:t,value:n}))}function $d(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Zr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ca=et(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function zd(e,t,n){return e[xs(e,t,n)]}function xs(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 Cb(e,t,n,r){const o=xs(e,t,r),s=xs(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ys(e){return!ct(e.groupOffsetTree)}function ua({index:e},t){return t===e?0:t<e?-1:1}function Tb(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function kb(e,t){let n=ct(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ct(e)){e=Jt(e,0,s);continue}const a=ms(e,i-1,o+1);if(a.some(Rb(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=sa(e,f)):(c=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Jt(e,o+1,h));c&&(e=Jt(e,i,s))}return[e,n]}function Eb(e){return typeof e.groupIndex<"u"}function Ib({offset:e},t){return t===e?0:t<e?-1:1}function Qr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=zd(t,e,ua),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Bd(e,t){if(!ys(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Hd(e,t,n){if(Eb(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Bd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Nb(e,t,n,r=0){return r>0&&(t=Math.max(t,zd(e,r,ua).offset)),Pd(Cb(e,t,n,Ib),_b)}function Ab(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&&ct(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((m,x)=>Jt(Jt(m,x,h),x+1,p),i)}else[i,a]=kb(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Jt(h,p,Qr(p,f,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function jb(e){return or(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Ud(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 da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=xs(o,t-1,ua),a=o[l].offset;const c=hn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of ms(n,t,1/0)){const f=c-s,h=f*i+a+f*r;o.push({index:c,offset:h,size:d}),s=c,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function _b(e){return{index:e.index,value:e}}function Rb(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 Pb={offsetHeight:"height",offsetWidth:"width"},Tn=et(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=Dt(r,0),s=Ve(),i=Ve(),a=X(0),l=X([]),c=X(void 0),d=X(void 0),f=X((T,C)=>$n(T,Pb[C])),h=X(void 0),p=X(0),m=Tb(),x=Dt(W(n,Le(l,e,p),Cn(Ab,m),pt()),m),y=Dt(W(l,pt(),Cn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),ce(({prev:T})=>T)),[]);me(W(l,Ce(T=>T.length>0),Le(x,p),ce(([T,C,E])=>{const j=T.reduce((N,A,M)=>Jt(N,A,Qr(A,C.offsetTree,E)||M),Nr());return{...C,groupIndices:T,groupOffsetTree:j}})),x),me(W(r,Le(x),Ce(([T,{lastIndex:C}])=>T<C),ce(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),me(c,d);const g=Dt(W(c,ce(T=>T===void 0)),!0);me(W(d,Ce(T=>T!==void 0&&ct(bt(x).sizeTree)),ce(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Xt(W(n,Le(x),Cn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:m}),ce(T=>T.changed)));ot(W(a,Cn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),ce(T=>T.diff)),T=>{const{groupIndices:C}=bt(x);if(T>0)Oe(t,!0),Oe(s,T+Ud(T,C));else if(T<0){const E=bt(y);E.length>0&&(T-=Ud(-T,E)),Oe(i,T)}}),ot(W(a,Le(e)),([T,C])=>{T<0&&C("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Vt.ERROR)});const S=Xt(s);me(W(s,Le(x),ce(([T,C])=>{const E=C.groupIndices.length>0,j=[],N=C.lastSize;if(E){const A=Jr(C.sizeTree,0);let M=0,F=0;for(;M<T;){const R=C.groupIndices[F],z=C.groupIndices.length===F+1?1/0:C.groupIndices[F+1]-R-1;j.push({endIndex:R,size:A,startIndex:R}),j.push({endIndex:R+1+z-1,size:N,startIndex:R+1}),F++,M+=z+1}const $=or(C.sizeTree);return M!==T&&$.shift(),$.reduce((R,{k:z,v:_})=>{let B=R.ranges;return R.prevSize!==0&&(B=[...R.ranges,{endIndex:z+T-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:z+T,prevSize:_,ranges:B}},{prevIndex:T,prevSize:0,ranges:j}).ranges}return or(C.sizeTree).reduce((A,{k:M,v:F})=>({prevIndex:M+T,prevSize:F,ranges:[...A.ranges,{endIndex:M+T-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:N,ranges:[]}).ranges})),n);const k=Xt(W(i,Le(x,p),ce(([T,{offsetTree:C},E])=>{const j=-T;return Qr(j,C,E)})));return me(W(i,Le(x,p),ce(([T,C,E])=>{if(C.groupIndices.length>0){if(ct(C.sizeTree))return C;let j=Nr();const N=bt(y);let A=0,M=0,F=0;for(;A<-T;){F=N[M];const $=N[M+1]-F-1;M++,A+=$+1}if(j=or(C.sizeTree).reduce(($,{k:R,v:z})=>Jt($,Math.max(0,R+T),z),j),A!==-T){const $=Jr(C.sizeTree,F);j=Jt(j,0,$);const R=hn(C.sizeTree,-T+1)[1];j=Jt(j,1,R)}return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}else{const j=or(C.sizeTree).reduce((N,{k:A,v:M})=>Jt(N,Math.max(0,A+T),M),Nr());return{...C,sizeTree:j,...da(C.offsetTree,0,j,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},ht(Fn,ca),{singleton:!0});function Ob(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Wd=et(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Xt(W(s,ce(Ob)));return me(W(a,ce(l=>l.totalCount)),n),me(W(a,ce(l=>l.groupIndices)),e),me(W(It(o,t,r),Ce(([l,c])=>ys(c)),ce(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),pt(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ht(Tn,Bt)),zn=et(([{log:e}])=>{const t=X(!1),n=Xt(W(t,Ce(r=>r),pt()));return ot(t,r=>{r&&bt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},ht(Fn),{singleton:!0}),Mb=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Vd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Mb)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const eo=et(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ve(),m=Ve(),x=X(0);let y=null,g=null,w=null;function S(){y&&(y(),y=null),w&&(w(),w=null),g&&(clearTimeout(g),g=null),Oe(l,!1)}return me(W(p,Le(n,f,r,x,a,i,h),Le(e,s,o),ce(([[k,T,C,E,j,N,A,M],F,$,R])=>{const z=Vd(k),{align:_,behavior:B,offset:L}=z,D=E-1,Z=Hd(z,T,D);let J=Qr(Z,T.offsetTree,F)+N;_==="end"?(J+=$+hn(T.sizeTree,Z)[1]-C+R,Z===D&&(J+=A)):_==="center"?J+=($+hn(T.sizeTree,Z)[1]-C+R)/2:J-=j,L&&(J+=L);const pe=Ee=>{S(),Ee?(M("retrying to scroll to",{location:k},Vt.DEBUG),Oe(p,k)):(Oe(m,!0),M("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),B==="smooth"){let Ee=!1;w=ot(t,Ne=>{Ee=Ee||Ne}),y=fn(d,()=>{pe(Ee)})}else y=fn(W(t,Db(150)),pe);return g=setTimeout(()=>{S()},1200),Oe(l,!0),M("scrolling from index to",{behavior:B,index:Z,top:J},Vt.DEBUG),{behavior:B,top:J}})),c),{scrollTargetReached:m,scrollToIndex:p,topListHeight:x}},ht(Tn,Bt,Fn),{singleton:!0});function Db(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function fa(e,t){e==0?t():requestAnimationFrame(()=>{fa(e-1,t)})}function ha(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const to=et(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),c=X(!0);return me(W(i,Le(l),Ce(([d,f])=>!!f),Sn(!1)),a),me(W(i,Le(l),Ce(([d,f])=>!!f),Sn(!1)),c),ot(W(It(t,i),Le(a,n,e,c),Ce(([[,d],f,{sizeTree:h},p,m])=>d&&(!ct(h)||ta(p))&&!f&&!m),Le(l)),([,d])=>{fn(o,()=>{Oe(c,!0)}),fa(4,()=>{fn(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ht(Tn,Bt,eo,zn),{singleton:!0});function Kd(e,t){return Math.abs(e-t)<1.01}const no="up",ro="down",Lb="none",Fb={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},$b=0,oo=et(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Ve(),c=Ve(),d=X(4),f=X($b),h=Dt(W(ra(W(Se(o),nr(1),Sn(!0)),W(Se(o),nr(1),Sn(!1),Ad(100))),pt()),!1),p=Dt(W(ra(W(n,Sn(!0)),W(n,Sn(!1),Ad(200))),pt()),!1);me(W(It(Se(o),Se(f)),ce(([w,S])=>w<=S),pt()),a),me(W(a,_n(50)),c);const m=Xt(W(It(r,Se(s),Se(t),Se(e),Se(d)),Cn((w,[{scrollHeight:S,scrollTop:k},T,C,E,j])=>{const N=k+T-S>-j,A={scrollHeight:S,scrollTop:k,viewportHeight:T};if(N){let F,$;return k>w.state.scrollTop?(F="SCROLLED_DOWN",$=w.state.scrollTop-k):(F="SIZE_DECREASED",$=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:F,scrollTopDelta:$,state:A}}let M;return A.scrollHeight>w.state.scrollHeight?M="SIZE_INCREASED":T<w.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:A}},Fb),pt((w,S)=>w&&w.atBottom===S.atBottom))),x=Dt(W(r,Cn((w,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Kd(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return w.scrollTop!==k&&C?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ce(w=>w.changed),ce(w=>w.jump)),0);me(W(m,ce(w=>w.atBottom)),i),me(W(i,_n(50)),l);const y=X(ro);me(W(r,ce(({scrollTop:w})=>w),pt(),Cn((w,S)=>bt(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?no:ro,prevScrollTop:S},{direction:ro,prevScrollTop:0}),ce(w=>w.direction)),y),me(W(r,_n(50),Sn(Lb)),y);const g=X(0);return me(W(h,Ce(w=>!w),Sn(0)),g),me(W(o,_n(100),Le(h),Ce(([w,S])=>!!S),Cn(([w,S],[k])=>[S,k],[0,0]),ce(([w,S])=>S-w)),g),{atBottomState:m,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:y,scrollVelocity:g}},ht(Bt)),vs="top",ws="bottom",qd="none";function Gd(e,t,n){return typeof e=="number"?n===no&&t===vs||n===ro&&t===ws?e:0:n===no?t===vs?e.main:e.reverse:t===ws?e.main:e.reverse}function Yd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const pa=et(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=X(0),a=X(0),l=X(0),c=Dt(W(It(Se(r),Se(o),Se(n),Se(s,Zr),Se(l),Se(i),Se(t),Se(e),Se(a)),ce(([d,f,h,[p,m],x,y,g,w,S])=>{const k=d-w,T=y+g,C=Math.max(h-k,0);let E=qd;const j=Yd(S,vs),N=Yd(S,ws);return p-=w,p+=h+g,m+=h+g,m-=w,p>d+T-j&&(E=no),m<d-C+f+N&&(E=ro),E!==qd?[Math.max(k-h-Gd(x,vs,E)-j,0),k-C-g+f+Gd(x,ws,E)+N]:null}),Ce(d=>d!=null),pt(Zr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ht(Bt),{singleton:!0});function zb(e,t,n){if(ys(t)){const r=Bd(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 ma={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function bs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=c,m=h-d;return{bottom:d,firstItemIndex:s,items:Jd(e,o,s),offsetBottom:m,offsetTop:c,top:p,topItems:Jd(t,o,s),topListHeight:t.reduce((x,y)=>y.size+x,0),totalCount:n}}function Xd(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=ha(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return bs(c,[],a,o,n,r)}function Jd(e,t,n){if(e.length===0)return[];if(!ys(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=ms(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const sr=et(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:m}])=>{const x=X([]),y=X(0),g=Ve();me(s.topItemsIndexes,x);const w=Dt(W(It(p,m,Se(l,Zr),Se(o),Se(r),Se(c),d,Se(x),Se(t),Se(n),e),Ce(([C,E,,j,,,,,,,N])=>{const A=N&&N.length!==j;return C&&!E&&!A}),ce(([,,[C,E],j,N,A,M,F,$,R,z])=>{const _=N,{offsetTree:B,sizeTree:L}=_,D=bt(y);if(j===0)return{...ma,totalCount:j};if(C===0&&E===0)return D===0?{...ma,totalCount:j}:Xd(D,A,N,$,R,z||[]);if(ct(L))return D>0?null:bs(zb(ha(A,j),_,z),[],j,R,_,$);const Z=[];if(F.length>0){const V=F[0],ee=F[F.length-1];let U=0;for(const O of ms(L,V,ee)){const H=O.value,te=Math.max(O.start,V),ie=Math.min(O.end,ee);for(let ne=te;ne<=ie;ne++)Z.push({data:z==null?void 0:z[ne],index:ne,offset:U,size:H}),U+=H}}if(!M)return bs([],Z,j,R,_,$);const J=F.length>0?F[F.length-1]+1:0,pe=Nb(B,C,E,J);if(pe.length===0)return null;const Ee=j-1,Ne=ps([],V=>{for(const ee of pe){const U=ee.value;let O=U.offset,H=ee.start;const te=U.size;if(U.offset<C){H+=Math.floor((C-U.offset+R)/(te+R));const ne=H-ee.start;O+=ne*te+ne*R}H<J&&(O+=(J-H)*te,H=J);const ie=Math.min(ee.end,Ee);for(let ne=H;ne<=ie&&!(O>=E);ne++)V.push({data:z==null?void 0:z[ne],index:ne,offset:O,size:te}),O+=te+R}});return bs(Ne,Z,j,R,_,$)}),Ce(C=>C!==null),pt()),ma);me(W(e,Ce(ta),ce(C=>C==null?void 0:C.length)),o),me(W(w,ce(C=>C.topListHeight)),f),me(f,a),me(W(w,ce(C=>[C.top,C.bottom])),i),me(W(w,ce(C=>C.items)),g);const S=Xt(W(w,Ce(({items:C})=>C.length>0),Le(o,e),Ce(([{items:C},E])=>C[C.length-1].originalIndex===E-1),ce(([,C,E])=>[C-1,E]),pt(Zr),ce(([C])=>C))),k=Xt(W(w,_n(200),Ce(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),ce(({items:C})=>C[0].index),pt())),T=Xt(W(w,Ce(({items:C})=>C.length>0),ce(({items:C})=>{let E=0,j=C.length-1;for(;C[E].type==="group"&&E<j;)E++;for(;C[j].type==="group"&&j>E;)j--;return{endIndex:C[j].index,startIndex:C[E].index}}),pt($d)));return{endReached:S,initialItemCount:y,itemsRendered:g,listState:w,rangeChanged:T,startReached:k,topItemsIndexes:x,...h}},ht(Tn,Wd,pa,to,eo,oo,zn,ca),{singleton:!0}),Zd=et(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=Dt(W(It(n,e,r,t,o),ce(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return me(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},ht(Bt,sr),{singleton:!0}),Bb=et(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=Dt(W(It(n,e,t),Ce(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),_n(0),pt()),0);return{alignToBottom:n,paddingTopAddition:r}},ht(Bt,Zd),{singleton:!0}),Qd=et(()=>({context:X(null)})),Hb=({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,ef=et(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ve();return me(W(d,Le(t,l,n,s,o,r,a),Le(e),ce(([[f,h,p,m,x,y,g,w],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Hb,done:E,...j}=f,N=Hd(f,h,m-1),A=Qr(N,h.offsetTree,S)+x+y,M=A+hn(h.sizeTree,N)[1],F=w+y,$=w+p-g,R=C({itemBottom:M,itemTop:A,locationParams:{align:k,behavior:T,...j},viewportBottom:$,viewportTop:F});return R?E&&fn(W(i,Ce(z=>!z),nr(bt(i)?1:2)),E):E&&E(),R}),Ce(f=>f!==null)),c),{scrollIntoView:d}},ht(Tn,Bt,eo,sr,Fn),{singleton:!0});function tf(e){return e?e==="smooth"?"smooth":"auto":!1}const Ub=(e,t)=>typeof e=="function"?tf(e(t)):t&&tf(e),Wb=et(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const m=X(!1),x=Ve();let y=null;function g(T){Oe(i,{align:"end",behavior:T,index:"LAST"})}ot(W(It(W(Se(t),nr(1)),l),Le(Se(m),s,a,f),ce(([[T,C],E,j,N,A])=>{let M=C&&N,F="auto";return M&&(F=Ub(E,j||A),M=M&&!!F),{followOutputBehavior:F,shouldFollow:M,totalCount:T}}),Ce(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{y&&(y(),y=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T)}):y=fn(e,()=>{bt(d)("following output to ",{totalCount:C},Vt.DEBUG),g(T),y=null})});function w(T){const C=fn(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(bt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),g("auto"))});setTimeout(C,100)}ot(W(It(Se(m),t,c),Ce(([T,,C])=>T&&C),Cn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ce(({refreshed:T})=>T),Le(m,t)),([,T])=>{bt(a)&&w(T!==!1)}),ot(x,()=>{w(bt(m)!==!1)}),ot(It(Se(m),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=X(null),k=Ve();return me(ra(W(Se(r),ce(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),W(Se(t))),k),ot(W(It(W(k,nr(1)),l),Le(Se(S),a,f,h),ce(([[T,C],E,j,N,A])=>C&&j&&(E==null?void 0:E({context:A,totalCount:T,scrollingInProgress:N}))),Ce(T=>!!T),_n(0)),T=>{y&&(y(),y=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),Oe(p,T)}):y=fn(e,()=>{bt(d)("scrolling into view",{}),Oe(p,T),y=null})}),{autoscrollToBottom:x,followOutput:m,scrollIntoViewOnChange:S}},ht(Tn,oo,eo,to,zn,Fn,Bt,Qd,ef)),Vb=et(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(W(a,Le(s),Ce(([,l])=>l!==0),Le(o,r,t,n,e),ce(([[,l],c,d,f,h,p=[]])=>Xd(l,c,d,f,h,p))),i),{}),ht(Tn,to,sr,zn),{singleton:!0}),Kb=et(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return ot(W(e,Le(r),Ce(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(W(n,nr(1),Ce(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},ht(zn,Bt,sr),{singleton:!0}),nf=et(([{scrollVelocity:e}])=>{const t=X(!1),n=Ve(),r=X(!1);return me(W(e,Le(r,t,n),Ce(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),pt()),t),ot(W(It(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ht(oo),{singleton:!0}),ga=et(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=X(!1),i=X(void 0);return me(W(It(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),me(W(t,Le(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ht(Bt)),qb=et(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ve(),d=X(void 0),f=X(null),h=X(null);return me(a,f),me(l,h),ot(W(c,Le(t,r,i,f,h,n)),([p,m,x,y,g,w,S])=>{const k=jb(m.sizeTree);y&&g!==null&&w!==null&&(x=g.scrollTop-w.offsetTop),x-=S,p({ranges:k,scrollTop:x})}),me(W(d,Ce(ta),ce(Gb)),o),me(W(s,Le(d),Ce(([,p])=>p!==void 0),pt(),ce(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},ht(Tn,Bt,to,zn,ga));function Gb(e){return{align:"start",index:0,offset:e.scrollTop}}const Yb=et(([{topItemsIndexes:e}])=>{const t=X(0);return me(W(t,Ce(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ht(sr));function rf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Xb=rf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Jb=et(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:m}])=>{const x=Xt(W(l,Le(i),Cn(([,g,w,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},j])=>{const N=k+C;let A=0;return w===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(A=N-S,A!==0&&(A+=j))),[A,T,E,N]},[0,[],0,0]),Ce(([g])=>g!==0),Le(r,a,n,o,p,m),Ce(([,g,w,S,,,k])=>!k&&!S&&g!==0&&w===no),ce(([[g],,,,,w])=>(w("Upward scrolling compensation",{amount:g},Vt.DEBUG),g))));function y(g){g>0?(Oe(t,{behavior:"auto",top:-g}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-g}))}return ot(W(x,Le(e,s)),([g,w,S])=>{S&&Xb()?Oe(e,w-g):y(-g)}),ot(W(It(Dt(s,!1),e,m),Ce(([g,w,S])=>!g&&!S&&w!==0),ce(([g,w])=>w),_n(1)),y),me(W(f,ce(g=>({top:-g}))),t),ot(W(c,Le(h,d),ce(([g,{groupIndices:w,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(w.length===0)return C(g);{let E=0;const j=Jr(k,0);let N=0,A=0;for(;N<g;){N++,E+=j;let M=w.length===A+1?1/0:w[A+1]-w[A]-1;N+M>g&&(E-=j,M=g-N+1),N+=M,E+=C(M),A++}return E}})),g=>{Oe(e,g),requestAnimationFrame(()=>{Oe(t,{top:g}),requestAnimationFrame(()=>{Oe(e,0),Oe(m,!1)})})}),{deviation:e}},ht(Bt,oo,sr,Tn,Fn,ca)),Zb=et(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ht(pa,Vb,zn,nf,Zd,Kb,Bb,ga,ef,Fn,Qd)),of=et(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m},x,y,g,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:j},N])=>(me(k.rangeChanged,N.scrollSeekRangeChanged),me(W(N.windowViewportRect,ce(A=>A.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:m,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...N,...x,sizes:l,...y}),ht(Tn,to,Bt,qb,Wb,sr,eo,Jb,Yb,Wd,Zb));function Qb(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 Ss=typeof document<"u"?b.useLayoutEffect:b.useEffect;function sf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(y,g){y.propsReady&&Oe(y.propsReady,!1);for(const w of r){const S=y[t.required[w]];Oe(S,g[w])}for(const w of o)if(w in g){const S=y[t.optional[w]];Oe(S,g[w])}y.propsReady&&Oe(y.propsReady,!0)}function c(y){return s.reduce((g,w)=>(g[w]=S=>{const k=y[t.methods[w]];Oe(k,S)},g),{})}function d(y){return i.reduce((g,w)=>(g[w]=mb(y[t.events[w]]),g),{})}const f=b.forwardRef((y,g)=>{const{children:w,...S}=y,[k]=b.useState(()=>ps(xb(e),E=>{l(E,S)})),[T]=b.useState(Nd(d,k));Ss(()=>{for(const E of i)E in S&&ot(T[E],S[E]);return()=>{Object.values(T).map(na)}},[S,T,k]),Ss(()=>{l(k,S)}),b.useImperativeHandle(g,Ed(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...Qb([...r,...o,...i],S),children:w}):w})}),h=y=>{const g=b.useContext(a);return b.useCallback(w=>{Oe(g[y],w)},[g,y])},p=y=>{const g=b.useContext(a)[y],w=b.useCallback(S=>ot(g,S),[g]);return b.useSyncExternalStore(w,()=>bt(g),()=>bt(g))},m=y=>{const g=b.useContext(a)[y],[w,S]=b.useState(Nd(bt,g));return Ss(()=>ot(g,k=>{k!==w&&S(Ed(k))}),[g,w]),w},x=b.version.startsWith("18")?p:m;return{Component:f,useEmitter:(y,g)=>{const w=b.useContext(a)[y];Ss(()=>ot(w,g),[g,w])},useEmitterValue:x,usePublisher:h}}const af=b.createContext(void 0),lf=b.createContext(void 0),cf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function xa(e){return"self"in e}function e0(e){return"body"in e}function uf(e,t,n,r=Ir,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(h=>{let p,m,x;const y=h.target;if(e0(y)||xa(y)){const w=xa(y)?y:y.defaultView;x=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,m=s?w.innerWidth:w.innerHeight}else x=s?y.scrollLeft:y.scrollTop,p=s?y.scrollWidth:y.scrollHeight,m=s?y.offsetWidth:y.offsetHeight;const g=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:m})};h.suppressFlushSync?g():Js.flushSync(g),a.current!==null&&(x===a.current||x<=0||x===p-m)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const h=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",c)}},[i,c,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 m=h.behavior==="smooth";let x,y,g;xa(p)?(y=Math.max($n(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,g=s?window.scrollX:window.scrollY):(y=p[s?"scrollWidth":"scrollHeight"],x=$n(p,s?"width":"height"),g=p[s?"scrollLeft":"scrollTop"]);const w=y-x;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Kd(x,y)||h.top===g){e({scrollHeight:y,scrollTop:g,viewportHeight:x}),m&&t(!0);return}m?(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 ya="-webkit-sticky",df="sticky",va=rf(()=>{if(typeof document>"u")return df;const e=document.createElement("div");return e.style.position=ya,e.style.position===ya?ya:df});function wa(e){return e}const t0=et(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(wa),o=X("div"),s=X(Ir),i=(a,l=null)=>Dt(W(n,ce(c=>c[a]),pt()),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")}}),n0=et(([e,t])=>({...e,...t}),ht(of,t0)),r0=({height:e})=>u.jsx("div",{style:{height:e}}),o0={overflowAnchor:"none",position:va(),zIndex:1},ff={overflowAnchor:"none"},s0={...ff,display:"inline-block",height:"100%"},hf=b.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=rn("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),c=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),h=Ie("itemSize"),p=Ie("log"),m=rn("gap"),x=Ie("horizontalDirection"),{callbackRef:y}=wb(n,h,f,e?Ir:a,p,m,o,x,Ie("skipAnimationFrameInResizeObserver")),[g,w]=b.useState(0);ba("deviation",R=>{g!==R&&w(R)});const S=Ie("EmptyPlaceholder"),k=Ie("ScrollSeekPlaceholder")||r0,T=Ie("ListComponent"),C=Ie("ItemComponent"),E=Ie("GroupComponent"),j=Ie("computeItemKey"),N=Ie("isSeeking"),A=Ie("groupIndices").length>0,M=Ie("alignToBottom"),F=Ie("initialItemFinalLocationReached"),$=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:g!==0?g:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...F?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Lt(S,c)}):u.jsx(T,{...Lt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:$,children:(e?t.topItems:t.items).map(R=>{const z=R.originalIndex,_=j(z+t.firstItemIndex,R.data,c);return N?b.createElement(k,{...Lt(k,c),height:R.size,index:R.index,key:_,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?b.createElement(E,{...Lt(E,c),"data-index":z,"data-item-index":R.index,"data-known-size":R.size,key:_,style:o0},d(R.index,c)):b.createElement(C,{...Lt(C,c),...c0(C,R.data),"data-index":z,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:_,style:x?s0:ff},A?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),i0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},a0={outline:"none",overflowX:"auto",position:"relative"},Cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),l0={position:va(),top:0,width:"100%",zIndex:1};function Lt(e,t){if(typeof e!="string")return{context:t}}function c0(e,t){return{item:typeof e=="string"?void 0:t}}const u0=b.memo(function(){const e=Ie("HeaderComponent"),t=rn("headerHeight"),n=Ie("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),d0=b.memo(function(){const e=Ie("FooterComponent"),t=rn("footerHeight"),n=Ie("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null});function pf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:m}=uf(a,c,l,d,void 0,f);return e("scrollTo",m),e("scrollBy",h),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?a0:i0,...o},tabIndex:0,...i,...Lt(l,s),children:r})})}function mf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=b.useRef(null),m=t("scrollerRef"),{scrollByCallback:x,scrollerRef:y,scrollToCallback:g}=uf(a,c,l,m,h);return cf(()=>{var w;return y.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{y.current=null}},[y,h]),e("windowScrollTo",g),e("scrollBy",x),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Lt(l,s),children:r})})}const f0=({children:e})=>{const t=b.useContext(af),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=b.useMemo(()=>Id(n,l=>$n(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ie("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Cs(o),children:e})},h0=({children:e})=>{const t=b.useContext(af),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ie("customScrollParent"),s=Rd(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Cs(i),children:e})},p0=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...l0,marginTop:`${n}px`},o=Ie("context");return u.jsx(t,{style:r,...Lt(t,o),children:e})},m0=b.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return u.jsxs(r||t?y0:x0,{...e,context:o,children:[n&&u.jsx(p0,{children:u.jsx(hf,{showTopList:!0})}),u.jsxs(r||t?h0:f0,{children:[u.jsx(u0,{}),u.jsx(hf,{}),u.jsx(d0,{})]})]})}),{Component:g0,useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}=sf(n0,{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"}},m0),x0=pf({useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}),y0=mf({useEmitter:ba,useEmitterValue:Ie,usePublisher:rn}),v0=g0;ht(of,et(()=>{const e=X(c=>u.jsxs("td",{children:["Item $",c]})),t=X(null),n=X(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=X(null),o=X(null),s=X({}),i=X(wa),a=X(Ir),l=(c,d=null)=>Dt(W(s,ce(f=>f[c]),pt()),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")}})),va();const gf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},w0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:xf,floor:Ts,max:so,min:Sa,round:yf}=Math;function vf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function b0(e){return{...w0,items:e}}function ks(e,t){return e&&e.width===t.width&&e.height===t.height}function S0(e,t){return e&&e.column===t.column&&e.row===t.row}const C0=et(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:m,propsReady:x},{customScrollParent:y,useWindowScroll:g,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},T])=>{const C=X(0),E=X(0),j=X(gf),N=X({height:0,width:0}),A=X({height:0,width:0}),M=Ve(),F=Ve(),$=X(0),R=X(null),z=X({column:0,row:0}),_=Ve(),B=Ve(),L=X(!1),D=X(0),Z=X(!0),J=X(!1),pe=X(!1);ot(W(m,Le(D),Ce(([O,H])=>!!H)),()=>{Oe(Z,!1)}),ot(W(It(m,Z,A,N,D,J),Ce(([O,H,te,ie,,ne])=>O&&!H&&te.height!==0&&ie.height!==0&&!ne)),([,,,,O])=>{Oe(J,!0),fa(1,()=>{Oe(M,O)}),fn(W(c),()=>{Oe(t,[0,0]),Oe(Z,!0)})}),me(W(B,Ce(O=>O!=null&&O.scrollTop>0),Sn(0)),E),ot(W(m,Le(B),Ce(([,O])=>O!=null)),([,O])=>{O&&(Oe(N,O.viewport),Oe(A,O.item),Oe(z,O.gap),O.scrollTop>0&&(Oe(L,!0),fn(W(c,nr(1)),H=>{Oe(L,!1)}),Oe(l,{top:O.scrollTop})))}),me(W(N,ce(({height:O})=>O)),f),me(W(It(Se(N,ks),Se(A,ks),Se(z,(O,H)=>O&&O.column===H.column&&O.row===H.row),Se(c)),ce(([O,H,te,ie])=>({gap:te,item:H,scrollTop:ie,viewport:O}))),_),me(W(It(Se(C),r,Se(z,S0),Se(A,ks),Se(N,ks),Se(R),Se(E),Se(L),Se(Z),Se(D)),Ce(([,,,,,,,O])=>!O),ce(([O,[H,te],ie,ne,Fe,Y,fe,,ke,je])=>{const{column:Be,row:He}=ie,{height:Ke,width:qe}=ne,{width:Ge}=Fe;if(fe===0&&(O===0||Ge===0))return gf;if(qe===0){const re=ha(je,O),Ye=re+Math.max(fe-1,0);return b0(vf(re,Ye,Y))}const tt=wf(Ge,qe,Be);let Qe,st;ke?H===0&&te===0&&fe>0?(Qe=0,st=fe-1):(Qe=tt*Ts((H+He)/(Ke+He)),st=tt*xf((te+He)/(Ke+He))-1,st=Sa(O-1,so(st,tt-1)),Qe=Sa(st,so(0,Qe))):(Qe=0,st=-1);const St=vf(Qe,st,Y),{bottom:mt,top:at}=bf(Fe,ie,ne,St),Ct=xf(O/tt),de=Ct*Ke+(Ct-1)*He-mt;return{bottom:mt,itemHeight:Ke,items:St,itemWidth:qe,offsetBottom:de,offsetTop:at,top:at}})),j),me(W(R,Ce(O=>O!==null),ce(O=>O.length)),C),me(W(It(N,A,j,z),Ce(([O,H,{items:te}])=>te.length>0&&H.height!==0&&O.height!==0),ce(([O,H,{items:te},ie])=>{const{bottom:ne,top:Fe}=bf(O,ie,H,te);return[Fe,ne]}),pt(Zr)),t);const Ee=X(!1);me(W(c,Le(Ee),ce(([O,H])=>H||O!==0)),Ee);const Ne=Xt(W(It(j,C),Ce(([{items:O}])=>O.length>0),Le(Ee),Ce(([[O,H],te])=>{const ie=O.items[O.items.length-1].index===H-1;return(te||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===H)&&ie}),ce(([[,O]])=>O-1),pt())),V=Xt(W(Se(j),Ce(({items:O})=>O.length>0&&O[0].index===0),Sn(0),pt())),ee=Xt(W(Se(j),Le(L),Ce(([{items:O},H])=>O.length>0&&!H),ce(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),pt($d),_n(0)));me(ee,p.scrollSeekRangeChanged),me(W(M,Le(N,A,C,z),ce(([O,H,te,ie,ne])=>{const Fe=Vd(O),{align:Y,behavior:fe,offset:ke}=Fe;let je=Fe.index;je==="LAST"&&(je=ie-1),je=so(0,je,Sa(ie-1,je));let Be=Ca(H,ne,te,je);return Y==="end"?Be=yf(Be-H.height+te.height):Y==="center"&&(Be=yf(Be-H.height/2+te.height/2)),ke&&(Be+=ke),{behavior:fe,top:Be}})),l);const U=Dt(W(j,ce(O=>O.offsetBottom+O.bottom)),0);return me(W(k,ce(O=>({height:O.visibleHeight,width:O.visibleWidth}))),N),{customScrollParent:y,data:R,deviation:$,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:A,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:F,scrollTo:l,scrollToIndex:M,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:N,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...p,gridState:j,horizontalDirection:pe,initialTopMostItemIndex:D,totalListHeight:U,...h,endReached:Ne,propsReady:x,rangeChanged:ee,startReached:V,stateChanged:_,stateRestoreInProgress:L,...T}},ht(pa,Bt,oo,nf,zn,ga,Fn));function wf(e,t,n){return so(1,Ts((e+n)/(Ts(t)+n)))}function bf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ca(e,t,n,r[0].index);return{bottom:Ca(e,t,n,r[r.length-1].index)+o,top:s}}function Ca(e,t,n,r){const o=wf(e.width,n.width,t.column),s=Ts(r/o),i=s*n.height+so(0,s-1)*t.row;return i>0?i+t.row:i}const T0=et(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(wa),i=X("div"),a=X(Ir),l=(f,h=null)=>Dt(W(t,ce(p=>p[f]),pt()),h),c=X(!1),d=X(!1);return me(Se(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),k0=et(([e,t])=>({...e,...t}),ht(C0,T0)),E0=b.memo(function(){const e=xt("gridState"),t=xt("listClassName"),n=xt("itemClassName"),r=xt("itemContent"),o=xt("computeItemKey"),s=xt("isSeeking"),i=on("scrollHeight"),a=xt("ItemComponent"),l=xt("ListComponent"),c=xt("ScrollSeekPlaceholder"),d=xt("context"),f=on("itemDimensions"),h=on("gap"),p=xt("log"),m=xt("stateRestoreInProgress"),x=on("reportReadyState"),y=rr(b.useMemo(()=>g=>{const w=g.parentElement.parentElement.scrollHeight;i(w);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}h({column:Cf("column-gap",getComputedStyle(g).columnGap,p),row:Cf("row-gap",getComputedStyle(g).rowGap,p)})},[i,f,h,p]),!0,!1);return cf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),m?null:u.jsx(l,{className:t,ref:y,...Lt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const w=o(g.index,g.data,d);return s?u.jsx(c,{...Lt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},w):b.createElement(a,{...Lt(a,d),className:n,"data-index":g.index,key:w},r(g.index,g.data,d))})})}),I0=b.memo(function(){const e=xt("HeaderComponent"),t=on("headerHeight"),n=xt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),N0=b.memo(function(){const e=xt("FooterComponent"),t=on("footerHeight"),n=xt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=xt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Lt(e,o)})}):null}),A0=({children:e})=>{const t=b.useContext(lf),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Cs(!1),children:e})},j0=({children:e})=>{const t=b.useContext(lf),n=on("windowViewportRect"),r=on("itemDimensions"),o=xt("customScrollParent"),s=Rd(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Cs(!1),children:e})},_0=b.memo(function({...e}){const t=xt("useWindowScroll"),n=xt("customScrollParent"),r=n||t?P0:R0,o=n||t?j0:A0,s=xt("context");return u.jsx(r,{...e,...Lt(r,s),children:u.jsxs(o,{children:[u.jsx(I0,{}),u.jsx(E0,{}),u.jsx(N0,{})]})})}),{useEmitter:Sf,useEmitterValue:xt,usePublisher:on}=sf(k0,{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"}},_0),R0=pf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on}),P0=mf({useEmitter:Sf,useEmitterValue:xt,usePublisher:on});function Cf(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 O0=xo.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 Tf({className:e,variant:t,...n}){return u.jsx("div",{className:Q(O0({variant:t}),e),...n})}const io=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));io.displayName="Card";const ao=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));ao.displayName="CardHeader";const lo=v.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));lo.displayName="CardTitle";const kf=v.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));kf.displayName="CardDescription";const co=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));co.displayName="CardContent";const Ef=v.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Ef.displayName="CardFooter";const M0=1,D0=1e6;let Ta=0;function L0(){return Ta=(Ta+1)%Number.MAX_SAFE_INTEGER,Ta.toString()}const ka=new Map,If=e=>{if(ka.has(e))return;const t=setTimeout(()=>{ka.delete(e),uo({type:"REMOVE_TOAST",toastId:e})},D0);ka.set(e,t)},F0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,M0)};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?If(n):e.toasts.forEach(r=>{If(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)}}},Es=[];let Is={toasts:[]};function uo(e){Is=F0(Is,e),Es.forEach(t=>{t(Is)})}function $0({...e}){const t=L0(),n=o=>uo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>uo({type:"DISMISS_TOAST",toastId:t});return uo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ea(){const[e,t]=v.useState(Is);return v.useEffect(()=>(Es.push(t),()=>{const n=Es.indexOf(t);n>-1&&Es.splice(n,1)}),[e]),{...e,toast:$0,dismiss:n=>uo({type:"DISMISS_TOAST",toastId:n})}}async function Nf(e,t){return await Qt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Af(e,t){return await(await Nf(`/files/${e}/view`,t)).text()}async function z0(e,t){const n=await Nf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Qt(`/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 B0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Qt("/files",{params:r})}function Ia(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 jf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function fo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(fo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(jf(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=fo(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 ho(e){if(typeof e=="string")return e;if(jf(e))return"";try{const t=fo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function H0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function U0(e){const t=ho(e);return typeof e=="string"&&H0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Ns(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ia(t);if(n!==null)return Ns(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Ns(e.content):e}var As="Dialog",[_f,vT]=In(As),[W0,pn]=_f(As),Rf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=v.useRef(null),l=v.useRef(null),[c,d]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return u.jsx(W0,{scope:t,triggerRef:a,contentRef:l,contentId:Nn(),titleId:Nn(),descriptionId:Nn(),open:c,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Rf.displayName=As;var Pf="DialogTrigger",Of=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Pf,n),s=We(t,o.triggerRef);return u.jsx(Ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ja(o.open),...r,ref:s,onClick:he(e.onClick,o.onOpenToggle)})});Of.displayName=Pf;var Na="DialogPortal",[V0,Mf]=_f(Na,{forceMount:void 0}),Df=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(Na,t);return u.jsx(V0,{scope:t,forceMount:n,children:v.Children.map(r,i=>u.jsx(tn,{present:n||s.open,children:u.jsx(Jo,{asChild:!0,container:o,children:i})}))})};Df.displayName=Na;var js="DialogOverlay",Lf=v.forwardRef((e,t)=>{const n=Mf(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(js,e.__scopeDialog);return s.modal?u.jsx(tn,{present:r||s.open,children:u.jsx(q0,{...o,ref:t})}):null});Lf.displayName=js;var K0=Yn.createSlot("DialogOverlay.RemoveScroll"),q0=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(js,n);return u.jsx(is,{as:K0,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Ae.div,{"data-state":ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Ff=v.forwardRef((e,t)=>{const n=Mf(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(tn,{present:r||s.open,children:s.modal?u.jsx(G0,{...o,ref:t}):u.jsx(Y0,{...o,ref:t})})});Ff.displayName=ir;var G0=v.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=v.useRef(null),o=We(t,n.contentRef,r);return v.useEffect(()=>{const s=r.current;if(s)return Bi(s)},[]),u.jsx($f,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:he(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:he(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:he(e.onFocusOutside,s=>s.preventDefault())})}),Y0=v.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return u.jsx($f,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),$f=v.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(ir,n),l=v.useRef(null),c=We(t,l);return Si(),u.jsxs(u.Fragment,{children:[u.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Fo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(X0,{titleId:a.titleId}),u.jsx(Z0,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Aa="DialogTitle",zf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Aa,n);return u.jsx(Ae.h2,{id:o.titleId,...r,ref:t})});zf.displayName=Aa;var Bf="DialogDescription",Hf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Bf,n);return u.jsx(Ae.p,{id:o.descriptionId,...r,ref:t})});Hf.displayName=Bf;var Uf="DialogClose",Wf=v.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Uf,n);return u.jsx(Ae.button,{type:"button",...r,ref:t,onClick:he(e.onClick,()=>o.onOpenChange(!1))})});Wf.displayName=Uf;function ja(e){return e?"open":"closed"}var Vf="DialogTitleWarning",[wT,Kf]=tx(Vf,{contentName:ir,titleName:Aa,docsSlug:"dialog"}),X0=({titleId:e})=>{const t=Kf(Vf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
87
87
|
|
|
88
88
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
89
89
|
|
|
90
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},J0="DialogDescriptionWarning",Z0=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kf(J0).contentName}}.`;return v.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},qf=Rf,Q0=Of,Gf=Df,_s=Lf,Rs=Ff,ar=zf,Ps=Hf,Yf=Wf;const eS=qf,tS=Gf,Xf=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:Q("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}));Xf.displayName=_s.displayName;const Jf=v.forwardRef(({className:e,children:t,...n},r)=>{const o=v.useMemo(()=>{let s=!1;function i(a){v.Children.forEach(a,l=>{if(s||!v.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(tS,{children:[u.jsx(Xf,{}),u.jsxs(Rs,{ref:r,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(Yf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Jf.displayName=Rs.displayName;const Zf=({className:e,...t})=>u.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Zf.displayName="DialogHeader";const Qf=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));Qf.displayName=ar.displayName;const nS=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));nS.displayName=Ps.displayName;function rS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=Ea(),
|
|
90
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},J0="DialogDescriptionWarning",Z0=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kf(J0).contentName}}.`;return v.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},qf=Rf,Q0=Of,Gf=Df,_s=Lf,Rs=Ff,ar=zf,Ps=Hf,Yf=Wf;const eS=qf,tS=Gf,Xf=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:Q("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}));Xf.displayName=_s.displayName;const Jf=v.forwardRef(({className:e,children:t,...n},r)=>{const o=v.useMemo(()=>{let s=!1;function i(a){v.Children.forEach(a,l=>{if(s||!v.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(tS,{children:[u.jsx(Xf,{}),u.jsxs(Rs,{ref:r,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(Yf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Jf.displayName=Rs.displayName;const Zf=({className:e,...t})=>u.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Zf.displayName="DialogHeader";const Qf=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));Qf.displayName=ar.displayName;const nS=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));nS.displayName=Ps.displayName;function rS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=Ea(),h=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const g=await Af(n);l(g)}catch(g){console.error("Failed to load file:",g),d(g instanceof Error?g.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await z0(n),f({title:"Download started",description:`Downloading ${r}`})}catch(g){console.error("Failed to download file:",g),f({title:"Download failed",description:String(g),variant:"destructive"})}},m=async()=>{if(n)try{const g=await Af(n),w=new Blob([g],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(g){console.error("Failed to open file externally:",g),f({title:"Failed to open file",description:String(g),variant:"destructive"})}},x=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(se.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(rt,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(se.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),y=()=>o.startsWith("image/")?u.jsx(se.Image,{className:"h-5 w-5"}):u.jsx(se.FileText,{className:"h-5 w-5"});return u.jsx(eS,{open:e,onOpenChange:t,children:u.jsxs(Jf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Zf,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[y(),u.jsxs("div",{children:[u.jsx(Qf,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(rt,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[u.jsx(se.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(rt,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[u.jsx(se.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function eh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let lr=eh();function oS(e){lr=e}const th=/[&<>"']/,sS=new RegExp(th.source,"g"),nh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,iS=new RegExp(nh.source,"g"),aS={"&":"&","<":"<",">":">",'"':""","'":"'"},rh=e=>aS[e];function Ft(e,t){if(t){if(th.test(e))return e.replace(sS,rh)}else if(nh.test(e))return e.replace(iS,rh);return e}const lS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function oh(e){return e.replace(lS,(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 cS=/(^|[^\[])\^/g;function ut(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(cS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const uS=/[^\w:]/g,dS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function sh(e,t,n){if(e){let r;try{r=decodeURIComponent(oh(n)).replace(uS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!dS.test(n)&&(n=mS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Os={},fS=/^[^:]+:\/*[^/]*$/,hS=/^([^:]+:)[\s\S]*$/,pS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function mS(e,t){Os[" "+e]||(fS.test(e)?Os[" "+e]=e+"/":Os[" "+e]=Ds(e,"/",!0)),e=Os[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(hS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(pS,"$1")+t:e+t}const Ms={exec:function(){}};function ih(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Ds(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 gS(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 xS(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 ah(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function lh(e,t,n,r){const o=t.href,s=t.title?Ft(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:Ft(i)}}function yS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
91
91
|
`).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(`
|
|
92
92
|
`)}class _a{constructor(t){this.options=t||lr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Ds(r,`
|
|
93
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=yS(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=Ds(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,p,
|
|
93
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=yS(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=Ds(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,h,p,m,x=n[1].trim();const y=x.length>1,g={type:"list",raw:"",ordered:y,start:y?+x.slice(0,-1):"",loose:!1,items:[]};x=y?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=y?x:"[*+-]");const w=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(m=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
94
94
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
95
|
-
`,1)[0],this.options.pedantic?(i=2,
|
|
96
|
-
`,t=t.substring(f.length+1),m=!0),!m){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(
|
|
97
|
-
`,1)[0],f=
|
|
98
|
-
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||C.test(d)||E.test(d)||T.test(d))break;
|
|
99
|
-
`+f}!l&&!f.trim()&&(l=!0),r+=
|
|
100
|
-
`,t=t.substring(
|
|
101
|
-
`):[]};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]=
|
|
102
|
-
`?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:Ft(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]):Ft(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=Ds(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=gS(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)),
|
|
103
|
-
]`).replace("lheading",ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ms,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:Ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=
|
|
95
|
+
`,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
96
|
+
`,t=t.substring(f.length+1),m=!0),!m){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
97
|
+
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||E.test(f)||k.test(f)||T.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
98
|
+
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||C.test(d)||E.test(d)||T.test(d))break;p+=`
|
|
99
|
+
`+f}!l&&!f.trim()&&(l=!0),r+=h+`
|
|
100
|
+
`,t=t.substring(h.length+1),d=f.slice(i)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=p.trimRight(),g.raw=g.raw.trimRight();const S=g.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,g.items[a].tokens=this.lexer.blockTokens(g.items[a].text,[]),!g.loose){const k=g.items[a].tokens.filter(C=>C.type==="space"),T=k.length>0&&k.some(C=>/\n.*\n/.test(C.raw));g.loose=T}if(g.loose)for(a=0;a<S;a++)g.items[a].loose=!0;return g}}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]):Ft(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:ih(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
101
|
+
`):[]};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]=ih(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
102
|
+
`?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:Ft(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]):Ft(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=Ds(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=gS(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)),lh(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 lh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const 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]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const m=h.slice(1,-1);return{type:"em",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}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=Ft(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=Ft(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ft(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=Ft(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=Ft(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]):Ft(r[0]):r[0]:o=Ft(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ye={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:Ms,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ye._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ye._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ye.def=ut(ye.def).replace("label",ye._label).replace("title",ye._title).getRegex(),ye.bullet=/(?:[*+-]|\d{1,9}[.)])/,ye.listItemStart=ut(/^( *)(bull) */).replace("bull",ye.bullet).getRegex(),ye.list=ut(ye.list).replace(/bull/g,ye.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ye.def.source+")").getRegex(),ye._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",ye._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ye.html=ut(ye.html,"i").replace("comment",ye._comment).replace("tag",ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ye.paragraph=ut(ye._paragraph).replace("hr",ye.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",ye._tag).getRegex(),ye.blockquote=ut(ye.blockquote).replace("paragraph",ye.paragraph).getRegex(),ye.normal={...ye},ye.gfm={...ye.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ye.gfm.table=ut(ye.gfm.table).replace("hr",ye.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",ye._tag).getRegex(),ye.gfm.paragraph=ut(ye._paragraph).replace("hr",ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ye.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",ye._tag).getRegex(),ye.pedantic={...ye.normal,html:ut(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ye._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:Ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ut(ye.normal._paragraph).replace("hr",ye.hr).replace("heading",` *#{1,6} *[^
|
|
103
|
+
]`).replace("lheading",ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ms,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:Ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=ut(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=ut(ye._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=ut(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=ut(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=ut(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=ut(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=ut(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=ut(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=ut(ue.reflink).replace("label",ue._label).replace("ref",ye._label).getRegex(),ue.nolink=ut(ue.nolink).replace("ref",ye._label).getRegex(),ue.reflinkSearch=ut(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.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:ut(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:ut(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:ut(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=ut(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:ut(ue.br).replace("{2,}","*").getRegex(),text:ut(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function vS(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 ch(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 Bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new _a,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:ye.normal,inline:ue.normal};this.options.pedantic?(n.block=ye.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=ye.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:ye,inline:ue}}static lex(t,n){return new Bn(n).lex(t)}static lexInline(t,n){return new Bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
104
104
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
105
105
|
`: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+=`
|
|
106
106
|
`+r.raw,o.text+=`
|
|
@@ -110,7 +110,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
110
110
|
`+r.raw,o.text+=`
|
|
111
111
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
112
112
|
`+r.raw,o.text+=`
|
|
113
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+
|
|
113
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+ah("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+ah("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ch)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ch))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,vS)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ra{constructor(t){this.options=t||lr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
114
114
|
`,o?'<pre><code class="'+this.options.langPrefix+Ft(o)+'">'+(r?t:Ft(t,!0))+`</code></pre>
|
|
115
115
|
`:"<pre><code>"+(r?t:Ft(t,!0))+`</code></pre>
|
|
116
116
|
`}blockquote(t){return`<blockquote>
|
|
@@ -130,8 +130,8 @@ ${t}</blockquote>
|
|
|
130
130
|
`}tablerow(t){return`<tr>
|
|
131
131
|
${t}</tr>
|
|
132
132
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
133
|
-
`}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=
|
|
134
|
-
`+(
|
|
135
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ft(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
|
|
136
|
-
`)):r=t(e),r||""}function TS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function
|
|
137
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[Ne[ve]?u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ft,Ne[ve]?" (processing)":""]})]},ve)}if(V.type==="interrupt"){const xe=V,ft=Fs((xe==null?void 0:xe.id)??(xe==null?void 0:xe.interrupt_id)),gt=!!(ke&&ft&&ft===ke),Tt=gt?je??(xe==null?void 0:xe.value):xe==null?void 0:xe.value,Pe=ft?{...xe,id:ft,interrupt_id:ft}:xe;return u.jsx(ES,{interruptPart:Pe,onApprove:ot,onReject:St,disabled:w,isActive:gt,payload:Tt},ve)}return null},[W,Ne,ot,St,D,c,d,R,L,ke,je,g,w,Y]),it=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ct=b.useCallback(()=>{const V=te.trim().length>0||ne.length>0||De.length>0||Y.length>0;if(!Z&&De.length>0&&!r)return it();if(!Z&&!V&&!r)return null;if(Z)return u.jsx(AS,{message:t,viewMode:F},t.id);if(!Z&&!J){const ve=t,xe=u.jsx("div",{className:"space-y-2",children:ve.content.map((ft,gt)=>u.jsx(mt,{part:ft,i:gt},gt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,u.jsx(kS,{className:H})]}):xe}},[te,ne.length,De.length,Y.length,r,Z,F,it,H]),de=b.useMemo(()=>J?"Assistant":TS(t),[J,t]),re=b.useMemo(()=>J?[]:Array.isArray(T)?T:[],[T,J]),Qe=b.useMemo(()=>{var V;return re.length?j&&re.some(ve=>ve.id===j)?j:((V=re[0])==null?void 0:V.id)??null:null},[j,re]),Le=b.useMemo(()=>!re.length||!C?null:re.some(V=>V.id===C)?C:null,[C,re])??Qe,ut=D==="user"&&re.length>0&&typeof E=="function",et=b.useCallback(V=>{if(!E)return;const ve=(V==null?void 0:V.id)??null,xe=(V==null?void 0:V.parentId)??N??null;E(ve,xe)},[N,E]),Fe=b.useMemo(()=>Le?re.findIndex(V=>V.id===Le):-1,[Le,re]),jt=b.useMemo(()=>Fe<0?null:re[Fe]??null,[Fe,re]),At=b.useCallback(V=>{const ve=[];if(V.step!==null&&ve.push(`Step ${V.step}`),V.source&&ve.push(V.source),!V.createdAt)return ve.length?ve.join(" • "):V.id.slice(0,8);let xe="";try{const ft=new Date(V.createdAt);Number.isNaN(ft.getTime())||(xe=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ft))}catch{xe=""}return`${xe}`},[]);return Z&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:Q(Ze(),p.container),children:u.jsxs("div",{className:Q(Xe(),p.content),children:[(i||a||Z)&&u.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",H,p.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[qe(),a&&de&&u.jsx("span",{className:Q("font-medium",L?"text-xs":"text-sm"),children:de}),Z&&u.jsxs(Tf,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer select-none",H,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":F==="expanded",onClick:()=>$(V=>V==="expanded"?"preview":"expanded"),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),$(ve=>ve==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ie.name??"Tool Output"}),ie.toolCallId&&u.jsx("span",{className:"opacity-70",children:ie.toolCallId.slice(0,8)}),F==="expanded"?u.jsx(se.ChevronUp,{className:"h-3 w-3"}):u.jsx(se.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[ut&&jt&&Fe>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:Q("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Fe>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Fe<=0)return;const V=re[Fe-1];V&&et(V)},"aria-label":"Previous checkpoint",disabled:Fe<=0,children:u.jsx(se.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[Fe+1," / ",re.length]}),u.jsx("span",{className:"text-muted-foreground",children:At(jt)})]}),u.jsx("button",{type:"button",className:Q("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Fe<re.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Fe>=re.length-1)return;const V=re[Fe+1];V&&et(V)},"aria-label":"Next checkpoint",disabled:Fe>=re.length-1,children:u.jsx(se.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:Q("text-xs opacity-60",H,L&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(se.Copy,{className:Q(A?"text-success":H,L?"h-3 w-3":"h-4 w-4")})})}),D==="user"&&h&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:Ve,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(se.Edit,{className:Q(H,L?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&m&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:Ke,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(se.RotateCcw,{className:Q(H,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Ct()}),Z&&F==="expanded"&&(ie.toolCallId||ie.name)&&u.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ie.name&&u.jsxs("div",{children:["Function: ",ie.name]}),ie.toolCallId&&u.jsxs("div",{children:["Call ID: ",ie.toolCallId]})]}),!(i||a||Z)&&s&&!o&&u.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Be(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Copy,{className:Q(A?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),D==="user"&&h&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:Ve,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Edit,{className:Q("text-current",L?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&m&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:Ke,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.RotateCcw,{className:Q("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),q&&u.jsx(rS,{isOpen:ee,onClose:O,fileId:q.id,fileName:q.name,mimeType:q.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,p,h;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&hp(e.message)===hp(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),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)===((c=t.customStyles)==null?void 0:c.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((p=e.customStyles)==null?void 0:p.header)===((h=t.customStyles)==null?void 0:h.header);return o&&s});function mp({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:bS,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:po(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:po(e)})}function ES({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=po(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(io,{className:Q("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ao,{className:"pb-3",children:[u.jsx(lo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(kf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(co,{className:"pt-0 pb-3",children:a}),u.jsx(Ef,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(nt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(nt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function IS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ea(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(h=>{a(h),c(!0)},[]),p=b.useCallback(async(h,m,x)=>{var y,g;if(!t){h.preventDefault();return}if(o[x]){h.preventDefault();return}try{const w=String(m.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],T=m.name||`file_${k}`,C=m.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(w.startsWith("data:")){h.preventDefault(),s(T=>({...T,[x]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await B0(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:m.name||C.filename||`file_${C.id}`,mimeType:m.mimeType||C.mime_type||"application/octet-stream"}),(y=k.update)==null||y.call(k,{id:k.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(g=k.update)==null||g.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[x]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function NS({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(ho,{content:e,allowHtml:!1}):u.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(nt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function AS({message:e,viewMode:t}){const r=pp(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Ia(c)??c:c;if(d&&typeof d=="object")return u.jsx(mp,{data:d});const f=typeof d=="string"?d:(()=>{try{return po(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=U0(c);return f?u.jsx(ho,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Ns(d);return s(f)}const a=fo(i),l=Ns(a);return s(l)}const gp=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,jS=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},Oa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:p,emptyMessage:h,followNewMessages:m=!0,isNavigatingCheckpoint:x=!1,onScrollAway:y,onAtBottom:g,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:N,onSelectCheckpoint:A,timelineCheckpoints:M},F)=>{const $=b.useRef(null),R=b.useRef(null),z=b.useRef(!1),[_,B]=b.useState(!0),L=b.useMemo(()=>w?e.some(Y=>"type"in Y&&Y.type==="default_message"?!1:Array.isArray(Y==null?void 0:Y.content)&&Y.content.some(fe=>fe&&fe.type==="interrupt"&&(fe.id??fe.interrupt_id)===w.id)):!1,[w,e]),D=b.useMemo(()=>{if(!w||L)return null;const Y=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let fe;const ke=w.value;if(ke&&typeof ke=="object"&&!Array.isArray(ke)){const je=ke.title;typeof je=="string"&&je.trim()&&(fe=je.trim())}return{id:`interrupt-${Y}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Y,value:ke,title:fe}]}},[w,L]),Z=b.useMemo(()=>D?[...e,D]:e,[e,D]),J=b.useMemo(()=>C?Z:Z.filter(Y=>(Y==null?void 0:Y.role)!=="tool"),[Z,C]),he=b.useMemo(()=>{const Y=new Set,fe=[];for(let ke=J.length-1;ke>=0;ke--){const je=J[ke];if(!je)continue;if("type"in je&&je.type==="default_message"){fe.push(je);continue}const ze=je,Be=jS(ze);Y.has(Be)||(Y.add(Be),fe.push(ze))}return fe.reverse()},[J]),Ee=b.useCallback(Y=>{B(Y),y&&y(!Y),g&&g(Y)},[y,g]),Ne=b.useMemo(()=>{if(a)return async()=>{if(!z.current){z.current=!0;try{await a()}finally{z.current=!1}}}},[a]),W=b.useMemo(()=>!m||x?!1:_?"auto":!1,[_,m,x]),ee=b.useMemo(()=>M??[],[M]),q=N??(ee.length?ee[ee.length-1].id:null),O=ee.length>0,H=b.useMemo(()=>{if(typeof h!="string")return null;const Y=h.trim();return Y?{id:"default-message",role:"assistant",type:"default_message",content:Y,createdAt:new Date().toISOString()}:null},[h]),te=O?u.jsxs("div",{className:"w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative z-50",children:[u.jsx(se.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:ee.map(Y=>{const fe=q===Y.id;return u.jsxs("button",{type:"button",disabled:!A,onClick:()=>A==null?void 0:A(Y.id),className:`relative flex items-start gap-3 text-left text-xs transition ${fe?"text-primary":"text-muted-foreground"} ${A?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${fe?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${fe?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:Y.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[Y.step!==null?`STEP ${Y.step}`:"STEP —",Y.next?` - ${Y.next}`:""]})]})]},Y.id)})})]}),A&&u.jsx("button",{type:"button",onClick:()=>A==null?void 0:A(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ie=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),ne=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Pa,{message:H,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:h??"No messages yet. Start a conversation!"}),De=he.length>0;return b.useImperativeHandle(F,()=>({scrollToLatest:()=>{var Y,fe;if($.current&&he.length>0){const ke=he.length-1;(fe=(Y=$.current).scrollToIndex)==null||fe.call(Y,{index:ke,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},scrollToTop:()=>{var Y,fe;$.current&&he.length>0?(fe=(Y=$.current).scrollToIndex)==null||fe.call(Y,{index:0,align:"start",behavior:"auto"}):R.current&&(R.current.scrollTop=0)}}),[he]),u.jsxs("div",{className:ie,style:p,children:[te,u.jsx("div",{className:"relative flex-1 min-h-0",children:De?u.jsx(v0,{ref:Y=>{$.current=Y},scrollerRef:Y=>{R.current=Y instanceof HTMLDivElement?Y:null},data:he,followOutput:W,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{Ne&&Ne()},atBottomStateChange:Ee,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Y,fe)=>gp(fe,Y),itemContent:(Y,fe)=>{var ot;const ke=gp(fe,Y),je="type"in fe&&fe.type==="default_message";let ze=[],Be=null,Ve={},Ke={},qe=null,Ze=null;if(!je){const St=fe,mt=St.checkpointId??null;Ve=St.additionalKwargs??{},Ke=St.responseMetadata??{};const it=mt&&E?E.get(mt)??null:null;qe=typeof Ve.step=="number"?Ve.step:typeof Ke.step=="number"?Ke.step:(it==null?void 0:it.step)??null;const Ct=typeof Ve.source=="string"?Ve.source:typeof Ke.source=="string"?Ke.source:(it==null?void 0:it.source)??null;Ze=Ct?String(Ct):null;const de=qe!==null&&Ze?`${qe}:${Ze}`:null;de&&(j!=null&&j.has(de))?ze=j.get(de)??[]:mt&&it&&(ze=[it]),Be=mt??((ot=ze[0])==null?void 0:ot.id)??null}const Xe=(()=>{if(typeof Ve.parentCheckpointId=="string")return Ve.parentCheckpointId;if(typeof Ke.parentCheckpointId=="string")return Ke.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":ke,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Pa,{message:fe,messageIndex:Y,isStreamingMessage:t&&n===fe.id,streamingDebounceMs:r,isEditing:i===fe.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(Y),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:ze,activeCheckpointId:N??null,onSelectCheckpoint:A,defaultCheckpointId:Be,messageParentCheckpointId:Xe})})}}):ne()})]})});Oa.displayName="MessageList";const xp={value:""};function $s({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,customStyles:f={},onMessageSent:p,onExcelUploadSuccess:h,onError:m}){const{api:x}=fi(),{currentThreadId:y}=Oo(),{threadId:g,messages:w,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:N,checkpoints:A,interrupt:M,metadata:F}=Mo(),{isStreaming:$,error:R,connectionState:z,submit:_,stop:B}=pc(),L=g??y??null,D=(N==null?void 0:N.id)??null,Z=(N==null?void 0:N.namespace)??null,J=(F==null?void 0:F.assemblingMessageId)??null,he=M,[Ee,Ne]=b.useState(!1);b.useEffect(()=>{he||Ne(!1)},[he]);const W=b.useCallback(()=>{Ne(!0)},[]),ee=b.useCallback(()=>{Ne(!1)},[]),q=!!he||Ee,[O,H]=b.useState(null),[te,ie]=b.useState(""),[ne,De]=b.useState(null),[Y,fe]=b.useState(null),[ke,je]=b.useState([]),[ze,Be]=b.useState(0),[Ve,Ke]=b.useState(0),[qe,Ze]=b.useState(!1),[Xe,ot]=b.useState(null),[St,mt]=b.useState(null),[it,Ct]=b.useState(!1),[de,re]=b.useState(null),[Qe,Re]=b.useState(!1),Le=b.useRef(!1),[ut,et]=b.useState(()=>xp.value),Fe=b.useRef(ut),jt=b.useRef(null),At=b.useCallback(G=>{xp.value=G,et(G)},[]),[V,ve]=b.useState(!1),xe=b.useRef(null),ft=b.useCallback(G=>{if(!Array.isArray(G))return{text:null,messageId:null};for(let oe=G.length-1;oe>=0;oe--){const le=G[oe];if(!le||le.role!=="user")continue;const be=(le.content??[]).filter(Ye=>(Ye==null?void 0:Ye.type)==="text").map(Ye=>Ye.text).filter(Ye=>typeof Ye=="string"&&Ye.trim().length>0);return{text:be.length?be.join(" ").trim():null,messageId:le.id??null}}return{text:null,messageId:null}},[]),gt=b.useCallback((G,oe)=>{if(!G||typeof G!="object")return null;const le=G[oe];return typeof le=="number"?le:null},[]),Tt=b.useCallback((G,oe)=>{if(!G||typeof G!="object")return null;const le=G[oe];return typeof le=="string"&&le.trim()?le:null},[]),Pe=b.useMemo(()=>{const G=be=>{if(!Array.isArray(be)||be.length===0)return null;const dt=be.map(Ye=>{if(typeof Ye=="string")return Ye.trim();if(Ye&&typeof Ye=="object"&&"type"in Ye){const tt=Ye;if(typeof tt.type=="string")return tt.type}return null}).filter(Ye=>!!(Ye&&Ye.length));return dt.length?dt.join(", "):null},oe=Array.isArray(A)?A.map(be=>{const dt=G(be.next);return dt?{...be,metadata:{...be.metadata??{},next:dt}}:be}):[];return oe.some(be=>gt(be.metadata,"step")!==null)&&oe.sort((be,dt)=>{const Ye=gt(be.metadata,"step"),tt=gt(dt.metadata,"step");if(Ye!==null||tt!==null)return(tt??Number.NEGATIVE_INFINITY)-(Ye??Number.NEGATIVE_INFINITY);const Ot=Date.parse(be.createdAt??""),ln=Date.parse(dt.createdAt??"");return Number.isNaN(Ot)||Number.isNaN(ln)?0:ln-Ot}),oe},[A,gt]),{checkpointMetaById:Kt,checkpointIndexByKey:at}=b.useMemo(()=>{const G=new Map,oe=new Map;for(const le of Pe){const be=le.checkpointId??null;if(!be)continue;const dt=gt(le.metadata,"step"),Ye=Tt(le.metadata,"source"),tt={id:be,step:dt,source:Ye,createdAt:le.createdAt??null,namespace:le.checkpointNs??null,parentId:le.parentId??null};if(G.set(be,tt),dt!==null&&Ye){const Ot=`${dt}:${Ye}`,ln=oe.get(Ot)??[];ln.push(tt),oe.set(Ot,ln)}}for(const le of oe.values())le.sort((be,dt)=>{const Ye=be.createdAt??"";return(dt.createdAt??"").localeCompare(Ye)});return{checkpointMetaById:G,checkpointIndexByKey:oe}},[Pe,gt,Tt]),kt=b.useMemo(()=>{var Ye;if(!Pe.length)return[];const G=[...Pe].reverse(),oe=(tt,Ot)=>{const ln=tt.checkpointId??null;if(!ln)return null;const pr=Tt(tt.metadata,"source");Tt(tt.metadata,"next");const{text:Vh,messageId:WC}=ft(tt.messages),Za=Vh&&Vh.replace(/\s+/g," ").trim()||Tt(tt.metadata,"title")||Tt(tt.metadata,"label")||Ot||pr||"Checkpoint",VC=Za.length>60?`${Za.slice(0,57)}…`:Za;return{id:ln,label:VC,messageId:WC??null,createdAt:tt.createdAt??null,step:gt(tt.metadata,"step"),source:pr??null,next:Tt(tt.metadata,"next")}},le=[],be=new Set;for(const tt of G){const Ot=((Ye=Tt(tt.metadata,"source"))==null?void 0:Ye.toLowerCase())??null;if(!(Ot==="input"||Ot==="user_input"||Ot==="user"))continue;const pr=oe(tt,"User input");pr&&!be.has(pr.id)&&(le.push(pr),be.add(pr.id))}if(!le.length)for(const tt of G){const Ot=oe(tt);Ot&&!be.has(Ot.id)&&(le.push(Ot),be.add(Ot.id))}const dt=Pe.find(tt=>{var ln;return(((ln=Tt(tt.metadata,"source"))==null?void 0:ln.toLowerCase())??null)==="loop"});if(dt){const tt=oe(dt,"Latest loop");tt&&!be.has(tt.id)&&(le.push(tt),be.add(tt.id))}return le},[Pe,ft,gt,Tt]),Kn=b.useRef(null),fr=b.useRef(null),qn=b.useCallback(()=>{Kn.current&&(Kn.current.value=""),fr.current&&(fr.current.value=""),Be(G=>G+1),Ke(G=>G+1)},[]),Ya=b.useCallback(G=>{At(G)},[At]),Xs=b.useRef(!1);b.useEffect(()=>{Xs.current&&!$&&(je([]),qn()),Xs.current=$},[$,qn]);const[Xa,Ja]=b.useState("desktop");b.useEffect(()=>{const G=()=>{const oe=window.innerWidth;Ja(oe<640?"phone":oe<1024?"tablet":"desktop")};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),b.useEffect(()=>{Re(!1),Le.current=!1},[L]),b.useEffect(()=>{Fe.current=ut},[ut]),b.useEffect(()=>{if(!O){jt.current=null;return}jt.current===null&&(jt.current=Fe.current),At(te??"")},[te,O,At]);const I=b.useCallback(async()=>{if(!(!S||k||!Qe))try{await C()}catch(G){console.warn("loadOlder failed",G)}},[S,Qe,k,C]);b.useEffect(()=>{(async()=>{if(!x.baseUrl){re(null);return}try{const le=(await x.getAgent("default")).uiDefaultMessage||"";re(le||null)}catch(oe){console.warn("Failed to fetch default message:",oe),re(null)}})()},[x.baseUrl]),b.useEffect(()=>{R&&!it&&(m==null||m(R))},[R,it,m]);const K=G=>{if(G.length>fs)return`Message too long (${G.length}/${fs} characters)`;try{return cb(G),null}catch(oe){return(oe==null?void 0:oe.message)||"Invalid message"}},ae=async G=>{const oe=G.trim();if(!(!oe&&ke.length===0)){if(oe){const le=K(oe);if(le){fe(le);return}}try{const le=D??void 0,be=Z??void 0,dt=O?{edit:!0,originalMessageId:O,...ne!=null&&ne.checkpointId?{originalCheckpointId:ne.checkpointId}:{},...ne!=null&&ne.checkpointNs?{originalCheckpointNs:ne.checkpointNs}:{}}:void 0;await _({text:oe||"",attachments:ke,messageAdditionalKwargs:dt},{checkpointId:le,checkpointNs:be}),p==null||p(oe),At(""),fe(null),je([]),qn(),H(null),ie(""),De(null)}catch(le){const be=(le==null?void 0:le.message)||"Failed to send message";fe(be),m==null||m(be)}}},we=b.useCallback((G,oe,le)=>{c&&(jt.current=ut,H(G),ie(oe),At(oe),fe(null),De({checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}))},[ut,c,At]),Ge=b.useCallback(()=>{H(null),ie(""),De(null),fe(null),At(jt.current??ut),jt.current=null},[ut,At]),st=b.useCallback((G,oe,le)=>{we(G,oe,le)},[we]),He=b.useCallback(G=>{for(let oe=G-1;oe>=0;oe--)if(w[oe].role==="user"){const le=w[oe].content||[],dt=le.filter(Ye=>Ye.type==="text").map(Ye=>Ye.text).join("")||(()=>{try{return JSON.stringify(le,null,2)}catch{return String(le)}})();dt&&_({text:dt},{checkpointId:D??void 0,checkpointNs:Z??void 0});break}},[w,_,D,Z]),$e=G=>{const oe=Array.from(G.target.files||[]);je(le=>[...le,...oe]),G.target.value=""},Pt=G=>{je(oe=>{const le=oe.filter((be,dt)=>G!==dt);return le.length===0&&qn(),le})},vt=async G=>{const oe=(G.target.files||[])[0];if(oe){ot(null),mt(null),Ze(!0);try{await _({attachments:[oe]},{checkpointId:D??void 0,checkpointNs:Z??void 0});const le=`Uploaded ${oe.name} - processing through chat stream`;mt(le)}catch(le){const be=le instanceof Error?le.message:"Failed to upload Excel file";console.error("Excel upload failed",le),ot(be),m==null||m(be)}finally{Ze(!1),G.target.value="",qn()}}},yt=async G=>{if(y){ve(!0);try{if(!G){await j(),Re(!1),requestAnimationFrame(()=>{var be;(be=xe.current)==null||be.scrollToLatest()});return}const oe=Pe.find(be=>be.checkpointId===G),le=(oe==null?void 0:oe.checkpointNs)??null;await E(G,le),Re(!0),requestAnimationFrame(()=>{var be;(be=xe.current)==null||be.scrollToTop()})}finally{ve(!1)}}},qt=b.useCallback(async G=>{await yt(G)},[yt]),Gn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,Rn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,$t=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,go=b.useCallback(G=>{if(!G)return"Latest";const oe=[];G.step!==null&&oe.push(`Step ${G.step}`),G.source&&oe.push(G.source);const le=G.createdAt?new Date(G.createdAt):null,be=le&&!Number.isNaN(le.getTime())?le.toLocaleString():G.createdAt??G.id,dt=oe.length?` — ${oe.join(" • ")}`:"";return`${be}${dt}`},[]);return u.jsxs("div",{className:Gn,children:[!!R&&!it&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:R}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Ct(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(se.X,{size:16})})]}),y&&Pe.length>0&&u.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:[u.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),u.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:D??"",onChange:G=>{const oe=G.target.value||null;yt(oe)},children:[u.jsx("option",{value:"",children:"Latest"}),Pe.map(G=>{const oe=Kt.get(G.checkpointId??"")??null;return u.jsx("option",{value:G.checkpointId??void 0,children:go(oe)},G.checkpointId)})]})]}),u.jsxs("div",{className:`relative ${Rn}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Oa,{ref:xe,className:"h-full",style:{height:"100%"},messages:w,isStreaming:$,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xa,enableMessageEditing:c,editingMessageId:O,onStartReached:()=>{Qe&&I()},onScrollAway:G=>{if(!Le.current){Le.current=!0;return}G&&Re(!0)},onEdit:st,onRegenerate:He,onCancelEdit:Ge,emptyMessage:de??void 0,isNavigatingCheckpoint:V,activeInterrupt:he,disableInterruptActions:Ee,onInterruptActionStart:W,onInterruptActionEnd:ee,showToolMessages:d,checkpointMetaById:Kt,checkpointIndexByKey:at,activeCheckpointId:D,onSelectCheckpoint:qt,timelineCheckpoints:kt}),(z==="reconnecting"||z==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(se.Loader2,{className:"h-3 w-3 animate-spin"}),z==="reconnecting"?"Reconnecting…":"Connecting…"]})}),z==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||V)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:$t,children:[O&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(se.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:Ge,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(se.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Kn,type:"file",multiple:!0,onChange:G=>$e(G),className:"hidden"},ze),ke.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map((G,oe)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(se.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:G.name}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>Pt(oe),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 ${G.name}`,children:u.jsx(se.X,{size:12})})]},oe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:fr,type:"file",accept:".xls,.xlsx,.xlsm",onChange:vt,className:"hidden"},Ve),qe&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),St&&!qe&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:St}),Xe&&!qe&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Xe})]})]}),Y&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Y}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Qw,{children:[u.jsx(eb,{asChild:!0,children:u.jsx(nt,{type:"button",size:"icon",variant:"outline",disabled:$||q,title:"More input actions",className:f.moreButton||"",children:u.jsx(se.Plus,{size:16})})}),u.jsxs(Td,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(ea,{onClick:()=>{var G;return(G=Kn.current)==null?void 0:G.click()},className:"cursor-pointer",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(ea,{onClick:()=>{var G;qe||(G=fr.current)==null||G.click()},className:`cursor-pointer ${qe?"opacity-60 pointer-events-none":""}`,children:[u.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(ex,{initialValue:te,editingMessageId:O,value:ut,onValueChange:Ya,placeholder:O?"Edit your message...":t,isStreaming:$,disabled:q,maxLength:fs,onSend:ae,onCancelEdit:Ge,onStop:B,allowEmptySend:ke.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${O?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Y?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const zs=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:Q("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}));zs.displayName="Input";function Ma(e,[t,n]){return Math.min(n,Math.max(t,e))}function _S(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var Da="ScrollArea",[yp,bT]=In(Da),[RS,sn]=yp(Da),vp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,d]=v.useState(null),[f,p]=v.useState(null),[h,m]=v.useState(null),[x,y]=v.useState(null),[g,w]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,j]=v.useState(!1),N=Ue(t,M=>l(M)),A=Lo(o);return u.jsx(RS,{scope:n,type:r,dir:A,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:m,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:x,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(Ae.div,{dir:A,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});vp.displayName=Da;var wp="ScrollAreaViewport",bp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(wp,n),a=v.useRef(null),l=Ue(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});bp.displayName=wp;var kn="ScrollAreaScrollbar",La=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(PS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(OS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Sp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Fa,{...r,ref:t}):null});La.displayName=kn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(tn,{present:n||s,children:u.jsx(Sp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ws(()=>l("SCROLL_END"),100),[a,l]=_S("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const p=()=>{const h=c[d];f!==h&&(l("SCROLL"),i()),f=h};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[o.viewport,s,l,i]),u.jsx(tn,{present:n||a!=="hidden",children:u.jsx(Fa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Sp=v.forwardRef((e,t)=>{const n=sn(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=Ws(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ar(n.viewport,l),Ar(n.content,l),u.jsx(tn,{present:r||s,children:u.jsx(Fa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Fa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(kn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Ip(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:p=>s.current=p,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:p=>i.current=p};function f(p,h){return zS(p,i.current,a,h)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,h=Np(p,a,o.dir);s.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollLeft=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollLeft=f(p,o.dir))}}):n==="vertical"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,h=Np(p,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:p=>{o.viewport&&(o.viewport.scrollTop=p)},onDragScroll:p=>{o.viewport&&(o.viewport.scrollTop=f(p))}}):null}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ue(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Tp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Ue(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Tp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Us(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const p=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(p),jp(p,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[LS,Cp]=yp(kn),Tp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...p}=e,h=sn(kn,n),[m,x]=v.useState(null),y=Ue(t,N=>x(N)),g=v.useRef(null),w=v.useRef(""),S=h.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Ws(f,10);function j(N){if(g.current){const A=N.clientX-g.current.left,M=N.clientY-g.current.top;c({x:A,y:M})}}return v.useEffect(()=>{const N=A=>{const M=A.target;(m==null?void 0:m.contains(M))&&T(A,k)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[S,m,k,T]),v.useEffect(C,[r,C]),Ar(m,E),Ar(h.content,E),u.jsx(LS,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(Ae.div,{...p,ref:y,style:{position:"absolute",...p.style},onPointerDown:pe(e.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),g.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),j(N))}),onPointerMove:pe(e.onPointerMove,j),onPointerUp:pe(e.onPointerUp,N=>{const A=N.target;A.hasPointerCapture(N.pointerId)&&A.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=w.current,h.viewport&&(h.viewport.style.scrollBehavior=""),g.current=null})})})}),Bs="ScrollAreaThumb",kp=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Cp(Bs,e.__scopeScrollArea);return u.jsx(tn,{present:n||o.hasThumb,children:u.jsx(FS,{ref:t,...r})})}),FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Bs,n),i=Cp(Bs,n),{onThumbPositionChange:a}=i,l=Ue(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=Ws(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!c.current){const h=BS(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(Ae.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 h=f.target.getBoundingClientRect(),m=f.clientX-h.left,x=f.clientY-h.top;i.onThumbPointerDown({x:m,y:x})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});kp.displayName=Bs;var $a="ScrollAreaCorner",Ep=v.forwardRef((e,t)=>{const n=sn($a,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx($S,{...e,ref:t}):null});Ep.displayName=$a;var $S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn($a,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Ar(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ar(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(Ae.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 Hs(e){return e?parseInt(e,10):0}function Ip(e,t){const n=e/t;return isNaN(n)?0:n}function Us(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 zS(e,t,n,r="ltr"){const o=Us(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Ap([l,c],f)(e)}function Np(e,t,n="ltr"){const r=Us(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Ma(e,l);return Ap([0,i],[0,a])(c)}function Ap(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 jp(e,t){return e>0&&e<t}var BS=(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 Ws(e,t){const n=Rt(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ar(e,t){const n=Rt(t);_t(()=>{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 _p=vp,HS=bp,US=Ep;const Rp=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(_p,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Pp,{}),u.jsx(US,{})]}));Rp.displayName=_p.displayName;const Pp=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(La,{ref:r,orientation:t,className:Q("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(kp,{className:"relative flex-1 rounded-full bg-border"})}));Pp.displayName=La.displayName;const Op=25;function za({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d}){const{threads:f,currentThreadId:p,setCurrentThreadId:h,isLoading:m,actions:x}=Oo(),{loadThread:y}=Mo(),{createThread:g,deleteThread:w,renameThread:S}=x,[k,T]=b.useState(Array.isArray(f)?f:[]),C=b.useRef(k.length>0),E=b.useRef(null),j=b.useRef(0),[N,A]=b.useState(null),[M,F]=b.useState(""),[$,R]=b.useState(!1);b.useEffect(()=>{const W=Array.isArray(f)?f:[];if(W.length>0){C.current=!0,T(W);return}m||(C.current=!1,T(W))},[f,m]),b.useEffect(()=>{if(!E.current)return;const W=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!W)return;let ee=null,q=null;return ee=requestAnimationFrame(()=>{q=requestAnimationFrame(()=>{W.scrollTop=j.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),q!==null&&cancelAnimationFrame(q)}},[k]);const z=async W=>{try{h(W),await y(W),a==null||a(W),l==null||l(W)}catch(ee){console.error("Failed to select thread:",ee)}},_=async()=>{try{R(!0);const W=await g();W&&(c==null||c(W),a==null||a(W))}catch(W){console.error("Failed to create thread:",W)}finally{R(!1)}},B=async(W,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const q=E.current.querySelector("[data-radix-scroll-area-viewport]");q&&(j.current=q.scrollTop)}try{await w(W),d==null||d(W)}catch(q){console.error("Failed to delete thread:",q)}}},L=(W,ee)=>{ee.stopPropagation(),A(W.threadId),F(W.title||`Thread ${W.threadId.slice(0,8)}`)},D=async W=>{if(M.trim())try{await S(W,M.trim()),A(null),F("")}catch(ee){console.error("Failed to update title:",ee)}},Z=()=>{A(null),F("")},J=(W,ee)=>{W.key==="Enter"?D(ee):W.key==="Escape"&&Z()},he=W=>{if(!W)return"";try{const ee=new Date(W),O=new Date().getTime()-ee.getTime(),H=Math.floor(O/(1e3*60*60*24));return H===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):H===1?"Yesterday":H<7?`${H} days ago`:ee.toLocaleDateString()}catch{return""}},Ee=W=>W.title||`Thread ${W.threadId.slice(0,8)}`,Ne=W=>{const ee=Ee(W);return ee.length<=Op?ee:`${ee.slice(0,Op)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&u.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:u.jsx(nt,{onClick:_,disabled:$||m,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:$?"Creating...":"New Chat",children:u.jsx(se.MessageSquarePlus,{size:20})})}),u.jsx(Rp,{ref:E,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:m?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(se.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):k.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(se.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):k.slice().sort((W,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(W.updatedAt||W.createdAt||"").getTime()).map(W=>u.jsxs("div",{onClick:()=>z(W.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===W.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:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:N===W.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[u.jsx(zs,{value:M,onChange:ee=>F(ee.target.value),onKeyDown:ee=>J(ee,W.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:()=>D(W.threadId),className:"h-6 w-6 p-0",children:u.jsx(se.Check,{size:12})}),u.jsx(nt,{variant:"ghost",size:"sm",onClick:Z,className:"h-6 w-6 p-0",children:u.jsx(se.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:Ne(W)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(se.Calendar,{size:10}),u.jsx("span",{children:he(W.updatedAt||W.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==W.threadId&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:ee=>L(W,ee),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(se.Edit3,{size:12})}),n&&u.jsx(nt,{variant:"ghost",size:"sm",onClick:ee=>B(W.threadId,ee),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:u.jsx(se.Trash2,{size:12})})]})]}),i===W.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},W.threadId))})})]})}function jr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return En(t)}function Mp(){const e=[jr("__API_BASE_URL__"),jr("__CHAT_API_BASE_URL__"),jr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function Dp(){const e=[jr("__API_AUTH_TOKEN__"),jr("__CHAT_API_KEY__"),jr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return En(t);return En()}function Fp(){const e={},t=Mp(),n=Dp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function $p(){const e=Fp(),t=Pn.getAuthToken(),n=Mp();return{apiBaseUrl:Lp(e.baseUrl,Pn.baseUrl,n),apiKey:t||e.apiKey||Dp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const zp="chat-settings";function VS(){try{const e=localStorage.getItem(zp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:En(e.apiBaseUrl)};localStorage.setItem(zp,JSON.stringify(t)),t.apiKey&&Pn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=$p(),t=VS(),n=Pn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lp(Pn.baseUrl,r,e.apiBaseUrl)}}function GS(e){Pn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Bp=v.forwardRef((e,t)=>u.jsx(Ae.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())}}));Bp.displayName=YS;var Hp=Bp;const XS=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),an=v.forwardRef(({className:e,...t},n)=>u.jsx(Hp,{ref:n,className:Q(XS(),e),...t}));an.displayName=Hp.displayName;function Up(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Vs="Switch",[JS,ST]=In(Vs),[ZS,QS]=JS(Vs),Wp=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[p,h]=v.useState(null),m=Ue(t,S=>h(S)),x=v.useRef(!1),y=p?d||!!p.closest("form"):!0,[g,w]=xr({prop:o,defaultProp:s??!1,onChange:c,caller:Vs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(Ae.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Gp(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:pe(e.onClick,S=>{w(k=>!k),y&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),y&&u.jsx(qp,{control:p,bubbles:!x.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Wp.displayName=Vs;var Vp="SwitchThumb",Kp=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(Vp,n);return u.jsx(Ae.span,{"data-state":Gp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Kp.displayName=Vp;var eC="SwitchBubbleInput",qp=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=Ue(i,s),l=Up(n),c=Jc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const m=new Event("click",{bubbles:r});h.call(d,n),d.dispatchEvent(m)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});qp.displayName=eC;function Gp(e){return e?"checked":"unchecked"}var Yp=Wp,tC=Kp;const Un=v.forwardRef(({className:e,...t},n)=>u.jsx(Yp,{className:Q("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(tC,{className:Q("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")})}));Un.displayName=Yp.displayName;var Xp=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"}),nC="VisuallyHidden",rC=v.forwardRef((e,t)=>u.jsx(Ae.span,{...e,ref:t,style:{...Xp,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],cr="Select",[Ks,qs,iC]=vi(cr),[_r,CT]=In(cr,[iC,Xo]),Gs=Xo(),[aC,Wn]=_r(cr),[lC,cC]=_r(cr),Jp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:p,required:h,form:m}=e,x=Gs(t),[y,g]=v.useState(null),[w,S]=v.useState(null),[k,T]=v.useState(!1),C=Lo(c),[E,j]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:cr}),[N,A]=xr({prop:i,defaultProp:a,onChange:l,caller:cr}),M=v.useRef(null),F=y?m||!!y.closest("form"):!0,[$,R]=v.useState(new Set),z=Array.from($).map(_=>_.props.value).join(";");return u.jsx(au,{...x,children:u.jsxs(aC,{required:h,scope:t,trigger:y,onTriggerChange:g,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:Nn(),value:N,onValueChange:A,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:M,disabled:p,children:[u.jsx(Ks.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{R(B=>new Set(B).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{R(B=>{const L=new Set(B);return L.delete(_),L})},[]),children:n})}),F?u.jsxs(bh,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:N,onChange:_=>A(_.target.value),disabled:p,form:m,children:[N===void 0?u.jsx("option",{value:""}):null,Array.from($)]},z):null]})})};Jp.displayName=cr;var Zp="SelectTrigger",Qp=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Gs(n),i=Wn(Zp,n),a=i.disabled||r,l=Ue(t,i.onTriggerChange),c=qs(n),d=v.useRef("touch"),[f,p,h]=Ch(x=>{const y=c().filter(S=>!S.disabled),g=y.find(S=>S.value===i.value),w=Th(y,x,g);w!==void 0&&i.onValueChange(w.value)}),m=x=>{a||(i.onOpenChange(!0),h()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return u.jsx(lu,{asChild:!0,...s,children:u.jsx(Ae.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":Sh(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&m(x)}),onPointerDown:pe(o.onPointerDown,x=>{d.current=x.pointerType;const y=x.target;y.hasPointerCapture(x.pointerId)&&y.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(m(x),x.preventDefault())}),onKeyDown:pe(o.onKeyDown,x=>{const y=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&p(x.key),!(y&&x.key===" ")&&oC.includes(x.key)&&(m(),x.preventDefault())})})})});Qp.displayName=Zp;var eh="SelectValue",th=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Wn(eh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Ue(t,l.onValueNodeChange);return _t(()=>{c(d)},[c,d]),u.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:Sh(l.value)?u.jsx(u.Fragment,{children:i}):s})});th.displayName=eh;var uC="SelectIcon",nh=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});nh.displayName=uC;var dC="SelectPortal",rh=e=>u.jsx(Jo,{asChild:!0,...e});rh.displayName=dC;var ur="SelectContent",oh=v.forwardRef((e,t)=>{const n=Wn(ur,e.__scopeSelect),[r,o]=v.useState();if(_t(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?yo.createPortal(u.jsx(sh,{scope:e.__scopeSelect,children:u.jsx(Ks.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(ih,{...e,ref:t})});oh.displayName=ur;var mn=10,[sh,Vn]=_r(ur),fC="SelectContentImpl",pC=Yn.createSlot("SelectContent.RemoveScroll"),ih=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:m,hideWhenDetached:x,avoidCollisions:y,...g}=e,w=Wn(ur,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=Ue(t,q=>k(q)),[j,N]=v.useState(null),[A,M]=v.useState(null),F=qs(n),[$,R]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Bi(S)},[S]),Si();const _=v.useCallback(q=>{const[O,...H]=F().map(ne=>ne.ref.current),[te]=H.slice(-1),ie=document.activeElement;for(const ne of q)if(ne===ie||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===O&&T&&(T.scrollTop=0),ne===te&&T&&(T.scrollTop=T.scrollHeight),ne==null||ne.focus(),document.activeElement!==ie))return},[F,T]),B=v.useCallback(()=>_([j,S]),[_,j,S]);v.useEffect(()=>{$&&B()},[$,B]);const{onOpenChange:L,triggerPointerDownPosRef:D}=w;v.useEffect(()=>{if(S){let q={x:0,y:0};const O=te=>{var ie,ne;q={x:Math.abs(Math.round(te.pageX)-(((ie=D.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ne=D.current)==null?void 0:ne.y)??0))}},H=te=>{q.x<=10&&q.y<=10?te.preventDefault():S.contains(te.target)||L(!1),document.removeEventListener("pointermove",O),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,L,D]),v.useEffect(()=>{const q=()=>L(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[L]);const[Z,J]=Ch(q=>{const O=F().filter(ie=>!ie.disabled),H=O.find(ie=>ie.ref.current===document.activeElement),te=Th(O,q,H);te&&setTimeout(()=>te.ref.current.focus())}),he=v.useCallback((q,O,H)=>{const te=!z.current&&!H;(w.value!==void 0&&w.value===O||te)&&(N(q),te&&(z.current=!0))},[w.value]),Ee=v.useCallback(()=>S==null?void 0:S.focus(),[S]),Ne=v.useCallback((q,O,H)=>{const te=!z.current&&!H;(w.value!==void 0&&w.value===O||te)&&M(q)},[w.value]),W=r==="popper"?Ba:ah,ee=W===Ba?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:m,hideWhenDetached:x,avoidCollisions:y}:{};return u.jsx(sh,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:he,selectedItem:j,onItemLeave:Ee,itemTextRefCallback:Ne,focusSelectedItem:B,selectedItemText:A,position:r,isPositioned:$,searchRef:Z,children:u.jsx(is,{as:pC,allowPinchZoom:!0,children:u.jsx($o,{asChild:!0,trapped:w.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:pe(o,q=>{var O;(O=w.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(W,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:q=>q.preventDefault(),...g,...ee,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:pe(g.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&J(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let te=F().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(q.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const ie=q.target,ne=te.indexOf(ie);te=te.slice(ne+1)}setTimeout(()=>_(te)),q.preventDefault()}})})})})})})});ih.displayName=fC;var hC="SelectItemAlignedPosition",ah=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Wn(ur,n),i=Vn(ur,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=Ue(t,E=>d(E)),p=qs(n),h=v.useRef(!1),m=v.useRef(!0),{viewport:x,selectedItem:y,selectedItemText:g,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&x&&y&&g){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),N=s.valueNode.getBoundingClientRect(),A=g.getBoundingClientRect();if(s.dir!=="rtl"){const ie=A.left-j.left,ne=N.left-ie,De=E.left-ne,Y=E.width+De,fe=Math.max(Y,j.width),ke=window.innerWidth-mn,je=Ma(ne,[mn,Math.max(mn,ke-fe)]);a.style.minWidth=Y+"px",a.style.left=je+"px"}else{const ie=j.right-A.right,ne=window.innerWidth-N.right-ie,De=window.innerWidth-E.right-ne,Y=E.width+De,fe=Math.max(Y,j.width),ke=window.innerWidth-mn,je=Ma(ne,[mn,Math.max(mn,ke-fe)]);a.style.minWidth=Y+"px",a.style.right=je+"px"}const M=p(),F=window.innerHeight-mn*2,$=x.scrollHeight,R=window.getComputedStyle(c),z=parseInt(R.borderTopWidth,10),_=parseInt(R.paddingTop,10),B=parseInt(R.borderBottomWidth,10),L=parseInt(R.paddingBottom,10),D=z+_+$+L+B,Z=Math.min(y.offsetHeight*5,D),J=window.getComputedStyle(x),he=parseInt(J.paddingTop,10),Ee=parseInt(J.paddingBottom,10),Ne=E.top+E.height/2-mn,W=F-Ne,ee=y.offsetHeight/2,q=y.offsetTop+ee,O=z+_+q,H=D-O;if(O<=Ne){const ie=M.length>0&&y===M[M.length-1].ref.current;a.style.bottom="0px";const ne=c.clientHeight-x.offsetTop-x.offsetHeight,De=Math.max(W,ee+(ie?Ee:0)+ne+B),Y=O+De;a.style.height=Y+"px"}else{const ie=M.length>0&&y===M[0].ref.current;a.style.top="0px";const De=Math.max(Ne,z+x.offsetTop+(ie?he:0)+ee)+H;a.style.height=De+"px",x.scrollTop=O-Ne+x.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=Z+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[p,s.trigger,s.valueNode,a,c,x,y,g,s.dir,r]);_t(()=>S(),[S]);const[k,T]=v.useState();_t(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&m.current===!0&&(S(),w==null||w(),m.current=!1)},[S,w]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ah.displayName=hC;var mC="SelectPopperPosition",Ba=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=Gs(n);return u.jsx(cu,{...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)"}})});Ba.displayName=mC;var[gC,Ha]=_r(ur,{}),Ua="SelectViewport",lh=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Vn(Ua,n),i=Ha(Ua,n),a=Ue(t,s.onViewportChange),l=v.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Ks.Slot,{scope:n,children:u.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const h=Math.abs(l.current-d.scrollTop);if(h>0){const m=window.innerHeight-mn*2,x=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),g=Math.max(x,y);if(g<m){const w=g+h,S=Math.min(m,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});lh.displayName=Ua;var ch="SelectGroup",[xC,yC]=_r(ch),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return u.jsx(xC,{scope:n,id:o,children:u.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=ch;var uh="SelectLabel",dh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(uh,n);return u.jsx(Ae.div,{id:o.id,...r,ref:t})});dh.displayName=uh;var Ys="SelectItem",[wC,fh]=_r(Ys),ph=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Wn(Ys,n),l=Vn(Ys,n),c=a.value===r,[d,f]=v.useState(s??""),[p,h]=v.useState(!1),m=Ue(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=Nn(),y=v.useRef("touch"),g=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(wC,{scope:n,value:r,disabled:o,textId:x,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Ae.div,{role:"option","aria-labelledby":x,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:pe(i.onFocus,()=>h(!0)),onBlur:pe(i.onBlur,()=>h(!1)),onClick:pe(i.onClick,()=>{y.current!=="mouse"&&g()}),onPointerUp:pe(i.onPointerUp,()=>{y.current==="mouse"&&g()}),onPointerDown:pe(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:pe(i.onPointerMove,w=>{var S;y.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:pe(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(sC.includes(w.key)&&g(),w.key===" "&&w.preventDefault())})})})})});ph.displayName=Ys;var mo="SelectItemText",hh=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Wn(mo,n),a=Vn(mo,n),l=fh(mo,n),c=cC(mo,n),[d,f]=v.useState(null),p=Ue(t,g=>f(g),l.onItemTextChange,g=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,g,l.value,l.disabled)}),h=d==null?void 0:d.textContent,m=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:x,onNativeOptionRemove:y}=c;return _t(()=>(x(m),()=>y(m)),[x,y,m]),u.jsxs(u.Fragment,{children:[u.jsx(Ae.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?yo.createPortal(s.children,i.valueNode):null]})});hh.displayName=mo;var mh="SelectItemIndicator",gh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fh(mh,n).isSelected?u.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});gh.displayName=mh;var Wa="SelectScrollUpButton",xh=v.forwardRef((e,t)=>{const n=Vn(Wa,e.__scopeSelect),r=Ha(Wa,e.__scopeSelect),[o,s]=v.useState(!1),i=Ue(t,r.onScrollButtonChange);return _t(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});xh.displayName=Wa;var Va="SelectScrollDownButton",yh=v.forwardRef((e,t)=>{const n=Vn(Va,e.__scopeSelect),r=Ha(Va,e.__scopeSelect),[o,s]=v.useState(!1),i=Ue(t,r.onScrollButtonChange);return _t(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});yh.displayName=Va;var vh=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Vn("SelectScrollButton",n),i=v.useRef(null),a=qs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),_t(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(Ae.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 c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),bC="SelectSeparator",wh=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});wh.displayName=bC;var Ka="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gs(n),s=Wn(Ka,n),i=Vn(Ka,n);return s.open&&i.position==="popper"?u.jsx(uu,{...o,...r,ref:t}):null});SC.displayName=Ka;var CC="SelectBubbleInput",bh=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=Ue(r,o),i=Up(t);return v.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]),u.jsx(Ae.select,{...n,style:{...Xp,...n.style},ref:s,defaultValue:t})});bh.displayName=CC;function Sh(e){return e===""||e===void 0}function Ch(e){const t=Rt(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Th(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function TC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kC=Jp,kh=Qp,EC=th,IC=nh,NC=rh,Eh=oh,AC=lh,Ih=dh,Nh=ph,jC=hh,_C=gh,Ah=xh,jh=yh,_h=wh;const Rh=kC,Ph=EC,qa=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(kh,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(IC,{asChild:!0,children:u.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qa.displayName=kh.displayName;const Oh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ah,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Oh.displayName=Ah.displayName;const Mh=v.forwardRef(({className:e,...t},n)=>u.jsx(jh,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Mh.displayName=jh.displayName;const Ga=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(Eh,{ref:o,className:Q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Oh,{}),u.jsx(AC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Mh,{})]})}));Ga.displayName=Eh.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ih,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Ih.displayName;const dr=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Nh,{ref:r,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(_C,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));dr.displayName=Nh.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(_h,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=_h.displayName;var OC="Separator",Dh="horizontal",MC=["horizontal","vertical"],Lh=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=Dh,...o}=e,s=DC(r)?r:Dh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});Lh.displayName=OC;function DC(e){return MC.includes(e)}var Fh=Lh;const $h=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Fh,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));$h.displayName=Fh.displayName;const LC=qf,FC=Q0,$C=Gf,zh=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{className:Q("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}));zh.displayName=_s.displayName;const zC=xo.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"}}),Bh=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs($C,{children:[u.jsx(zh,{}),u.jsxs(Rs,{ref:o,className:Q(zC({side:e}),t),...r,children:[n,u.jsxs(Yf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bh.displayName=Rs.displayName;const Hh=({className:e,...t})=>u.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Hh.displayName="SheetHeader";const Uh=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Uh.displayName=ar.displayName;const Wh=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Wh.displayName=Ps.displayName;const BC={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 HC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,d]=b.useState(!1),{toast:f}=Ea();b.useEffect(()=>{const y=JSON.stringify(a)!==JSON.stringify(e);d(y)},[a,e]),b.useEffect(()=>{l(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},h=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},m=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const g=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${g.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return u.jsxs(LC,{open:r,onOpenChange:o,children:[u.jsx(FC,{asChild:!0,children:u.jsxs(nt,{variant:"outline",size:"sm",className:n,children:[u.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Tf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Bh,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Hh,{children:[u.jsx(Uh,{children:"Chat Settings"}),u.jsx(Wh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"api-url",value:a.api.baseUrl,onChange:y=>l(g=>({...g,api:{...g.api,baseUrl:y.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(nt,{variant:"outline",onClick:x,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Un,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:y=>l(g=>({...g,api:{...g.api,enableAuth:y}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:y=>l(g=>({...g,api:{...g.api,authToken:y.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(nt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(se.EyeOff,{className:"h-4 w-4"}):u.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Rh,{value:a.ui.layout,onValueChange:y=>l(g=>({...g,ui:{...g.ui,layout:y}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(dr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(dr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"theme",children:"Theme"}),u.jsxs(Rh,{value:a.ui.theme,onValueChange:y=>l(g=>({...g,ui:{...g.ui,theme:y}})),children:[u.jsx(qa,{children:u.jsx(Ph,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"light",children:"Light"}),u.jsx(dr,{value:"dark",children:"Dark"}),u.jsx(dr,{value:"system",children:"System"})]})]})]}),u.jsx($h,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Un,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showTimestamps:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Un,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showAgentNames:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Un,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,compactMessages:y}}))})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Un,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,autoSave:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Un,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Un,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:y}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(nt,{variant:"outline",onClick:h,children:[u.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(nt,{variant:"outline",onClick:m,children:"Cancel"}),u.jsxs(nt,{onClick:p,disabled:!c,children:[u.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function UC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(za,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Do,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(za,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=ql,Te.ChatInput=mc,Te.ChatInterface=$s,Te.ChatProviders=Do,Te.ChatSettings=HC,Te.MarkdownContent=ho,Te.MessageComponent=Pa,Te.MessageList=Oa,Te.ThreadManager=za,Te.applySettings=GS,Te.chatApiClient=Pn,Te.default=UC,Te.del=Kl,Te.get=Qt,Te.getChatToken=Ul,Te.getCurrentSettings=qS,Te.getDefaultApiConfig=Fp,Te.getDefaultChatSettings=$p,Te.onChatTokenChanged=Wl,Te.post=di,Te.put=Vl,Te.setChatToken=jo,Te.useApi=fi,Te.useChatStream=lc,Te.useMessagesReducer=ec,Te.useStream=pc,Te.useThreadState=Mo,Te.useThreads=Oo,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
133
|
+
`}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=sh(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=sh(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 uh{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 dh{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 Hn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new Ra,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uh,this.slugger=new dh}static parse(t,n){return new Hn(n).parse(t)}static parseInline(t,n){return new Hn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,h,p,m,x,y,g,w,S,k,T,C;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(C=this.options.extensions.renderers[p.type].call({parser:this},p),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=C||"";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,oh(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(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[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(m=p.ordered,x=p.start,y=p.loose,a=p.items.length,h="",s=0;s<a;s++)w=p.items[s],S=w.checked,k=w.task,g="",w.task&&(T=this.renderer.checkbox(S),y?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=T+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=T+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:T}):g+=T),g+=this.parse(w.tokens,y),h+=this.renderer.listitem(g,k,S);r+=this.renderer.list(h,m,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<E&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
134
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ls{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}Kp(Ls,"passThroughHooks",new Set(["preprocess","postprocess"]));function wS(e,t,n){return r=>{if(r.message+=`
|
|
135
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ft(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 fh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=wS(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(xS(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 c=function(f){let h;if(!f)try{r.walkTokens&&ge.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 c();let d=0;ge.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return c(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ge.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&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return fh(Bn.lex,Hn.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},oS(ge.defaults),ge},ge.getDefaults=eh,ge.defaults=lr,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.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=ge.defaults.renderer||new Ra;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=ge.defaults.tokenizer||new _a;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=ge.defaults.hooks||new Ls;for(const s in n.hooks){const i=o[s];Ls.passThroughHooks.has(s)?o[s]=a=>{if(ge.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ge.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}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=fh(Bn.lexInline,Hn.parseInline),ge.Parser=Hn,ge.parser=Hn.parse,ge.Renderer=Ra,ge.TextRenderer=uh,ge.Lexer=Bn,ge.lexer=Bn.lex,ge.Tokenizer=_a,ge.Slugger=dh,ge.Hooks=Ls,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,Hn.parse,Bn.lex;function po({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ge.parse=="function"?ge.parse(i):ge(i)}return typeof ge.parse=="function"?ge.parse(e):ge(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:Q("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}const bS="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function SS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function hh(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Fs(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function CS(e){const t=o=>{try{const s=fo(o);return typeof s=="string"?s:JSON.stringify(s??"")}catch{return""}},n=e.filter(o=>o.type==="text");let r="";return n.length?r=t(n.map(o=>o.text).join(`
|
|
136
|
+
`)):r=t(e),r||""}function TS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ph(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(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"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function kS({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Pa=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:h={},onEdit:p,onRegenerate:m,onCancelEdit:x,onCopy:y,activeInterrupt:g,disableInterruptActions:w=!1,onInterruptActionStart:S,onInterruptActionEnd:k,checkpointCandidates:T=[],activeCheckpointId:C=null,onSelectCheckpoint:E,defaultCheckpointId:j=null,messageParentCheckpointId:N=null}){const[A,M]=b.useState(!1),[F,$]=b.useState("preview"),[R,z]=b.useState(!1),{currentThreadId:_}=Oo(),{respondToInterrupt:B}=Mo(),L=l==="phone"||l==="half-screen",D=t.role,Z=D==="tool",J=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),pe=!!J,Ee=!(r&&D!=="user"),{uploadingFiles:Ne,handleFileClick:V,fileViewerOpen:ee,currentFileInfo:U,closeFileViewer:O}=IS({allowFileOpen:Ee,currentThreadId:_}),H=b.useMemo(()=>{switch(D){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))]"}},[D]),te=b.useMemo(()=>J?"":SS(t.content),[J,t]),ie=b.useMemo(()=>J?{}:hh(t),[J,t]),ne=b.useMemo(()=>J?[]:t.content.filter(K=>K.type==="image_url"),[J,t]),Fe=b.useMemo(()=>J?[]:t.content.filter(K=>K.type==="file"),[J,t]),Y=b.useMemo(()=>J?[]:t.content.filter(K=>K.type==="interrupt"),[J,t]),fe=(g==null?void 0:g.id)??(g==null?void 0:g.interrupt_id),ke=Fs(fe),je=g==null?void 0:g.value,Be=b.useMemo(()=>J?"":CS(t.content),[J,t]),He=b.useCallback(async()=>{const K=Z?Be:te;async function ve(xe){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(xe);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ft=new Blob([xe],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ft})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ve(K),M(!0),setTimeout(()=>M(!1),2e3),y==null||y(K)}catch(xe){console.error("Failed to copy:",xe)}},[Z,Be,te,y]),Ke=b.useCallback(()=>{if(!p)return;const K=Z?Be:te,ve="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};p(t.id,K,ve)},[p,t.id,Z,Be,te,t]),qe=b.useCallback(()=>{m==null||m(n)},[m,n]),Ge=b.useCallback(()=>{const ve=Q(L?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",H);switch(D){case"user":return u.jsx(se.User,{className:ve});case"assistant":return u.jsx(se.Bot,{className:ve});case"tool":return u.jsx(se.Wrench,{className:ve});default:return u.jsx(se.Bot,{className:ve})}},[L,H,D]),tt=b.useCallback(()=>{const K="group relative mb-4 flex w-full";switch(D){case"user":return Q(K,"justify-end");case"assistant":case"tool":case"system":return Q(K,"justify-start");default:return K}},[D]),Qe=b.useCallback(()=>{const K=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",L&&"px-3 py-2 text-sm");if(pe)return Q(K,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(D){case"user":return Q(K,"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 Q(K,"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 Q(K,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(K,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(K,"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")}},[L,pe,D]);if(pe&&J)return u.jsx("div",{className:Q(tt(),h.container),children:u.jsxs("div",{className:Q(Qe(),h.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(se.Bot,{className:Q("h-4 w-4",H)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(po,{content:J.content,className:"text-current"})]})});const st=b.useCallback(async K=>{if(w)return;const ve=Fs((K==null?void 0:K.id)??(K==null?void 0:K.interrupt_id));if(!ve){console.warn("Interrupt part missing id",K);return}try{S==null||S(),await B(ve,!0)}catch(xe){console.error("Failed to approve interrupt:",xe)}finally{k==null||k()}},[w,k,S,B]),St=b.useCallback(async K=>{if(w)return;const ve=Fs((K==null?void 0:K.id)??(K==null?void 0:K.interrupt_id));if(!ve){console.warn("Interrupt part missing id",K);return}try{S==null||S(),await B(ve,!1)}catch(xe){console.error("Failed to reject interrupt:",xe)}finally{k==null||k()}},[w,k,S,B]),mt=b.useCallback(({part:K,i:ve})=>{if(K.type==="text"){const xe=K.text??"",ft=xe.trim(),gt=Ia(ft);return gt&&D!=="tool"?u.jsx(mh,{data:gt},ve):D==="user"&&c&&ft.length>d?u.jsx(NS,{text:ft,expanded:R,onExpandedChange:z,previewLength:d,isCompact:L},ve):u.jsx(po,{content:xe,allowHtml:!1},ve)}if(K.type==="image_url"){const xe=K;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:xe.url,alt:xe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ve)}if(K.type==="file"){const xe=K,ft=xe.name||"file";return u.jsxs("a",{href:xe.url,onClick:gt=>V(gt,xe,ve),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
137
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[Ne[ve]?u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ft,Ne[ve]?" (processing)":""]})]},ve)}if(K.type==="interrupt"){const xe=K,ft=Fs((xe==null?void 0:xe.id)??(xe==null?void 0:xe.interrupt_id)),gt=!!(ke&&ft&&ft===ke),Tt=gt?je??(xe==null?void 0:xe.value):xe==null?void 0:xe.value,Pe=ft?{...xe,id:ft,interrupt_id:ft}:xe;return u.jsx(ES,{interruptPart:Pe,onApprove:st,onReject:St,disabled:w,isActive:gt,payload:Tt},ve)}return null},[V,Ne,st,St,D,c,d,R,L,ke,je,g,w,Y]),at=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ct=b.useCallback(()=>{const K=te.trim().length>0||ne.length>0||Fe.length>0||Y.length>0;if(!Z&&Fe.length>0&&!r)return at();if(!Z&&!K&&!r)return null;if(Z)return u.jsx(AS,{message:t,viewMode:F},t.id);if(!Z&&!J){const ve=t,xe=u.jsx("div",{className:"space-y-2",children:ve.content.map((ft,gt)=>u.jsx(mt,{part:ft,i:gt},gt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[xe,u.jsx(kS,{className:H})]}):xe}},[te,ne.length,Fe.length,Y.length,r,Z,F,at,H]),de=b.useMemo(()=>J?"Assistant":TS(t),[J,t]),re=b.useMemo(()=>J?[]:Array.isArray(T)?T:[],[T,J]),Ye=b.useMemo(()=>{var K;return re.length?j&&re.some(ve=>ve.id===j)?j:((K=re[0])==null?void 0:K.id)??null:null},[j,re]),Xe=b.useMemo(()=>!re.length||!C?null:re.some(K=>K.id===C)?C:null,[C,re])??Ye,Re=D==="user"&&re.length>0&&typeof E=="function",$e=b.useCallback(K=>{if(!E)return;const ve=(K==null?void 0:K.id)??null,xe=(K==null?void 0:K.parentId)??N??null;E(ve,xe)},[N,E]),Me=b.useMemo(()=>Xe?re.findIndex(K=>K.id===Xe):-1,[Xe,re]),jt=b.useMemo(()=>Me<0?null:re[Me]??null,[Me,re]),At=b.useCallback(K=>{const ve=[];if(K.step!==null&&ve.push(`Step ${K.step}`),K.source&&ve.push(K.source),!K.createdAt)return ve.length?ve.join(" • "):K.id.slice(0,8);let xe="";try{const ft=new Date(K.createdAt);Number.isNaN(ft.getTime())||(xe=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ft))}catch{xe=""}return`${xe}`},[]);return Z&&!f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:Q(tt(),h.container),children:u.jsxs("div",{className:Q(Qe(),h.content),children:[(i||a||Z)&&u.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",H,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ge(),a&&de&&u.jsx("span",{className:Q("font-medium",L?"text-xs":"text-sm"),children:de}),Z&&u.jsxs(Tf,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer select-none",H,"border border-current/40",L&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":F==="expanded",onClick:()=>$(K=>K==="expanded"?"preview":"expanded"),onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),$(ve=>ve==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ie.name??"Tool Output"}),ie.toolCallId&&u.jsx("span",{className:"opacity-70",children:ie.toolCallId.slice(0,8)}),F==="expanded"?u.jsx(se.ChevronUp,{className:"h-3 w-3"}):u.jsx(se.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Re&&jt&&Me>=0&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:Q("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Me>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Me<=0)return;const K=re[Me-1];K&&$e(K)},"aria-label":"Previous checkpoint",disabled:Me<=0,children:u.jsx(se.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[Me+1," / ",re.length]}),u.jsx("span",{className:"text-muted-foreground",children:At(jt)})]}),u.jsx("button",{type:"button",className:Q("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Me<re.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Me>=re.length-1)return;const K=re[Me+1];K&&$e(K)},"aria-label":"Next checkpoint",disabled:Me>=re.length-1,children:u.jsx(se.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:Q("text-xs opacity-60",H,L&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>He(),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(se.Copy,{className:Q(A?"text-success":H,L?"h-3 w-3":"h-4 w-4")})})}),D==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Ke,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(se.Edit,{className:Q(H,L?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:qe,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",H,L&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(se.RotateCcw,{className:Q(H,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Ct()}),Z&&F==="expanded"&&(ie.toolCallId||ie.name)&&u.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[ie.name&&u.jsxs("div",{children:["Function: ",ie.name]}),ie.toolCallId&&u.jsxs("div",{children:["Call ID: ",ie.toolCallId]})]}),!(i||a||Z)&&s&&!o&&u.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>He(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Copy,{className:Q(A?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),D==="user"&&p&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:Ke,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.Edit,{className:Q("text-current",L?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&m&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:qe,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(se.RotateCcw,{className:Q("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),U&&u.jsx(rS,{isOpen:ee,onClose:O,fileId:U.id,fileName:U.name,mimeType:U.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ph(e.message)===ph(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(m=>e[m]===t[m]),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)===((c=t.customStyles)==null?void 0:c.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 mh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:bS,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ho(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ho(e)})}function ES({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=ho(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(io,{className:Q("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ao,{className:"pb-3",children:[u.jsx(lo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(kf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(co,{className:"pt-0 pb-3",children:a}),u.jsx(Ef,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(rt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(rt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function IS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ea(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(p=>{a(p),c(!0)},[]),h=b.useCallback(async(p,m,x)=>{var y,g;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const w=String(m.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const k=S[1],T=m.name||`file_${k}`,C=m.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(w.startsWith("data:")){p.preventDefault(),s(T=>({...T,[x]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await B0(n??void 0);if(!T||!Array.isArray(T))throw new Error("Invalid file list response");const C=T.find(E=>!E||typeof E!="object"||!((E.filename??"")===(m.name??""))?!1:typeof m.size=="number"&&typeof E.size=="number"?E.size===m.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${m.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:m.name||C.filename||`file_${C.id}`,mimeType:m.mimeType||C.mime_type||"application/octet-stream"}),(y=k.update)==null||y.call(k,{id:k.id,title:"Success",description:`Opened ${m.name}`,open:!0})}catch(T){console.error("Failed to fetch server file:",T);const C=T instanceof Error?T.message:"Unknown error occurred";(g=k.update)==null||g.call(k,{id:k.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(T=>({...T,[x]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function NS({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(po,{content:e,allowHtml:!1}):u.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(rt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(se.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function AS({message:e,viewMode:t}){const r=hh(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?Ia(c)??c:c;if(d&&typeof d=="object")return u.jsx(mh,{data:d});const f=typeof d=="string"?d:(()=>{try{return ho(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},s=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=U0(c);return f?u.jsx(po,{content:d,className:"text-current"}):o(c)};if(t==="preview")return null;const i=e.content.find(c=>c.type!=="tool_call");if(!i)return u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader,{className:"h-4 w-4 animate-spin"}),u.jsxs("span",{children:["Waiting for ",r," output…"]})]});if(i.type==="text"){const d=(i.text??"").trim();if(!d)return null;const f=Ns(d);return s(f)}const a=fo(i),l=Ns(a);return s(l)}const gh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,jS=e=>{const t=e.additionalKwargs??{},n=e.responseMetadata??{},r=t.originalMessageId??n.originalMessageId??t.original_message_id??n.original_message_id;return typeof r=="string"&&r.trim()?r.trim():e.id},Oa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:m=!0,isNavigatingCheckpoint:x=!1,onScrollAway:y,onAtBottom:g,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,checkpointMetaById:E,checkpointIndexByKey:j,activeCheckpointId:N,onSelectCheckpoint:A,timelineCheckpoints:M},F)=>{const $=b.useRef(null),R=b.useRef(null),z=b.useRef(!1),[_,B]=b.useState(!0),L=b.useMemo(()=>w?e.some(Y=>"type"in Y&&Y.type==="default_message"?!1:Array.isArray(Y==null?void 0:Y.content)&&Y.content.some(fe=>fe&&fe.type==="interrupt"&&(fe.id??fe.interrupt_id)===w.id)):!1,[w,e]),D=b.useMemo(()=>{if(!w||L)return null;const Y=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let fe;const ke=w.value;if(ke&&typeof ke=="object"&&!Array.isArray(ke)){const je=ke.title;typeof je=="string"&&je.trim()&&(fe=je.trim())}return{id:`interrupt-${Y}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Y,value:ke,title:fe}]}},[w,L]),Z=b.useMemo(()=>D?[...e,D]:e,[e,D]),J=b.useMemo(()=>C?Z:Z.filter(Y=>(Y==null?void 0:Y.role)!=="tool"),[Z,C]),pe=b.useMemo(()=>{const Y=new Set,fe=[];for(let ke=J.length-1;ke>=0;ke--){const je=J[ke];if(!je)continue;if("type"in je&&je.type==="default_message"){fe.push(je);continue}const Be=je,He=jS(Be);Y.has(He)||(Y.add(He),fe.push(Be))}return fe.reverse()},[J]),Ee=b.useCallback(Y=>{B(Y),y&&y(!Y),g&&g(Y)},[y,g]),Ne=b.useMemo(()=>{if(a)return async()=>{if(!z.current){z.current=!0;try{await a()}finally{z.current=!1}}}},[a]),V=b.useMemo(()=>!m||x?!1:_?"auto":!1,[_,m,x]),ee=b.useMemo(()=>M??[],[M]),U=N??(ee.length?ee[ee.length-1].id:null),O=ee.length>0,H=b.useMemo(()=>{if(typeof p!="string")return null;const Y=p.trim();return Y?{id:"default-message",role:"assistant",type:"default_message",content:Y,createdAt:new Date().toISOString()}:null},[p]),te=O?u.jsxs("div",{className:"w-48 flex-shrink-0 flex-col border-r border-border/40 pr-4 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-5 pb-5 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:"Timeline"}),u.jsxs("div",{className:"group relative z-50",children:[u.jsx(se.Info,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[11px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:'Shows user inputs and the latest loop checkpoint. Click a dot to jump the chat to that point. Click on the "Latest" button to return to the most recent messages.'})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-5 top-0 bottom-0 w-px bg-border/50"}),u.jsx("div",{className:"flex flex-col gap-4",children:ee.map(Y=>{const fe=U===Y.id;return u.jsxs("button",{type:"button",disabled:!A,onClick:()=>A==null?void 0:A(Y.id),className:`relative flex items-start gap-3 text-left text-xs transition ${fe?"text-primary":"text-muted-foreground"} ${A?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-4 w-4 items-center justify-center rounded-full border ${fe?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${fe?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium",children:Y.label||"User input"}),u.jsxs("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:[Y.step!==null?`STEP ${Y.step}`:"STEP —",Y.next?` - ${Y.next}`:""]})]})]},Y.id)})})]}),A&&u.jsx("button",{type:"button",onClick:()=>A==null?void 0:A(null),className:"mt-auto rounded-md border border-border/70 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null,ie=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),ne=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Pa,{message:H,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),Fe=pe.length>0;return b.useImperativeHandle(F,()=>({scrollToLatest:()=>{var Y,fe;if($.current&&pe.length>0){const ke=pe.length-1;(fe=(Y=$.current).scrollToIndex)==null||fe.call(Y,{index:ke,align:"end",behavior:"auto"})}else R.current&&(R.current.scrollTop=R.current.scrollHeight)},scrollToTop:()=>{var Y,fe;$.current&&pe.length>0?(fe=(Y=$.current).scrollToIndex)==null||fe.call(Y,{index:0,align:"start",behavior:"auto"}):R.current&&(R.current.scrollTop=0)}}),[pe]),u.jsxs("div",{className:ie,style:h,children:[te,u.jsx("div",{className:"relative flex-1 min-h-0",children:Fe?u.jsx(v0,{ref:Y=>{$.current=Y},scrollerRef:Y=>{R.current=Y instanceof HTMLDivElement?Y:null},data:pe,followOutput:V,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{Ne&&Ne()},atBottomStateChange:Ee,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Y,fe)=>gh(fe,Y),itemContent:(Y,fe)=>{var st;const ke=gh(fe,Y),je="type"in fe&&fe.type==="default_message";let Be=[],He=null,Ke={},qe={},Ge=null,tt=null;if(!je){const St=fe,mt=St.checkpointId??null;Ke=St.additionalKwargs??{},qe=St.responseMetadata??{};const at=mt&&E?E.get(mt)??null:null;Ge=typeof Ke.step=="number"?Ke.step:typeof qe.step=="number"?qe.step:(at==null?void 0:at.step)??null;const Ct=typeof Ke.source=="string"?Ke.source:typeof qe.source=="string"?qe.source:(at==null?void 0:at.source)??null;tt=Ct?String(Ct):null;const de=Ge!==null&&tt?`${Ge}:${tt}`:null;de&&(j!=null&&j.has(de))?Be=j.get(de)??[]:mt&&at&&(Be=[at]),He=mt??((st=Be[0])==null?void 0:st.id)??null}const Qe=(()=>{if(typeof Ke.parentCheckpointId=="string")return Ke.parentCheckpointId;if(typeof qe.parentCheckpointId=="string")return qe.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":ke,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Pa,{message:fe,messageIndex:Y,isStreamingMessage:t&&n===fe.id,streamingDebounceMs:r,isEditing:i===fe.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(Y),onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,checkpointCandidates:Be,activeCheckpointId:N??null,onSelectCheckpoint:A,defaultCheckpointId:He,messageParentCheckpointId:Qe})})}}):ne()})]})});Oa.displayName="MessageList";const xh={value:""};function $s({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:m}){const{api:x}=fi(),{currentThreadId:y}=Oo(),{threadId:g,messages:w,hasMore:S,isHistoryLoading:k,isLoading:T,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:N,checkpoints:A,interrupt:M,metadata:F}=Mo(),{isStreaming:$,error:R,connectionState:z,submit:_,stop:B}=hc(),L=g??y??null,D=(N==null?void 0:N.id)??null,Z=(N==null?void 0:N.namespace)??null,J=(F==null?void 0:F.assemblingMessageId)??null,pe=M,[Ee,Ne]=b.useState(!1);b.useEffect(()=>{pe||Ne(!1)},[pe]);const V=b.useCallback(()=>{Ne(!0)},[]),ee=b.useCallback(()=>{Ne(!1)},[]),U=!!pe||Ee,[O,H]=b.useState(null),[te,ie]=b.useState(""),[ne,Fe]=b.useState(null),[Y,fe]=b.useState(null),[ke,je]=b.useState([]),[Be,He]=b.useState(0),[Ke,qe]=b.useState(0),[Ge,tt]=b.useState(!1),[Qe,st]=b.useState(null),[St,mt]=b.useState(null),[at,Ct]=b.useState(!1),[de,re]=b.useState(null),[Ye,De]=b.useState(!1),Xe=b.useRef(!1),[Re,$e]=b.useState(()=>xh.value),Me=b.useRef(Re),jt=b.useRef(null),At=b.useCallback(G=>{xh.value=G,$e(G)},[]),[K,ve]=b.useState(!1),xe=b.useRef(null),ft=b.useCallback(G=>{if(!Array.isArray(G))return{text:null,messageId:null};for(let oe=G.length-1;oe>=0;oe--){const le=G[oe];if(!le||le.role!=="user")continue;const be=(le.content??[]).filter(Ze=>(Ze==null?void 0:Ze.type)==="text").map(Ze=>Ze.text).filter(Ze=>typeof Ze=="string"&&Ze.trim().length>0);return{text:be.length?be.join(" ").trim():null,messageId:le.id??null}}return{text:null,messageId:null}},[]),gt=b.useCallback((G,oe)=>{if(!G||typeof G!="object")return null;const le=G[oe];return typeof le=="number"?le:null},[]),Tt=b.useCallback((G,oe)=>{if(!G||typeof G!="object")return null;const le=G[oe];return typeof le=="string"&&le.trim()?le:null},[]),Pe=b.useMemo(()=>{const G=be=>{if(!Array.isArray(be)||be.length===0)return null;const dt=be.map(Ze=>{if(typeof Ze=="string")return Ze.trim();if(Ze&&typeof Ze=="object"&&"type"in Ze){const nt=Ze;if(typeof nt.type=="string")return nt.type}return null}).filter(Ze=>!!(Ze&&Ze.length));return dt.length?dt.join(", "):null},oe=Array.isArray(A)?A.map(be=>{const dt=G(be.next);return dt?{...be,metadata:{...be.metadata??{},next:dt}}:be}):[];return oe.some(be=>gt(be.metadata,"step")!==null)&&oe.sort((be,dt)=>{const Ze=gt(be.metadata,"step"),nt=gt(dt.metadata,"step");if(Ze!==null||nt!==null)return(nt??Number.NEGATIVE_INFINITY)-(Ze??Number.NEGATIVE_INFINITY);const Ot=Date.parse(be.createdAt??""),ln=Date.parse(dt.createdAt??"");return Number.isNaN(Ot)||Number.isNaN(ln)?0:ln-Ot}),oe},[A,gt]),{checkpointMetaById:Kt,checkpointIndexByKey:lt}=b.useMemo(()=>{const G=new Map,oe=new Map;for(const le of Pe){const be=le.checkpointId??null;if(!be)continue;const dt=gt(le.metadata,"step"),Ze=Tt(le.metadata,"source"),nt={id:be,step:dt,source:Ze,createdAt:le.createdAt??null,namespace:le.checkpointNs??null,parentId:le.parentId??null};if(G.set(be,nt),dt!==null&&Ze){const Ot=`${dt}:${Ze}`,ln=oe.get(Ot)??[];ln.push(nt),oe.set(Ot,ln)}}for(const le of oe.values())le.sort((be,dt)=>{const Ze=be.createdAt??"";return(dt.createdAt??"").localeCompare(Ze)});return{checkpointMetaById:G,checkpointIndexByKey:oe}},[Pe,gt,Tt]),kt=b.useMemo(()=>{var Ze;if(!Pe.length)return[];const G=[...Pe].reverse(),oe=(nt,Ot)=>{const ln=nt.checkpointId??null;if(!ln)return null;const hr=Tt(nt.metadata,"source");Tt(nt.metadata,"next");const{text:Vp,messageId:WC}=ft(nt.messages),Za=Vp&&Vp.replace(/\s+/g," ").trim()||Tt(nt.metadata,"title")||Tt(nt.metadata,"label")||Ot||hr||"Checkpoint",VC=Za.length>60?`${Za.slice(0,57)}…`:Za;return{id:ln,label:VC,messageId:WC??null,createdAt:nt.createdAt??null,step:gt(nt.metadata,"step"),source:hr??null,next:Tt(nt.metadata,"next")}},le=[],be=new Set;for(const nt of G){const Ot=((Ze=Tt(nt.metadata,"source"))==null?void 0:Ze.toLowerCase())??null;if(!(Ot==="input"||Ot==="user_input"||Ot==="user"))continue;const hr=oe(nt,"User input");hr&&!be.has(hr.id)&&(le.push(hr),be.add(hr.id))}if(!le.length)for(const nt of G){const Ot=oe(nt);Ot&&!be.has(Ot.id)&&(le.push(Ot),be.add(Ot.id))}const dt=Pe.find(nt=>{var ln;return(((ln=Tt(nt.metadata,"source"))==null?void 0:ln.toLowerCase())??null)==="loop"});if(dt){const nt=oe(dt,"Latest loop");nt&&!be.has(nt.id)&&(le.push(nt),be.add(nt.id))}return le},[Pe,ft,gt,Tt]),Kn=b.useRef(null),fr=b.useRef(null),qn=b.useCallback(()=>{Kn.current&&(Kn.current.value=""),fr.current&&(fr.current.value=""),He(G=>G+1),qe(G=>G+1)},[]),Ya=b.useCallback(G=>{At(G)},[At]),Xs=b.useRef(!1);b.useEffect(()=>{Xs.current&&!$&&(je([]),qn()),Xs.current=$},[$,qn]);const[Xa,Ja]=b.useState("desktop");b.useEffect(()=>{const G=()=>{const oe=window.innerWidth;Ja(oe<640?"phone":oe<1024?"tablet":"desktop")};return G(),window.addEventListener("resize",G),()=>window.removeEventListener("resize",G)},[]),b.useEffect(()=>{De(!1),Xe.current=!1},[L]),b.useEffect(()=>{Me.current=Re},[Re]),b.useEffect(()=>{if(!O){jt.current=null;return}jt.current===null&&(jt.current=Me.current),At(te??"")},[te,O,At]);const I=b.useCallback(async()=>{if(!(!S||k||!Ye))try{await C()}catch(G){console.warn("loadOlder failed",G)}},[S,Ye,k,C]);b.useEffect(()=>{(async()=>{if(!x.baseUrl){re(null);return}try{const le=(await x.getAgent("default")).uiDefaultMessage||"";re(le||null)}catch(oe){console.warn("Failed to fetch default message:",oe),re(null)}})()},[x.baseUrl]),b.useEffect(()=>{R&&!at&&(m==null||m(R))},[R,at,m]);const q=G=>{if(G.length>fs)return`Message too long (${G.length}/${fs} characters)`;try{return cb(G),null}catch(oe){return(oe==null?void 0:oe.message)||"Invalid message"}},ae=async G=>{const oe=G.trim();if(!(!oe&&ke.length===0)){if(oe){const le=q(oe);if(le){fe(le);return}}try{const le=D??void 0,be=Z??void 0,dt=O?{edit:!0,originalMessageId:O,...ne!=null&&ne.checkpointId?{originalCheckpointId:ne.checkpointId}:{},...ne!=null&&ne.checkpointNs?{originalCheckpointNs:ne.checkpointNs}:{}}:void 0;await _({text:oe||"",attachments:ke,messageAdditionalKwargs:dt},{checkpointId:le,checkpointNs:be}),h==null||h(oe),At(""),fe(null),je([]),qn(),H(null),ie(""),Fe(null)}catch(le){const be=(le==null?void 0:le.message)||"Failed to send message";fe(be),m==null||m(be)}}},we=b.useCallback((G,oe,le)=>{c&&(jt.current=Re,H(G),ie(oe),At(oe),fe(null),Fe({checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}))},[Re,c,At]),Je=b.useCallback(()=>{H(null),ie(""),Fe(null),fe(null),At(jt.current??Re),jt.current=null},[Re,At]),it=b.useCallback((G,oe,le)=>{we(G,oe,le)},[we]),Ue=b.useCallback(G=>{for(let oe=G-1;oe>=0;oe--)if(w[oe].role==="user"){const le=w[oe].content||[],dt=le.filter(Ze=>Ze.type==="text").map(Ze=>Ze.text).join("")||(()=>{try{return JSON.stringify(le,null,2)}catch{return String(le)}})();dt&&_({text:dt},{checkpointId:D??void 0,checkpointNs:Z??void 0});break}},[w,_,D,Z]),ze=G=>{const oe=Array.from(G.target.files||[]);je(le=>[...le,...oe]),G.target.value=""},Pt=G=>{je(oe=>{const le=oe.filter((be,dt)=>G!==dt);return le.length===0&&qn(),le})},vt=async G=>{const oe=(G.target.files||[])[0];if(oe){st(null),mt(null),tt(!0);try{await _({attachments:[oe]},{checkpointId:D??void 0,checkpointNs:Z??void 0});const le=`Uploaded ${oe.name} - processing through chat stream`;mt(le)}catch(le){const be=le instanceof Error?le.message:"Failed to upload Excel file";console.error("Excel upload failed",le),st(be),m==null||m(be)}finally{tt(!1),G.target.value="",qn()}}},yt=async G=>{if(y){ve(!0);try{if(!G){await j(),De(!1),requestAnimationFrame(()=>{var be;(be=xe.current)==null||be.scrollToLatest()});return}const oe=Pe.find(be=>be.checkpointId===G),le=(oe==null?void 0:oe.checkpointNs)??null;await E(G,le),De(!0),requestAnimationFrame(()=>{var be;(be=xe.current)==null||be.scrollToTop()})}finally{ve(!1)}}},qt=b.useCallback(async G=>{await yt(G)},[yt]),Gn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,Rn=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${f.messagesArea||""}`,$t=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,go=b.useCallback(G=>{if(!G)return"Latest";const oe=[];G.step!==null&&oe.push(`Step ${G.step}`),G.source&&oe.push(G.source);const le=G.createdAt?new Date(G.createdAt):null,be=le&&!Number.isNaN(le.getTime())?le.toLocaleString():G.createdAt??G.id,dt=oe.length?` — ${oe.join(" • ")}`:"";return`${be}${dt}`},[]);return u.jsxs("div",{className:Gn,children:[!!R&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:R}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Ct(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(se.X,{size:16})})]}),y&&Pe.length>0&&u.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:[u.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),u.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:D??"",onChange:G=>{const oe=G.target.value||null;yt(oe)},children:[u.jsx("option",{value:"",children:"Latest"}),Pe.map(G=>{const oe=Kt.get(G.checkpointId??"")??null;return u.jsx("option",{value:G.checkpointId??void 0,children:go(oe)},G.checkpointId)})]})]}),u.jsxs("div",{className:`relative ${Rn}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Oa,{ref:xe,className:"h-full",style:{height:"100%"},messages:w,isStreaming:$,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xa,enableMessageEditing:c,editingMessageId:O,onStartReached:()=>{Ye&&I()},onScrollAway:G=>{if(!Xe.current){Xe.current=!0;return}G&&De(!0)},onEdit:it,onRegenerate:Ue,onCancelEdit:Je,emptyMessage:de??void 0,isNavigatingCheckpoint:K,activeInterrupt:pe,disableInterruptActions:Ee,onInterruptActionStart:V,onInterruptActionEnd:ee,showToolMessages:d,checkpointMetaById:Kt,checkpointIndexByKey:lt,activeCheckpointId:D,onSelectCheckpoint:qt,timelineCheckpoints:kt}),(z==="reconnecting"||z==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(se.Loader2,{className:"h-3 w-3 animate-spin"}),z==="reconnecting"?"Reconnecting…":"Connecting…"]})}),z==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||K)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:$t,children:[O&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(se.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:Je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(se.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Kn,type:"file",multiple:!0,onChange:G=>ze(G),className:"hidden"},Be),ke.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:ke.map((G,oe)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(se.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:G.name}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>Pt(oe),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 ${G.name}`,children:u.jsx(se.X,{size:12})})]},oe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:fr,type:"file",accept:".xls,.xlsx,.xlsm",onChange:vt,className:"hidden"},Ke),Ge&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(se.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),St&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:St}),Qe&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Qe})]})]}),Y&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Y}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Qw,{children:[u.jsx(eb,{asChild:!0,children:u.jsx(rt,{type:"button",size:"icon",variant:"outline",disabled:$||U,title:"More input actions",className:f.moreButton||"",children:u.jsx(se.Plus,{size:16})})}),u.jsxs(Td,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(ea,{onClick:()=>{var G;return(G=Kn.current)==null?void 0:G.click()},className:"cursor-pointer",children:[u.jsx(se.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(ea,{onClick:()=>{var G;Ge||(G=fr.current)==null||G.click()},className:`cursor-pointer ${Ge?"opacity-60 pointer-events-none":""}`,children:[u.jsx(se.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(ex,{initialValue:te,editingMessageId:O,value:Re,onValueChange:Ya,placeholder:O?"Edit your message...":t,isStreaming:$,disabled:U,maxLength:fs,onSend:ae,onCancelEdit:Je,onStop:B,allowEmptySend:ke.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${O?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Y?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const zs=v.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:Q("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}));zs.displayName="Input";function Ma(e,[t,n]){return Math.min(n,Math.max(t,e))}function _S(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var Da="ScrollArea",[yh,bT]=In(Da),[RS,sn]=yh(Da),vh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,d]=v.useState(null),[f,h]=v.useState(null),[p,m]=v.useState(null),[x,y]=v.useState(null),[g,w]=v.useState(0),[S,k]=v.useState(0),[T,C]=v.useState(!1),[E,j]=v.useState(!1),N=We(t,M=>l(M)),A=Lo(o);return u.jsx(RS,{scope:n,type:r,dir:A,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:x,onScrollbarYChange:y,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(Ae.div,{dir:A,...i,ref:N,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});vh.displayName=Da;var wh="ScrollAreaViewport",bh=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(wh,n),a=v.useRef(null),l=We(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(Ae.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});bh.displayName=wh;var kn="ScrollAreaScrollbar",La=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(PS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(OS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Sh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Fa,{...r,ref:t}):null});La.displayName=kn;var PS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(tn,{present:n||s,children:u.jsx(Sh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),OS=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ws(()=>l("SCROLL_END"),100),[a,l]=_S("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const h=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),u.jsx(tn,{present:n||a!=="hidden",children:u.jsx(Fa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:he(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:he(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Sh=v.forwardRef((e,t)=>{const n=sn(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=Ws(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ar(n.viewport,l),Ar(n.content,l),u.jsx(tn,{present:r||s,children:u.jsx(Fa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Fa=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(kn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Ih(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return zS(h,i.current,a,p)}return n==="horizontal"?u.jsx(MS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Nh(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"?u.jsx(DS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Nh(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}),MS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=We(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Th,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Us(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),jh(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:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),DS=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(kn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=We(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Th,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Us(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),jh(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:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[LS,Ch]=yh(kn),Th=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...h}=e,p=sn(kn,n),[m,x]=v.useState(null),y=We(t,N=>x(N)),g=v.useRef(null),w=v.useRef(""),S=p.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Ws(f,10);function j(N){if(g.current){const A=N.clientX-g.current.left,M=N.clientY-g.current.top;c({x:A,y:M})}}return v.useEffect(()=>{const N=A=>{const M=A.target;(m==null?void 0:m.contains(M))&&T(A,k)};return document.addEventListener("wheel",N,{passive:!1}),()=>document.removeEventListener("wheel",N,{passive:!1})},[S,m,k,T]),v.useEffect(C,[r,C]),Ar(m,E),Ar(p.content,E),u.jsx(LS,{scope:n,scrollbar:m,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(Ae.div,{...h,ref:y,style:{position:"absolute",...h.style},onPointerDown:he(e.onPointerDown,N=>{N.button===0&&(N.target.setPointerCapture(N.pointerId),g.current=m.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(N))}),onPointerMove:he(e.onPointerMove,j),onPointerUp:he(e.onPointerUp,N=>{const A=N.target;A.hasPointerCapture(N.pointerId)&&A.releasePointerCapture(N.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),g.current=null})})})}),Bs="ScrollAreaThumb",kh=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ch(Bs,e.__scopeScrollArea);return u.jsx(tn,{present:n||o.hasThumb,children:u.jsx(FS,{ref:t,...r})})}),FS=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Bs,n),i=Ch(Bs,n),{onThumbPositionChange:a}=i,l=We(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),d=Ws(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!c.current){const p=BS(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),u.jsx(Ae.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(),m=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:m,y:x})}),onPointerUp:he(e.onPointerUp,i.onThumbPointerUp)})});kh.displayName=Bs;var $a="ScrollAreaCorner",Eh=v.forwardRef((e,t)=>{const n=sn($a,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx($S,{...e,ref:t}):null});Eh.displayName=$a;var $S=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn($a,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return Ar(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ar(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(Ae.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 Hs(e){return e?parseInt(e,10):0}function Ih(e,t){const n=e/t;return isNaN(n)?0:n}function Us(e){const t=Ih(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zS(e,t,n,r="ltr"){const o=Us(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Ah([l,c],f)(e)}function Nh(e,t,n="ltr"){const r=Us(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Ma(e,l);return Ah([0,i],[0,a])(c)}function Ah(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 jh(e,t){return e>0&&e<t}var BS=(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 Ws(e,t){const n=Rt(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ar(e,t){const n=Rt(t);_t(()=>{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 _h=vh,HS=bh,US=Eh;const Rh=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(_h,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[u.jsx(HS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Ph,{}),u.jsx(US,{})]}));Rh.displayName=_h.displayName;const Ph=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(La,{ref:r,orientation:t,className:Q("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(kh,{className:"relative flex-1 rounded-full bg-border"})}));Ph.displayName=La.displayName;const Oh=25;function za({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d}){const{threads:f,currentThreadId:h,setCurrentThreadId:p,isLoading:m,actions:x}=Oo(),{loadThread:y}=Mo(),{createThread:g,deleteThread:w,renameThread:S}=x,[k,T]=b.useState(Array.isArray(f)?f:[]),C=b.useRef(k.length>0),E=b.useRef(null),j=b.useRef(0),[N,A]=b.useState(null),[M,F]=b.useState(""),[$,R]=b.useState(!1);b.useEffect(()=>{const V=Array.isArray(f)?f:[];if(V.length>0){C.current=!0,T(V);return}m||(C.current=!1,T(V))},[f,m]),b.useEffect(()=>{if(!E.current)return;const V=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!V)return;let ee=null,U=null;return ee=requestAnimationFrame(()=>{U=requestAnimationFrame(()=>{V.scrollTop=j.current})}),()=>{ee!==null&&cancelAnimationFrame(ee),U!==null&&cancelAnimationFrame(U)}},[k]);const z=async V=>{try{p(V),await y(V),a==null||a(V),l==null||l(V)}catch(ee){console.error("Failed to select thread:",ee)}},_=async()=>{try{R(!0);const V=await g();V&&(c==null||c(V),a==null||a(V))}catch(V){console.error("Failed to create thread:",V)}finally{R(!1)}},B=async(V,ee)=>{if(ee.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const U=E.current.querySelector("[data-radix-scroll-area-viewport]");U&&(j.current=U.scrollTop)}try{await w(V),d==null||d(V)}catch(U){console.error("Failed to delete thread:",U)}}},L=(V,ee)=>{ee.stopPropagation(),A(V.threadId),F(V.title||`Thread ${V.threadId.slice(0,8)}`)},D=async V=>{if(M.trim())try{await S(V,M.trim()),A(null),F("")}catch(ee){console.error("Failed to update title:",ee)}},Z=()=>{A(null),F("")},J=(V,ee)=>{V.key==="Enter"?D(ee):V.key==="Escape"&&Z()},pe=V=>{if(!V)return"";try{const ee=new Date(V),O=new Date().getTime()-ee.getTime(),H=Math.floor(O/(1e3*60*60*24));return H===0?ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):H===1?"Yesterday":H<7?`${H} days ago`:ee.toLocaleDateString()}catch{return""}},Ee=V=>V.title||`Thread ${V.threadId.slice(0,8)}`,Ne=V=>{const ee=Ee(V);return ee.length<=Oh?ee:`${ee.slice(0,Oh)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&u.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:u.jsx(rt,{onClick:_,disabled:$||m,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:$?"Creating...":"New Chat",children:u.jsx(se.MessageSquarePlus,{size:20})})}),u.jsx(Rh,{ref:E,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:m?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(se.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):k.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(se.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):k.slice().sort((V,ee)=>new Date(ee.updatedAt||ee.createdAt||"").getTime()-new Date(V.updatedAt||V.createdAt||"").getTime()).map(V=>u.jsxs("div",{onClick:()=>z(V.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===V.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:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:N===V.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:ee=>ee.stopPropagation(),children:[u.jsx(zs,{value:M,onChange:ee=>F(ee.target.value),onKeyDown:ee=>J(ee,V.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:()=>D(V.threadId),className:"h-6 w-6 p-0",children:u.jsx(se.Check,{size:12})}),u.jsx(rt,{variant:"ghost",size:"sm",onClick:Z,className:"h-6 w-6 p-0",children:u.jsx(se.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:Ne(V)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(se.Calendar,{size:10}),u.jsx("span",{children:pe(V.updatedAt||V.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==V.threadId&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ee=>L(V,ee),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(se.Edit3,{size:12})}),n&&u.jsx(rt,{variant:"ghost",size:"sm",onClick:ee=>B(V.threadId,ee),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:u.jsx(se.Trash2,{size:12})})]})]}),i===V.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},V.threadId))})})]})}function jr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function WS(e){if(typeof e!="string")return;const t=e.trim();if(t)return En(t)}function Mh(){const e=[jr("__API_BASE_URL__"),jr("__CHAT_API_BASE_URL__"),jr("__CHAT_API_URL__")];for(const t of e){const n=WS(t);if(n)return n}}function Dh(){const e=[jr("__API_AUTH_TOKEN__"),jr("__CHAT_API_KEY__"),jr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Lh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return En(t);return En()}function Fh(){const e={},t=Mh(),n=Dh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function $h(){const e=Fh(),t=Pn.getAuthToken(),n=Mh();return{apiBaseUrl:Lh(e.baseUrl,Pn.baseUrl,n),apiKey:t||e.apiKey||Dh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const zh="chat-settings";function VS(){try{const e=localStorage.getItem(zh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function KS(e){try{const t={...e,apiBaseUrl:En(e.apiBaseUrl)};localStorage.setItem(zh,JSON.stringify(t)),t.apiKey&&Pn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function qS(){const e=$h(),t=VS(),n=Pn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Lh(Pn.baseUrl,r,e.apiBaseUrl)}}function GS(e){Pn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),KS(e)}var YS="Label",Bh=v.forwardRef((e,t)=>u.jsx(Ae.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())}}));Bh.displayName=YS;var Hh=Bh;const XS=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),an=v.forwardRef(({className:e,...t},n)=>u.jsx(Hh,{ref:n,className:Q(XS(),e),...t}));an.displayName=Hh.displayName;function Uh(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Vs="Switch",[JS,ST]=In(Vs),[ZS,QS]=JS(Vs),Wh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[h,p]=v.useState(null),m=We(t,S=>p(S)),x=v.useRef(!1),y=h?d||!!h.closest("form"):!0,[g,w]=xr({prop:o,defaultProp:s??!1,onChange:c,caller:Vs});return u.jsxs(ZS,{scope:n,checked:g,disabled:a,children:[u.jsx(Ae.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Gh(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onClick:he(e.onClick,S=>{w(k=>!k),y&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),y&&u.jsx(qh,{control:h,bubbles:!x.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Wh.displayName=Vs;var Vh="SwitchThumb",Kh=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=QS(Vh,n);return u.jsx(Ae.span,{"data-state":Gh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Kh.displayName=Vh;var eC="SwitchBubbleInput",qh=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=We(i,s),l=Uh(n),c=Jc(t);return v.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const m=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(m)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});qh.displayName=eC;function Gh(e){return e?"checked":"unchecked"}var Yh=Wh,tC=Kh;const Un=v.forwardRef(({className:e,...t},n)=>u.jsx(Yh,{className:Q("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(tC,{className:Q("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")})}));Un.displayName=Yh.displayName;var Xh=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"}),nC="VisuallyHidden",rC=v.forwardRef((e,t)=>u.jsx(Ae.span,{...e,ref:t,style:{...Xh,...e.style}}));rC.displayName=nC;var oC=[" ","Enter","ArrowUp","ArrowDown"],sC=[" ","Enter"],cr="Select",[Ks,qs,iC]=vi(cr),[_r,CT]=In(cr,[iC,Xo]),Gs=Xo(),[aC,Wn]=_r(cr),[lC,cC]=_r(cr),Jh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:h,required:p,form:m}=e,x=Gs(t),[y,g]=v.useState(null),[w,S]=v.useState(null),[k,T]=v.useState(!1),C=Lo(c),[E,j]=xr({prop:r,defaultProp:o??!1,onChange:s,caller:cr}),[N,A]=xr({prop:i,defaultProp:a,onChange:l,caller:cr}),M=v.useRef(null),F=y?m||!!y.closest("form"):!0,[$,R]=v.useState(new Set),z=Array.from($).map(_=>_.props.value).join(";");return u.jsx(au,{...x,children:u.jsxs(aC,{required:p,scope:t,trigger:y,onTriggerChange:g,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:Nn(),value:N,onValueChange:A,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:M,disabled:h,children:[u.jsx(Ks.Provider,{scope:t,children:u.jsx(lC,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(_=>{R(B=>new Set(B).add(_))},[]),onNativeOptionRemove:v.useCallback(_=>{R(B=>{const L=new Set(B);return L.delete(_),L})},[]),children:n})}),F?u.jsxs(bp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:N,onChange:_=>A(_.target.value),disabled:h,form:m,children:[N===void 0?u.jsx("option",{value:""}):null,Array.from($)]},z):null]})})};Jh.displayName=cr;var Zh="SelectTrigger",Qh=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Gs(n),i=Wn(Zh,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=qs(n),d=v.useRef("touch"),[f,h,p]=Cp(x=>{const y=c().filter(S=>!S.disabled),g=y.find(S=>S.value===i.value),w=Tp(y,x,g);w!==void 0&&i.onValueChange(w.value)}),m=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return u.jsx(lu,{asChild:!0,...s,children:u.jsx(Ae.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":Sp(i.value)?"":void 0,...o,ref:l,onClick:he(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&m(x)}),onPointerDown:he(o.onPointerDown,x=>{d.current=x.pointerType;const y=x.target;y.hasPointerCapture(x.pointerId)&&y.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(m(x),x.preventDefault())}),onKeyDown:he(o.onKeyDown,x=>{const y=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(y&&x.key===" ")&&oC.includes(x.key)&&(m(),x.preventDefault())})})})});Qh.displayName=Zh;var ep="SelectValue",tp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Wn(ep,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=We(t,l.onValueNodeChange);return _t(()=>{c(d)},[c,d]),u.jsx(Ae.span,{...a,ref:f,style:{pointerEvents:"none"},children:Sp(l.value)?u.jsx(u.Fragment,{children:i}):s})});tp.displayName=ep;var uC="SelectIcon",np=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Ae.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});np.displayName=uC;var dC="SelectPortal",rp=e=>u.jsx(Jo,{asChild:!0,...e});rp.displayName=dC;var ur="SelectContent",op=v.forwardRef((e,t)=>{const n=Wn(ur,e.__scopeSelect),[r,o]=v.useState();if(_t(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?yo.createPortal(u.jsx(sp,{scope:e.__scopeSelect,children:u.jsx(Ks.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(ip,{...e,ref:t})});op.displayName=ur;var mn=10,[sp,Vn]=_r(ur),fC="SelectContentImpl",hC=Yn.createSlot("SelectContent.RemoveScroll"),ip=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y,...g}=e,w=Wn(ur,n),[S,k]=v.useState(null),[T,C]=v.useState(null),E=We(t,U=>k(U)),[j,N]=v.useState(null),[A,M]=v.useState(null),F=qs(n),[$,R]=v.useState(!1),z=v.useRef(!1);v.useEffect(()=>{if(S)return Bi(S)},[S]),Si();const _=v.useCallback(U=>{const[O,...H]=F().map(ne=>ne.ref.current),[te]=H.slice(-1),ie=document.activeElement;for(const ne of U)if(ne===ie||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===O&&T&&(T.scrollTop=0),ne===te&&T&&(T.scrollTop=T.scrollHeight),ne==null||ne.focus(),document.activeElement!==ie))return},[F,T]),B=v.useCallback(()=>_([j,S]),[_,j,S]);v.useEffect(()=>{$&&B()},[$,B]);const{onOpenChange:L,triggerPointerDownPosRef:D}=w;v.useEffect(()=>{if(S){let U={x:0,y:0};const O=te=>{var ie,ne;U={x:Math.abs(Math.round(te.pageX)-(((ie=D.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ne=D.current)==null?void 0:ne.y)??0))}},H=te=>{U.x<=10&&U.y<=10?te.preventDefault():S.contains(te.target)||L(!1),document.removeEventListener("pointermove",O),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,L,D]),v.useEffect(()=>{const U=()=>L(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[L]);const[Z,J]=Cp(U=>{const O=F().filter(ie=>!ie.disabled),H=O.find(ie=>ie.ref.current===document.activeElement),te=Tp(O,U,H);te&&setTimeout(()=>te.ref.current.focus())}),pe=v.useCallback((U,O,H)=>{const te=!z.current&&!H;(w.value!==void 0&&w.value===O||te)&&(N(U),te&&(z.current=!0))},[w.value]),Ee=v.useCallback(()=>S==null?void 0:S.focus(),[S]),Ne=v.useCallback((U,O,H)=>{const te=!z.current&&!H;(w.value!==void 0&&w.value===O||te)&&M(U)},[w.value]),V=r==="popper"?Ba:ap,ee=V===Ba?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:m,hideWhenDetached:x,avoidCollisions:y}:{};return u.jsx(sp,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:pe,selectedItem:j,onItemLeave:Ee,itemTextRefCallback:Ne,focusSelectedItem:B,selectedItemText:A,position:r,isPositioned:$,searchRef:Z,children:u.jsx(is,{as:hC,allowPinchZoom:!0,children:u.jsx($o,{asChild:!0,trapped:w.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:he(o,U=>{var O;(O=w.trigger)==null||O.focus({preventScroll:!0}),U.preventDefault()}),children:u.jsx(Fo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(V,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:U=>U.preventDefault(),...g,...ee,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:he(g.onKeyDown,U=>{const O=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!O&&U.key.length===1&&J(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let te=F().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(U.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const ie=U.target,ne=te.indexOf(ie);te=te.slice(ne+1)}setTimeout(()=>_(te)),U.preventDefault()}})})})})})})});ip.displayName=fC;var pC="SelectItemAlignedPosition",ap=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Wn(ur,n),i=Vn(ur,n),[a,l]=v.useState(null),[c,d]=v.useState(null),f=We(t,E=>d(E)),h=qs(n),p=v.useRef(!1),m=v.useRef(!0),{viewport:x,selectedItem:y,selectedItemText:g,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&x&&y&&g){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),N=s.valueNode.getBoundingClientRect(),A=g.getBoundingClientRect();if(s.dir!=="rtl"){const ie=A.left-j.left,ne=N.left-ie,Fe=E.left-ne,Y=E.width+Fe,fe=Math.max(Y,j.width),ke=window.innerWidth-mn,je=Ma(ne,[mn,Math.max(mn,ke-fe)]);a.style.minWidth=Y+"px",a.style.left=je+"px"}else{const ie=j.right-A.right,ne=window.innerWidth-N.right-ie,Fe=window.innerWidth-E.right-ne,Y=E.width+Fe,fe=Math.max(Y,j.width),ke=window.innerWidth-mn,je=Ma(ne,[mn,Math.max(mn,ke-fe)]);a.style.minWidth=Y+"px",a.style.right=je+"px"}const M=h(),F=window.innerHeight-mn*2,$=x.scrollHeight,R=window.getComputedStyle(c),z=parseInt(R.borderTopWidth,10),_=parseInt(R.paddingTop,10),B=parseInt(R.borderBottomWidth,10),L=parseInt(R.paddingBottom,10),D=z+_+$+L+B,Z=Math.min(y.offsetHeight*5,D),J=window.getComputedStyle(x),pe=parseInt(J.paddingTop,10),Ee=parseInt(J.paddingBottom,10),Ne=E.top+E.height/2-mn,V=F-Ne,ee=y.offsetHeight/2,U=y.offsetTop+ee,O=z+_+U,H=D-O;if(O<=Ne){const ie=M.length>0&&y===M[M.length-1].ref.current;a.style.bottom="0px";const ne=c.clientHeight-x.offsetTop-x.offsetHeight,Fe=Math.max(V,ee+(ie?Ee:0)+ne+B),Y=O+Fe;a.style.height=Y+"px"}else{const ie=M.length>0&&y===M[0].ref.current;a.style.top="0px";const Fe=Math.max(Ne,z+x.offsetTop+(ie?pe:0)+ee)+H;a.style.height=Fe+"px",x.scrollTop=O-Ne+x.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=Z+"px",a.style.maxHeight=F+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,x,y,g,s.dir,r]);_t(()=>S(),[S]);const[k,T]=v.useState();_t(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&m.current===!0&&(S(),w==null||w(),m.current=!1)},[S,w]);return u.jsx(gC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(Ae.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ap.displayName=pC;var mC="SelectPopperPosition",Ba=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=Gs(n);return u.jsx(cu,{...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)"}})});Ba.displayName=mC;var[gC,Ha]=_r(ur,{}),Ua="SelectViewport",lp=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Vn(Ua,n),i=Ha(Ua,n),a=We(t,s.onViewportChange),l=v.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Ks.Slot,{scope:n,children:u.jsx(Ae.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:he(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const m=window.innerHeight-mn*2,x=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),g=Math.max(x,y);if(g<m){const w=g+p,S=Math.min(m,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});lp.displayName=Ua;var cp="SelectGroup",[xC,yC]=_r(cp),vC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nn();return u.jsx(xC,{scope:n,id:o,children:u.jsx(Ae.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vC.displayName=cp;var up="SelectLabel",dp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yC(up,n);return u.jsx(Ae.div,{id:o.id,...r,ref:t})});dp.displayName=up;var Ys="SelectItem",[wC,fp]=_r(Ys),hp=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Wn(Ys,n),l=Vn(Ys,n),c=a.value===r,[d,f]=v.useState(s??""),[h,p]=v.useState(!1),m=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=Nn(),y=v.useRef("touch"),g=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(wC,{scope:n,value:r,disabled:o,textId:x,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Ae.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:m,onFocus:he(i.onFocus,()=>p(!0)),onBlur:he(i.onBlur,()=>p(!1)),onClick:he(i.onClick,()=>{y.current!=="mouse"&&g()}),onPointerUp:he(i.onPointerUp,()=>{y.current==="mouse"&&g()}),onPointerDown:he(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:he(i.onPointerMove,w=>{var S;y.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:he(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:he(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(sC.includes(w.key)&&g(),w.key===" "&&w.preventDefault())})})})})});hp.displayName=Ys;var mo="SelectItemText",pp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Wn(mo,n),a=Vn(mo,n),l=fp(mo,n),c=cC(mo,n),[d,f]=v.useState(null),h=We(t,g=>f(g),l.onItemTextChange,g=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,g,l.value,l.disabled)}),p=d==null?void 0:d.textContent,m=v.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:y}=c;return _t(()=>(x(m),()=>y(m)),[x,y,m]),u.jsxs(u.Fragment,{children:[u.jsx(Ae.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?yo.createPortal(s.children,i.valueNode):null]})});pp.displayName=mo;var mp="SelectItemIndicator",gp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return fp(mp,n).isSelected?u.jsx(Ae.span,{"aria-hidden":!0,...r,ref:t}):null});gp.displayName=mp;var Wa="SelectScrollUpButton",xp=v.forwardRef((e,t)=>{const n=Vn(Wa,e.__scopeSelect),r=Ha(Wa,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return _t(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(vp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});xp.displayName=Wa;var Va="SelectScrollDownButton",yp=v.forwardRef((e,t)=>{const n=Vn(Va,e.__scopeSelect),r=Ha(Va,e.__scopeSelect),[o,s]=v.useState(!1),i=We(t,r.onScrollButtonChange);return _t(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(vp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});yp.displayName=Va;var vp=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Vn("SelectScrollButton",n),i=v.useRef(null),a=qs(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),_t(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(Ae.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 c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:he(o.onPointerLeave,()=>{l()})})}),bC="SelectSeparator",wp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Ae.div,{"aria-hidden":!0,...r,ref:t})});wp.displayName=bC;var Ka="SelectArrow",SC=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gs(n),s=Wn(Ka,n),i=Vn(Ka,n);return s.open&&i.position==="popper"?u.jsx(uu,{...o,...r,ref:t}):null});SC.displayName=Ka;var CC="SelectBubbleInput",bp=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=We(r,o),i=Uh(t);return v.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]),u.jsx(Ae.select,{...n,style:{...Xh,...n.style},ref:s,defaultValue:t})});bp.displayName=CC;function Sp(e){return e===""||e===void 0}function Cp(e){const t=Rt(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Tp(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=TC(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function TC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kC=Jh,kp=Qh,EC=tp,IC=np,NC=rp,Ep=op,AC=lp,Ip=dp,Np=hp,jC=pp,_C=gp,Ap=xp,jp=yp,_p=wp;const Rp=kC,Pp=EC,qa=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(kp,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(IC,{asChild:!0,children:u.jsx(se.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));qa.displayName=kp.displayName;const Op=v.forwardRef(({className:e,...t},n)=>u.jsx(Ap,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronUp,{className:"h-4 w-4"})}));Op.displayName=Ap.displayName;const Mp=v.forwardRef(({className:e,...t},n)=>u.jsx(jp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(se.ChevronDown,{className:"h-4 w-4"})}));Mp.displayName=jp.displayName;const Ga=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(NC,{children:u.jsxs(Ep,{ref:o,className:Q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Op,{}),u.jsx(AC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Mp,{})]})}));Ga.displayName=Ep.displayName;const RC=v.forwardRef(({className:e,...t},n)=>u.jsx(Ip,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RC.displayName=Ip.displayName;const dr=v.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Np,{ref:r,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(_C,{children:u.jsx(se.Check,{className:"h-4 w-4"})})}),u.jsx(jC,{children:t})]}));dr.displayName=Np.displayName;const PC=v.forwardRef(({className:e,...t},n)=>u.jsx(_p,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));PC.displayName=_p.displayName;var OC="Separator",Dp="horizontal",MC=["horizontal","vertical"],Lp=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=Dp,...o}=e,s=DC(r)?r:Dp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Ae.div,{"data-orientation":s,...a,...o,ref:t})});Lp.displayName=OC;function DC(e){return MC.includes(e)}var Fp=Lp;const $p=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Fp,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));$p.displayName=Fp.displayName;const LC=qf,FC=Q0,$C=Gf,zp=v.forwardRef(({className:e,...t},n)=>u.jsx(_s,{className:Q("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}));zp.displayName=_s.displayName;const zC=xo.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"}}),Bp=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs($C,{children:[u.jsx(zp,{}),u.jsxs(Rs,{ref:o,className:Q(zC({side:e}),t),...r,children:[n,u.jsxs(Yf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(se.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Bp.displayName=Rs.displayName;const Hp=({className:e,...t})=>u.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Hp.displayName="SheetHeader";const Up=v.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Up.displayName=ar.displayName;const Wp=v.forwardRef(({className:e,...t},n)=>u.jsx(Ps,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Wp.displayName=Ps.displayName;const BC={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 HC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,d]=b.useState(!1),{toast:f}=Ea();b.useEffect(()=>{const y=JSON.stringify(a)!==JSON.stringify(e);d(y)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(BC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},m=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const g=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${g.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return u.jsxs(LC,{open:r,onOpenChange:o,children:[u.jsx(FC,{asChild:!0,children:u.jsxs(rt,{variant:"outline",size:"sm",className:n,children:[u.jsx(se.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Tf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Bp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Hp,{children:[u.jsx(Up,{children:"Chat Settings"}),u.jsx(Wp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"api-url",value:a.api.baseUrl,onChange:y=>l(g=>({...g,api:{...g.api,baseUrl:y.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(rt,{variant:"outline",onClick:x,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Un,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:y=>l(g=>({...g,api:{...g.api,enableAuth:y}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(zs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:y=>l(g=>({...g,api:{...g.api,authToken:y.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(rt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(se.EyeOff,{className:"h-4 w-4"}):u.jsx(se.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Rp,{value:a.ui.layout,onValueChange:y=>l(g=>({...g,ui:{...g.ui,layout:y}})),children:[u.jsx(qa,{children:u.jsx(Pp,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(dr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(dr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(an,{htmlFor:"theme",children:"Theme"}),u.jsxs(Rp,{value:a.ui.theme,onValueChange:y=>l(g=>({...g,ui:{...g.ui,theme:y}})),children:[u.jsx(qa,{children:u.jsx(Pp,{})}),u.jsxs(Ga,{children:[u.jsx(dr,{value:"light",children:"Light"}),u.jsx(dr,{value:"dark",children:"Dark"}),u.jsx(dr,{value:"system",children:"System"})]})]})]}),u.jsx($p,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Un,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showTimestamps:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Un,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,showAgentNames:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(an,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Un,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:y=>l(g=>({...g,ui:{...g.ui,compactMessages:y}}))})]})]})]})]}),u.jsxs(io,{children:[u.jsx(ao,{className:"pb-3",children:u.jsxs(lo,{className:"text-lg flex items-center gap-2",children:[u.jsx(se.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(co,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Un,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,autoSave:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Un,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:y}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(an,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Un,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:y=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:y}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(rt,{variant:"outline",onClick:p,children:[u.jsx(se.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(rt,{variant:"outline",onClick:m,children:"Cancel"}),u.jsxs(rt,{onClick:h,disabled:!c,children:[u.jsx(se.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function UC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Do,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(za,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Do,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(za,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=ql,Te.ChatInput=mc,Te.ChatInterface=$s,Te.ChatProviders=Do,Te.ChatSettings=HC,Te.MarkdownContent=po,Te.MessageComponent=Pa,Te.MessageList=Oa,Te.ThreadManager=za,Te.applySettings=GS,Te.chatApiClient=Pn,Te.default=UC,Te.del=Kl,Te.get=Qt,Te.getChatToken=Ul,Te.getCurrentSettings=qS,Te.getDefaultApiConfig=Fh,Te.getDefaultChatSettings=$h,Te.onChatTokenChanged=Wl,Te.post=di,Te.put=Vl,Te.setChatToken=jo,Te.useApi=fi,Te.useChatStream=lc,Te.useMessagesReducer=ec,Te.useStream=hc,Te.useThreadState=Mo,Te.useThreads=Oo,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|