teodor-new-chat-ui 4.3.310 → 4.3.312

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Ne,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(Ne=typeof globalThis<"u"?globalThis:Ne||self,w(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,w,ce,Kn,ho,Kh,qh,Gs){"use strict";var oT=Object.defineProperty;var sT=(Ne,w,ce)=>w in Ne?oT(Ne,w,{enumerable:!0,configurable:!0,writable:!0,value:ce}):Ne[w]=ce;var Wh=(Ne,w,ce)=>sT(Ne,typeof w!="symbol"?w+"":w,ce);var Ys=typeof document<"u"?document.currentScript:null;function Xa(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 y=Xa(w),mo=Xa(Gs);var Xs={exports:{}},jr={};/**
1
+ (function(Ie,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],w):(Ie=typeof globalThis<"u"?globalThis:Ie||self,w(Ie.NewChatUI={},Ie.React,Ie.LucideReact,Ie.reactSlot,Ie.classVarianceAuthority,Ie.clsx,Ie.tailwindMerge,Ie.ReactDOM))})(this,function(Ie,w,ce,Vn,ho,qh,Gh,Gs){"use strict";var aT=Object.defineProperty;var lT=(Ie,w,ce)=>w in Ie?aT(Ie,w,{enumerable:!0,configurable:!0,writable:!0,value:ce}):Ie[w]=ce;var Vh=(Ie,w,ce)=>lT(Ie,typeof w!="symbol"?w+"":w,ce);var Ys=typeof document<"u"?document.currentScript:null;function Xa(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 y=Xa(w),mo=Xa(Gs);var Xs={exports:{}},_r={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ja;function Gh(){if(Ja)return jr;Ja=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,f={},p=null,h=null;c!==void 0&&(p=""+c),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(h=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:p,ref:h,props:f,_owner:o.current}}return jr.Fragment=n,jr.jsx=i,jr.jsxs=i,jr}var Rr={};/**
9
+ */var Ja;function Yh(){if(Ja)return _r;Ja=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,f={},p=null,h=null;c!==void 0&&(p=""+c),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(h=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:p,ref:h,props:f,_owner:o.current}}return _r.Fragment=n,_r.jsx=i,_r.jsxs=i,_r}var jr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,33 +14,33 @@
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 Za;function Yh(){return Za||(Za=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),x=Symbol.iterator,m="@@iterator";function v(I){if(I===null||typeof I!="object")return null;var W=x&&I[x]||I[m];return typeof W=="function"?W:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var W=arguments.length,le=new Array(W>1?W-1:0),Ie=1;Ie<W;Ie++)le[Ie-1]=arguments[Ie];S("error",I,le)}}function S(I,W,le){{var Ie=g.ReactDebugCurrentFrame,Qe=Ie.getStackAddendum();Qe!==""&&(W+="%s",le=le.concat([Qe]));var ot=le.map(function(Ve){return String(Ve)});ot.unshift("Warning: "+W),Function.prototype.apply.call(console[I],console,ot)}}var k=!1,T=!1,C=!1,E=!1,N=!1,_;_=Symbol.for("react.module.reference");function L(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||N||I===o||I===c||I===d||E||I===h||k||T||C||typeof I=="object"&&I!==null&&(I.$$typeof===p||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===_||I.getModuleId!==void 0))}function j(I,W,le){var Ie=I.displayName;if(Ie)return Ie;var Qe=W.displayName||W.name||"";return Qe!==""?le+"("+Qe+")":le}function M(I){return I.displayName||"Context"}function z(I){if(I==null)return null;if(typeof I.tag=="number"&&b("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 W=I;return M(W)+".Consumer";case i:var le=I;return M(le._context)+".Provider";case l:return j(I,I.render,"ForwardRef");case f:var Ie=I.displayName||null;return Ie!==null?Ie:z(I.type)||"Memo";case p:{var Qe=I,ot=Qe._payload,Ve=Qe._init;try{return z(Ve(ot))}catch{return null}}}return null}var A=Object.assign,F=0,R,G,B,D,V,Y,he;function ae(){}ae.__reactDisabledLog=!0;function _e(){{if(F===0){R=console.log,G=console.info,B=console.warn,D=console.error,V=console.group,Y=console.groupCollapsed,he=console.groupEnd;var I={configurable:!0,enumerable:!0,value:ae,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}F++}}function X(){{if(F--,F===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},I,{value:R}),info:A({},I,{value:G}),warn:A({},I,{value:B}),error:A({},I,{value:D}),group:A({},I,{value:V}),groupCollapsed:A({},I,{value:Y}),groupEnd:A({},I,{value:he})})}F<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var H=g.ReactCurrentDispatcher,J;function $(I,W,le){{if(J===void 0)try{throw Error()}catch(Qe){var Ie=Qe.stack.trim().match(/\n( *(at )?)/);J=Ie&&Ie[1]||""}return`
18
- `+J+I}}var K=!1,re;{var oe=typeof WeakMap=="function"?WeakMap:Map;re=new oe}function se(I,W){if(!I||K)return"";{var le=re.get(I);if(le!==void 0)return le}var Ie;K=!0;var Qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ot;ot=H.current,H.current=null,_e();try{if(W){var Ve=function(){throw Error()};if(Object.defineProperty(Ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ve,[])}catch(ie){Ie=ie}Reflect.construct(I,[],Ve)}else{try{Ve.call()}catch(ie){Ie=ie}I.call(Ve.prototype)}}else{try{throw Error()}catch(ie){Ie=ie}I()}}catch(ie){if(ie&&Ie&&typeof ie.stack=="string"){for(var He=ie.stack.split(`
19
- `),_t=Ie.stack.split(`
20
- `),bt=He.length-1,St=_t.length-1;bt>=1&&St>=0&&He[bt]!==_t[St];)St--;for(;bt>=1&&St>=0;bt--,St--)if(He[bt]!==_t[St]){if(bt!==1||St!==1)do if(bt--,St--,St<0||He[bt]!==_t[St]){var Vt=`
21
- `+He[bt].replace(" at new "," at ");return I.displayName&&Vt.includes("<anonymous>")&&(Vt=Vt.replace("<anonymous>",I.displayName)),typeof I=="function"&&re.set(I,Vt),Vt}while(bt>=1&&St>=0);break}}}finally{K=!1,H.current=ot,X(),Error.prepareStackTrace=Qe}var Vn=I?I.displayName||I.name:"",ne=Vn?$(Vn):"";return typeof I=="function"&&re.set(I,ne),ne}function Te(I,W,le){return se(I,!1)}function Ye(I){var W=I.prototype;return!!(W&&W.isReactComponent)}function Le(I,W,le){if(I==null)return"";if(typeof I=="function")return se(I,Ye(I));if(typeof I=="string")return $(I);switch(I){case c:return $("Suspense");case d:return $("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Te(I.render);case f:return Le(I.type,W,le);case p:{var Ie=I,Qe=Ie._payload,ot=Ie._init;try{return Le(ot(Qe),W,le)}catch{}}}return""}var Ge=Object.prototype.hasOwnProperty,de={},be=g.ReactDebugCurrentFrame;function ze(I){if(I){var W=I._owner,le=Le(I.type,I._source,W?W.type:null);be.setExtraStackFrame(le)}else be.setExtraStackFrame(null)}function Ue(I,W,le,Ie,Qe){{var ot=Function.call.bind(Ge);for(var Ve in I)if(ot(I,Ve)){var He=void 0;try{if(typeof I[Ve]!="function"){var _t=Error((Ie||"React class")+": "+le+" type `"+Ve+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ve]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _t.name="Invariant Violation",_t}He=I[Ve](W,Ve,Ie,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(bt){He=bt}He&&!(He instanceof Error)&&(ze(Qe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",le,Ve,typeof He),ze(null)),He instanceof Error&&!(He.message in de)&&(de[He.message]=!0,ze(Qe),b("Failed %s type: %s",le,He.message),ze(null))}}}var We=Array.isArray;function nt(I){return We(I)}function $e(I){{var W=typeof Symbol=="function"&&Symbol.toStringTag,le=W&&I[Symbol.toStringTag]||I.constructor.name||"Object";return le}}function Fe(I){try{return rt(I),!1}catch{return!0}}function rt(I){return""+I}function It(I){if(Fe(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",$e(I)),rt(I)}var dt=g.ReactCurrentOwner,ft={key:!0,ref:!0,__self:!0,__source:!0},pt,yt;function vt(I){if(Ge.call(I,"ref")){var W=Object.getOwnPropertyDescriptor(I,"ref").get;if(W&&W.isReactWarning)return!1}return I.ref!==void 0}function xt(I){if(Ge.call(I,"key")){var W=Object.getOwnPropertyDescriptor(I,"key").get;if(W&&W.isReactWarning)return!1}return I.key!==void 0}function Lt(I,W){typeof I.ref=="string"&&dt.current}function Be(I,W){{var le=function(){pt||(pt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};le.isReactWarning=!0,Object.defineProperty(I,"key",{get:le,configurable:!0})}}function hn(I,W){{var le=function(){yt||(yt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};le.isReactWarning=!0,Object.defineProperty(I,"ref",{get:le,configurable:!0})}}var st=function(I,W,le,Ie,Qe,ot,Ve){var He={$$typeof:t,type:I,key:W,ref:le,props:Ve,_owner:ot};return He._store={},Object.defineProperty(He._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(He,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(He,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Qe}),Object.freeze&&(Object.freeze(He.props),Object.freeze(He)),He};function Ze(I,W,le,Ie,Qe){{var ot,Ve={},He=null,_t=null;le!==void 0&&(It(le),He=""+le),xt(W)&&(It(W.key),He=""+W.key),vt(W)&&(_t=W.ref,Lt(W,Qe));for(ot in W)Ge.call(W,ot)&&!ft.hasOwnProperty(ot)&&(Ve[ot]=W[ot]);if(I&&I.defaultProps){var bt=I.defaultProps;for(ot in bt)Ve[ot]===void 0&&(Ve[ot]=bt[ot])}if(He||_t){var St=typeof I=="function"?I.displayName||I.name||"Unknown":I;He&&Be(Ve,St),_t&&hn(Ve,St)}return st(I,He,_t,Qe,Ie,dt.current,Ve)}}var wt=g.ReactCurrentOwner,Q=g.ReactDebugCurrentFrame;function te(I){if(I){var W=I._owner,le=Le(I.type,I._source,W?W.type:null);Q.setExtraStackFrame(le)}else Q.setExtraStackFrame(null)}var ve;ve=!1;function Ce(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function Oe(){{if(wt.current){var I=z(wt.current.type);if(I)return`
17
+ */var Za;function Xh(){return Za||(Za=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),x=Symbol.iterator,m="@@iterator";function v(I){if(I===null||typeof I!="object")return null;var W=x&&I[x]||I[m];return typeof W=="function"?W:null}var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var W=arguments.length,ae=new Array(W>1?W-1:0),Ee=1;Ee<W;Ee++)ae[Ee-1]=arguments[Ee];S("error",I,ae)}}function S(I,W,ae){{var Ee=g.ReactDebugCurrentFrame,et=Ee.getStackAddendum();et!==""&&(W+="%s",ae=ae.concat([et]));var it=ae.map(function(Ve){return String(Ve)});it.unshift("Warning: "+W),Function.prototype.apply.call(console[I],console,it)}}var k=!1,T=!1,C=!1,E=!1,N=!1,j;j=Symbol.for("react.module.reference");function L(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||N||I===o||I===c||I===d||E||I===h||k||T||C||typeof I=="object"&&I!==null&&(I.$$typeof===p||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===j||I.getModuleId!==void 0))}function _(I,W,ae){var Ee=I.displayName;if(Ee)return Ee;var et=W.displayName||W.name||"";return et!==""?ae+"("+et+")":ae}function M(I){return I.displayName||"Context"}function z(I){if(I==null)return null;if(typeof I.tag=="number"&&b("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 W=I;return M(W)+".Consumer";case i:var ae=I;return M(ae._context)+".Provider";case l:return _(I,I.render,"ForwardRef");case f:var Ee=I.displayName||null;return Ee!==null?Ee:z(I.type)||"Memo";case p:{var et=I,it=et._payload,Ve=et._init;try{return z(Ve(it))}catch{return null}}}return null}var A=Object.assign,F=0,R,G,B,D,V,Y,he;function ie(){}ie.__reactDisabledLog=!0;function Ae(){{if(F===0){R=console.log,G=console.info,B=console.warn,D=console.error,V=console.group,Y=console.groupCollapsed,he=console.groupEnd;var I={configurable:!0,enumerable:!0,value:ie,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}F++}}function X(){{if(F--,F===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},I,{value:R}),info:A({},I,{value:G}),warn:A({},I,{value:B}),error:A({},I,{value:D}),group:A({},I,{value:V}),groupCollapsed:A({},I,{value:Y}),groupEnd:A({},I,{value:he})})}F<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var H=g.ReactCurrentDispatcher,J;function $(I,W,ae){{if(J===void 0)try{throw Error()}catch(et){var Ee=et.stack.trim().match(/\n( *(at )?)/);J=Ee&&Ee[1]||""}return`
18
+ `+J+I}}var K=!1,re;{var oe=typeof WeakMap=="function"?WeakMap:Map;re=new oe}function se(I,W){if(!I||K)return"";{var ae=re.get(I);if(ae!==void 0)return ae}var Ee;K=!0;var et=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var it;it=H.current,H.current=null,Ae();try{if(W){var Ve=function(){throw Error()};if(Object.defineProperty(Ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ve,[])}catch(le){Ee=le}Reflect.construct(I,[],Ve)}else{try{Ve.call()}catch(le){Ee=le}I.call(Ve.prototype)}}else{try{throw Error()}catch(le){Ee=le}I()}}catch(le){if(le&&Ee&&typeof le.stack=="string"){for(var Be=le.stack.split(`
19
+ `),_t=Ee.stack.split(`
20
+ `),bt=Be.length-1,St=_t.length-1;bt>=1&&St>=0&&Be[bt]!==_t[St];)St--;for(;bt>=1&&St>=0;bt--,St--)if(Be[bt]!==_t[St]){if(bt!==1||St!==1)do if(bt--,St--,St<0||Be[bt]!==_t[St]){var Vt=`
21
+ `+Be[bt].replace(" at new "," at ");return I.displayName&&Vt.includes("<anonymous>")&&(Vt=Vt.replace("<anonymous>",I.displayName)),typeof I=="function"&&re.set(I,Vt),Vt}while(bt>=1&&St>=0);break}}}finally{K=!1,H.current=it,X(),Error.prepareStackTrace=et}var Wn=I?I.displayName||I.name:"",ne=Wn?$(Wn):"";return typeof I=="function"&&re.set(I,ne),ne}function Te(I,W,ae){return se(I,!1)}function Je(I){var W=I.prototype;return!!(W&&W.isReactComponent)}function De(I,W,ae){if(I==null)return"";if(typeof I=="function")return se(I,Je(I));if(typeof I=="string")return $(I);switch(I){case c:return $("Suspense");case d:return $("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Te(I.render);case f:return De(I.type,W,ae);case p:{var Ee=I,et=Ee._payload,it=Ee._init;try{return De(it(et),W,ae)}catch{}}}return""}var Ye=Object.prototype.hasOwnProperty,de={},be=g.ReactDebugCurrentFrame;function Fe(I){if(I){var W=I._owner,ae=De(I.type,I._source,W?W.type:null);be.setExtraStackFrame(ae)}else be.setExtraStackFrame(null)}function He(I,W,ae,Ee,et){{var it=Function.call.bind(Ye);for(var Ve in I)if(it(I,Ve)){var Be=void 0;try{if(typeof I[Ve]!="function"){var _t=Error((Ee||"React class")+": "+ae+" type `"+Ve+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[Ve]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _t.name="Invariant Violation",_t}Be=I[Ve](W,Ve,Ee,ae,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(bt){Be=bt}Be&&!(Be instanceof Error)&&(Fe(et),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",ae,Ve,typeof Be),Fe(null)),Be instanceof Error&&!(Be.message in de)&&(de[Be.message]=!0,Fe(et),b("Failed %s type: %s",ae,Be.message),Fe(null))}}}var Ue=Array.isArray;function rt(I){return Ue(I)}function Le(I){{var W=typeof Symbol=="function"&&Symbol.toStringTag,ae=W&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ae}}function $e(I){try{return ot(I),!1}catch{return!0}}function ot(I){return""+I}function It(I){if($e(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(I)),ot(I)}var st=g.ReactCurrentOwner,pt={key:!0,ref:!0,__self:!0,__source:!0},ht,vt;function xt(I){if(Ye.call(I,"ref")){var W=Object.getOwnPropertyDescriptor(I,"ref").get;if(W&&W.isReactWarning)return!1}return I.ref!==void 0}function yt(I){if(Ye.call(I,"key")){var W=Object.getOwnPropertyDescriptor(I,"key").get;if(W&&W.isReactWarning)return!1}return I.key!==void 0}function Lt(I,W){typeof I.ref=="string"&&st.current}function ze(I,W){{var ae=function(){ht||(ht=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};ae.isReactWarning=!0,Object.defineProperty(I,"key",{get:ae,configurable:!0})}}function hn(I,W){{var ae=function(){vt||(vt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};ae.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ae,configurable:!0})}}var at=function(I,W,ae,Ee,et,it,Ve){var Be={$$typeof:t,type:I,key:W,ref:ae,props:Ve,_owner:it};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:et}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function Qe(I,W,ae,Ee,et){{var it,Ve={},Be=null,_t=null;ae!==void 0&&(It(ae),Be=""+ae),yt(W)&&(It(W.key),Be=""+W.key),xt(W)&&(_t=W.ref,Lt(W,et));for(it in W)Ye.call(W,it)&&!pt.hasOwnProperty(it)&&(Ve[it]=W[it]);if(I&&I.defaultProps){var bt=I.defaultProps;for(it in bt)Ve[it]===void 0&&(Ve[it]=bt[it])}if(Be||_t){var St=typeof I=="function"?I.displayName||I.name||"Unknown":I;Be&&ze(Ve,St),_t&&hn(Ve,St)}return at(I,Be,_t,et,Ee,st.current,Ve)}}var wt=g.ReactCurrentOwner,Q=g.ReactDebugCurrentFrame;function te(I){if(I){var W=I._owner,ae=De(I.type,I._source,W?W.type:null);Q.setExtraStackFrame(ae)}else Q.setExtraStackFrame(null)}var ve;ve=!1;function Ce(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function Pe(){{if(wt.current){var I=z(wt.current.type);if(I)return`
22
22
 
23
- Check the render method of \``+I+"`."}return""}}function Xe(I){return""}var Nt={};function P(I){{var W=Oe();if(!W){var le=typeof I=="string"?I:I.displayName||I.name;le&&(W=`
23
+ Check the render method of \``+I+"`."}return""}}function Ge(I){return""}var Nt={};function P(I){{var W=Pe();if(!W){var ae=typeof I=="string"?I:I.displayName||I.name;ae&&(W=`
24
24
 
25
- Check the top-level render call using <`+le+">.")}return W}}function ue(I,W){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var le=P(W);if(Nt[le])return;Nt[le]=!0;var Ie="";I&&I._owner&&I._owner!==wt.current&&(Ie=" It was passed a child from "+z(I._owner.type)+"."),te(I),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',le,Ie),te(null)}}function q(I,W){{if(typeof I!="object")return;if(nt(I))for(var le=0;le<I.length;le++){var Ie=I[le];Ce(Ie)&&ue(Ie,W)}else if(Ce(I))I._store&&(I._store.validated=!0);else if(I){var Qe=v(I);if(typeof Qe=="function"&&Qe!==I.entries)for(var ot=Qe.call(I),Ve;!(Ve=ot.next()).done;)Ce(Ve.value)&&ue(Ve.value,W)}}}function we(I){{var W=I.type;if(W==null||typeof W=="string")return;var le;if(typeof W=="function")le=W.propTypes;else if(typeof W=="object"&&(W.$$typeof===l||W.$$typeof===f))le=W.propTypes;else return;if(le){var Ie=z(W);Ue(le,I.props,"prop",Ie,I)}else if(W.PropTypes!==void 0&&!ve){ve=!0;var Qe=z(W);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Qe||"Unknown")}typeof W.getDefaultProps=="function"&&!W.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kt(I){{for(var W=Object.keys(I.props),le=0;le<W.length;le++){var Ie=W[le];if(Ie!=="children"&&Ie!=="key"){te(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),te(null);break}}I.ref!==null&&(te(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}}var Wt={};function Ar(I,W,le,Ie,Qe,ot){{var Ve=L(I);if(!Ve){var He="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(He+=" 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 _t=Xe();_t?He+=_t:He+=Oe();var bt;I===null?bt="null":nt(I)?bt="array":I!==void 0&&I.$$typeof===t?(bt="<"+(z(I.type)||"Unknown")+" />",He=" Did you accidentally export a JSX literal instead of a component?"):bt=typeof I,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",bt,He)}var St=Ze(I,W,le,Qe,ot);if(St==null)return St;if(Ve){var Vt=W.children;if(Vt!==void 0)if(Ie)if(nt(Vt)){for(var Vn=0;Vn<Vt.length;Vn++)q(Vt[Vn],I);Object.freeze&&Object.freeze(Vt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else q(Vt,I)}if(Ge.call(W,"key")){var ne=z(I),ie=Object.keys(W).filter(function(lt){return lt!=="key"}),xe=ie.length>0?"{key: someKey, "+ie.join(": ..., ")+": ...}":"{key: someKey}";if(!Wt[ne+xe]){var ke=ie.length>0?"{"+ie.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+ae+">.")}return W}}function ue(I,W){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ae=P(W);if(Nt[ae])return;Nt[ae]=!0;var Ee="";I&&I._owner&&I._owner!==wt.current&&(Ee=" It was passed a child from "+z(I._owner.type)+"."),te(I),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ae,Ee),te(null)}}function q(I,W){{if(typeof I!="object")return;if(rt(I))for(var ae=0;ae<I.length;ae++){var Ee=I[ae];Ce(Ee)&&ue(Ee,W)}else if(Ce(I))I._store&&(I._store.validated=!0);else if(I){var et=v(I);if(typeof et=="function"&&et!==I.entries)for(var it=et.call(I),Ve;!(Ve=it.next()).done;)Ce(Ve.value)&&ue(Ve.value,W)}}}function we(I){{var W=I.type;if(W==null||typeof W=="string")return;var ae;if(typeof W=="function")ae=W.propTypes;else if(typeof W=="object"&&(W.$$typeof===l||W.$$typeof===f))ae=W.propTypes;else return;if(ae){var Ee=z(W);He(ae,I.props,"prop",Ee,I)}else if(W.PropTypes!==void 0&&!ve){ve=!0;var et=z(W);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",et||"Unknown")}typeof W.getDefaultProps=="function"&&!W.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kt(I){{for(var W=Object.keys(I.props),ae=0;ae<W.length;ae++){var Ee=W[ae];if(Ee!=="children"&&Ee!=="key"){te(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),te(null);break}}I.ref!==null&&(te(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}}var Wt={};function Nr(I,W,ae,Ee,et,it){{var Ve=L(I);if(!Ve){var Be="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Be+=" 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 _t=Ge();_t?Be+=_t:Be+=Pe();var bt;I===null?bt="null":rt(I)?bt="array":I!==void 0&&I.$$typeof===t?(bt="<"+(z(I.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):bt=typeof I,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",bt,Be)}var St=Qe(I,W,ae,et,it);if(St==null)return St;if(Ve){var Vt=W.children;if(Vt!==void 0)if(Ee)if(rt(Vt)){for(var Wn=0;Wn<Vt.length;Wn++)q(Vt[Wn],I);Object.freeze&&Object.freeze(Vt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else q(Vt,I)}if(Ye.call(W,"key")){var ne=z(I),le=Object.keys(W).filter(function(Xe){return Xe!=="key"}),ge=le.length>0?"{key: someKey, "+le.join(": ..., ")+": ...}":"{key: someKey}";if(!Wt[ne+ge]){var We=le.length>0?"{"+le.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,xe,ne,ke,ne),Wt[ne+xe]=!0}}return I===r?kt(St):we(St),St}}function qs(I,W,le){return Ar(I,W,le,!0)}function qa(I,W,le){return Ar(I,W,le,!1)}var Ga=qa,Ya=qs;Rr.Fragment=r,Rr.jsx=Ga,Rr.jsxs=Ya}()),Rr}process.env.NODE_ENV==="production"?Xs.exports=Gh():Xs.exports=Yh();var u=Xs.exports;function Qa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Xh}=Object.prototype,{getPrototypeOf:Js}=Object,{iterator:go,toStringTag:el}=Symbol,xo=(e=>t=>{const n=Xh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>xo(t)===e),yo=e=>t=>typeof t===e,{isArray:cr}=Array,ur=yo("undefined");function Pr(e){return e!==null&&!ur(e)&&e.constructor!==null&&!ur(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const tl=an("ArrayBuffer");function Jh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&tl(e.buffer),t}const Zh=yo("string"),Bt=yo("function"),nl=yo("number"),Or=e=>e!==null&&typeof e=="object",Qh=e=>e===!0||e===!1,vo=e=>{if(xo(e)!=="object")return!1;const t=Js(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(el in e)&&!(go in e)},em=e=>{if(!Or(e)||Pr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},tm=an("Date"),nm=an("File"),rm=an("Blob"),om=an("FileList"),sm=e=>Or(e)&&Bt(e.pipe),im=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=xo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},am=an("URLSearchParams"),[lm,cm,um,dm]=["ReadableStream","Request","Response","Headers"].map(an),fm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Mr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),cr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Pr(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 rl(e,t){if(Pr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const qn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ol=e=>!ur(e)&&e!==qn;function Zs(){const{caseless:e,skipUndefined:t}=ol(this)&&this||{},n={},r=(o,s)=>{const i=e&&rl(n,s)||s;vo(n[i])&&vo(o)?n[i]=Zs(n[i],o):vo(o)?n[i]=Zs({},o):cr(o)?n[i]=o.slice():(!t||!ur(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Mr(arguments[o],r);return n}const pm=(e,t,n,{allOwnKeys:r}={})=>(Mr(t,(o,s)=>{n&&Bt(o)?e[s]=Qa(o,n):e[s]=o},{allOwnKeys:r}),e),hm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),mm=(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)},gm=(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&&Js(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},xm=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},ym=e=>{if(!e)return null;if(cr(e))return e;let t=e.length;if(!nl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},vm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Js(Uint8Array)),bm=(e,t)=>{const r=(e&&e[go]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},wm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Sm=an("HTMLFormElement"),Cm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),sl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Tm=an("RegExp"),il=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Mr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},km=e=>{il(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(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+"'")})}})},Em=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return cr(e)?r(e):r(String(e).split(t)),n},Im=()=>{},Nm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Am(e){return!!(e&&Bt(e.append)&&e[el]==="FormData"&&e[go])}const _m=e=>{const t=new Array(10),n=(r,o)=>{if(Or(r)){if(t.indexOf(r)>=0)return;if(Pr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=cr(r)?[]:{};return Mr(r,(i,a)=>{const l=n(i,o+1);!ur(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},jm=an("AsyncFunction"),Rm=e=>e&&(Or(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),al=((e,t)=>e?setImmediate:t?((n,r)=>(qn.addEventListener("message",({source:o,data:s})=>{o===qn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),qn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Bt(qn.postMessage)),Pm=typeof queueMicrotask<"u"?queueMicrotask.bind(qn):typeof process<"u"&&process.nextTick||al,O={isArray:cr,isArrayBuffer:tl,isBuffer:Pr,isFormData:im,isArrayBufferView:Jh,isString:Zh,isNumber:nl,isBoolean:Qh,isObject:Or,isPlainObject:vo,isEmptyObject:em,isReadableStream:lm,isRequest:cm,isResponse:um,isHeaders:dm,isUndefined:ur,isDate:tm,isFile:nm,isBlob:rm,isRegExp:Tm,isFunction:Bt,isStream:sm,isURLSearchParams:am,isTypedArray:vm,isFileList:om,forEach:Mr,merge:Zs,extend:pm,trim:fm,stripBOM:hm,inherits:mm,toFlatObject:gm,kindOf:xo,kindOfTest:an,endsWith:xm,toArray:ym,forEachEntry:bm,matchAll:wm,isHTMLForm:Sm,hasOwnProperty:sl,hasOwnProp:sl,reduceDescriptors:il,freezeMethods:km,toObjectSet:Em,toCamelCase:Cm,noop:Im,toFiniteNumber:Nm,findKey:rl,global:qn,isContextDefined:ol,isSpecCompliantForm:Am,toJSONObject:_m,isAsyncFn:jm,isThenable:Rm,setImmediate:al,asap:Pm,isIterable:e=>e!=null&&Bt(e[go])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const ll=Pe.prototype,cl={};["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=>{cl[e]={value:e}}),Object.defineProperties(Pe,cl),Object.defineProperty(ll,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(ll);O.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Om=null;function Qs(e){return O.isPlainObject(e)||O.isArray(e)}function ul(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function dl(e,t,n){return e?e.concat(t).map(function(o,s){return o=ul(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Mm(e){return O.isArray(e)&&!e.some(Qs)}const Dm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function bo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,v){return!O.isUndefined(v[m])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function c(x){if(x===null)return"";if(O.isDate(x))return x.toISOString();if(O.isBoolean(x))return x.toString();if(!l&&O.isBlob(x))throw new Pe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(x)||O.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,m,v){let g=x;if(x&&!v&&typeof x=="object"){if(O.endsWith(m,"{}"))m=r?m:m.slice(0,-2),x=JSON.stringify(x);else if(O.isArray(x)&&Mm(x)||(O.isFileList(x)||O.endsWith(m,"[]"))&&(g=O.toArray(x)))return m=ul(m),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?dl([m],k,s):i===null?m:m+"[]",c(S))}),!1}return Qs(x)?!0:(t.append(dl(v,m,s),c(x)),!1)}const f=[],p=Object.assign(Dm,{defaultVisitor:d,convertValue:c,isVisitable:Qs});function h(x,m){if(!O.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(x),O.forEach(x,function(g,b){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(b)?b.trim():b,m,p))===!0&&h(g,m?m.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return h(e),t}function fl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ei(e,t){this._pairs=[],e&&bo(e,this,t)}const pl=ei.prototype;pl.append=function(t,n){this._pairs.push([t,n])},pl.toString=function(t){const n=t?function(r){return t.call(this,r,fl)}:fl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Lm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hl(e,t,n){if(!t)return e;const r=n&&n.encode||Lm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new ei(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class ml{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){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const gl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},$m={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ei,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ti=typeof window<"u"&&typeof document<"u",ni=typeof navigator=="object"&&navigator||void 0,Fm=ti&&(!ni||["ReactNative","NativeScript","NS"].indexOf(ni.product)<0),zm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Bm=ti&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ti,hasStandardBrowserEnv:Fm,hasStandardBrowserWebWorkerEnv:zm,navigator:ni,origin:Bm},Symbol.toStringTag,{value:"Module"})),...$m};function Hm(e,t){return bo(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Um(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Wm(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 xl(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&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Wm(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Um(r),o,n,0)}),n}return null}function Vm(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Dr={transitional:gl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(xl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.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 Hm(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Vm(t)):t}],transformResponse:[function(t){const n=this.transitional||Dr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pt.classes.FormData,Blob:Pt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Dr.headers[e]={}});const Km=O.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"]),qm=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Km[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},yl=Symbol("internals");function Lr(e){return e&&String(e).trim().toLowerCase()}function wo(e){return e===!1||e==null?e:O.isArray(e)?e.map(wo):String(e)}function Gm(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 Ym=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ri(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Xm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Jm(e,t){const n=O.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 Ht=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Lr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=wo(a))}const i=(a,l)=>O.forEach(a,(c,d)=>s(c,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Ym(t))i(qm(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,c;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?O.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=Lr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Gm(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Lr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ri(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Lr(i),i){const a=O.findKey(r,i);a&&(!n||ri(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.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||ri(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=wo(o),delete n[s];return}const a=t?Xm(s):String(s).trim();a!==s&&delete n[s],n[a]=wo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.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[yl]=this[yl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Lr(i);r[a]||(Jm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ht);function oi(e,t){const n=this||Dr,r=t||n,o=Ht.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function vl(e){return!!(e&&e.__CANCEL__)}function dr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(dr,Pe,{__CANCEL__:!0});function bl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Zm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Qm(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 eg(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 So=(e,t,n=3)=>{let r=0;const o=Qm(50,250);return eg(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)},wl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Sl=e=>(...t)=>O.asap(()=>e(...t)),tg=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,ng=Pt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.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 rg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function og(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Cl(e,t,n){let r=!rg(t);return e&&(r||n==!1)?og(e,t):t}const Tl=e=>e instanceof Ht?{...e}:e;function Gn(e,t){t=t||{};const n={};function r(c,d,f,p){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:p},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,p){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}function s(c,d){if(!O.isUndefined(d))return r(void 0,d)}function i(c,d){if(O.isUndefined(d)){if(!O.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(Tl(c),Tl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,p=f(e[d],t[d],d);O.isUndefined(p)&&f!==a||(n[d]=p)}),n}const kl=e=>{const t=Gn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ht.from(i),t.url=hl(Cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.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(Pt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&tg(t.url))){const l=o&&s&&ng.read(s);l&&i.set(o,l)}return t},sg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=kl(e);let s=o.data;const i=Ht.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,p,h,x;function m(){h&&h(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let v=new XMLHttpRequest;v.open(o.method.toUpperCase(),o.url,!0),v.timeout=o.timeout;function g(){if(!v)return;const S=Ht.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:S,config:e,request:v};bl(function(E){n(E),m()},function(E){r(E),m()},T),v=null}"onloadend"in v?v.onloadend=g:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(g)},v.onabort=function(){v&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,v)),v=null)},v.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Pe(T,Pe.ERR_NETWORK,e,v);C.event=k||null,r(C),v=null},v.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||gl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,v)),v=null},s===void 0&&i.setContentType(null),"setRequestHeader"in v&&O.forEach(i.toJSON(),function(k,T){v.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(v.withCredentials=!!o.withCredentials),a&&a!=="json"&&(v.responseType=o.responseType),c&&([p,x]=So(c,!0),v.addEventListener("progress",p)),l&&v.upload&&([f,h]=So(l),v.upload.addEventListener("progress",f),v.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{v&&(r(!S||S.type?new dr(null,e,v):S),v.abort(),v=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Zm(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}v.send(s||null)})},ig=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new dr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>O.asap(a),l}},ag=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},lg=async function*(e,t){for await(const n of cg(e))yield*ag(n,t)},cg=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()}},El=(e,t,n,r)=>{const o=lg(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})},Il=64*1024,{isFunction:Co}=O,ug=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:Nl,TextEncoder:Al}=O.global,_l=(e,...t)=>{try{return!!e(...t)}catch{return!1}},dg=e=>{e=O.merge.call({skipUndefined:!0},ug,e);const{fetch:t,Request:n,Response:r}=e,o=t?Co(t):typeof fetch=="function",s=Co(n),i=Co(r);if(!o)return!1;const a=o&&Co(Nl),l=o&&(typeof Al=="function"?(x=>m=>x.encode(m))(new Al):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&_l(()=>{let x=!1;const m=new n(Pt.origin,{body:new Nl,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!m}),d=i&&a&&_l(()=>O.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(m,v)=>{let g=m&&m[x];if(g)return g.call(m);throw new Pe(`Response type '${x}' is not supported`,Pe.ERR_NOT_SUPPORT,v)})});const p=async x=>{if(x==null)return 0;if(O.isBlob(x))return x.size;if(O.isSpecCompliantForm(x))return(await new n(Pt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(O.isArrayBufferView(x)||O.isArrayBuffer(x))return x.byteLength;if(O.isURLSearchParams(x)&&(x=x+""),O.isString(x))return(await l(x)).byteLength},h=async(x,m)=>{const v=O.toFiniteNumber(x.getContentLength());return v??p(m)};return async x=>{let{url:m,method:v,data:g,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:_="same-origin",fetchOptions:L}=kl(x),j=t||fetch;E=E?(E+"").toLowerCase():"text";let M=ig([b,S&&S.toAbortSignal()],k),z=null;const A=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let F;try{if(C&&c&&v!=="get"&&v!=="head"&&(F=await h(N,g))!==0){let Y=new n(m,{method:"POST",body:g,duplex:"half"}),he;if(O.isFormData(g)&&(he=Y.headers.get("content-type"))&&N.setContentType(he),Y.body){const[ae,_e]=wl(F,So(Sl(C)));g=El(Y.body,Il,ae,_e)}}O.isString(_)||(_=_?"include":"omit");const R=s&&"credentials"in n.prototype,G={...L,signal:M,method:v.toUpperCase(),headers:N.normalize().toJSON(),body:g,duplex:"half",credentials:R?_:void 0};z=s&&new n(m,G);let B=await(s?j(z,L):j(m,G));const D=d&&(E==="stream"||E==="response");if(d&&(T||D&&A)){const Y={};["status","statusText","headers"].forEach(X=>{Y[X]=B[X]});const he=O.toFiniteNumber(B.headers.get("content-length")),[ae,_e]=T&&wl(he,So(Sl(T),!0))||[];B=new r(El(B.body,Il,ae,()=>{_e&&_e(),A&&A()}),Y)}E=E||"text";let V=await f[O.findKey(f,E)||"text"](B,x);return!D&&A&&A(),await new Promise((Y,he)=>{bl(Y,he,{data:V,headers:Ht.from(B.headers),status:B.status,statusText:B.statusText,config:x,request:z})})}catch(R){throw A&&A(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,x,z),{cause:R.cause||R}):Pe.from(R,R&&R.code,x,z)}}},fg=new Map,jl=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=fg;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:dg(t)),d=c;return c};jl();const si={http:Om,xhr:sg,fetch:{get:jl}};O.forEach(si,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Rl=e=>`- ${e}`,pg=e=>O.isFunction(e)||e===null||e===!1,Pl={getAdapter:(e,t)=>{e=O.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,!pg(r)&&(o=si[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
30
+ <%s key={someKey} {...props} />`,ge,ne,We,ne),Wt[ne+ge]=!0}}return I===r?kt(St):we(St),St}}function qs(I,W,ae){return Nr(I,W,ae,!0)}function qa(I,W,ae){return Nr(I,W,ae,!1)}var Ga=qa,Ya=qs;jr.Fragment=r,jr.jsx=Ga,jr.jsxs=Ya}()),jr}process.env.NODE_ENV==="production"?Xs.exports=Yh():Xs.exports=Xh();var u=Xs.exports;function Qa(e,t){return function(){return e.apply(t,arguments)}}const{toString:Jh}=Object.prototype,{getPrototypeOf:Js}=Object,{iterator:go,toStringTag:el}=Symbol,xo=(e=>t=>{const n=Jh.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>xo(t)===e),yo=e=>t=>typeof t===e,{isArray:lr}=Array,cr=yo("undefined");function Rr(e){return e!==null&&!cr(e)&&e.constructor!==null&&!cr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const tl=an("ArrayBuffer");function Zh(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&tl(e.buffer),t}const Qh=yo("string"),Bt=yo("function"),nl=yo("number"),Pr=e=>e!==null&&typeof e=="object",em=e=>e===!0||e===!1,vo=e=>{if(xo(e)!=="object")return!1;const t=Js(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(el in e)&&!(go in e)},tm=e=>{if(!Pr(e)||Rr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},nm=an("Date"),rm=an("File"),om=an("Blob"),sm=an("FileList"),im=e=>Pr(e)&&Bt(e.pipe),am=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=xo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},lm=an("URLSearchParams"),[cm,um,dm,fm]=["ReadableStream","Request","Response","Headers"].map(an),pm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Or(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),lr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Rr(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 rl(e,t){if(Rr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Kn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ol=e=>!cr(e)&&e!==Kn;function Zs(){const{caseless:e,skipUndefined:t}=ol(this)&&this||{},n={},r=(o,s)=>{const i=e&&rl(n,s)||s;vo(n[i])&&vo(o)?n[i]=Zs(n[i],o):vo(o)?n[i]=Zs({},o):lr(o)?n[i]=o.slice():(!t||!cr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Or(arguments[o],r);return n}const hm=(e,t,n,{allOwnKeys:r}={})=>(Or(t,(o,s)=>{n&&Bt(o)?e[s]=Qa(o,n):e[s]=o},{allOwnKeys:r}),e),mm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gm=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},xm=(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&&Js(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ym=(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},vm=e=>{if(!e)return null;if(lr(e))return e;let t=e.length;if(!nl(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"&&Js(Uint8Array)),wm=(e,t)=>{const r=(e&&e[go]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Sm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Cm=an("HTMLFormElement"),Tm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),sl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),km=an("RegExp"),il=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Or(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Em=e=>{il(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(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+"'")})}})},Im=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return lr(e)?r(e):r(String(e).split(t)),n},Nm=()=>{},Am=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function _m(e){return!!(e&&Bt(e.append)&&e[el]==="FormData"&&e[go])}const jm=e=>{const t=new Array(10),n=(r,o)=>{if(Pr(r)){if(t.indexOf(r)>=0)return;if(Rr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=lr(r)?[]:{};return Or(r,(i,a)=>{const l=n(i,o+1);!cr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Rm=an("AsyncFunction"),Pm=e=>e&&(Pr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),al=((e,t)=>e?setImmediate:t?((n,r)=>(Kn.addEventListener("message",({source:o,data:s})=>{o===Kn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Kn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Bt(Kn.postMessage)),Om=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||al,O={isArray:lr,isArrayBuffer:tl,isBuffer:Rr,isFormData:am,isArrayBufferView:Zh,isString:Qh,isNumber:nl,isBoolean:em,isObject:Pr,isPlainObject:vo,isEmptyObject:tm,isReadableStream:cm,isRequest:um,isResponse:dm,isHeaders:fm,isUndefined:cr,isDate:nm,isFile:rm,isBlob:om,isRegExp:km,isFunction:Bt,isStream:im,isURLSearchParams:lm,isTypedArray:bm,isFileList:sm,forEach:Or,merge:Zs,extend:hm,trim:pm,stripBOM:mm,inherits:gm,toFlatObject:xm,kindOf:xo,kindOfTest:an,endsWith:ym,toArray:vm,forEachEntry:wm,matchAll:Sm,isHTMLForm:Cm,hasOwnProperty:sl,hasOwnProp:sl,reduceDescriptors:il,freezeMethods:Em,toObjectSet:Im,toCamelCase:Tm,noop:Nm,toFiniteNumber:Am,findKey:rl,global:Kn,isContextDefined:ol,isSpecCompliantForm:_m,toJSONObject:jm,isAsyncFn:Rm,isThenable:Pm,setImmediate:al,asap:Om,isIterable:e=>e!=null&&Bt(e[go])};function Re(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const ll=Re.prototype,cl={};["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=>{cl[e]={value:e}}),Object.defineProperties(Re,cl),Object.defineProperty(ll,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(ll);O.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Re.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Mm=null;function Qs(e){return O.isPlainObject(e)||O.isArray(e)}function ul(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function dl(e,t,n){return e?e.concat(t).map(function(o,s){return o=ul(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Dm(e){return O.isArray(e)&&!e.some(Qs)}const Lm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function bo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,v){return!O.isUndefined(v[m])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function c(x){if(x===null)return"";if(O.isDate(x))return x.toISOString();if(O.isBoolean(x))return x.toString();if(!l&&O.isBlob(x))throw new Re("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(x)||O.isTypedArray(x)?l&&typeof Blob=="function"?new Blob([x]):Buffer.from(x):x}function d(x,m,v){let g=x;if(x&&!v&&typeof x=="object"){if(O.endsWith(m,"{}"))m=r?m:m.slice(0,-2),x=JSON.stringify(x);else if(O.isArray(x)&&Dm(x)||(O.isFileList(x)||O.endsWith(m,"[]"))&&(g=O.toArray(x)))return m=ul(m),g.forEach(function(S,k){!(O.isUndefined(S)||S===null)&&t.append(i===!0?dl([m],k,s):i===null?m:m+"[]",c(S))}),!1}return Qs(x)?!0:(t.append(dl(v,m,s),c(x)),!1)}const f=[],p=Object.assign(Lm,{defaultVisitor:d,convertValue:c,isVisitable:Qs});function h(x,m){if(!O.isUndefined(x)){if(f.indexOf(x)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(x),O.forEach(x,function(g,b){(!(O.isUndefined(g)||g===null)&&o.call(t,g,O.isString(b)?b.trim():b,m,p))===!0&&h(g,m?m.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return h(e),t}function fl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ei(e,t){this._pairs=[],e&&bo(e,this,t)}const pl=ei.prototype;pl.append=function(t,n){this._pairs.push([t,n])},pl.toString=function(t){const n=t?function(r){return t.call(this,r,fl)}:fl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function $m(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function hl(e,t,n){if(!t)return e;const r=n&&n.encode||$m;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new ei(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class ml{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){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const gl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Fm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ei,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ti=typeof window<"u"&&typeof document<"u",ni=typeof navigator=="object"&&navigator||void 0,zm=ti&&(!ni||["ReactNative","NativeScript","NS"].indexOf(ni.product)<0),Bm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Hm=ti&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ti,hasStandardBrowserEnv:zm,hasStandardBrowserWebWorkerEnv:Bm,navigator:ni,origin:Hm},Symbol.toStringTag,{value:"Module"})),...Fm};function Um(e,t){return bo(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Wm(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Vm(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 xl(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&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Vm(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Wm(r),o,n,0)}),n}return null}function Km(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Mr={transitional:gl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(xl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.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 Um(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return bo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Km(t)):t}],transformResponse:[function(t){const n=this.transitional||Mr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Re.from(a,Re.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pt.classes.FormData,Blob:Pt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Mr.headers[e]={}});const qm=O.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"]),Gm=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&qm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},yl=Symbol("internals");function Dr(e){return e&&String(e).trim().toLowerCase()}function wo(e){return e===!1||e==null?e:O.isArray(e)?e.map(wo):String(e)}function Ym(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 Xm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ri(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Jm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Zm(e,t){const n=O.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 Ht=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Dr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=wo(a))}const i=(a,l)=>O.forEach(a,(c,d)=>s(c,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Xm(t))i(Gm(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,c;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?O.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=Dr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Ym(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Dr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ri(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Dr(i),i){const a=O.findKey(r,i);a&&(!n||ri(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.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||ri(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=wo(o),delete n[s];return}const a=t?Jm(s):String(s).trim();a!==s&&delete n[s],n[a]=wo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.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[yl]=this[yl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Dr(i);r[a]||(Zm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};Ht.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(Ht.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(Ht);function oi(e,t){const n=this||Mr,r=t||n,o=Ht.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function vl(e){return!!(e&&e.__CANCEL__)}function ur(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(ur,Re,{__CANCEL__:!0});function bl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Qm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function eg(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 tg(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 So=(e,t,n=3)=>{let r=0;const o=eg(50,250);return tg(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)},wl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Sl=e=>(...t)=>O.asap(()=>e(...t)),ng=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,rg=Pt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.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 og(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Cl(e,t,n){let r=!og(t);return e&&(r||n==!1)?sg(e,t):t}const Tl=e=>e instanceof Ht?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,f,p){return O.isPlainObject(c)&&O.isPlainObject(d)?O.merge.call({caseless:p},c,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(c,d,f,p){if(O.isUndefined(d)){if(!O.isUndefined(c))return r(void 0,c,f,p)}else return r(c,d,f,p)}function s(c,d){if(!O.isUndefined(d))return r(void 0,d)}function i(c,d){if(O.isUndefined(d)){if(!O.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(Tl(c),Tl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,p=f(e[d],t[d],d);O.isUndefined(p)&&f!==a||(n[d]=p)}),n}const kl=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ht.from(i),t.url=hl(Cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.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(Pt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&ng(t.url))){const l=o&&s&&rg.read(s);l&&i.set(o,l)}return t},ig=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=kl(e);let s=o.data;const i=Ht.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,p,h,x;function m(){h&&h(),x&&x(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let v=new XMLHttpRequest;v.open(o.method.toUpperCase(),o.url,!0),v.timeout=o.timeout;function g(){if(!v)return;const S=Ht.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:S,config:e,request:v};bl(function(E){n(E),m()},function(E){r(E),m()},T),v=null}"onloadend"in v?v.onloadend=g:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(g)},v.onabort=function(){v&&(r(new Re("Request aborted",Re.ECONNABORTED,e,v)),v=null)},v.onerror=function(k){const T=k&&k.message?k.message:"Network Error",C=new Re(T,Re.ERR_NETWORK,e,v);C.event=k||null,r(C),v=null},v.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||gl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Re(k,T.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,v)),v=null},s===void 0&&i.setContentType(null),"setRequestHeader"in v&&O.forEach(i.toJSON(),function(k,T){v.setRequestHeader(T,k)}),O.isUndefined(o.withCredentials)||(v.withCredentials=!!o.withCredentials),a&&a!=="json"&&(v.responseType=o.responseType),c&&([p,x]=So(c,!0),v.addEventListener("progress",p)),l&&v.upload&&([f,h]=So(l),v.upload.addEventListener("progress",f),v.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{v&&(r(!S||S.type?new ur(null,e,v):S),v.abort(),v=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Qm(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}v.send(s||null)})},ag=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Re?d:new ur(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>O.asap(a),l}},lg=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},cg=async function*(e,t){for await(const n of ug(e))yield*lg(n,t)},ug=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()}},El=(e,t,n,r)=>{const o=cg(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})},Il=64*1024,{isFunction:Co}=O,dg=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:Nl,TextEncoder:Al}=O.global,_l=(e,...t)=>{try{return!!e(...t)}catch{return!1}},fg=e=>{e=O.merge.call({skipUndefined:!0},dg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Co(t):typeof fetch=="function",s=Co(n),i=Co(r);if(!o)return!1;const a=o&&Co(Nl),l=o&&(typeof Al=="function"?(x=>m=>x.encode(m))(new Al):async x=>new Uint8Array(await new n(x).arrayBuffer())),c=s&&a&&_l(()=>{let x=!1;const m=new n(Pt.origin,{body:new Nl,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!m}),d=i&&a&&_l(()=>O.isReadableStream(new r("").body)),f={stream:d&&(x=>x.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!f[x]&&(f[x]=(m,v)=>{let g=m&&m[x];if(g)return g.call(m);throw new Re(`Response type '${x}' is not supported`,Re.ERR_NOT_SUPPORT,v)})});const p=async x=>{if(x==null)return 0;if(O.isBlob(x))return x.size;if(O.isSpecCompliantForm(x))return(await new n(Pt.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(O.isArrayBufferView(x)||O.isArrayBuffer(x))return x.byteLength;if(O.isURLSearchParams(x)&&(x=x+""),O.isString(x))return(await l(x)).byteLength},h=async(x,m)=>{const v=O.toFiniteNumber(x.getContentLength());return v??p(m)};return async x=>{let{url:m,method:v,data:g,signal:b,cancelToken:S,timeout:k,onDownloadProgress:T,onUploadProgress:C,responseType:E,headers:N,withCredentials:j="same-origin",fetchOptions:L}=kl(x),_=t||fetch;E=E?(E+"").toLowerCase():"text";let M=ag([b,S&&S.toAbortSignal()],k),z=null;const A=M&&M.unsubscribe&&(()=>{M.unsubscribe()});let F;try{if(C&&c&&v!=="get"&&v!=="head"&&(F=await h(N,g))!==0){let Y=new n(m,{method:"POST",body:g,duplex:"half"}),he;if(O.isFormData(g)&&(he=Y.headers.get("content-type"))&&N.setContentType(he),Y.body){const[ie,Ae]=wl(F,So(Sl(C)));g=El(Y.body,Il,ie,Ae)}}O.isString(j)||(j=j?"include":"omit");const R=s&&"credentials"in n.prototype,G={...L,signal:M,method:v.toUpperCase(),headers:N.normalize().toJSON(),body:g,duplex:"half",credentials:R?j:void 0};z=s&&new n(m,G);let B=await(s?_(z,L):_(m,G));const D=d&&(E==="stream"||E==="response");if(d&&(T||D&&A)){const Y={};["status","statusText","headers"].forEach(X=>{Y[X]=B[X]});const he=O.toFiniteNumber(B.headers.get("content-length")),[ie,Ae]=T&&wl(he,So(Sl(T),!0))||[];B=new r(El(B.body,Il,ie,()=>{Ae&&Ae(),A&&A()}),Y)}E=E||"text";let V=await f[O.findKey(f,E)||"text"](B,x);return!D&&A&&A(),await new Promise((Y,he)=>{bl(Y,he,{data:V,headers:Ht.from(B.headers),status:B.status,statusText:B.statusText,config:x,request:z})})}catch(R){throw A&&A(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,x,z),{cause:R.cause||R}):Re.from(R,R&&R.code,x,z)}}},pg=new Map,jl=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:fg(t)),d=c;return c};jl();const si={http:Mm,xhr:ig,fetch:{get:jl}};O.forEach(si,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Rl=e=>`- ${e}`,hg=e=>O.isFunction(e)||e===null||e===!1,Pl={getAdapter:(e,t)=>{e=O.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,!hg(r)&&(o=si[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(O.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(Rl).join(`
34
- `):" "+Rl(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:si};function ii(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new dr(null,e)}function Ol(e){return ii(e),e.headers=Ht.from(e.headers),e.data=oi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Pl.getAdapter(e.adapter||Dr.adapter,e)(e).then(function(r){return ii(e),r.data=oi.call(e,e.transformResponse,r),r.headers=Ht.from(r.headers),r},function(r){return vl(r)||(ii(e),r&&r.response&&(r.response.data=oi.call(e,e.transformResponse,r.response),r.response.headers=Ht.from(r.response.headers))),Promise.reject(r)})}const Ml="1.12.2",To={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{To[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Dl={};To.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Ml+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Dl[i]&&(Dl[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}},To.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function hg(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const ko={assertOptions:hg,validators:To},mn=ko.validators;let Yn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ml,response:new ml}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Gn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ko.assertOptions(r,{silentJSONParsing:mn.transitional(mn.boolean),forcedJSONParsing:mn.transitional(mn.boolean),clarifyTimeoutError:mn.transitional(mn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:ko.assertOptions(o,{encode:mn.function,serialize:mn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ko.assertOptions(n,{baseUrl:mn.spelling("baseURL"),withXsrfToken:mn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Ht.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let d,f=0,p;if(!l){const x=[Ol.bind(this),void 0];for(x.unshift(...a),x.push(...c),p=x.length,d=Promise.resolve(n);f<p;)d=d.then(x[f++],x[f++]);return d}p=a.length;let h=n;for(;f<p;){const x=a[f++],m=a[f++];try{h=x(h)}catch(v){m.call(this,v);break}}try{d=Ol.call(this,h)}catch(x){return Promise.reject(x)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Gn(this.defaults,t);const n=Cl(t.baseURL,t.url,t.allowAbsoluteUrls);return hl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Yn.prototype[t]=function(n,r){return this.request(Gn(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Gn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Yn.prototype[t]=n(),Yn.prototype[t+"Form"]=n(!0)});let mg=class Vh{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 dr(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 Vh(function(o){t=o}),cancel:t}}};function gg(e){return function(n){return e.apply(null,n)}}function xg(e){return O.isObject(e)&&e.isAxiosError===!0}const ai={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(ai).forEach(([e,t])=>{ai[t]=e});function Ll(e){const t=new Yn(e),n=Qa(Yn.prototype.request,t);return O.extend(n,Yn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ll(Gn(e,o))},n}const Ct=Ll(Dr);Ct.Axios=Yn,Ct.CanceledError=dr,Ct.CancelToken=mg,Ct.isCancel=vl,Ct.VERSION=Ml,Ct.toFormData=bo,Ct.AxiosError=Pe,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=gg,Ct.isAxiosError=xg,Ct.mergeConfig=Gn,Ct.AxiosHeaders=Ht,Ct.formToJSON=e=>xl(O.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=Pl.getAdapter,Ct.HttpStatusCode=ai,Ct.default=Ct;const{Axios:fT,AxiosError:pT,CanceledError:hT,isCancel:mT,CancelToken:gT,VERSION:xT,all:yT,Cancel:vT,isAxiosError:bT,spread:wT,toFormData:ST,AxiosHeaders:CT,HttpStatusCode:TT,formToJSON:kT,getAdapter:ET,mergeConfig:IT}=Ct,$l=typeof window<"u"?window.__API_BASE_URL__:void 0,Fl=$l?kn($l):void 0;function kn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Eo=null;const li=new Set;function zl(){return Eo}function Io(e){Eo=e,li.forEach(t=>t(e))}function Bl(e){return li.add(e),()=>li.delete(e)}const yg=3e4,vg=9e4,Jt=Ct.create({...Fl?{baseURL:Fl}:{},timeout:yg,withCredentials:!0});Jt.interceptors.request.use(e=>(Eo&&(e.headers.Authorization=`Bearer ${Eo}`),e)),Jt.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),Io(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 Zt(e,t){return Jt.defaults.baseURL?(await Jt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function ci(e,t,n){return Jt.defaults.baseURL?(await Jt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Hl(e,t,n){return Jt.defaults.baseURL?(await Jt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ul(e,t){return Jt.defaults.baseURL?(await Jt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Qt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Wl{get baseUrl(){const t=Jt.defaults.baseURL;return t?kn(String(t)):""}updateConfig(t){t.baseUrl&&(Jt.defaults.baseURL=kn(String(t.baseUrl))),t.authToken!==void 0&&Io(t.authToken)}getAuthToken(){return zl()}setAuthToken(t){Io(t)}onTokenChange(t){return Bl(t)}async listThreads(){const t=await Zt("/threads"),n=Qt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await ci("/threads",t?{title:t}:void 0);return Qt(r)}async updateThread(t,n){const r=await Hl(`/threads/${t}`,{title:n});return Qt(r)}async deleteThread(t){const n=await Ul(`/threads/${t}`);return Qt(n)}async threadInfo(t){const n=await Zt(`/threads/${t}/info`);return Qt(n)}async listAgents(){const t=await Zt("/agents"),n=Qt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Zt(`/agents/${t}`);return Qt(n)}async getAgentSchema(t){const n=await Zt(`/agents/${t}/schema`);return Qt(n)}async getState(t){const n=await Zt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Qt(n)}async getStateHistory(t){const n=await Zt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:vg});return Qt(n)}async cancelRun(t){const n=await ci("/runs/cancel",{threadId:t});return Qt(n)}async listCheckpointSummaries(t){const n=await Zt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=Qt(n);return(r==null?void 0:r.items)??[]}}const Rn=new Wl,Vl=w.createContext(null);function bg({children:e,apiConfig:t}){const n=Rn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(Vl.Provider,{value:r,children:e})}function ui(){const e=w.useContext(Vl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function wg(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 Sg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await wg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Cg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function di(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 Tg(e,t){return`${e??""}::${t??""}`}function fr(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(!di(r))return{threadId:n,latest:null,checkpoints:[],timeline:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Eg(t),i=Kl(r,0),a=Ig(o);return{threadId:n,latest:i,checkpoints:o,timeline:a,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Kl(e,t){if(!di(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(_=>!!_&&typeof _=="object").map(_=>({..._})):a===null?null:void 0,c=r.map((_,L)=>Dg(_,L)).filter(_=>!!_),d=$t(e.config),f=$t(d==null?void 0:d.configurable),p=mt(f,["checkpoint_id","checkpointId"]),h=mt(f,["checkpoint_ns","checkpointNs"]),x=$t(e==null?void 0:e.parentConfig),m=$t(x==null?void 0:x.configurable),v=mt(m,["checkpoint_id","checkpointId"])??null,g=mt(m,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,S=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),k=c.slice().reverse().find(_=>_.role==="user")??null,T=$t(e==null?void 0:e.metadata),C=mt(T,["branch_label","branchLabel"]),E=mt(m,["checkpoint_id","checkpointId"]),N=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:v,nextCursorNs:g,interrupt:kg(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastUserMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:x??null,next:N??null,tasks:l??null,values:i??null}}function kg(e,t,n){const r=Og(e,n);return r||Pg(t,n)}function Eg(e){const t=new Map;e.forEach((o,s)=>{if(!di(o))return;const i=Kl(o,s);if(!(i!=null&&i.checkpointId))return;const a=Tg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,_g(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Gl(s.createdAt??"")-Gl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ig(e){var n,r;const t=[];for(const o of e){const s=o.checkpointId??null;if(!s)continue;const i=o.metadata??{},a=mt(i,["label"])??mt(i,["branch_label","branchLabel"])??mt(i,["description"])??"User input",l=Ag(i,["step"]),c=mt(i,["source"]),d=o.createdAt??null,f=((r=(n=o.messages)==null?void 0:n[o.messages.length-1])==null?void 0:r.id)??null,p=o.lastUserMessageId??f,h=Ng(o.next);t.push({id:s,label:a,messageId:p,step:l,source:c??null,createdAt:d,next:h??void 0})}return t}function Ng(e){if(!Array.isArray(e)||e.length===0)return null;const t=e.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"&&"type"in n){const r=n;if(typeof r.type=="string")return r.type}return null}).filter(n=>!!(n&&n.length));return t.length?t.join(", "):null}function Ag(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function _g(e,t){return{...e,metadata:No(e.metadata,t.metadata)??null,config:No(e.config,t.config)??null,parentConfig:No(e.parentConfig,t.parentConfig)??null,next:jg(e.next,t.next)??null,tasks:Rg(e.tasks,t.tasks)??null,values:No(e.values,t.values)??null}}function No(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 Rg(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 Pg(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 Og(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Mg(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=$r(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=$r(r.state,`${o}-state`);if(s)return s}}return null}function Mg(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,x=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",m=Array.isArray(d)?d:void 0,v=p.length?p[p.length-1]:void 0;return{id:h,name:x,interrupts:m,state:v!==void 0?v:f}}const n=$t(e);if(!n)return null;const r=mt(n,["id","thread_id","taskId"])??t,o=mt(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function $r(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=ql(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=$r(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=$r(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=$r(l,t,n+1,r);if(c)return c}}return null}function ql(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=mt(n,["type","event","kind"]),o=mt(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=ql(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 Gl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Dg(e,t){if(!e||typeof e!="object")return null;const n=e,r=$t(e)??{},o=$t(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Cg[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=$t(o.additional_kwargs)??$t(o.additionalKwargs),d=$t(o.response_metadata)??$t(o.responseMetadata),f=mt(c,["createdAt","created_at"])??mt(o,["created_at","createdAt"]),p=mt(c,["checkpointId","checkpoint_id"]),h=mt(c,["checkpointNs","checkpoint_ns"]),x=Lg(o.content),m={id:l,role:i,content:x};f&&(m.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(m.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(m.model=String(d.model_name)),!m.model&&typeof o.model=="string"&&(m.model=o.model),p&&(m.checkpointId=p),h&&(m.checkpointNs=h);const v=zg($t(o.artifact??r.artifact??o.artifacts??r.artifacts));v&&(m.artifact=v);const g=Wg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),b=d?{...d}:void 0;g&&Object.keys(g).length&&(m.additionalKwargs=g),b&&Object.keys(b).length&&(m.responseMetadata=b);const S=$g((c==null?void 0:c.tool_calls)??o.tool_calls);if(S.length&&(m.content=[...m.content,...S]),i==="tool"){const k=Fg(o,m.content);k&&(m.content=k)}return m}function Lg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Yl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Yl(e);return t?[t]:[]}return[]}function Yl(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=mt(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=mt(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return Xl(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=mt(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function Xl(e,t){var s;const n=mt(e,["id","call_id"])??t,r=mt(e,["name"])??mt($t(e.function),["name"]);if(!n||!r)return null;const o=Ug(e.args??e.arguments??((s=$t(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function $g(e){return Array.isArray(e)?e.map((t,n)=>Xl(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 zg(e){return e?{plots:Bg(e.plots)}:void 0}function Bg(e){return Array.isArray(e)?e.map(t=>Hg(t)).filter(t=>!!t):[]}function Hg(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.content_base64=="string"&&t.content_base64.trim()||void 0,r=typeof t.url=="string"&&t.url.trim()||void 0,o=(typeof t.format=="string"?t.format.trim():void 0)||(typeof t.mimeType=="string"?t.mimeType.trim():void 0)||(typeof t.mime_type=="string"?t.mime_type.trim():void 0),s=typeof t.plotId=="string"&&t.plotId.trim()||void 0,i=typeof t.artifactId=="string"&&t.artifactId.trim()||void 0,a={};return n&&(a.content_base64=n),r&&(a.url=r),o&&(a.format=o),s&&(a.plotId=s),i&&(a.artifactId=i),a}function Ug(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 $t(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function mt(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function Wg(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}const pr=120;function Vg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>pr?`${n.slice(0,pr-3)}…`:n:""}function Kg(e){var r,o;const t=[(r=e.additionalKwargs)==null?void 0:r.summary,(o=e.responseMetadata)==null?void 0:o.summary];for(const s of t)if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>pr?`${i.slice(0,pr-3)}…`:i}const n=(e.name||e.id||"").toString().trim();return n?n.length>pr?`${n.slice(0,pr-3)}…`:n:""}function Jl(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const o=Vg(n.content)||Kg(n);o&&t.set(n.id,o)}return t}function Zl(e={}){const t=w.useMemo(()=>kn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,x]=w.useState(null),[m,v]=w.useState(0),[g,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),N=w.useRef(null),_=w.useRef(null),L=w.useCallback(A=>{o(A)},[]),j=w.useCallback(()=>{p(""),x(null),d(null),E.current=null,N.current=null,_.current=null},[]),M=w.useCallback(()=>{var A;console.debug("[use-chat] stop() invoked - aborting stream"),(A=S.current)==null||A.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,v(0)},[]),z=w.useCallback((A,F,R)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),x(null),E.current=null,N.current=null,_.current=null;const G=new AbortController;S.current=G;let B=null,D=null,V=!1;return C.current={threadId:A.threadId??null,headers:{}},(async()=>{var he,ae,_e,X,H,J,$,K,re,oe,se,Te,Ye,Le,Ge,de,be,ze;const Y=Ue=>{var We;try{const nt=JSON.parse(JSON.stringify(Ue));return(We=nt==null?void 0:nt.payload)!=null&&We.files_info&&Array.isArray(nt.payload.files_info)&&(nt.payload.files_info=nt.payload.files_info.map($e=>({...$e,data:$e!=null&&$e.data?`<base64 ${String($e.data).length} chars>`:$e==null?void 0:$e.data}))),nt}catch{return Ue}};try{let Ue={};try{if(r)Ue={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ze=window.__AUTH_TOKEN__,wt=((he=window.localStorage)==null?void 0:he.getItem("authToken"))||null;let Q=null;try{const ve=(ae=window.localStorage)==null?void 0:ae.getItem("chat-settings");ve&&(Q=((_e=JSON.parse(ve))==null?void 0:_e.apiKey)||null)}catch{}const te=Ze||wt||Q||null;te&&(Ue={Authorization:`Bearer ${te}`})}}catch{}console.debug("[use-chat] POST",t+n,Y(A));let We={};if(typeof window<"u")try{const st=(X=window.localStorage)==null?void 0:X.getItem("authSessionId");st&&(We={"X-Session-Id":st})}catch{}const nt={...Ue,...We,...s.current},$e={"Content-Type":"application/json",Accept:"text/event-stream",...nt},Fe=await fetch(t+n,{method:"POST",headers:$e,body:JSON.stringify(A),signal:G.signal,credentials:i});if(C.current&&(C.current.headers=nt),!Fe.ok||!Fe.body){const st=await Fe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Fe.status,st==null?void 0:st.slice(0,500));const Ze=`stream ${Fe.status}${st?": "+st:""}`;throw(H=R==null?void 0:R.onConnectionError)==null||H.call(R,Ze),V=!0,B="error",D=Ze,new Error(Ze)}b(!0);const rt=Fe.body.getReader(),It=new TextDecoder;let dt="",ft=[];T.current=0,v(0);let pt=0,yt=null;const vt=()=>{if(ft.length){const st=ft.join("");ft=[],k.current&&p(Ze=>Ze+st)}yt=null},xt=()=>{typeof window<"u"&&yt==null&&(yt=requestAnimationFrame(vt))};let Lt=Date.now();const Be=setInterval(()=>{var st;if(Date.now()-Lt>18e5){const Ze="Stream idle timeout";d(Ze),B="error",D=Ze,G.abort(),(st=R==null?void 0:R.onError)==null||st.call(R,Ze)}},5e3),hn=1024*1024;try{const st=Fe.headers.get("X-Thread-Id")||Fe.headers.get("x-thread-id"),Ze=Fe.headers.get("X-Thread-Created")||Fe.headers.get("x-thread-created"),wt=st??null,Q=String(Ze??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:wt}),(J=R==null?void 0:R.onOpen)==null||J.call(R,{threadId:wt,created:Q});;){const{value:te,done:ve}=await rt.read();if(ve)break;dt+=It.decode(te,{stream:!0}),dt.length>hn&&(dt="",console.warn("Stream buffer reset: exceeded 1MB"));let Ce;for(;(Ce=dt.indexOf(`
34
+ `):" "+Rl(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:si};function ii(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ur(null,e)}function Ol(e){return ii(e),e.headers=Ht.from(e.headers),e.data=oi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Pl.getAdapter(e.adapter||Mr.adapter,e)(e).then(function(r){return ii(e),r.data=oi.call(e,e.transformResponse,r),r.headers=Ht.from(r.headers),r},function(r){return vl(r)||(ii(e),r&&r.response&&(r.response.data=oi.call(e,e.transformResponse,r.response),r.response.headers=Ht.from(r.response.headers))),Promise.reject(r)})}const Ml="1.12.2",To={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{To[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Dl={};To.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Ml+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!Dl[i]&&(Dl[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}},To.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function mg(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const ko={assertOptions:mg,validators:To},mn=ko.validators;let Gn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new ml,response:new ml}}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=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ko.assertOptions(r,{silentJSONParsing:mn.transitional(mn.boolean),forcedJSONParsing:mn.transitional(mn.boolean),clarifyTimeoutError:mn.transitional(mn.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:ko.assertOptions(o,{encode:mn.function,serialize:mn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ko.assertOptions(n,{baseUrl:mn.spelling("baseURL"),withXsrfToken:mn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Ht.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let d,f=0,p;if(!l){const x=[Ol.bind(this),void 0];for(x.unshift(...a),x.push(...c),p=x.length,d=Promise.resolve(n);f<p;)d=d.then(x[f++],x[f++]);return d}p=a.length;let h=n;for(;f<p;){const x=a[f++],m=a[f++];try{h=x(h)}catch(v){m.call(this,v);break}}try{d=Ol.call(this,h)}catch(x){return Promise.reject(x)}for(f=0,p=c.length;f<p;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=qn(this.defaults,t);const n=Cl(t.baseURL,t.url,t.allowAbsoluteUrls);return hl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Gn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Gn.prototype[t]=n(),Gn.prototype[t+"Form"]=n(!0)});let gg=class Kh{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 ur(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 Kh(function(o){t=o}),cancel:t}}};function xg(e){return function(n){return e.apply(null,n)}}function yg(e){return O.isObject(e)&&e.isAxiosError===!0}const ai={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(ai).forEach(([e,t])=>{ai[t]=e});function Ll(e){const t=new Gn(e),n=Qa(Gn.prototype.request,t);return O.extend(n,Gn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ll(qn(e,o))},n}const Ct=Ll(Mr);Ct.Axios=Gn,Ct.CanceledError=ur,Ct.CancelToken=gg,Ct.isCancel=vl,Ct.VERSION=Ml,Ct.toFormData=bo,Ct.AxiosError=Re,Ct.Cancel=Ct.CanceledError,Ct.all=function(t){return Promise.all(t)},Ct.spread=xg,Ct.isAxiosError=yg,Ct.mergeConfig=qn,Ct.AxiosHeaders=Ht,Ct.formToJSON=e=>xl(O.isHTMLForm(e)?new FormData(e):e),Ct.getAdapter=Pl.getAdapter,Ct.HttpStatusCode=ai,Ct.default=Ct;const{Axios:mT,AxiosError:gT,CanceledError:xT,isCancel:yT,CancelToken:vT,VERSION:bT,all:wT,Cancel:ST,isAxiosError:CT,spread:TT,toFormData:kT,AxiosHeaders:ET,HttpStatusCode:IT,formToJSON:NT,getAdapter:AT,mergeConfig:_T}=Ct,$l=typeof window<"u"?window.__API_BASE_URL__:void 0,Fl=$l?kn($l):void 0;function kn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Eo=null;const li=new Set;function zl(){return Eo}function Io(e){Eo=e,li.forEach(t=>t(e))}function Bl(e){return li.add(e),()=>li.delete(e)}const vg=3e4,bg=9e4,Jt=Ct.create({...Fl?{baseURL:Fl}:{},timeout:vg,withCredentials:!0});Jt.interceptors.request.use(e=>(Eo&&(e.headers.Authorization=`Bearer ${Eo}`),e)),Jt.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),Io(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 Zt(e,t){return Jt.defaults.baseURL?(await Jt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function ci(e,t,n){return Jt.defaults.baseURL?(await Jt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Hl(e,t,n){return Jt.defaults.baseURL?(await Jt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ul(e,t){return Jt.defaults.baseURL?(await Jt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Qt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Wl{get baseUrl(){const t=Jt.defaults.baseURL;return t?kn(String(t)):""}updateConfig(t){t.baseUrl&&(Jt.defaults.baseURL=kn(String(t.baseUrl))),t.authToken!==void 0&&Io(t.authToken)}getAuthToken(){return zl()}setAuthToken(t){Io(t)}onTokenChange(t){return Bl(t)}async listThreads(){const t=await Zt("/threads"),n=Qt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await ci("/threads",t?{title:t}:void 0);return Qt(r)}async updateThread(t,n){const r=await Hl(`/threads/${t}`,{title:n});return Qt(r)}async deleteThread(t){const n=await Ul(`/threads/${t}`);return Qt(n)}async threadInfo(t){const n=await Zt(`/threads/${t}/info`);return Qt(n)}async listAgents(){const t=await Zt("/agents"),n=Qt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Zt(`/agents/${t}`);return Qt(n)}async getAgentSchema(t){const n=await Zt(`/agents/${t}/schema`);return Qt(n)}async getState(t){const n=await Zt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Qt(n)}async getStateHistory(t){const n=await Zt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:bg});return Qt(n)}async cancelRun(t){const n=await ci("/runs/cancel",{threadId:t});return Qt(n)}async listCheckpointSummaries(t){const n=await Zt(`/threads/${t}/state/checkpoints`,{params:{thread_id:t}}),r=Qt(n);return(r==null?void 0:r.items)??[]}}const jn=new Wl,Vl=w.createContext(null);function wg({children:e,apiConfig:t}){const n=jn;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(Vl.Provider,{value:r,children:e})}function ui(){const e=w.useContext(Vl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Sg(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 Cg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const c=await Sg(l);a.push({filename:l.name,data:c,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Tg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function di(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 kg(e,t){return`${e??""}::${t??""}`}function dr(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(!di(r))return{threadId:n,latest:null,checkpoints:[],timeline:[],interrupt:null,snapshots:{}};const{orderedSnapshots:o,snapshotMap:s}=Ig(t),i=Kl(r,0),a=Ng(o);return{threadId:n,latest:i,checkpoints:o,timeline:a,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function Kl(e,t){if(!di(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(j=>!!j&&typeof j=="object").map(j=>({...j})):a===null?null:void 0,c=r.map((j,L)=>Lg(j,L)).filter(j=>!!j),d=$t(e.config),f=$t(d==null?void 0:d.configurable),p=mt(f,["checkpoint_id","checkpointId"]),h=mt(f,["checkpoint_ns","checkpointNs"]),x=$t(e==null?void 0:e.parentConfig),m=$t(x==null?void 0:x.configurable),v=mt(m,["checkpoint_id","checkpointId"])??null,g=mt(m,["checkpoint_ns","checkpointNs"])??null,b=e==null?void 0:e.createdAt,S=typeof b=="string"&&b.trim()?b:new Date(Date.now()-t).toISOString(),k=c.slice().reverse().find(j=>j.role==="user")??null,T=$t(e==null?void 0:e.metadata),C=mt(T,["branch_label","branchLabel"]),E=mt(m,["checkpoint_id","checkpointId"]),N=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:v,nextCursorNs:g,interrupt:Eg(a,c,t),createdAt:S,parentId:E??null,branchLabel:C??null,lastUserMessageId:(k==null?void 0:k.id)??null,hasMessages:c.length>0,messagesLen:c.length,metadata:T??null,config:d??null,parentConfig:x??null,next:N??null,tasks:l??null,values:i??null}}function Eg(e,t,n){const r=Mg(e,n);return r||Og(t,n)}function Ig(e){const t=new Map;e.forEach((o,s)=>{if(!di(o))return;const i=Kl(o,s);if(!(i!=null&&i.checkpointId))return;const a=kg(i.checkpointId,i.checkpointNs??null),l=t.get(a);if(!l){t.set(a,i);return}t.set(a,jg(l,i))});const n=Array.from(t.values());n.sort((o,s)=>Gl(s.createdAt??"")-Gl(o.createdAt??""));const r={};for(const[o,s]of t.entries())r[o]=s;return{orderedSnapshots:n,snapshotMap:r}}function Ng(e){var n,r;const t=[];for(const o of e){const s=o.checkpointId??null;if(!s)continue;const i=o.metadata??{},a=mt(i,["label"])??mt(i,["branch_label","branchLabel"])??mt(i,["description"])??"User input",l=_g(i,["step"]),c=mt(i,["source"]),d=o.createdAt??null,f=((r=(n=o.messages)==null?void 0:n[o.messages.length-1])==null?void 0:r.id)??null,p=o.lastUserMessageId??f,h=Ag(o.next);t.push({id:s,label:a,messageId:p,step:l,source:c??null,createdAt:d,next:h??void 0})}return t}function Ag(e){if(!Array.isArray(e)||e.length===0)return null;const t=e.map(n=>{if(typeof n=="string")return n.trim();if(n&&typeof n=="object"&&"type"in n){const r=n;if(typeof r.type=="string")return r.type}return null}).filter(n=>!!(n&&n.length));return t.length?t.join(", "):null}function _g(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function jg(e,t){return{...e,metadata:No(e.metadata,t.metadata)??null,config:No(e.config,t.config)??null,parentConfig:No(e.parentConfig,t.parentConfig)??null,next:Rg(e.next,t.next)??null,tasks:Pg(e.tasks,t.tasks)??null,values:No(e.values,t.values)??null}}function No(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 Rg(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 Pg(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 Og(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 Mg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Dg(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=Lr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Lr(r.state,`${o}-state`);if(s)return s}}return null}function Dg(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,x=typeof l=="string"&&l.trim()?l:Array.isArray(c)&&typeof c[0]=="string"?String(c[0]):"task",m=Array.isArray(d)?d:void 0,v=p.length?p[p.length-1]:void 0;return{id:h,name:x,interrupts:m,state:v!==void 0?v:f}}const n=$t(e);if(!n)return null;const r=mt(n,["id","thread_id","taskId"])??t,o=mt(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Lr(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=ql(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Lr(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=Lr(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=Lr(l,t,n+1,r);if(c)return c}}return null}function ql(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=mt(n,["type","event","kind"]),o=mt(n,["id","interrupt_id","interruptId","value_id"])??(r&&r.toLowerCase().includes("interrupt")?t:void 0);if(!(Object.prototype.hasOwnProperty.call(n,"value")||Object.prototype.hasOwnProperty.call(n,"data")||Object.prototype.hasOwnProperty.call(n,"payload"))&&!(r&&r.toLowerCase().includes("interrupt")))return null;const i=Object.prototype.hasOwnProperty.call(n,"value")?n.value:Object.prototype.hasOwnProperty.call(n,"data")?n.data:Object.prototype.hasOwnProperty.call(n,"payload")?n.payload:n,a=o&&o.trim()?o:t;return a?{id:a,value:i}:null}if(Array.isArray(e)){for(let n=e.length-1;n>=0;n--){const r=ql(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 Gl(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Lg(e,t){if(!e||typeof e!="object")return null;const n=e,r=$t(e)??{},o=$t(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Tg[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=$t(o.additional_kwargs)??$t(o.additionalKwargs),d=$t(o.response_metadata)??$t(o.responseMetadata),f=mt(c,["createdAt","created_at"])??mt(o,["created_at","createdAt"]),p=mt(c,["checkpointId","checkpoint_id"]),h=mt(c,["checkpointNs","checkpoint_ns"]),x=$g(o.content),m={id:l,role:i,content:x};f&&(m.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(m.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(m.model=String(d.model_name)),!m.model&&typeof o.model=="string"&&(m.model=o.model),p&&(m.checkpointId=p),h&&(m.checkpointNs=h);const v=Bg($t(o.artifact??r.artifact??o.artifacts??r.artifacts));v&&(m.artifact=v);const g=Vg(c,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),b=d?{...d}:void 0;g&&Object.keys(g).length&&(m.additionalKwargs=g),b&&Object.keys(b).length&&(m.responseMetadata=b);const S=Fg((c==null?void 0:c.tool_calls)??o.tool_calls);if(S.length&&(m.content=[...m.content,...S]),i==="tool"){const k=zg(o,m.content);k&&(m.content=k)}return m}function $g(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>Yl(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=Yl(e);return t?[t]:[]}return[]}function Yl(e){if(!e||typeof e!="object")return typeof e=="string"&&e.trim()?{type:"text",text:e}:null;const t=e,n=String(t.type??"").toLowerCase();if(!n||n==="text"){const o=typeof t.text=="string"?t.text:typeof t.value=="string"?t.value:"";return o.trim()?{type:"text",text:o}:null}if(n==="image"||n==="image_url"){const o=mt(t,["url","src"]);if(!o)return null;const s={type:"image_url",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.alt=="string"&&(s.alt=t.alt),s}if(n==="file"){const o=mt(t,["url"]);if(!o)return null;const s={type:"file",url:o};return typeof t.mimeType=="string"&&(s.mimeType=t.mimeType),typeof t.name=="string"&&(s.name=t.name),typeof t.size=="number"&&(s.size=t.size),typeof t.sourceType=="string"&&(s.sourceType=t.sourceType),s}if(n==="tool_call")return Xl(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=mt(t,["text","content"]);if(o)return{type:"text",text:o}}const r=typeof t.content=="string"?t.content:typeof t.value=="string"?t.value:JSON.stringify(t);return r?{type:"text",text:r}:null}function Xl(e,t){var s;const n=mt(e,["id","call_id"])??t,r=mt(e,["name"])??mt($t(e.function),["name"]);if(!n||!r)return null;const o=Wg(e.args??e.arguments??((s=$t(e.function))==null?void 0:s.arguments));return{type:"tool_call",id:n,name:r,args:o}}function Fg(e){return Array.isArray(e)?e.map((t,n)=>Xl(t,`tool_call_${n}`)).filter(t=>!!t):[]}function zg(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 Bg(e){return e?{plots:Hg(e.plots)}:void 0}function Hg(e){return Array.isArray(e)?e.map(t=>Ug(t)).filter(t=>!!t):[]}function Ug(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.content_base64=="string"&&t.content_base64.trim()||void 0,r=typeof t.url=="string"&&t.url.trim()||void 0,o=(typeof t.format=="string"?t.format.trim():void 0)||(typeof t.mimeType=="string"?t.mimeType.trim():void 0)||(typeof t.mime_type=="string"?t.mime_type.trim():void 0),s=typeof t.plotId=="string"&&t.plotId.trim()||void 0,i=typeof t.artifactId=="string"&&t.artifactId.trim()||void 0,a={};return n&&(a.content_base64=n),r&&(a.url=r),o&&(a.format=o),s&&(a.plotId=s),i&&(a.artifactId=i),a}function Wg(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 $t(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function mt(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function Vg(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}const fr=120;function Kg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>fr?`${n.slice(0,fr-3)}…`:n:""}function qg(e){var r,o;const t=[(r=e.additionalKwargs)==null?void 0:r.summary,(o=e.responseMetadata)==null?void 0:o.summary];for(const s of t)if(typeof s=="string"&&s.trim()){const i=s.trim();return i.length>fr?`${i.slice(0,fr-3)}…`:i}const n=(e.name||e.id||"").toString().trim();return n?n.length>fr?`${n.slice(0,fr-3)}…`:n:""}function Jl(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const o=Kg(n.content)||qg(n);o&&t.set(n.id,o)}return t}function Zl(e={}){const t=w.useMemo(()=>kn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[f,p]=w.useState(""),[h,x]=w.useState(null),[m,v]=w.useState(0),[g,b]=w.useState(!1),S=w.useRef(null),k=w.useRef(!0),T=w.useRef(0),C=w.useRef(null),E=w.useRef(null),N=w.useRef(null),j=w.useRef(null),L=w.useCallback(A=>{o(A)},[]),_=w.useCallback(()=>{p(""),x(null),d(null),E.current=null,N.current=null,j.current=null},[]),M=w.useCallback(()=>{var A;console.debug("[use-chat] stop() invoked - aborting stream"),(A=S.current)==null||A.abort(),S.current=null,C.current=null,l(!1),b(!1),T.current=0,v(0)},[]),z=w.useCallback((A,F,R)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&p(""),x(null),E.current=null,N.current=null,j.current=null;const G=new AbortController;S.current=G;let B=null,D=null,V=!1;return C.current={threadId:A.threadId??null,headers:{}},(async()=>{var he,ie,Ae,X,H,J,$,K,re,oe,se,Te,Je,De,Ye,de,be,Fe;const Y=He=>{var Ue;try{const rt=JSON.parse(JSON.stringify(He));return(Ue=rt==null?void 0:rt.payload)!=null&&Ue.files_info&&Array.isArray(rt.payload.files_info)&&(rt.payload.files_info=rt.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),rt}catch{return He}};try{let He={};try{if(r)He={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Qe=window.__AUTH_TOKEN__,wt=((he=window.localStorage)==null?void 0:he.getItem("authToken"))||null;let Q=null;try{const ve=(ie=window.localStorage)==null?void 0:ie.getItem("chat-settings");ve&&(Q=((Ae=JSON.parse(ve))==null?void 0:Ae.apiKey)||null)}catch{}const te=Qe||wt||Q||null;te&&(He={Authorization:`Bearer ${te}`})}}catch{}console.debug("[use-chat] POST",t+n,Y(A));let Ue={};if(typeof window<"u")try{const at=(X=window.localStorage)==null?void 0:X.getItem("authSessionId");at&&(Ue={"X-Session-Id":at})}catch{}const rt={...He,...Ue,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...rt},$e=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify(A),signal:G.signal,credentials:i});if(C.current&&(C.current.headers=rt),!$e.ok||!$e.body){const at=await $e.text().catch(()=>"");console.debug("[use-chat] non-OK response",$e.status,at==null?void 0:at.slice(0,500));const Qe=`stream ${$e.status}${at?": "+at:""}`;throw(H=R==null?void 0:R.onConnectionError)==null||H.call(R,Qe),V=!0,B="error",D=Qe,new Error(Qe)}b(!0);const ot=$e.body.getReader(),It=new TextDecoder;let st="",pt=[];T.current=0,v(0);let ht=0,vt=null;const xt=()=>{if(pt.length){const at=pt.join("");pt=[],k.current&&p(Qe=>Qe+at)}vt=null},yt=()=>{typeof window<"u"&&vt==null&&(vt=requestAnimationFrame(xt))};let Lt=Date.now();const ze=setInterval(()=>{var at;if(Date.now()-Lt>18e5){const Qe="Stream idle timeout";d(Qe),B="error",D=Qe,G.abort(),(at=R==null?void 0:R.onError)==null||at.call(R,Qe)}},5e3),hn=1024*1024;try{const at=$e.headers.get("X-Thread-Id")||$e.headers.get("x-thread-id"),Qe=$e.headers.get("X-Thread-Created")||$e.headers.get("x-thread-created"),wt=at??null,Q=String(Qe??"").toLowerCase()==="true";for(C.current&&!C.current.threadId&&(C.current={...C.current,threadId:wt}),(J=R==null?void 0:R.onOpen)==null||J.call(R,{threadId:wt,created:Q});;){const{value:te,done:ve}=await ot.read();if(ve)break;st+=It.decode(te,{stream:!0}),st.length>hn&&(st="",console.warn("Stream buffer reset: exceeded 1MB"));let Ce;for(;(Ce=st.indexOf(`
36
36
 
37
- `))>=0;){const Oe=dt.slice(0,Ce);dt=dt.slice(Ce+2);const Xe=Gg(Oe);if(!Xe)continue;let Nt;try{Nt=JSON.parse(Xe)}catch{console.debug("[use-chat] malformed SSE:",Xe.slice(0,200));continue}const P=qg(Nt)?Nt.data:Nt;Lt=Date.now();const ue=P.seq;if(ue!==void 0){if(ue<=pt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ue,lastProcessedSeq:pt,type:P.type});continue}pt>0&&ue>pt+1&&(($=R==null?void 0:R.onGap)==null||$.call(R,{from:pt,to:ue})),pt=ue,T.current=ue,v(ue)}if(console.debug("[use-chat] received event",{seq:P.seq,type:P.type,preview:(()=>{var q;try{return P.type==="message_delta"?{deltaTypes:(q=P.delta)==null?void 0:q.map(we=>we.type),textLen:(P.delta||[]).filter(we=>we.type==="text").map(we=>String(we.text||"").length)}:P.content||P.delta?{hasContent:!0}:{}}catch(we){return{err:String(we)}}})()}),P.type==="checkpoint")E.current=P.checkpointId??null,N.current=P.checkpointNs??null,x(P.checkpointId??null);else if(P.type==="state_history"){_.current=P;try{const we=fr(P).latest;we&&(E.current=we.checkpointId??null,N.current=we.checkpointNs??null,x(we.checkpointId??null))}catch(q){console.warn("[use-chat] Failed to hydrate state_history payload",q)}}try{F==null||F(P)}catch(q){console.error("[use-chat] Error in onEvent callback:",q,"for event:",P.type)}if(P.type==="token"&&e.autoAppendAssistant!==!1)ft.push(P.content),xt();else if(P.type==="message_delta"){const q=P.delta.filter(we=>we.type==="text").map(we=>we.text).join("");q&&e.autoAppendAssistant!==!1&&(ft.push(q),xt())}else if(P.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(K=R==null?void 0:R.onHeartbeat)==null||K.call(R,P)}catch(q){console.warn("[use-chat] heartbeat callback failed",q)}}else if(yt!==null&&cancelAnimationFrame(yt),vt(),P.type==="checkpoint")x(P.checkpointId);else if(P.type==="error"){const q=P;if(d(q.message),B="error",D=q.message,q.error_type==="auth_error"||q.code==="TOKEN_EXPIRED"||((re=q.message)==null?void 0:re.includes("token"))||((oe=q.message)==null?void 0:oe.includes("401"))||((se=q.message)==null?void 0:se.includes("unauthorized"))||((Te=q.message)==null?void 0:Te.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",q.message);try{(Ye=R==null?void 0:R.onAuthError)==null||Ye.call(R,q.message)}catch(kt){console.warn("[use-chat] onAuthError handler failed",kt)}G.abort()}}}}vt(),B===null&&!G.signal.aborted&&(B="complete")}catch(st){if(st.name==="AbortError")B=B??"aborted";else{const Ze=st.message||String(st);B="error",D=Ze,d(Ze),(Le=R==null?void 0:R.onError)==null||Le.call(R,Ze)}}finally{try{await rt.cancel()}catch{}finally{(Ge=rt.releaseLock)==null||Ge.call(rt)}yt!==null&&typeof window<"u"&&window.cancelAnimationFrame(yt),clearInterval(Be)}}catch(Ue){if(Ue.name==="AbortError")B=B??"aborted";else{const We=Ue.message||String(Ue);B="error",D=We,d(We),(de=R==null?void 0:R.onError)==null||de.call(R,We),V||((be=R==null?void 0:R.onConnectionError)==null||be.call(R,We),V=!0)}}finally{const Ue=T.current,We=E.current,nt=N.current,$e=_.current,Fe=B??(G.signal.aborted?"aborted":D?"error":"complete");try{(ze=R==null?void 0:R.onClosed)==null||ze.call(R,{reason:Fe,lastSeq:Ue,lastCheckpointId:We,lastCheckpointNs:nt,lastStateHistory:$e,error:D})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),b(!1),S.current=null,T.current=0,v(0),C.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var A;k.current=!1,(A=S.current)==null||A.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:h,lastSeq:m,connected:g,stream:z,stop:M,clear:j,setToken:L}}function qg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Gg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
- `)}function Yg(e){return e.type!=="token"}const Xg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Jg(e,t){var n;switch(t.type){case"reset":return{messages:fi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=fi(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=fi(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 ec(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ec(o,s),e):e}case"interrupt_response":return{...e,messages:tc(e.messages),pendingInterrupt:null};default:return e}}function Ql(e=[]){const[t,n]=w.useReducer(Jg,{...Xg,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,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 ec(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=tx(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??nc(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:sc(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:x,newMeta:m,changed:v}=Zg(d.content,t.delta,p,h);if(!v)return e;const g={...d,content:x},b=Ao(l,c,g),S={...f,[a]:m};return{...e,messages:b,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??nc(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=rc(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=oc(e,d,c),p=f>=0?e.messages[f]:null,h=l??d[0]??`${c}-${Date.now()}`,x=(p==null?void 0:p.id)??`tool-${h}`,m=d[0]??h,v={type:"tool_call",id:m,name:c,args:t.args};if(p){const S=hi(p,d,c,t.args),k={...p,name:p.name??c,additionalKwargs:S},T=f,C=T>=0?Ao(e.messages,T,k):e.messages,E=_o(k,d),N=mi(e.toolIndex,x,E);return{...e,messages:C,toolIndex:N}}const g={id:x,role:"tool",name:c,createdAt:new Date().toISOString(),content:[v],additionalKwargs:hi(void 0,d.length?d:[m],c,t.args)},b=_o(g,d.length?d:[m]);return{...e,messages:[...e.messages,g],toolIndex:mi(e.toolIndex,x,b)}}if(t.type==="tool_end"){const a=rc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=oc(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}`,x=_o(d,a);let m=t.output;if(typeof t.output=="string")try{const E=t.output.trim();(E.startsWith("{")||E.startsWith("["))&&(m=JSON.parse(E))}catch{m=t.output}const v=t.artifact??(d==null?void 0:d.artifact),g={type:"text",text:typeof m=="string"?m:JSON.stringify(m)},b=(d==null?void 0:d.createdAt)??new Date().toISOString(),S=hi(d??void 0,x.length?x:a,f),k={id:h,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[g],createdAt:b,artifact:v??void 0,additionalKwargs:S},T=c>=0?Ao(e.messages,c,k):[...e.messages,k],C=_o(k,a.length?a:x);return{...e,messages:T,toolIndex:mi(e.toolIndex,h,C)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=ex(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=fr(t),l=a.interrupt,c=a.latest,d=l===null?tc(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 t.type==="thread_info",e}function fi(e){return e.filter(t=>{var s;if(t.role!=="assistant")return!0;const n=(t.content||[]).some(i=>{var a;return i&&i.type==="text"&&((a=i.text)==null?void 0:a.trim())}),r=(t.content||[]).some(i=>i&&i.type==="image_url"),o=!!((s=t.artifact)!=null&&s.plots&&t.artifact.plots.length>0);return!!(n||r||o)})}function Ao(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function tc(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 nc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function rc(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 pi(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 hi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=pi(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 _o(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=pi(e);for(const o of r)n.add(o);return Array.from(n)}function mi(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 oc(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(pi(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 sc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Zg(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??sc(e);let l="",c=e.slice();if(s){const f=Qg(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??"",x={...p,text:h+l};c=[...c.slice(0,c.length-1),x]}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 ic(e){return e.replace(/\s+/g," ").trim()}function Qg(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=ic(e),o=ic(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 ex(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 Ao(e,r,s)}return e}function tx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const ac=200;function nx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:c}){const d=w.useRef(null),f=w.useRef(null),p=w.useRef(new Map),h=w.useRef(null),x=w.useRef(null),m=w.useCallback(j=>{try{const M=globalThis.structuredClone;if(typeof M=="function")return M(j)}catch{}try{return JSON.parse(JSON.stringify(j))}catch{return j}},[]),v=w.useCallback((j,M)=>{if(!j)return;const z=p.current.get(j)??[],A=m(M),F=z.length>=ac?[...z.slice(z.length-ac+1),A]:[...z,A];p.current.set(j,F)},[m]),g=w.useCallback(j=>{j&&p.current.set(j,[])},[]),b=w.useCallback(j=>{const M=j??f.current;if(!M)return;const z=p.current.get(M);z!=null&&z.length&&z.forEach(A=>{try{n(A)}catch(F){console.error("[useChatStreamingService] Failed to replay buffered event",F)}})},[n]),S=w.useCallback(j=>{var A,F,R,G,B;const M=j.seq??null;if(M!==null){const D=d.current;if(D!==null){if(M<=D)return;M>D+1&&(s==null||s({from:D,to:M}))}d.current=M}if(j.type==="thread_info"){f.current=j.threadId,h.current&&(h.current.threadIdGuess=j.threadId),x.current=j,g(j.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",j);try{t(j)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}return}if(j.type==="heartbeat"){try{c==null||c(j)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}return}if(j.type==="error"){const D=j;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((A=D.message)==null?void 0:A.includes("token"))||((F=D.message)==null?void 0:F.includes("401"))||((R=D.message)==null?void 0:R.includes("unauthorized"))||((G=D.message)==null?void 0:G.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{l==null||l(D.message)}catch(Y){console.warn("[useChatStreamingService] onAuthError handler failed",Y)}}}const z=j.threadId??(j.type==="state_history"?j.threadId:void 0)??f.current??((B=h.current)==null?void 0:B.threadIdGuess)??null;if(j.type==="state_history"){f.current=z??f.current;try{r==null||r(j)}catch(D){console.error("[useChatStreamingService] onStateHistory handler failed",D)}}if(Yg(j)){j.type==="checkpoint"||j.type==="state_history"?g(z??null):v(z??null,j);try{n(j)}catch(D){console.error("[useChatStreamingService] Error in onMessageEvent handler:",D)}return}try{o==null||o(j)}catch(D){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",D)}},[v,g,n,s,t,r,o]),{stream:k,stop:T,isStreaming:C,error:E,setToken:N}=Zl({baseUrl:e,token:void 0}),_=w.useCallback((j,M)=>{d.current=null,x.current=null,f.current=j.threadId??null,h.current={request:j,callbacks:M,manualStop:!1,threadIdGuess:j.threadId??null},k(j,S,{onOpen:M==null?void 0:M.onOpen,onError:z=>{var A;(A=M==null?void 0:M.onError)==null||A.call(M,z)},onGap:(M==null?void 0:M.onGap)??s,onConnectionError:z=>{var A;a==null||a(z),(A=M==null?void 0:M.onConnectionError)==null||A.call(M,z)},onAuthError:z=>{var A;l==null||l(z),(A=M==null?void 0:M.onAuthError)==null||A.call(M,z)},onHeartbeat:z=>{var A;try{c==null||c(z)}catch(F){console.warn("[useChatStreamingService] onHeartbeat handler failed",F)}try{(A=M==null?void 0:M.onHeartbeat)==null||A.call(M,z)}catch(F){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",F)}},onClosed:z=>{var G,B,D,V;const A=((G=h.current)==null?void 0:G.manualStop)??!1,F=f.current??((B=h.current)==null?void 0:B.threadIdGuess)??((D=z.lastStateHistory)==null?void 0:D.threadId)??null;(z.reason==="complete"||z.reason==="aborted"&&A)&&g(F);const R={...z,threadId:F,threadInfo:x.current,manualStop:A};try{i==null||i(R)}catch(Y){console.warn("[useChatStreamingService] onStreamClosed handler failed",Y)}try{(V=M==null?void 0:M.onClosed)==null||V.call(M,R)}catch(Y){console.warn("[useChatStreamingService] downstream onClosed handler failed",Y)}h.current&&(h.current=null)}})},[g,S,l,a,c,s,i,k]),L=w.useCallback(()=>{h.current&&(h.current.manualStop=!0),T()},[T]);return w.useMemo(()=>({startStream:_,stop:L,isStreaming:C,error:E,setAuthToken:N,replayBufferedEvents:b}),[_,L,C,E,N,b])}const lc=w.createContext(null),cc=w.createContext(null),uc=w.createContext(null);w.createContext(!1);function rx({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a}){const{api:l,baseUrl:c}=ui(),d=w.useMemo(()=>kn(c),[c]),[f,p]=w.useState([]),[h,x]=w.useState(t),[m,v]=w.useState(!1),[g,b]=w.useState(null),[S,k]=w.useState(!1),[T,C]=w.useState(null),{state:E,seed:N,prepend:_,pushUser:L,onEvent:j}=Ql(),[M,z]=w.useState(!1),[A,F]=w.useState(!1),[R,G]=w.useState(null),[B,D]=w.useState([]),[V,Y]=w.useState([]),[he,ae]=w.useState(!1),_e=w.useMemo(()=>B.flatMap(Q=>Q.messages??[]),[B]),X=w.useMemo(()=>Jl(_e),[_e]),H=w.useRef(h),J=w.useRef(null),$=w.useRef(null),K=w.useRef(null),re=w.useRef(null),oe=w.useRef(!1),se=w.useRef(null),Te=w.useRef(new Map),Ye=w.useRef(new Map);w.useEffect(()=>{H.current=h},[h]);const Le=w.useCallback(async()=>{v(!0),b(null);try{const Q=await l.listThreads();p(Q??[])}catch(Q){const te=String(Q);b(te),s==null||s(te)}finally{v(!1)}},[l,s]),Ge=w.useCallback(Q=>{if(!(Q!=null&&Q.threadId))return;const te={threadId:Q.threadId,title:Q.title||`Thread ${Q.threadId.slice(0,8)}`,createdAt:Q.createdAt||new Date().toISOString(),updatedAt:Q.updatedAt||new Date().toISOString(),messageCount:Q.messageCount??1};p(ve=>ve.some(Oe=>Oe.threadId===te.threadId)?(console.debug("[ChatSessionProvider] thread_info: thread already in list",te.threadId),ve):(console.debug("[ChatSessionProvider] thread_info: adding thread to list",te.threadId),[te,...ve]))},[]),de=w.useCallback(Q=>{const te=Q.threadId??H.current;if(!te||H.current&&H.current!==te)return;const{checkpoints:ve,timeline:Ce}=fr(Q);if(!ve.length)return;const Oe=ve.find(Xe=>Xe.messages&&Xe.messages.length>0)??ve.find(Xe=>!!Xe.checkpointId)??ve[0];N((Oe==null?void 0:Oe.messages)??[],{checkpointId:(Oe==null?void 0:Oe.checkpointId)??null,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??null}),Y(Ce),D(ve),z(!!(Oe!=null&&Oe.nextCursor)),G((Oe==null?void 0:Oe.nextCursor)??null),se.current=`${te}:latest`,$.current=null,K.current=null},[N]),be=w.useCallback(Q=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Q.threadId),Ge(Q),H.current!==Q.threadId&&((Q.created??!H.current)&&($.current=Q.threadId),K.current=Q.threadId,console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),x(Q.threadId))},[Ge]),{startStream:ze,stop:Ue,isStreaming:We,error:nt,setAuthToken:$e}=nx({baseUrl:d,onThreadInfo:be,onMessageEvent:j,onStateHistory:de,onUnhandledEvent:Q=>{console.warn("[ChatSessionProvider] Unhandled event:",Q.type)},onAuthError:i}),Fe=w.useCallback(async Q=>{try{const te=await l.createThread(Q);return x(te.threadId),await Le(),te.threadId}catch(te){return s==null||s(String(te)),null}},[l,Le,s]),rt=w.useCallback(async Q=>{const te=f;p(Ce=>Ce.filter(Oe=>Oe.threadId!==Q));const ve=new AbortController;Ye.current.set(Q,ve);try{await l.deleteThread(Q),H.current===Q&&(x(null),N([],{})),console.log("[ChatSessionProvider] Thread deleted successfully:",Q)}catch(Ce){console.error("[ChatSessionProvider] Delete failed, restoring thread:",Q,Ce),p(te),s==null||s(`Failed to delete thread: ${String(Ce)}`)}finally{Ye.current.delete(Q)}},[f,l,N,s]),It=w.useCallback(async(Q,te)=>{try{await l.updateThread(Q,te),await Le()}catch(ve){s==null||s(String(ve))}},[l,Le,s]),dt=w.useCallback(async(Q,te)=>{if(!Q)return;const ve=`${Q}:${te??"latest"}`,Ce=Te.current.get(ve);if(Ce)return Ce;const Oe=(async()=>{const Xe=Q;k(!0),C(null);try{const Nt=await l.getStateHistory({threadId:Xe,checkpointId:te||void 0});if(H.current!==Xe){console.log(`[ChatSessionProvider] Thread changed during load (was ${Xe}, now ${H.current}), discarding stale data`);return}const{checkpoints:P,timeline:ue}=fr(Nt),q=P.find(we=>we.messages&&we.messages.length>0)??(te?P.find(we=>we.checkpointId===te):null)??P[0];N((q==null?void 0:q.messages)??[],{checkpointId:(q==null?void 0:q.checkpointId)??null,checkpointNs:(q==null?void 0:q.checkpointNs)??null}),Y(ue),D(P),z(!!(q!=null&&q.nextCursor)),G((q==null?void 0:q.nextCursor)??null)}catch(Nt){if(H.current===Xe){const P=String(Nt);C(P),s==null||s(P)}}finally{k(!1)}})();Te.current.set(ve,Oe);try{await Oe}finally{Te.current.delete(ve)}return H.current===Q&&(se.current=ve),Oe},[l,N,s]),ft=w.useCallback(async(Q,te)=>{re.current=Q;try{await dt(Q,te)}finally{re.current===Q&&(re.current=null)}},[dt]);w.useEffect(()=>{if(!o||!h||S||We)return;if($.current===h){$.current=null,J.current=h;return}if(K.current===h){J.current=h;return}if(re.current===h){re.current=null,J.current=h;return}if(J.current===h)return;J.current=h;const Q=!oe.current&&!!n&&h===t;let te;Q&&n?(te=n,oe.current=!0,console.log("[ChatSessionProvider] Loading thread with checkpoint:",te,r?`(ns: ${r})`:"")):console.log("[ChatSessionProvider] Loading thread with latest checkpoint");const ve=`${h}:${te??"latest"}`;se.current!==ve&&ft(h,te)},[o,h,n,r,t,S,We,ft]);const pt=w.useCallback(async(Q,te)=>{const ve=H.current;if(!ve)return;const Ce=ve;ae(!0);try{const Oe=await l.getStateHistory({threadId:Ce,checkpointId:Q,checkpointNs:te??void 0});if(H.current!==Ce){console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${Ce}, now ${H.current}), discarding stale data`);return}const{checkpoints:Xe,timeline:Nt}=fr(Oe),P=Xe.find(ue=>ue.checkpointId===Q&&(te?ue.checkpointNs===te:!0));if(!P){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:Q,checkpointNs:te});return}Y(Nt),D(Xe),N(P.messages??[],{checkpointId:P.checkpointId??null,checkpointNs:P.checkpointNs??null})}catch(Oe){H.current===Ce&&(s==null||s(String(Oe)))}finally{ae(!1)}},[l,N,s]),yt=w.useCallback((Q,te)=>{N(E.messages,{checkpointId:Q??null,checkpointNs:te??null})},[N,E.messages]),vt=w.useCallback(async()=>{H.current&&await ft(H.current)},[ft]),xt=w.useCallback(async()=>{if(!H.current||!R)return;const Q=H.current;F(!0);try{const te=await l.getStateHistory({threadId:Q,checkpointId:R});if(H.current!==Q){console.log(`[ChatSessionProvider] Thread changed during history load (was ${Q}, now ${H.current}), discarding stale data`);return}const{checkpoints:ve}=fr(te);if(ve.length>0){const Ce=ve[ve.length-1];_((Ce==null?void 0:Ce.messages)??[]),z(!!(Ce!=null&&Ce.nextCursor)),G((Ce==null?void 0:Ce.nextCursor)??null)}}catch(te){H.current===Q&&(s==null||s(String(te)))}finally{F(!1)}},[l,R,_,s]),Lt=w.useCallback(async()=>{N([],{}),x(null),Ue(),D([]),Y([]),z(!1),G(null),k(!1),ae(!1),F(!1),C(null);try{await l.getAgent("default")}catch(Q){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Q)}},[N,Ue,l]),Be=w.useCallback(async(Q,te,ve)=>{const Ce=H.current;if(!Ce)throw new Error("No active thread to handle interrupt");const Oe=te?ve??!0:!1;try{const Xe={threadId:Ce,checkpointId:E.lastCheckpointId??void 0,checkpointNs:E.lastCheckpointNs??void 0,command:{kind:"resume",value:Oe}};ze(Xe)}catch(Xe){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Q}:`,Xe),Xe}},[E.lastCheckpointId,E.lastCheckpointNs,ze]);w.useEffect(()=>{Le()},[Le]),w.useEffect(()=>{a==null||a(h)},[h,a]);const hn=w.useCallback(async(Q,te)=>{let ve=H.current;const Ce=(Q==null?void 0:Q.text)??"";if(!ve&&!Ce)return;if(!ve&&Ce){const ue=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),q=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);ve=`${ue}${q}`,$.current=ve,x(ve)}const{contentParts:Oe}=await Sg(l,(Q==null?void 0:Q.attachments)??[]),Xe=[...Oe];Ce!=null&&Ce.trim()&&Xe.push({type:"text",text:Ce});const Nt={id:`msg-${Date.now()}`,role:"user",content:Xe,createdAt:new Date().toISOString()};L(Nt);const P={threadId:ve,payload:{messages:[Nt]},checkpointId:(te==null?void 0:te.checkpointId)??E.lastCheckpointId??void 0,checkpointNs:(te==null?void 0:te.checkpointNs)??E.lastCheckpointNs??void 0};ze(P)},[l,Fe,L,E,ze]),st=w.useMemo(()=>({threads:f,currentThreadId:h,setCurrentThreadId:x,isLoading:m,error:g,actions:{createThread:Fe,deleteThread:rt,renameThread:It,refreshThreads:Le}}),[f,h,m,g,Fe,rt,It,Le]),Ze=w.useMemo(()=>({threadId:h,messages:E.messages,interrupt:null,checkpoint:{id:E.lastCheckpointId??null,namespace:E.lastCheckpointNs??null},checkpoints:B,timelineCheckpoints:V,metadata:null,isLoading:S,isHistoryLoading:A,isLoadingCheckpoint:he,error:T,hasMore:M,loadOlder:xt,clearState:Lt,navigateToCheckpoint:pt,setCurrentCheckpointId:yt,returnToLatest:vt,loadThread:ft,clearThread:Lt,respondToInterrupt:Be,messagePreviews:X}),[h,E,B,V,S,A,he,T,M,xt,Lt,pt,yt,vt,ft,Be,X]),wt=w.useMemo(()=>({isStreaming:We,error:nt,connectionState:We?"connected":"idle",submit:hn,send:hn,stop:Ue,setAuthToken:$e}),[We,nt,hn,Ue,$e]);return u.jsx(lc.Provider,{value:st,children:u.jsx(cc.Provider,{value:Ze,children:u.jsx(uc.Provider,{value:wt,children:e})})})}function jo(){const e=w.useContext(lc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Ro(){const e=w.useContext(cc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function dc(){const e=w.useContext(uc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Po({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l}){return u.jsx(bg,{apiConfig:t,children:u.jsx(rx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,children:e})})}function ee(...e){return qh.twMerge(Kh.clsx(e))}const ox=ho.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"}}),et=y.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Kn.Slot:"button";return u.jsx(i,{className:ee(ox({variant:t,size:n,className:e})),ref:s,...o})});et.displayName="Button";const fc=y.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ee("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}));fc.displayName="Textarea";function pc({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 x=i!==void 0,[m,v]=w.useState(e),g=(x?i:m)??"",[b,S]=w.useTransition(),k=w.useRef(null),T=w.useRef(0),C=w.useRef(null);w.useEffect(()=>{x||(v(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,x]);const E=w.useCallback(()=>{const F=k.current;F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},[]);w.useEffect(()=>{E()},[E,g]);const N=w.useCallback((F,{fromUser:R})=>{x||v(F),R&&(a==null||a(F))},[x,a]),_=w.useCallback(async F=>{F&&F.preventDefault();const R=(g??"").trim();if(!R&&!h)return;const G=++T.current;C.current={id:G,shouldClear:!0},S(()=>{var B,D,V;try{const Y=l(R);Y&&typeof Y.then=="function"?Y.then(()=>{var he,ae;((he=C.current)==null?void 0:he.id)===G&&C.current.shouldClear&&(x||(v(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ae=C.current)==null?void 0:ae.id)===G&&(C.current=null)}).catch(()=>{var he;((he=C.current)==null?void 0:he.id)===G&&(C.current=null)}):(((B=C.current)==null?void 0:B.id)===G&&C.current.shouldClear&&(x||(v(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((D=C.current)==null?void 0:D.id)===G&&(C.current=null))}catch{((V=C.current)==null?void 0:V.id)===G&&(C.current=null)}})},[g,l,h,x,a]),L=w.useCallback(F=>{const R=F.target.value;N(R,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[N]),j=w.useCallback(F=>{F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),_()):F.key==="Escape"&&t&&(F.preventDefault(),c==null||c())},[_,t,c]),A=`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:F=>void _(F),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(fc,{ref:k,value:g,onChange:L,onKeyDown:j,placeholder:t?"Edit your message...":n,className:A,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(et,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ce.Square,{size:16})}):u.jsx(et,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!h||b,children:u.jsx(ce.Send,{size:16})})})]})})}const sx=w.memo(pc);function me(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 hc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=hc(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():hc(e[o],null)}}}}function Ke(...e){return y.useCallback(gi(...e),e)}function ix(e,t){const n=y.createContext(t),r=s=>{const{children:i,...a}=s,l=y.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=y.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 En(e,t=[]){let n=[];function r(s,i){const a=y.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:p,children:h,...x}=f,m=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,v=y.useMemo(()=>x,Object.values(x));return u.jsx(m.Provider,{value:v,children:h})};c.displayName=s+"Provider";function d(f,p){var m;const h=((m=p==null?void 0:p[e])==null?void 0:m[l])||a,x=y.useContext(h);if(x)return x;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=>y.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return y.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,ax(o,...t)]}function ax(...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 y.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var jt=globalThis!=null&&globalThis.document?y.useLayoutEffect:()=>{},lx=y[" useInsertionEffect ".trim().toString()]||jt;function hr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=cx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=y.useRef(e!==void 0);y.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=y.useCallback(d=>{var f;if(a){const p=ux(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 cx({defaultProp:e,onChange:t}){const[n,r]=y.useState(e),o=y.useRef(n),s=y.useRef(t);return lx(()=>{s.current=t},[t]),y.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function ux(e){return typeof e=="function"}var dx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Re=dx.reduce((e,t)=>{const n=Kn.createSlot(`Primitive.${t}`),r=y.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 mc(e,t){e&&mo.flushSync(()=>e.dispatchEvent(t))}function xi(e){const t=e+"CollectionProvider",[n,r]=En(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:v,children:g}=m,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:v,itemMap:S,collectionRef:b,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Kn.createSlot(a),c=w.forwardRef((m,v)=>{const{scope:g,children:b}=m,S=s(a,g),k=Ke(v,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Kn.createSlot(d),h=w.forwardRef((m,v)=>{const{scope:g,children:b,...S}=m,k=w.useRef(null),T=Ke(v,k),C=s(d,g);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(p,{[f]:"",ref:T,children:b})});h.displayName=d;function x(m){const v=s(e+"CollectionConsumer",m);return w.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},x,r]}var fx=y.createContext(void 0);function Oo(e){const t=y.useContext(fx);return e||t||"ltr"}function Rt(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e}),y.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function px(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e);y.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 hx="DismissableLayer",yi="dismissableLayer.update",mx="dismissableLayer.pointerDownOutside",gx="dismissableLayer.focusOutside",gc,xc=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Mo=y.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=y.useContext(xc),[d,f]=y.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=y.useState({}),x=Ke(t,E=>f(E)),m=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=m.indexOf(v),b=d?m.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=g,T=vx(E=>{const N=E.target,_=[...c.branches].some(L=>L.contains(N));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),C=bx(E=>{const N=E.target;[...c.branches].some(L=>L.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return px(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),y.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(gc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),yc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=gc)}},[d,p,n,c]),y.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),yc())},[d,c]),y.useEffect(()=>{const E=()=>h({});return document.addEventListener(yi,E),()=>document.removeEventListener(yi,E)},[]),u.jsx(Re.div,{...l,ref:x,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,C.onFocusCapture),onBlurCapture:me(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,T.onPointerDownCapture)})});Mo.displayName=hx;var xx="DismissableLayerBranch",yx=y.forwardRef((e,t)=>{const n=y.useContext(xc),r=y.useRef(null),o=Ke(t,r);return y.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(Re.div,{...e,ref:o})});yx.displayName=xx;function vx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=y.useRef(!1),o=y.useRef(()=>{});return y.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){vc(mx,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 bx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=y.useRef(!1);return y.useEffect(()=>{const o=s=>{s.target&&!r.current&&vc(gx,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 yc(){const e=new CustomEvent(yi);document.dispatchEvent(e)}function vc(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?mc(o,s):o.dispatchEvent(s)}var vi=0;function bi(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??bc()),document.body.insertAdjacentElement("beforeend",e[1]??bc()),vi++,()=>{vi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),vi--}},[])}function bc(){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 wi="focusScope.autoFocusOnMount",Si="focusScope.autoFocusOnUnmount",wc={bubbles:!1,cancelable:!0},wx="FocusScope",Do=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=y.useState(null),c=Rt(o),d=Rt(s),f=y.useRef(null),p=Ke(t,m=>l(m)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let m=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Pn(f.current,{select:!0})},v=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Pn(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Pn(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const b=new MutationObserver(g);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),b.disconnect()}}},[r,a,h.paused]),y.useEffect(()=>{if(a){Tc.add(h);const m=document.activeElement;if(!a.contains(m)){const g=new CustomEvent(wi,wc);a.addEventListener(wi,c),a.dispatchEvent(g),g.defaultPrevented||(Sx(Ix(Sc(a)),{select:!0}),document.activeElement===m&&Pn(a))}return()=>{a.removeEventListener(wi,c),setTimeout(()=>{const g=new CustomEvent(Si,wc);a.addEventListener(Si,d),a.dispatchEvent(g),g.defaultPrevented||Pn(m??document.body,{select:!0}),a.removeEventListener(Si,d),Tc.remove(h)},0)}}},[a,c,d,h]);const x=y.useCallback(m=>{if(!n&&!r||h.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,g=document.activeElement;if(v&&g){const b=m.currentTarget,[S,k]=Cx(b);S&&k?!m.shiftKey&&g===k?(m.preventDefault(),n&&Pn(S,{select:!0})):m.shiftKey&&g===S&&(m.preventDefault(),n&&Pn(k,{select:!0})):g===b&&m.preventDefault()}},[n,r,h.paused]);return u.jsx(Re.div,{tabIndex:-1,...i,ref:p,onKeyDown:x})});Do.displayName=wx;function Sx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function Cx(e){const t=Sc(e),n=Cc(t,e),r=Cc(t.reverse(),e);return[n,r]}function Sc(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 Cc(e,t){for(const n of e)if(!Tx(n,{upTo:t}))return n}function Tx(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 kx(e){return e instanceof HTMLInputElement&&"select"in e}function Pn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&kx(e)&&t&&e.select()}}var Tc=Ex();function Ex(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=kc(e,t),e.unshift(t)},remove(t){var n;e=kc(e,t),(n=e[0])==null||n.resume()}}}function kc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ix(e){return e.filter(t=>t.tagName!=="A")}var Nx=y[" useId ".trim().toString()]||(()=>{}),Ax=0;function In(e){const[t,n]=y.useState(Nx());return jt(()=>{n(r=>r??String(Ax++))},[e]),t?`radix-${t}`:""}const _x=["top","right","bottom","left"],On=Math.min,qt=Math.max,Lo=Math.round,$o=Math.floor,gn=e=>({x:e,y:e}),jx={left:"right",right:"left",bottom:"top",top:"bottom"},Rx={start:"end",end:"start"};function Ci(e,t,n){return qt(e,On(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function mr(e){return e.split("-")[1]}function Ti(e){return e==="x"?"y":"x"}function ki(e){return e==="y"?"height":"width"}const Px=new Set(["top","bottom"]);function xn(e){return Px.has(An(e))?"y":"x"}function Ei(e){return Ti(xn(e))}function Ox(e,t,n){n===void 0&&(n=!1);const r=mr(e),o=Ei(e),s=ki(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Fo(i)),[i,Fo(i)]}function Mx(e){const t=Fo(e);return[Ii(e),t,Ii(t)]}function Ii(e){return e.replace(/start|end/g,t=>Rx[t])}const Ec=["left","right"],Ic=["right","left"],Dx=["top","bottom"],Lx=["bottom","top"];function $x(e,t,n){switch(e){case"top":case"bottom":return n?t?Ic:Ec:t?Ec:Ic;case"left":case"right":return t?Dx:Lx;default:return[]}}function Fx(e,t,n,r){const o=mr(e);let s=$x(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ii)))),s}function Fo(e){return e.replace(/left|right|bottom|top/g,t=>jx[t])}function zx(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nc(e){return typeof e!="number"?zx(e):{top:e,right:e,bottom:e,left:e}}function zo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ac(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Ei(t),a=ki(i),l=An(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(mr(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const Bx=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}=Ac(c,r,l),p=r,h={},x=0;for(let m=0;m<a.length;m++){const{name:v,fn:g}=a[m],{x:b,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=b??d,f=S??f,h={...h,[v]:{...h[v],...k}},T&&x<=50&&(x++,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}=Ac(c,p,l)),m=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:h}};async function Fr(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}=Nn(t,e),x=Nc(h),v=a[p?f==="floating"?"reference":"floating":f],g=zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(g.top-T.top+x.top)/k.y,bottom:(T.bottom-g.bottom+x.bottom)/k.y,left:(g.left-T.left+x.left)/k.x,right:(T.right-g.right+x.right)/k.x}}const Hx=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=Nn(e,t)||{};if(c==null)return{};const f=Nc(d),p={x:n,y:r},h=Ei(o),x=ki(h),m=await i.getDimensions(c),v=h==="y",g=v?"top":"left",b=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[h]-p[h]-s.floating[x],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[x]);const N=k/2-T/2,_=E/2-m[x]/2-1,L=On(f[g],_),j=On(f[b],_),M=L,z=E-m[x]-j,A=E/2-m[x]/2+N,F=Ci(M,A,z),R=!l.arrow&&mr(o)!=null&&A!==F&&s.reference[x]/2-(A<M?L:j)-m[x]/2<0,G=R?A<M?A-M:A-z:0;return{[h]:p[h]+G,data:{[h]:F,centerOffset:A-F-G,...R&&{alignmentOffset:G}},reset:R}}}),Ux=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:x="none",flipAlignment:m=!0,...v}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=An(o),b=xn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(S||!m?[Fo(a)]:Mx(a)),C=x!=="none";!p&&C&&T.push(...Fx(a,m,x,k));const E=[a,...T],N=await Fr(t,v),_=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(N[g]),f){const A=Ox(o,i,k);_.push(N[A[0]],N[A[1]])}if(L=[...L,{placement:o,overflows:_}],!_.every(A=>A<=0)){var j,M;const A=(((j=s.flip)==null?void 0:j.index)||0)+1,F=E[A];if(F&&(!(f==="alignment"?b!==xn(F):!1)||L.every(B=>xn(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:A,overflows:L},reset:{placement:F}};let R=(M=L.filter(G=>G.overflows[0]<=0).sort((G,B)=>G.overflows[1]-B.overflows[1])[0])==null?void 0:M.placement;if(!R)switch(h){case"bestFit":{var z;const G=(z=L.filter(B=>{if(C){const D=xn(B.placement);return D===b||D==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(D=>D>0).reduce((D,V)=>D+V,0)]).sort((B,D)=>B[1]-D[1])[0])==null?void 0:z[0];G&&(R=G);break}case"initialPlacement":R=a;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function _c(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jc(e){return _x.some(t=>e[t]>=0)}const Wx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await Fr(t,{...o,elementContext:"reference"}),i=_c(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:jc(i)}}}case"escaped":{const s=await Fr(t,{...o,altBoundary:!0}),i=_c(s,n.floating);return{data:{escapedOffsets:i,escaped:jc(i)}}}default:return{}}}}},Rc=new Set(["left","top"]);async function Vx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=mr(n),l=xn(n)==="y",c=Rc.has(i)?-1:1,d=s&&l?-1:1,f=Nn(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(h=a==="end"?x*-1:x),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const Kx=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 Vx(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}}}}},qx=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:v=>{let{x:g,y:b}=v;return{x:g,y:b}}},...l}=Nn(e,t),c={x:n,y:r},d=await Fr(t,l),f=xn(An(o)),p=Ti(f);let h=c[p],x=c[f];if(s){const v=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[v],S=h-d[g];h=Ci(b,h,S)}if(i){const v=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=x+d[v],S=x-d[g];x=Ci(b,x,S)}const m=a.fn({...t,[p]:h,[f]:x});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[p]:s,[f]:i}}}}}},Gx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Nn(e,t),d={x:n,y:r},f=xn(o),p=Ti(f);let h=d[p],x=d[f];const m=Nn(a,t),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+v.mainAxis,T=s.reference[p]+s.reference[S]-v.mainAxis;h<k?h=k:h>T&&(h=T)}if(c){var g,b;const S=p==="y"?"width":"height",k=Rc.has(An(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:v.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?v.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[p]:h,[f]:x}}}},Yx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Nn(e,t),d=await Fr(t,c),f=An(o),p=mr(o),h=xn(o)==="y",{width:x,height:m}=s.floating;let v,g;f==="top"||f==="bottom"?(v=f,g=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,v=p==="end"?"top":"bottom");const b=m-d.top-d.bottom,S=x-d.left-d.right,k=On(m-d[v],b),T=On(x-d[g],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!p){const L=qt(d.left,0),j=qt(d.right,0),M=qt(d.top,0),z=qt(d.bottom,0);h?N=x-2*(L!==0||j!==0?L+j:qt(d.left,d.right)):E=m-2*(M!==0||z!==0?M+z:qt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const _=await i.getDimensions(a.floating);return x!==_.width||m!==_.height?{reset:{rects:!0}}:{}}}};function Bo(){return typeof window<"u"}function gr(e){return Pc(e)?(e.nodeName||"").toLowerCase():"#document"}function Gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(Pc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Pc(e){return Bo()?e instanceof Node||e instanceof Gt(e).Node:!1}function ln(e){return Bo()?e instanceof Element||e instanceof Gt(e).Element:!1}function vn(e){return Bo()?e instanceof HTMLElement||e instanceof Gt(e).HTMLElement:!1}function Oc(e){return!Bo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Gt(e).ShadowRoot}const Xx=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Xx.has(o)}const Jx=new Set(["table","td","th"]);function Zx(e){return Jx.has(gr(e))}const Qx=[":popover-open",":modal"];function Ho(e){return Qx.some(t=>{try{return e.matches(t)}catch{return!1}})}const ey=["transform","translate","scale","rotate","perspective"],ty=["transform","translate","scale","rotate","perspective","filter"],ny=["paint","layout","strict","content"];function Ni(e){const t=Ai(),n=ln(e)?cn(e):e;return ey.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)||ty.some(r=>(n.willChange||"").includes(r))||ny.some(r=>(n.contain||"").includes(r))}function ry(e){let t=Mn(e);for(;vn(t)&&!xr(t);){if(Ni(t))return t;if(Ho(t))return null;t=Mn(t)}return null}function Ai(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const oy=new Set(["html","body","#document"]);function xr(e){return oy.has(gr(e))}function cn(e){return Gt(e).getComputedStyle(e)}function Uo(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Mn(e){if(gr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Oc(e)&&e.host||yn(e);return Oc(t)?t.host:t}function Mc(e){const t=Mn(e);return xr(t)?e.ownerDocument?e.ownerDocument.body:e.body:vn(t)&&zr(t)?t:Mc(t)}function Br(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Mc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Gt(o);if(s){const a=_i(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Br(a):[])}return t.concat(o,Br(o,[],n))}function _i(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Dc(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Lo(n)!==s||Lo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ji(e){return ln(e)?e:e.contextElement}function yr(e){const t=ji(e);if(!vn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Dc(t);let i=(s?Lo(n.width):n.width)/r,a=(s?Lo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const sy=gn(0);function Lc(e){const t=Gt(e);return!Ai()||!t.visualViewport?sy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function iy(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Gt(e)?!1:t}function Xn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ji(e);let i=gn(1);t&&(r?ln(r)&&(i=yr(r)):i=yr(e));const a=iy(s,n,r)?Lc(s):gn(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=Gt(s),h=r&&ln(r)?Gt(r):r;let x=p,m=_i(x);for(;m&&r&&h!==x;){const v=yr(m),g=m.getBoundingClientRect(),b=cn(m),S=g.left+(m.clientLeft+parseFloat(b.paddingLeft))*v.x,k=g.top+(m.clientTop+parseFloat(b.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,f*=v.y,l+=S,c+=k,x=Gt(m),m=_i(x)}}return zo({width:d,height:f,x:l,y:c})}function Wo(e,t){const n=Uo(e).scrollLeft;return t?t.left+n:Xn(yn(e)).left+n}function $c(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Wo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ay(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?Ho(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),f=vn(r);if((f||!f&&!s)&&((gr(r)!=="body"||zr(i))&&(l=Uo(r)),vn(r))){const h=Xn(r);c=yr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!s?$c(i,l):gn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function ly(e){return Array.from(e.getClientRects())}function cy(e){const t=yn(e),n=Uo(e),r=e.ownerDocument.body,o=qt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=qt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Wo(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=qt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Fc=25;function uy(e,t){const n=Gt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ai();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Wo(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,x=Math.abs(r.clientWidth-f.clientWidth-h);x<=Fc&&(s-=x)}else c<=Fc&&(s+=c);return{width:s,height:i,x:a,y:l}}const dy=new Set(["absolute","fixed"]);function fy(e,t){const n=Xn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vn(e)?yr(e):gn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function zc(e,t,n){let r;if(t==="viewport")r=uy(e,n);else if(t==="document")r=cy(yn(e));else if(ln(t))r=fy(t,n);else{const o=Lc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return zo(r)}function Bc(e,t){const n=Mn(e);return n===t||!ln(n)||xr(n)?!1:cn(n).position==="fixed"||Bc(n,t)}function py(e,t){const n=t.get(e);if(n)return n;let r=Br(e,[],!1).filter(a=>ln(a)&&gr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?Mn(e):e;for(;ln(i)&&!xr(i);){const a=cn(i),l=Ni(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&dy.has(o.position)||zr(i)&&!l&&Bc(e,i))?r=r.filter(d=>d!==i):o=a,i=Mn(i)}return t.set(e,r),r}function hy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ho(t)?[]:py(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=zc(t,d,o);return c.top=qt(f.top,c.top),c.right=On(f.right,c.right),c.bottom=On(f.bottom,c.bottom),c.left=qt(f.left,c.left),c},zc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function my(e){const{width:t,height:n}=Dc(e);return{width:t,height:n}}function gy(e,t,n){const r=vn(t),o=yn(t),s=n==="fixed",i=Xn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=Wo(o)}if(r||!r&&!s)if((gr(t)!=="body"||zr(o))&&(a=Uo(t)),r){const h=Xn(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?$c(o,a):gn(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 Ri(e){return cn(e).position==="static"}function Hc(e,t){if(!vn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function Uc(e,t){const n=Gt(e);if(Ho(e))return n;if(!vn(e)){let o=Mn(e);for(;o&&!xr(o);){if(ln(o)&&!Ri(o))return o;o=Mn(o)}return n}let r=Hc(e,t);for(;r&&Zx(r)&&Ri(r);)r=Hc(r,t);return r&&xr(r)&&Ri(r)&&!Ni(r)?n:r||ry(e)||n}const xy=async function(e){const t=this.getOffsetParent||Uc,n=this.getDimensions,r=await n(e.floating);return{reference:gy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yy(e){return cn(e).direction==="rtl"}const vy={convertOffsetParentRelativeRectToViewportRelativeRect:ay,getDocumentElement:yn,getClippingRect:hy,getOffsetParent:Uc,getElementRects:xy,getClientRects:ly,getDimensions:my,getScale:yr,isElement:ln,isRTL:yy};function Wc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function by(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=c;if(a||t(),!p||!h)return;const x=$o(f),m=$o(o.clientWidth-(d+p)),v=$o(o.clientHeight-(f+h)),g=$o(d),S={rootMargin:-x+"px "+-m+"px "+-v+"px "+-g+"px",threshold:qt(0,On(1,l))||1};let k=!0;function T(C){const E=C[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Wc(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 wy(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=ji(e),d=o||s?[...c?Br(c):[],...Br(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?by(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(g=>{let[b]=g;b&&b.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 x,m=l?Xn(e):null;l&&v();function v(){const g=Xn(e);m&&!Wc(m,g)&&n(),m=g,x=requestAnimationFrame(v)}return n(),()=>{var g;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(x)}}const Sy=Kx,Cy=qx,Ty=Ux,ky=Yx,Ey=Wx,Vc=Hx,Iy=Gx,Ny=(e,t,n)=>{const r=new Map,o={platform:vy,...n},s={...o.platform,_c:r};return Bx(e,t,{...o,platform:s})};var Ay=typeof document<"u",_y=function(){},Vo=Ay?w.useLayoutEffect:_y;function Ko(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(!Ko(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)&&!Ko(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Kc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qc(e,t){const n=Kc(e);return Math.round(t*n)/n}function Pi(e){const t=y.useRef(e);return Vo(()=>{t.current=e}),t}function jy(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]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=y.useState(r);Ko(p,r)||h(r);const[x,m]=y.useState(null),[v,g]=y.useState(null),b=y.useCallback(B=>{B!==C.current&&(C.current=B,m(B))},[]),S=y.useCallback(B=>{B!==E.current&&(E.current=B,g(B))},[]),k=s||x,T=i||v,C=y.useRef(null),E=y.useRef(null),N=y.useRef(d),_=l!=null,L=Pi(l),j=Pi(o),M=Pi(c),z=y.useCallback(()=>{if(!C.current||!E.current)return;const B={placement:t,strategy:n,middleware:p};j.current&&(B.platform=j.current),Ny(C.current,E.current,B).then(D=>{const V={...D,isPositioned:M.current!==!1};A.current&&!Ko(N.current,V)&&(N.current=V,mo.flushSync(()=>{f(V)}))})},[p,t,n,j,M]);Vo(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[c]);const A=y.useRef(!1);Vo(()=>(A.current=!0,()=>{A.current=!1}),[]),Vo(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(L.current)return L.current(k,T,z);z()}},[k,T,z,L,_]);const F=y.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),R=y.useMemo(()=>({reference:k,floating:T}),[k,T]),G=y.useMemo(()=>{const B={position:n,left:0,top:0};if(!R.floating)return B;const D=qc(R.floating,d.x),V=qc(R.floating,d.y);return a?{...B,transform:"translate("+D+"px, "+V+"px)",...Kc(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:V}},[n,a,R.floating,d.x,d.y]);return y.useMemo(()=>({...d,update:z,refs:F,elements:R,floatingStyles:G}),[d,z,F,R,G])}const Ry=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?Vc({element:r.current,padding:o}).fn(n):{}:r?Vc({element:r,padding:o}).fn(n):{}}}},Py=(e,t)=>({...Sy(e),options:[e,t]}),Oy=(e,t)=>({...Cy(e),options:[e,t]}),My=(e,t)=>({...Iy(e),options:[e,t]}),Dy=(e,t)=>({...Ty(e),options:[e,t]}),Ly=(e,t)=>({...ky(e),options:[e,t]}),$y=(e,t)=>({...Ey(e),options:[e,t]}),Fy=(e,t)=>({...Ry(e),options:[e,t]});var zy="Arrow",Gc=y.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(Re.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"})})});Gc.displayName=zy;var By=Gc;function Yc(e){const[t,n]=y.useState(void 0);return jt(()=>{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 Oi="Popper",[Xc,qo]=En(Oi),[Hy,Jc]=Xc(Oi),Zc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=y.useState(null);return u.jsx(Hy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Zc.displayName=Oi;var Qc="PopperAnchor",eu=y.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Jc(Qc,n),i=y.useRef(null),a=Ke(t,i),l=y.useRef(null);return y.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(Re.div,{...o,ref:a})});eu.displayName=Qc;var Mi="PopperContent",[Uy,Wy]=Xc(Mi),tu=y.forwardRef((e,t)=>{var J,$,K,re,oe,se;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:x,...m}=e,v=Jc(Mi,n),[g,b]=y.useState(null),S=Ke(t,Te=>b(Te)),[k,T]=y.useState(null),C=Yc(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,_=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},j=Array.isArray(c)?c:[c],M=j.length>0,z={padding:L,boundary:j.filter(Ky),altBoundary:M},{refs:A,floatingStyles:F,placement:R,isPositioned:G,middlewareData:B}=jy({strategy:"fixed",placement:_,whileElementsMounted:(...Te)=>wy(...Te,{animationFrame:h==="always"}),elements:{reference:v.anchor},middleware:[Py({mainAxis:o+N,alignmentAxis:i}),l&&Oy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?My():void 0,...z}),l&&Dy({...z}),Ly({...z,apply:({elements:Te,rects:Ye,availableWidth:Le,availableHeight:Ge})=>{const{width:de,height:be}=Ye.reference,ze=Te.floating.style;ze.setProperty("--radix-popper-available-width",`${Le}px`),ze.setProperty("--radix-popper-available-height",`${Ge}px`),ze.setProperty("--radix-popper-anchor-width",`${de}px`),ze.setProperty("--radix-popper-anchor-height",`${be}px`)}}),k&&Fy({element:k,padding:a}),qy({arrowWidth:E,arrowHeight:N}),p&&$y({strategy:"referenceHidden",...z})]}),[D,V]=ou(R),Y=Rt(x);jt(()=>{G&&(Y==null||Y())},[G,Y]);const he=(J=B.arrow)==null?void 0:J.x,ae=($=B.arrow)==null?void 0:$.y,_e=((K=B.arrow)==null?void 0:K.centerOffset)!==0,[X,H]=y.useState();return jt(()=>{g&&H(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:G?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(re=B.transformOrigin)==null?void 0:re.x,(oe=B.transformOrigin)==null?void 0:oe.y].join(" "),...((se=B.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Uy,{scope:n,placedSide:D,onArrowChange:T,arrowX:he,arrowY:ae,shouldHideArrow:_e,children:u.jsx(Re.div,{"data-side":D,"data-align":V,...m,ref:S,style:{...m.style,animation:G?void 0:"none"}})})})});tu.displayName=Mi;var nu="PopperArrow",Vy={top:"bottom",right:"left",bottom:"top",left:"right"},ru=y.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Wy(nu,r),i=Vy[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(By,{...o,ref:n,style:{...o.style,display:"block"}})})});ru.displayName=nu;function Ky(e){return e!==null}var qy=e=>({name:"transformOrigin",options:e,fn(t){var v,g,b;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=ou(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let x="",m="";return c==="bottom"?(x=i?f:`${p}px`,m=`${-l}px`):c==="top"?(x=i?f:`${p}px`,m=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,m=i?f:`${h}px`):c==="left"&&(x=`${r.floating.width+l}px`,m=i?f:`${h}px`),{data:{x,y:m}}}});function ou(e){const[t,n="center"]=e.split("-");return[t,n]}var su=Zc,iu=eu,au=tu,lu=ru,Gy="Portal",Go=y.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=y.useState(!1);jt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Gs.createPortal(u.jsx(Re.div,{...r,ref:t}),i):null});Go.displayName=Gy;function Yy(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var en=e=>{const{present:t,children:n}=e,r=Xy(t),o=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),s=Ke(r.ref,Jy(o));return typeof n=="function"||r.isPresent?y.cloneElement(o,{ref:s}):null};en.displayName="Presence";function Xy(e){const[t,n]=y.useState(),r=y.useRef(null),o=y.useRef(e),s=y.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Yy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const c=Yo(r.current);s.current=a==="mounted"?c:"none"},[a]),jt(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,h=Yo(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]),jt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const m=Yo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&m&&(l("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},p=h=>{h.target===t&&(s.current=Yo(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:y.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Yo(e){return(e==null?void 0:e.animationName)||"none"}function Jy(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 Di="rovingFocusGroup.onEntryFocus",Zy={bubbles:!1,cancelable:!0},Hr="RovingFocusGroup",[Li,cu,Qy]=xi(Hr),[ev,uu]=En(Hr,[Qy]),[tv,nv]=ev(Hr),du=y.forwardRef((e,t)=>u.jsx(Li.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Li.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(rv,{...e,ref:t})})}));du.displayName=Hr;var rv=y.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=y.useRef(null),h=Ke(t,p),x=Oo(s),[m,v]=hr({prop:i,defaultProp:a??null,onChange:l,caller:Hr}),[g,b]=y.useState(!1),S=Rt(c),k=cu(n),T=y.useRef(!1),[C,E]=y.useState(0);return y.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(Di,S),()=>N.removeEventListener(Di,S)},[S]),u.jsx(tv,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:m,onItemFocus:y.useCallback(N=>v(N),[v]),onItemShiftTab:y.useCallback(()=>b(!0),[]),onFocusableItemAdd:y.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:y.useCallback(()=>E(N=>N-1),[]),children:u.jsx(Re.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{T.current=!0}),onFocus:me(e.onFocus,N=>{const _=!T.current;if(N.target===N.currentTarget&&_&&!g){const L=new CustomEvent(Di,Zy);if(N.currentTarget.dispatchEvent(L),!L.defaultPrevented){const j=k().filter(R=>R.focusable),M=j.find(R=>R.active),z=j.find(R=>R.id===m),F=[M,z,...j].filter(Boolean).map(R=>R.ref.current);hu(F,d)}}T.current=!1}),onBlur:me(e.onBlur,()=>b(!1))})})}),fu="RovingFocusGroupItem",pu=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=In(),c=s||l,d=nv(fu,n),f=d.currentTabStopId===c,p=cu(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:m}=d;return y.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),u.jsx(Li.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(Re.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:me(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const g=iv(v,d.orientation,d.dir);if(g!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.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(v.currentTarget);S=d.loop?av(S,k+1):S.slice(k+1)}setTimeout(()=>hu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:m!=null}):i})})});pu.displayName=fu;var ov={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function sv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iv(e,t,n){const r=sv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ov[r]}function hu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function av(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var lv=du,cv=pu,uv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},vr=new WeakMap,Xo=new WeakMap,Jo={},$i=0,mu=function(e){return e&&(e.host||mu(e.parentNode))},dv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=mu(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})},fv=function(e,t,n,r){var o=dv(t,Array.isArray(e)?e:[e]);Jo[n]||(Jo[n]=new WeakMap);var s=Jo[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),x=h!==null&&h!=="false",m=(vr.get(p)||0)+1,v=(s.get(p)||0)+1;vr.set(p,m),s.set(p,v),i.push(p),m===1&&x&&Xo.set(p,!0),v===1&&p.setAttribute(n,"true"),x||p.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",p,g)}})};return d(t),a.clear(),$i++,function(){i.forEach(function(f){var p=vr.get(f)-1,h=s.get(f)-1;vr.set(f,p),s.set(f,h),p||(Xo.has(f)||f.removeAttribute(r),Xo.delete(f)),h||f.removeAttribute(n)}),$i--,$i||(vr=new WeakMap,vr=new WeakMap,Xo=new WeakMap,Jo={})}},Fi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=uv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),fv(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 gu(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 pv(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 Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",hv="with-scroll-bars-hidden",mv="--removed-body-scroll-bar-size";function zi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gv(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var xv=typeof window<"u"?y.useLayoutEffect:y.useEffect,xu=new WeakMap;function yv(e,t){var n=gv(null,function(r){return e.forEach(function(o){return zi(o,r)})});return xv(function(){var r=xu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||zi(a,null)}),s.forEach(function(a){o.has(a)||zi(a,i)})}xu.set(n,e)},[e]),n}function vv(e){return e}function bv(e,t){t===void 0&&(t=vv);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 wv(e){e===void 0&&(e={});var t=bv(null);return t.options=bn({async:!0,ssr:!1},e),t}var yu=function(e){var t=e.sideCar,n=gu(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 y.createElement(r,bn({},n))};yu.isSideCarExport=!0;function Sv(e,t){return e.useMedium(t),yu}var vu=wv(),Bi=function(){},es=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:Bi,onWheelCapture:Bi,onTouchMoveCapture:Bi}),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,x=e.noIsolation,m=e.inert,v=e.allowPinchZoom,g=e.as,b=g===void 0?"div":g,S=e.gapMode,k=gu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=p,C=yv([n,t]),E=bn(bn({},k),o);return y.createElement(y.Fragment,null,d&&y.createElement(T,{sideCar:vu,removeScrollBar:c,shards:f,noRelative:h,noIsolation:x,inert:m,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(a),bn(bn({},E),{ref:C})):y.createElement(b,bn({},E,{className:l,ref:C}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var Cv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Tv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Cv();return t&&e.setAttribute("nonce",t),e}function kv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ev(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Iv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Tv())&&(kv(t,n),Ev(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Nv=function(){var e=Iv();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bu=function(){var e=Nv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Av={left:0,top:0,right:0,gap:0},Hi=function(e){return parseInt(e||"",10)||0},_v=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[Hi(n),Hi(r),Hi(o)]},jv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Av;var t=_v(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])}},Rv=bu(),br="data-scroll-locked",Pv=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
- .`.concat(hv,` {
37
+ `))>=0;){const Pe=st.slice(0,Ce);st=st.slice(Ce+2);const Ge=Yg(Pe);if(!Ge)continue;let Nt;try{Nt=JSON.parse(Ge)}catch{console.debug("[use-chat] malformed SSE:",Ge.slice(0,200));continue}const P=Gg(Nt)?Nt.data:Nt;Lt=Date.now();const ue=P.seq;if(ue!==void 0){if(ue<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ue,lastProcessedSeq:ht,type:P.type});continue}ht>0&&ue>ht+1&&(($=R==null?void 0:R.onGap)==null||$.call(R,{from:ht,to:ue})),ht=ue,T.current=ue,v(ue)}if(console.debug("[use-chat] received event",{seq:P.seq,type:P.type,preview:(()=>{var q;try{return P.type==="message_delta"?{deltaTypes:(q=P.delta)==null?void 0:q.map(we=>we.type),textLen:(P.delta||[]).filter(we=>we.type==="text").map(we=>String(we.text||"").length)}:P.content||P.delta?{hasContent:!0}:{}}catch(we){return{err:String(we)}}})()}),P.type==="checkpoint")E.current=P.checkpointId??null,N.current=P.checkpointNs??null,x(P.checkpointId??null);else if(P.type==="state_history"){j.current=P;try{const we=dr(P).latest;we&&(E.current=we.checkpointId??null,N.current=we.checkpointNs??null,x(we.checkpointId??null))}catch(q){console.warn("[use-chat] Failed to hydrate state_history payload",q)}}try{F==null||F(P)}catch(q){console.error("[use-chat] Error in onEvent callback:",q,"for event:",P.type)}if(P.type==="token"&&e.autoAppendAssistant!==!1)pt.push(P.content),yt();else if(P.type==="message_delta"){const q=P.delta.filter(we=>we.type==="text").map(we=>we.text).join("");q&&e.autoAppendAssistant!==!1&&(pt.push(q),yt())}else if(P.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(K=R==null?void 0:R.onHeartbeat)==null||K.call(R,P)}catch(q){console.warn("[use-chat] heartbeat callback failed",q)}}else if(vt!==null&&cancelAnimationFrame(vt),xt(),P.type==="checkpoint")x(P.checkpointId);else if(P.type==="error"){const q=P;if(d(q.message),B="error",D=q.message,q.error_type==="auth_error"||q.code==="TOKEN_EXPIRED"||((re=q.message)==null?void 0:re.includes("token"))||((oe=q.message)==null?void 0:oe.includes("401"))||((se=q.message)==null?void 0:se.includes("unauthorized"))||((Te=q.message)==null?void 0:Te.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",q.message);try{(Je=R==null?void 0:R.onAuthError)==null||Je.call(R,q.message)}catch(kt){console.warn("[use-chat] onAuthError handler failed",kt)}G.abort()}}}}xt(),B===null&&!G.signal.aborted&&(B="complete")}catch(at){if(at.name==="AbortError")B=B??"aborted";else{const Qe=at.message||String(at);B="error",D=Qe,d(Qe),(De=R==null?void 0:R.onError)==null||De.call(R,Qe)}}finally{try{await ot.cancel()}catch{}finally{(Ye=ot.releaseLock)==null||Ye.call(ot)}vt!==null&&typeof window<"u"&&window.cancelAnimationFrame(vt),clearInterval(ze)}}catch(He){if(He.name==="AbortError")B=B??"aborted";else{const Ue=He.message||String(He);B="error",D=Ue,d(Ue),(de=R==null?void 0:R.onError)==null||de.call(R,Ue),V||((be=R==null?void 0:R.onConnectionError)==null||be.call(R,Ue),V=!0)}}finally{const He=T.current,Ue=E.current,rt=N.current,Le=j.current,$e=B??(G.signal.aborted?"aborted":D?"error":"complete");try{(Fe=R==null?void 0:R.onClosed)==null||Fe.call(R,{reason:$e,lastSeq:He,lastCheckpointId:Ue,lastCheckpointNs:rt,lastStateHistory:Le,error:D})}catch(ot){console.warn("[use-chat] onClosed callback failed",ot)}l(!1),b(!1),S.current=null,T.current=0,v(0),C.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var A;k.current=!1,(A=S.current)==null||A.abort()},[]),{isStreaming:a,error:c,assistantText:f,lastCheckpointId:h,lastSeq:m,connected:g,stream:z,stop:M,clear:_,setToken:L}}function Gg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Yg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
+ `)}function Xg(e){return e.type!=="token"}const Jg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function Zg(e,t){var n;switch(t.type){case"reset":return{messages:fi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};case"seed":{const r=fi(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=fi(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 ec(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ec(o,s),e):e}case"interrupt_response":return{...e,messages:tc(e.messages),pendingInterrupt:null};default:return e}}function Ql(e=[]){const[t,n]=w.useReducer(Zg,{...Jg,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,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 ec(e,t){var n,r,o,s,i;if(t.type==="message_start"&&t.role==="assistant"){const a=t.id,l=nx(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??nc(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:sc(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:x,newMeta:m,changed:v}=Qg(d.content,t.delta,p,h);if(!v)return e;const g={...d,content:x},b=Ao(l,c,g),S={...f,[a]:m};return{...e,messages:b,messagesStreamMeta:S}}if(t.type==="message_end"){const a=e.assemblingId??nc(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=rc(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=oc(e,d,c),p=f>=0?e.messages[f]:null,h=l??d[0]??`${c}-${Date.now()}`,x=(p==null?void 0:p.id)??`tool-${h}`,m=d[0]??h,v={type:"tool_call",id:m,name:c,args:t.args};if(p){const S=hi(p,d,c,t.args),k={...p,name:p.name??c,additionalKwargs:S},T=f,C=T>=0?Ao(e.messages,T,k):e.messages,E=_o(k,d),N=mi(e.toolIndex,x,E);return{...e,messages:C,toolIndex:N}}const g={id:x,role:"tool",name:c,createdAt:new Date().toISOString(),content:[v],additionalKwargs:hi(void 0,d.length?d:[m],c,t.args)},b=_o(g,d.length?d:[m]);return{...e,messages:[...e.messages,g],toolIndex:mi(e.toolIndex,x,b)}}if(t.type==="tool_end"){const a=rc(t);if(!a.length&&!(typeof t.id=="string"&&t.id))return e;const l=t.name??null,c=oc(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}`,x=_o(d,a);let m=t.output;if(typeof t.output=="string")try{const E=t.output.trim();(E.startsWith("{")||E.startsWith("["))&&(m=JSON.parse(E))}catch{m=t.output}const v=t.artifact??(d==null?void 0:d.artifact),g={type:"text",text:typeof m=="string"?m:JSON.stringify(m)},b=(d==null?void 0:d.createdAt)??new Date().toISOString(),S=hi(d??void 0,x.length?x:a,f),k={id:h,role:"tool",name:f??(d==null?void 0:d.name)??"tool",content:[g],createdAt:b,artifact:v??void 0,additionalKwargs:S},T=c>=0?Ao(e.messages,c,k):[...e.messages,k],C=_o(k,a.length?a:x);return{...e,messages:T,toolIndex:mi(e.toolIndex,h,C)}}if(t.type==="checkpoint"){const a=t.checkpointNs??e.lastCheckpointNs??null,l=tx(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=dr(t),l=a.interrupt,c=a.latest,d=l===null?tc(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 t.type==="thread_info",e}function fi(e){return e.filter(t=>{var s;if(t.role!=="assistant")return!0;const n=(t.content||[]).some(i=>{var a;return i&&i.type==="text"&&((a=i.text)==null?void 0:a.trim())}),r=(t.content||[]).some(i=>i&&i.type==="image_url"),o=!!((s=t.artifact)!=null&&s.plots&&t.artifact.plots.length>0);return!!(n||r||o)})}function Ao(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function tc(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 nc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function rc(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 pi(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 hi(e,t,n,r){const o=new Set,s=l=>{typeof l=="string"&&l.trim()&&o.add(l.trim())};if(e){const l=pi(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 _o(e,t){const n=new Set;for(const o of t)typeof o=="string"&&o.trim()&&n.add(o.trim());const r=pi(e);for(const o of r)n.add(o);return Array.from(n)}function mi(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 oc(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(pi(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 sc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Qg(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??sc(e);let l="",c=e.slice();if(s){const f=ex(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??"",x={...p,text:h+l};c=[...c.slice(0,c.length-1),x]}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 ic(e){return e.replace(/\s+/g," ").trim()}function ex(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=ic(e),o=ic(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 tx(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 Ao(e,r,s)}return e}function nx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const ac=200;function rx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:c}){const d=w.useRef(null),f=w.useRef(null),p=w.useRef(new Map),h=w.useRef(null),x=w.useRef(null),m=w.useCallback(_=>{try{const M=globalThis.structuredClone;if(typeof M=="function")return M(_)}catch{}try{return JSON.parse(JSON.stringify(_))}catch{return _}},[]),v=w.useCallback((_,M)=>{if(!_)return;const z=p.current.get(_)??[],A=m(M),F=z.length>=ac?[...z.slice(z.length-ac+1),A]:[...z,A];p.current.set(_,F)},[m]),g=w.useCallback(_=>{_&&p.current.set(_,[])},[]),b=w.useCallback(_=>{const M=_??f.current;if(!M)return;const z=p.current.get(M);z!=null&&z.length&&z.forEach(A=>{try{n(A)}catch(F){console.error("[useChatStreamingService] Failed to replay buffered event",F)}})},[n]),S=w.useCallback(_=>{var A,F,R,G,B;const M=_.seq??null;if(M!==null){const D=d.current;if(D!==null){if(M<=D)return;M>D+1&&(s==null||s({from:D,to:M}))}d.current=M}if(_.type==="thread_info"){f.current=_.threadId,h.current&&(h.current.threadIdGuess=_.threadId),x.current=_,g(_.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",_);try{t(_)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}return}if(_.type==="heartbeat"){try{c==null||c(_)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}return}if(_.type==="error"){const D=_;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((A=D.message)==null?void 0:A.includes("token"))||((F=D.message)==null?void 0:F.includes("401"))||((R=D.message)==null?void 0:R.includes("unauthorized"))||((G=D.message)==null?void 0:G.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{l==null||l(D.message)}catch(Y){console.warn("[useChatStreamingService] onAuthError handler failed",Y)}}}const z=_.threadId??(_.type==="state_history"?_.threadId:void 0)??f.current??((B=h.current)==null?void 0:B.threadIdGuess)??null;if(_.type==="state_history"){f.current=z??f.current;try{r==null||r(_)}catch(D){console.error("[useChatStreamingService] onStateHistory handler failed",D)}}if(Xg(_)){_.type==="checkpoint"||_.type==="state_history"?g(z??null):v(z??null,_);try{n(_)}catch(D){console.error("[useChatStreamingService] Error in onMessageEvent handler:",D)}return}try{o==null||o(_)}catch(D){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",D)}},[v,g,n,s,t,r,o]),{stream:k,stop:T,isStreaming:C,error:E,setToken:N}=Zl({baseUrl:e,token:void 0}),j=w.useCallback((_,M)=>{d.current=null,x.current=null,f.current=_.threadId??null,h.current={request:_,callbacks:M,manualStop:!1,threadIdGuess:_.threadId??null},k(_,S,{onOpen:M==null?void 0:M.onOpen,onError:z=>{var A;(A=M==null?void 0:M.onError)==null||A.call(M,z)},onGap:(M==null?void 0:M.onGap)??s,onConnectionError:z=>{var A;a==null||a(z),(A=M==null?void 0:M.onConnectionError)==null||A.call(M,z)},onAuthError:z=>{var A;l==null||l(z),(A=M==null?void 0:M.onAuthError)==null||A.call(M,z)},onHeartbeat:z=>{var A;try{c==null||c(z)}catch(F){console.warn("[useChatStreamingService] onHeartbeat handler failed",F)}try{(A=M==null?void 0:M.onHeartbeat)==null||A.call(M,z)}catch(F){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",F)}},onClosed:z=>{var G,B,D,V;const A=((G=h.current)==null?void 0:G.manualStop)??!1,F=f.current??((B=h.current)==null?void 0:B.threadIdGuess)??((D=z.lastStateHistory)==null?void 0:D.threadId)??null;(z.reason==="complete"||z.reason==="aborted"&&A)&&g(F);const R={...z,threadId:F,threadInfo:x.current,manualStop:A};try{i==null||i(R)}catch(Y){console.warn("[useChatStreamingService] onStreamClosed handler failed",Y)}try{(V=M==null?void 0:M.onClosed)==null||V.call(M,R)}catch(Y){console.warn("[useChatStreamingService] downstream onClosed handler failed",Y)}h.current&&(h.current=null)}})},[g,S,l,a,c,s,i,k]),L=w.useCallback(()=>{h.current&&(h.current.manualStop=!0),T()},[T]);return w.useMemo(()=>({startStream:j,stop:L,isStreaming:C,error:E,setAuthToken:N,replayBufferedEvents:b}),[j,L,C,E,N,b])}const lc=w.createContext(null),cc=w.createContext(null),uc=w.createContext(null);w.createContext(!1);function ox({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a}){const{api:l,baseUrl:c}=ui(),d=w.useMemo(()=>kn(c),[c]),[f,p]=w.useState([]),[h,x]=w.useState(t),[m,v]=w.useState(!1),[g,b]=w.useState(null),[S,k]=w.useState(!1),[T,C]=w.useState(null),{state:E,seed:N,prepend:j,pushUser:L,onEvent:_}=Ql(),[M,z]=w.useState(!1),[A,F]=w.useState(!1),[R,G]=w.useState(null),[B,D]=w.useState([]),[V,Y]=w.useState([]),[he,ie]=w.useState(!1),Ae=w.useMemo(()=>B.flatMap(Q=>Q.messages??[]),[B]),X=w.useMemo(()=>Jl(Ae),[Ae]),H=w.useRef(h),J=w.useRef(null),$=w.useRef(null),K=w.useRef(null),re=w.useRef(null),oe=w.useRef(!1),se=w.useRef(null),Te=w.useRef(new Map),Je=w.useRef(new Map);w.useEffect(()=>{H.current=h},[h]);const De=w.useCallback(async()=>{v(!0),b(null);try{const Q=await l.listThreads();p(Q??[])}catch(Q){const te=String(Q);b(te),s==null||s(te)}finally{v(!1)}},[l,s]),Ye=w.useCallback(Q=>{if(!(Q!=null&&Q.threadId))return;const te={threadId:Q.threadId,title:Q.title||`Thread ${Q.threadId.slice(0,8)}`,createdAt:Q.createdAt||new Date().toISOString(),updatedAt:Q.updatedAt||new Date().toISOString(),messageCount:Q.messageCount??1};p(ve=>ve.some(Pe=>Pe.threadId===te.threadId)?(console.debug("[ChatSessionProvider] thread_info: thread already in list",te.threadId),ve):(console.debug("[ChatSessionProvider] thread_info: adding thread to list",te.threadId),[te,...ve]))},[]),de=w.useCallback(Q=>{const te=Q.threadId??H.current;if(!te||H.current&&H.current!==te)return;const{checkpoints:ve,timeline:Ce}=dr(Q);if(!ve.length)return;const Pe=ve.find(Ge=>Ge.messages&&Ge.messages.length>0)??ve.find(Ge=>!!Ge.checkpointId)??ve[0];N((Pe==null?void 0:Pe.messages)??[],{checkpointId:(Pe==null?void 0:Pe.checkpointId)??null,checkpointNs:(Pe==null?void 0:Pe.checkpointNs)??null}),Y(Ce),D(ve),z(!!(Pe!=null&&Pe.nextCursor)),G((Pe==null?void 0:Pe.nextCursor)??null),se.current=`${te}:latest`,$.current=null,K.current=null},[N]),be=w.useCallback(Q=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Q.threadId),Ye(Q),H.current!==Q.threadId&&((Q.created??!H.current)&&($.current=Q.threadId),K.current=Q.threadId,console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),x(Q.threadId))},[Ye]),{startStream:Fe,stop:He,isStreaming:Ue,error:rt,setAuthToken:Le}=rx({baseUrl:d,onThreadInfo:be,onMessageEvent:_,onStateHistory:de,onUnhandledEvent:Q=>{console.warn("[ChatSessionProvider] Unhandled event:",Q.type)},onAuthError:i}),$e=w.useCallback(async Q=>{try{const te=await l.createThread(Q);return x(te.threadId),await De(),te.threadId}catch(te){return s==null||s(String(te)),null}},[l,De,s]),ot=w.useCallback(async Q=>{const te=f;p(Ce=>Ce.filter(Pe=>Pe.threadId!==Q));const ve=new AbortController;Je.current.set(Q,ve);try{await l.deleteThread(Q),H.current===Q&&(x(null),N([],{})),console.log("[ChatSessionProvider] Thread deleted successfully:",Q)}catch(Ce){console.error("[ChatSessionProvider] Delete failed, restoring thread:",Q,Ce),p(te),s==null||s(`Failed to delete thread: ${String(Ce)}`)}finally{Je.current.delete(Q)}},[f,l,N,s]),It=w.useCallback(async(Q,te)=>{try{await l.updateThread(Q,te),await De()}catch(ve){s==null||s(String(ve))}},[l,De,s]),st=w.useCallback(async(Q,te)=>{if(!Q)return;const ve=`${Q}:${te??"latest"}`,Ce=Te.current.get(ve);if(Ce)return Ce;const Pe=(async()=>{const Ge=Q;k(!0),C(null);try{const Nt=await l.getStateHistory({threadId:Ge,checkpointId:te||void 0});if(H.current!==Ge){console.log(`[ChatSessionProvider] Thread changed during load (was ${Ge}, now ${H.current}), discarding stale data`);return}const{checkpoints:P,timeline:ue}=dr(Nt),q=P.find(we=>we.messages&&we.messages.length>0)??(te?P.find(we=>we.checkpointId===te):null)??P[0];N((q==null?void 0:q.messages)??[],{checkpointId:(q==null?void 0:q.checkpointId)??null,checkpointNs:(q==null?void 0:q.checkpointNs)??null}),Y(ue),D(P),z(!!(q!=null&&q.nextCursor)),G((q==null?void 0:q.nextCursor)??null)}catch(Nt){if(H.current===Ge){const P=String(Nt);C(P),s==null||s(P)}}finally{k(!1)}})();Te.current.set(ve,Pe);try{await Pe}finally{Te.current.delete(ve)}return H.current===Q&&(se.current=ve),Pe},[l,N,s]),pt=w.useCallback(async(Q,te)=>{re.current=Q;try{await st(Q,te)}finally{re.current===Q&&(re.current=null)}},[st]);w.useEffect(()=>{if(!o||!h||S||Ue)return;if($.current===h){$.current=null,J.current=h;return}if(K.current===h){J.current=h;return}if(re.current===h){re.current=null,J.current=h;return}if(J.current===h)return;J.current=h;const Q=!oe.current&&!!n&&h===t;let te;Q&&n?(te=n,oe.current=!0,console.log("[ChatSessionProvider] Loading thread with checkpoint:",te,r?`(ns: ${r})`:"")):console.log("[ChatSessionProvider] Loading thread with latest checkpoint");const ve=`${h}:${te??"latest"}`;se.current!==ve&&pt(h,te)},[o,h,n,r,t,S,Ue,pt]);const ht=w.useCallback(async(Q,te)=>{const ve=H.current;if(!ve)return;const Ce=ve;ie(!0);try{const Pe=await l.getStateHistory({threadId:Ce,checkpointId:Q,checkpointNs:te??void 0});if(H.current!==Ce){console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${Ce}, now ${H.current}), discarding stale data`);return}const{checkpoints:Ge,timeline:Nt}=dr(Pe),P=Ge.find(ue=>ue.checkpointId===Q&&(te?ue.checkpointNs===te:!0));if(!P){console.warn("[ChatSessionProvider] Requested checkpoint not found:",{checkpointId:Q,checkpointNs:te});return}Y(Nt),D(Ge),N(P.messages??[],{checkpointId:P.checkpointId??null,checkpointNs:P.checkpointNs??null})}catch(Pe){H.current===Ce&&(s==null||s(String(Pe)))}finally{ie(!1)}},[l,N,s]),vt=w.useCallback((Q,te)=>{N(E.messages,{checkpointId:Q??null,checkpointNs:te??null})},[N,E.messages]),xt=w.useCallback(async()=>{H.current&&await pt(H.current)},[pt]),yt=w.useCallback(async()=>{if(!H.current||!R)return;const Q=H.current;F(!0);try{const te=await l.getStateHistory({threadId:Q,checkpointId:R});if(H.current!==Q){console.log(`[ChatSessionProvider] Thread changed during history load (was ${Q}, now ${H.current}), discarding stale data`);return}const{checkpoints:ve}=dr(te);if(ve.length>0){const Ce=ve[ve.length-1];j((Ce==null?void 0:Ce.messages)??[]),z(!!(Ce!=null&&Ce.nextCursor)),G((Ce==null?void 0:Ce.nextCursor)??null)}}catch(te){H.current===Q&&(s==null||s(String(te)))}finally{F(!1)}},[l,R,j,s]),Lt=w.useCallback(async()=>{N([],{}),x(null),He(),D([]),Y([]),z(!1),G(null),k(!1),ie(!1),F(!1),C(null);try{await l.getAgent("default")}catch(Q){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Q)}},[N,He,l]),ze=w.useCallback(async(Q,te,ve)=>{const Ce=H.current;if(!Ce)throw new Error("No active thread to handle interrupt");const Pe=te?ve??!0:!1;try{const Ge={threadId:Ce,checkpointId:E.lastCheckpointId??void 0,checkpointNs:E.lastCheckpointNs??void 0,command:{kind:"resume",value:Pe}};Fe(Ge)}catch(Ge){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Q}:`,Ge),Ge}},[E.lastCheckpointId,E.lastCheckpointNs,Fe]);w.useEffect(()=>{De()},[De]),w.useEffect(()=>{a==null||a(h)},[h,a]);const hn=w.useCallback(async(Q,te)=>{let ve=H.current;const Ce=(Q==null?void 0:Q.text)??"";if(!ve&&!Ce)return;if(!ve&&Ce){const ue=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),q=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);ve=`${ue}${q}`,$.current=ve,x(ve)}const{contentParts:Pe}=await Cg(l,(Q==null?void 0:Q.attachments)??[]),Ge=[...Pe];Ce!=null&&Ce.trim()&&Ge.push({type:"text",text:Ce});const Nt={id:`msg-${Date.now()}`,role:"user",content:Ge,createdAt:new Date().toISOString()};L(Nt);const P={threadId:ve,payload:{messages:[Nt]},checkpointId:(te==null?void 0:te.checkpointId)??E.lastCheckpointId??void 0,checkpointNs:(te==null?void 0:te.checkpointNs)??E.lastCheckpointNs??void 0};Fe(P)},[l,$e,L,E,Fe]),at=w.useMemo(()=>({threads:f,currentThreadId:h,setCurrentThreadId:x,isLoading:m,error:g,actions:{createThread:$e,deleteThread:ot,renameThread:It,refreshThreads:De}}),[f,h,m,g,$e,ot,It,De]),Qe=w.useMemo(()=>({threadId:h,messages:E.messages,interrupt:null,checkpoint:{id:E.lastCheckpointId??null,namespace:E.lastCheckpointNs??null},checkpoints:B,timelineCheckpoints:V,metadata:null,isLoading:S,isHistoryLoading:A,isLoadingCheckpoint:he,error:T,hasMore:M,loadOlder:yt,clearState:Lt,navigateToCheckpoint:ht,setCurrentCheckpointId:vt,returnToLatest:xt,loadThread:pt,clearThread:Lt,respondToInterrupt:ze,messagePreviews:X}),[h,E,B,V,S,A,he,T,M,yt,Lt,ht,vt,xt,pt,ze,X]),wt=w.useMemo(()=>({isStreaming:Ue,error:rt,connectionState:Ue?"connected":"idle",submit:hn,send:hn,stop:He,setAuthToken:Le}),[Ue,rt,hn,He,Le]);return u.jsx(lc.Provider,{value:at,children:u.jsx(cc.Provider,{value:Qe,children:u.jsx(uc.Provider,{value:wt,children:e})})})}function jo(){const e=w.useContext(lc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Ro(){const e=w.useContext(cc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function dc(){const e=w.useContext(uc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Po({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onError:i,onAuthError:a,onThreadChange:l}){return u.jsx(wg,{apiConfig:t,children:u.jsx(ox,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:i,onAuthError:a,onThreadChange:l,children:e})})}function ee(...e){return Gh.twMerge(qh.clsx(e))}const sx=ho.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),tt=y.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vn.Slot:"button";return u.jsx(i,{className:ee(sx({variant:t,size:n,className:e})),ref:s,...o})});tt.displayName="Button";const fc=y.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ee("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}));fc.displayName="Textarea";function pc({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 x=i!==void 0,[m,v]=w.useState(e),g=(x?i:m)??"",[b,S]=w.useTransition(),k=w.useRef(null),T=w.useRef(0),C=w.useRef(null);w.useEffect(()=>{x||(v(e??""),C.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,x]);const E=w.useCallback(()=>{const F=k.current;F&&(F.style.height="auto",F.style.height=`${F.scrollHeight}px`)},[]);w.useEffect(()=>{E()},[E,g]);const N=w.useCallback((F,{fromUser:R})=>{x||v(F),R&&(a==null||a(F))},[x,a]),j=w.useCallback(async F=>{F&&F.preventDefault();const R=(g??"").trim();if(!R&&!h)return;const G=++T.current;C.current={id:G,shouldClear:!0},S(()=>{var B,D,V;try{const Y=l(R);Y&&typeof Y.then=="function"?Y.then(()=>{var he,ie;((he=C.current)==null?void 0:he.id)===G&&C.current.shouldClear&&(x||(v(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ie=C.current)==null?void 0:ie.id)===G&&(C.current=null)}).catch(()=>{var he;((he=C.current)==null?void 0:he.id)===G&&(C.current=null)}):(((B=C.current)==null?void 0:B.id)===G&&C.current.shouldClear&&(x||(v(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((D=C.current)==null?void 0:D.id)===G&&(C.current=null))}catch{((V=C.current)==null?void 0:V.id)===G&&(C.current=null)}})},[g,l,h,x,a]),L=w.useCallback(F=>{const R=F.target.value;N(R,{fromUser:!0}),C.current&&(C.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`)},[N]),_=w.useCallback(F=>{F.key==="Enter"&&!F.shiftKey?(F.preventDefault(),j()):F.key==="Escape"&&t&&(F.preventDefault(),c==null||c())},[j,t,c]),A=`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:F=>void j(F),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(fc,{ref:k,value:g,onChange:L,onKeyDown:_,placeholder:t?"Edit your message...":n,className:A,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(tt,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ce.Square,{size:16})}):u.jsx(tt,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!g.trim()&&!h||b,children:u.jsx(ce.Send,{size:16})})})]})})}const ix=w.memo(pc);function me(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 hc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=hc(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():hc(e[o],null)}}}}function Ke(...e){return y.useCallback(gi(...e),e)}function ax(e,t){const n=y.createContext(t),r=s=>{const{children:i,...a}=s,l=y.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=y.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 En(e,t=[]){let n=[];function r(s,i){const a=y.createContext(i),l=n.length;n=[...n,i];const c=f=>{var g;const{scope:p,children:h,...x}=f,m=((g=p==null?void 0:p[e])==null?void 0:g[l])||a,v=y.useMemo(()=>x,Object.values(x));return u.jsx(m.Provider,{value:v,children:h})};c.displayName=s+"Provider";function d(f,p){var m;const h=((m=p==null?void 0:p[e])==null?void 0:m[l])||a,x=y.useContext(h);if(x)return x;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=>y.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return y.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,lx(o,...t)]}function lx(...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 y.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var jt=globalThis!=null&&globalThis.document?y.useLayoutEffect:()=>{},cx=y[" useInsertionEffect ".trim().toString()]||jt;function pr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=ux({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=y.useRef(e!==void 0);y.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=y.useCallback(d=>{var f;if(a){const p=dx(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 ux({defaultProp:e,onChange:t}){const[n,r]=y.useState(e),o=y.useRef(n),s=y.useRef(t);return cx(()=>{s.current=t},[t]),y.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function dx(e){return typeof e=="function"}var fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=fx.reduce((e,t)=>{const n=Vn.createSlot(`Primitive.${t}`),r=y.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 mc(e,t){e&&mo.flushSync(()=>e.dispatchEvent(t))}function xi(e){const t=e+"CollectionProvider",[n,r]=En(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:v,children:g}=m,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:v,itemMap:S,collectionRef:b,children:g})};i.displayName=t;const a=e+"CollectionSlot",l=Vn.createSlot(a),c=w.forwardRef((m,v)=>{const{scope:g,children:b}=m,S=s(a,g),k=Ke(v,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Vn.createSlot(d),h=w.forwardRef((m,v)=>{const{scope:g,children:b,...S}=m,k=w.useRef(null),T=Ke(v,k),C=s(d,g);return w.useEffect(()=>(C.itemMap.set(k,{ref:k,...S}),()=>void C.itemMap.delete(k))),u.jsx(p,{[f]:"",ref:T,children:b})});h.displayName=d;function x(m){const v=s(e+"CollectionConsumer",m);return w.useCallback(()=>{const b=v.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},x,r]}var px=y.createContext(void 0);function Oo(e){const t=y.useContext(px);return e||t||"ltr"}function Rt(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e}),y.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function hx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e);y.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 mx="DismissableLayer",yi="dismissableLayer.update",gx="dismissableLayer.pointerDownOutside",xx="dismissableLayer.focusOutside",gc,xc=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Mo=y.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=y.useContext(xc),[d,f]=y.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=y.useState({}),x=Ke(t,E=>f(E)),m=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=m.indexOf(v),b=d?m.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=g,T=bx(E=>{const N=E.target,j=[...c.branches].some(L=>L.contains(N));!k||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},p),C=wx(E=>{const N=E.target;[...c.branches].some(L=>L.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},p);return hx(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},p),y.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(gc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),yc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=gc)}},[d,p,n,c]),y.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),yc())},[d,c]),y.useEffect(()=>{const E=()=>h({});return document.addEventListener(yi,E),()=>document.removeEventListener(yi,E)},[]),u.jsx(je.div,{...l,ref:x,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,C.onFocusCapture),onBlurCapture:me(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,T.onPointerDownCapture)})});Mo.displayName=mx;var yx="DismissableLayerBranch",vx=y.forwardRef((e,t)=>{const n=y.useContext(xc),r=y.useRef(null),o=Ke(t,r);return y.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(je.div,{...e,ref:o})});vx.displayName=yx;function bx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=y.useRef(!1),o=y.useRef(()=>{});return y.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){vc(gx,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 wx(e,t=globalThis==null?void 0:globalThis.document){const n=Rt(e),r=y.useRef(!1);return y.useEffect(()=>{const o=s=>{s.target&&!r.current&&vc(xx,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 yc(){const e=new CustomEvent(yi);document.dispatchEvent(e)}function vc(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?mc(o,s):o.dispatchEvent(s)}var vi=0;function bi(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??bc()),document.body.insertAdjacentElement("beforeend",e[1]??bc()),vi++,()=>{vi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),vi--}},[])}function bc(){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 wi="focusScope.autoFocusOnMount",Si="focusScope.autoFocusOnUnmount",wc={bubbles:!1,cancelable:!0},Sx="FocusScope",Do=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=y.useState(null),c=Rt(o),d=Rt(s),f=y.useRef(null),p=Ke(t,m=>l(m)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let m=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Rn(f.current,{select:!0})},v=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Rn(f.current,{select:!0}))},g=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Rn(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",v);const b=new MutationObserver(g);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",v),b.disconnect()}}},[r,a,h.paused]),y.useEffect(()=>{if(a){Tc.add(h);const m=document.activeElement;if(!a.contains(m)){const g=new CustomEvent(wi,wc);a.addEventListener(wi,c),a.dispatchEvent(g),g.defaultPrevented||(Cx(Nx(Sc(a)),{select:!0}),document.activeElement===m&&Rn(a))}return()=>{a.removeEventListener(wi,c),setTimeout(()=>{const g=new CustomEvent(Si,wc);a.addEventListener(Si,d),a.dispatchEvent(g),g.defaultPrevented||Rn(m??document.body,{select:!0}),a.removeEventListener(Si,d),Tc.remove(h)},0)}}},[a,c,d,h]);const x=y.useCallback(m=>{if(!n&&!r||h.paused)return;const v=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,g=document.activeElement;if(v&&g){const b=m.currentTarget,[S,k]=Tx(b);S&&k?!m.shiftKey&&g===k?(m.preventDefault(),n&&Rn(S,{select:!0})):m.shiftKey&&g===S&&(m.preventDefault(),n&&Rn(k,{select:!0})):g===b&&m.preventDefault()}},[n,r,h.paused]);return u.jsx(je.div,{tabIndex:-1,...i,ref:p,onKeyDown:x})});Do.displayName=Sx;function Cx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Rn(r,{select:t}),document.activeElement!==n)return}function Tx(e){const t=Sc(e),n=Cc(t,e),r=Cc(t.reverse(),e);return[n,r]}function Sc(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 Cc(e,t){for(const n of e)if(!kx(n,{upTo:t}))return n}function kx(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 Ex(e){return e instanceof HTMLInputElement&&"select"in e}function Rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ex(e)&&t&&e.select()}}var Tc=Ix();function Ix(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=kc(e,t),e.unshift(t)},remove(t){var n;e=kc(e,t),(n=e[0])==null||n.resume()}}}function kc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Nx(e){return e.filter(t=>t.tagName!=="A")}var Ax=y[" useId ".trim().toString()]||(()=>{}),_x=0;function In(e){const[t,n]=y.useState(Ax());return jt(()=>{n(r=>r??String(_x++))},[e]),t?`radix-${t}`:""}const jx=["top","right","bottom","left"],Pn=Math.min,qt=Math.max,Lo=Math.round,$o=Math.floor,gn=e=>({x:e,y:e}),Rx={left:"right",right:"left",bottom:"top",top:"bottom"},Px={start:"end",end:"start"};function Ci(e,t,n){return qt(e,Pn(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function Ti(e){return e==="x"?"y":"x"}function ki(e){return e==="y"?"height":"width"}const Ox=new Set(["top","bottom"]);function xn(e){return Ox.has(An(e))?"y":"x"}function Ei(e){return Ti(xn(e))}function Mx(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=Ei(e),s=ki(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Fo(i)),[i,Fo(i)]}function Dx(e){const t=Fo(e);return[Ii(e),t,Ii(t)]}function Ii(e){return e.replace(/start|end/g,t=>Px[t])}const Ec=["left","right"],Ic=["right","left"],Lx=["top","bottom"],$x=["bottom","top"];function Fx(e,t,n){switch(e){case"top":case"bottom":return n?t?Ic:Ec:t?Ec:Ic;case"left":case"right":return t?Lx:$x;default:return[]}}function zx(e,t,n,r){const o=hr(e);let s=Fx(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ii)))),s}function Fo(e){return e.replace(/left|right|bottom|top/g,t=>Rx[t])}function Bx(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nc(e){return typeof e!="number"?Bx(e):{top:e,right:e,bottom:e,left:e}}function zo(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ac(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Ei(t),a=ki(i),l=An(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(hr(t)){case"start":h[i]-=p*(n&&c?-1:1);break;case"end":h[i]+=p*(n&&c?-1:1);break}return h}const Hx=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}=Ac(c,r,l),p=r,h={},x=0;for(let m=0;m<a.length;m++){const{name:v,fn:g}=a[m],{x:b,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=b??d,f=S??f,h={...h,[v]:{...h[v],...k}},T&&x<=50&&(x++,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}=Ac(c,p,l)),m=-1)}return{x:d,y:f,placement:p,strategy:o,middlewareData:h}};async function $r(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}=Nn(t,e),x=Nc(h),v=a[p?f==="floating"?"reference":"floating":f],g=zo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},T=zo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(g.top-T.top+x.top)/k.y,bottom:(T.bottom-g.bottom+x.bottom)/k.y,left:(g.left-T.left+x.left)/k.x,right:(T.right-g.right+x.right)/k.x}}const Ux=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=Nn(e,t)||{};if(c==null)return{};const f=Nc(d),p={x:n,y:r},h=Ei(o),x=ki(h),m=await i.getDimensions(c),v=h==="y",g=v?"top":"left",b=v?"bottom":"right",S=v?"clientHeight":"clientWidth",k=s.reference[x]+s.reference[h]-p[h]-s.floating[x],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[x]);const N=k/2-T/2,j=E/2-m[x]/2-1,L=Pn(f[g],j),_=Pn(f[b],j),M=L,z=E-m[x]-_,A=E/2-m[x]/2+N,F=Ci(M,A,z),R=!l.arrow&&hr(o)!=null&&A!==F&&s.reference[x]/2-(A<M?L:_)-m[x]/2<0,G=R?A<M?A-M:A-z:0;return{[h]:p[h]+G,data:{[h]:F,centerOffset:A-F-G,...R&&{alignmentOffset:G}},reset:R}}}),Wx=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:x="none",flipAlignment:m=!0,...v}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const g=An(o),b=xn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=p||(S||!m?[Fo(a)]:Dx(a)),C=x!=="none";!p&&C&&T.push(...zx(a,m,x,k));const E=[a,...T],N=await $r(t,v),j=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(N[g]),f){const A=Mx(o,i,k);j.push(N[A[0]],N[A[1]])}if(L=[...L,{placement:o,overflows:j}],!j.every(A=>A<=0)){var _,M;const A=(((_=s.flip)==null?void 0:_.index)||0)+1,F=E[A];if(F&&(!(f==="alignment"?b!==xn(F):!1)||L.every(B=>xn(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:A,overflows:L},reset:{placement:F}};let R=(M=L.filter(G=>G.overflows[0]<=0).sort((G,B)=>G.overflows[1]-B.overflows[1])[0])==null?void 0:M.placement;if(!R)switch(h){case"bestFit":{var z;const G=(z=L.filter(B=>{if(C){const D=xn(B.placement);return D===b||D==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(D=>D>0).reduce((D,V)=>D+V,0)]).sort((B,D)=>B[1]-D[1])[0])==null?void 0:z[0];G&&(R=G);break}case"initialPlacement":R=a;break}if(o!==R)return{reset:{placement:R}}}return{}}}};function _c(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function jc(e){return jx.some(t=>e[t]>=0)}const Vx=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await $r(t,{...o,elementContext:"reference"}),i=_c(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:jc(i)}}}case"escaped":{const s=await $r(t,{...o,altBoundary:!0}),i=_c(s,n.floating);return{data:{escapedOffsets:i,escaped:jc(i)}}}default:return{}}}}},Rc=new Set(["left","top"]);async function Kx(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=hr(n),l=xn(n)==="y",c=Rc.has(i)?-1:1,d=s&&l?-1:1,f=Nn(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:x}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof x=="number"&&(h=a==="end"?x*-1:x),l?{x:h*d,y:p*c}:{x:p*c,y:h*d}}const qx=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 Kx(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}}}}},Gx=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:v=>{let{x:g,y:b}=v;return{x:g,y:b}}},...l}=Nn(e,t),c={x:n,y:r},d=await $r(t,l),f=xn(An(o)),p=Ti(f);let h=c[p],x=c[f];if(s){const v=p==="y"?"top":"left",g=p==="y"?"bottom":"right",b=h+d[v],S=h-d[g];h=Ci(b,h,S)}if(i){const v=f==="y"?"top":"left",g=f==="y"?"bottom":"right",b=x+d[v],S=x-d[g];x=Ci(b,x,S)}const m=a.fn({...t,[p]:h,[f]:x});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[p]:s,[f]:i}}}}}},Yx=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Nn(e,t),d={x:n,y:r},f=xn(o),p=Ti(f);let h=d[p],x=d[f];const m=Nn(a,t),v=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const S=p==="y"?"height":"width",k=s.reference[p]-s.floating[S]+v.mainAxis,T=s.reference[p]+s.reference[S]-v.mainAxis;h<k?h=k:h>T&&(h=T)}if(c){var g,b;const S=p==="y"?"width":"height",k=Rc.has(An(o)),T=s.reference[f]-s.floating[S]+(k&&((g=i.offset)==null?void 0:g[f])||0)+(k?0:v.crossAxis),C=s.reference[f]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?v.crossAxis:0);x<T?x=T:x>C&&(x=C)}return{[p]:h,[f]:x}}}},Xx=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Nn(e,t),d=await $r(t,c),f=An(o),p=hr(o),h=xn(o)==="y",{width:x,height:m}=s.floating;let v,g;f==="top"||f==="bottom"?(v=f,g=p===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(g=f,v=p==="end"?"top":"bottom");const b=m-d.top-d.bottom,S=x-d.left-d.right,k=Pn(m-d[v],b),T=Pn(x-d[g],S),C=!t.middlewareData.shift;let E=k,N=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),C&&!p){const L=qt(d.left,0),_=qt(d.right,0),M=qt(d.top,0),z=qt(d.bottom,0);h?N=x-2*(L!==0||_!==0?L+_:qt(d.left,d.right)):E=m-2*(M!==0||z!==0?M+z:qt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const j=await i.getDimensions(a.floating);return x!==j.width||m!==j.height?{reset:{rects:!0}}:{}}}};function Bo(){return typeof window<"u"}function mr(e){return Pc(e)?(e.nodeName||"").toLowerCase():"#document"}function Gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(Pc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Pc(e){return Bo()?e instanceof Node||e instanceof Gt(e).Node:!1}function ln(e){return Bo()?e instanceof Element||e instanceof Gt(e).Element:!1}function vn(e){return Bo()?e instanceof HTMLElement||e instanceof Gt(e).HTMLElement:!1}function Oc(e){return!Bo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Gt(e).ShadowRoot}const Jx=new Set(["inline","contents"]);function Fr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Jx.has(o)}const Zx=new Set(["table","td","th"]);function Qx(e){return Zx.has(mr(e))}const ey=[":popover-open",":modal"];function Ho(e){return ey.some(t=>{try{return e.matches(t)}catch{return!1}})}const ty=["transform","translate","scale","rotate","perspective"],ny=["transform","translate","scale","rotate","perspective","filter"],ry=["paint","layout","strict","content"];function Ni(e){const t=Ai(),n=ln(e)?cn(e):e;return ty.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)||ny.some(r=>(n.willChange||"").includes(r))||ry.some(r=>(n.contain||"").includes(r))}function oy(e){let t=On(e);for(;vn(t)&&!gr(t);){if(Ni(t))return t;if(Ho(t))return null;t=On(t)}return null}function Ai(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const sy=new Set(["html","body","#document"]);function gr(e){return sy.has(mr(e))}function cn(e){return Gt(e).getComputedStyle(e)}function Uo(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(mr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Oc(e)&&e.host||yn(e);return Oc(t)?t.host:t}function Mc(e){const t=On(e);return gr(t)?e.ownerDocument?e.ownerDocument.body:e.body:vn(t)&&Fr(t)?t:Mc(t)}function zr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Mc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Gt(o);if(s){const a=_i(i);return t.concat(i,i.visualViewport||[],Fr(o)?o:[],a&&n?zr(a):[])}return t.concat(o,zr(o,[],n))}function _i(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Dc(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Lo(n)!==s||Lo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ji(e){return ln(e)?e:e.contextElement}function xr(e){const t=ji(e);if(!vn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Dc(t);let i=(s?Lo(n.width):n.width)/r,a=(s?Lo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const iy=gn(0);function Lc(e){const t=Gt(e);return!Ai()||!t.visualViewport?iy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ay(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Gt(e)?!1:t}function Yn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ji(e);let i=gn(1);t&&(r?ln(r)&&(i=xr(r)):i=xr(e));const a=ay(s,n,r)?Lc(s):gn(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=Gt(s),h=r&&ln(r)?Gt(r):r;let x=p,m=_i(x);for(;m&&r&&h!==x;){const v=xr(m),g=m.getBoundingClientRect(),b=cn(m),S=g.left+(m.clientLeft+parseFloat(b.paddingLeft))*v.x,k=g.top+(m.clientTop+parseFloat(b.paddingTop))*v.y;l*=v.x,c*=v.y,d*=v.x,f*=v.y,l+=S,c+=k,x=Gt(m),m=_i(x)}}return zo({width:d,height:f,x:l,y:c})}function Wo(e,t){const n=Uo(e).scrollLeft;return t?t.left+n:Yn(yn(e)).left+n}function $c(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Wo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function ly(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?Ho(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),f=vn(r);if((f||!f&&!s)&&((mr(r)!=="body"||Fr(i))&&(l=Uo(r)),vn(r))){const h=Yn(r);c=xr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=i&&!f&&!s?$c(i,l):gn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-l.scrollTop*c.y+d.y+p.y}}function cy(e){return Array.from(e.getClientRects())}function uy(e){const t=yn(e),n=Uo(e),r=e.ownerDocument.body,o=qt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=qt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Wo(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=qt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Fc=25;function dy(e,t){const n=Gt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ai();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Wo(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,x=Math.abs(r.clientWidth-f.clientWidth-h);x<=Fc&&(s-=x)}else c<=Fc&&(s+=c);return{width:s,height:i,x:a,y:l}}const fy=new Set(["absolute","fixed"]);function py(e,t){const n=Yn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vn(e)?xr(e):gn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function zc(e,t,n){let r;if(t==="viewport")r=dy(e,n);else if(t==="document")r=uy(yn(e));else if(ln(t))r=py(t,n);else{const o=Lc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return zo(r)}function Bc(e,t){const n=On(e);return n===t||!ln(n)||gr(n)?!1:cn(n).position==="fixed"||Bc(n,t)}function hy(e,t){const n=t.get(e);if(n)return n;let r=zr(e,[],!1).filter(a=>ln(a)&&mr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?On(e):e;for(;ln(i)&&!gr(i);){const a=cn(i),l=Ni(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&fy.has(o.position)||Fr(i)&&!l&&Bc(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function my(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ho(t)?[]:hy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=zc(t,d,o);return c.top=qt(f.top,c.top),c.right=Pn(f.right,c.right),c.bottom=Pn(f.bottom,c.bottom),c.left=qt(f.left,c.left),c},zc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function gy(e){const{width:t,height:n}=Dc(e);return{width:t,height:n}}function xy(e,t,n){const r=vn(t),o=yn(t),s=n==="fixed",i=Yn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=Wo(o)}if(r||!r&&!s)if((mr(t)!=="body"||Fr(o))&&(a=Uo(t)),r){const h=Yn(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?$c(o,a):gn(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 Ri(e){return cn(e).position==="static"}function Hc(e,t){if(!vn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function Uc(e,t){const n=Gt(e);if(Ho(e))return n;if(!vn(e)){let o=On(e);for(;o&&!gr(o);){if(ln(o)&&!Ri(o))return o;o=On(o)}return n}let r=Hc(e,t);for(;r&&Qx(r)&&Ri(r);)r=Hc(r,t);return r&&gr(r)&&Ri(r)&&!Ni(r)?n:r||oy(e)||n}const yy=async function(e){const t=this.getOffsetParent||Uc,n=this.getDimensions,r=await n(e.floating);return{reference:xy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function vy(e){return cn(e).direction==="rtl"}const by={convertOffsetParentRelativeRectToViewportRelativeRect:ly,getDocumentElement:yn,getClippingRect:my,getOffsetParent:Uc,getElementRects:yy,getClientRects:cy,getDimensions:gy,getScale:xr,isElement:ln,isRTL:vy};function Wc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wy(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=c;if(a||t(),!p||!h)return;const x=$o(f),m=$o(o.clientWidth-(d+p)),v=$o(o.clientHeight-(f+h)),g=$o(d),S={rootMargin:-x+"px "+-m+"px "+-v+"px "+-g+"px",threshold:qt(0,Pn(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&&!Wc(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 Sy(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=ji(e),d=o||s?[...c?zr(c):[],...zr(t)]:[];d.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),s&&g.addEventListener("resize",n)});const f=c&&a?wy(c,n):null;let p=-1,h=null;i&&(h=new ResizeObserver(g=>{let[b]=g;b&&b.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 x,m=l?Yn(e):null;l&&v();function v(){const g=Yn(e);m&&!Wc(m,g)&&n(),m=g,x=requestAnimationFrame(v)}return n(),()=>{var g;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(x)}}const Cy=qx,Ty=Gx,ky=Wx,Ey=Xx,Iy=Vx,Vc=Ux,Ny=Yx,Ay=(e,t,n)=>{const r=new Map,o={platform:by,...n},s={...o.platform,_c:r};return Hx(e,t,{...o,platform:s})};var _y=typeof document<"u",jy=function(){},Vo=_y?w.useLayoutEffect:jy;function Ko(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(!Ko(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)&&!Ko(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Kc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qc(e,t){const n=Kc(e);return Math.round(t*n)/n}function Pi(e){const t=y.useRef(e);return Vo(()=>{t.current=e}),t}function Ry(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]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=y.useState(r);Ko(p,r)||h(r);const[x,m]=y.useState(null),[v,g]=y.useState(null),b=y.useCallback(B=>{B!==C.current&&(C.current=B,m(B))},[]),S=y.useCallback(B=>{B!==E.current&&(E.current=B,g(B))},[]),k=s||x,T=i||v,C=y.useRef(null),E=y.useRef(null),N=y.useRef(d),j=l!=null,L=Pi(l),_=Pi(o),M=Pi(c),z=y.useCallback(()=>{if(!C.current||!E.current)return;const B={placement:t,strategy:n,middleware:p};_.current&&(B.platform=_.current),Ay(C.current,E.current,B).then(D=>{const V={...D,isPositioned:M.current!==!1};A.current&&!Ko(N.current,V)&&(N.current=V,mo.flushSync(()=>{f(V)}))})},[p,t,n,_,M]);Vo(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[c]);const A=y.useRef(!1);Vo(()=>(A.current=!0,()=>{A.current=!1}),[]),Vo(()=>{if(k&&(C.current=k),T&&(E.current=T),k&&T){if(L.current)return L.current(k,T,z);z()}},[k,T,z,L,j]);const F=y.useMemo(()=>({reference:C,floating:E,setReference:b,setFloating:S}),[b,S]),R=y.useMemo(()=>({reference:k,floating:T}),[k,T]),G=y.useMemo(()=>{const B={position:n,left:0,top:0};if(!R.floating)return B;const D=qc(R.floating,d.x),V=qc(R.floating,d.y);return a?{...B,transform:"translate("+D+"px, "+V+"px)",...Kc(R.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:D,top:V}},[n,a,R.floating,d.x,d.y]);return y.useMemo(()=>({...d,update:z,refs:F,elements:R,floatingStyles:G}),[d,z,F,R,G])}const Py=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?Vc({element:r.current,padding:o}).fn(n):{}:r?Vc({element:r,padding:o}).fn(n):{}}}},Oy=(e,t)=>({...Cy(e),options:[e,t]}),My=(e,t)=>({...Ty(e),options:[e,t]}),Dy=(e,t)=>({...Ny(e),options:[e,t]}),Ly=(e,t)=>({...ky(e),options:[e,t]}),$y=(e,t)=>({...Ey(e),options:[e,t]}),Fy=(e,t)=>({...Iy(e),options:[e,t]}),zy=(e,t)=>({...Py(e),options:[e,t]});var By="Arrow",Gc=y.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(je.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"})})});Gc.displayName=By;var Hy=Gc;function Yc(e){const[t,n]=y.useState(void 0);return jt(()=>{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 Oi="Popper",[Xc,qo]=En(Oi),[Uy,Jc]=Xc(Oi),Zc=e=>{const{__scopePopper:t,children:n}=e,[r,o]=y.useState(null);return u.jsx(Uy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Zc.displayName=Oi;var Qc="PopperAnchor",eu=y.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Jc(Qc,n),i=y.useRef(null),a=Ke(t,i),l=y.useRef(null);return y.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(je.div,{...o,ref:a})});eu.displayName=Qc;var Mi="PopperContent",[Wy,Vy]=Xc(Mi),tu=y.forwardRef((e,t)=>{var J,$,K,re,oe,se;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:x,...m}=e,v=Jc(Mi,n),[g,b]=y.useState(null),S=Ke(t,Te=>b(Te)),[k,T]=y.useState(null),C=Yc(k),E=(C==null?void 0:C.width)??0,N=(C==null?void 0:C.height)??0,j=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},_=Array.isArray(c)?c:[c],M=_.length>0,z={padding:L,boundary:_.filter(qy),altBoundary:M},{refs:A,floatingStyles:F,placement:R,isPositioned:G,middlewareData:B}=Ry({strategy:"fixed",placement:j,whileElementsMounted:(...Te)=>Sy(...Te,{animationFrame:h==="always"}),elements:{reference:v.anchor},middleware:[Oy({mainAxis:o+N,alignmentAxis:i}),l&&My({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Dy():void 0,...z}),l&&Ly({...z}),$y({...z,apply:({elements:Te,rects:Je,availableWidth:De,availableHeight:Ye})=>{const{width:de,height:be}=Je.reference,Fe=Te.floating.style;Fe.setProperty("--radix-popper-available-width",`${De}px`),Fe.setProperty("--radix-popper-available-height",`${Ye}px`),Fe.setProperty("--radix-popper-anchor-width",`${de}px`),Fe.setProperty("--radix-popper-anchor-height",`${be}px`)}}),k&&zy({element:k,padding:a}),Gy({arrowWidth:E,arrowHeight:N}),p&&Fy({strategy:"referenceHidden",...z})]}),[D,V]=ou(R),Y=Rt(x);jt(()=>{G&&(Y==null||Y())},[G,Y]);const he=(J=B.arrow)==null?void 0:J.x,ie=($=B.arrow)==null?void 0:$.y,Ae=((K=B.arrow)==null?void 0:K.centerOffset)!==0,[X,H]=y.useState();return jt(()=>{g&&H(window.getComputedStyle(g).zIndex)},[g]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...F,transform:G?F.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(re=B.transformOrigin)==null?void 0:re.x,(oe=B.transformOrigin)==null?void 0:oe.y].join(" "),...((se=B.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Wy,{scope:n,placedSide:D,onArrowChange:T,arrowX:he,arrowY:ie,shouldHideArrow:Ae,children:u.jsx(je.div,{"data-side":D,"data-align":V,...m,ref:S,style:{...m.style,animation:G?void 0:"none"}})})})});tu.displayName=Mi;var nu="PopperArrow",Ky={top:"bottom",right:"left",bottom:"top",left:"right"},ru=y.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Vy(nu,r),i=Ky[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(Hy,{...o,ref:n,style:{...o.style,display:"block"}})})});ru.displayName=nu;function qy(e){return e!==null}var Gy=e=>({name:"transformOrigin",options:e,fn(t){var v,g,b;const{placement:n,rects:r,middlewareData:o}=t,i=((v=o.arrow)==null?void 0:v.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=ou(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((g=o.arrow)==null?void 0:g.x)??0)+a/2,h=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let x="",m="";return c==="bottom"?(x=i?f:`${p}px`,m=`${-l}px`):c==="top"?(x=i?f:`${p}px`,m=`${r.floating.height+l}px`):c==="right"?(x=`${-l}px`,m=i?f:`${h}px`):c==="left"&&(x=`${r.floating.width+l}px`,m=i?f:`${h}px`),{data:{x,y:m}}}});function ou(e){const[t,n="center"]=e.split("-");return[t,n]}var su=Zc,iu=eu,au=tu,lu=ru,Yy="Portal",Go=y.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=y.useState(!1);jt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Gs.createPortal(u.jsx(je.div,{...r,ref:t}),i):null});Go.displayName=Yy;function Xy(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var en=e=>{const{present:t,children:n}=e,r=Jy(t),o=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),s=Ke(r.ref,Zy(o));return typeof n=="function"||r.isPresent?y.cloneElement(o,{ref:s}):null};en.displayName="Presence";function Jy(e){const[t,n]=y.useState(),r=y.useRef(null),o=y.useRef(e),s=y.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Xy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const c=Yo(r.current);s.current=a==="mounted"?c:"none"},[a]),jt(()=>{const c=r.current,d=o.current;if(d!==e){const p=s.current,h=Yo(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]),jt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const m=Yo(r.current).includes(CSS.escape(h.animationName));if(h.target===t&&m&&(l("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},p=h=>{h.target===t&&(s.current=Yo(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:y.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Yo(e){return(e==null?void 0:e.animationName)||"none"}function Zy(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 Di="rovingFocusGroup.onEntryFocus",Qy={bubbles:!1,cancelable:!0},Br="RovingFocusGroup",[Li,cu,ev]=xi(Br),[tv,uu]=En(Br,[ev]),[nv,rv]=tv(Br),du=y.forwardRef((e,t)=>u.jsx(Li.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Li.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ov,{...e,ref:t})})}));du.displayName=Br;var ov=y.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=y.useRef(null),h=Ke(t,p),x=Oo(s),[m,v]=pr({prop:i,defaultProp:a??null,onChange:l,caller:Br}),[g,b]=y.useState(!1),S=Rt(c),k=cu(n),T=y.useRef(!1),[C,E]=y.useState(0);return y.useEffect(()=>{const N=p.current;if(N)return N.addEventListener(Di,S),()=>N.removeEventListener(Di,S)},[S]),u.jsx(nv,{scope:n,orientation:r,dir:x,loop:o,currentTabStopId:m,onItemFocus:y.useCallback(N=>v(N),[v]),onItemShiftTab:y.useCallback(()=>b(!0),[]),onFocusableItemAdd:y.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:y.useCallback(()=>E(N=>N-1),[]),children:u.jsx(je.div,{tabIndex:g||C===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{T.current=!0}),onFocus:me(e.onFocus,N=>{const j=!T.current;if(N.target===N.currentTarget&&j&&!g){const L=new CustomEvent(Di,Qy);if(N.currentTarget.dispatchEvent(L),!L.defaultPrevented){const _=k().filter(R=>R.focusable),M=_.find(R=>R.active),z=_.find(R=>R.id===m),F=[M,z,..._].filter(Boolean).map(R=>R.ref.current);hu(F,d)}}T.current=!1}),onBlur:me(e.onBlur,()=>b(!1))})})}),fu="RovingFocusGroupItem",pu=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=In(),c=s||l,d=rv(fu,n),f=d.currentTabStopId===c,p=cu(n),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:m}=d;return y.useEffect(()=>{if(r)return h(),()=>x()},[r,h,x]),u.jsx(Li.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(je.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:me(e.onMouseDown,v=>{r?d.onItemFocus(c):v.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){d.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const g=av(v,d.orientation,d.dir);if(g!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.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(v.currentTarget);S=d.loop?lv(S,k+1):S.slice(k+1)}setTimeout(()=>hu(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:m!=null}):i})})});pu.displayName=fu;var sv={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function iv(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function av(e,t,n){const r=iv(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return sv[r]}function hu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function lv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cv=du,uv=pu,dv=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},yr=new WeakMap,Xo=new WeakMap,Jo={},$i=0,mu=function(e){return e&&(e.host||mu(e.parentNode))},fv=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=mu(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})},pv=function(e,t,n,r){var o=fv(t,Array.isArray(e)?e:[e]);Jo[n]||(Jo[n]=new WeakMap);var s=Jo[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),x=h!==null&&h!=="false",m=(yr.get(p)||0)+1,v=(s.get(p)||0)+1;yr.set(p,m),s.set(p,v),i.push(p),m===1&&x&&Xo.set(p,!0),v===1&&p.setAttribute(n,"true"),x||p.setAttribute(r,"true")}catch(g){console.error("aria-hidden: cannot operate on ",p,g)}})};return d(t),a.clear(),$i++,function(){i.forEach(function(f){var p=yr.get(f)-1,h=s.get(f)-1;yr.set(f,p),s.set(f,h),p||(Xo.has(f)||f.removeAttribute(r),Xo.delete(f)),h||f.removeAttribute(n)}),$i--,$i||(yr=new WeakMap,yr=new WeakMap,Xo=new WeakMap,Jo={})}},Fi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=dv(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),pv(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 gu(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 hv(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 Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",mv="with-scroll-bars-hidden",gv="--removed-body-scroll-bar-size";function zi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function xv(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var yv=typeof window<"u"?y.useLayoutEffect:y.useEffect,xu=new WeakMap;function vv(e,t){var n=xv(null,function(r){return e.forEach(function(o){return zi(o,r)})});return yv(function(){var r=xu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||zi(a,null)}),s.forEach(function(a){o.has(a)||zi(a,i)})}xu.set(n,e)},[e]),n}function bv(e){return e}function wv(e,t){t===void 0&&(t=bv);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 Sv(e){e===void 0&&(e={});var t=wv(null);return t.options=bn({async:!0,ssr:!1},e),t}var yu=function(e){var t=e.sideCar,n=gu(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 y.createElement(r,bn({},n))};yu.isSideCarExport=!0;function Cv(e,t){return e.useMedium(t),yu}var vu=Sv(),Bi=function(){},es=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:Bi,onWheelCapture:Bi,onTouchMoveCapture:Bi}),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,x=e.noIsolation,m=e.inert,v=e.allowPinchZoom,g=e.as,b=g===void 0?"div":g,S=e.gapMode,k=gu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=p,C=vv([n,t]),E=bn(bn({},k),o);return y.createElement(y.Fragment,null,d&&y.createElement(T,{sideCar:vu,removeScrollBar:c,shards:f,noRelative:h,noIsolation:x,inert:m,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(a),bn(bn({},E),{ref:C})):y.createElement(b,bn({},E,{className:l,ref:C}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var Tv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function kv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Tv();return t&&e.setAttribute("nonce",t),e}function Ev(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Iv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Nv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=kv())&&(Ev(t,n),Iv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Av=function(){var e=Nv();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bu=function(){var e=Av(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},_v={left:0,top:0,right:0,gap:0},Hi=function(e){return parseInt(e||"",10)||0},jv=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[Hi(n),Hi(r),Hi(o)]},Rv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return _v;var t=jv(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])}},Pv=bu(),vr="data-scroll-locked",Ov=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
+ .`.concat(mv,` {
40
40
  overflow: hidden `).concat(r,`;
41
41
  padding-right: `).concat(a,"px ").concat(r,`;
42
42
  }
43
- body[`).concat(br,`] {
43
+ body[`).concat(vr,`] {
44
44
  overflow: hidden `).concat(r,`;
45
45
  overscroll-behavior: contain;
46
46
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -69,13 +69,13 @@ React keys must be passed directly to JSX without using spread:
69
69
  margin-right: 0 `).concat(r,`;
70
70
  }
71
71
 
72
- body[`).concat(br,`] {
73
- `).concat(mv,": ").concat(a,`px;
72
+ body[`).concat(vr,`] {
73
+ `).concat(gv,": ").concat(a,`px;
74
74
  }
75
- `)},wu=function(){var e=parseInt(document.body.getAttribute(br)||"0",10);return isFinite(e)?e:0},Ov=function(){y.useEffect(function(){return document.body.setAttribute(br,(wu()+1).toString()),function(){var e=wu()-1;e<=0?document.body.removeAttribute(br):document.body.setAttribute(br,e.toString())}},[])},Mv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Ov();var s=y.useMemo(function(){return jv(o)},[o]);return y.createElement(Rv,{styles:Pv(s,!t,o,n?"":"!important")})},Ui=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return Ui=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{Ui=!1}var wr=Ui?{passive:!1}:!1,Dv=function(e){return e.tagName==="TEXTAREA"},Su=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Dv(e)&&n[t]==="visible")},Lv=function(e){return Su(e,"overflowY")},$v=function(e){return Su(e,"overflowX")},Cu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Tu(e,r);if(o){var s=ku(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Fv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},zv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Tu=function(e,t){return e==="v"?Lv(t):$v(t)},ku=function(e,t){return e==="v"?Fv(t):zv(t)},Bv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Hv=function(e,t,n,r,o){var s=Bv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,p=0;do{if(!a)break;var h=ku(e,a),x=h[0],m=h[1],v=h[2],g=m-v-s*x;(x||g)&&Tu(e,a)&&(f+=g,p+=x);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(c=!0),c},ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Eu=function(e){return[e.deltaX,e.deltaY]},Iu=function(e){return e&&"current"in e?e.current:e},Uv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Wv=function(e){return`
75
+ `)},wu=function(){var e=parseInt(document.body.getAttribute(vr)||"0",10);return isFinite(e)?e:0},Mv=function(){y.useEffect(function(){return document.body.setAttribute(vr,(wu()+1).toString()),function(){var e=wu()-1;e<=0?document.body.removeAttribute(vr):document.body.setAttribute(vr,e.toString())}},[])},Dv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Mv();var s=y.useMemo(function(){return Rv(o)},[o]);return y.createElement(Pv,{styles:Ov(s,!t,o,n?"":"!important")})},Ui=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return Ui=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{Ui=!1}var br=Ui?{passive:!1}:!1,Lv=function(e){return e.tagName==="TEXTAREA"},Su=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Lv(e)&&n[t]==="visible")},$v=function(e){return Su(e,"overflowY")},Fv=function(e){return Su(e,"overflowX")},Cu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Tu(e,r);if(o){var s=ku(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},zv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Bv=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Tu=function(e,t){return e==="v"?$v(t):Fv(t)},ku=function(e,t){return e==="v"?zv(t):Bv(t)},Hv=function(e,t){return e==="h"&&t==="rtl"?-1:1},Uv=function(e,t,n,r,o){var s=Hv(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,p=0;do{if(!a)break;var h=ku(e,a),x=h[0],m=h[1],v=h[2],g=m-v-s*x;(x||g)&&Tu(e,a)&&(f+=g,p+=x);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(c=!0),c},ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Eu=function(e){return[e.deltaX,e.deltaY]},Iu=function(e){return e&&"current"in e?e.current:e},Wv=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Vv=function(e){return`
76
76
  .block-interactivity-`.concat(e,` {pointer-events: none;}
77
77
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
78
- `)},Vv=0,Sr=[];function Kv(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(Vv++)[0],s=y.useState(bu)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=pv([e.lockRef.current],(e.shards||[]).map(Iu),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var g=ns(m),b=n.current,S="deltaX"in m?m.deltaX:b[0]-g[0],k="deltaY"in m?m.deltaY:b[1]-g[1],T,C=m.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in m&&E==="h"&&C.type==="range")return!1;var N=Cu(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=Cu(E,C)),!N)return!1;if(!r.current&&"changedTouches"in m&&(S||k)&&(r.current=T),!T)return!0;var _=r.current||T;return Hv(_,v,m,_==="h"?S:k)},[]),l=y.useCallback(function(m){var v=m;if(!(!Sr.length||Sr[Sr.length-1]!==s)){var g="deltaY"in v?Eu(v):ns(v),b=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&Uv(T.delta,g)})[0];if(b&&b.should){v.cancelable&&v.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Iu).filter(Boolean).filter(function(T){return T.contains(v.target)}),k=S.length>0?a(v,S[0]):!i.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,g,b){var S={name:m,delta:v,target:g,should:b,shadowParent:qv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=y.useCallback(function(m){n.current=ns(m),r.current=void 0},[]),f=y.useCallback(function(m){c(m.type,Eu(m),m.target,a(m,e.lockRef.current))},[]),p=y.useCallback(function(m){c(m.type,ns(m),m.target,a(m,e.lockRef.current))},[]);y.useEffect(function(){return Sr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,wr),document.addEventListener("touchmove",l,wr),document.addEventListener("touchstart",d,wr),function(){Sr=Sr.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,wr),document.removeEventListener("touchmove",l,wr),document.removeEventListener("touchstart",d,wr)}},[]);var h=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(s,{styles:Wv(o)}):null,h?y.createElement(Mv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function qv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Gv=Sv(vu,Kv);var rs=y.forwardRef(function(e,t){return y.createElement(es,bn({},e,{ref:t,sideCar:Gv}))});rs.classNames=es.classNames;var Wi=["Enter"," "],Yv=["ArrowDown","PageUp","Home"],Nu=["ArrowUp","PageDown","End"],Xv=[...Yv,...Nu],Jv={ltr:[...Wi,"ArrowRight"],rtl:[...Wi,"ArrowLeft"]},Zv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ur="Menu",[Wr,Qv,eb]=xi(Ur),[Jn,Au]=En(Ur,[eb,qo,uu]),os=qo(),_u=uu(),[tb,Zn]=Jn(Ur),[nb,Vr]=Jn(Ur),ju=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=os(t),[l,c]=y.useState(null),d=y.useRef(!1),f=Rt(s),p=Oo(o);return y.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(su,{...a,children:u.jsx(tb,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(nb,{scope:t,onClose:y.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};ju.displayName=Ur;var rb="MenuAnchor",Vi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=os(n);return u.jsx(iu,{...o,...r,ref:t})});Vi.displayName=rb;var Ki="MenuPortal",[ob,Ru]=Jn(Ki,{forceMount:void 0}),Pu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Zn(Ki,t);return u.jsx(ob,{scope:t,forceMount:n,children:u.jsx(en,{present:n||s.open,children:u.jsx(Go,{asChild:!0,container:o,children:r})})})};Pu.displayName=Ki;var tn="MenuContent",[sb,qi]=Jn(tn),Ou=y.forwardRef((e,t)=>{const n=Ru(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Zn(tn,e.__scopeMenu),i=Vr(tn,e.__scopeMenu);return u.jsx(Wr.Provider,{scope:e.__scopeMenu,children:u.jsx(en,{present:r||s.open,children:u.jsx(Wr.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(ib,{...o,ref:t}):u.jsx(ab,{...o,ref:t})})})})}),ib=y.forwardRef((e,t)=>{const n=Zn(tn,e.__scopeMenu),r=y.useRef(null),o=Ke(t,r);return y.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),u.jsx(Gi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),ab=y.forwardRef((e,t)=>{const n=Zn(tn,e.__scopeMenu);return u.jsx(Gi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),lb=Kn.createSlot("MenuContent.ScrollLock"),Gi=y.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:x,...m}=e,v=Zn(tn,n),g=Vr(tn,n),b=os(n),S=_u(n),k=Qv(n),[T,C]=y.useState(null),E=y.useRef(null),N=Ke(t,E,v.onContentChange),_=y.useRef(0),L=y.useRef(""),j=y.useRef(0),M=y.useRef(null),z=y.useRef("right"),A=y.useRef(0),F=x?rs:y.Fragment,R=x?{as:lb,allowPinchZoom:!0}:void 0,G=D=>{var J,$;const V=L.current+D,Y=k().filter(K=>!K.disabled),he=document.activeElement,ae=(J=Y.find(K=>K.ref.current===he))==null?void 0:J.textValue,_e=Y.map(K=>K.textValue),X=bb(_e,V,ae),H=($=Y.find(K=>K.textValue===X))==null?void 0:$.ref.current;(function K(re){L.current=re,window.clearTimeout(_.current),re!==""&&(_.current=window.setTimeout(()=>K(""),1e3))})(V),H&&setTimeout(()=>H.focus())};y.useEffect(()=>()=>window.clearTimeout(_.current),[]),bi();const B=y.useCallback(D=>{var Y,he;return z.current===((Y=M.current)==null?void 0:Y.side)&&Sb(D,(he=M.current)==null?void 0:he.area)},[]);return u.jsx(sb,{scope:n,searchRef:L,onItemEnter:y.useCallback(D=>{B(D)&&D.preventDefault()},[B]),onItemLeave:y.useCallback(D=>{var V;B(D)||((V=E.current)==null||V.focus(),C(null))},[B]),onTriggerLeave:y.useCallback(D=>{B(D)&&D.preventDefault()},[B]),pointerGraceTimerRef:j,onPointerGraceIntentChange:y.useCallback(D=>{M.current=D},[]),children:u.jsx(F,{...R,children:u.jsx(Do,{asChild:!0,trapped:o,onMountAutoFocus:me(s,D=>{var V;D.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Mo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(lv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:me(l,D=>{g.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(au,{role:"menu","aria-orientation":"vertical","data-state":Ju(v.open),"data-radix-menu-content":"",dir:g.dir,...b,...m,ref:N,style:{outline:"none",...m.style},onKeyDown:me(m.onKeyDown,D=>{const Y=D.target.closest("[data-radix-menu-content]")===D.currentTarget,he=D.ctrlKey||D.altKey||D.metaKey,ae=D.key.length===1;Y&&(D.key==="Tab"&&D.preventDefault(),!he&&ae&&G(D.key));const _e=E.current;if(D.target!==_e||!Xv.includes(D.key))return;D.preventDefault();const H=k().filter(J=>!J.disabled).map(J=>J.ref.current);Nu.includes(D.key)&&H.reverse(),yb(H)}),onBlur:me(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(_.current),L.current="")}),onPointerMove:me(e.onPointerMove,qr(D=>{const V=D.target,Y=A.current!==D.clientX;if(D.currentTarget.contains(V)&&Y){const he=D.clientX>A.current?"right":"left";z.current=he,A.current=D.clientX}}))})})})})})})});Ou.displayName=tn;var cb="MenuGroup",Yi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{role:"group",...r,ref:t})});Yi.displayName=cb;var ub="MenuLabel",Mu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{...r,ref:t})});Mu.displayName=ub;var ss="MenuItem",Du="menu.itemSelect",is=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=y.useRef(null),i=Vr(ss,e.__scopeMenu),a=qi(ss,e.__scopeMenu),l=Ke(t,s),c=y.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(Du,{bubbles:!0,cancelable:!0});f.addEventListener(Du,h=>r==null?void 0:r(h),{once:!0}),mc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Lu,{...o,ref:l,disabled:n,onClick:me(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:me(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:me(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Wi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});is.displayName=ss;var Lu=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=qi(ss,n),a=_u(n),l=y.useRef(null),c=Ke(t,l),[d,f]=y.useState(!1),[p,h]=y.useState("");return y.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Wr.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(cv,{asChild:!0,...a,focusable:!r,children:u.jsx(Re.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:me(e.onPointerMove,qr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:me(e.onPointerLeave,qr(x=>i.onItemLeave(x))),onFocus:me(e.onFocus,()=>f(!0)),onBlur:me(e.onBlur,()=>f(!1))})})})}),db="MenuCheckboxItem",$u=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Uu,{scope:e.__scopeMenu,checked:n,children:u.jsx(is,{role:"menuitemcheckbox","aria-checked":as(n)?"mixed":n,...o,ref:t,"data-state":Ji(n),onSelect:me(o.onSelect,()=>r==null?void 0:r(as(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$u.displayName=db;var Fu="MenuRadioGroup",[fb,pb]=Jn(Fu,{value:void 0,onValueChange:()=>{}}),zu=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(fb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Yi,{...o,ref:t})})});zu.displayName=Fu;var Bu="MenuRadioItem",Hu=y.forwardRef((e,t)=>{const{value:n,...r}=e,o=pb(Bu,e.__scopeMenu),s=n===o.value;return u.jsx(Uu,{scope:e.__scopeMenu,checked:s,children:u.jsx(is,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ji(s),onSelect:me(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Hu.displayName=Bu;var Xi="MenuItemIndicator",[Uu,hb]=Jn(Xi,{checked:!1}),Wu=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=hb(Xi,n);return u.jsx(en,{present:r||as(s.checked)||s.checked===!0,children:u.jsx(Re.span,{...o,ref:t,"data-state":Ji(s.checked)})})});Wu.displayName=Xi;var mb="MenuSeparator",Vu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Re.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Vu.displayName=mb;var gb="MenuArrow",Ku=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=os(n);return u.jsx(lu,{...o,...r,ref:t})});Ku.displayName=gb;var xb="MenuSub",[NT,qu]=Jn(xb),Kr="MenuSubTrigger",Gu=y.forwardRef((e,t)=>{const n=Zn(Kr,e.__scopeMenu),r=Vr(Kr,e.__scopeMenu),o=qu(Kr,e.__scopeMenu),s=qi(Kr,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>d,[d]),y.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Vi,{asChild:!0,...c,children:u.jsx(Lu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Ju(n.open),...e,ref:gi(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:me(e.onPointerMove,qr(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:me(e.onPointerLeave,qr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const m=(x=n.content)==null?void 0:x.dataset.side,v=m==="right",g=v?-5:5,b=p[v?"left":"right"],S=p[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:me(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Jv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Gu.displayName=Kr;var Yu="MenuSubContent",Xu=y.forwardRef((e,t)=>{const n=Ru(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Zn(tn,e.__scopeMenu),i=Vr(tn,e.__scopeMenu),a=qu(Yu,e.__scopeMenu),l=y.useRef(null),c=Ke(t,l);return u.jsx(Wr.Provider,{scope:e.__scopeMenu,children:u.jsx(en,{present:r||s.open,children:u.jsx(Wr.Slot,{scope:e.__scopeMenu,children:u.jsx(Gi,{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:me(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:me(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:me(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),p=Zv[i.dir].includes(d.key);f&&p&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});Xu.displayName=Yu;function Ju(e){return e?"open":"closed"}function as(e){return e==="indeterminate"}function Ji(e){return as(e)?"indeterminate":e?"checked":"unchecked"}function yb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bb(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=vb(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 wb(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 Sb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wb(n,t)}function qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Cb=ju,Tb=Vi,kb=Pu,Eb=Ou,Ib=Yi,Nb=Mu,Ab=is,_b=$u,jb=zu,Rb=Hu,Pb=Wu,Ob=Vu,Mb=Ku,Db=Gu,Lb=Xu,ls="DropdownMenu",[$b,AT]=En(ls,[Au]),Ft=Au(),[Fb,Zu]=$b(ls),Qu=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=y.useRef(null),[d,f]=hr({prop:o,defaultProp:s??!1,onChange:i,caller:ls});return u.jsx(Fb,{scope:t,triggerId:In(),triggerRef:c,contentId:In(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(Cb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Qu.displayName=ls;var ed="DropdownMenuTrigger",td=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Zu(ed,n),i=Ft(n);return u.jsx(Tb,{asChild:!0,...i,children:u.jsx(Re.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:gi(t,s.triggerRef),onPointerDown:me(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:me(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});td.displayName=ed;var zb="DropdownMenuPortal",nd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(kb,{...r,...n})};nd.displayName=zb;var rd="DropdownMenuContent",od=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Zu(rd,n),s=Ft(n),i=y.useRef(!1);return u.jsx(Eb,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:me(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:me(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)"}})});od.displayName=rd;var Bb="DropdownMenuGroup",Hb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Ib,{...o,...r,ref:t})});Hb.displayName=Bb;var Ub="DropdownMenuLabel",sd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Nb,{...o,...r,ref:t})});sd.displayName=Ub;var Wb="DropdownMenuItem",id=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Ab,{...o,...r,ref:t})});id.displayName=Wb;var Vb="DropdownMenuCheckboxItem",ad=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(_b,{...o,...r,ref:t})});ad.displayName=Vb;var Kb="DropdownMenuRadioGroup",qb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(jb,{...o,...r,ref:t})});qb.displayName=Kb;var Gb="DropdownMenuRadioItem",ld=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Rb,{...o,...r,ref:t})});ld.displayName=Gb;var Yb="DropdownMenuItemIndicator",cd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Pb,{...o,...r,ref:t})});cd.displayName=Yb;var Xb="DropdownMenuSeparator",ud=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Ob,{...o,...r,ref:t})});ud.displayName=Xb;var Jb="DropdownMenuArrow",Zb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Mb,{...o,...r,ref:t})});Zb.displayName=Jb;var Qb="DropdownMenuSubTrigger",dd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Db,{...o,...r,ref:t})});dd.displayName=Qb;var ew="DropdownMenuSubContent",fd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Lb,{...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)"}})});fd.displayName=ew;var tw=Qu,nw=td,rw=nd,pd=od,hd=sd,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd;const ow=tw,sw=nw,iw=y.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(bd,{ref:o,className:ee("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(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));iw.displayName=bd.displayName;const aw=y.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:ee("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}));aw.displayName=wd.displayName;const Sd=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(rw,{children:u.jsx(pd,{ref:r,sideOffset:t,className:ee("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})}));Sd.displayName=pd.displayName;const Zi=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(md,{ref:r,className:ee("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}));Zi.displayName=md.displayName;const lw=y.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(gd,{ref:o,className:ee("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(yd,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));lw.displayName=gd.displayName;const cw=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xd,{ref:r,className:ee("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(yd,{children:u.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));cw.displayName=xd.displayName;const uw=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(hd,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));uw.displayName=hd.displayName;const dw=y.forwardRef(({className:e,...t},n)=>u.jsx(vd,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));dw.displayName=vd.displayName;const cs=1e4;function fw(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
+ `)},Kv=0,wr=[];function qv(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),o=y.useState(Kv++)[0],s=y.useState(bu)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var m=hv([e.lockRef.current],(e.shards||[]).map(Iu),!0).filter(Boolean);return m.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=y.useCallback(function(m,v){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var g=ns(m),b=n.current,S="deltaX"in m?m.deltaX:b[0]-g[0],k="deltaY"in m?m.deltaY:b[1]-g[1],T,C=m.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in m&&E==="h"&&C.type==="range")return!1;var N=Cu(E,C);if(!N)return!0;if(N?T=E:(T=E==="v"?"h":"v",N=Cu(E,C)),!N)return!1;if(!r.current&&"changedTouches"in m&&(S||k)&&(r.current=T),!T)return!0;var j=r.current||T;return Uv(j,v,m,j==="h"?S:k)},[]),l=y.useCallback(function(m){var v=m;if(!(!wr.length||wr[wr.length-1]!==s)){var g="deltaY"in v?Eu(v):ns(v),b=t.current.filter(function(T){return T.name===v.type&&(T.target===v.target||v.target===T.shadowParent)&&Wv(T.delta,g)})[0];if(b&&b.should){v.cancelable&&v.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Iu).filter(Boolean).filter(function(T){return T.contains(v.target)}),k=S.length>0?a(v,S[0]):!i.current.noIsolation;k&&v.cancelable&&v.preventDefault()}}},[]),c=y.useCallback(function(m,v,g,b){var S={name:m,delta:v,target:g,should:b,shadowParent:Gv(g)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=y.useCallback(function(m){n.current=ns(m),r.current=void 0},[]),f=y.useCallback(function(m){c(m.type,Eu(m),m.target,a(m,e.lockRef.current))},[]),p=y.useCallback(function(m){c(m.type,ns(m),m.target,a(m,e.lockRef.current))},[]);y.useEffect(function(){return wr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,br),document.addEventListener("touchmove",l,br),document.addEventListener("touchstart",d,br),function(){wr=wr.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,br),document.removeEventListener("touchmove",l,br),document.removeEventListener("touchstart",d,br)}},[]);var h=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(s,{styles:Vv(o)}):null,h?y.createElement(Dv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Gv(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Yv=Cv(vu,qv);var rs=y.forwardRef(function(e,t){return y.createElement(es,bn({},e,{ref:t,sideCar:Yv}))});rs.classNames=es.classNames;var Wi=["Enter"," "],Xv=["ArrowDown","PageUp","Home"],Nu=["ArrowUp","PageDown","End"],Jv=[...Xv,...Nu],Zv={ltr:[...Wi,"ArrowRight"],rtl:[...Wi,"ArrowLeft"]},Qv={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hr="Menu",[Ur,eb,tb]=xi(Hr),[Xn,Au]=En(Hr,[tb,qo,uu]),os=qo(),_u=uu(),[nb,Jn]=Xn(Hr),[rb,Wr]=Xn(Hr),ju=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=os(t),[l,c]=y.useState(null),d=y.useRef(!1),f=Rt(s),p=Oo(o);return y.useEffect(()=>{const h=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),u.jsx(su,{...a,children:u.jsx(nb,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(rb,{scope:t,onClose:y.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:i,children:r})})})};ju.displayName=Hr;var ob="MenuAnchor",Vi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=os(n);return u.jsx(iu,{...o,...r,ref:t})});Vi.displayName=ob;var Ki="MenuPortal",[sb,Ru]=Xn(Ki,{forceMount:void 0}),Pu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Jn(Ki,t);return u.jsx(sb,{scope:t,forceMount:n,children:u.jsx(en,{present:n||s.open,children:u.jsx(Go,{asChild:!0,container:o,children:r})})})};Pu.displayName=Ki;var tn="MenuContent",[ib,qi]=Xn(tn),Ou=y.forwardRef((e,t)=>{const n=Ru(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(tn,e.__scopeMenu),i=Wr(tn,e.__scopeMenu);return u.jsx(Ur.Provider,{scope:e.__scopeMenu,children:u.jsx(en,{present:r||s.open,children:u.jsx(Ur.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(ab,{...o,ref:t}):u.jsx(lb,{...o,ref:t})})})})}),ab=y.forwardRef((e,t)=>{const n=Jn(tn,e.__scopeMenu),r=y.useRef(null),o=Ke(t,r);return y.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),u.jsx(Gi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),lb=y.forwardRef((e,t)=>{const n=Jn(tn,e.__scopeMenu);return u.jsx(Gi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),cb=Vn.createSlot("MenuContent.ScrollLock"),Gi=y.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:x,...m}=e,v=Jn(tn,n),g=Wr(tn,n),b=os(n),S=_u(n),k=eb(n),[T,C]=y.useState(null),E=y.useRef(null),N=Ke(t,E,v.onContentChange),j=y.useRef(0),L=y.useRef(""),_=y.useRef(0),M=y.useRef(null),z=y.useRef("right"),A=y.useRef(0),F=x?rs:y.Fragment,R=x?{as:cb,allowPinchZoom:!0}:void 0,G=D=>{var J,$;const V=L.current+D,Y=k().filter(K=>!K.disabled),he=document.activeElement,ie=(J=Y.find(K=>K.ref.current===he))==null?void 0:J.textValue,Ae=Y.map(K=>K.textValue),X=wb(Ae,V,ie),H=($=Y.find(K=>K.textValue===X))==null?void 0:$.ref.current;(function K(re){L.current=re,window.clearTimeout(j.current),re!==""&&(j.current=window.setTimeout(()=>K(""),1e3))})(V),H&&setTimeout(()=>H.focus())};y.useEffect(()=>()=>window.clearTimeout(j.current),[]),bi();const B=y.useCallback(D=>{var Y,he;return z.current===((Y=M.current)==null?void 0:Y.side)&&Cb(D,(he=M.current)==null?void 0:he.area)},[]);return u.jsx(ib,{scope:n,searchRef:L,onItemEnter:y.useCallback(D=>{B(D)&&D.preventDefault()},[B]),onItemLeave:y.useCallback(D=>{var V;B(D)||((V=E.current)==null||V.focus(),C(null))},[B]),onTriggerLeave:y.useCallback(D=>{B(D)&&D.preventDefault()},[B]),pointerGraceTimerRef:_,onPointerGraceIntentChange:y.useCallback(D=>{M.current=D},[]),children:u.jsx(F,{...R,children:u.jsx(Do,{asChild:!0,trapped:o,onMountAutoFocus:me(s,D=>{var V;D.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Mo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:h,children:u.jsx(cv,{asChild:!0,...S,dir:g.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:C,onEntryFocus:me(l,D=>{g.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(au,{role:"menu","aria-orientation":"vertical","data-state":Ju(v.open),"data-radix-menu-content":"",dir:g.dir,...b,...m,ref:N,style:{outline:"none",...m.style},onKeyDown:me(m.onKeyDown,D=>{const Y=D.target.closest("[data-radix-menu-content]")===D.currentTarget,he=D.ctrlKey||D.altKey||D.metaKey,ie=D.key.length===1;Y&&(D.key==="Tab"&&D.preventDefault(),!he&&ie&&G(D.key));const Ae=E.current;if(D.target!==Ae||!Jv.includes(D.key))return;D.preventDefault();const H=k().filter(J=>!J.disabled).map(J=>J.ref.current);Nu.includes(D.key)&&H.reverse(),vb(H)}),onBlur:me(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(j.current),L.current="")}),onPointerMove:me(e.onPointerMove,Kr(D=>{const V=D.target,Y=A.current!==D.clientX;if(D.currentTarget.contains(V)&&Y){const he=D.clientX>A.current?"right":"left";z.current=he,A.current=D.clientX}}))})})})})})})});Ou.displayName=tn;var ub="MenuGroup",Yi=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(je.div,{role:"group",...r,ref:t})});Yi.displayName=ub;var db="MenuLabel",Mu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(je.div,{...r,ref:t})});Mu.displayName=db;var ss="MenuItem",Du="menu.itemSelect",is=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=y.useRef(null),i=Wr(ss,e.__scopeMenu),a=qi(ss,e.__scopeMenu),l=Ke(t,s),c=y.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const p=new CustomEvent(Du,{bubbles:!0,cancelable:!0});f.addEventListener(Du,h=>r==null?void 0:r(h),{once:!0}),mc(f,p),p.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Lu,{...o,ref:l,disabled:n,onClick:me(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)==null||p.call(e,f),c.current=!0},onPointerUp:me(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)==null||p.click()}),onKeyDown:me(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||Wi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});is.displayName=ss;var Lu=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=qi(ss,n),a=_u(n),l=y.useRef(null),c=Ke(t,l),[d,f]=y.useState(!1),[p,h]=y.useState("");return y.useEffect(()=>{const x=l.current;x&&h((x.textContent??"").trim())},[s.children]),u.jsx(Ur.ItemSlot,{scope:n,disabled:r,textValue:o??p,children:u.jsx(uv,{asChild:!0,...a,focusable:!r,children:u.jsx(je.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:me(e.onPointerMove,Kr(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:me(e.onPointerLeave,Kr(x=>i.onItemLeave(x))),onFocus:me(e.onFocus,()=>f(!0)),onBlur:me(e.onBlur,()=>f(!1))})})})}),fb="MenuCheckboxItem",$u=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Uu,{scope:e.__scopeMenu,checked:n,children:u.jsx(is,{role:"menuitemcheckbox","aria-checked":as(n)?"mixed":n,...o,ref:t,"data-state":Ji(n),onSelect:me(o.onSelect,()=>r==null?void 0:r(as(n)?!0:!n),{checkForDefaultPrevented:!1})})})});$u.displayName=fb;var Fu="MenuRadioGroup",[pb,hb]=Xn(Fu,{value:void 0,onValueChange:()=>{}}),zu=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Rt(r);return u.jsx(pb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Yi,{...o,ref:t})})});zu.displayName=Fu;var Bu="MenuRadioItem",Hu=y.forwardRef((e,t)=>{const{value:n,...r}=e,o=hb(Bu,e.__scopeMenu),s=n===o.value;return u.jsx(Uu,{scope:e.__scopeMenu,checked:s,children:u.jsx(is,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ji(s),onSelect:me(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Hu.displayName=Bu;var Xi="MenuItemIndicator",[Uu,mb]=Xn(Xi,{checked:!1}),Wu=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=mb(Xi,n);return u.jsx(en,{present:r||as(s.checked)||s.checked===!0,children:u.jsx(je.span,{...o,ref:t,"data-state":Ji(s.checked)})})});Wu.displayName=Xi;var gb="MenuSeparator",Vu=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Vu.displayName=gb;var xb="MenuArrow",Ku=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=os(n);return u.jsx(lu,{...o,...r,ref:t})});Ku.displayName=xb;var yb="MenuSub",[jT,qu]=Xn(yb),Vr="MenuSubTrigger",Gu=y.forwardRef((e,t)=>{const n=Jn(Vr,e.__scopeMenu),r=Wr(Vr,e.__scopeMenu),o=qu(Vr,e.__scopeMenu),s=qi(Vr,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>d,[d]),y.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(Vi,{asChild:!0,...c,children:u.jsx(Lu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Ju(n.open),...e,ref:gi(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:me(e.onPointerMove,Kr(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:me(e.onPointerLeave,Kr(f=>{var h,x;d();const p=(h=n.content)==null?void 0:h.getBoundingClientRect();if(p){const m=(x=n.content)==null?void 0:x.dataset.side,v=m==="right",g=v?-5:5,b=p[v?"left":"right"],S=p[v?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+g,y:f.clientY},{x:b,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:b,y:p.bottom}],side:m}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:me(e.onKeyDown,f=>{var h;const p=s.searchRef.current!=="";e.disabled||p&&f.key===" "||Zv[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});Gu.displayName=Vr;var Yu="MenuSubContent",Xu=y.forwardRef((e,t)=>{const n=Ru(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(tn,e.__scopeMenu),i=Wr(tn,e.__scopeMenu),a=qu(Yu,e.__scopeMenu),l=y.useRef(null),c=Ke(t,l);return u.jsx(Ur.Provider,{scope:e.__scopeMenu,children:u.jsx(en,{present:r||s.open,children:u.jsx(Ur.Slot,{scope:e.__scopeMenu,children:u.jsx(Gi,{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:me(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:me(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:me(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())})})})})})});Xu.displayName=Yu;function Ju(e){return e?"open":"closed"}function as(e){return e==="indeterminate"}function Ji(e){return as(e)?"indeterminate":e?"checked":"unchecked"}function vb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function bb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function wb(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=bb(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 Sb(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 Cb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Sb(n,t)}function Kr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Tb=ju,kb=Vi,Eb=Pu,Ib=Ou,Nb=Yi,Ab=Mu,_b=is,jb=$u,Rb=zu,Pb=Hu,Ob=Wu,Mb=Vu,Db=Ku,Lb=Gu,$b=Xu,ls="DropdownMenu",[Fb,RT]=En(ls,[Au]),Ft=Au(),[zb,Zu]=Fb(ls),Qu=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=y.useRef(null),[d,f]=pr({prop:o,defaultProp:s??!1,onChange:i,caller:ls});return u.jsx(zb,{scope:t,triggerId:In(),triggerRef:c,contentId:In(),open:d,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(p=>!p),[f]),modal:a,children:u.jsx(Tb,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Qu.displayName=ls;var ed="DropdownMenuTrigger",td=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Zu(ed,n),i=Ft(n);return u.jsx(kb,{asChild:!0,...i,children:u.jsx(je.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:gi(t,s.triggerRef),onPointerDown:me(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:me(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});td.displayName=ed;var Bb="DropdownMenuPortal",nd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(Eb,{...r,...n})};nd.displayName=Bb;var rd="DropdownMenuContent",od=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Zu(rd,n),s=Ft(n),i=y.useRef(!1);return u.jsx(Ib,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:me(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:me(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)"}})});od.displayName=rd;var Hb="DropdownMenuGroup",Ub=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Nb,{...o,...r,ref:t})});Ub.displayName=Hb;var Wb="DropdownMenuLabel",sd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Ab,{...o,...r,ref:t})});sd.displayName=Wb;var Vb="DropdownMenuItem",id=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(_b,{...o,...r,ref:t})});id.displayName=Vb;var Kb="DropdownMenuCheckboxItem",ad=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(jb,{...o,...r,ref:t})});ad.displayName=Kb;var qb="DropdownMenuRadioGroup",Gb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Rb,{...o,...r,ref:t})});Gb.displayName=qb;var Yb="DropdownMenuRadioItem",ld=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Pb,{...o,...r,ref:t})});ld.displayName=Yb;var Xb="DropdownMenuItemIndicator",cd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Ob,{...o,...r,ref:t})});cd.displayName=Xb;var Jb="DropdownMenuSeparator",ud=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Mb,{...o,...r,ref:t})});ud.displayName=Jb;var Zb="DropdownMenuArrow",Qb=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Db,{...o,...r,ref:t})});Qb.displayName=Zb;var ew="DropdownMenuSubTrigger",dd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Lb,{...o,...r,ref:t})});dd.displayName=ew;var tw="DropdownMenuSubContent",fd=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx($b,{...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)"}})});fd.displayName=tw;var nw=Qu,rw=td,ow=nd,pd=od,hd=sd,md=id,gd=ad,xd=ld,yd=cd,vd=ud,bd=dd,wd=fd;const sw=nw,iw=rw,aw=y.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(bd,{ref:o,className:ee("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(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));aw.displayName=bd.displayName;const lw=y.forwardRef(({className:e,...t},n)=>u.jsx(wd,{ref:n,className:ee("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}));lw.displayName=wd.displayName;const Sd=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(ow,{children:u.jsx(pd,{ref:r,sideOffset:t,className:ee("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})}));Sd.displayName=pd.displayName;const Zi=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(md,{ref:r,className:ee("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}));Zi.displayName=md.displayName;const cw=y.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(gd,{ref:o,className:ee("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(yd,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));cw.displayName=gd.displayName;const uw=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xd,{ref:r,className:ee("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(yd,{children:u.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));uw.displayName=xd.displayName;const dw=y.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(hd,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));dw.displayName=hd.displayName;const fw=y.forwardRef(({className:e,...t},n)=>u.jsx(vd,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));fw.displayName=vd.displayName;function pw(e){const t=new Map;console.log("[attemptDetection] groupCheckpointsByLastUserMessageId processing",e.length,"checkpoints");for(const n of e){const o=[...n.messages??[]].reverse().find(s=>s.role==="user");if(o!=null&&o.id){const s=t.get(o.id)??[];s.push(n),t.set(o.id,s),s.length===1?console.log(`[attemptDetection] New user message group: "${o.id}" checkpoint ${n.checkpointId}`):console.log(`[attemptDetection] Adding to existing group: "${o.id}" now has ${s.length} checkpoints`)}else console.log(`[attemptDetection] Checkpoint ${n.checkpointId} has no user messages`)}return console.log("[attemptDetection] Final grouping:",{totalGroups:t.size,groupSizes:Array.from(t.entries()).map(([n,r])=>({userMessageId:n,count:r.length}))}),t}function hw(e){console.log("[attemptDetection] buildAttemptMetadataMap called with",e.length,"checkpoints");const t=new Map,n=pw(e);console.log("[attemptDetection] Grouped into",n.size,"unique user message IDs");for(const[r,o]of n.entries())o.length>1&&console.log(`[attemptDetection] User message "${r}" found in ${o.length} checkpoints (EDITS DETECTED)`,{checkpointIds:o.map(s=>s.checkpointId),createdAts:o.map(s=>s.createdAt)});for(const[r,o]of n.entries())if(o.length===1){const s=o[0];s.checkpointId&&t.set(s.checkpointId,{attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:r})}else{const s=[...o].sort((i,a)=>Date.parse(a.createdAt??"0")-Date.parse(i.createdAt??"0"));console.log(`[attemptDetection] Sorted ${s.length} versions for user message "${r}":`,{versionOrder:s.map((i,a)=>`v${a}: ${i.checkpointId} (${i.createdAt})`)}),s.forEach((i,a)=>{i.checkpointId&&t.set(i.checkpointId,{attemptIndex:a,attemptCount:s.length,isLatestAttempt:a===0,baseUserMessageId:r})})}return console.log("[attemptDetection] Final versionMetadata:",{totalCheckpoints:t.size,editedMessages:Array.from(t.entries()).filter(([r,o])=>o.attemptCount>1).map(([r,o])=>({checkpointId:r,attemptIndex:o.attemptIndex,attemptCount:o.attemptCount,isLatestAttempt:o.isLatestAttempt}))}),t}const cs=1e4;function mw(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,14 +83,14 @@ 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,"&lt;").replace(/>/g,"&gt;").trim()}function pw(e,t=cs){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 hw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),pw(t),fw(t)}const us=0,Dn=1,Cr=2,Cd=4;function Td(e){return()=>e}function mw(e){e()}function kd(e,t){return n=>e(t(n))}function Ed(e,t){return()=>e(t)}function gw(e,t){return n=>e(t,n)}function Qi(e){return e!==void 0}function xw(...e){return()=>{e.map(mw)}}function Tr(){}function ds(e,t){return t(e),e}function yw(e,t){return t(e)}function ct(...e){return e}function tt(e,t){return e(Dn,t)}function Me(e,t){e(us,t)}function ea(e){e(Cr)}function Tt(e){return e(Cd)}function ge(e,t){return tt(e,gw(t,us))}function un(e,t){const n=e(Dn,r=>{n(),t(r)});return n}function Id(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Nd(e,t){return e===t}function ut(e=Nd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>kd(t,e)}function wn(e){return t=>()=>{t(e)}}function U(e,...t){const n=vw(...t);return(r,o)=>{switch(r){case Cr:ea(e);return;case Dn:return tt(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Qn(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);tt(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 vw(...e){return t=>e.reduceRight(yw,t)}function bw(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Dn:return s?n===s?void 0:(r(),n=s,t=tt(e,s),t):(r(),Tr);case Cr:r(),n=null;return}}}function Z(e){let t=e;const n=qe();return(r,o)=>{switch(r){case us:t=o;break;case Dn:{o(t);break}case Cd:return t}return n(r,o)}}function Ot(e,t){return ds(Z(t),n=>ge(e,n))}function qe(){const e=[];return(t,n)=>{switch(t){case us:e.slice().forEach(r=>{r(n)});return;case Cr:e.splice(0,e.length);return;case Dn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Yt(e){return ds(qe(),t=>ge(e,t))}function Je(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ww(),singleton:n}}const ww=()=>Symbol();function Sw(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 Et(...e){const t=qe(),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);tt(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Cr:{ea(t);return}case Dn:return r===o&&i(n),tt(t,i)}}}function Ee(e,t=Nd){return U(e,ut(t))}function ta(...e){return function(t,n){switch(t){case Cr:return;case Dn:return xw(...e.map(r=>tt(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const Cw={0:"debug",3:"error",1:"log",2:"warn"},Tw=()=>typeof globalThis>"u"?window:globalThis,Ln=Je(()=>{const e=Z(3);return{log:Z((t,n,r=1)=>{var o;const s=(o=Tw().VIRTUOSO_LOG_LEVEL)!=null?o:Tt(e);r>=s&&console[Cw[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function er(e,t,n){return na(e,t,n).callbackRef}function na(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function kw(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=Ew(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 x;h&&(x=p.ownerDocument.defaultView);const m=i?a?i.scrollLeft:i.scrollTop:h?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,v=i?a?i.scrollWidth:i.scrollHeight:h?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:h?a?x.innerWidth:x.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:v,scrollTop:Math.max(m,0),viewportHeight:g}),s==null||s(a?Ad("column-gap",getComputedStyle(d).columnGap,o):Ad("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return na(c,n,l)}function Ew(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},Ut.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 Ad(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function _d(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(t){const h=t.getBoundingClientRect(),x=c.top-h.top;p=h.height-Math.max(0,x),f=x+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}=na(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const zt=Je(()=>{const e=qe(),t=qe(),n=Z(0),r=qe(),o=Z(0),s=qe(),i=qe(),a=Z(0),l=Z(0),c=Z(0),d=Z(0),f=qe(),p=qe(),h=Z(!1),x=Z(!1),m=Z(!1);return ge(U(e,fe(({scrollTop:v})=>v)),t),ge(U(e,fe(({scrollHeight:v})=>v)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:m,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Gr={lvl:0};function jd(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 it(e){return e===Gr}function Yr(e,t){if(!it(e))return t===e.k?e.v:t<e.k?Yr(e.l,t):Yr(e.r,t)}function dn(e,t,n="k"){if(it(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Xt(e,t,n){return it(e)?Od(t,n,1):t===e.k?At(e,{k:t,v:n}):t<e.k?Md(At(e,{l:Xt(e.l,t,n)})):Md(At(e,{r:Xt(e.r,t,n)}))}function kr(){return Gr}function fs(e,t,n){if(it(e))return[];const r=dn(e,t)[0];return Iw(oa(e,r,n))}function ra(e,t){if(it(e))return Gr;const{k:n,l:r,r:o}=e;if(t===n){if(it(r))return o;if(it(o))return r;{const[s,i]=Pd(r);return ps(At(e,{k:s,l:Rd(r),v:i}))}}else return t<n?ps(At(e,{l:ra(r,t)})):ps(At(e,{r:ra(o,t)}))}function tr(e){return it(e)?[]:[...tr(e.l),{k:e.k,v:e.v},...tr(e.r)]}function oa(e,t,n){if(it(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(oa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(oa(s,t,n))),a}function ps(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(sa(t))return Dd(At(e,{lvl:n-1}));if(!it(t)&&!it(t.r))return At(t.r,{l:At(t,{r:t.r.l}),lvl:n,r:At(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(sa(e))return ia(At(e,{lvl:n-1}));if(!it(r)&&!it(r.l)){const o=r.l,s=sa(o)?r.lvl-1:r.lvl;return At(o,{l:At(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ia(At(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return Od(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 Rd(e){return it(e.r)?e.l:ps(At(e,{r:Rd(e.r)}))}function sa(e){return it(e)||e.lvl>e.r.lvl}function Pd(e){return it(e.r)?[e.k,e.v]:Pd(e.r)}function Od(e,t,n,r=Gr,o=Gr){return{k:e,l:r,lvl:n,r:o,v:t}}function Md(e){return ia(Dd(e))}function Dd(e){const{l:t}=e;return!it(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function ia(e){const{lvl:t,r:n}=e;return!it(n)&&!it(n.r)&&n.lvl===t&&n.r.lvl===t?At(n,{l:At(e,{r:n.l}),lvl:t+1}):e}function Iw(e){return jd(e,({k:t,v:n})=>({index:t,value:n}))}function Ld(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Xr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const aa=Je(()=>({recalcInProgress:Z(!1)}),[],{singleton:!0});function $d(e,t,n){return e[hs(e,t,n)]}function hs(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 Nw(e,t,n,r){const o=hs(e,t,r),s=hs(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ms(e){return!it(e.groupOffsetTree)}function la({index:e},t){return t===e?0:t<e?-1:1}function Aw(){return{groupIndices:[],groupOffsetTree:kr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:kr()}}function _w(e,t){let n=it(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),it(e)){e=Xt(e,0,s);continue}const a=fs(e,i-1,o+1);if(a.some(Lw(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:p}of a)l?(o>=f||s===p)&&(e=ra(e,f)):(c=p!==s,l=!0),d>o&&o>=f&&p!==s&&(e=Xt(e,o+1,p));c&&(e=Xt(e,i,s))}return[e,n]}function jw(e){return typeof e.groupIndex<"u"}function Rw({offset:e},t){return t===e?0:t<e?-1:1}function Jr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=$d(t,e,la),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Fd(e,t){if(!ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function zd(e,t,n){if(jw(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Fd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Pw(e,t,n,r=0){return r>0&&(t=Math.max(t,$d(e,r,la).offset)),jd(Nw(e,t,n,Rw),Dw)}function Ow(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&it(s)&&t.length===2){const p=t[0].size,h=t[1].size;i=n.reduce((x,m)=>Xt(Xt(x,m,p),m+1,h),i)}else[i,a]=_w(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=ca(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,h)=>Xt(p,h,Jr(h,f,o)),kr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Mw(e){return tr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Bd(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 ca(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=hs(o,t-1,la),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of fs(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 Dw(e){return{index:e.index,value:e}}function Lw(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 $w={offsetHeight:"height",offsetWidth:"width"},Cn=Je(([{log:e},{recalcInProgress:t}])=>{const n=qe(),r=qe(),o=Ot(r,0),s=qe(),i=qe(),a=Z(0),l=Z([]),c=Z(void 0),d=Z(void 0),f=Z((T,C)=>$n(T,$w[C])),p=Z(void 0),h=Z(0),x=Aw(),m=Ot(U(n,De(l,e,h),Sn(Ow,x),ut()),x),v=Ot(U(l,ut(),Sn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);ge(U(l,Ae(T=>T.length>0),De(m,h),fe(([T,C,E])=>{const N=T.reduce((_,L,j)=>Xt(_,L,Jr(L,C.offsetTree,E)||j),kr());return{...C,groupIndices:T,groupOffsetTree:N}})),m),ge(U(r,De(m),Ae(([T,{lastIndex:C}])=>T<C),fe(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),ge(c,d);const g=Ot(U(c,fe(T=>T===void 0)),!0);ge(U(d,Ae(T=>T!==void 0&&it(Tt(m).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Yt(U(n,De(m),Sn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:x}),fe(T=>T.changed)));tt(U(a,Sn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:C}=Tt(m);if(T>0)Me(t,!0),Me(s,T+Bd(T,C));else if(T<0){const E=Tt(v);E.length>0&&(T-=Bd(-T,E)),Me(i,T)}}),tt(U(a,De(e)),([T,C])=>{T<0&&C("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ut.ERROR)});const S=Yt(s);ge(U(s,De(m),fe(([T,C])=>{const E=C.groupIndices.length>0,N=[],_=C.lastSize;if(E){const L=Yr(C.sizeTree,0);let j=0,M=0;for(;j<T;){const A=C.groupIndices[M],F=C.groupIndices.length===M+1?1/0:C.groupIndices[M+1]-A-1;N.push({endIndex:A,size:L,startIndex:A}),N.push({endIndex:A+1+F-1,size:_,startIndex:A+1}),M++,j+=F+1}const z=tr(C.sizeTree);return j!==T&&z.shift(),z.reduce((A,{k:F,v:R})=>{let G=A.ranges;return A.prevSize!==0&&(G=[...A.ranges,{endIndex:F+T-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:F+T,prevSize:R,ranges:G}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return tr(C.sizeTree).reduce((L,{k:j,v:M})=>({prevIndex:j+T,prevSize:M,ranges:[...L.ranges,{endIndex:j+T-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Yt(U(i,De(m,h),fe(([T,{offsetTree:C},E])=>{const N=-T;return Jr(N,C,E)})));return ge(U(i,De(m,h),fe(([T,C,E])=>{if(C.groupIndices.length>0){if(it(C.sizeTree))return C;let N=kr();const _=Tt(v);let L=0,j=0,M=0;for(;L<-T;){M=_[j];const z=_[j+1]-M-1;j++,L+=z+1}if(N=tr(C.sizeTree).reduce((z,{k:A,v:F})=>Xt(z,Math.max(0,A+T),F),N),L!==-T){const z=Yr(C.sizeTree,M);N=Xt(N,0,z);const A=dn(C.sizeTree,-T+1)[1];N=Xt(N,1,A)}return{...C,sizeTree:N,...ca(C.offsetTree,0,N,E)}}else{const N=tr(C.sizeTree).reduce((_,{k:L,v:j})=>Xt(_,Math.max(0,L+T),j),kr());return{...C,sizeTree:N,...ca(C.offsetTree,0,N,E)}}})),m),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:m,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},ct(Ln,aa),{singleton:!0});function Fw(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Hd=Je(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=qe(),i=qe(),a=Yt(U(s,fe(Fw)));return ge(U(a,fe(l=>l.totalCount)),n),ge(U(a,fe(l=>l.groupIndices)),e),ge(U(Et(o,t,r),Ae(([l,c])=>ms(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ut(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ct(Cn,zt)),Fn=Je(([{log:e}])=>{const t=Z(!1),n=Yt(U(t,Ae(r=>r),ut()));return tt(t,r=>{r&&Tt(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},ct(Ln),{singleton:!0}),zw=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ud(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!zw)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Zr=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=qe(),x=qe(),m=Z(0);let v=null,g=null,b=null;function S(){v&&(v(),v=null),b&&(b(),b=null),g&&(clearTimeout(g),g=null),Me(l,!1)}return ge(U(h,De(n,f,r,m,a,i,p),De(e,s,o),fe(([[k,T,C,E,N,_,L,j],M,z,A])=>{const F=Ud(k),{align:R,behavior:G,offset:B}=F,D=E-1,V=zd(F,T,D);let Y=Jr(V,T.offsetTree,M)+_;R==="end"?(Y+=z+dn(T.sizeTree,V)[1]-C+A,V===D&&(Y+=L)):R==="center"?Y+=(z+dn(T.sizeTree,V)[1]-C+A)/2:Y-=N,B&&(Y+=B);const he=ae=>{S(),ae?(j("retrying to scroll to",{location:k},Ut.DEBUG),Me(h,k)):(Me(x,!0),j("list did not change, scroll successful",{},Ut.DEBUG))};if(S(),G==="smooth"){let ae=!1;b=tt(t,_e=>{ae=ae||_e}),v=un(d,()=>{he(ae)})}else v=un(U(t,Bw(150)),he);return g=setTimeout(()=>{S()},1200),Me(l,!0),j("scrolling from index to",{behavior:G,index:V,top:Y},Ut.DEBUG),{behavior:G,top:Y}})),c),{scrollTargetReached:x,scrollToIndex:h,topListHeight:m}},ct(Cn,zt,Ln),{singleton:!0});function Bw(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ua(e,t){e==0?t():requestAnimationFrame(()=>{ua(e-1,t)})}function da(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Qr=Je(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Z(!0),l=Z(0),c=Z(!0);return ge(U(i,De(l),Ae(([d,f])=>!!f),wn(!1)),a),ge(U(i,De(l),Ae(([d,f])=>!!f),wn(!1)),c),tt(U(Et(t,i),De(a,n,e,c),Ae(([[,d],f,{sizeTree:p},h,x])=>d&&(!it(p)||Qi(h))&&!f&&!x),De(l)),([,d])=>{un(o,()=>{Me(c,!0)}),ua(4,()=>{un(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(Cn,zt,Zr,Fn),{singleton:!0});function Wd(e,t){return Math.abs(e-t)<1.01}const eo="up",to="down",Hw="none",Uw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ww=0,no=Je(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Z(!1),a=Z(!0),l=qe(),c=qe(),d=Z(4),f=Z(Ww),p=Ot(U(ta(U(Ee(o),Qn(1),wn(!0)),U(Ee(o),Qn(1),wn(!1),Id(100))),ut()),!1),h=Ot(U(ta(U(n,wn(!0)),U(n,wn(!1),Id(200))),ut()),!1);ge(U(Et(Ee(o),Ee(f)),fe(([b,S])=>b<=S),ut()),a),ge(U(a,_n(50)),c);const x=Yt(U(Et(r,Ee(s),Ee(t),Ee(e),Ee(d)),Sn((b,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const _=k+T-S>-N,L={scrollHeight:S,scrollTop:k,viewportHeight:T};if(_){let M,z;return k>b.state.scrollTop?(M="SCROLLED_DOWN",z=b.state.scrollTop-k):(M="SIZE_DECREASED",z=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:z,state:L}}let j;return L.scrollHeight>b.state.scrollHeight?j="SIZE_INCREASED":T<b.state.viewportHeight?j="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?j="SCROLLING_UPWARDS":j="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:j,state:L}},Uw),ut((b,S)=>b&&b.atBottom===S.atBottom))),m=Ot(U(r,Sn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Wd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(b=>b.changed),fe(b=>b.jump)),0);ge(U(x,fe(b=>b.atBottom)),i),ge(U(i,_n(50)),l);const v=Z(to);ge(U(r,fe(({scrollTop:b})=>b),ut(),Sn((b,S)=>Tt(h)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?eo:to,prevScrollTop:S},{direction:to,prevScrollTop:0}),fe(b=>b.direction)),v),ge(U(r,_n(50),wn(Hw)),v);const g=Z(0);return ge(U(p,Ae(b=>!b),wn(0)),g),ge(U(o,_n(100),De(p),Ae(([b,S])=>!!S),Sn(([b,S],[k])=>[S,k],[0,0]),fe(([b,S])=>S-b)),g),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:m,scrollDirection:v,scrollVelocity:g}},ct(zt)),gs="top",xs="bottom",Vd="none";function Kd(e,t,n){return typeof e=="number"?n===eo&&t===gs||n===to&&t===xs?e:0:n===eo?t===gs?e.main:e.reverse:t===xs?e.main:e.reverse}function qd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const fa=Je(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=qe(),i=Z(0),a=Z(0),l=Z(0),c=Ot(U(Et(Ee(r),Ee(o),Ee(n),Ee(s,Xr),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),fe(([d,f,p,[h,x],m,v,g,b,S])=>{const k=d-b,T=v+g,C=Math.max(p-k,0);let E=Vd;const N=qd(S,gs),_=qd(S,xs);return h-=b,h+=p+g,x+=p+g,x-=b,h>d+T-N&&(E=eo),x<d-C+f+_&&(E=to),E!==Vd?[Math.max(k-p-Kd(m,gs,E)-N,0),k-C-g+f+Kd(m,xs,E)+_]:null}),Ae(d=>d!=null),ut(Xr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ct(zt),{singleton:!0});function Vw(e,t,n){if(ms(t)){const r=Fd(e,t);return[{index:dn(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 pa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ys(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 m=e[e.length-1];d=m.offset+m.size}const f=n-i,p=a+f*l+(f-1)*r,h=c,x=p-d;return{bottom:d,firstItemIndex:s,items:Yd(e,o,s),offsetBottom:x,offsetTop:c,top:h,topItems:Yd(t,o,s),topListHeight:t.reduce((m,v)=>v.size+m,0),totalCount:n}}function Gd(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=da(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ys(c,[],a,o,n,r)}function Yd(e,t,n){if(e.length===0)return[];if(!ms(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=fs(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const nr=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:x}])=>{const m=Z([]),v=Z(0),g=qe();ge(s.topItemsIndexes,m);const b=Ot(U(Et(h,x,Ee(l,Xr),Ee(o),Ee(r),Ee(c),d,Ee(m),Ee(t),Ee(n),e),Ae(([C,E,,N,,,,,,,_])=>{const L=_&&_.length!==N;return C&&!E&&!L}),fe(([,,[C,E],N,_,L,j,M,z,A,F])=>{const R=_,{offsetTree:G,sizeTree:B}=R,D=Tt(v);if(N===0)return{...pa,totalCount:N};if(C===0&&E===0)return D===0?{...pa,totalCount:N}:Gd(D,L,_,z,A,F||[]);if(it(B))return D>0?null:ys(Vw(da(L,N),R,F),[],N,A,R,z);const V=[];if(M.length>0){const X=M[0],H=M[M.length-1];let J=0;for(const $ of fs(B,X,H)){const K=$.value,re=Math.max($.start,X),oe=Math.min($.end,H);for(let se=re;se<=oe;se++)V.push({data:F==null?void 0:F[se],index:se,offset:J,size:K}),J+=K}}if(!j)return ys([],V,N,A,R,z);const Y=M.length>0?M[M.length-1]+1:0,he=Pw(G,C,E,Y);if(he.length===0)return null;const ae=N-1,_e=ds([],X=>{for(const H of he){const J=H.value;let $=J.offset,K=H.start;const re=J.size;if(J.offset<C){K+=Math.floor((C-J.offset+A)/(re+A));const se=K-H.start;$+=se*re+se*A}K<Y&&($+=(Y-K)*re,K=Y);const oe=Math.min(H.end,ae);for(let se=K;se<=oe&&!($>=E);se++)X.push({data:F==null?void 0:F[se],index:se,offset:$,size:re}),$+=re+A}});return ys(_e,V,N,A,R,z)}),Ae(C=>C!==null),ut()),pa);ge(U(e,Ae(Qi),fe(C=>C==null?void 0:C.length)),o),ge(U(b,fe(C=>C.topListHeight)),f),ge(f,a),ge(U(b,fe(C=>[C.top,C.bottom])),i),ge(U(b,fe(C=>C.items)),g);const S=Yt(U(b,Ae(({items:C})=>C.length>0),De(o,e),Ae(([{items:C},E])=>C[C.length-1].originalIndex===E-1),fe(([,C,E])=>[C-1,E]),ut(Xr),fe(([C])=>C))),k=Yt(U(b,_n(200),Ae(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),fe(({items:C})=>C[0].index),ut())),T=Yt(U(b,Ae(({items:C})=>C.length>0),fe(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),ut(Ld)));return{endReached:S,initialItemCount:v,itemsRendered:g,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:m,...p}},ct(Cn,Hd,fa,Qr,Zr,no,Fn,aa),{singleton:!0}),Xd=Je(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=qe(),i=Ot(U(Et(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(zt,nr),{singleton:!0}),Kw=Je(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Z(!1),r=Ot(U(Et(n,e,t),Ae(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),_n(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(zt,Xd),{singleton:!0}),Jd=Je(()=>({context:Z(null)})),qw=({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,Zd=Je(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=qe();return ge(U(d,De(t,l,n,s,o,r,a),De(e),fe(([[f,p,h,x,m,v,g,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=qw,done:E,...N}=f,_=zd(f,p,x-1),L=Jr(_,p.offsetTree,S)+m+v,j=L+dn(p.sizeTree,_)[1],M=b+v,z=b+h-g,A=C({itemBottom:j,itemTop:L,locationParams:{align:k,behavior:T,...N},viewportBottom:z,viewportTop:M});return A?E&&un(U(i,Ae(F=>!F),Qn(Tt(i)?1:2)),E):E&&E(),A}),Ae(f=>f!==null)),c),{scrollIntoView:d}},ct(Cn,zt,Zr,nr,Ln),{singleton:!0});function Qd(e){return e?e==="smooth"?"smooth":"auto":!1}const Gw=(e,t)=>typeof e=="function"?Qd(e(t)):t&&Qd(e),Yw=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 x=Z(!1),m=qe();let v=null;function g(T){Me(i,{align:"end",behavior:T,index:"LAST"})}tt(U(Et(U(Ee(t),Qn(1)),l),De(Ee(x),s,a,f),fe(([[T,C],E,N,_,L])=>{let j=C&&_,M="auto";return j&&(M=Gw(E,N||L),j=j&&!!M),{followOutputBehavior:M,shouldFollow:j,totalCount:T}}),Ae(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{v&&(v(),v=null),Tt(n)?requestAnimationFrame(()=>{Tt(d)("following output to ",{totalCount:C},Ut.DEBUG),g(T)}):v=un(e,()=>{Tt(d)("following output to ",{totalCount:C},Ut.DEBUG),g(T),v=null})});function b(T){const C=un(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!v&&(Tt(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),g("auto"))});setTimeout(C,100)}tt(U(Et(Ee(x),t,c),Ae(([T,,C])=>T&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ae(({refreshed:T})=>T),De(x,t)),([,T])=>{Tt(a)&&b(T!==!1)}),tt(m,()=>{b(Tt(x)!==!1)}),tt(Et(Ee(x),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Z(null),k=qe();return ge(ta(U(Ee(r),fe(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),U(Ee(t))),k),tt(U(Et(U(k,Qn(1)),l),De(Ee(S),a,f,p),fe(([[T,C],E,N,_,L])=>C&&N&&(E==null?void 0:E({context:L,totalCount:T,scrollingInProgress:_}))),Ae(T=>!!T),_n(0)),T=>{v&&(v(),v=null),Tt(n)?requestAnimationFrame(()=>{Tt(d)("scrolling into view",{}),Me(h,T)}):v=un(e,()=>{Tt(d)("scrolling into view",{}),Me(h,T),v=null})}),{autoscrollToBottom:m,followOutput:x,scrollIntoViewOnChange:S}},ct(Cn,no,Zr,Qr,Fn,Ln,zt,Jd,Zd)),Xw=Je(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(U(a,De(s),Ae(([,l])=>l!==0),De(o,r,t,n,e),fe(([[,l],c,d,f,p,h=[]])=>Gd(l,c,d,f,p,h))),i),{}),ct(Cn,Qr,nr,Fn),{singleton:!0}),Jw=Je(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Z(0);return tt(U(e,De(r),Ae(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(U(n,Qn(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},ct(Fn,zt,nr),{singleton:!0}),ef=Je(([{scrollVelocity:e}])=>{const t=Z(!1),n=qe(),r=Z(!1);return ge(U(e,De(r,t,n),Ae(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ut()),t),tt(U(Et(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(no),{singleton:!0}),ha=Je(([{scrollContainerState:e,scrollTo:t}])=>{const n=qe(),r=qe(),o=qe(),s=Z(!1),i=Z(void 0);return ge(U(Et(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(U(t,De(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(zt)),Zw=Je(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=qe(),d=Z(void 0),f=Z(null),p=Z(null);return ge(a,f),ge(l,p),tt(U(c,De(t,r,i,f,p,n)),([h,x,m,v,g,b,S])=>{const k=Mw(x.sizeTree);v&&g!==null&&b!==null&&(m=g.scrollTop-b.offsetTop),m-=S,h({ranges:k,scrollTop:m})}),ge(U(d,Ae(Qi),fe(Qw)),o),ge(U(s,De(d),Ae(([,h])=>h!==void 0),ut(),fe(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},ct(Cn,zt,Qr,Fn,ha));function Qw(e){return{align:"start",index:0,offset:e.scrollTop}}const e0=Je(([{topItemsIndexes:e}])=>{const t=Z(0);return ge(U(t,Ae(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(nr));function tf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const t0=tf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),n0=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:x}])=>{const m=Yt(U(l,De(i),Sn(([,g,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const _=k+C;let L=0;return b===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(L=_-S,L!==0&&(L+=N))),[L,T,E,_]},[0,[],0,0]),Ae(([g])=>g!==0),De(r,a,n,o,h,x),Ae(([,g,b,S,,,k])=>!k&&!S&&g!==0&&b===eo),fe(([[g],,,,,b])=>(b("Upward scrolling compensation",{amount:g},Ut.DEBUG),g))));function v(g){g>0?(Me(t,{behavior:"auto",top:-g}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-g}))}return tt(U(m,De(e,s)),([g,b,S])=>{S&&t0()?Me(e,b-g):v(-g)}),tt(U(Et(Ot(s,!1),e,x),Ae(([g,b,S])=>!g&&!S&&b!==0),fe(([g,b])=>b),_n(1)),v),ge(U(f,fe(g=>({top:-g}))),t),tt(U(c,De(p,d),fe(([g,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(g);{let E=0;const N=Yr(k,0);let _=0,L=0;for(;_<g;){_++,E+=N;let j=b.length===L+1?1/0:b[L+1]-b[L]-1;_+j>g&&(E-=N,j=g-_+1),_+=j,E+=C(j),L++}return E}})),g=>{Me(e,g),requestAnimationFrame(()=>{Me(t,{top:g}),requestAnimationFrame(()=>{Me(e,0),Me(x,!1)})})}),{deviation:e}},ct(zt,no,nr,Cn,Ln,aa)),r0=Je(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ct(fa,Xw,Fn,ef,Xd,Jw,Kw,ha,Zd,Ln,Jd)),nf=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:x},m,v,g,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},_])=>(ge(k.rangeChanged,_.scrollSeekRangeChanged),ge(U(_.windowViewportRect,fe(L=>L.visibleHeight)),m.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:b,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,..._,...m,sizes:l,...v}),ct(Cn,Qr,zt,Zw,Yw,nr,Zr,n0,e0,Hd,r0));function o0(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 vs=typeof document<"u"?w.useLayoutEffect:w.useEffect;function rf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(v,g){v.propsReady&&Me(v.propsReady,!1);for(const b of r){const S=v[t.required[b]];Me(S,g[b])}for(const b of o)if(b in g){const S=v[t.optional[b]];Me(S,g[b])}v.propsReady&&Me(v.propsReady,!0)}function c(v){return s.reduce((g,b)=>(g[b]=S=>{const k=v[t.methods[b]];Me(k,S)},g),{})}function d(v){return i.reduce((g,b)=>(g[b]=bw(v[t.events[b]]),g),{})}const f=w.forwardRef((v,g)=>{const{children:b,...S}=v,[k]=w.useState(()=>ds(Sw(e),E=>{l(E,S)})),[T]=w.useState(Ed(d,k));vs(()=>{for(const E of i)E in S&&tt(T[E],S[E]);return()=>{Object.values(T).map(ea)}},[S,T,k]),vs(()=>{l(k,S)}),w.useImperativeHandle(g,Td(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...o0([...r,...o,...i],S),children:b}):b})}),p=v=>{const g=w.useContext(a);return w.useCallback(b=>{Me(g[v],b)},[g,v])},h=v=>{const g=w.useContext(a)[v],b=w.useCallback(S=>tt(g,S),[g]);return w.useSyncExternalStore(b,()=>Tt(g),()=>Tt(g))},x=v=>{const g=w.useContext(a)[v],[b,S]=w.useState(Ed(Tt,g));return vs(()=>tt(g,k=>{k!==b&&S(Td(k))}),[g,b]),b},m=w.version.startsWith("18")?h:x;return{Component:f,useEmitter:(v,g)=>{const b=w.useContext(a)[v];vs(()=>tt(b,g),[g,b])},useEmitterValue:m,usePublisher:p}}const of=w.createContext(void 0),sf=w.createContext(void 0),af=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ma(e){return"self"in e}function s0(e){return"body"in e}function lf(e,t,n,r=Tr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(p=>{let h,x,m;const v=p.target;if(s0(v)||ma(v)){const b=ma(v)?v:v.defaultView;m=s?b.scrollX:b.scrollY,h=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else m=s?v.scrollLeft:v.scrollTop,h=s?v.scrollWidth:v.scrollHeight,x=s?v.offsetWidth:v.offsetHeight;const g=()=>{e({scrollHeight:h,scrollTop:Math.max(m,0),viewportHeight:x})};p.suppressFlushSync?g():Gs.flushSync(g),a.current!==null&&(m===a.current||m<=0||m===h-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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 x=p.behavior==="smooth";let m,v,g;ma(h)?(v=Math.max($n(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),m=s?h.innerWidth:h.innerHeight,g=s?window.scrollX:window.scrollY):(v=h[s?"scrollWidth":"scrollHeight"],m=$n(h,s?"width":"height"),g=h[s?"scrollLeft":"scrollTop"]);const b=v-m;if(p.top=Math.ceil(Math.max(Math.min(b,p.top),0)),Wd(m,v)||p.top===g){e({scrollHeight:v,scrollTop:g,viewportHeight:m}),x&&t(!0);return}x?(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 ga="-webkit-sticky",cf="sticky",xa=tf(()=>{if(typeof document>"u")return cf;const e=document.createElement("div");return e.style.position=ga,e.style.position===ga?ga:cf});function ya(e){return e}const i0=Je(()=>{const e=Z(a=>`Item ${a}`),t=Z(a=>`Group ${a}`),n=Z({}),r=Z(ya),o=Z("div"),s=Z(Tr),i=(a,l=null)=>Ot(U(n,fe(c=>c[a]),ut()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),a0=Je(([e,t])=>({...e,...t}),ct(nf,i0)),l0=({height:e})=>u.jsx("div",{style:{height:e}}),c0={overflowAnchor:"none",position:xa(),zIndex:1},uf={overflowAnchor:"none"},u0={...uf,display:"inline-block",height:"100%"},df=w.memo(function({showTopList:e=!1}){const t=je("listState"),n=nn("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=nn("windowScrollContainerState"),i=nn("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),c=je("context"),d=je("groupContent"),f=je("trackItemSizes"),p=je("itemSize"),h=je("log"),x=nn("gap"),m=je("horizontalDirection"),{callbackRef:v}=kw(n,p,f,e?Tr:a,h,x,o,m,je("skipAnimationFrameInResizeObserver")),[g,b]=w.useState(0);va("deviation",A=>{g!==A&&b(A)});const S=je("EmptyPlaceholder"),k=je("ScrollSeekPlaceholder")||l0,T=je("ListComponent"),C=je("ItemComponent"),E=je("GroupComponent"),N=je("computeItemKey"),_=je("isSeeking"),L=je("groupIndices").length>0,j=je("alignToBottom"),M=je("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...m?{display:"inline-block",height:"100%",marginLeft:g!==0?g:j?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:j?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Mt(S,c)}):u.jsx(T,{...Mt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:z,children:(e?t.topItems:t.items).map(A=>{const F=A.originalIndex,R=N(F+t.firstItemIndex,A.data,c);return _?w.createElement(k,{...Mt(k,c),height:A.size,index:A.index,key:R,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":F,"data-item-index":A.index,"data-known-size":A.size,key:R,style:c0},d(A.index,c)):w.createElement(C,{...Mt(C,c),...h0(C,A.data),"data-index":F,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:R,style:m?u0:uf},L?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),d0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},f0={outline:"none",overflowX:"auto",position:"relative"},bs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),p0={position:xa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function h0(e,t){return{item:typeof e=="string"?void 0:t}}const m0=w.memo(function(){const e=je("HeaderComponent"),t=nn("headerHeight"),n=je("HeaderFooterTag"),r=er(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),g0=w.memo(function(){const e=je("FooterComponent"),t=nn("footerHeight"),n=je("HeaderFooterTag"),r=er(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function ff({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:h,scrollToCallback:x}=lf(a,c,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?f0:d0,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function pf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),p=t("customScrollParent"),h=w.useRef(null),x=t("scrollerRef"),{scrollByCallback:m,scrollerRef:v,scrollToCallback:g}=lf(a,c,l,x,p);return af(()=>{var b;return v.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{v.current=null}},[v,p]),e("windowScrollTo",g),e("scrollBy",m),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const x0=({children:e})=>{const t=w.useContext(of),n=nn("viewportHeight"),r=nn("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=w.useMemo(()=>kd(n,l=>$n(l,s?"width":"height")),[n,s]),a=er(i,!0,je("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:bs(o),children:e})},y0=({children:e})=>{const t=w.useContext(of),n=nn("windowViewportRect"),r=nn("fixedItemHeight"),o=je("customScrollParent"),s=_d(n,o,je("skipAnimationFrameInResizeObserver")),i=je("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:bs(i),children:e})},v0=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...p0,marginTop:`${n}px`},o=je("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},b0=w.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return u.jsxs(r||t?C0:S0,{...e,context:o,children:[n&&u.jsx(v0,{children:u.jsx(df,{showTopList:!0})}),u.jsxs(r||t?y0:x0,{children:[u.jsx(m0,{}),u.jsx(df,{}),u.jsx(g0,{})]})]})}),{Component:w0,useEmitter:va,useEmitterValue:je,usePublisher:nn}=rf(a0,{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"}},b0),S0=ff({useEmitter:va,useEmitterValue:je,usePublisher:nn}),C0=pf({useEmitter:va,useEmitterValue:je,usePublisher:nn}),T0=w0;ct(nf,Je(()=>{const e=Z(c=>u.jsxs("td",{children:["Item $",c]})),t=Z(null),n=Z(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Z(null),o=Z(null),s=Z({}),i=Z(ya),a=Z(Tr),l=(c,d=null)=>Ot(U(s,fe(f=>f[c]),ut()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),xa();const hf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},k0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:mf,floor:ws,max:ro,min:ba,round:gf}=Math;function xf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function E0(e){return{...k0,items:e}}function Ss(e,t){return e&&e.width===t.width&&e.height===t.height}function I0(e,t){return e&&e.column===t.column&&e.row===t.row}const N0=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:x,propsReady:m},{customScrollParent:v,useWindowScroll:g,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Z(0),E=Z(0),N=Z(hf),_=Z({height:0,width:0}),L=Z({height:0,width:0}),j=qe(),M=qe(),z=Z(0),A=Z(null),F=Z({column:0,row:0}),R=qe(),G=qe(),B=Z(!1),D=Z(0),V=Z(!0),Y=Z(!1),he=Z(!1);tt(U(x,De(D),Ae(([$,K])=>!!K)),()=>{Me(V,!1)}),tt(U(Et(x,V,L,_,D,Y),Ae(([$,K,re,oe,,se])=>$&&!K&&re.height!==0&&oe.height!==0&&!se)),([,,,,$])=>{Me(Y,!0),ua(1,()=>{Me(j,$)}),un(U(c),()=>{Me(t,[0,0]),Me(V,!0)})}),ge(U(G,Ae($=>$!=null&&$.scrollTop>0),wn(0)),E),tt(U(x,De(G),Ae(([,$])=>$!=null)),([,$])=>{$&&(Me(_,$.viewport),Me(L,$.item),Me(F,$.gap),$.scrollTop>0&&(Me(B,!0),un(U(c,Qn(1)),K=>{Me(B,!1)}),Me(l,{top:$.scrollTop})))}),ge(U(_,fe(({height:$})=>$)),f),ge(U(Et(Ee(_,Ss),Ee(L,Ss),Ee(F,($,K)=>$&&$.column===K.column&&$.row===K.row),Ee(c)),fe(([$,K,re,oe])=>({gap:re,item:K,scrollTop:oe,viewport:$}))),R),ge(U(Et(Ee(C),r,Ee(F,I0),Ee(L,Ss),Ee(_,Ss),Ee(A),Ee(E),Ee(B),Ee(V),Ee(D)),Ae(([,,,,,,,$])=>!$),fe(([$,[K,re],oe,se,Te,Ye,Le,,Ge,de])=>{const{column:be,row:ze}=oe,{height:Ue,width:We}=se,{width:nt}=Te;if(Le===0&&($===0||nt===0))return hf;if(We===0){const vt=da(de,$),xt=vt+Math.max(Le-1,0);return E0(xf(vt,xt,Ye))}const $e=yf(nt,We,be);let Fe,rt;Ge?K===0&&re===0&&Le>0?(Fe=0,rt=Le-1):(Fe=$e*ws((K+ze)/(Ue+ze)),rt=$e*mf((re+ze)/(Ue+ze))-1,rt=ba($-1,ro(rt,$e-1)),Fe=ba(rt,ro(0,Fe))):(Fe=0,rt=-1);const It=xf(Fe,rt,Ye),{bottom:dt,top:ft}=vf(Te,oe,se,It),pt=mf($/$e),yt=pt*Ue+(pt-1)*ze-dt;return{bottom:dt,itemHeight:Ue,items:It,itemWidth:We,offsetBottom:yt,offsetTop:ft,top:ft}})),N),ge(U(A,Ae($=>$!==null),fe($=>$.length)),C),ge(U(Et(_,L,N,F),Ae(([$,K,{items:re}])=>re.length>0&&K.height!==0&&$.height!==0),fe(([$,K,{items:re},oe])=>{const{bottom:se,top:Te}=vf($,oe,K,re);return[Te,se]}),ut(Xr)),t);const ae=Z(!1);ge(U(c,De(ae),fe(([$,K])=>K||$!==0)),ae);const _e=Yt(U(Et(N,C),Ae(([{items:$}])=>$.length>0),De(ae),Ae(([[$,K],re])=>{const oe=$.items[$.items.length-1].index===K-1;return(re||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===K)&&oe}),fe(([[,$]])=>$-1),ut())),X=Yt(U(Ee(N),Ae(({items:$})=>$.length>0&&$[0].index===0),wn(0),ut())),H=Yt(U(Ee(N),De(B),Ae(([{items:$},K])=>$.length>0&&!K),fe(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ut(Ld),_n(0)));ge(H,h.scrollSeekRangeChanged),ge(U(j,De(_,L,C,F),fe(([$,K,re,oe,se])=>{const Te=Ud($),{align:Ye,behavior:Le,offset:Ge}=Te;let de=Te.index;de==="LAST"&&(de=oe-1),de=ro(0,de,ba(oe-1,de));let be=wa(K,se,re,de);return Ye==="end"?be=gf(be-K.height+re.height):Ye==="center"&&(be=gf(be-K.height/2+re.height/2)),Ge&&(be+=Ge),{behavior:Le,top:be}})),l);const J=Ot(U(N,fe($=>$.offsetBottom+$.bottom)),0);return ge(U(k,fe($=>({height:$.visibleHeight,width:$.visibleWidth}))),_),{customScrollParent:v,data:A,deviation:z,footerHeight:o,gap:F,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:G,scrollBy:i,scrollContainerState:a,scrollHeight:M,scrollTo:l,scrollToIndex:j,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...h,gridState:N,horizontalDirection:he,initialTopMostItemIndex:D,totalListHeight:J,...p,endReached:_e,propsReady:m,rangeChanged:H,startReached:X,stateChanged:R,stateRestoreInProgress:B,...T}},ct(fa,zt,no,ef,Fn,ha,Ln));function yf(e,t,n){return ro(1,ws((e+n)/(ws(t)+n)))}function vf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=wa(e,t,n,r[0].index);return{bottom:wa(e,t,n,r[r.length-1].index)+o,top:s}}function wa(e,t,n,r){const o=yf(e.width,n.width,t.column),s=ws(r/o),i=s*n.height+ro(0,s-1)*t.row;return i>0?i+t.row:i}const A0=Je(()=>{const e=Z(f=>`Item ${f}`),t=Z({}),n=Z(null),r=Z("virtuoso-grid-item"),o=Z("virtuoso-grid-list"),s=Z(ya),i=Z("div"),a=Z(Tr),l=(f,p=null)=>Ot(U(t,fe(h=>h[f]),ut()),p),c=Z(!1),d=Z(!1);return ge(Ee(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),_0=Je(([e,t])=>({...e,...t}),ct(N0,A0)),j0=w.memo(function(){const e=gt("gridState"),t=gt("listClassName"),n=gt("itemClassName"),r=gt("itemContent"),o=gt("computeItemKey"),s=gt("isSeeking"),i=rn("scrollHeight"),a=gt("ItemComponent"),l=gt("ListComponent"),c=gt("ScrollSeekPlaceholder"),d=gt("context"),f=rn("itemDimensions"),p=rn("gap"),h=gt("log"),x=gt("stateRestoreInProgress"),m=rn("reportReadyState"),v=er(w.useMemo(()=>g=>{const b=g.parentElement.parentElement.scrollHeight;i(b);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}p({column:wf("column-gap",getComputedStyle(g).columnGap,h),row:wf("row-gap",getComputedStyle(g).rowGap,h)})},[i,f,p,h]),!0,!1);return af(()=>{e.itemHeight>0&&e.itemWidth>0&&m(!0)},[e]),x?null:u.jsx(l,{className:t,ref:v,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const b=o(g.index,g.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":g.index,key:b},r(g.index,g.data,d))})})}),R0=w.memo(function(){const e=gt("HeaderComponent"),t=rn("headerHeight"),n=gt("headerFooterTag"),r=er(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),P0=w.memo(function(){const e=gt("FooterComponent"),t=rn("footerHeight"),n=gt("headerFooterTag"),r=er(w.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),O0=({children:e})=>{const t=w.useContext(sf),n=rn("itemDimensions"),r=rn("viewportDimensions"),o=er(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:bs(!1),children:e})},M0=({children:e})=>{const t=w.useContext(sf),n=rn("windowViewportRect"),r=rn("itemDimensions"),o=gt("customScrollParent"),s=_d(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:bs(!1),children:e})},D0=w.memo(function({...e}){const t=gt("useWindowScroll"),n=gt("customScrollParent"),r=n||t?$0:L0,o=n||t?M0:O0,s=gt("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(R0,{}),u.jsx(j0,{}),u.jsx(P0,{})]})})}),{useEmitter:bf,useEmitterValue:gt,usePublisher:rn}=rf(_0,{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"}},D0),L0=ff({useEmitter:bf,useEmitterValue:gt,usePublisher:rn}),$0=pf({useEmitter:bf,useEmitterValue:gt,usePublisher:rn});function wf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}const F0=ho.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 Sf({className:e,variant:t,...n}){return u.jsx("div",{className:ee(F0({variant:t}),e),...n})}const oo=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));oo.displayName="Card";const so=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));so.displayName="CardHeader";const io=y.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));io.displayName="CardTitle";const Cf=y.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Cf.displayName="CardDescription";const ao=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));ao.displayName="CardContent";const Tf=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));Tf.displayName="CardFooter";const z0=1,B0=1e6;let Sa=0;function H0(){return Sa=(Sa+1)%Number.MAX_SAFE_INTEGER,Sa.toString()}const Ca=new Map,kf=e=>{if(Ca.has(e))return;const t=setTimeout(()=>{Ca.delete(e),lo({type:"REMOVE_TOAST",toastId:e})},B0);Ca.set(e,t)},U0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,z0)};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?kf(n):e.toasts.forEach(r=>{kf(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)}}},Cs=[];let Ts={toasts:[]};function lo(e){Ts=U0(Ts,e),Cs.forEach(t=>{t(Ts)})}function W0({...e}){const t=H0(),n=o=>lo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>lo({type:"DISMISS_TOAST",toastId:t});return lo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ta(){const[e,t]=y.useState(Ts);return y.useEffect(()=>(Cs.push(t),()=>{const n=Cs.indexOf(t);n>-1&&Cs.splice(n,1)}),[e]),{...e,toast:W0,dismiss:n=>lo({type:"DISMISS_TOAST",toastId:n})}}async function Ef(e,t){return await Zt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function If(e,t){return await(await Ef(`/files/${e}/view`,t)).text()}async function V0(e,t){const n=await Ef(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Zt(`/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 K0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Zt("/files",{params:r})}function ka(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 Nf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function co(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(co).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Nf(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=co(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 uo(e){if(typeof e=="string")return e;if(Nf(e))return"";try{const t=co(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function q0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function G0(e){const t=uo(e);return typeof e=="string"&&q0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function ks(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=ka(t);if(n!==null)return ks(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?ks(e.content):e}const Y0={MODE:"library"};function X0(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ys&&Ys.tagName.toUpperCase()==="SCRIPT"&&Ys.src||new URL("index.umd.js",document.baseURI).href}<"u"?Y0:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function J0(){return!X0()}function Z0(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function Q0(){return J0()||Z0()}var Es="Dialog",[Af,jT]=En(Es),[eS,fn]=Af(Es),_f=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=y.useRef(null),l=y.useRef(null),[c,d]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:Es});return u.jsx(eS,{scope:t,triggerRef:a,contentRef:l,contentId:In(),titleId:In(),descriptionId:In(),open:c,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};_f.displayName=Es;var jf="DialogTrigger",Rf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(jf,n),s=Ke(t,o.triggerRef);return u.jsx(Re.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Na(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});Rf.displayName=jf;var Ea="DialogPortal",[tS,Pf]=Af(Ea,{forceMount:void 0}),Of=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Ea,t);return u.jsx(tS,{scope:t,forceMount:n,children:y.Children.map(r,i=>u.jsx(en,{present:n||s.open,children:u.jsx(Go,{asChild:!0,container:o,children:i})}))})};Of.displayName=Ea;var Is="DialogOverlay",Mf=y.forwardRef((e,t)=>{const n=Pf(Is,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(Is,e.__scopeDialog);return s.modal?u.jsx(en,{present:r||s.open,children:u.jsx(rS,{...o,ref:t})}):null});Mf.displayName=Is;var nS=Kn.createSlot("DialogOverlay.RemoveScroll"),rS=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Is,n);return u.jsx(rs,{as:nS,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(Re.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rr="DialogContent",Df=y.forwardRef((e,t)=>{const n=Pf(rr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(rr,e.__scopeDialog);return u.jsx(en,{present:r||s.open,children:s.modal?u.jsx(oS,{...o,ref:t}):u.jsx(sS,{...o,ref:t})})});Df.displayName=rr;var oS=y.forwardRef((e,t)=>{const n=fn(rr,e.__scopeDialog),r=y.useRef(null),o=Ke(t,n.contentRef,r);return y.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),u.jsx(Lf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),sS=y.forwardRef((e,t)=>{const n=fn(rr,e.__scopeDialog),r=y.useRef(!1),o=y.useRef(!1);return u.jsx(Lf,{...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()}})}),Lf=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(rr,n),l=y.useRef(null),c=Ke(t,l);return bi(),u.jsxs(u.Fragment,{children:[u.jsx(Do,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Mo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(iS,{titleId:a.titleId}),u.jsx(lS,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",$f=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ia,n);return u.jsx(Re.h2,{id:o.titleId,...r,ref:t})});$f.displayName=Ia;var Ff="DialogDescription",zf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ff,n);return u.jsx(Re.p,{id:o.descriptionId,...r,ref:t})});zf.displayName=Ff;var Bf="DialogClose",Hf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Bf,n);return u.jsx(Re.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});Hf.displayName=Bf;function Na(e){return e?"open":"closed"}var Uf="DialogTitleWarning",[RT,Wf]=ix(Uf,{contentName:rr,titleName:Ia,docsSlug:"dialog"}),iS=({titleId:e})=>{const t=Wf(Uf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
86
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function gw(e,t=cs){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 xw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),gw(t),mw(t)}const us=0,Mn=1,Sr=2,Cd=4;function Td(e){return()=>e}function yw(e){e()}function kd(e,t){return n=>e(t(n))}function Ed(e,t){return()=>e(t)}function vw(e,t){return n=>e(t,n)}function Qi(e){return e!==void 0}function bw(...e){return()=>{e.map(yw)}}function Cr(){}function ds(e,t){return t(e),e}function ww(e,t){return t(e)}function dt(...e){return e}function nt(e,t){return e(Mn,t)}function Oe(e,t){e(us,t)}function ea(e){e(Sr)}function Tt(e){return e(Cd)}function xe(e,t){return nt(e,vw(t,us))}function un(e,t){const n=e(Mn,r=>{n(),t(r)});return n}function Id(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Nd(e,t){return e===t}function ft(e=Nd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>kd(t,e)}function wn(e){return t=>()=>{t(e)}}function U(e,...t){const n=Sw(...t);return(r,o)=>{switch(r){case Sr:ea(e);return;case Mn:return nt(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Zn(e){return t=>n=>{e>0?e--:t(n)}}function _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);nt(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 Sw(...e){return t=>e.reduceRight(ww,t)}function Cw(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Mn:return s?n===s?void 0:(r(),n=s,t=nt(e,s),t):(r(),Cr);case Sr:r(),n=null;return}}}function Z(e){let t=e;const n=qe();return(r,o)=>{switch(r){case us:t=o;break;case Mn:{o(t);break}case Cd:return t}return n(r,o)}}function Ot(e,t){return ds(Z(t),n=>xe(e,n))}function qe(){const e=[];return(t,n)=>{switch(t){case us:e.slice().forEach(r=>{r(n)});return;case Sr:e.splice(0,e.length);return;case Mn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Yt(e){return ds(qe(),t=>xe(e,t))}function Ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Tw(),singleton:n}}const Tw=()=>Symbol();function kw(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 Et(...e){const t=qe(),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);nt(s,l=>{n[i]=l,r=r|a,r===o&&Oe(t,n)})}),function(s,i){switch(s){case Sr:{ea(t);return}case Mn:return r===o&&i(n),nt(t,i)}}}function ke(e,t=Nd){return U(e,ft(t))}function ta(...e){return function(t,n){switch(t){case Sr:return;case Mn:return bw(...e.map(r=>nt(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const Ew={0:"debug",3:"error",1:"log",2:"warn"},Iw=()=>typeof globalThis>"u"?window:globalThis,Dn=Ze(()=>{const e=Z(3);return{log:Z((t,n,r=1)=>{var o;const s=(o=Iw().VIRTUOSO_LOG_LEVEL)!=null?o:Tt(e);r>=s&&console[Ew[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Qn(e,t,n){return na(e,t,n).callbackRef}function na(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Nw(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const f=Aw(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 x;h&&(x=p.ownerDocument.defaultView);const m=i?a?i.scrollLeft:i.scrollTop:h?a?x.scrollX||x.document.documentElement.scrollLeft:x.scrollY||x.document.documentElement.scrollTop:a?p.scrollLeft:p.scrollTop,v=i?a?i.scrollWidth:i.scrollHeight:h?a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight:a?p.scrollWidth:p.scrollHeight,g=i?a?i.offsetWidth:i.offsetHeight:h?a?x.innerWidth:x.innerHeight:a?p.offsetWidth:p.offsetHeight;r({scrollHeight:v,scrollTop:Math.max(m,0),viewportHeight:g}),s==null||s(a?Ad("column-gap",getComputedStyle(d).columnGap,o):Ad("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return na(c,n,l)}function Aw(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},Ut.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 Ad(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function _d(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let f,p;if(t){const h=t.getBoundingClientRect(),x=c.top-h.top;p=h.height-Math.max(0,x),f=x+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}=na(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const zt=Ze(()=>{const e=qe(),t=qe(),n=Z(0),r=qe(),o=Z(0),s=qe(),i=qe(),a=Z(0),l=Z(0),c=Z(0),d=Z(0),f=qe(),p=qe(),h=Z(!1),x=Z(!1),m=Z(!1);return xe(U(e,fe(({scrollTop:v})=>v)),t),xe(U(e,fe(({scrollHeight:v})=>v)),i),xe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:x,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:m,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),qr={lvl:0};function jd(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===qr}function Gr(e,t){if(!lt(e))return t===e.k?e.v:t<e.k?Gr(e.l,t):Gr(e.r,t)}function dn(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=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Xt(e,t,n){return lt(e)?Od(t,n,1):t===e.k?At(e,{k:t,v:n}):t<e.k?Md(At(e,{l:Xt(e.l,t,n)})):Md(At(e,{r:Xt(e.r,t,n)}))}function Tr(){return qr}function fs(e,t,n){if(lt(e))return[];const r=dn(e,t)[0];return _w(oa(e,r,n))}function ra(e,t){if(lt(e))return qr;const{k:n,l:r,r:o}=e;if(t===n){if(lt(r))return o;if(lt(o))return r;{const[s,i]=Pd(r);return ps(At(e,{k:s,l:Rd(r),v:i}))}}else return t<n?ps(At(e,{l:ra(r,t)})):ps(At(e,{r:ra(o,t)}))}function er(e){return lt(e)?[]:[...er(e.l),{k:e.k,v:e.v},...er(e.r)]}function oa(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(oa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(oa(s,t,n))),a}function ps(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(sa(t))return Dd(At(e,{lvl:n-1}));if(!lt(t)&&!lt(t.r))return At(t.r,{l:At(t,{r:t.r.l}),lvl:n,r:At(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(sa(e))return ia(At(e,{lvl:n-1}));if(!lt(r)&&!lt(r.l)){const o=r.l,s=sa(o)?r.lvl-1:r.lvl;return At(o,{l:At(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ia(At(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return Od(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 Rd(e){return lt(e.r)?e.l:ps(At(e,{r:Rd(e.r)}))}function sa(e){return lt(e)||e.lvl>e.r.lvl}function Pd(e){return lt(e.r)?[e.k,e.v]:Pd(e.r)}function Od(e,t,n,r=qr,o=qr){return{k:e,l:r,lvl:n,r:o,v:t}}function Md(e){return ia(Dd(e))}function Dd(e){const{l:t}=e;return!lt(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function ia(e){const{lvl:t,r:n}=e;return!lt(n)&&!lt(n.r)&&n.lvl===t&&n.r.lvl===t?At(n,{l:At(e,{r:n.l}),lvl:t+1}):e}function _w(e){return jd(e,({k:t,v:n})=>({index:t,value:n}))}function Ld(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Yr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const aa=Ze(()=>({recalcInProgress:Z(!1)}),[],{singleton:!0});function $d(e,t,n){return e[hs(e,t,n)]}function hs(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 jw(e,t,n,r){const o=hs(e,t,r),s=hs(e,n,r,o);return e.slice(o,s+1)}function Ln(e,t){return Math.round(e.getBoundingClientRect()[t])}function ms(e){return!lt(e.groupOffsetTree)}function la({index:e},t){return t===e?0:t<e?-1:1}function Rw(){return{groupIndices:[],groupOffsetTree:Tr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Tr()}}function Pw(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=Xt(e,0,s);continue}const a=fs(e,i-1,o+1);if(a.some(zw(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:p}of a)l?(o>=f||s===p)&&(e=ra(e,f)):(c=p!==s,l=!0),d>o&&o>=f&&p!==s&&(e=Xt(e,o+1,p));c&&(e=Xt(e,i,s))}return[e,n]}function Ow(e){return typeof e.groupIndex<"u"}function Mw({offset:e},t){return t===e?0:t<e?-1:1}function Xr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=$d(t,e,la),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Fd(e,t){if(!ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function zd(e,t,n){if(Ow(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Fd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Dw(e,t,n,r=0){return r>0&&(t=Math.max(t,$d(e,r,la).offset)),jd(jw(e,t,n,Mw),Fw)}function Lw(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&lt(s)&&t.length===2){const p=t[0].size,h=t[1].size;i=n.reduce((x,m)=>Xt(Xt(x,m,p),m+1,h),i)}else[i,a]=Pw(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=ca(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((p,h)=>Xt(p,h,Xr(h,f,o)),Tr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function $w(e){return er(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function Bd(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 ca(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=hs(o,t-1,la),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of fs(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 Fw(e){return{index:e.index,value:e}}function zw(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 Bw={offsetHeight:"height",offsetWidth:"width"},Cn=Ze(([{log:e},{recalcInProgress:t}])=>{const n=qe(),r=qe(),o=Ot(r,0),s=qe(),i=qe(),a=Z(0),l=Z([]),c=Z(void 0),d=Z(void 0),f=Z((T,C)=>Ln(T,Bw[C])),p=Z(void 0),h=Z(0),x=Rw(),m=Ot(U(n,Me(l,e,h),Sn(Lw,x),ft()),x),v=Ot(U(l,ft(),Sn((T,C)=>({current:C,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);xe(U(l,Ne(T=>T.length>0),Me(m,h),fe(([T,C,E])=>{const N=T.reduce((j,L,_)=>Xt(j,L,Xr(L,C.offsetTree,E)||_),Tr());return{...C,groupIndices:T,groupOffsetTree:N}})),m),xe(U(r,Me(m),Ne(([T,{lastIndex:C}])=>T<C),fe(([T,{lastIndex:C,lastSize:E}])=>[{endIndex:C,size:E,startIndex:T}])),n),xe(c,d);const g=Ot(U(c,fe(T=>T===void 0)),!0);xe(U(d,Ne(T=>T!==void 0&&lt(Tt(m).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const b=Yt(U(n,Me(m),Sn(({sizes:T},[C,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:x}),fe(T=>T.changed)));nt(U(a,Sn((T,C)=>({diff:T.prev-C,prev:C}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:C}=Tt(m);if(T>0)Oe(t,!0),Oe(s,T+Bd(T,C));else if(T<0){const E=Tt(v);E.length>0&&(T-=Bd(-T,E)),Oe(i,T)}}),nt(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},Ut.ERROR)});const S=Yt(s);xe(U(s,Me(m),fe(([T,C])=>{const E=C.groupIndices.length>0,N=[],j=C.lastSize;if(E){const L=Gr(C.sizeTree,0);let _=0,M=0;for(;_<T;){const A=C.groupIndices[M],F=C.groupIndices.length===M+1?1/0:C.groupIndices[M+1]-A-1;N.push({endIndex:A,size:L,startIndex:A}),N.push({endIndex:A+1+F-1,size:j,startIndex:A+1}),M++,_+=F+1}const z=er(C.sizeTree);return _!==T&&z.shift(),z.reduce((A,{k:F,v:R})=>{let G=A.ranges;return A.prevSize!==0&&(G=[...A.ranges,{endIndex:F+T-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:F+T,prevSize:R,ranges:G}},{prevIndex:T,prevSize:0,ranges:N}).ranges}return er(C.sizeTree).reduce((L,{k:_,v:M})=>({prevIndex:_+T,prevSize:M,ranges:[...L.ranges,{endIndex:_+T-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Yt(U(i,Me(m,h),fe(([T,{offsetTree:C},E])=>{const N=-T;return Xr(N,C,E)})));return xe(U(i,Me(m,h),fe(([T,C,E])=>{if(C.groupIndices.length>0){if(lt(C.sizeTree))return C;let N=Tr();const j=Tt(v);let L=0,_=0,M=0;for(;L<-T;){M=j[_];const z=j[_+1]-M-1;_++,L+=z+1}if(N=er(C.sizeTree).reduce((z,{k:A,v:F})=>Xt(z,Math.max(0,A+T),F),N),L!==-T){const z=Gr(C.sizeTree,M);N=Xt(N,0,z);const A=dn(C.sizeTree,-T+1)[1];N=Xt(N,1,A)}return{...C,sizeTree:N,...ca(C.offsetTree,0,N,E)}}else{const N=er(C.sizeTree).reduce((j,{k:L,v:_})=>Xt(j,Math.max(0,L+T),_),Tr());return{...C,sizeTree:N,...ca(C.offsetTree,0,N,E)}}})),m),{beforeUnshiftWith:S,data:p,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:m,statefulTotalCount:o,totalCount:r,trackItemSizes:g,unshiftWith:s}},dt(Dn,aa),{singleton:!0});function Hw(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Hd=Ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=qe(),i=qe(),a=Yt(U(s,fe(Hw)));return xe(U(a,fe(l=>l.totalCount)),n),xe(U(a,fe(l=>l.groupIndices)),e),xe(U(Et(o,t,r),Ne(([l,c])=>ms(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ft(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},dt(Cn,zt)),$n=Ze(([{log:e}])=>{const t=Z(!1),n=Yt(U(t,Ne(r=>r),ft()));return nt(t,r=>{r&&Tt(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},dt(Dn),{singleton:!0}),Uw=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ud(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Uw)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Jr=Ze(([{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=qe(),x=qe(),m=Z(0);let v=null,g=null,b=null;function S(){v&&(v(),v=null),b&&(b(),b=null),g&&(clearTimeout(g),g=null),Oe(l,!1)}return xe(U(h,Me(n,f,r,m,a,i,p),Me(e,s,o),fe(([[k,T,C,E,N,j,L,_],M,z,A])=>{const F=Ud(k),{align:R,behavior:G,offset:B}=F,D=E-1,V=zd(F,T,D);let Y=Xr(V,T.offsetTree,M)+j;R==="end"?(Y+=z+dn(T.sizeTree,V)[1]-C+A,V===D&&(Y+=L)):R==="center"?Y+=(z+dn(T.sizeTree,V)[1]-C+A)/2:Y-=N,B&&(Y+=B);const he=ie=>{S(),ie?(_("retrying to scroll to",{location:k},Ut.DEBUG),Oe(h,k)):(Oe(x,!0),_("list did not change, scroll successful",{},Ut.DEBUG))};if(S(),G==="smooth"){let ie=!1;b=nt(t,Ae=>{ie=ie||Ae}),v=un(d,()=>{he(ie)})}else v=un(U(t,Ww(150)),he);return g=setTimeout(()=>{S()},1200),Oe(l,!0),_("scrolling from index to",{behavior:G,index:V,top:Y},Ut.DEBUG),{behavior:G,top:Y}})),c),{scrollTargetReached:x,scrollToIndex:h,topListHeight:m}},dt(Cn,zt,Dn),{singleton:!0});function Ww(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ua(e,t){e==0?t():requestAnimationFrame(()=>{ua(e-1,t)})}function da(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Zr=Ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Z(!0),l=Z(0),c=Z(!0);return xe(U(i,Me(l),Ne(([d,f])=>!!f),wn(!1)),a),xe(U(i,Me(l),Ne(([d,f])=>!!f),wn(!1)),c),nt(U(Et(t,i),Me(a,n,e,c),Ne(([[,d],f,{sizeTree:p},h,x])=>d&&(!lt(p)||Qi(h))&&!f&&!x),Me(l)),([,d])=>{un(o,()=>{Oe(c,!0)}),ua(4,()=>{un(r,()=>{Oe(a,!0)}),Oe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},dt(Cn,zt,Jr,$n),{singleton:!0});function Wd(e,t){return Math.abs(e-t)<1.01}const Qr="up",eo="down",Vw="none",Kw={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},qw=0,to=Ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Z(!1),a=Z(!0),l=qe(),c=qe(),d=Z(4),f=Z(qw),p=Ot(U(ta(U(ke(o),Zn(1),wn(!0)),U(ke(o),Zn(1),wn(!1),Id(100))),ft()),!1),h=Ot(U(ta(U(n,wn(!0)),U(n,wn(!1),Id(200))),ft()),!1);xe(U(Et(ke(o),ke(f)),fe(([b,S])=>b<=S),ft()),a),xe(U(a,_n(50)),c);const x=Yt(U(Et(r,ke(s),ke(t),ke(e),ke(d)),Sn((b,[{scrollHeight:S,scrollTop:k},T,C,E,N])=>{const j=k+T-S>-N,L={scrollHeight:S,scrollTop:k,viewportHeight:T};if(j){let M,z;return k>b.state.scrollTop?(M="SCROLLED_DOWN",z=b.state.scrollTop-k):(M="SIZE_DECREASED",z=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:z,state:L}}let _;return L.scrollHeight>b.state.scrollHeight?_="SIZE_INCREASED":T<b.state.viewportHeight?_="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?_="SCROLLING_UPWARDS":_="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:_,state:L}},Kw),ft((b,S)=>b&&b.atBottom===S.atBottom))),m=Ot(U(r,Sn((b,{scrollHeight:S,scrollTop:k,viewportHeight:T})=>{if(Wd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const C=S-(k+T)<1;return b.scrollTop!==k&&C?{changed:!0,jump:b.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ne(b=>b.changed),fe(b=>b.jump)),0);xe(U(x,fe(b=>b.atBottom)),i),xe(U(i,_n(50)),l);const v=Z(eo);xe(U(r,fe(({scrollTop:b})=>b),ft(),Sn((b,S)=>Tt(h)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Qr:eo,prevScrollTop:S},{direction:eo,prevScrollTop:0}),fe(b=>b.direction)),v),xe(U(r,_n(50),wn(Vw)),v);const g=Z(0);return xe(U(p,Ne(b=>!b),wn(0)),g),xe(U(o,_n(100),Me(p),Ne(([b,S])=>!!S),Sn(([b,S],[k])=>[S,k],[0,0]),fe(([b,S])=>S-b)),g),{atBottomState:x,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:p,lastJumpDueToItemResize:m,scrollDirection:v,scrollVelocity:g}},dt(zt)),gs="top",xs="bottom",Vd="none";function Kd(e,t,n){return typeof e=="number"?n===Qr&&t===gs||n===eo&&t===xs?e:0:n===Qr?t===gs?e.main:e.reverse:t===xs?e.main:e.reverse}function qd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const fa=Ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=qe(),i=Z(0),a=Z(0),l=Z(0),c=Ot(U(Et(ke(r),ke(o),ke(n),ke(s,Yr),ke(l),ke(i),ke(t),ke(e),ke(a)),fe(([d,f,p,[h,x],m,v,g,b,S])=>{const k=d-b,T=v+g,C=Math.max(p-k,0);let E=Vd;const N=qd(S,gs),j=qd(S,xs);return h-=b,h+=p+g,x+=p+g,x-=b,h>d+T-N&&(E=Qr),x<d-C+f+j&&(E=eo),E!==Vd?[Math.max(k-p-Kd(m,gs,E)-N,0),k-C-g+f+Kd(m,xs,E)+j]:null}),Ne(d=>d!=null),ft(Yr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},dt(zt),{singleton:!0});function Gw(e,t,n){if(ms(t)){const r=Fd(e,t);return[{index:dn(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 pa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ys(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 m=e[e.length-1];d=m.offset+m.size}const f=n-i,p=a+f*l+(f-1)*r,h=c,x=p-d;return{bottom:d,firstItemIndex:s,items:Yd(e,o,s),offsetBottom:x,offsetTop:c,top:h,topItems:Yd(t,o,s),topListHeight:t.reduce((m,v)=>v.size+m,0),totalCount:n}}function Gd(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=da(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ys(c,[],a,o,n,r)}function Yd(e,t,n){if(e.length===0)return[];if(!ms(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=fs(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const tr=Ze(([{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:x}])=>{const m=Z([]),v=Z(0),g=qe();xe(s.topItemsIndexes,m);const b=Ot(U(Et(h,x,ke(l,Yr),ke(o),ke(r),ke(c),d,ke(m),ke(t),ke(n),e),Ne(([C,E,,N,,,,,,,j])=>{const L=j&&j.length!==N;return C&&!E&&!L}),fe(([,,[C,E],N,j,L,_,M,z,A,F])=>{const R=j,{offsetTree:G,sizeTree:B}=R,D=Tt(v);if(N===0)return{...pa,totalCount:N};if(C===0&&E===0)return D===0?{...pa,totalCount:N}:Gd(D,L,j,z,A,F||[]);if(lt(B))return D>0?null:ys(Gw(da(L,N),R,F),[],N,A,R,z);const V=[];if(M.length>0){const X=M[0],H=M[M.length-1];let J=0;for(const $ of fs(B,X,H)){const K=$.value,re=Math.max($.start,X),oe=Math.min($.end,H);for(let se=re;se<=oe;se++)V.push({data:F==null?void 0:F[se],index:se,offset:J,size:K}),J+=K}}if(!_)return ys([],V,N,A,R,z);const Y=M.length>0?M[M.length-1]+1:0,he=Dw(G,C,E,Y);if(he.length===0)return null;const ie=N-1,Ae=ds([],X=>{for(const H of he){const J=H.value;let $=J.offset,K=H.start;const re=J.size;if(J.offset<C){K+=Math.floor((C-J.offset+A)/(re+A));const se=K-H.start;$+=se*re+se*A}K<Y&&($+=(Y-K)*re,K=Y);const oe=Math.min(H.end,ie);for(let se=K;se<=oe&&!($>=E);se++)X.push({data:F==null?void 0:F[se],index:se,offset:$,size:re}),$+=re+A}});return ys(Ae,V,N,A,R,z)}),Ne(C=>C!==null),ft()),pa);xe(U(e,Ne(Qi),fe(C=>C==null?void 0:C.length)),o),xe(U(b,fe(C=>C.topListHeight)),f),xe(f,a),xe(U(b,fe(C=>[C.top,C.bottom])),i),xe(U(b,fe(C=>C.items)),g);const S=Yt(U(b,Ne(({items:C})=>C.length>0),Me(o,e),Ne(([{items:C},E])=>C[C.length-1].originalIndex===E-1),fe(([,C,E])=>[C-1,E]),ft(Yr),fe(([C])=>C))),k=Yt(U(b,_n(200),Ne(({items:C,topItems:E})=>C.length>0&&C[0].originalIndex===E.length),fe(({items:C})=>C[0].index),ft())),T=Yt(U(b,Ne(({items:C})=>C.length>0),fe(({items:C})=>{let E=0,N=C.length-1;for(;C[E].type==="group"&&E<N;)E++;for(;C[N].type==="group"&&N>E;)N--;return{endIndex:C[N].index,startIndex:C[E].index}}),ft(Ld)));return{endReached:S,initialItemCount:v,itemsRendered:g,listState:b,rangeChanged:T,startReached:k,topItemsIndexes:m,...p}},dt(Cn,Hd,fa,Zr,Jr,to,$n,aa),{singleton:!0}),Xd=Ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=qe(),i=Ot(U(Et(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return xe(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},dt(zt,tr),{singleton:!0}),Yw=Ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Z(!1),r=Ot(U(Et(n,e,t),Ne(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),_n(0),ft()),0);return{alignToBottom:n,paddingTopAddition:r}},dt(zt,Xd),{singleton:!0}),Jd=Ze(()=>({context:Z(null)})),Xw=({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,Zd=Ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=qe();return xe(U(d,Me(t,l,n,s,o,r,a),Me(e),fe(([[f,p,h,x,m,v,g,b],S])=>{const{align:k,behavior:T,calculateViewLocation:C=Xw,done:E,...N}=f,j=zd(f,p,x-1),L=Xr(j,p.offsetTree,S)+m+v,_=L+dn(p.sizeTree,j)[1],M=b+v,z=b+h-g,A=C({itemBottom:_,itemTop:L,locationParams:{align:k,behavior:T,...N},viewportBottom:z,viewportTop:M});return A?E&&un(U(i,Ne(F=>!F),Zn(Tt(i)?1:2)),E):E&&E(),A}),Ne(f=>f!==null)),c),{scrollIntoView:d}},dt(Cn,zt,Jr,tr,Dn),{singleton:!0});function Qd(e){return e?e==="smooth"?"smooth":"auto":!1}const Jw=(e,t)=>typeof e=="function"?Qd(e(t)):t&&Qd(e),Zw=Ze(([{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 x=Z(!1),m=qe();let v=null;function g(T){Oe(i,{align:"end",behavior:T,index:"LAST"})}nt(U(Et(U(ke(t),Zn(1)),l),Me(ke(x),s,a,f),fe(([[T,C],E,N,j,L])=>{let _=C&&j,M="auto";return _&&(M=Jw(E,N||L),_=_&&!!M),{followOutputBehavior:M,shouldFollow:_,totalCount:T}}),Ne(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{v&&(v(),v=null),Tt(n)?requestAnimationFrame(()=>{Tt(d)("following output to ",{totalCount:C},Ut.DEBUG),g(T)}):v=un(e,()=>{Tt(d)("following output to ",{totalCount:C},Ut.DEBUG),g(T),v=null})});function b(T){const C=un(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!v&&(Tt(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),g("auto"))});setTimeout(C,100)}nt(U(Et(ke(x),t,c),Ne(([T,,C])=>T&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),Ne(({refreshed:T})=>T),Me(x,t)),([,T])=>{Tt(a)&&b(T!==!1)}),nt(m,()=>{b(Tt(x)!==!1)}),nt(Et(ke(x),o),([T,C])=>{T&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const S=Z(null),k=qe();return xe(ta(U(ke(r),fe(T=>{var C;return(C=T==null?void 0:T.length)!=null?C:0})),U(ke(t))),k),nt(U(Et(U(k,Zn(1)),l),Me(ke(S),a,f,p),fe(([[T,C],E,N,j,L])=>C&&N&&(E==null?void 0:E({context:L,totalCount:T,scrollingInProgress:j}))),Ne(T=>!!T),_n(0)),T=>{v&&(v(),v=null),Tt(n)?requestAnimationFrame(()=>{Tt(d)("scrolling into view",{}),Oe(h,T)}):v=un(e,()=>{Tt(d)("scrolling into view",{}),Oe(h,T),v=null})}),{autoscrollToBottom:m,followOutput:x,scrollIntoViewOnChange:S}},dt(Cn,to,Jr,Zr,$n,Dn,zt,Jd,Zd)),Qw=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(U(a,Me(s),Ne(([,l])=>l!==0),Me(o,r,t,n,e),fe(([[,l],c,d,f,p,h=[]])=>Gd(l,c,d,f,p,h))),i),{}),dt(Cn,Zr,tr,$n),{singleton:!0}),e0=Ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Z(0);return nt(U(e,Me(r),Ne(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(U(n,Zn(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Oe(t,o)})})}),{initialScrollTop:r}},dt($n,zt,tr),{singleton:!0}),ef=Ze(([{scrollVelocity:e}])=>{const t=Z(!1),n=qe(),r=Z(!1);return xe(U(e,Me(r,t,n),Ne(([o,s])=>!!s),fe(([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}),ft()),t),nt(U(Et(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}},dt(to),{singleton:!0}),ha=Ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=qe(),r=qe(),o=qe(),s=Z(!1),i=Z(void 0);return xe(U(Et(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(U(t,Me(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},dt(zt)),t0=Ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=qe(),d=Z(void 0),f=Z(null),p=Z(null);return xe(a,f),xe(l,p),nt(U(c,Me(t,r,i,f,p,n)),([h,x,m,v,g,b,S])=>{const k=$w(x.sizeTree);v&&g!==null&&b!==null&&(m=g.scrollTop-b.offsetTop),m-=S,h({ranges:k,scrollTop:m})}),xe(U(d,Ne(Qi),fe(n0)),o),xe(U(s,Me(d),Ne(([,h])=>h!==void 0),ft(),fe(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},dt(Cn,zt,Zr,$n,ha));function n0(e){return{align:"start",index:0,offset:e.scrollTop}}const r0=Ze(([{topItemsIndexes:e}])=>{const t=Z(0);return xe(U(t,Ne(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},dt(tr));function tf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const o0=tf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),s0=Ze(([{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:x}])=>{const m=Yt(U(l,Me(i),Sn(([,g,b,S],[{bottom:k,items:T,offsetBottom:C,totalCount:E},N])=>{const j=k+C;let L=0;return b===E&&g.length>0&&T.length>0&&(T[0].originalIndex===0&&g[0].originalIndex===0||(L=j-S,L!==0&&(L+=N))),[L,T,E,j]},[0,[],0,0]),Ne(([g])=>g!==0),Me(r,a,n,o,h,x),Ne(([,g,b,S,,,k])=>!k&&!S&&g!==0&&b===Qr),fe(([[g],,,,,b])=>(b("Upward scrolling compensation",{amount:g},Ut.DEBUG),g))));function v(g){g>0?(Oe(t,{behavior:"auto",top:-g}),Oe(e,0)):(Oe(e,0),Oe(t,{behavior:"auto",top:-g}))}return nt(U(m,Me(e,s)),([g,b,S])=>{S&&o0()?Oe(e,b-g):v(-g)}),nt(U(Et(Ot(s,!1),e,x),Ne(([g,b,S])=>!g&&!S&&b!==0),fe(([g,b])=>b),_n(1)),v),xe(U(f,fe(g=>({top:-g}))),t),nt(U(c,Me(p,d),fe(([g,{groupIndices:b,lastSize:S,sizeTree:k},T])=>{function C(E){return E*(S+T)}if(b.length===0)return C(g);{let E=0;const N=Gr(k,0);let j=0,L=0;for(;j<g;){j++,E+=N;let _=b.length===L+1?1/0:b[L+1]-b[L]-1;j+_>g&&(E-=N,_=g-j+1),j+=_,E+=C(_),L++}return E}})),g=>{Oe(e,g),requestAnimationFrame(()=>{Oe(t,{top:g}),requestAnimationFrame(()=>{Oe(e,0),Oe(x,!1)})})}),{deviation:e}},dt(zt,to,tr,Cn,Dn,aa)),i0=Ze(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),dt(fa,Qw,$n,ef,Xd,e0,Yw,ha,Zd,Dn,Jd)),nf=Ze(([{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:x},m,v,g,{listState:b,topItemsIndexes:S,...k},{scrollToIndex:T},C,{topItemCount:E},{groupCounts:N},j])=>(xe(k.rangeChanged,j.scrollSeekRangeChanged),xe(U(j.windowViewportRect,fe(L=>L.visibleHeight)),m.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:p,initialTopMostItemIndex:h,scrolledToInitialItem:x,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...g,groupIndices:s,itemSize:i,listState:b,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...k,...j,...m,sizes:l,...v}),dt(Cn,Zr,zt,t0,Zw,tr,Jr,s0,r0,Hd,i0));function a0(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 vs=typeof document<"u"?w.useLayoutEffect:w.useEffect;function rf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(v,g){v.propsReady&&Oe(v.propsReady,!1);for(const b of r){const S=v[t.required[b]];Oe(S,g[b])}for(const b of o)if(b in g){const S=v[t.optional[b]];Oe(S,g[b])}v.propsReady&&Oe(v.propsReady,!0)}function c(v){return s.reduce((g,b)=>(g[b]=S=>{const k=v[t.methods[b]];Oe(k,S)},g),{})}function d(v){return i.reduce((g,b)=>(g[b]=Cw(v[t.events[b]]),g),{})}const f=w.forwardRef((v,g)=>{const{children:b,...S}=v,[k]=w.useState(()=>ds(kw(e),E=>{l(E,S)})),[T]=w.useState(Ed(d,k));vs(()=>{for(const E of i)E in S&&nt(T[E],S[E]);return()=>{Object.values(T).map(ea)}},[S,T,k]),vs(()=>{l(k,S)}),w.useImperativeHandle(g,Td(c(k)));const C=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(C,{...a0([...r,...o,...i],S),children:b}):b})}),p=v=>{const g=w.useContext(a);return w.useCallback(b=>{Oe(g[v],b)},[g,v])},h=v=>{const g=w.useContext(a)[v],b=w.useCallback(S=>nt(g,S),[g]);return w.useSyncExternalStore(b,()=>Tt(g),()=>Tt(g))},x=v=>{const g=w.useContext(a)[v],[b,S]=w.useState(Ed(Tt,g));return vs(()=>nt(g,k=>{k!==b&&S(Td(k))}),[g,b]),b},m=w.version.startsWith("18")?h:x;return{Component:f,useEmitter:(v,g)=>{const b=w.useContext(a)[v];vs(()=>nt(b,g),[g,b])},useEmitterValue:m,usePublisher:p}}const of=w.createContext(void 0),sf=w.createContext(void 0),af=typeof document<"u"?w.useLayoutEffect:w.useEffect;function ma(e){return"self"in e}function l0(e){return"body"in e}function lf(e,t,n,r=Cr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(p=>{let h,x,m;const v=p.target;if(l0(v)||ma(v)){const b=ma(v)?v:v.defaultView;m=s?b.scrollX:b.scrollY,h=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,x=s?b.innerWidth:b.innerHeight}else m=s?v.scrollLeft:v.scrollTop,h=s?v.scrollWidth:v.scrollHeight,x=s?v.offsetWidth:v.offsetHeight;const g=()=>{e({scrollHeight:h,scrollTop:Math.max(m,0),viewportHeight:x})};p.suppressFlushSync?g():Gs.flushSync(g),a.current!==null&&(m===a.current||m<=0||m===h-x)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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 x=p.behavior==="smooth";let m,v,g;ma(h)?(v=Math.max(Ln(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),m=s?h.innerWidth:h.innerHeight,g=s?window.scrollX:window.scrollY):(v=h[s?"scrollWidth":"scrollHeight"],m=Ln(h,s?"width":"height"),g=h[s?"scrollLeft":"scrollTop"]);const b=v-m;if(p.top=Math.ceil(Math.max(Math.min(b,p.top),0)),Wd(m,v)||p.top===g){e({scrollHeight:v,scrollTop:g,viewportHeight:m}),x&&t(!0);return}x?(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 ga="-webkit-sticky",cf="sticky",xa=tf(()=>{if(typeof document>"u")return cf;const e=document.createElement("div");return e.style.position=ga,e.style.position===ga?ga:cf});function ya(e){return e}const c0=Ze(()=>{const e=Z(a=>`Item ${a}`),t=Z(a=>`Group ${a}`),n=Z({}),r=Z(ya),o=Z("div"),s=Z(Cr),i=(a,l=null)=>Ot(U(n,fe(c=>c[a]),ft()),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")}}),u0=Ze(([e,t])=>({...e,...t}),dt(nf,c0)),d0=({height:e})=>u.jsx("div",{style:{height:e}}),f0={overflowAnchor:"none",position:xa(),zIndex:1},uf={overflowAnchor:"none"},p0={...uf,display:"inline-block",height:"100%"},df=w.memo(function({showTopList:e=!1}){const t=_e("listState"),n=nn("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=nn("windowScrollContainerState"),i=nn("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),p=_e("itemSize"),h=_e("log"),x=nn("gap"),m=_e("horizontalDirection"),{callbackRef:v}=Nw(n,p,f,e?Cr:a,h,x,o,m,_e("skipAnimationFrameInResizeObserver")),[g,b]=w.useState(0);va("deviation",A=>{g!==A&&b(A)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||d0,T=_e("ListComponent"),C=_e("ItemComponent"),E=_e("GroupComponent"),N=_e("computeItemKey"),j=_e("isSeeking"),L=_e("groupIndices").length>0,_=_e("alignToBottom"),M=_e("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...m?{display:"inline-block",height:"100%",marginLeft:g!==0?g:_?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:_?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Mt(S,c)}):u.jsx(T,{...Mt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:z,children:(e?t.topItems:t.items).map(A=>{const F=A.originalIndex,R=N(F+t.firstItemIndex,A.data,c);return j?w.createElement(k,{...Mt(k,c),height:A.size,index:A.index,key:R,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":F,"data-item-index":A.index,"data-known-size":A.size,key:R,style:f0},d(A.index,c)):w.createElement(C,{...Mt(C,c),...x0(C,A.data),"data-index":F,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:R,style:m?p0:uf},L?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),h0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},m0={outline:"none",overflowX:"auto",position:"relative"},bs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),g0={position:xa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function x0(e,t){return{item:typeof e=="string"?void 0:t}}const y0=w.memo(function(){const e=_e("HeaderComponent"),t=nn("headerHeight"),n=_e("HeaderFooterTag"),r=Qn(w.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),v0=w.memo(function(){const e=_e("FooterComponent"),t=nn("footerHeight"),n=_e("HeaderFooterTag"),r=Qn(w.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function ff({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:h,scrollToCallback:x}=lf(a,c,l,d,void 0,f);return e("scrollTo",x),e("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?m0:h0,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function pf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),p=t("customScrollParent"),h=w.useRef(null),x=t("scrollerRef"),{scrollByCallback:m,scrollerRef:v,scrollToCallback:g}=lf(a,c,l,x,p);return af(()=>{var b;return v.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{v.current=null}},[v,p]),e("windowScrollTo",g),e("scrollBy",m),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const b0=({children:e})=>{const t=w.useContext(of),n=nn("viewportHeight"),r=nn("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=w.useMemo(()=>kd(n,l=>Ln(l,s?"width":"height")),[n,s]),a=Qn(i,!0,_e("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:bs(o),children:e})},w0=({children:e})=>{const t=w.useContext(of),n=nn("windowViewportRect"),r=nn("fixedItemHeight"),o=_e("customScrollParent"),s=_d(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:bs(i),children:e})},S0=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...g0,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},C0=w.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?E0:k0,{...e,context:o,children:[n&&u.jsx(S0,{children:u.jsx(df,{showTopList:!0})}),u.jsxs(r||t?w0:b0,{children:[u.jsx(y0,{}),u.jsx(df,{}),u.jsx(v0,{})]})]})}),{Component:T0,useEmitter:va,useEmitterValue:_e,usePublisher:nn}=rf(u0,{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"}},C0),k0=ff({useEmitter:va,useEmitterValue:_e,usePublisher:nn}),E0=pf({useEmitter:va,useEmitterValue:_e,usePublisher:nn}),I0=T0;dt(nf,Ze(()=>{const e=Z(c=>u.jsxs("td",{children:["Item $",c]})),t=Z(null),n=Z(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=Z(null),o=Z(null),s=Z({}),i=Z(ya),a=Z(Cr),l=(c,d=null)=>Ot(U(s,fe(f=>f[c]),ft()),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")}})),xa();const hf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},N0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:mf,floor:ws,max:no,min:ba,round:gf}=Math;function xf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function A0(e){return{...N0,items:e}}function Ss(e,t){return e&&e.width===t.width&&e.height===t.height}function _0(e,t){return e&&e.column===t.column&&e.row===t.row}const j0=Ze(([{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:x,propsReady:m},{customScrollParent:v,useWindowScroll:g,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k},T])=>{const C=Z(0),E=Z(0),N=Z(hf),j=Z({height:0,width:0}),L=Z({height:0,width:0}),_=qe(),M=qe(),z=Z(0),A=Z(null),F=Z({column:0,row:0}),R=qe(),G=qe(),B=Z(!1),D=Z(0),V=Z(!0),Y=Z(!1),he=Z(!1);nt(U(x,Me(D),Ne(([$,K])=>!!K)),()=>{Oe(V,!1)}),nt(U(Et(x,V,L,j,D,Y),Ne(([$,K,re,oe,,se])=>$&&!K&&re.height!==0&&oe.height!==0&&!se)),([,,,,$])=>{Oe(Y,!0),ua(1,()=>{Oe(_,$)}),un(U(c),()=>{Oe(t,[0,0]),Oe(V,!0)})}),xe(U(G,Ne($=>$!=null&&$.scrollTop>0),wn(0)),E),nt(U(x,Me(G),Ne(([,$])=>$!=null)),([,$])=>{$&&(Oe(j,$.viewport),Oe(L,$.item),Oe(F,$.gap),$.scrollTop>0&&(Oe(B,!0),un(U(c,Zn(1)),K=>{Oe(B,!1)}),Oe(l,{top:$.scrollTop})))}),xe(U(j,fe(({height:$})=>$)),f),xe(U(Et(ke(j,Ss),ke(L,Ss),ke(F,($,K)=>$&&$.column===K.column&&$.row===K.row),ke(c)),fe(([$,K,re,oe])=>({gap:re,item:K,scrollTop:oe,viewport:$}))),R),xe(U(Et(ke(C),r,ke(F,_0),ke(L,Ss),ke(j,Ss),ke(A),ke(E),ke(B),ke(V),ke(D)),Ne(([,,,,,,,$])=>!$),fe(([$,[K,re],oe,se,Te,Je,De,,Ye,de])=>{const{column:be,row:Fe}=oe,{height:He,width:Ue}=se,{width:rt}=Te;if(De===0&&($===0||rt===0))return hf;if(Ue===0){const xt=da(de,$),yt=xt+Math.max(De-1,0);return A0(xf(xt,yt,Je))}const Le=yf(rt,Ue,be);let $e,ot;Ye?K===0&&re===0&&De>0?($e=0,ot=De-1):($e=Le*ws((K+Fe)/(He+Fe)),ot=Le*mf((re+Fe)/(He+Fe))-1,ot=ba($-1,no(ot,Le-1)),$e=ba(ot,no(0,$e))):($e=0,ot=-1);const It=xf($e,ot,Je),{bottom:st,top:pt}=vf(Te,oe,se,It),ht=mf($/Le),vt=ht*He+(ht-1)*Fe-st;return{bottom:st,itemHeight:He,items:It,itemWidth:Ue,offsetBottom:vt,offsetTop:pt,top:pt}})),N),xe(U(A,Ne($=>$!==null),fe($=>$.length)),C),xe(U(Et(j,L,N,F),Ne(([$,K,{items:re}])=>re.length>0&&K.height!==0&&$.height!==0),fe(([$,K,{items:re},oe])=>{const{bottom:se,top:Te}=vf($,oe,K,re);return[Te,se]}),ft(Yr)),t);const ie=Z(!1);xe(U(c,Me(ie),fe(([$,K])=>K||$!==0)),ie);const Ae=Yt(U(Et(N,C),Ne(([{items:$}])=>$.length>0),Me(ie),Ne(([[$,K],re])=>{const oe=$.items[$.items.length-1].index===K-1;return(re||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===K)&&oe}),fe(([[,$]])=>$-1),ft())),X=Yt(U(ke(N),Ne(({items:$})=>$.length>0&&$[0].index===0),wn(0),ft())),H=Yt(U(ke(N),Me(B),Ne(([{items:$},K])=>$.length>0&&!K),fe(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ft(Ld),_n(0)));xe(H,h.scrollSeekRangeChanged),xe(U(_,Me(j,L,C,F),fe(([$,K,re,oe,se])=>{const Te=Ud($),{align:Je,behavior:De,offset:Ye}=Te;let de=Te.index;de==="LAST"&&(de=oe-1),de=no(0,de,ba(oe-1,de));let be=wa(K,se,re,de);return Je==="end"?be=gf(be-K.height+re.height):Je==="center"&&(be=gf(be-K.height/2+re.height/2)),Ye&&(be+=Ye),{behavior:De,top:be}})),l);const J=Ot(U(N,fe($=>$.offsetBottom+$.bottom)),0);return xe(U(k,fe($=>({height:$.visibleHeight,width:$.visibleWidth}))),j),{customScrollParent:v,data:A,deviation:z,footerHeight:o,gap:F,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:G,scrollBy:i,scrollContainerState:a,scrollHeight:M,scrollTo:l,scrollToIndex:_,scrollTop:c,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:g,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:k,...h,gridState:N,horizontalDirection:he,initialTopMostItemIndex:D,totalListHeight:J,...p,endReached:Ae,propsReady:m,rangeChanged:H,startReached:X,stateChanged:R,stateRestoreInProgress:B,...T}},dt(fa,zt,to,ef,$n,ha,Dn));function yf(e,t,n){return no(1,ws((e+n)/(ws(t)+n)))}function vf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=wa(e,t,n,r[0].index);return{bottom:wa(e,t,n,r[r.length-1].index)+o,top:s}}function wa(e,t,n,r){const o=yf(e.width,n.width,t.column),s=ws(r/o),i=s*n.height+no(0,s-1)*t.row;return i>0?i+t.row:i}const R0=Ze(()=>{const e=Z(f=>`Item ${f}`),t=Z({}),n=Z(null),r=Z("virtuoso-grid-item"),o=Z("virtuoso-grid-list"),s=Z(ya),i=Z("div"),a=Z(Cr),l=(f,p=null)=>Ot(U(t,fe(h=>h[f]),ft()),p),c=Z(!1),d=Z(!1);return xe(ke(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),P0=Ze(([e,t])=>({...e,...t}),dt(j0,R0)),O0=w.memo(function(){const e=gt("gridState"),t=gt("listClassName"),n=gt("itemClassName"),r=gt("itemContent"),o=gt("computeItemKey"),s=gt("isSeeking"),i=rn("scrollHeight"),a=gt("ItemComponent"),l=gt("ListComponent"),c=gt("ScrollSeekPlaceholder"),d=gt("context"),f=rn("itemDimensions"),p=rn("gap"),h=gt("log"),x=gt("stateRestoreInProgress"),m=rn("reportReadyState"),v=Qn(w.useMemo(()=>g=>{const b=g.parentElement.parentElement.scrollHeight;i(b);const S=g.firstChild;if(S){const{height:k,width:T}=S.getBoundingClientRect();f({height:k,width:T})}p({column:wf("column-gap",getComputedStyle(g).columnGap,h),row:wf("row-gap",getComputedStyle(g).rowGap,h)})},[i,f,p,h]),!0,!1);return af(()=>{e.itemHeight>0&&e.itemWidth>0&&m(!0)},[e]),x?null:u.jsx(l,{className:t,ref:v,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const b=o(g.index,g.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:g.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":g.index,key:b},r(g.index,g.data,d))})})}),M0=w.memo(function(){const e=gt("HeaderComponent"),t=rn("headerHeight"),n=gt("headerFooterTag"),r=Qn(w.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),D0=w.memo(function(){const e=gt("FooterComponent"),t=rn("footerHeight"),n=gt("headerFooterTag"),r=Qn(w.useMemo(()=>s=>{t(Ln(s,"height"))},[t]),!0,!1),o=gt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),L0=({children:e})=>{const t=w.useContext(sf),n=rn("itemDimensions"),r=rn("viewportDimensions"),o=Qn(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:bs(!1),children:e})},$0=({children:e})=>{const t=w.useContext(sf),n=rn("windowViewportRect"),r=rn("itemDimensions"),o=gt("customScrollParent"),s=_d(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:bs(!1),children:e})},F0=w.memo(function({...e}){const t=gt("useWindowScroll"),n=gt("customScrollParent"),r=n||t?B0:z0,o=n||t?$0:L0,s=gt("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(M0,{}),u.jsx(O0,{}),u.jsx(D0,{})]})})}),{useEmitter:bf,useEmitterValue:gt,usePublisher:rn}=rf(P0,{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"}},F0),z0=ff({useEmitter:bf,useEmitterValue:gt,usePublisher:rn}),B0=pf({useEmitter:bf,useEmitterValue:gt,usePublisher:rn});function wf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}const H0=ho.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 Sf({className:e,variant:t,...n}){return u.jsx("div",{className:ee(H0({variant:t}),e),...n})}const ro=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ro.displayName="Card";const oo=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));oo.displayName="CardHeader";const so=y.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));so.displayName="CardTitle";const Cf=y.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Cf.displayName="CardDescription";const io=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));io.displayName="CardContent";const Tf=y.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));Tf.displayName="CardFooter";const U0=1,W0=1e6;let Sa=0;function V0(){return Sa=(Sa+1)%Number.MAX_SAFE_INTEGER,Sa.toString()}const Ca=new Map,kf=e=>{if(Ca.has(e))return;const t=setTimeout(()=>{Ca.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},W0);Ca.set(e,t)},K0=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,U0)};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?kf(n):e.toasts.forEach(r=>{kf(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)}}},Cs=[];let Ts={toasts:[]};function ao(e){Ts=K0(Ts,e),Cs.forEach(t=>{t(Ts)})}function q0({...e}){const t=V0(),n=o=>ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ao({type:"DISMISS_TOAST",toastId:t});return ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ta(){const[e,t]=y.useState(Ts);return y.useEffect(()=>(Cs.push(t),()=>{const n=Cs.indexOf(t);n>-1&&Cs.splice(n,1)}),[e]),{...e,toast:q0,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}async function Ef(e,t){return await Zt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function If(e,t){return await(await Ef(`/files/${e}/view`,t)).text()}async function G0(e,t){const n=await Ef(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Zt(`/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 Y0(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Zt("/files",{params:r})}function ka(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 Nf(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function lo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(lo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Nf(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=lo(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 co(e){if(typeof e=="string")return e;if(Nf(e))return"";try{const t=lo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function X0(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function J0(e){const t=co(e);return typeof e=="string"&&X0(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function ks(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=ka(t);if(n!==null)return ks(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?ks(e.content):e}const Z0={MODE:"library"};function Q0(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ys&&Ys.tagName.toUpperCase()==="SCRIPT"&&Ys.src||new URL("index.umd.js",document.baseURI).href}<"u"?Z0:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function eS(){return!Q0()}function tS(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function nS(){return eS()||tS()}var Es="Dialog",[Af,OT]=En(Es),[rS,fn]=Af(Es),_f=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=y.useRef(null),l=y.useRef(null),[c,d]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:Es});return u.jsx(rS,{scope:t,triggerRef:a,contentRef:l,contentId:In(),titleId:In(),descriptionId:In(),open:c,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};_f.displayName=Es;var jf="DialogTrigger",Rf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(jf,n),s=Ke(t,o.triggerRef);return u.jsx(je.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Na(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});Rf.displayName=jf;var Ea="DialogPortal",[oS,Pf]=Af(Ea,{forceMount:void 0}),Of=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Ea,t);return u.jsx(oS,{scope:t,forceMount:n,children:y.Children.map(r,i=>u.jsx(en,{present:n||s.open,children:u.jsx(Go,{asChild:!0,container:o,children:i})}))})};Of.displayName=Ea;var Is="DialogOverlay",Mf=y.forwardRef((e,t)=>{const n=Pf(Is,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(Is,e.__scopeDialog);return s.modal?u.jsx(en,{present:r||s.open,children:u.jsx(iS,{...o,ref:t})}):null});Mf.displayName=Is;var sS=Vn.createSlot("DialogOverlay.RemoveScroll"),iS=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Is,n);return u.jsx(rs,{as:sS,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(je.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),nr="DialogContent",Df=y.forwardRef((e,t)=>{const n=Pf(nr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(nr,e.__scopeDialog);return u.jsx(en,{present:r||s.open,children:s.modal?u.jsx(aS,{...o,ref:t}):u.jsx(lS,{...o,ref:t})})});Df.displayName=nr;var aS=y.forwardRef((e,t)=>{const n=fn(nr,e.__scopeDialog),r=y.useRef(null),o=Ke(t,n.contentRef,r);return y.useEffect(()=>{const s=r.current;if(s)return Fi(s)},[]),u.jsx(Lf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),lS=y.forwardRef((e,t)=>{const n=fn(nr,e.__scopeDialog),r=y.useRef(!1),o=y.useRef(!1);return u.jsx(Lf,{...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()}})}),Lf=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(nr,n),l=y.useRef(null),c=Ke(t,l);return bi(),u.jsxs(u.Fragment,{children:[u.jsx(Do,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Mo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(cS,{titleId:a.titleId}),u.jsx(dS,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",$f=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ia,n);return u.jsx(je.h2,{id:o.titleId,...r,ref:t})});$f.displayName=Ia;var Ff="DialogDescription",zf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ff,n);return u.jsx(je.p,{id:o.descriptionId,...r,ref:t})});zf.displayName=Ff;var Bf="DialogClose",Hf=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Bf,n);return u.jsx(je.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});Hf.displayName=Bf;function Na(e){return e?"open":"closed"}var Uf="DialogTitleWarning",[MT,Wf]=ax(Uf,{contentName:nr,titleName:Ia,docsSlug:"dialog"}),cS=({titleId:e})=>{const t=Wf(Uf),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 y.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},aS="DialogDescriptionWarning",lS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wf(aS).contentName}}.`;return y.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},Vf=_f,cS=Rf,Kf=Of,Ns=Mf,As=Df,or=$f,_s=zf,qf=Hf;const uS=Vf,dS=Kf,Gf=y.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{ref:n,className:ee("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}));Gf.displayName=Ns.displayName;const Yf=y.forwardRef(({className:e,children:t,...n},r)=>{const o=y.useMemo(()=>{let s=!1;function i(a){y.Children.forEach(a,l=>{if(s||!y.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(dS,{children:[u.jsx(Gf,{}),u.jsxs(As,{ref:r,className:ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs(qf,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Yf.displayName=As.displayName;const Xf=({className:e,...t})=>u.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Xf.displayName="DialogHeader";const Jf=y.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));Jf.displayName=or.displayName;const fS=y.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));fS.displayName=_s.displayName;function pS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:f}=Ta(),p=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const g=await If(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]);w.useEffect(()=>{e&&n&&p()},[e,n,p]);const h=async()=>{if(n)try{await V0(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"})}},x=async()=>{if(n)try{const g=await If(n),b=new Blob([g],{type:o}),S=URL.createObjectURL(b);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"})}},m=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ce.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(et,{onClick:p,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(ce.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"})}),v=()=>o.startsWith("image/")?u.jsx(ce.Image,{className:"h-5 w-5"}):u.jsx(ce.FileText,{className:"h-5 w-5"});return u.jsx(uS,{open:e,onOpenChange:t,children:u.jsxs(Yf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Xf,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[v(),u.jsxs("div",{children:[u.jsx(Jf,{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(et,{variant:"outline",size:"sm",onClick:x,className:"flex items-center gap-2",children:[u.jsx(ce.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(et,{variant:"outline",size:"sm",onClick:h,className:"flex items-center gap-2",children:[u.jsx(ce.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:m()})]})})}function Zf(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let sr=Zf();function hS(e){sr=e}const Qf=/[&<>"']/,mS=new RegExp(Qf.source,"g"),ep=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,gS=new RegExp(ep.source,"g"),xS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},tp=e=>xS[e];function Dt(e,t){if(t){if(Qf.test(e))return e.replace(mS,tp)}else if(ep.test(e))return e.replace(gS,tp);return e}const yS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function np(e){return e.replace(yS,(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 vS=/(^|[^\[])\^/g;function at(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(vS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const bS=/[^\w:]/g,wS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rp(e,t,n){if(e){let r;try{r=decodeURIComponent(np(n)).replace(bS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!wS.test(n)&&(n=kS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const js={},SS=/^[^:]+:\/*[^/]*$/,CS=/^([^:]+:)[\s\S]*$/,TS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function kS(e,t){js[" "+e]||(SS.test(e)?js[" "+e]=e+"/":js[" "+e]=Ps(e,"/",!0)),e=js[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(CS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(TS,"$1")+t:e+t}const Rs={exec:function(){}};function op(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 Ps(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function ES(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 IS(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 sp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ip(e,t,n,r){const o=t.href,s=t.title?Dt(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:Dt(i)}}function NS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
90
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return y.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},uS="DialogDescriptionWarning",dS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wf(uS).contentName}}.`;return y.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},Vf=_f,fS=Rf,Kf=Of,Ns=Mf,As=Df,rr=$f,_s=zf,qf=Hf;const pS=Vf,hS=Kf,Gf=y.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{ref:n,className:ee("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}));Gf.displayName=Ns.displayName;const Yf=y.forwardRef(({className:e,children:t,...n},r)=>{const o=y.useMemo(()=>{let s=!1;function i(a){y.Children.forEach(a,l=>{if(s||!y.isValidElement(l))return;const c=l.type;if(c===rr||(c==null?void 0:c.displayName)===rr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(hS,{children:[u.jsx(Gf,{}),u.jsxs(As,{ref:r,className:ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(rr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(qf,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Yf.displayName=As.displayName;const Xf=({className:e,...t})=>u.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Xf.displayName="DialogHeader";const Jf=y.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));Jf.displayName=rr.displayName;const mS=y.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));mS.displayName=_s.displayName;function gS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:f}=Ta(),p=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const g=await If(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]);w.useEffect(()=>{e&&n&&p()},[e,n,p]);const h=async()=>{if(n)try{await G0(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"})}},x=async()=>{if(n)try{const g=await If(n),b=new Blob([g],{type:o}),S=URL.createObjectURL(b);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"})}},m=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ce.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(tt,{onClick:p,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(ce.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"})}),v=()=>o.startsWith("image/")?u.jsx(ce.Image,{className:"h-5 w-5"}):u.jsx(ce.FileText,{className:"h-5 w-5"});return u.jsx(pS,{open:e,onOpenChange:t,children:u.jsxs(Yf,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Xf,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[v(),u.jsxs("div",{children:[u.jsx(Jf,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(tt,{variant:"outline",size:"sm",onClick:x,className:"flex items-center gap-2",children:[u.jsx(ce.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(tt,{variant:"outline",size:"sm",onClick:h,className:"flex items-center gap-2",children:[u.jsx(ce.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:m()})]})})}function Zf(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let or=Zf();function xS(e){or=e}const Qf=/[&<>"']/,yS=new RegExp(Qf.source,"g"),ep=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vS=new RegExp(ep.source,"g"),bS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},tp=e=>bS[e];function Dt(e,t){if(t){if(Qf.test(e))return e.replace(yS,tp)}else if(ep.test(e))return e.replace(vS,tp);return e}const wS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function np(e){return e.replace(wS,(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 SS=/(^|[^\[])\^/g;function ct(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(SS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const CS=/[^\w:]/g,TS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rp(e,t,n){if(e){let r;try{r=decodeURIComponent(np(n)).replace(CS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!TS.test(n)&&(n=NS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const js={},kS=/^[^:]+:\/*[^/]*$/,ES=/^([^:]+:)[\s\S]*$/,IS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function NS(e,t){js[" "+e]||(kS.test(e)?js[" "+e]=e+"/":js[" "+e]=Ps(e,"/",!0)),e=js[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(ES,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(IS,"$1")+t:e+t}const Rs={exec:function(){}};function op(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 Ps(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function AS(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 _S(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 sp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ip(e,t,n,r){const o=t.href,s=t.title?Dt(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:Dt(i)}}function jS(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
- `)}class Aa{constructor(t){this.options=t||sr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Ps(r,`
93
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=NS(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Ps(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,p,h,x,m=n[1].trim();const v=m.length>1,g={type:"list",raw:"",ordered:v,start:v?+m.slice(0,-1):"",loose:!1,items:[]};m=v?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=v?m:"[*+-]");const b=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(x=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
92
+ `)}class Aa{constructor(t){this.options=t||or}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Ps(r,`
93
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=jS(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Ps(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,p,h,x,m=n[1].trim();const v=m.length>1,g={type:"list",raw:"",ordered:v,start:v?+m.slice(0,-1):"",loose:!1,items:[]};m=v?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=v?m:"[*+-]");const b=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(x=!1,!(!(n=b.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
95
  `,1)[0],this.options.pedantic?(i=2,h=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,h=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
96
96
  `,t=t.substring(f.length+1),x=!0),!x){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&&(p=t.split(`
@@ -99,8 +99,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
99
99
  `+f}!l&&!f.trim()&&(l=!0),r+=p+`
100
100
  `,t=t.substring(p.length+1),d=f.slice(i)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(h),o&&(s=o[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:h}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=h.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]):Dt(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:op(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
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]=op(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:Dt(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]):Dt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Ps(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=ES(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)),ip(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 ip(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 p=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}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=Dt(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=Dt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Dt(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=Dt(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=Dt(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]):Dt(r[0]):r[0]:o=Dt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Rs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=at(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=at(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=at(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=at(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=at(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.blockquote=at(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=at(Se.gfm.table).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.gfm.paragraph=at(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:at(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Rs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:at(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
103
- ]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Rs,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:Rs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=at(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=at(Se._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=at(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=at(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=at(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._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])?)+(?![-_])/,pe.autolink=at(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=at(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=at(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=at(pe.reflink).replace("label",pe._label).replace("ref",Se._label).getRegex(),pe.nolink=at(pe.nolink).replace("ref",Se._label).getRegex(),pe.reflinkSearch=at(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.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:at(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:at(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:at(pe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=at(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:at(pe.br).replace("{2,}","*").getRegex(),text:at(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function AS(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 ap(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 zn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new Aa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Se.normal,inline:pe.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:pe}}static lex(t,n){return new zn(n).lex(t)}static lexInline(t,n){return new zn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
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:Dt(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]):Dt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Ps(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=AS(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)),ip(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 ip(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 p=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}const h=p.slice(2,-2);return{type:"strong",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}}}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=Dt(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=Dt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Dt(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=Dt(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=Dt(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]):Dt(r[0]):r[0]:o=Dt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Rs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=ct(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=ct(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=ct(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=ct(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=ct(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.blockquote=ct(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=ct(Se.gfm.table).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.gfm.paragraph=ct(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:ct(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Rs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ct(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
103
+ ]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Rs,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:Rs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=ct(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=ct(Se._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=ct(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=ct(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=ct(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._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])?)+(?![-_])/,pe.autolink=ct(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=ct(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=ct(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=ct(pe.reflink).replace("label",pe._label).replace("ref",Se._label).getRegex(),pe.nolink=ct(pe.nolink).replace("ref",Se._label).getRegex(),pe.reflinkSearch=ct(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.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:ct(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:ct(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:ct(pe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=ct(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:ct(pe.br).replace("{2,}","*").getRegex(),text:ct(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function RS(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 ap(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 Fn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||or,this.options.tokenizer=this.options.tokenizer||new Aa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Se.normal,inline:pe.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:pe}}static lex(t,n){return new Fn(n).lex(t)}static lexInline(t,n){return new Fn(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)+"["+sp("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)+"["+sp("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,ap)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ap))){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 p;this.options.extensions.startInline.forEach(function(h){p=h.call({lexer:this},f),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,AS)){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 _a{constructor(t){this.options=t||sr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
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)+"["+sp("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)+"["+sp("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,ap)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ap))){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 p;this.options.extensions.startInline.forEach(function(h){p=h.call({lexer:this},f),typeof p=="number"&&p>=0&&(d=Math.min(d,p))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,RS)){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 _a{constructor(t){this.options=t||or}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+Dt(o)+'">'+(r?t:Dt(t,!0))+`</code></pre>
115
115
  `:"<pre><code>"+(r?t:Dt(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=rp(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=rp(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 lp{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 cp{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 Bn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new _a,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new lp,this.slugger=new cp}static parse(t,n){return new Bn(n).parse(t)}static parseInline(t,n){return new Bn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,p,h,x,m,v,g,b,S,k,T,C;const E=t.length;for(o=0;o<E;o++){if(h=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(C=this.options.extensions.renderers[h.type].call({parser:this},h),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){r+=C||"";continue}switch(h.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(h.tokens),h.depth,np(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(f="",d="",a=h.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(h.header[s].tokens),{header:!0,align:h.align[s]});for(f+=this.renderer.tablerow(d),p="",a=h.rows.length,s=0;s<a;s++){for(c=h.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:h.align[i]});p+=this.renderer.tablerow(d)}r+=this.renderer.table(f,p);continue}case"blockquote":{p=this.parse(h.tokens),r+=this.renderer.blockquote(p);continue}case"list":{for(x=h.ordered,m=h.start,v=h.loose,a=h.items.length,p="",s=0;s<a;s++)b=h.items[s],S=b.checked,k=b.task,g="",b.task&&(T=this.renderer.checkbox(S),v?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):g+=T),g+=this.parse(b.tokens,v),p+=this.renderer.listitem(g,k,S);r+=this.renderer.list(p,x,m);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(p=h.tokens?this.parseInline(h.tokens):h.text;o+1<E&&t[o+1].type==="text";)h=t[++o],p+=`
134
- `+(h.tokens?this.parseInline(h.tokens):h.text);r+=n?this.renderer.paragraph(p):p;continue}default:{const N='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Os{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}Wh(Os,"passThroughHooks",new Set(["preprocess","postprocess"]));function _S(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>"+Dt(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 up(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=_S(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(IS(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 p;if(!f)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),p=t(l,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(h){f=h}return r.highlight=a,f?i(f):o(null,p)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(p,h){if(p)return c(p);h!=null&&h!==f.text&&(f.text=h,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(ye.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return up(zn.lex,Bn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},hS(ye.defaults),ye},ye.getDefaults=Zf,ye.defaults=sr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ye.defaults.renderer||new _a;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ye.defaults.tokenizer||new Aa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ye.defaults.hooks||new Os;for(const s in n.hooks){const i=o[s];Os.passThroughHooks.has(s)?o[s]=a=>{if(ye.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ye.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=up(zn.lexInline,Bn.parseInline),ye.Parser=Bn,ye.parser=Bn.parse,ye.Renderer=_a,ye.TextRenderer=lp,ye.Lexer=zn,ye.lexer=zn.lex,ye.Tokenizer=Aa,ye.Slugger=cp,ye.Hooks=Os,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Bn.parse,zn.lex;function fo({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ee("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 jS="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 RS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function dp(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 Ms(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function PS(e){const t=o=>{try{const s=co(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 OS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function fp(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 MS(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function DS(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function LS({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=MS(n),i=o?`data:${s};base64,${e}`:t,a=DS(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function $S(e){var s,i;const t=((s=e.content_base64)==null?void 0:s.trim())||void 0,n=((i=e.url)==null?void 0:i.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return LS({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function FS({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ee("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const ja=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:p=!0,customStyles:h={},onEdit:x,onRegenerate:m,onCancelEdit:v,onCopy:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,checkpointCandidates:C=[],activeCheckpointId:E=null,onSelectCheckpoint:N,defaultCheckpointId:_=null,messageParentCheckpointId:L=null,attemptMeta:j=null}){const[M,z]=w.useState(!1),[A,F]=w.useState("preview"),[R,G]=w.useState(!1),{currentThreadId:B}=jo(),{respondToInterrupt:D}=Ro(),V=l==="phone"||l==="half-screen",Y=t.role,he=Y==="tool",ae=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),_e=!!ae,X=!(r&&Y!=="user"),{uploadingFiles:H,handleFileClick:J,fileViewerOpen:$,currentFileInfo:K,closeFileViewer:re}=BS({allowFileOpen:X,currentThreadId:B}),oe=w.useMemo(()=>{switch(Y){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))]"}},[Y]),se=w.useMemo(()=>ae?"":RS(t.content),[ae,t]),Te=w.useMemo(()=>ae?{}:dp(t),[ae,t]),Ye=w.useMemo(()=>ae?[]:t.content.filter(P=>P.type==="image_url"),[ae,t]),Le=w.useMemo(()=>ae?[]:t.content.filter(P=>P.type==="file"),[ae,t]),Ge=w.useMemo(()=>ae?[]:t.content.filter(P=>P.type==="interrupt"),[ae,t]),de=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),be=Ms(de),ze=b==null?void 0:b.value,Ue=w.useMemo(()=>ae?"":PS(t.content),[ae,t]),We=w.useMemo(()=>{if(ae||!p)return[];const ue=t.artifact;if(!ue)return[];const q=[],we=[...Array.isArray(ue.plots)?ue.plots:[]];for(const kt of we){const Wt=$S(kt);Wt&&q.push(Wt)}return q},[ae,t,p]),nt=w.useCallback(async()=>{const P=he?Ue:se;async function ue(q){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(q);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const we=new Blob([q],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":we})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ue(P),z(!0),setTimeout(()=>z(!1),2e3),g==null||g(P)}catch(q){console.error("Failed to copy:",q)}},[he,Ue,se,g]),$e=w.useCallback(()=>{if(!x)return;const P=he?Ue:se,ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,P,ue)},[x,t.id,he,Ue,se,t]),Fe=w.useCallback(()=>{m==null||m(n)},[m,n]),rt=w.useCallback(()=>{const ue=ee(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",oe);switch(Y){case"user":return u.jsx(ce.User,{className:ue});case"assistant":return u.jsx(ce.Bot,{className:ue});case"tool":return u.jsx(ce.Wrench,{className:ue});default:return u.jsx(ce.Bot,{className:ue})}},[V,oe,Y]),It=w.useCallback(()=>{const P="group relative mb-4 flex w-full";switch(Y){case"user":return ee(P,"justify-end");case"assistant":case"tool":case"system":return ee(P,"justify-start");default:return P}},[Y]),dt=w.useCallback(()=>{const P=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");if(_e)return ee(P,"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(Y){case"user":return ee(P,"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 ee(P,"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 ee(P,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(P,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(P,"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")}},[V,_e,Y]);if(_e&&ae)return u.jsx("div",{className:ee(It(),h.container),children:u.jsxs("div",{className:ee(dt(),h.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ce.Bot,{className:ee("h-4 w-4",oe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fo,{content:ae.content,className:"text-current"})]})});const ft=w.useCallback(async P=>{if(S)return;const ue=Ms((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!ue){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await D(ue,!0)}catch(q){console.error("Failed to approve interrupt:",q)}finally{T==null||T()}},[S,T,k,D]),pt=w.useCallback(async P=>{if(S)return;const ue=Ms((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!ue){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await D(ue,!1)}catch(q){console.error("Failed to reject interrupt:",q)}finally{T==null||T()}},[S,T,k,D]),yt=w.useCallback(({part:P,i:ue})=>{if(P.type==="text"){const q=P.text??"",we=q.trim(),kt=ka(we);return kt&&Y!=="tool"?u.jsx(pp,{data:kt},ue):Y==="user"&&c&&we.length>d?u.jsx(HS,{text:we,expanded:R,onExpandedChange:G,previewLength:d,isCompact:V},ue):u.jsx(fo,{content:q,allowHtml:!1},ue)}if(P.type==="image_url"){const q=P;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:q.url,alt:q.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ue)}if(P.type==="file"){const q=P,we=q.name||"file";return u.jsxs("a",{href:q.url,onClick:kt=>J(kt.nativeEvent,q,ue),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:[H[ue]?u.jsx(ce.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[we,H[ue]?" (processing)":""]})]},ue)}if(P.type==="interrupt"){const q=P,we=Ms((q==null?void 0:q.id)??(q==null?void 0:q.interrupt_id)),kt=!!(be&&we&&we===be),Wt=kt?ze??(q==null?void 0:q.value):q==null?void 0:q.value,Ar=we?{...q,id:we,interrupt_id:we}:q;return u.jsx(zS,{interruptPart:Ar,onApprove:ft,onReject:pt,disabled:S,isActive:kt,payload:Wt},ue)}return null},[J,H,ft,pt,Y,c,d,R,V,be,ze,b,S,Ge]),vt=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),xt=w.useCallback(()=>{const P=se.trim().length>0||Ye.length>0||Le.length>0||Ge.length>0;if(!he&&Le.length>0&&!r)return vt();if(!he&&!P&&!r)return null;if(he)return!f&&We.length>0?null:f?u.jsx(US,{message:t,viewMode:A},t.id):null;if(!he&&!ae){const ue=t,q=u.jsx("div",{className:"space-y-2",children:ue.content.map((we,kt)=>u.jsx(yt,{part:we,i:kt},kt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[q,u.jsx(FS,{className:oe})]}):q}},[se,Ye.length,Le.length,Ge.length,r,he,A,f,We.length,vt,oe]),Lt=w.useMemo(()=>ae?"Assistant":OS(t),[ae,t]),Be=w.useMemo(()=>ae?[]:Array.isArray(C)?C:[],[C,ae]),hn=w.useMemo(()=>{var P;return Be.length?_&&Be.some(ue=>ue.id===_)?_:((P=Be[0])==null?void 0:P.id)??null:null},[_,Be]),Ze=w.useMemo(()=>!Be.length||!E?null:Be.some(P=>P.id===E)?E:null,[E,Be])??hn,wt=Y==="user"&&Be.length>0&&typeof N=="function",Q=w.useCallback(P=>{if(!N)return;const ue=(P==null?void 0:P.id)??null,q=(P==null?void 0:P.parentId)??L??null;N(ue,q)},[L,N]),te=w.useMemo(()=>Ze?Be.findIndex(P=>P.id===Ze):-1,[Ze,Be]),ve=w.useMemo(()=>te<0?null:Be[te]??null,[te,Be]),Ce=w.useCallback(P=>{const ue=[];if(P.step!==null&&ue.push(`Step ${P.step}`),P.source&&ue.push(P.source),!P.createdAt)return ue.length?ue.join(" • "):P.id.slice(0,8);let q="";try{const we=new Date(P.createdAt);Number.isNaN(we.getTime())||(q=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(we))}catch{q=""}return`${q}`},[]),Oe=w.useCallback(P=>{if(!P)return"";try{const ue=new Date(P);return Number.isNaN(ue.getTime())?"":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ue)}catch{return""}},[]),Xe=w.useMemo(()=>{if(!j||j.attemptCount<=1)return null;const P=j.isLatestAttempt?`Latest of ${j.attemptCount}`:`Attempt ${j.attemptIndex+1} of ${j.attemptCount}`;return u.jsx("span",{className:ee("rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide",j.isLatestAttempt?"border-emerald-500 bg-emerald-50 text-emerald-700 dark:border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-200":"border-border bg-muted/10 text-muted-foreground dark:bg-muted/30"),children:P})},[j]),Nt=w.useMemo(()=>!j||j.attemptCount<=1||C.length<=1?null:u.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{className:"font-semibold text-[11px] text-foreground",children:"Versions"}),u.jsx("div",{className:"flex flex-wrap gap-1",children:C.map((P,ue)=>{const q=P.id===(ve==null?void 0:ve.id)||P.id===_,we=Oe(P.createdAt);return u.jsxs("span",{className:ee("rounded-full border px-2 py-0.5 font-semibold text-[10px] tracking-wider",q?"border-emerald-500 bg-emerald-50 text-emerald-700 dark:border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-200":"border-border bg-muted/10 text-muted-foreground dark:bg-muted/30"),children:[q?"Current":`Attempt ${ue+1}`,we&&u.jsx("span",{className:"ml-1 block text-[9px] uppercase tracking-normal text-muted-foreground",children:we})]},P.id)})})]}),[j,C,ve,_,Oe]);return he&&!f&&We.length===0?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ee(It(),h.container),children:u.jsxs("div",{className:ee(dt(),h.content),children:[(i||a||he)&&u.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",oe,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&Lt&&u.jsx("span",{className:ee("font-medium",V?"text-xs":"text-sm"),children:Lt}),Xe&&u.jsx("div",{className:"flex items-center",children:Xe}),he&&u.jsxs(Sf,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer select-none",oe,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":A==="expanded",onClick:()=>F(P=>P==="expanded"?"preview":"expanded"),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),F(ue=>ue==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Te.name??"Tool Output"}),Te.toolCallId&&u.jsx("span",{className:"opacity-70",children:Te.toolCallId.slice(0,8)}),A==="expanded"?u.jsx(ce.ChevronUp,{className:"h-3 w-3"}):u.jsx(ce.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[wt&&ve&&te>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ee("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",te>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(te<=0)return;const P=Be[te-1];P&&Q(P)},"aria-label":"Previous checkpoint",disabled:te<=0,children:u.jsx(ce.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[te+1," / ",Be.length]}),u.jsx("span",{className:"text-muted-foreground",children:Ce(ve)})]}),u.jsx("button",{type:"button",className:ee("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",te<Be.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(te>=Be.length-1)return;const P=Be[te+1];P&&Q(P)},"aria-label":"Next checkpoint",disabled:te>=Be.length-1,children:u.jsx(ce.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ee("text-xs opacity-60",oe,V&&"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:ee("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ce.Copy,{className:ee(M?"text-success":oe,V?"h-3 w-3":"h-4 w-4")})})}),Y==="user"&&x&&u.jsx(et,{variant:"ghost",size:"sm",onClick:$e,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ce.Edit,{className:ee(oe,V?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&m&&u.jsx(et,{variant:"ghost",size:"sm",onClick:Fe,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ce.RotateCcw,{className:ee(oe,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),Nt,u.jsxs("div",{className:"relative",children:[xt(),p&&We.length>0&&u.jsx("div",{className:"mt-3 space-y-4",children:We.map((P,ue)=>(w.useEffect(()=>{Q0()&&console.debug(`[MessageComponent] Preview ${ue} mounted:`,{src:P.src.substring(0,100),alt:P.alt,label:P.label})},[]),u.jsxs("div",{className:"space-y-2",children:[P.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",P.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:P.src,alt:P.alt,title:P.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:q=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${ue}:`,{alt:P.alt,label:P.label,message:q.target.alt})}})})]},`artifact-${ue}`)))})]}),he&&A==="expanded"&&(Te.toolCallId||Te.name)&&u.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[Te.name&&u.jsxs("div",{children:["Function: ",Te.name]}),Te.toolCallId&&u.jsxs("div",{children:["Call ID: ",Te.toolCallId]})]}),!(i||a||he)&&s&&!o&&u.jsxs("div",{className:ee("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.Copy,{className:ee(M?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),Y==="user"&&x&&u.jsx(et,{variant:"ghost",size:"sm",onClick:$e,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.Edit,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&m&&u.jsx(et,{variant:"ghost",size:"sm",onClick:Fe,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.RotateCcw,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),K&&u.jsx(pS,{isOpen:$,onClose:re,fileId:K.id,fileName:K.name,mimeType:K.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,p,h;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&fp(e.message)===fp(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","attemptMeta"].every(x=>e[x]===t[x]),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 pp({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:jS,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:uo(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:uo(e)})}function zS({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=uo(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(oo,{className:ee("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(so,{className:"pb-3",children:[u.jsx(io,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Cf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ao,{className:"pt-0 pb-3",children:a}),u.jsx(Tf,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(et,{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(et,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function BS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ta(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(h=>{a(h),c(!0)},[]),p=w.useCallback(async(h,x,m)=>{var v,g;if(!t){h.preventDefault();return}if(o[m]){h.preventDefault();return}try{const b=String(x.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],T=x.name||`file_${k}`,C=x.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){h.preventDefault(),s(T=>({...T,[m]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await K0(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??"")===(x.name??""))?!1:typeof x.size=="number"&&typeof E.size=="number"?E.size===x.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${x.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:x.name||C.filename||`file_${C.id}`,mimeType:x.mimeType||C.mime_type||"application/octet-stream"}),(v=k.update)==null||v.call(k,{id:k.id,title:"Success",description:`Opened ${x.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,[m]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[m]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function HS({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:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(fo,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ee("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(et,{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(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function US({message:e,viewMode:t}){const r=dp(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?ka(c)??c:c;if(d&&typeof d=="object")return u.jsx(pp,{data:d});const f=typeof d=="string"?d:(()=>{try{return uo(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}=G0(c);return f?u.jsx(fo,{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(ce.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=ks(d);return s(f)}const a=co(i),l=ks(a);return s(l)}const WS=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r})=>{const o=e??[],s=o.length>0,i=w.useMemo(()=>s?[...o].reverse():[],[o,s]),a=t??(o.length?o[o.length-1].id:null);return w.useEffect(()=>{console.debug("[TimelineColumn] entries:",o.length)},[o.length]),s?u.jsxs("div",{className:"w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-[10px] 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(ce.Info,{className:"h-3 w-3 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[10px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:"Backend pre-selects user inputs + latest loop checkpoint. Click a dot to jump, or use “Latest” to return to the newest messages."})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:i.map(l=>{const c=a===l.id,d=l.messageId?(r==null?void 0:r.get(l.messageId))??null:null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(l.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${c?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${c?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:l.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[l.step!==null?`STEP ${l.step}`:"STEP —",l.next?` - ${l.next}`:""]}),d&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:d,children:d})]})]},l.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null},hp=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ra=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:p,emptyMessage:h,followNewMessages:x=!0,isNavigatingCheckpoint:m=!1,onScrollAway:v,onAtBottom:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,showArtifactPreviews:E=!0,checkpointMetaById:N,checkpointIndexByKey:_,attemptMetaById:L,activeCheckpointId:j,onSelectCheckpoint:M,timelineCheckpoints:z,messagePreviews:A,createSyntheticThinkingMessage:F=!1},R)=>{const G=w.useRef(null),B=w.useRef(null),D=w.useRef(!1),[V,Y]=w.useState(!0),he=w.useMemo(()=>b?e.some(de=>"type"in de&&de.type==="default_message"?!1:Array.isArray(de==null?void 0:de.content)&&de.content.some(be=>be&&be.type==="interrupt"&&(be.id??be.interrupt_id)===b.id)):!1,[b,e]),ae=w.useMemo(()=>{if(!b||he)return null;const de=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let be;const ze=b.value;if(ze&&typeof ze=="object"&&!Array.isArray(ze)){const Ue=ze.title;typeof Ue=="string"&&Ue.trim()&&(be=Ue.trim())}return{id:`interrupt-${de}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:de,value:ze,title:be}]}},[b,he]),_e=w.useMemo(()=>ae?[...e,ae]:e,[e,ae]),X=w.useMemo(()=>!F||!t?_e:!_e.some(be=>be.role==="assistant")&&_e.length>0?[..._e,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString()}]:_e,[_e,t,F]),H=w.useMemo(()=>C?X:X.filter(de=>(de==null?void 0:de.role)!=="tool"),[X,C]),J=w.useCallback(de=>{Y(de),v&&v(!de),g&&g(de)},[v,g]),$=w.useMemo(()=>{if(a)return async()=>{if(!D.current){D.current=!0;try{await a()}finally{D.current=!1}}}},[a]),K=w.useMemo(()=>!x||m?!1:V?"auto":!1,[V,x,m]),re=z??[],oe=re.length>0,se=w.useMemo(()=>{if(typeof h!="string")return null;const de=h.trim();return de?{id:"default-message",role:"assistant",type:"default_message",content:de,createdAt:new Date().toISOString()}:null},[h]),Te=oe?u.jsx(WS,{timelineEntries:re,activeCheckpointId:j??null,onSelectCheckpoint:M,messagePreviews:A}):null,Ye=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),Le=()=>se?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ja,{message:se,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:h??"No messages yet. Start a conversation!"}),Ge=H.length>0;return w.useImperativeHandle(R,()=>({scrollToLatest:()=>{var de,be;if(G.current&&H.length>0){const ze=H.length-1;(be=(de=G.current).scrollToIndex)==null||be.call(de,{index:ze,align:"end",behavior:"auto"})}else B.current&&(B.current.scrollTop=B.current.scrollHeight)},scrollToTop:()=>{var de,be;G.current&&H.length>0?(be=(de=G.current).scrollToIndex)==null||be.call(de,{index:0,align:"start",behavior:"auto"}):B.current&&(B.current.scrollTop=0)}}),[H]),u.jsxs("div",{className:Ye,style:p,children:[Te,u.jsx("div",{className:"relative flex-1 min-h-0",children:Ge?u.jsx(T0,{ref:de=>{G.current=de},scrollerRef:de=>{B.current=de instanceof HTMLDivElement?de:null},data:H,followOutput:K,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{$&&$()},atBottomStateChange:J,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(de,be)=>hp(be,de),itemContent:(de,be)=>{var pt;const ze=hp(be,de),Ue="type"in be&&be.type==="default_message";let We=[],nt=null,$e={},Fe={},rt=null,It=null,dt=null;if(!Ue){const yt=be,vt=yt.checkpointId??null;$e=yt.additionalKwargs??{},Fe=yt.responseMetadata??{};const xt=vt&&N?N.get(vt)??null:null;rt=typeof $e.step=="number"?$e.step:typeof Fe.step=="number"?Fe.step:(xt==null?void 0:xt.step)??null;const Lt=typeof $e.source=="string"?$e.source:typeof Fe.source=="string"?Fe.source:(xt==null?void 0:xt.source)??null;It=Lt?String(Lt):null;const Be=rt!==null&&It?`${rt}:${It}`:null;Be&&(_!=null&&_.has(Be))?We=_.get(Be)??[]:vt&&xt&&(We=[xt]),nt=vt??((pt=We[0])==null?void 0:pt.id)??null,dt=vt?(L==null?void 0:L.get(vt))??null:null}const ft=(()=>{if(typeof $e.parentCheckpointId=="string")return $e.parentCheckpointId;if(typeof Fe.parentCheckpointId=="string")return Fe.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":ze,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ja,{message:be,messageIndex:de,isStreamingMessage:t&&n===be.id,streamingDebounceMs:r,isEditing:i===be.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(de),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,showArtifactPreviews:E,checkpointCandidates:We,activeCheckpointId:j??null,onSelectCheckpoint:M,defaultCheckpointId:nt,messageParentCheckpointId:ft,attemptMeta:dt})})}}):Le()})]})});Ra.displayName="MessageList";const mp={value:""};function Ds({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:p={},onMessageSent:h,onExcelUploadSuccess:x,onError:m}){const{api:v}=ui(),{currentThreadId:g}=jo(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:T,navigateToCheckpoint:C,returnToLatest:E,checkpoint:N,checkpoints:_,interrupt:L,metadata:j,timelineCheckpoints:M,messagePreviews:z}=Ro(),{isStreaming:A,error:F,connectionState:R,submit:G,stop:B}=dc(),D=b??g??null,V=(N==null?void 0:N.id)??null,Y=(N==null?void 0:N.namespace)??null,he=(j==null?void 0:j.assemblingMessageId)??null,ae=L,[_e,X]=w.useState(!1);w.useEffect(()=>{ae||X(!1)},[ae]);const H=w.useCallback(()=>{X(!0)},[]),J=w.useCallback(()=>{X(!1)},[]),$=!!ae||_e,[K,re]=w.useState(null),[oe,se]=w.useState(""),[Te,Ye]=w.useState(null),[Le,Ge]=w.useState(null),[de,be]=w.useState([]),[ze,Ue]=w.useState(0),[We,nt]=w.useState(0),[$e,Fe]=w.useState(!1),[rt,It]=w.useState(null),[dt,ft]=w.useState(null),[pt,yt]=w.useState(!1),[vt,xt]=w.useState(null),Lt=w.useRef(!1),[Be,hn]=w.useState(()=>mp.value),st=w.useRef(Be),Ze=w.useRef(null),wt=w.useCallback(ne=>{mp.value=ne,hn(ne)},[]),[Q,te]=w.useState(!1),ve=w.useRef(null),Ce=w.useCallback((ne,ie)=>{if(!ne||typeof ne!="object")return null;const xe=ne[ie];return typeof xe=="number"?xe:null},[]),Oe=w.useCallback((ne,ie)=>{if(!ne||typeof ne!="object")return null;const xe=ne[ie];return typeof xe=="string"&&xe.trim()?xe:null},[]),Xe=w.useMemo(()=>{const ne=ke=>{if(!Array.isArray(ke)||ke.length===0)return null;const lt=ke.map(ht=>{if(typeof ht=="string")return ht.trim();if(ht&&typeof ht=="object"&&"type"in ht){const Kt=ht;if(typeof Kt.type=="string")return Kt.type}return null}).filter(ht=>!!(ht&&ht.length));return lt.length?lt.join(", "):null},ie=Array.isArray(_)?_.map(ke=>{const lt=ne(ke.next);return lt?{...ke,metadata:{...ke.metadata??{},next:lt}}:ke}):[];return ie.some(ke=>Ce(ke.metadata,"step")!==null)&&ie.sort((ke,lt)=>{const ht=Ce(ke.metadata,"step"),Kt=Ce(lt.metadata,"step");if(ht!==null||Kt!==null)return(Kt??Number.NEGATIVE_INFINITY)-(ht??Number.NEGATIVE_INFINITY);const jn=Date.parse(ke.createdAt??""),_r=Date.parse(lt.createdAt??"");return Number.isNaN(jn)||Number.isNaN(_r)?0:_r-jn}),ie},[_,Ce]),{checkpointMetaById:Nt,checkpointIndexByKey:P,attemptMetaById:ue}=w.useMemo(()=>{const ne=new Map,ie=new Map,xe=new Map;for(const ke of Xe){const lt=ke.checkpointId??null;if(!lt)continue;const ht=Ce(ke.metadata,"step"),Kt=Oe(ke.metadata,"source"),jn={id:lt,step:ht,source:Kt,createdAt:ke.createdAt??null,namespace:ke.checkpointNs??null,parentId:ke.parentId??null};if(ne.set(lt,jn),ht!==null&&Kt){const _r=`${ht}:${Kt}`,Uh=ie.get(_r)??[];Uh.push(jn),ie.set(_r,Uh)}}for(const ke of ie.values()){ke.sort((ht,Kt)=>{const jn=ht.createdAt??"";return(Kt.createdAt??"").localeCompare(jn)});const lt=ke.length;ke.forEach((ht,Kt)=>{const jn={...ht,attemptIndex:Kt,attemptCount:lt,isLatestAttempt:Kt===0};xe.set(ht.id,jn)})}for(const[ke,lt]of ne.entries())xe.has(ke)||xe.set(ke,{...lt,attemptIndex:0,attemptCount:1,isLatestAttempt:!0});return{checkpointMetaById:ne,checkpointIndexByKey:ie,attemptMetaById:xe}},[Xe,Ce,Oe]),q=M??[],we=w.useRef(null),kt=w.useRef(null),Wt=w.useCallback(()=>{we.current&&(we.current.value=""),kt.current&&(kt.current.value=""),Ue(ne=>ne+1),nt(ne=>ne+1)},[]),Ar=w.useCallback(ne=>{wt(ne)},[wt]),qs=w.useRef(!1);w.useEffect(()=>{qs.current&&!A&&(be([]),Wt()),qs.current=A},[A,Wt]);const[qa,Ga]=w.useState("desktop");w.useEffect(()=>{const ne=()=>{const ie=window.innerWidth;Ga(ie<640?"phone":ie<1024?"tablet":"desktop")};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[]),w.useEffect(()=>{Lt.current=!1},[D]),w.useEffect(()=>{st.current=Be},[Be]),w.useEffect(()=>{if(!K){Ze.current=null;return}Ze.current===null&&(Ze.current=st.current),wt(oe??"")},[oe,K,wt]),w.useEffect(()=>{(async()=>{if(!v.baseUrl){xt(null);return}try{const xe=(await v.getAgent("default")).uiDefaultMessage||"";xt(xe||null)}catch(ie){console.warn("Failed to fetch default message:",ie),xt(null)}})()},[v.baseUrl]),w.useEffect(()=>{F&&!pt&&(m==null||m(F))},[F,pt,m]);const Ya=ne=>{if(ne.length>cs)return`Message too long (${ne.length}/${cs} characters)`;try{return hw(ne),null}catch(ie){return(ie==null?void 0:ie.message)||"Invalid message"}},I=async ne=>{const ie=ne.trim();if(!(!ie&&de.length===0)){if(ie){const xe=Ya(ie);if(xe){Ge(xe);return}}try{const xe=V??void 0,ke=Y??void 0,lt=K?{edit:!0,originalMessageId:K,...Te!=null&&Te.checkpointId?{originalCheckpointId:Te.checkpointId}:{},...Te!=null&&Te.checkpointNs?{originalCheckpointNs:Te.checkpointNs}:{}}:void 0;await G({text:ie||"",attachments:de,messageAdditionalKwargs:lt},{checkpointId:xe,checkpointNs:ke}),h==null||h(ie),wt(""),Ge(null),be([]),Wt(),re(null),se(""),Ye(null)}catch(xe){const ke=(xe==null?void 0:xe.message)||"Failed to send message";Ge(ke),m==null||m(ke)}}},W=w.useCallback((ne,ie,xe)=>{c&&(Ze.current=Be,re(ne),se(ie),wt(ie),Ge(null),Ye({checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null}))},[Be,c,wt]),le=w.useCallback(()=>{re(null),se(""),Ye(null),Ge(null),wt(Ze.current??Be),Ze.current=null},[Be,wt]),Ie=w.useCallback((ne,ie,xe)=>{W(ne,ie,xe)},[W]),Qe=w.useCallback(ne=>{for(let ie=ne-1;ie>=0;ie--)if(S[ie].role==="user"){const xe=S[ie].content||[],lt=xe.filter(ht=>ht.type==="text").map(ht=>ht.text).join("")||(()=>{try{return JSON.stringify(xe,null,2)}catch{return String(xe)}})();lt&&G({text:lt},{checkpointId:V??void 0,checkpointNs:Y??void 0});break}},[S,G,V,Y]),ot=ne=>{const ie=Array.from(ne.target.files||[]);be(xe=>[...xe,...ie]),ne.target.value=""},Ve=ne=>{be(ie=>{const xe=ie.filter((ke,lt)=>ne!==lt);return xe.length===0&&Wt(),xe})},He=async ne=>{const ie=(ne.target.files||[])[0];if(ie){It(null),ft(null),Fe(!0);try{await G({attachments:[ie]},{checkpointId:V??void 0,checkpointNs:Y??void 0});const xe=`Uploaded ${ie.name} - processing through chat stream`;ft(xe)}catch(xe){const ke=xe instanceof Error?xe.message:"Failed to upload Excel file";console.error("Excel upload failed",xe),It(ke),m==null||m(ke)}finally{Fe(!1),ne.target.value="",Wt()}}},_t=async ne=>{if(g){te(!0);try{if(!ne){await E(),requestAnimationFrame(()=>{var ke;(ke=ve.current)==null||ke.scrollToLatest()});return}const ie=Xe.find(ke=>ke.checkpointId===ne),xe=(ie==null?void 0:ie.checkpointNs)??null;await C(ne,xe),requestAnimationFrame(()=>{var ke;(ke=ve.current)==null||ke.scrollToTop()})}finally{te(!1)}}},bt=w.useCallback(async ne=>{await _t(ne)},[_t]),St=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${p.container||""}`,Vt=`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 ${p.messagesArea||""}`,Vn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${p.inputArea||""}`;return w.useCallback(ne=>{if(!ne)return"Latest";const ie=[];ne.step!==null&&ie.push(`Step ${ne.step}`),ne.source&&ie.push(ne.source);const xe=ne.createdAt?new Date(ne.createdAt):null,ke=xe&&!Number.isNaN(xe.getTime())?xe.toLocaleString():ne.createdAt??ne.id,lt=ie.length?` — ${ie.join(" • ")}`:"";return`${ke}${lt}`},[]),u.jsxs("div",{className:St,children:[!!F&&!pt&&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:F}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>yt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ce.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Vt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Ra,{ref:ve,className:"h-full",style:{height:"100%"},messages:S,isStreaming:A,streamingAssistantId:he,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:qa,enableMessageEditing:c,editingMessageId:K,onEdit:Ie,onRegenerate:Qe,onCancelEdit:le,emptyMessage:vt??void 0,isNavigatingCheckpoint:Q,activeInterrupt:ae,disableInterruptActions:_e,onInterruptActionStart:H,onInterruptActionEnd:J,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:Nt,checkpointIndexByKey:P,attemptMetaById:ue,activeCheckpointId:V,onSelectCheckpoint:bt,timelineCheckpoints:q,messagePreviews:z}),(R==="reconnecting"||R==="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(ce.Loader2,{className:"h-3 w-3 animate-spin"}),R==="reconnecting"?"Reconnecting…":"Connecting…"]})}),R==="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(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Q)&&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(ce.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:Vn,children:[K&&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(ce.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(et,{variant:"ghost",size:"sm",onClick:le,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ce.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:we,type:"file",multiple:!0,onChange:ne=>ot(ne),className:"hidden"},ze),de.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:de.map((ne,ie)=>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(ce.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ne.name}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>Ve(ie),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ne.name}`,children:u.jsx(ce.X,{size:12})})]},ie))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:kt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:He,className:"hidden"},We),$e&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),dt&&!$e&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:dt}),rt&&!$e&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:rt})]})]}),Le&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Le}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(ow,{children:[u.jsx(sw,{asChild:!0,children:u.jsx(et,{type:"button",size:"icon",variant:"outline",disabled:A||$,title:"More input actions",className:p.moreButton||"",children:u.jsx(ce.Plus,{size:16})})}),u.jsxs(Sd,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Zi,{onClick:()=>{var ne;return(ne=we.current)==null?void 0:ne.click()},className:"cursor-pointer",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Zi,{onClick:()=>{var ne;$e||(ne=kt.current)==null||ne.click()},className:`cursor-pointer ${$e?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(sx,{initialValue:oe,editingMessageId:K,value:Be,onValueChange:Ar,placeholder:K?"Edit your message...":t,isStreaming:A,disabled:$,maxLength:cs,onSend:I,onCancelEdit:le,onStop:B,allowEmptySend:de.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Le?"border-red-400":""} ${p.textarea||""}`})})]})]})]})}const Ls=y.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ee("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}));Ls.displayName="Input";function Pa(e,[t,n]){return Math.min(n,Math.max(t,e))}function VS(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var Oa="ScrollArea",[gp,PT]=En(Oa),[KS,on]=gp(Oa),xp=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=y.useState(null),[c,d]=y.useState(null),[f,p]=y.useState(null),[h,x]=y.useState(null),[m,v]=y.useState(null),[g,b]=y.useState(0),[S,k]=y.useState(0),[T,C]=y.useState(!1),[E,N]=y.useState(!1),_=Ke(t,j=>l(j)),L=Oo(o);return u.jsx(KS,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:m,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(Re.div,{dir:L,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});xp.displayName=Oa;var yp="ScrollAreaViewport",vp=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=on(yp,n),a=y.useRef(null),l=Ke(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(Re.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})})]})});vp.displayName=yp;var Tn="ScrollAreaScrollbar",Ma=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return y.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(qS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(GS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(bp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Da,{...r,ref:t}):null});Ma.displayName=Tn;var qS=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),[s,i]=y.useState(!1);return y.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(en,{present:n||s,children:u.jsx(bp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),GS=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Bs(()=>l("SCROLL_END"),100),[a,l]=VS("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 y.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),y.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(en,{present:n||a!=="hidden",children:u.jsx(Da,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:me(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:me(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),bp=y.forwardRef((e,t)=>{const n=on(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=y.useState(!1),a=e.orientation==="horizontal",l=Bs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Er(n.viewport,l),Er(n.content,l),u.jsx(en,{present:r||s,children:u.jsx(Da,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Da=y.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=on(Tn,e.__scopeScrollArea),s=y.useRef(null),i=y.useRef(0),[a,l]=y.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=kp(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 eC(p,i.current,a,h)}return n==="horizontal"?u.jsx(YS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,h=Ep(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(XS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,h=Ep(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}),YS=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Tn,e.__scopeScrollArea),[i,a]=y.useState(),l=y.useRef(null),c=Ke(t,l,s.onScrollbarXChange);return y.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Sp,{"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":zs(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),Np(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:Fs(i.paddingLeft),paddingEnd:Fs(i.paddingRight)}})}})}),XS=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Tn,e.__scopeScrollArea),[i,a]=y.useState(),l=y.useRef(null),c=Ke(t,l,s.onScrollbarYChange);return y.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Sp,{"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":zs(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),Np(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:Fs(i.paddingTop),paddingEnd:Fs(i.paddingBottom)}})}})}),[JS,wp]=gp(Tn),Sp=y.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=on(Tn,n),[x,m]=y.useState(null),v=Ke(t,_=>m(_)),g=y.useRef(null),b=y.useRef(""),S=h.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Bs(f,10);function N(_){if(g.current){const L=_.clientX-g.current.left,j=_.clientY-g.current.top;c({x:L,y:j})}}return y.useEffect(()=>{const _=L=>{const j=L.target;(x==null?void 0:x.contains(j))&&T(L,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,x,k,T]),y.useEffect(C,[r,C]),Er(x,E),Er(h.content,E),u.jsx(JS,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(Re.div,{...p,ref:v,style:{position:"absolute",...p.style},onPointerDown:me(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),g.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),N(_))}),onPointerMove:me(e.onPointerMove,N),onPointerUp:me(e.onPointerUp,_=>{const L=_.target;L.hasPointerCapture(_.pointerId)&&L.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),g.current=null})})})}),$s="ScrollAreaThumb",Cp=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=wp($s,e.__scopeScrollArea);return u.jsx(en,{present:n||o.hasThumb,children:u.jsx(ZS,{ref:t,...r})})}),ZS=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=on($s,n),i=wp($s,n),{onThumbPositionChange:a}=i,l=Ke(t,f=>i.onThumbChange(f)),c=y.useRef(void 0),d=Bs(()=>{c.current&&(c.current(),c.current=void 0)},100);return y.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!c.current){const h=tC(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(Re.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:me(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),x=f.clientX-h.left,m=f.clientY-h.top;i.onThumbPointerDown({x,y:m})}),onPointerUp:me(e.onPointerUp,i.onThumbPointerUp)})});Cp.displayName=$s;var La="ScrollAreaCorner",Tp=y.forwardRef((e,t)=>{const n=on(La,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(QS,{...e,ref:t}):null});Tp.displayName=La;var QS=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=on(La,n),[s,i]=y.useState(0),[a,l]=y.useState(0),c=!!(s&&a);return Er(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Er(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(Re.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 Fs(e){return e?parseInt(e,10):0}function kp(e,t){const n=e/t;return isNaN(n)?0:n}function zs(e){const t=kp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function eC(e,t,n,r="ltr"){const o=zs(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 Ip([l,c],f)(e)}function Ep(e,t,n="ltr"){const r=zs(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=Pa(e,l);return Ip([0,i],[0,a])(c)}function Ip(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 Np(e,t){return e>0&&e<t}var tC=(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 Bs(e,t){const n=Rt(e),r=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),y.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Er(e,t){const n=Rt(t);jt(()=>{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 Ap=xp,nC=vp,rC=Tp;const _p=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ap,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[u.jsx(nC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(jp,{}),u.jsx(rC,{})]}));_p.displayName=Ap.displayName;const jp=y.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ma,{ref:r,orientation:t,className:ee("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(Cp,{className:"relative flex-1 rounded-full bg-border"})}));jp.displayName=Ma.displayName;const Rp=25;function $a({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:x,actions:m}=jo(),{loadThread:v}=Ro(),{createThread:g,deleteThread:b,renameThread:S}=m,[k,T]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(k.length>0),E=w.useRef(null),N=w.useRef(0),[_,L]=w.useState(null),[j,M]=w.useState(""),[z,A]=w.useState(!1);w.useEffect(()=>{const X=Array.isArray(f)?f:[];if(X.length>0){C.current=!0,T(X);return}x||(C.current=!1,T(X))},[f,x]),w.useEffect(()=>{if(!E.current)return;const X=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!X)return;let H=null,J=null;return H=requestAnimationFrame(()=>{J=requestAnimationFrame(()=>{X.scrollTop=N.current})}),()=>{H!==null&&cancelAnimationFrame(H),J!==null&&cancelAnimationFrame(J)}},[k]);const F=async X=>{try{h(X),await v(X),a==null||a(X),l==null||l(X)}catch(H){console.error("Failed to select thread:",H)}},R=async()=>{try{A(!0);const X=await g();X&&(c==null||c(X),a==null||a(X))}catch(X){console.error("Failed to create thread:",X)}finally{A(!1)}},G=async(X,H)=>{if(H.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const J=E.current.querySelector("[data-radix-scroll-area-viewport]");J&&(N.current=J.scrollTop)}try{await b(X),d==null||d(X)}catch(J){console.error("Failed to delete thread:",J)}}},B=(X,H)=>{H.stopPropagation(),L(X.threadId),M(X.title||`Thread ${X.threadId.slice(0,8)}`)},D=async X=>{if(j.trim())try{await S(X,j.trim()),L(null),M("")}catch(H){console.error("Failed to update title:",H)}},V=()=>{L(null),M("")},Y=(X,H)=>{X.key==="Enter"?D(H):X.key==="Escape"&&V()},he=X=>{if(!X)return"";try{const H=new Date(X),$=new Date().getTime()-H.getTime(),K=Math.floor($/(1e3*60*60*24));return K===0?H.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):K===1?"Yesterday":K<7?`${K} days ago`:H.toLocaleDateString()}catch{return""}},ae=X=>X.title||`Thread ${X.threadId.slice(0,8)}`,_e=X=>{const H=ae(X);return H.length<=Rp?H:`${H.slice(0,Rp)}...`};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(et,{onClick:R,disabled:z||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:u.jsx(ce.MessageSquarePlus,{size:20})})}),u.jsx(_p,{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:x?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ce.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(ce.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((X,H)=>new Date(H.updatedAt||H.createdAt||"").getTime()-new Date(X.updatedAt||X.createdAt||"").getTime()).map(X=>u.jsxs("div",{onClick:()=>F(X.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===X.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:_===X.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:H=>H.stopPropagation(),children:[u.jsx(Ls,{value:j,onChange:H=>M(H.target.value),onKeyDown:H=>Y(H,X.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>D(X.threadId),className:"h-6 w-6 p-0",children:u.jsx(ce.Check,{size:12})}),u.jsx(et,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:u.jsx(ce.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:_e(X)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ce.Calendar,{size:10}),u.jsx("span",{children:he(X.updatedAt||X.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&_!==X.threadId&&u.jsx(et,{variant:"ghost",size:"sm",onClick:H=>B(X,H),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(ce.Edit3,{size:12})}),n&&u.jsx(et,{variant:"ghost",size:"sm",onClick:H=>G(X.threadId,H),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(ce.Trash2,{size:12})})]})]}),i===X.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},X.threadId))})})]})}function Ir(e){if(!(typeof globalThis>"u"))return globalThis[e]}function oC(e){if(typeof e!="string")return;const t=e.trim();if(t)return kn(t)}function Pp(){const e=[Ir("__API_BASE_URL__"),Ir("__CHAT_API_BASE_URL__"),Ir("__CHAT_API_URL__")];for(const t of e){const n=oC(t);if(n)return n}}function Op(){const e=[Ir("__API_AUTH_TOKEN__"),Ir("__CHAT_API_KEY__"),Ir("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return kn(t);return kn()}function Dp(){const e={},t=Pp(),n=Op();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Lp(){const e=Dp(),t=Rn.getAuthToken(),n=Pp();return{apiBaseUrl:Mp(e.baseUrl,Rn.baseUrl,n),apiKey:t||e.apiKey||Op()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $p="chat-settings";function sC(){try{const e=localStorage.getItem($p);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function iC(e){try{const t={...e,apiBaseUrl:kn(e.apiBaseUrl)};localStorage.setItem($p,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function aC(){const e=Lp(),t=sC(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mp(Rn.baseUrl,r,e.apiBaseUrl)}}function lC(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),iC(e)}var cC="Label",Fp=y.forwardRef((e,t)=>u.jsx(Re.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())}}));Fp.displayName=cC;var zp=Fp;const uC=ho.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),sn=y.forwardRef(({className:e,...t},n)=>u.jsx(zp,{ref:n,className:ee(uC(),e),...t}));sn.displayName=zp.displayName;function Bp(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Hp=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"}),dC="VisuallyHidden",fC=y.forwardRef((e,t)=>u.jsx(Re.span,{...e,ref:t,style:{...Hp,...e.style}}));fC.displayName=dC;var pC=[" ","Enter","ArrowUp","ArrowDown"],hC=[" ","Enter"],ir="Select",[Hs,Us,mC]=xi(ir),[Nr,OT]=En(ir,[mC,qo]),Ws=qo(),[gC,Hn]=Nr(ir),[xC,yC]=Nr(ir),Up=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:x}=e,m=Ws(t),[v,g]=y.useState(null),[b,S]=y.useState(null),[k,T]=y.useState(!1),C=Oo(c),[E,N]=hr({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[_,L]=hr({prop:i,defaultProp:a,onChange:l,caller:ir}),j=y.useRef(null),M=v?x||!!v.closest("form"):!0,[z,A]=y.useState(new Set),F=Array.from(z).map(R=>R.props.value).join(";");return u.jsx(su,{...m,children:u.jsxs(gC,{required:h,scope:t,trigger:v,onTriggerChange:g,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:In(),value:_,onValueChange:L,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:j,disabled:p,children:[u.jsx(Hs.Provider,{scope:t,children:u.jsx(xC,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(R=>{A(G=>new Set(G).add(R))},[]),onNativeOptionRemove:y.useCallback(R=>{A(G=>{const B=new Set(G);return B.delete(R),B})},[]),children:n})}),M?u.jsxs(ph,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:R=>L(R.target.value),disabled:p,form:x,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(z)]},F):null]})})};Up.displayName=ir;var Wp="SelectTrigger",Vp=y.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ws(n),i=Hn(Wp,n),a=i.disabled||r,l=Ke(t,i.onTriggerChange),c=Us(n),d=y.useRef("touch"),[f,p,h]=mh(m=>{const v=c().filter(S=>!S.disabled),g=v.find(S=>S.value===i.value),b=gh(v,m,g);b!==void 0&&i.onValueChange(b.value)}),x=m=>{a||(i.onOpenChange(!0),h()),m&&(i.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return u.jsx(iu,{asChild:!0,...s,children:u.jsx(Re.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":hh(i.value)?"":void 0,...o,ref:l,onClick:me(o.onClick,m=>{m.currentTarget.focus(),d.current!=="mouse"&&x(m)}),onPointerDown:me(o.onPointerDown,m=>{d.current=m.pointerType;const v=m.target;v.hasPointerCapture(m.pointerId)&&v.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(x(m),m.preventDefault())}),onKeyDown:me(o.onKeyDown,m=>{const v=f.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&p(m.key),!(v&&m.key===" ")&&pC.includes(m.key)&&(x(),m.preventDefault())})})})});Vp.displayName=Wp;var Kp="SelectValue",qp=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Hn(Kp,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Ke(t,l.onValueNodeChange);return jt(()=>{c(d)},[c,d]),u.jsx(Re.span,{...a,ref:f,style:{pointerEvents:"none"},children:hh(l.value)?u.jsx(u.Fragment,{children:i}):s})});qp.displayName=Kp;var vC="SelectIcon",Gp=y.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(Re.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Gp.displayName=vC;var bC="SelectPortal",Yp=e=>u.jsx(Go,{asChild:!0,...e});Yp.displayName=bC;var ar="SelectContent",Xp=y.forwardRef((e,t)=>{const n=Hn(ar,e.__scopeSelect),[r,o]=y.useState();if(jt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?mo.createPortal(u.jsx(Jp,{scope:e.__scopeSelect,children:u.jsx(Hs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Zp,{...e,ref:t})});Xp.displayName=ar;var pn=10,[Jp,Un]=Nr(ar),wC="SelectContentImpl",SC=Kn.createSlot("SelectContent.RemoveScroll"),Zp=y.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:x,hideWhenDetached:m,avoidCollisions:v,...g}=e,b=Hn(ar,n),[S,k]=y.useState(null),[T,C]=y.useState(null),E=Ke(t,J=>k(J)),[N,_]=y.useState(null),[L,j]=y.useState(null),M=Us(n),[z,A]=y.useState(!1),F=y.useRef(!1);y.useEffect(()=>{if(S)return Fi(S)},[S]),bi();const R=y.useCallback(J=>{const[$,...K]=M().map(se=>se.ref.current),[re]=K.slice(-1),oe=document.activeElement;for(const se of J)if(se===oe||(se==null||se.scrollIntoView({block:"nearest"}),se===$&&T&&(T.scrollTop=0),se===re&&T&&(T.scrollTop=T.scrollHeight),se==null||se.focus(),document.activeElement!==oe))return},[M,T]),G=y.useCallback(()=>R([N,S]),[R,N,S]);y.useEffect(()=>{z&&G()},[z,G]);const{onOpenChange:B,triggerPointerDownPosRef:D}=b;y.useEffect(()=>{if(S){let J={x:0,y:0};const $=re=>{var oe,se;J={x:Math.abs(Math.round(re.pageX)-(((oe=D.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(re.pageY)-(((se=D.current)==null?void 0:se.y)??0))}},K=re=>{J.x<=10&&J.y<=10?re.preventDefault():S.contains(re.target)||B(!1),document.removeEventListener("pointermove",$),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",K,{capture:!0})}}},[S,B,D]),y.useEffect(()=>{const J=()=>B(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[B]);const[V,Y]=mh(J=>{const $=M().filter(oe=>!oe.disabled),K=$.find(oe=>oe.ref.current===document.activeElement),re=gh($,J,K);re&&setTimeout(()=>re.ref.current.focus())}),he=y.useCallback((J,$,K)=>{const re=!F.current&&!K;(b.value!==void 0&&b.value===$||re)&&(_(J),re&&(F.current=!0))},[b.value]),ae=y.useCallback(()=>S==null?void 0:S.focus(),[S]),_e=y.useCallback((J,$,K)=>{const re=!F.current&&!K;(b.value!==void 0&&b.value===$||re)&&j(J)},[b.value]),X=r==="popper"?Fa:Qp,H=X===Fa?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:x,hideWhenDetached:m,avoidCollisions:v}:{};return u.jsx(Jp,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:he,selectedItem:N,onItemLeave:ae,itemTextRefCallback:_e,focusSelectedItem:G,selectedItemText:L,position:r,isPositioned:z,searchRef:V,children:u.jsx(rs,{as:SC,allowPinchZoom:!0,children:u.jsx(Do,{asChild:!0,trapped:b.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:me(o,J=>{var $;($=b.trigger)==null||$.focus({preventScroll:!0}),J.preventDefault()}),children:u.jsx(Mo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(X,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:J=>J.preventDefault(),...g,...H,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:me(g.onKeyDown,J=>{const $=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!$&&J.key.length===1&&Y(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let re=M().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(J.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const oe=J.target,se=re.indexOf(oe);re=re.slice(se+1)}setTimeout(()=>R(re)),J.preventDefault()}})})})})})})});Zp.displayName=wC;var CC="SelectItemAlignedPosition",Qp=y.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Hn(ar,n),i=Un(ar,n),[a,l]=y.useState(null),[c,d]=y.useState(null),f=Ke(t,E=>d(E)),p=Us(n),h=y.useRef(!1),x=y.useRef(!0),{viewport:m,selectedItem:v,selectedItemText:g,focusSelectedItem:b}=i,S=y.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&m&&v&&g){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),L=g.getBoundingClientRect();if(s.dir!=="rtl"){const oe=L.left-N.left,se=_.left-oe,Te=E.left-se,Ye=E.width+Te,Le=Math.max(Ye,N.width),Ge=window.innerWidth-pn,de=Pa(se,[pn,Math.max(pn,Ge-Le)]);a.style.minWidth=Ye+"px",a.style.left=de+"px"}else{const oe=N.right-L.right,se=window.innerWidth-_.right-oe,Te=window.innerWidth-E.right-se,Ye=E.width+Te,Le=Math.max(Ye,N.width),Ge=window.innerWidth-pn,de=Pa(se,[pn,Math.max(pn,Ge-Le)]);a.style.minWidth=Ye+"px",a.style.right=de+"px"}const j=p(),M=window.innerHeight-pn*2,z=m.scrollHeight,A=window.getComputedStyle(c),F=parseInt(A.borderTopWidth,10),R=parseInt(A.paddingTop,10),G=parseInt(A.borderBottomWidth,10),B=parseInt(A.paddingBottom,10),D=F+R+z+B+G,V=Math.min(v.offsetHeight*5,D),Y=window.getComputedStyle(m),he=parseInt(Y.paddingTop,10),ae=parseInt(Y.paddingBottom,10),_e=E.top+E.height/2-pn,X=M-_e,H=v.offsetHeight/2,J=v.offsetTop+H,$=F+R+J,K=D-$;if($<=_e){const oe=j.length>0&&v===j[j.length-1].ref.current;a.style.bottom="0px";const se=c.clientHeight-m.offsetTop-m.offsetHeight,Te=Math.max(X,H+(oe?ae:0)+se+G),Ye=$+Te;a.style.height=Ye+"px"}else{const oe=j.length>0&&v===j[0].ref.current;a.style.top="0px";const Te=Math.max(_e,F+m.offsetTop+(oe?he:0)+H)+K;a.style.height=Te+"px",m.scrollTop=$-_e+m.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=M+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[p,s.trigger,s.valueNode,a,c,m,v,g,s.dir,r]);jt(()=>S(),[S]);const[k,T]=y.useState();jt(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=y.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return u.jsx(kC,{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(Re.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Qp.displayName=CC;var TC="SelectPopperPosition",Fa=y.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=Ws(n);return u.jsx(au,{...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)"}})});Fa.displayName=TC;var[kC,za]=Nr(ar,{}),Ba="SelectViewport",eh=y.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Un(Ba,n),i=za(Ba,n),a=Ke(t,s.onViewportChange),l=y.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(Hs.Slot,{scope:n,children:u.jsx(Re.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:me(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 x=window.innerHeight-pn*2,m=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),g=Math.max(m,v);if(g<x){const b=g+h,S=Math.min(x,b),k=b-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})})})]})});eh.displayName=Ba;var th="SelectGroup",[EC,IC]=Nr(th),NC=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=In();return u.jsx(EC,{scope:n,id:o,children:u.jsx(Re.div,{role:"group","aria-labelledby":o,...r,ref:t})})});NC.displayName=th;var nh="SelectLabel",rh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=IC(nh,n);return u.jsx(Re.div,{id:o.id,...r,ref:t})});rh.displayName=nh;var Vs="SelectItem",[AC,oh]=Nr(Vs),sh=y.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Hn(Vs,n),l=Un(Vs,n),c=a.value===r,[d,f]=y.useState(s??""),[p,h]=y.useState(!1),x=Ke(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),m=In(),v=y.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(AC,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:y.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Hs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(Re.div,{role:"option","aria-labelledby":m,"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:x,onFocus:me(i.onFocus,()=>h(!0)),onBlur:me(i.onBlur,()=>h(!1)),onClick:me(i.onClick,()=>{v.current!=="mouse"&&g()}),onPointerUp:me(i.onPointerUp,()=>{v.current==="mouse"&&g()}),onPointerDown:me(i.onPointerDown,b=>{v.current=b.pointerType}),onPointerMove:me(i.onPointerMove,b=>{var S;v.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:me(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:me(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(hC.includes(b.key)&&g(),b.key===" "&&b.preventDefault())})})})})});sh.displayName=Vs;var po="SelectItemText",ih=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Hn(po,n),a=Un(po,n),l=oh(po,n),c=yC(po,n),[d,f]=y.useState(null),p=Ke(t,g=>f(g),l.onItemTextChange,g=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,g,l.value,l.disabled)}),h=d==null?void 0:d.textContent,x=y.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:m,onNativeOptionRemove:v}=c;return jt(()=>(m(x),()=>v(x)),[m,v,x]),u.jsxs(u.Fragment,{children:[u.jsx(Re.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?mo.createPortal(s.children,i.valueNode):null]})});ih.displayName=po;var ah="SelectItemIndicator",lh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return oh(ah,n).isSelected?u.jsx(Re.span,{"aria-hidden":!0,...r,ref:t}):null});lh.displayName=ah;var Ha="SelectScrollUpButton",ch=y.forwardRef((e,t)=>{const n=Un(Ha,e.__scopeSelect),r=za(Ha,e.__scopeSelect),[o,s]=y.useState(!1),i=Ke(t,r.onScrollButtonChange);return jt(()=>{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(dh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});ch.displayName=Ha;var Ua="SelectScrollDownButton",uh=y.forwardRef((e,t)=>{const n=Un(Ua,e.__scopeSelect),r=za(Ua,e.__scopeSelect),[o,s]=y.useState(!1),i=Ke(t,r.onScrollButtonChange);return jt(()=>{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(dh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});uh.displayName=Ua;var dh=y.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Un("SelectScrollButton",n),i=y.useRef(null),a=Us(n),l=y.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return y.useEffect(()=>()=>l(),[l]),jt(()=>{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(Re.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{l()})})}),_C="SelectSeparator",fh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(Re.div,{"aria-hidden":!0,...r,ref:t})});fh.displayName=_C;var Wa="SelectArrow",jC=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ws(n),s=Hn(Wa,n),i=Un(Wa,n);return s.open&&i.position==="popper"?u.jsx(lu,{...o,...r,ref:t}):null});jC.displayName=Wa;var RC="SelectBubbleInput",ph=y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=y.useRef(null),s=Ke(r,o),i=Bp(t);return y.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(Re.select,{...n,style:{...Hp,...n.style},ref:s,defaultValue:t})});ph.displayName=RC;function hh(e){return e===""||e===void 0}function mh(e){const t=Rt(e),n=y.useRef(""),r=y.useRef(0),o=y.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=y.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function gh(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=PC(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 PC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var OC=Up,xh=Vp,MC=qp,DC=Gp,LC=Yp,yh=Xp,$C=eh,vh=rh,bh=sh,FC=ih,zC=lh,wh=ch,Sh=uh,Ch=fh;const Th=OC,kh=MC,Va=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xh,{ref:r,className:ee("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(DC,{asChild:!0,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Va.displayName=xh.displayName;const Eh=y.forwardRef(({className:e,...t},n)=>u.jsx(wh,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));Eh.displayName=wh.displayName;const Ih=y.forwardRef(({className:e,...t},n)=>u.jsx(Sh,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4"})}));Ih.displayName=Sh.displayName;const Ka=y.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(LC,{children:u.jsxs(yh,{ref:o,className:ee("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(Eh,{}),u.jsx($C,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Ih,{})]})}));Ka.displayName=yh.displayName;const BC=y.forwardRef(({className:e,...t},n)=>u.jsx(vh,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));BC.displayName=vh.displayName;const lr=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(bh,{ref:r,className:ee("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(zC,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),u.jsx(FC,{children:t})]}));lr.displayName=bh.displayName;const HC=y.forwardRef(({className:e,...t},n)=>u.jsx(Ch,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));HC.displayName=Ch.displayName;var UC="Separator",Nh="horizontal",WC=["horizontal","vertical"],Ah=y.forwardRef((e,t)=>{const{decorative:n,orientation:r=Nh,...o}=e,s=VC(r)?r:Nh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(Re.div,{"data-orientation":s,...a,...o,ref:t})});Ah.displayName=UC;function VC(e){return WC.includes(e)}var _h=Ah;const jh=y.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(_h,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));jh.displayName=_h.displayName;const KC=Vf,qC=cS,GC=Kf,Rh=y.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{className:ee("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}));Rh.displayName=Ns.displayName;const YC=ho.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"}}),Ph=y.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(GC,{children:[u.jsx(Rh,{}),u.jsxs(As,{ref:o,className:ee(YC({side:e}),t),...r,children:[n,u.jsxs(qf,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ph.displayName=As.displayName;const Oh=({className:e,...t})=>u.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});Oh.displayName="SheetHeader";const Mh=y.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));Mh.displayName=or.displayName;const Dh=y.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Dh.displayName=_s.displayName;var Ks="Switch",[XC,MT]=En(Ks),[JC,ZC]=XC(Ks),Lh=y.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]=y.useState(null),x=Ke(t,S=>h(S)),m=y.useRef(!1),v=p?d||!!p.closest("form"):!0,[g,b]=hr({prop:o,defaultProp:s??!1,onChange:c,caller:Ks});return u.jsxs(JC,{scope:n,checked:g,disabled:a,children:[u.jsx(Re.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Bh(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:me(e.onClick,S=>{b(k=>!k),v&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),v&&u.jsx(zh,{control:p,bubbles:!m.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Lh.displayName=Ks;var $h="SwitchThumb",Fh=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ZC($h,n);return u.jsx(Re.span,{"data-state":Bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Fh.displayName=$h;var QC="SwitchBubbleInput",zh=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=y.useRef(null),a=Ke(i,s),l=Bp(n),c=Yc(t);return y.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const x=new Event("click",{bubbles:r});h.call(d,n),d.dispatchEvent(x)}},[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}})});zh.displayName=QC;function Bh(e){return e?"checked":"unchecked"}var Hh=Lh,eT=Fh;const Wn=y.forwardRef(({className:e,...t},n)=>u.jsx(Hh,{className:ee("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(eT,{className:ee("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")})}));Wn.displayName=Hh.displayName;const tT={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 nT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[c,d]=w.useState(!1),{toast:f}=Ta();w.useEffect(()=>{const v=JSON.stringify(a)!==JSON.stringify(e);d(v)},[a,e]),w.useEffect(()=>{l(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},h=()=>{l(tT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},m=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(KC,{open:r,onOpenChange:o,children:[u.jsx(qC,{asChild:!0,children:u.jsxs(et,{variant:"outline",size:"sm",className:n,children:[u.jsx(ce.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Sf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Ph,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Oh,{children:[u.jsx(Mh,{children:"Chat Settings"}),u.jsx(Dh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(oo,{children:[u.jsx(so,{className:"pb-3",children:u.jsxs(io,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(ao,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ls,{id:"api-url",value:a.api.baseUrl,onChange:v=>l(g=>({...g,api:{...g.api,baseUrl:v.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(et,{variant:"outline",onClick:m,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Wn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:v=>l(g=>({...g,api:{...g.api,enableAuth:v}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ls,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:v=>l(g=>({...g,api:{...g.api,authToken:v.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(et,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(ce.EyeOff,{className:"h-4 w-4"}):u.jsx(ce.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(oo,{children:[u.jsx(so,{className:"pb-3",children:u.jsxs(io,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(ao,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Th,{value:a.ui.layout,onValueChange:v=>l(g=>({...g,ui:{...g.ui,layout:v}})),children:[u.jsx(Va,{children:u.jsx(kh,{})}),u.jsxs(Ka,{children:[u.jsx(lr,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(lr,{value:"fullscreen",children:"Fullscreen"}),u.jsx(lr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"theme",children:"Theme"}),u.jsxs(Th,{value:a.ui.theme,onValueChange:v=>l(g=>({...g,ui:{...g.ui,theme:v}})),children:[u.jsx(Va,{children:u.jsx(kh,{})}),u.jsxs(Ka,{children:[u.jsx(lr,{value:"light",children:"Light"}),u.jsx(lr,{value:"dark",children:"Dark"}),u.jsx(lr,{value:"system",children:"System"})]})]})]}),u.jsx(jh,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Wn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,showTimestamps:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Wn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,showAgentNames:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Wn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,compactMessages:v}}))})]})]})]})]}),u.jsxs(oo,{children:[u.jsx(so,{className:"pb-3",children:u.jsxs(io,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(ao,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),u.jsx(Wn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:v=>l(g=>({...g,behavior:{...g.behavior,autoSave:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),u.jsx(Wn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:v=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),u.jsx(Wn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:v=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:v}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(et,{variant:"outline",onClick:h,children:[u.jsx(ce.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(et,{variant:"outline",onClick:x,children:"Cancel"}),u.jsxs(et,{onClick:p,disabled:!c,children:[u.jsx(ce.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function rT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Po,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Ds,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Po,{...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($a,{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(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Po,{...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($a,{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(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Wl,Ne.ChatInput=pc,Ne.ChatInterface=Ds,Ne.ChatProviders=Po,Ne.ChatSettings=nT,Ne.MarkdownContent=fo,Ne.MessageComponent=ja,Ne.MessageList=Ra,Ne.ThreadManager=$a,Ne.applySettings=lC,Ne.buildMessagePreviewMap=Jl,Ne.chatApiClient=Rn,Ne.default=rT,Ne.del=Ul,Ne.get=Zt,Ne.getChatToken=zl,Ne.getCurrentSettings=aC,Ne.getDefaultApiConfig=Dp,Ne.getDefaultChatSettings=Lp,Ne.onChatTokenChanged=Bl,Ne.post=ci,Ne.put=Hl,Ne.setChatToken=Io,Ne.useApi=ui,Ne.useChatStream=Zl,Ne.useMessagesReducer=Ql,Ne.useStream=dc,Ne.useThreadState=Ro,Ne.useThreads=jo,Object.defineProperties(Ne,{__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=rp(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=rp(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 lp{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 cp{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 zn{constructor(t){this.options=t||or,this.options.renderer=this.options.renderer||new _a,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new lp,this.slugger=new cp}static parse(t,n){return new zn(n).parse(t)}static parseInline(t,n){return new zn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,p,h,x,m,v,g,b,S,k,T,C;const E=t.length;for(o=0;o<E;o++){if(h=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(C=this.options.extensions.renderers[h.type].call({parser:this},h),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){r+=C||"";continue}switch(h.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(h.tokens),h.depth,np(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(f="",d="",a=h.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(h.header[s].tokens),{header:!0,align:h.align[s]});for(f+=this.renderer.tablerow(d),p="",a=h.rows.length,s=0;s<a;s++){for(c=h.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:h.align[i]});p+=this.renderer.tablerow(d)}r+=this.renderer.table(f,p);continue}case"blockquote":{p=this.parse(h.tokens),r+=this.renderer.blockquote(p);continue}case"list":{for(x=h.ordered,m=h.start,v=h.loose,a=h.items.length,p="",s=0;s<a;s++)b=h.items[s],S=b.checked,k=b.task,g="",b.task&&(T=this.renderer.checkbox(S),v?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):g+=T),g+=this.parse(b.tokens,v),p+=this.renderer.listitem(g,k,S);r+=this.renderer.list(p,x,m);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(p=h.tokens?this.parseInline(h.tokens):h.text;o+1<E&&t[o+1].type==="text";)h=t[++o],p+=`
134
+ `+(h.tokens?this.parseInline(h.tokens):h.text);r+=n?this.renderer.paragraph(p):p;continue}default:{const N='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Os{constructor(t){this.options=t||or}preprocess(t){return t}postprocess(t){return t}}Vh(Os,"passThroughHooks",new Set(["preprocess","postprocess"]));function PS(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>"+Dt(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 up(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=PS(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(_S(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 p;if(!f)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),p=t(l,r),r.hooks&&(p=r.hooks.postprocess(p))}catch(h){f=h}return r.highlight=a,f?i(f):o(null,p)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(p,h){if(p)return c(p);h!=null&&h!==f.text&&(f.text=h,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(ye.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return up(Fn.lex,zn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},xS(ye.defaults),ye},ye.getDefaults=Zf,ye.defaults=or,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ye.defaults.renderer||new _a;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ye.defaults.tokenizer||new Aa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ye.defaults.hooks||new Os;for(const s in n.hooks){const i=o[s];Os.passThroughHooks.has(s)?o[s]=a=>{if(ye.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ye.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=up(Fn.lexInline,zn.parseInline),ye.Parser=zn,ye.parser=zn.parse,ye.Renderer=_a,ye.TextRenderer=lp,ye.Lexer=Fn,ye.lexer=Fn.lex,ye.Tokenizer=Aa,ye.Slugger=cp,ye.Hooks=Os,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,zn.parse,Fn.lex;function uo({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ee("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 OS="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 MS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function dp(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 Ms(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function DS(e){const t=o=>{try{const s=lo(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 LS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function fp(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 $S(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function FS(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function zS({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=$S(n),i=o?`data:${s};base64,${e}`:t,a=FS(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function BS(e){var s,i;const t=((s=e.content_base64)==null?void 0:s.trim())||void 0,n=((i=e.url)==null?void 0:i.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return zS({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function HS({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ee("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const ja=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:p=!0,customStyles:h={},onEdit:x,onRegenerate:m,onCancelEdit:v,onCopy:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,checkpointCandidates:C=[],activeCheckpointId:E=null,onSelectCheckpoint:N,defaultCheckpointId:j=null,messageParentCheckpointId:L=null,attemptMeta:_=null}){const[M,z]=w.useState(!1);w.useEffect(()=>{_&&_.attemptCount>1&&console.log("[MessageComponent] Attempt meta received:",{messageId:t.id,attemptIndex:_.attemptIndex,attemptCount:_.attemptCount,isLatestAttempt:_.isLatestAttempt,messageRole:t.role})},[_,t.id,t.role]);const[A,F]=w.useState("preview"),[R,G]=w.useState(!1),{currentThreadId:B}=jo(),{respondToInterrupt:D}=Ro(),V=l==="phone"||l==="half-screen",Y=t.role,he=Y==="tool",ie=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),Ae=!!ie,X=!(r&&Y!=="user"),{uploadingFiles:H,handleFileClick:J,fileViewerOpen:$,currentFileInfo:K,closeFileViewer:re}=WS({allowFileOpen:X,currentThreadId:B}),oe=w.useMemo(()=>{switch(Y){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))]"}},[Y]),se=w.useMemo(()=>ie?"":MS(t.content),[ie,t]),Te=w.useMemo(()=>ie?{}:dp(t),[ie,t]),Je=w.useMemo(()=>ie?[]:t.content.filter(P=>P.type==="image_url"),[ie,t]),De=w.useMemo(()=>ie?[]:t.content.filter(P=>P.type==="file"),[ie,t]),Ye=w.useMemo(()=>ie?[]:t.content.filter(P=>P.type==="interrupt"),[ie,t]),de=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),be=Ms(de),Fe=b==null?void 0:b.value,He=w.useMemo(()=>ie?"":DS(t.content),[ie,t]),Ue=w.useMemo(()=>{if(ie||!p)return[];const ue=t.artifact;if(!ue)return[];const q=[],we=[...Array.isArray(ue.plots)?ue.plots:[]];for(const kt of we){const Wt=BS(kt);Wt&&q.push(Wt)}return q},[ie,t,p]),rt=w.useCallback(async()=>{const P=he?He:se;async function ue(q){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(q);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const we=new Blob([q],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":we})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ue(P),z(!0),setTimeout(()=>z(!1),2e3),g==null||g(P)}catch(q){console.error("Failed to copy:",q)}},[he,He,se,g]),Le=w.useCallback(()=>{if(!x)return;const P=he?He:se,ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,P,ue)},[x,t.id,he,He,se,t]),$e=w.useCallback(()=>{m==null||m(n)},[m,n]),ot=w.useCallback(()=>{const ue=ee(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",oe);switch(Y){case"user":return u.jsx(ce.User,{className:ue});case"assistant":return u.jsx(ce.Bot,{className:ue});case"tool":return u.jsx(ce.Wrench,{className:ue});default:return u.jsx(ce.Bot,{className:ue})}},[V,oe,Y]),It=w.useCallback(()=>{const P="group relative mb-4 flex w-full";switch(Y){case"user":return ee(P,"justify-end");case"assistant":case"tool":case"system":return ee(P,"justify-start");default:return P}},[Y]),st=w.useCallback(()=>{const P=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");if(Ae)return ee(P,"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(Y){case"user":return ee(P,"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 ee(P,"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 ee(P,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(P,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(P,"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")}},[V,Ae,Y]);if(Ae&&ie)return u.jsx("div",{className:ee(It(),h.container),children:u.jsxs("div",{className:ee(st(),h.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ce.Bot,{className:ee("h-4 w-4",oe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(uo,{content:ie.content,className:"text-current"})]})});const pt=w.useCallback(async P=>{if(S)return;const ue=Ms((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!ue){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await D(ue,!0)}catch(q){console.error("Failed to approve interrupt:",q)}finally{T==null||T()}},[S,T,k,D]),ht=w.useCallback(async P=>{if(S)return;const ue=Ms((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!ue){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await D(ue,!1)}catch(q){console.error("Failed to reject interrupt:",q)}finally{T==null||T()}},[S,T,k,D]),vt=w.useCallback(({part:P,i:ue})=>{if(P.type==="text"){const q=P.text??"",we=q.trim(),kt=ka(we);return kt&&Y!=="tool"?u.jsx(pp,{data:kt},ue):Y==="user"&&c&&we.length>d?u.jsx(VS,{text:we,expanded:R,onExpandedChange:G,previewLength:d,isCompact:V},ue):u.jsx(uo,{content:q,allowHtml:!1},ue)}if(P.type==="image_url"){const q=P;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:q.url,alt:q.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ue)}if(P.type==="file"){const q=P,we=q.name||"file";return u.jsxs("a",{href:q.url,onClick:kt=>J(kt.nativeEvent,q,ue),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:[H[ue]?u.jsx(ce.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[we,H[ue]?" (processing)":""]})]},ue)}if(P.type==="interrupt"){const q=P,we=Ms((q==null?void 0:q.id)??(q==null?void 0:q.interrupt_id)),kt=!!(be&&we&&we===be),Wt=kt?Fe??(q==null?void 0:q.value):q==null?void 0:q.value,Nr=we?{...q,id:we,interrupt_id:we}:q;return u.jsx(US,{interruptPart:Nr,onApprove:pt,onReject:ht,disabled:S,isActive:kt,payload:Wt},ue)}return null},[J,H,pt,ht,Y,c,d,R,V,be,Fe,b,S,Ye]),xt=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),yt=w.useCallback(()=>{const P=se.trim().length>0||Je.length>0||De.length>0||Ye.length>0;if(!he&&De.length>0&&!r)return xt();if(!he&&!P&&!r)return null;if(he)return!f&&Ue.length>0?null:f?u.jsx(KS,{message:t,viewMode:A},t.id):null;if(!he&&!ie){const ue=t,q=u.jsx("div",{className:"space-y-2",children:ue.content.map((we,kt)=>u.jsx(vt,{part:we,i:kt},kt))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[q,u.jsx(HS,{className:oe})]}):q}},[se,Je.length,De.length,Ye.length,r,he,A,f,Ue.length,xt,oe]),Lt=w.useMemo(()=>ie?"Assistant":LS(t),[ie,t]),ze=w.useMemo(()=>ie?[]:Array.isArray(C)?C:[],[C,ie]),hn=w.useMemo(()=>{var P;return ze.length?j&&ze.some(ue=>ue.id===j)?j:((P=ze[0])==null?void 0:P.id)??null:null},[j,ze]),Qe=w.useMemo(()=>!ze.length||!E?null:ze.some(P=>P.id===E)?E:null,[E,ze])??hn,wt=Y==="user"&&ze.length>0&&typeof N=="function",Q=w.useCallback(P=>{if(!N)return;const ue=(P==null?void 0:P.id)??null,q=(P==null?void 0:P.parentId)??L??null;N(ue,q)},[L,N]),te=w.useMemo(()=>Qe?ze.findIndex(P=>P.id===Qe):-1,[Qe,ze]),ve=w.useMemo(()=>te<0?null:ze[te]??null,[te,ze]),Ce=w.useCallback(P=>{const ue=[];if(P.step!==null&&ue.push(`Step ${P.step}`),P.source&&ue.push(P.source),!P.createdAt)return ue.length?ue.join(" • "):P.id.slice(0,8);let q="";try{const we=new Date(P.createdAt);Number.isNaN(we.getTime())||(q=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(we))}catch{q=""}return`${q}`},[]),Pe=w.useCallback(P=>{if(!P)return"";try{const ue=new Date(P);return Number.isNaN(ue.getTime())?"":new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(ue)}catch{return""}},[]),Ge=w.useMemo(()=>{if(!_||_.attemptCount<=1)return null;const P=_.isLatestAttempt?`Latest of ${_.attemptCount}`:`Attempt ${_.attemptIndex+1} of ${_.attemptCount}`;return u.jsx("span",{className:ee("rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide",_.isLatestAttempt?"border-emerald-500 bg-emerald-50 text-emerald-700 dark:border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-200":"border-border bg-muted/10 text-muted-foreground dark:bg-muted/30"),children:P})},[_]),Nt=w.useMemo(()=>!_||_.attemptCount<=1||C.length<=1?null:u.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[10px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{className:"font-semibold text-[11px] text-foreground",children:"Versions"}),u.jsx("div",{className:"flex flex-wrap gap-1",children:C.map((P,ue)=>{const q=P.id===(ve==null?void 0:ve.id)||P.id===j,we=Pe(P.createdAt);return u.jsxs("span",{className:ee("rounded-full border px-2 py-0.5 font-semibold text-[10px] tracking-wider",q?"border-emerald-500 bg-emerald-50 text-emerald-700 dark:border-emerald-400 dark:bg-emerald-900/40 dark:text-emerald-200":"border-border bg-muted/10 text-muted-foreground dark:bg-muted/30"),children:[q?"Current":`Attempt ${ue+1}`,we&&u.jsx("span",{className:"ml-1 block text-[9px] uppercase tracking-normal text-muted-foreground",children:we})]},P.id)})})]}),[_,C,ve,j,Pe]);return he&&!f&&Ue.length===0?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ee(It(),h.container),children:u.jsxs("div",{className:ee(st(),h.content),children:[(i||a||he)&&u.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",oe,h.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[ot(),a&&Lt&&u.jsx("span",{className:ee("font-medium",V?"text-xs":"text-sm"),children:Lt}),Ge&&u.jsx("div",{className:"flex items-center",children:Ge}),he&&u.jsxs(Sf,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer select-none",oe,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":A==="expanded",onClick:()=>F(P=>P==="expanded"?"preview":"expanded"),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),F(ue=>ue==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Te.name??"Tool Output"}),Te.toolCallId&&u.jsx("span",{className:"opacity-70",children:Te.toolCallId.slice(0,8)}),A==="expanded"?u.jsx(ce.ChevronUp,{className:"h-3 w-3"}):u.jsx(ce.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[wt&&ve&&te>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ee("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",te>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(te<=0)return;const P=ze[te-1];P&&Q(P)},"aria-label":"Previous checkpoint",disabled:te<=0,children:u.jsx(ce.ChevronLeft,{className:"h-3 w-3"})}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("span",{className:"whitespace-nowrap",children:[te+1," / ",ze.length]}),u.jsx("span",{className:"text-muted-foreground",children:Ce(ve)})]}),u.jsx("button",{type:"button",className:ee("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",te<ze.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(te>=ze.length-1)return;const P=ze[te+1];P&&Q(P)},"aria-label":"Next checkpoint",disabled:te>=ze.length-1,children:u.jsx(ce.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ee("text-xs opacity-60",oe,V&&"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:ee("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>rt(),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ce.Copy,{className:ee(M?"text-success":oe,V?"h-3 w-3":"h-4 w-4")})})}),Y==="user"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Le,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ce.Edit,{className:ee(oe,V?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&m&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:$e,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",oe,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ce.RotateCcw,{className:ee(oe,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),Nt,u.jsxs("div",{className:"relative",children:[yt(),p&&Ue.length>0&&u.jsx("div",{className:"mt-3 space-y-4",children:Ue.map((P,ue)=>(w.useEffect(()=>{nS()&&console.debug(`[MessageComponent] Preview ${ue} mounted:`,{src:P.src.substring(0,100),alt:P.alt,label:P.label})},[]),u.jsxs("div",{className:"space-y-2",children:[P.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",P.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:P.src,alt:P.alt,title:P.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:q=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${ue}:`,{alt:P.alt,label:P.label,message:q.target.alt})}})})]},`artifact-${ue}`)))})]}),he&&A==="expanded"&&(Te.toolCallId||Te.name)&&u.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[Te.name&&u.jsxs("div",{children:["Function: ",Te.name]}),Te.toolCallId&&u.jsxs("div",{children:["Call ID: ",Te.toolCallId]})]}),!(i||a||he)&&s&&!o&&u.jsxs("div",{className:ee("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",h.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>rt(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.Copy,{className:ee(M?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),Y==="user"&&x&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Le,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.Edit,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})}),Y==="assistant"&&m&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:$e,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:u.jsx(ce.RotateCcw,{className:ee("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),K&&u.jsx(gS,{isOpen:$,onClose:re,fileId:K.id,fileName:K.name,mimeType:K.mimeType})]})},(e,t)=>{var i,a,l,c,d,f,p,h;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&fp(e.message)===fp(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","attemptMeta"].every(x=>e[x]===t[x]),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 pp({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:OS,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:co(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:co(e)})}function US({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=co(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(ro,{className:ee("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(oo,{className:"pb-3",children:[u.jsx(so,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Cf,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(io,{className:"pt-0 pb-3",children:a}),u.jsx(Tf,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(tt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function WS(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ta(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),f=w.useCallback(h=>{a(h),c(!0)},[]),p=w.useCallback(async(h,x,m)=>{var v,g;if(!t){h.preventDefault();return}if(o[m]){h.preventDefault();return}try{const b=String(x.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],T=x.name||`file_${k}`,C=x.mimeType||"application/octet-stream";f({id:k,name:T,mimeType:C});return}if(b.startsWith("data:")){h.preventDefault(),s(T=>({...T,[m]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const T=await Y0(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??"")===(x.name??""))?!1:typeof x.size=="number"&&typeof E.size=="number"?E.size===x.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${x.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:x.name||C.filename||`file_${C.id}`,mimeType:x.mimeType||C.mime_type||"application/octet-stream"}),(v=k.update)==null||v.call(k,{id:k.id,title:"Success",description:`Opened ${x.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,[m]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[m]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:p,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function VS({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:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(uo,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ee("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(tt,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function KS({message:e,viewMode:t}){const r=dp(e).name||"tool",o=c=>{if(c==null)return null;const d=typeof c=="string"?ka(c)??c:c;if(d&&typeof d=="object")return u.jsx(pp,{data:d});const f=typeof d=="string"?d:(()=>{try{return co(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}=J0(c);return f?u.jsx(uo,{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(ce.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=ks(d);return s(f)}const a=lo(i),l=ks(a);return s(l)}const qS=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r})=>{const o=e??[],s=o.length>0,i=w.useMemo(()=>s?[...o].reverse():[],[o,s]),a=t??(o.length?o[o.length-1].id:null);return w.useEffect(()=>{console.debug("[TimelineColumn] entries:",o.length)},[o.length]),s?u.jsxs("div",{className:"w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex",children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsxs("div",{className:"absolute left-0 right-0 top-1 flex items-center justify-between px-2 pb-3 text-[10px] 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(ce.Info,{className:"h-3 w-3 text-muted-foreground cursor-help"}),u.jsx("div",{className:"pointer-events-auto fixed hidden w-56 rounded-md border bg-background p-3 text-[10px] font-normal text-muted-foreground shadow-lg group-hover:block whitespace-normal leading-relaxed",style:{zIndex:9999},children:"Backend pre-selects user inputs + latest loop checkpoint. Click a dot to jump, or use “Latest” to return to the newest messages."})]})]}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:i.map(l=>{const c=a===l.id,d=l.messageId?(r==null?void 0:r.get(l.messageId))??null:null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(l.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${c?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${c?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:l.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[l.step!==null?`STEP ${l.step}`:"STEP —",l.next?` - ${l.next}`:""]}),d&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:d,children:d})]})]},l.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]}):null},hp=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ra=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:p,emptyMessage:h,followNewMessages:x=!0,isNavigatingCheckpoint:m=!1,onScrollAway:v,onAtBottom:g,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C=!0,showArtifactPreviews:E=!0,checkpointMetaById:N,checkpointIndexByKey:j,attemptMetaById:L,activeCheckpointId:_,onSelectCheckpoint:M,timelineCheckpoints:z,messagePreviews:A,createSyntheticThinkingMessage:F=!1},R)=>{const G=w.useRef(null),B=w.useRef(null),D=w.useRef(!1),[V,Y]=w.useState(!0),he=w.useMemo(()=>b?e.some(de=>"type"in de&&de.type==="default_message"?!1:Array.isArray(de==null?void 0:de.content)&&de.content.some(be=>be&&be.type==="interrupt"&&(be.id??be.interrupt_id)===b.id)):!1,[b,e]),ie=w.useMemo(()=>{if(!b||he)return null;const de=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let be;const Fe=b.value;if(Fe&&typeof Fe=="object"&&!Array.isArray(Fe)){const He=Fe.title;typeof He=="string"&&He.trim()&&(be=He.trim())}return{id:`interrupt-${de}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:de,value:Fe,title:be}]}},[b,he]),Ae=w.useMemo(()=>ie?[...e,ie]:e,[e,ie]),X=w.useMemo(()=>!F||!t?Ae:!Ae.some(be=>be.role==="assistant")&&Ae.length>0?[...Ae,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString()}]:Ae,[Ae,t,F]),H=w.useMemo(()=>C?X:X.filter(de=>(de==null?void 0:de.role)!=="tool"),[X,C]),J=w.useCallback(de=>{Y(de),v&&v(!de),g&&g(de)},[v,g]),$=w.useMemo(()=>{if(a)return async()=>{if(!D.current){D.current=!0;try{await a()}finally{D.current=!1}}}},[a]),K=w.useMemo(()=>!x||m?!1:V?"auto":!1,[V,x,m]),re=z??[],oe=re.length>0,se=w.useMemo(()=>{if(typeof h!="string")return null;const de=h.trim();return de?{id:"default-message",role:"assistant",type:"default_message",content:de,createdAt:new Date().toISOString()}:null},[h]),Te=oe?u.jsx(qS,{timelineEntries:re,activeCheckpointId:_??null,onSelectCheckpoint:M,messagePreviews:A}):null,Je=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),De=()=>se?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ja,{message:se,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:h??"No messages yet. Start a conversation!"}),Ye=H.length>0;return w.useImperativeHandle(R,()=>({scrollToLatest:()=>{var de,be;if(G.current&&H.length>0){const Fe=H.length-1;(be=(de=G.current).scrollToIndex)==null||be.call(de,{index:Fe,align:"end",behavior:"auto"})}else B.current&&(B.current.scrollTop=B.current.scrollHeight)},scrollToTop:()=>{var de,be;G.current&&H.length>0?(be=(de=G.current).scrollToIndex)==null||be.call(de,{index:0,align:"start",behavior:"auto"}):B.current&&(B.current.scrollTop=0)}}),[H]),u.jsxs("div",{className:Je,style:p,children:[Te,u.jsx("div",{className:"relative flex-1 min-h-0",children:Ye?u.jsx(I0,{ref:de=>{G.current=de},scrollerRef:de=>{B.current=de instanceof HTMLDivElement?de:null},data:H,followOutput:K,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!0,startReached:()=>{$&&$()},atBottomStateChange:J,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(de,be)=>hp(be,de),itemContent:(de,be)=>{var ht;const Fe=hp(be,de),He="type"in be&&be.type==="default_message";let Ue=[],rt=null,Le={},$e={},ot=null,It=null,st=null;if(!He){const vt=be,xt=vt.checkpointId??null;Le=vt.additionalKwargs??{},$e=vt.responseMetadata??{};const yt=xt&&N?N.get(xt)??null:null;ot=typeof Le.step=="number"?Le.step:typeof $e.step=="number"?$e.step:(yt==null?void 0:yt.step)??null;const Lt=typeof Le.source=="string"?Le.source:typeof $e.source=="string"?$e.source:(yt==null?void 0:yt.source)??null;It=Lt?String(Lt):null;const ze=ot!==null&&It?`${ot}:${It}`:null;ze&&(j!=null&&j.has(ze))?Ue=j.get(ze)??[]:xt&&yt&&(Ue=[yt]),rt=xt??((ht=Ue[0])==null?void 0:ht.id)??null,st=xt?(L==null?void 0:L.get(xt))??null:null,st&&st.attemptCount>1&&console.log("[MessageList] Message has multiple attempts:",{messageId:be.id,messageCheckpointId:xt,attemptIndex:st.attemptIndex,attemptCount:st.attemptCount,isLatestAttempt:st.isLatestAttempt})}const pt=(()=>{if(typeof Le.parentCheckpointId=="string")return Le.parentCheckpointId;if(typeof $e.parentCheckpointId=="string")return $e.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":Fe,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ja,{message:be,messageIndex:de,isStreamingMessage:t&&n===be.id,streamingDebounceMs:r,isEditing:i===be.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:l,onRegenerate:()=>c(de),onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:T,showToolMessages:C,showArtifactPreviews:E,checkpointCandidates:Ue,activeCheckpointId:_??null,onSelectCheckpoint:M,defaultCheckpointId:rt,messageParentCheckpointId:pt,attemptMeta:st})})}}):De()})]})});Ra.displayName="MessageList";const mp={value:""};function Ds({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:p={},onMessageSent:h,onExcelUploadSuccess:x,onError:m}){const{api:v}=ui(),{currentThreadId:g}=jo(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:T,navigateToCheckpoint:C,returnToLatest:E,checkpoint:N,checkpoints:j,interrupt:L,metadata:_,timelineCheckpoints:M,messagePreviews:z}=Ro(),{isStreaming:A,error:F,connectionState:R,submit:G,stop:B}=dc(),D=b??g??null,V=(N==null?void 0:N.id)??null,Y=(N==null?void 0:N.namespace)??null,he=(_==null?void 0:_.assemblingMessageId)??null,ie=L,[Ae,X]=w.useState(!1);w.useEffect(()=>{ie||X(!1)},[ie]);const H=w.useCallback(()=>{X(!0)},[]),J=w.useCallback(()=>{X(!1)},[]),$=!!ie||Ae,[K,re]=w.useState(null),[oe,se]=w.useState(""),[Te,Je]=w.useState(null),[De,Ye]=w.useState(null),[de,be]=w.useState([]),[Fe,He]=w.useState(0),[Ue,rt]=w.useState(0),[Le,$e]=w.useState(!1),[ot,It]=w.useState(null),[st,pt]=w.useState(null),[ht,vt]=w.useState(!1),[xt,yt]=w.useState(null),Lt=w.useRef(!1),[ze,hn]=w.useState(()=>mp.value),at=w.useRef(ze),Qe=w.useRef(null),wt=w.useCallback(ne=>{mp.value=ne,hn(ne)},[]),[Q,te]=w.useState(!1),ve=w.useRef(null),Ce=w.useCallback((ne,le)=>{if(!ne||typeof ne!="object")return null;const ge=ne[le];return typeof ge=="number"?ge:null},[]),Pe=w.useCallback((ne,le)=>{if(!ne||typeof ne!="object")return null;const ge=ne[le];return typeof ge=="string"&&ge.trim()?ge:null},[]),Ge=w.useMemo(()=>{const ne=We=>{if(!Array.isArray(We)||We.length===0)return null;const Xe=We.map(ut=>{if(typeof ut=="string")return ut.trim();if(ut&&typeof ut=="object"&&"type"in ut){const Kt=ut;if(typeof Kt.type=="string")return Kt.type}return null}).filter(ut=>!!(ut&&ut.length));return Xe.length?Xe.join(", "):null},le=Array.isArray(j)?j.map(We=>{const Xe=ne(We.next);return Xe?{...We,metadata:{...We.metadata??{},next:Xe}}:We}):[];return le.some(We=>Ce(We.metadata,"step")!==null)&&le.sort((We,Xe)=>{const ut=Ce(We.metadata,"step"),Kt=Ce(Xe.metadata,"step");if(ut!==null||Kt!==null)return(Kt??Number.NEGATIVE_INFINITY)-(ut??Number.NEGATIVE_INFINITY);const Ar=Date.parse(We.createdAt??""),po=Date.parse(Xe.createdAt??"");return Number.isNaN(Ar)||Number.isNaN(po)?0:po-Ar}),le},[j,Ce]),{checkpointMetaById:Nt,checkpointIndexByKey:P,attemptMetaById:ue}=w.useMemo(()=>{const ne=new Map,le=new Map,ge=new Map;for(const Xe of Ge){const ut=Xe.checkpointId??null;if(!ut)continue;const Kt=Ce(Xe.metadata,"step"),Ar=Pe(Xe.metadata,"source"),po={id:ut,step:Kt,source:Ar,createdAt:Xe.createdAt??null,namespace:Xe.checkpointNs??null,parentId:Xe.parentId??null};if(ne.set(ut,po),Kt!==null&&Ar){const Uh=`${Kt}:${Ar}`,Wh=le.get(Uh)??[];Wh.push(po),le.set(Uh,Wh)}}console.log("[ChatInterface] Building attempt metadata for",Ge.length,"checkpoints");const We=hw(Ge);for(const[Xe,ut]of ne.entries()){const Kt=We.get(Xe);Kt?ge.set(Xe,{...ut,attemptIndex:Kt.attemptIndex,attemptCount:Kt.attemptCount,isLatestAttempt:Kt.isLatestAttempt}):ge.set(Xe,{...ut,attemptIndex:0,attemptCount:1,isLatestAttempt:!0})}return console.log("[ChatInterface] Final attemptMetaById:",{totalCheckpoints:ge.size,withMultipleAttempts:Array.from(ge.values()).filter(Xe=>Xe.attemptCount>1).length,samples:Array.from(ge.entries()).slice(0,3).map(([Xe,ut])=>({checkpointId:Xe,attemptIndex:ut.attemptIndex,attemptCount:ut.attemptCount}))}),{checkpointMetaById:ne,checkpointIndexByKey:le,attemptMetaById:ge}},[Ge,Ce,Pe]),q=M??[],we=w.useRef(null),kt=w.useRef(null),Wt=w.useCallback(()=>{we.current&&(we.current.value=""),kt.current&&(kt.current.value=""),He(ne=>ne+1),rt(ne=>ne+1)},[]),Nr=w.useCallback(ne=>{wt(ne)},[wt]),qs=w.useRef(!1);w.useEffect(()=>{qs.current&&!A&&(be([]),Wt()),qs.current=A},[A,Wt]);const[qa,Ga]=w.useState("desktop");w.useEffect(()=>{const ne=()=>{const le=window.innerWidth;Ga(le<640?"phone":le<1024?"tablet":"desktop")};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[]),w.useEffect(()=>{Lt.current=!1},[D]),w.useEffect(()=>{at.current=ze},[ze]),w.useEffect(()=>{if(!K){Qe.current=null;return}Qe.current===null&&(Qe.current=at.current),wt(oe??"")},[oe,K,wt]),w.useEffect(()=>{(async()=>{if(!v.baseUrl){yt(null);return}try{const ge=(await v.getAgent("default")).uiDefaultMessage||"";yt(ge||null)}catch(le){console.warn("Failed to fetch default message:",le),yt(null)}})()},[v.baseUrl]),w.useEffect(()=>{F&&!ht&&(m==null||m(F))},[F,ht,m]);const Ya=ne=>{if(ne.length>cs)return`Message too long (${ne.length}/${cs} characters)`;try{return xw(ne),null}catch(le){return(le==null?void 0:le.message)||"Invalid message"}},I=async ne=>{const le=ne.trim();if(!(!le&&de.length===0)){if(le){const ge=Ya(le);if(ge){Ye(ge);return}}try{const ge=V??void 0,We=Y??void 0,Xe=K?{edit:!0,originalMessageId:K,...Te!=null&&Te.checkpointId?{originalCheckpointId:Te.checkpointId}:{},...Te!=null&&Te.checkpointNs?{originalCheckpointNs:Te.checkpointNs}:{}}:void 0;await G({text:le||"",attachments:de,messageAdditionalKwargs:Xe},{checkpointId:ge,checkpointNs:We}),h==null||h(le),wt(""),Ye(null),be([]),Wt(),re(null),se(""),Je(null)}catch(ge){const We=(ge==null?void 0:ge.message)||"Failed to send message";Ye(We),m==null||m(We)}}},W=w.useCallback((ne,le,ge)=>{c&&(Qe.current=ze,re(ne),se(le),wt(le),Ye(null),Je({checkpointId:(ge==null?void 0:ge.checkpointId)??null,checkpointNs:(ge==null?void 0:ge.checkpointNs)??null}))},[ze,c,wt]),ae=w.useCallback(()=>{re(null),se(""),Je(null),Ye(null),wt(Qe.current??ze),Qe.current=null},[ze,wt]),Ee=w.useCallback((ne,le,ge)=>{W(ne,le,ge)},[W]),et=w.useCallback(ne=>{for(let le=ne-1;le>=0;le--)if(S[le].role==="user"){const ge=S[le].content||[],Xe=ge.filter(ut=>ut.type==="text").map(ut=>ut.text).join("")||(()=>{try{return JSON.stringify(ge,null,2)}catch{return String(ge)}})();Xe&&G({text:Xe},{checkpointId:V??void 0,checkpointNs:Y??void 0});break}},[S,G,V,Y]),it=ne=>{const le=Array.from(ne.target.files||[]);be(ge=>[...ge,...le]),ne.target.value=""},Ve=ne=>{be(le=>{const ge=le.filter((We,Xe)=>ne!==Xe);return ge.length===0&&Wt(),ge})},Be=async ne=>{const le=(ne.target.files||[])[0];if(le){It(null),pt(null),$e(!0);try{await G({attachments:[le]},{checkpointId:V??void 0,checkpointNs:Y??void 0});const ge=`Uploaded ${le.name} - processing through chat stream`;pt(ge)}catch(ge){const We=ge instanceof Error?ge.message:"Failed to upload Excel file";console.error("Excel upload failed",ge),It(We),m==null||m(We)}finally{$e(!1),ne.target.value="",Wt()}}},_t=async ne=>{if(g){te(!0);try{if(!ne){await E(),requestAnimationFrame(()=>{var We;(We=ve.current)==null||We.scrollToLatest()});return}const le=Ge.find(We=>We.checkpointId===ne),ge=(le==null?void 0:le.checkpointNs)??null;await C(ne,ge),requestAnimationFrame(()=>{var We;(We=ve.current)==null||We.scrollToTop()})}finally{te(!1)}}},bt=w.useCallback(async ne=>{await _t(ne)},[_t]),St=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${p.container||""}`,Vt=`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 ${p.messagesArea||""}`,Wn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${p.inputArea||""}`;return w.useCallback(ne=>{if(!ne)return"Latest";const le=[];ne.step!==null&&le.push(`Step ${ne.step}`),ne.source&&le.push(ne.source);const ge=ne.createdAt?new Date(ne.createdAt):null,We=ge&&!Number.isNaN(ge.getTime())?ge.toLocaleString():ne.createdAt??ne.id,Xe=le.length?` — ${le.join(" • ")}`:"";return`${We}${Xe}`},[]),u.jsxs("div",{className:St,children:[!!F&&!ht&&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:F}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>vt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ce.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Vt}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Ra,{ref:ve,className:"h-full",style:{height:"100%"},messages:S,isStreaming:A,streamingAssistantId:he,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:qa,enableMessageEditing:c,editingMessageId:K,onEdit:Ee,onRegenerate:et,onCancelEdit:ae,emptyMessage:xt??void 0,isNavigatingCheckpoint:Q,activeInterrupt:ie,disableInterruptActions:Ae,onInterruptActionStart:H,onInterruptActionEnd:J,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:Nt,checkpointIndexByKey:P,attemptMetaById:ue,activeCheckpointId:V,onSelectCheckpoint:bt,timelineCheckpoints:q,messagePreviews:z}),(R==="reconnecting"||R==="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(ce.Loader2,{className:"h-3 w-3 animate-spin"}),R==="reconnecting"?"Reconnecting…":"Connecting…"]})}),R==="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(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Q)&&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(ce.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:Wn,children:[K&&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(ce.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:ae,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ce.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:we,type:"file",multiple:!0,onChange:ne=>it(ne),className:"hidden"},Fe),de.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:de.map((ne,le)=>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(ce.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ne.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ve(le),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 ${ne.name}`,children:u.jsx(ce.X,{size:12})})]},le))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:kt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Be,className:"hidden"},Ue),Le&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),st&&!Le&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:st}),ot&&!Le&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ot})]})]}),De&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:De}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(sw,{children:[u.jsx(iw,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:A||$,title:"More input actions",className:p.moreButton||"",children:u.jsx(ce.Plus,{size:16})})}),u.jsxs(Sd,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Zi,{onClick:()=>{var ne;return(ne=we.current)==null?void 0:ne.click()},className:"cursor-pointer",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Zi,{onClick:()=>{var ne;Le||(ne=kt.current)==null||ne.click()},className:`cursor-pointer ${Le?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(ix,{initialValue:oe,editingMessageId:K,value:ze,onValueChange:Nr,placeholder:K?"Edit your message...":t,isStreaming:A,disabled:$,maxLength:cs,onSend:I,onCancelEdit:ae,onStop:B,allowEmptySend:de.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${De?"border-red-400":""} ${p.textarea||""}`})})]})]})]})}const Ls=y.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ee("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}));Ls.displayName="Input";function Pa(e,[t,n]){return Math.min(n,Math.max(t,e))}function GS(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var Oa="ScrollArea",[gp,DT]=En(Oa),[YS,on]=gp(Oa),xp=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=y.useState(null),[c,d]=y.useState(null),[f,p]=y.useState(null),[h,x]=y.useState(null),[m,v]=y.useState(null),[g,b]=y.useState(0),[S,k]=y.useState(0),[T,C]=y.useState(!1),[E,N]=y.useState(!1),j=Ke(t,_=>l(_)),L=Oo(o);return u.jsx(YS,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:p,scrollbarX:h,onScrollbarXChange:x,scrollbarXEnabled:T,onScrollbarXEnabledChange:C,scrollbarY:m,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(je.div,{dir:L,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":g+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});xp.displayName=Oa;var yp="ScrollAreaViewport",vp=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=on(yp,n),a=y.useRef(null),l=Ke(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(je.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})})]})});vp.displayName=yp;var Tn="ScrollAreaScrollbar",Ma=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return y.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(XS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(JS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(bp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Da,{...r,ref:t}):null});Ma.displayName=Tn;var XS=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),[s,i]=y.useState(!1);return y.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(en,{present:n||s,children:u.jsx(bp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),JS=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Bs(()=>l("SCROLL_END"),100),[a,l]=GS("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 y.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),y.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(en,{present:n||a!=="hidden",children:u.jsx(Da,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:me(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:me(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),bp=y.forwardRef((e,t)=>{const n=on(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=y.useState(!1),a=e.orientation==="horizontal",l=Bs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return kr(n.viewport,l),kr(n.content,l),u.jsx(en,{present:r||s,children:u.jsx(Da,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Da=y.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=on(Tn,e.__scopeScrollArea),s=y.useRef(null),i=y.useRef(0),[a,l]=y.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=kp(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 rC(p,i.current,a,h)}return n==="horizontal"?u.jsx(ZS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollLeft,h=Ep(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(QS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const p=o.viewport.scrollTop,h=Ep(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}),ZS=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Tn,e.__scopeScrollArea),[i,a]=y.useState(),l=y.useRef(null),c=Ke(t,l,s.onScrollbarXChange);return y.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Sp,{"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":zs(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),Np(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:Fs(i.paddingLeft),paddingEnd:Fs(i.paddingRight)}})}})}),QS=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Tn,e.__scopeScrollArea),[i,a]=y.useState(),l=y.useRef(null),c=Ke(t,l,s.onScrollbarYChange);return y.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Sp,{"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":zs(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),Np(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:Fs(i.paddingTop),paddingEnd:Fs(i.paddingBottom)}})}})}),[eC,wp]=gp(Tn),Sp=y.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=on(Tn,n),[x,m]=y.useState(null),v=Ke(t,j=>m(j)),g=y.useRef(null),b=y.useRef(""),S=h.viewport,k=r.content-r.viewport,T=Rt(d),C=Rt(l),E=Bs(f,10);function N(j){if(g.current){const L=j.clientX-g.current.left,_=j.clientY-g.current.top;c({x:L,y:_})}}return y.useEffect(()=>{const j=L=>{const _=L.target;(x==null?void 0:x.contains(_))&&T(L,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,x,k,T]),y.useEffect(C,[r,C]),kr(x,E),kr(h.content,E),u.jsx(eC,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:Rt(s),onThumbPointerUp:Rt(i),onThumbPositionChange:C,onThumbPointerDown:Rt(a),children:u.jsx(je.div,{...p,ref:v,style:{position:"absolute",...p.style},onPointerDown:me(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),g.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),N(j))}),onPointerMove:me(e.onPointerMove,N),onPointerUp:me(e.onPointerUp,j=>{const L=j.target;L.hasPointerCapture(j.pointerId)&&L.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=""),g.current=null})})})}),$s="ScrollAreaThumb",Cp=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=wp($s,e.__scopeScrollArea);return u.jsx(en,{present:n||o.hasThumb,children:u.jsx(tC,{ref:t,...r})})}),tC=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=on($s,n),i=wp($s,n),{onThumbPositionChange:a}=i,l=Ke(t,f=>i.onThumbChange(f)),c=y.useRef(void 0),d=Bs(()=>{c.current&&(c.current(),c.current=void 0)},100);return y.useEffect(()=>{const f=s.viewport;if(f){const p=()=>{if(d(),!c.current){const h=oC(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",p),()=>f.removeEventListener("scroll",p)}},[s.viewport,d,a]),u.jsx(je.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:me(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),x=f.clientX-h.left,m=f.clientY-h.top;i.onThumbPointerDown({x,y:m})}),onPointerUp:me(e.onPointerUp,i.onThumbPointerUp)})});Cp.displayName=$s;var La="ScrollAreaCorner",Tp=y.forwardRef((e,t)=>{const n=on(La,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(nC,{...e,ref:t}):null});Tp.displayName=La;var nC=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=on(La,n),[s,i]=y.useState(0),[a,l]=y.useState(0),c=!!(s&&a);return kr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),kr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(je.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 Fs(e){return e?parseInt(e,10):0}function kp(e,t){const n=e/t;return isNaN(n)?0:n}function zs(e){const t=kp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rC(e,t,n,r="ltr"){const o=zs(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 Ip([l,c],f)(e)}function Ep(e,t,n="ltr"){const r=zs(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=Pa(e,l);return Ip([0,i],[0,a])(c)}function Ip(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 Np(e,t){return e>0&&e<t}var oC=(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 Bs(e,t){const n=Rt(e),r=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),y.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function kr(e,t){const n=Rt(t);jt(()=>{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 Ap=xp,sC=vp,iC=Tp;const _p=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ap,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[u.jsx(sC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(jp,{}),u.jsx(iC,{})]}));_p.displayName=Ap.displayName;const jp=y.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ma,{ref:r,orientation:t,className:ee("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(Cp,{className:"relative flex-1 rounded-full bg-border"})}));jp.displayName=Ma.displayName;const Rp=25;function $a({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:x,actions:m}=jo(),{loadThread:v}=Ro(),{createThread:g,deleteThread:b,renameThread:S}=m,[k,T]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(k.length>0),E=w.useRef(null),N=w.useRef(0),[j,L]=w.useState(null),[_,M]=w.useState(""),[z,A]=w.useState(!1);w.useEffect(()=>{const X=Array.isArray(f)?f:[];if(X.length>0){C.current=!0,T(X);return}x||(C.current=!1,T(X))},[f,x]),w.useEffect(()=>{if(!E.current)return;const X=E.current.querySelector("[data-radix-scroll-area-viewport]");if(!X)return;let H=null,J=null;return H=requestAnimationFrame(()=>{J=requestAnimationFrame(()=>{X.scrollTop=N.current})}),()=>{H!==null&&cancelAnimationFrame(H),J!==null&&cancelAnimationFrame(J)}},[k]);const F=async X=>{try{h(X),await v(X),a==null||a(X),l==null||l(X)}catch(H){console.error("Failed to select thread:",H)}},R=async()=>{try{A(!0);const X=await g();X&&(c==null||c(X),a==null||a(X))}catch(X){console.error("Failed to create thread:",X)}finally{A(!1)}},G=async(X,H)=>{if(H.stopPropagation(),!!confirm("Delete this thread?")){if(E.current){const J=E.current.querySelector("[data-radix-scroll-area-viewport]");J&&(N.current=J.scrollTop)}try{await b(X),d==null||d(X)}catch(J){console.error("Failed to delete thread:",J)}}},B=(X,H)=>{H.stopPropagation(),L(X.threadId),M(X.title||`Thread ${X.threadId.slice(0,8)}`)},D=async X=>{if(_.trim())try{await S(X,_.trim()),L(null),M("")}catch(H){console.error("Failed to update title:",H)}},V=()=>{L(null),M("")},Y=(X,H)=>{X.key==="Enter"?D(H):X.key==="Escape"&&V()},he=X=>{if(!X)return"";try{const H=new Date(X),$=new Date().getTime()-H.getTime(),K=Math.floor($/(1e3*60*60*24));return K===0?H.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):K===1?"Yesterday":K<7?`${K} days ago`:H.toLocaleDateString()}catch{return""}},ie=X=>X.title||`Thread ${X.threadId.slice(0,8)}`,Ae=X=>{const H=ie(X);return H.length<=Rp?H:`${H.slice(0,Rp)}...`};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(tt,{onClick:R,disabled:z||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:u.jsx(ce.MessageSquarePlus,{size:20})})}),u.jsx(_p,{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:x?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ce.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(ce.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((X,H)=>new Date(H.updatedAt||H.createdAt||"").getTime()-new Date(X.updatedAt||X.createdAt||"").getTime()).map(X=>u.jsxs("div",{onClick:()=>F(X.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===X.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:j===X.threadId?u.jsxs("div",{className:"flex items-center gap-2",onClick:H=>H.stopPropagation(),children:[u.jsx(Ls,{value:_,onChange:H=>M(H.target.value),onKeyDown:H=>Y(H,X.threadId),className:"h-6 text-sm",autoFocus:!0}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>D(X.threadId),className:"h-6 w-6 p-0",children:u.jsx(ce.Check,{size:12})}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:u.jsx(ce.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:Ae(X)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ce.Calendar,{size:10}),u.jsx("span",{children:he(X.updatedAt||X.createdAt)})]})]})}),u.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&j!==X.threadId&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:H=>B(X,H),className:"h-6 w-6 p-0",title:"Edit title",children:u.jsx(ce.Edit3,{size:12})}),n&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:H=>G(X.threadId,H),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(ce.Trash2,{size:12})})]})]}),i===X.threadId&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},X.threadId))})})]})}function Er(e){if(!(typeof globalThis>"u"))return globalThis[e]}function aC(e){if(typeof e!="string")return;const t=e.trim();if(t)return kn(t)}function Pp(){const e=[Er("__API_BASE_URL__"),Er("__CHAT_API_BASE_URL__"),Er("__CHAT_API_URL__")];for(const t of e){const n=aC(t);if(n)return n}}function Op(){const e=[Er("__API_AUTH_TOKEN__"),Er("__CHAT_API_KEY__"),Er("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return kn(t);return kn()}function Dp(){const e={},t=Pp(),n=Op();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Lp(){const e=Dp(),t=jn.getAuthToken(),n=Pp();return{apiBaseUrl:Mp(e.baseUrl,jn.baseUrl,n),apiKey:t||e.apiKey||Op()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $p="chat-settings";function lC(){try{const e=localStorage.getItem($p);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function cC(e){try{const t={...e,apiBaseUrl:kn(e.apiBaseUrl)};localStorage.setItem($p,JSON.stringify(t)),t.apiKey&&jn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function uC(){const e=Lp(),t=lC(),n=jn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mp(jn.baseUrl,r,e.apiBaseUrl)}}function dC(e){jn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),cC(e)}var fC="Label",Fp=y.forwardRef((e,t)=>u.jsx(je.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())}}));Fp.displayName=fC;var zp=Fp;const pC=ho.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),sn=y.forwardRef(({className:e,...t},n)=>u.jsx(zp,{ref:n,className:ee(pC(),e),...t}));sn.displayName=zp.displayName;function Bp(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Hp=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"}),hC="VisuallyHidden",mC=y.forwardRef((e,t)=>u.jsx(je.span,{...e,ref:t,style:{...Hp,...e.style}}));mC.displayName=hC;var gC=[" ","Enter","ArrowUp","ArrowDown"],xC=[" ","Enter"],sr="Select",[Hs,Us,yC]=xi(sr),[Ir,LT]=En(sr,[yC,qo]),Ws=qo(),[vC,Bn]=Ir(sr),[bC,wC]=Ir(sr),Up=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:x}=e,m=Ws(t),[v,g]=y.useState(null),[b,S]=y.useState(null),[k,T]=y.useState(!1),C=Oo(c),[E,N]=pr({prop:r,defaultProp:o??!1,onChange:s,caller:sr}),[j,L]=pr({prop:i,defaultProp:a,onChange:l,caller:sr}),_=y.useRef(null),M=v?x||!!v.closest("form"):!0,[z,A]=y.useState(new Set),F=Array.from(z).map(R=>R.props.value).join(";");return u.jsx(su,{...m,children:u.jsxs(vC,{required:h,scope:t,trigger:v,onTriggerChange:g,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:T,contentId:In(),value:j,onValueChange:L,open:E,onOpenChange:N,dir:C,triggerPointerDownPosRef:_,disabled:p,children:[u.jsx(Hs.Provider,{scope:t,children:u.jsx(bC,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(R=>{A(G=>new Set(G).add(R))},[]),onNativeOptionRemove:y.useCallback(R=>{A(G=>{const B=new Set(G);return B.delete(R),B})},[]),children:n})}),M?u.jsxs(ph,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:R=>L(R.target.value),disabled:p,form:x,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(z)]},F):null]})})};Up.displayName=sr;var Wp="SelectTrigger",Vp=y.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ws(n),i=Bn(Wp,n),a=i.disabled||r,l=Ke(t,i.onTriggerChange),c=Us(n),d=y.useRef("touch"),[f,p,h]=mh(m=>{const v=c().filter(S=>!S.disabled),g=v.find(S=>S.value===i.value),b=gh(v,m,g);b!==void 0&&i.onValueChange(b.value)}),x=m=>{a||(i.onOpenChange(!0),h()),m&&(i.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return u.jsx(iu,{asChild:!0,...s,children:u.jsx(je.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":hh(i.value)?"":void 0,...o,ref:l,onClick:me(o.onClick,m=>{m.currentTarget.focus(),d.current!=="mouse"&&x(m)}),onPointerDown:me(o.onPointerDown,m=>{d.current=m.pointerType;const v=m.target;v.hasPointerCapture(m.pointerId)&&v.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(x(m),m.preventDefault())}),onKeyDown:me(o.onKeyDown,m=>{const v=f.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&p(m.key),!(v&&m.key===" ")&&gC.includes(m.key)&&(x(),m.preventDefault())})})})});Vp.displayName=Wp;var Kp="SelectValue",qp=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Bn(Kp,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Ke(t,l.onValueNodeChange);return jt(()=>{c(d)},[c,d]),u.jsx(je.span,{...a,ref:f,style:{pointerEvents:"none"},children:hh(l.value)?u.jsx(u.Fragment,{children:i}):s})});qp.displayName=Kp;var SC="SelectIcon",Gp=y.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Gp.displayName=SC;var CC="SelectPortal",Yp=e=>u.jsx(Go,{asChild:!0,...e});Yp.displayName=CC;var ir="SelectContent",Xp=y.forwardRef((e,t)=>{const n=Bn(ir,e.__scopeSelect),[r,o]=y.useState();if(jt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?mo.createPortal(u.jsx(Jp,{scope:e.__scopeSelect,children:u.jsx(Hs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Zp,{...e,ref:t})});Xp.displayName=ir;var pn=10,[Jp,Hn]=Ir(ir),TC="SelectContentImpl",kC=Vn.createSlot("SelectContent.RemoveScroll"),Zp=y.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:x,hideWhenDetached:m,avoidCollisions:v,...g}=e,b=Bn(ir,n),[S,k]=y.useState(null),[T,C]=y.useState(null),E=Ke(t,J=>k(J)),[N,j]=y.useState(null),[L,_]=y.useState(null),M=Us(n),[z,A]=y.useState(!1),F=y.useRef(!1);y.useEffect(()=>{if(S)return Fi(S)},[S]),bi();const R=y.useCallback(J=>{const[$,...K]=M().map(se=>se.ref.current),[re]=K.slice(-1),oe=document.activeElement;for(const se of J)if(se===oe||(se==null||se.scrollIntoView({block:"nearest"}),se===$&&T&&(T.scrollTop=0),se===re&&T&&(T.scrollTop=T.scrollHeight),se==null||se.focus(),document.activeElement!==oe))return},[M,T]),G=y.useCallback(()=>R([N,S]),[R,N,S]);y.useEffect(()=>{z&&G()},[z,G]);const{onOpenChange:B,triggerPointerDownPosRef:D}=b;y.useEffect(()=>{if(S){let J={x:0,y:0};const $=re=>{var oe,se;J={x:Math.abs(Math.round(re.pageX)-(((oe=D.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(re.pageY)-(((se=D.current)==null?void 0:se.y)??0))}},K=re=>{J.x<=10&&J.y<=10?re.preventDefault():S.contains(re.target)||B(!1),document.removeEventListener("pointermove",$),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",K,{capture:!0})}}},[S,B,D]),y.useEffect(()=>{const J=()=>B(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[B]);const[V,Y]=mh(J=>{const $=M().filter(oe=>!oe.disabled),K=$.find(oe=>oe.ref.current===document.activeElement),re=gh($,J,K);re&&setTimeout(()=>re.ref.current.focus())}),he=y.useCallback((J,$,K)=>{const re=!F.current&&!K;(b.value!==void 0&&b.value===$||re)&&(j(J),re&&(F.current=!0))},[b.value]),ie=y.useCallback(()=>S==null?void 0:S.focus(),[S]),Ae=y.useCallback((J,$,K)=>{const re=!F.current&&!K;(b.value!==void 0&&b.value===$||re)&&_(J)},[b.value]),X=r==="popper"?Fa:Qp,H=X===Fa?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:h,sticky:x,hideWhenDetached:m,avoidCollisions:v}:{};return u.jsx(Jp,{scope:n,content:S,viewport:T,onViewportChange:C,itemRefCallback:he,selectedItem:N,onItemLeave:ie,itemTextRefCallback:Ae,focusSelectedItem:G,selectedItemText:L,position:r,isPositioned:z,searchRef:V,children:u.jsx(rs,{as:kC,allowPinchZoom:!0,children:u.jsx(Do,{asChild:!0,trapped:b.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:me(o,J=>{var $;($=b.trigger)==null||$.focus({preventScroll:!0}),J.preventDefault()}),children:u.jsx(Mo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(X,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:J=>J.preventDefault(),...g,...H,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...g.style},onKeyDown:me(g.onKeyDown,J=>{const $=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!$&&J.key.length===1&&Y(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let re=M().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(J.key)&&(re=re.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const oe=J.target,se=re.indexOf(oe);re=re.slice(se+1)}setTimeout(()=>R(re)),J.preventDefault()}})})})})})})});Zp.displayName=TC;var EC="SelectItemAlignedPosition",Qp=y.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Bn(ir,n),i=Hn(ir,n),[a,l]=y.useState(null),[c,d]=y.useState(null),f=Ke(t,E=>d(E)),p=Us(n),h=y.useRef(!1),x=y.useRef(!0),{viewport:m,selectedItem:v,selectedItemText:g,focusSelectedItem:b}=i,S=y.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&m&&v&&g){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),L=g.getBoundingClientRect();if(s.dir!=="rtl"){const oe=L.left-N.left,se=j.left-oe,Te=E.left-se,Je=E.width+Te,De=Math.max(Je,N.width),Ye=window.innerWidth-pn,de=Pa(se,[pn,Math.max(pn,Ye-De)]);a.style.minWidth=Je+"px",a.style.left=de+"px"}else{const oe=N.right-L.right,se=window.innerWidth-j.right-oe,Te=window.innerWidth-E.right-se,Je=E.width+Te,De=Math.max(Je,N.width),Ye=window.innerWidth-pn,de=Pa(se,[pn,Math.max(pn,Ye-De)]);a.style.minWidth=Je+"px",a.style.right=de+"px"}const _=p(),M=window.innerHeight-pn*2,z=m.scrollHeight,A=window.getComputedStyle(c),F=parseInt(A.borderTopWidth,10),R=parseInt(A.paddingTop,10),G=parseInt(A.borderBottomWidth,10),B=parseInt(A.paddingBottom,10),D=F+R+z+B+G,V=Math.min(v.offsetHeight*5,D),Y=window.getComputedStyle(m),he=parseInt(Y.paddingTop,10),ie=parseInt(Y.paddingBottom,10),Ae=E.top+E.height/2-pn,X=M-Ae,H=v.offsetHeight/2,J=v.offsetTop+H,$=F+R+J,K=D-$;if($<=Ae){const oe=_.length>0&&v===_[_.length-1].ref.current;a.style.bottom="0px";const se=c.clientHeight-m.offsetTop-m.offsetHeight,Te=Math.max(X,H+(oe?ie:0)+se+G),Je=$+Te;a.style.height=Je+"px"}else{const oe=_.length>0&&v===_[0].ref.current;a.style.top="0px";const Te=Math.max(Ae,F+m.offsetTop+(oe?he:0)+H)+K;a.style.height=Te+"px",m.scrollTop=$-Ae+m.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=M+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[p,s.trigger,s.valueNode,a,c,m,v,g,s.dir,r]);jt(()=>S(),[S]);const[k,T]=y.useState();jt(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const C=y.useCallback(E=>{E&&x.current===!0&&(S(),b==null||b(),x.current=!1)},[S,b]);return u.jsx(NC,{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(je.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Qp.displayName=EC;var IC="SelectPopperPosition",Fa=y.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=Ws(n);return u.jsx(au,{...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)"}})});Fa.displayName=IC;var[NC,za]=Ir(ir,{}),Ba="SelectViewport",eh=y.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Hn(Ba,n),i=za(Ba,n),a=Ke(t,s.onViewportChange),l=y.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(Hs.Slot,{scope:n,children:u.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:me(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 x=window.innerHeight-pn*2,m=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),g=Math.max(m,v);if(g<x){const b=g+h,S=Math.min(x,b),k=b-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})})})]})});eh.displayName=Ba;var th="SelectGroup",[AC,_C]=Ir(th),jC=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=In();return u.jsx(AC,{scope:n,id:o,children:u.jsx(je.div,{role:"group","aria-labelledby":o,...r,ref:t})})});jC.displayName=th;var nh="SelectLabel",rh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_C(nh,n);return u.jsx(je.div,{id:o.id,...r,ref:t})});rh.displayName=nh;var Vs="SelectItem",[RC,oh]=Ir(Vs),sh=y.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Bn(Vs,n),l=Hn(Vs,n),c=a.value===r,[d,f]=y.useState(s??""),[p,h]=y.useState(!1),x=Ke(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),m=In(),v=y.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(RC,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:y.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(Hs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(je.div,{role:"option","aria-labelledby":m,"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:x,onFocus:me(i.onFocus,()=>h(!0)),onBlur:me(i.onBlur,()=>h(!1)),onClick:me(i.onClick,()=>{v.current!=="mouse"&&g()}),onPointerUp:me(i.onPointerUp,()=>{v.current==="mouse"&&g()}),onPointerDown:me(i.onPointerDown,b=>{v.current=b.pointerType}),onPointerMove:me(i.onPointerMove,b=>{var S;v.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):v.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:me(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:me(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(xC.includes(b.key)&&g(),b.key===" "&&b.preventDefault())})})})})});sh.displayName=Vs;var fo="SelectItemText",ih=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Bn(fo,n),a=Hn(fo,n),l=oh(fo,n),c=wC(fo,n),[d,f]=y.useState(null),p=Ke(t,g=>f(g),l.onItemTextChange,g=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,g,l.value,l.disabled)}),h=d==null?void 0:d.textContent,x=y.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:m,onNativeOptionRemove:v}=c;return jt(()=>(m(x),()=>v(x)),[m,v,x]),u.jsxs(u.Fragment,{children:[u.jsx(je.span,{id:l.textId,...s,ref:p}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?mo.createPortal(s.children,i.valueNode):null]})});ih.displayName=fo;var ah="SelectItemIndicator",lh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return oh(ah,n).isSelected?u.jsx(je.span,{"aria-hidden":!0,...r,ref:t}):null});lh.displayName=ah;var Ha="SelectScrollUpButton",ch=y.forwardRef((e,t)=>{const n=Hn(Ha,e.__scopeSelect),r=za(Ha,e.__scopeSelect),[o,s]=y.useState(!1),i=Ke(t,r.onScrollButtonChange);return jt(()=>{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(dh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});ch.displayName=Ha;var Ua="SelectScrollDownButton",uh=y.forwardRef((e,t)=>{const n=Hn(Ua,e.__scopeSelect),r=za(Ua,e.__scopeSelect),[o,s]=y.useState(!1),i=Ke(t,r.onScrollButtonChange);return jt(()=>{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(dh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});uh.displayName=Ua;var dh=y.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Hn("SelectScrollButton",n),i=y.useRef(null),a=Us(n),l=y.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return y.useEffect(()=>()=>l(),[l]),jt(()=>{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(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{l()})})}),PC="SelectSeparator",fh=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(je.div,{"aria-hidden":!0,...r,ref:t})});fh.displayName=PC;var Wa="SelectArrow",OC=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ws(n),s=Bn(Wa,n),i=Hn(Wa,n);return s.open&&i.position==="popper"?u.jsx(lu,{...o,...r,ref:t}):null});OC.displayName=Wa;var MC="SelectBubbleInput",ph=y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=y.useRef(null),s=Ke(r,o),i=Bp(t);return y.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(je.select,{...n,style:{...Hp,...n.style},ref:s,defaultValue:t})});ph.displayName=MC;function hh(e){return e===""||e===void 0}function mh(e){const t=Rt(e),n=y.useRef(""),r=y.useRef(0),o=y.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=y.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function gh(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=DC(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 DC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var LC=Up,xh=Vp,$C=qp,FC=Gp,zC=Yp,yh=Xp,BC=eh,vh=rh,bh=sh,HC=ih,UC=lh,wh=ch,Sh=uh,Ch=fh;const Th=LC,kh=$C,Va=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(xh,{ref:r,className:ee("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(FC,{asChild:!0,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Va.displayName=xh.displayName;const Eh=y.forwardRef(({className:e,...t},n)=>u.jsx(wh,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));Eh.displayName=wh.displayName;const Ih=y.forwardRef(({className:e,...t},n)=>u.jsx(Sh,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronDown,{className:"h-4 w-4"})}));Ih.displayName=Sh.displayName;const Ka=y.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(zC,{children:u.jsxs(yh,{ref:o,className:ee("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(Eh,{}),u.jsx(BC,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Ih,{})]})}));Ka.displayName=yh.displayName;const WC=y.forwardRef(({className:e,...t},n)=>u.jsx(vh,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));WC.displayName=vh.displayName;const ar=y.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(bh,{ref:r,className:ee("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(UC,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),u.jsx(HC,{children:t})]}));ar.displayName=bh.displayName;const VC=y.forwardRef(({className:e,...t},n)=>u.jsx(Ch,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));VC.displayName=Ch.displayName;var KC="Separator",Nh="horizontal",qC=["horizontal","vertical"],Ah=y.forwardRef((e,t)=>{const{decorative:n,orientation:r=Nh,...o}=e,s=GC(r)?r:Nh,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(je.div,{"data-orientation":s,...a,...o,ref:t})});Ah.displayName=KC;function GC(e){return qC.includes(e)}var _h=Ah;const jh=y.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(_h,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));jh.displayName=_h.displayName;const YC=Vf,XC=fS,JC=Kf,Rh=y.forwardRef(({className:e,...t},n)=>u.jsx(Ns,{className:ee("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}));Rh.displayName=Ns.displayName;const ZC=ho.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"}}),Ph=y.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(JC,{children:[u.jsx(Rh,{}),u.jsxs(As,{ref:o,className:ee(ZC({side:e}),t),...r,children:[n,u.jsxs(qf,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ph.displayName=As.displayName;const Oh=({className:e,...t})=>u.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});Oh.displayName="SheetHeader";const Mh=y.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));Mh.displayName=rr.displayName;const Dh=y.forwardRef(({className:e,...t},n)=>u.jsx(_s,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Dh.displayName=_s.displayName;var Ks="Switch",[QC,$T]=En(Ks),[eT,tT]=QC(Ks),Lh=y.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]=y.useState(null),x=Ke(t,S=>h(S)),m=y.useRef(!1),v=p?d||!!p.closest("form"):!0,[g,b]=pr({prop:o,defaultProp:s??!1,onChange:c,caller:Ks});return u.jsxs(eT,{scope:n,checked:g,disabled:a,children:[u.jsx(je.button,{type:"button",role:"switch","aria-checked":g,"aria-required":i,"data-state":Bh(g),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:x,onClick:me(e.onClick,S=>{b(k=>!k),v&&(m.current=S.isPropagationStopped(),m.current||S.stopPropagation())})}),v&&u.jsx(zh,{control:p,bubbles:!m.current,name:r,value:l,checked:g,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Lh.displayName=Ks;var $h="SwitchThumb",Fh=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=tT($h,n);return u.jsx(je.span,{"data-state":Bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Fh.displayName=$h;var nT="SwitchBubbleInput",zh=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=y.useRef(null),a=Ke(i,s),l=Bp(n),c=Yc(t);return y.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const x=new Event("click",{bubbles:r});h.call(d,n),d.dispatchEvent(x)}},[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}})});zh.displayName=nT;function Bh(e){return e?"checked":"unchecked"}var Hh=Lh,rT=Fh;const Un=y.forwardRef(({className:e,...t},n)=>u.jsx(Hh,{className:ee("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(rT,{className:ee("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=Hh.displayName;const oT={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 sT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[c,d]=w.useState(!1),{toast:f}=Ta();w.useEffect(()=>{const v=JSON.stringify(a)!==JSON.stringify(e);d(v)},[a,e]),w.useEffect(()=>{l(e)},[e]);const p=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},h=()=>{l(oT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},x=()=>{l(e),d(!1),o(!1)},m=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(YC,{open:r,onOpenChange:o,children:[u.jsx(XC,{asChild:!0,children:u.jsxs(tt,{variant:"outline",size:"sm",className:n,children:[u.jsx(ce.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&u.jsx(Sf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),u.jsxs(Ph,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[u.jsxs(Oh,{children:[u.jsx(Mh,{children:"Chat Settings"}),u.jsx(Dh,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),u.jsxs("div",{className:"space-y-6 py-6",children:[u.jsxs(ro,{children:[u.jsx(oo,{className:"pb-3",children:u.jsxs(so,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.Server,{className:"h-5 w-5"}),"API Configuration"]})}),u.jsxs(io,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"api-url",children:"API Base URL"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ls,{id:"api-url",value:a.api.baseUrl,onChange:v=>l(g=>({...g,api:{...g.api,baseUrl:v.target.value}})),placeholder:"http://localhost:8000/api"}),u.jsx(tt,{variant:"outline",onClick:m,children:"Test"})]})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"enable-auth",children:"Enable Authentication"}),u.jsx(Un,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:v=>l(g=>({...g,api:{...g.api,enableAuth:v}}))})]}),a.api.enableAuth&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"auth-token",children:"Authentication Token"}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(Ls,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:v=>l(g=>({...g,api:{...g.api,authToken:v.target.value}})),placeholder:"Enter your Bearer token"}),u.jsx(tt,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?u.jsx(ce.EyeOff,{className:"h-4 w-4"}):u.jsx(ce.Eye,{className:"h-4 w-4"})})]})]})]})]}),u.jsxs(ro,{children:[u.jsx(oo,{className:"pb-3",children:u.jsxs(so,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),u.jsxs(io,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"layout",children:"Layout Style"}),u.jsxs(Th,{value:a.ui.layout,onValueChange:v=>l(g=>({...g,ui:{...g.ui,layout:v}})),children:[u.jsx(Va,{children:u.jsx(kh,{})}),u.jsxs(Ka,{children:[u.jsx(ar,{value:"sidebar",children:"Sidebar Layout"}),u.jsx(ar,{value:"fullscreen",children:"Fullscreen"}),u.jsx(ar,{value:"tabs",children:"Tabbed Interface"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(sn,{htmlFor:"theme",children:"Theme"}),u.jsxs(Th,{value:a.ui.theme,onValueChange:v=>l(g=>({...g,ui:{...g.ui,theme:v}})),children:[u.jsx(Va,{children:u.jsx(kh,{})}),u.jsxs(Ka,{children:[u.jsx(ar,{value:"light",children:"Light"}),u.jsx(ar,{value:"dark",children:"Dark"}),u.jsx(ar,{value:"system",children:"System"})]})]})]}),u.jsx(jh,{}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),u.jsx(Un,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,showTimestamps:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),u.jsx(Un,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,showAgentNames:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(sn,{htmlFor:"compact-messages",children:"Compact Messages"}),u.jsx(Un,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:v=>l(g=>({...g,ui:{...g.ui,compactMessages:v}}))})]})]})]})]}),u.jsxs(ro,{children:[u.jsx(oo,{className:"pb-3",children:u.jsxs(so,{className:"text-lg flex items-center gap-2",children:[u.jsx(ce.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),u.jsxs(io,{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{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:v=>l(g=>({...g,behavior:{...g.behavior,autoSave:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{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:v=>l(g=>({...g,behavior:{...g.behavior,enableStreaming:v}}))})]}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx(sn,{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:v=>l(g=>({...g,behavior:{...g.behavior,showTypingIndicator:v}}))})]})]})]})]}),u.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[u.jsxs(tt,{variant:"outline",onClick:h,children:[u.jsx(ce.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx(tt,{variant:"outline",onClick:x,children:"Cancel"}),u.jsxs(tt,{onClick:p,disabled:!c,children:[u.jsx(ce.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function iT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Po,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Ds,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Po,{...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($a,{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(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Po,{...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($a,{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(Ds,{onError:s.onError,enableFileUpload:!0})})]})})}Ie.ChatApi=Wl,Ie.ChatInput=pc,Ie.ChatInterface=Ds,Ie.ChatProviders=Po,Ie.ChatSettings=sT,Ie.MarkdownContent=uo,Ie.MessageComponent=ja,Ie.MessageList=Ra,Ie.ThreadManager=$a,Ie.applySettings=dC,Ie.buildMessagePreviewMap=Jl,Ie.chatApiClient=jn,Ie.default=iT,Ie.del=Ul,Ie.get=Zt,Ie.getChatToken=zl,Ie.getCurrentSettings=uC,Ie.getDefaultApiConfig=Dp,Ie.getDefaultChatSettings=Lp,Ie.onChatTokenChanged=Bl,Ie.post=ci,Ie.put=Hl,Ie.setChatToken=Io,Ie.useApi=ui,Ie.useChatStream=Zl,Ie.useMessagesReducer=Ql,Ie.useStream=dc,Ie.useThreadState=Ro,Ie.useThreads=jo,Object.defineProperties(Ie,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});