teodor-new-chat-ui 4.3.5 → 4.3.6

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(Re,y){typeof exports=="object"&&typeof module<"u"?y(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"],y):(Re=typeof globalThis<"u"?globalThis:Re||self,y(Re.NewChatUI={},Re.React,Re.LucideReact,Re.reactSlot,Re.classVarianceAuthority,Re.clsx,Re.tailwindMerge,Re.ReactDOM))})(this,function(Re,y,ie,rr,ko,mm,gm,ai){"use strict";var wT=Object.defineProperty;var yT=(Re,y,ie)=>y in Re?wT(Re,y,{enumerable:!0,configurable:!0,writable:!0,value:ie}):Re[y]=ie;var hm=(Re,y,ie)=>yT(Re,typeof y!="symbol"?y+"":y,ie);function xl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=xl(y),Io=xl(ai);var li={exports:{}},Wr={};/**
1
+ (function(je,y){typeof exports=="object"&&typeof module<"u"?y(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"],y):(je=typeof globalThis<"u"?globalThis:je||self,y(je.NewChatUI={},je.React,je.LucideReact,je.reactSlot,je.classVarianceAuthority,je.clsx,je.tailwindMerge,je.ReactDOM))})(this,function(je,y,ae,nr,Io,xm,vm,ai){"use strict";var Ck=Object.defineProperty;var kk=(je,y,ae)=>y in je?Ck(je,y,{enumerable:!0,configurable:!0,writable:!0,value:ae}):je[y]=ae;var mm=(je,y,ae)=>kk(je,typeof y!="symbol"?y+"":y,ae);function vl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=vl(y),Eo=vl(ai);var li={exports:{}},Vr={};/**
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 vl;function xm(){if(vl)return Wr;vl=1;var e=y,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,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Wr.Fragment=n,Wr.jsx=i,Wr.jsxs=i,Wr}var Vr={};/**
9
+ */var bl;function bm(){if(bl)return Vr;bl=1;var e=y,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,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Vr.Fragment=n,Vr.jsx=i,Vr.jsxs=i,Vr}var Kr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,42 +14,42 @@
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 bl;function vm(){return bl||(bl=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),b=Symbol.iterator,x="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var H=b&&I[b]||I[x];return typeof H=="function"?H:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var H=arguments.length,ne=new Array(H>1?H-1:0),Ee=1;Ee<H;Ee++)ne[Ee-1]=arguments[Ee];S("error",I,ne)}}function S(I,H,ne){{var Ee=v.ReactDebugCurrentFrame,_e=Ee.getStackAddendum();_e!==""&&(H+="%s",ne=ne.concat([_e]));var Xe=ne.map(function(qe){return String(qe)});Xe.unshift("Warning: "+H),Function.prototype.apply.call(console[I],console,Xe)}}var N=!1,T=!1,k=!1,E=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===p||N||T||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===j||I.getModuleId!==void 0))}function L(I,H,ne){var Ee=I.displayName;if(Ee)return Ee;var _e=H.displayName||H.name||"";return _e!==""?ne+"("+_e+")":ne}function $(I){return I.displayName||"Context"}function V(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var H=I;return $(H)+".Consumer";case i:var ne=I;return $(ne._context)+".Provider";case l:return L(I,I.render,"ForwardRef");case f:var Ee=I.displayName||null;return Ee!==null?Ee:V(I.type)||"Memo";case h:{var _e=I,Xe=_e._payload,qe=_e._init;try{return V(qe(Xe))}catch{return null}}}return null}var M=Object.assign,G=0,K,W,B,F,ue,D,Q;function fe(){}fe.__reactDisabledLog=!0;function we(){{if(G===0){K=console.log,W=console.info,B=console.warn,F=console.error,ue=console.group,D=console.groupCollapsed,Q=console.groupEnd;var I={configurable:!0,enumerable:!0,value:fe,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}G++}}function ye(){{if(G--,G===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},I,{value:K}),info:M({},I,{value:W}),warn:M({},I,{value:B}),error:M({},I,{value:F}),group:M({},I,{value:ue}),groupCollapsed:M({},I,{value:D}),groupEnd:M({},I,{value:Q})})}G<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=v.ReactCurrentDispatcher,q;function O(I,H,ne){{if(q===void 0)try{throw Error()}catch(_e){var Ee=_e.stack.trim().match(/\n( *(at )?)/);q=Ee&&Ee[1]||""}return`
18
- `+q+I}}var X=!1,ee;{var pe=typeof WeakMap=="function"?WeakMap:Map;ee=new pe}function oe(I,H){if(!I||X)return"";{var ne=ee.get(I);if(ne!==void 0)return ne}var Ee;X=!0;var _e=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Xe;Xe=Se.current,Se.current=null,we();try{if(H){var qe=function(){throw Error()};if(Object.defineProperty(qe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(qe,[])}catch(Rt){Ee=Rt}Reflect.construct(I,[],qe)}else{try{qe.call()}catch(Rt){Ee=Rt}I.call(qe.prototype)}}else{try{throw Error()}catch(Rt){Ee=Rt}I()}}catch(Rt){if(Rt&&Ee&&typeof Rt.stack=="string"){for(var He=Rt.stack.split(`
19
- `),Tt=Ee.stack.split(`
20
- `),ft=He.length-1,pt=Tt.length-1;ft>=1&&pt>=0&&He[ft]!==Tt[pt];)pt--;for(;ft>=1&&pt>=0;ft--,pt--)if(He[ft]!==Tt[pt]){if(ft!==1||pt!==1)do if(ft--,pt--,pt<0||He[ft]!==Tt[pt]){var Lt=`
21
- `+He[ft].replace(" at new "," at ");return I.displayName&&Lt.includes("<anonymous>")&&(Lt=Lt.replace("<anonymous>",I.displayName)),typeof I=="function"&&ee.set(I,Lt),Lt}while(ft>=1&&pt>=0);break}}}finally{X=!1,Se.current=Xe,ye(),Error.prepareStackTrace=_e}var fn=I?I.displayName||I.name:"",jn=fn?O(fn):"";return typeof I=="function"&&ee.set(I,jn),jn}function me(I,H,ne){return oe(I,!1)}function et(I){var H=I.prototype;return!!(H&&H.isReactComponent)}function tt(I,H,ne){if(I==null)return"";if(typeof I=="function")return oe(I,et(I));if(typeof I=="string")return O(I);switch(I){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return me(I.render);case f:return tt(I.type,H,ne);case h:{var Ee=I,_e=Ee._payload,Xe=Ee._init;try{return tt(Xe(_e),H,ne)}catch{}}}return""}var Oe=Object.prototype.hasOwnProperty,We={},ut=v.ReactDebugCurrentFrame;function rt(I){if(I){var H=I._owner,ne=tt(I.type,I._source,H?H.type:null);ut.setExtraStackFrame(ne)}else ut.setExtraStackFrame(null)}function Ve(I,H,ne,Ee,_e){{var Xe=Function.call.bind(Oe);for(var qe in I)if(Xe(I,qe)){var He=void 0;try{if(typeof I[qe]!="function"){var Tt=Error((Ee||"React class")+": "+ne+" type `"+qe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[qe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Tt.name="Invariant Violation",Tt}He=I[qe](H,qe,Ee,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ft){He=ft}He&&!(He instanceof Error)&&(rt(_e),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",ne,qe,typeof He),rt(null)),He instanceof Error&&!(He.message in We)&&(We[He.message]=!0,rt(_e),w("Failed %s type: %s",ne,He.message),rt(null))}}}var xt=Array.isArray;function J(I){return xt(I)}function se(I){{var H=typeof Symbol=="function"&&Symbol.toStringTag,ne=H&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ne}}function ge(I){try{return Ce(I),!1}catch{return!0}}function Ce(I){return""+I}function xe(I){if(ge(I))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",se(I)),Ce(I)}var Me=v.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0},De,it;function vt(I){if(Oe.call(I,"ref")){var H=Object.getOwnPropertyDescriptor(I,"ref").get;if(H&&H.isReactWarning)return!1}return I.ref!==void 0}function _t(I){if(Oe.call(I,"key")){var H=Object.getOwnPropertyDescriptor(I,"key").get;if(H&&H.isReactWarning)return!1}return I.key!==void 0}function jt(I,H){typeof I.ref=="string"&&Me.current}function dn(I,H){{var ne=function(){De||(De=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};ne.isReactWarning=!0,Object.defineProperty(I,"key",{get:ne,configurable:!0})}}function In(I,H){{var ne=function(){it||(it=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};ne.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ne,configurable:!0})}}var Hr=function(I,H,ne,Ee,_e,Xe,qe){var He={$$typeof:t,type:I,key:H,ref:ne,props:qe,_owner:Xe};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:Ee}),Object.defineProperty(He,"_source",{configurable:!1,enumerable:!1,writable:!1,value:_e}),Object.freeze&&(Object.freeze(He.props),Object.freeze(He)),He};function oi(I,H,ne,Ee,_e){{var Xe,qe={},He=null,Tt=null;ne!==void 0&&(xe(ne),He=""+ne),_t(H)&&(xe(H.key),He=""+H.key),vt(H)&&(Tt=H.ref,jt(H,_e));for(Xe in H)Oe.call(H,Xe)&&!at.hasOwnProperty(Xe)&&(qe[Xe]=H[Xe]);if(I&&I.defaultProps){var ft=I.defaultProps;for(Xe in ft)qe[Xe]===void 0&&(qe[Xe]=ft[Xe])}if(He||Tt){var pt=typeof I=="function"?I.displayName||I.name||"Unknown":I;He&&dn(qe,pt),Tt&&In(qe,pt)}return Hr(I,He,Tt,_e,Ee,Me.current,qe)}}var Sr=v.ReactCurrentOwner,Zn=v.ReactDebugCurrentFrame;function bt(I){if(I){var H=I._owner,ne=tt(I.type,I._source,H?H.type:null);Zn.setExtraStackFrame(ne)}else Zn.setExtraStackFrame(null)}var Dn;Dn=!1;function Ln(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function St(){{if(Sr.current){var I=V(Sr.current.type);if(I)return`
17
+ */var wl;function wm(){return wl||(wl=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),b=Symbol.iterator,x="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var H=b&&I[b]||I[x];return typeof H=="function"?H:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var H=arguments.length,re=new Array(H>1?H-1:0),Ee=1;Ee<H;Ee++)re[Ee-1]=arguments[Ee];S("error",I,re)}}function S(I,H,re){{var Ee=v.ReactDebugCurrentFrame,Be=Ee.getStackAddendum();Be!==""&&(H+="%s",re=re.concat([Be]));var Xe=re.map(function(De){return String(De)});Xe.unshift("Warning: "+H),Function.prototype.apply.call(console[I],console,Xe)}}var N=!1,k=!1,T=!1,E=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===p||N||k||T||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===j||I.getModuleId!==void 0))}function L(I,H,re){var Ee=I.displayName;if(Ee)return Ee;var Be=H.displayName||H.name||"";return Be!==""?re+"("+Be+")":re}function $(I){return I.displayName||"Context"}function V(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var H=I;return $(H)+".Consumer";case i:var re=I;return $(re._context)+".Provider";case l:return L(I,I.render,"ForwardRef");case f:var Ee=I.displayName||null;return Ee!==null?Ee:V(I.type)||"Memo";case h:{var Be=I,Xe=Be._payload,De=Be._init;try{return V(De(Xe))}catch{return null}}}return null}var M=Object.assign,G=0,K,W,z,B,ue,D,te;function he(){}he.__reactDisabledLog=!0;function we(){{if(G===0){K=console.log,W=console.info,z=console.warn,B=console.error,ue=console.group,D=console.groupCollapsed,te=console.groupEnd;var I={configurable:!0,enumerable:!0,value:he,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}G++}}function ye(){{if(G--,G===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},I,{value:K}),info:M({},I,{value:W}),warn:M({},I,{value:z}),error:M({},I,{value:B}),group:M({},I,{value:ue}),groupCollapsed:M({},I,{value:D}),groupEnd:M({},I,{value:te})})}G<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=v.ReactCurrentDispatcher,q;function O(I,H,re){{if(q===void 0)try{throw Error()}catch(Be){var Ee=Be.stack.trim().match(/\n( *(at )?)/);q=Ee&&Ee[1]||""}return`
18
+ `+q+I}}var X=!1,ne;{var pe=typeof WeakMap=="function"?WeakMap:Map;ne=new pe}function se(I,H){if(!I||X)return"";{var re=ne.get(I);if(re!==void 0)return re}var Ee;X=!0;var Be=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Xe;Xe=Se.current,Se.current=null,we();try{if(H){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(St){Ee=St}Reflect.construct(I,[],De)}else{try{De.call()}catch(St){Ee=St}I.call(De.prototype)}}else{try{throw Error()}catch(St){Ee=St}I()}}catch(St){if(St&&Ee&&typeof St.stack=="string"){for(var Ue=St.stack.split(`
19
+ `),kt=Ee.stack.split(`
20
+ `),ht=Ue.length-1,mt=kt.length-1;ht>=1&&mt>=0&&Ue[ht]!==kt[mt];)mt--;for(;ht>=1&&mt>=0;ht--,mt--)if(Ue[ht]!==kt[mt]){if(ht!==1||mt!==1)do if(ht--,mt--,mt<0||Ue[ht]!==kt[mt]){var Dt=`
21
+ `+Ue[ht].replace(" at new "," at ");return I.displayName&&Dt.includes("<anonymous>")&&(Dt=Dt.replace("<anonymous>",I.displayName)),typeof I=="function"&&ne.set(I,Dt),Dt}while(ht>=1&&mt>=0);break}}}finally{X=!1,Se.current=Xe,ye(),Error.prepareStackTrace=Be}var $n=I?I.displayName||I.name:"",Pn=$n?O($n):"";return typeof I=="function"&&ne.set(I,Pn),Pn}function me(I,H,re){return se(I,!1)}function et(I){var H=I.prototype;return!!(H&&H.isReactComponent)}function tt(I,H,re){if(I==null)return"";if(typeof I=="function")return se(I,et(I));if(typeof I=="string")return O(I);switch(I){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return me(I.render);case f:return tt(I.type,H,re);case h:{var Ee=I,Be=Ee._payload,Xe=Ee._init;try{return tt(Xe(Be),H,re)}catch{}}}return""}var Pe=Object.prototype.hasOwnProperty,Ve={},ut=v.ReactDebugCurrentFrame;function nt(I){if(I){var H=I._owner,re=tt(I.type,I._source,H?H.type:null);ut.setExtraStackFrame(re)}else ut.setExtraStackFrame(null)}function Ke(I,H,re,Ee,Be){{var Xe=Function.call.bind(Pe);for(var De in I)if(Xe(I,De)){var Ue=void 0;try{if(typeof I[De]!="function"){var kt=Error((Ee||"React class")+": "+re+" type `"+De+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[De]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw kt.name="Invariant Violation",kt}Ue=I[De](H,De,Ee,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ht){Ue=ht}Ue&&!(Ue instanceof Error)&&(nt(Be),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",re,De,typeof Ue),nt(null)),Ue instanceof Error&&!(Ue.message in Ve)&&(Ve[Ue.message]=!0,nt(Be),w("Failed %s type: %s",re,Ue.message),nt(null))}}}var vt=Array.isArray;function Q(I){return vt(I)}function ie(I){{var H=typeof Symbol=="function"&&Symbol.toStringTag,re=H&&I[Symbol.toStringTag]||I.constructor.name||"Object";return re}}function xe(I){try{return Ce(I),!1}catch{return!0}}function Ce(I){return""+I}function ve(I){if(xe(I))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ie(I)),Ce(I)}var Oe=v.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0},Me,st;function ft(I){if(Pe.call(I,"ref")){var H=Object.getOwnPropertyDescriptor(I,"ref").get;if(H&&H.isReactWarning)return!1}return I.ref!==void 0}function It(I){if(Pe.call(I,"key")){var H=Object.getOwnPropertyDescriptor(I,"key").get;if(H&&H.isReactWarning)return!1}return I.key!==void 0}function Nn(I,H){typeof I.ref=="string"&&Oe.current}function dn(I,H){{var re=function(){Me||(Me=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};re.isReactWarning=!0,Object.defineProperty(I,"key",{get:re,configurable:!0})}}function Zt(I,H){{var re=function(){st||(st=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};re.isReactWarning=!0,Object.defineProperty(I,"ref",{get:re,configurable:!0})}}var An=function(I,H,re,Ee,Be,Xe,De){var Ue={$$typeof:t,type:I,key:H,ref:re,props:De,_owner:Xe};return Ue._store={},Object.defineProperty(Ue._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ue,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty(Ue,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Be}),Object.freeze&&(Object.freeze(Ue.props),Object.freeze(Ue)),Ue};function _n(I,H,re,Ee,Be){{var Xe,De={},Ue=null,kt=null;re!==void 0&&(ve(re),Ue=""+re),It(H)&&(ve(H.key),Ue=""+H.key),ft(H)&&(kt=H.ref,Nn(H,Be));for(Xe in H)Pe.call(H,Xe)&&!at.hasOwnProperty(Xe)&&(De[Xe]=H[Xe]);if(I&&I.defaultProps){var ht=I.defaultProps;for(Xe in ht)De[Xe]===void 0&&(De[Xe]=ht[Xe])}if(Ue||kt){var mt=typeof I=="function"?I.displayName||I.name||"Unknown":I;Ue&&dn(De,mt),kt&&Zt(De,mt)}return An(I,Ue,kt,Be,Ee,Oe.current,De)}}var Qn=v.ReactCurrentOwner,To=v.ReactDebugCurrentFrame;function fn(I){if(I){var H=I._owner,re=tt(I.type,I._source,H?H.type:null);To.setExtraStackFrame(re)}else To.setExtraStackFrame(null)}var hn;hn=!1;function Et(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function Ur(){{if(Qn.current){var I=V(Qn.current.type);if(I)return`
22
22
 
23
- Check the render method of \``+I+"`."}return""}}function En(I){return""}var Nn={};function Ur(I){{var H=St();if(!H){var ne=typeof I=="string"?I:I.displayName||I.name;ne&&(H=`
23
+ Check the render method of \``+I+"`."}return""}}function yr(I){return""}var yt={};function jn(I){{var H=Ur();if(!H){var re=typeof I=="string"?I:I.displayName||I.name;re&&(H=`
24
24
 
25
- Check the top-level render call using <`+ne+">.")}return H}}function qt(I,H){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ne=Ur(H);if(Nn[ne])return;Nn[ne]=!0;var Ee="";I&&I._owner&&I._owner!==Sr.current&&(Ee=" It was passed a child from "+V(I._owner.type)+"."),bt(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,Ee),bt(null)}}function Qn(I,H){{if(typeof I!="object")return;if(J(I))for(var ne=0;ne<I.length;ne++){var Ee=I[ne];Ln(Ee)&&qt(Ee,H)}else if(Ln(I))I._store&&(I._store.validated=!0);else if(I){var _e=g(I);if(typeof _e=="function"&&_e!==I.entries)for(var Xe=_e.call(I),qe;!(qe=Xe.next()).done;)Ln(qe.value)&&qt(qe.value,H)}}}function An(I){{var H=I.type;if(H==null||typeof H=="string")return;var ne;if(typeof H=="function")ne=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))ne=H.propTypes;else return;if(ne){var Ee=V(H);Ve(ne,I.props,"prop",Ee,I)}else if(H.PropTypes!==void 0&&!Dn){Dn=!0;var _e=V(H);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",_e||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _n(I){{for(var H=Object.keys(I.props),ne=0;ne<H.length;ne++){var Ee=H[ne];if(Ee!=="children"&&Ee!=="key"){bt(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),bt(null);break}}I.ref!==null&&(bt(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),bt(null))}}var er={};function le(I,H,ne,Ee,_e,Xe){{var qe=P(I);if(!qe){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 Tt=En();Tt?He+=Tt:He+=St();var ft;I===null?ft="null":J(I)?ft="array":I!==void 0&&I.$$typeof===t?(ft="<"+(V(I.type)||"Unknown")+" />",He=" Did you accidentally export a JSX literal instead of a component?"):ft=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ft,He)}var pt=oi(I,H,ne,_e,Xe);if(pt==null)return pt;if(qe){var Lt=H.children;if(Lt!==void 0)if(Ee)if(J(Lt)){for(var fn=0;fn<Lt.length;fn++)Qn(Lt[fn],I);Object.freeze&&Object.freeze(Lt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Qn(Lt,I)}if(Oe.call(H,"key")){var jn=V(I),Rt=Object.keys(H).filter(function(C){return C!=="key"}),To=Rt.length>0?"{key: someKey, "+Rt.join(": ..., ")+": ...}":"{key: someKey}";if(!er[jn+To]){var gl=Rt.length>0?"{"+Rt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+re+">.")}return H}}function Rn(I,H){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var re=jn(H);if(yt[re])return;yt[re]=!0;var Ee="";I&&I._owner&&I._owner!==Qn.current&&(Ee=" It was passed a child from "+V(I._owner.type)+"."),fn(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,Ee),fn(null)}}function Sr(I,H){{if(typeof I!="object")return;if(Q(I))for(var re=0;re<I.length;re++){var Ee=I[re];Et(Ee)&&Rn(Ee,H)}else if(Et(I))I._store&&(I._store.validated=!0);else if(I){var Be=g(I);if(typeof Be=="function"&&Be!==I.entries)for(var Xe=Be.call(I),De;!(De=Xe.next()).done;)Et(De.value)&&Rn(De.value,H)}}}function Qt(I){{var H=I.type;if(H==null||typeof H=="string")return;var re;if(typeof H=="function")re=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))re=H.propTypes;else return;if(re){var Ee=V(H);Ke(re,I.props,"prop",Ee,I)}else if(H.PropTypes!==void 0&&!hn){hn=!0;var Be=V(H);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Be||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Cr(I){{for(var H=Object.keys(I.props),re=0;re<H.length;re++){var Ee=H[re];if(Ee!=="children"&&Ee!=="key"){fn(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),fn(null);break}}I.ref!==null&&(fn(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),fn(null))}}var pn={};function oe(I,H,re,Ee,Be,Xe){{var De=P(I);if(!De){var Ue="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Ue+=" 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 kt=yr();kt?Ue+=kt:Ue+=Ur();var ht;I===null?ht="null":Q(I)?ht="array":I!==void 0&&I.$$typeof===t?(ht="<"+(V(I.type)||"Unknown")+" />",Ue=" Did you accidentally export a JSX literal instead of a component?"):ht=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ht,Ue)}var mt=_n(I,H,re,Be,Xe);if(mt==null)return mt;if(De){var Dt=H.children;if(Dt!==void 0)if(Ee)if(Q(Dt)){for(var $n=0;$n<Dt.length;$n++)Sr(Dt[$n],I);Object.freeze&&Object.freeze(Dt)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Sr(Dt,I)}if(Pe.call(H,"key")){var Pn=V(I),St=Object.keys(H).filter(function(xl){return xl!=="key"}),Wr=St.length>0?"{key: someKey, "+St.join(": ..., ")+": ...}":"{key: someKey}";if(!pn[Pn+Wr]){var gl=St.length>0?"{"+St.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,To,jn,gl,jn),er[jn+To]=!0}}return I===r?_n(pt):An(pt),pt}}function Ie(I,H,ne){return le(I,H,ne,!0)}function Ke(I,H,ne){return le(I,H,ne,!1)}var nt=Ke,Dt=Ie;Vr.Fragment=r,Vr.jsx=nt,Vr.jsxs=Dt}()),Vr}process.env.NODE_ENV==="production"?li.exports=xm():li.exports=vm();var c=li.exports;function wl(e,t){return function(){return e.apply(t,arguments)}}const{toString:bm}=Object.prototype,{getPrototypeOf:ci}=Object,{iterator:Eo,toStringTag:yl}=Symbol,No=(e=>t=>{const n=bm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),tn=e=>(e=e.toLowerCase(),t=>No(t)===e),Ao=e=>t=>typeof t===e,{isArray:Tr}=Array,kr=Ao("undefined");function Kr(e){return e!==null&&!kr(e)&&e.constructor!==null&&!kr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Sl=tn("ArrayBuffer");function wm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Sl(e.buffer),t}const ym=Ao("string"),$t=Ao("function"),Cl=Ao("number"),qr=e=>e!==null&&typeof e=="object",Sm=e=>e===!0||e===!1,_o=e=>{if(No(e)!=="object")return!1;const t=ci(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(yl in e)&&!(Eo in e)},Cm=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tm=tn("Date"),km=tn("File"),Im=tn("Blob"),Em=tn("FileList"),Nm=e=>qr(e)&&$t(e.pipe),Am=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=No(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},_m=tn("URLSearchParams"),[jm,Rm,Pm,Om]=["ReadableStream","Request","Response","Headers"].map(tn),Mm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Tr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Kr(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 Tl(e,t){if(Kr(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 or=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,kl=e=>!kr(e)&&e!==or;function ui(){const{caseless:e,skipUndefined:t}=kl(this)&&this||{},n={},r=(o,s)=>{const i=e&&Tl(n,s)||s;_o(n[i])&&_o(o)?n[i]=ui(n[i],o):_o(o)?n[i]=ui({},o):Tr(o)?n[i]=o.slice():(!t||!kr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Gr(arguments[o],r);return n}const Dm=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&$t(o)?e[s]=wl(o,n):e[s]=o},{allOwnKeys:r}),e),Lm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$m=(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)},Fm=(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&&ci(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bm=(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},zm=e=>{if(!e)return null;if(Tr(e))return e;let t=e.length;if(!Cl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ci(Uint8Array)),Um=(e,t)=>{const r=(e&&e[Eo]).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},Vm=tn("HTMLFormElement"),Km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Il=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qm=tn("RegExp"),El=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gm=e=>{El(e,(t,n)=>{if($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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+"'")})}})},Ym=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Tr(e)?r(e):r(String(e).split(t)),n},Xm=()=>{},Jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zm(e){return!!(e&&$t(e.append)&&e[yl]==="FormData"&&e[Eo])}const Qm=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Tr(r)?[]:{};return Gr(r,(i,a)=>{const l=n(i,o+1);!kr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},eg=tn("AsyncFunction"),tg=e=>e&&(qr(e)||$t(e))&&$t(e.then)&&$t(e.catch),Nl=((e,t)=>e?setImmediate:t?((n,r)=>(or.addEventListener("message",({source:o,data:s})=>{o===or&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),or.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(or.postMessage)),ng=typeof queueMicrotask<"u"?queueMicrotask.bind(or):typeof process<"u"&&process.nextTick||Nl,R={isArray:Tr,isArrayBuffer:Sl,isBuffer:Kr,isFormData:Am,isArrayBufferView:wm,isString:ym,isNumber:Cl,isBoolean:Sm,isObject:qr,isPlainObject:_o,isEmptyObject:Cm,isReadableStream:jm,isRequest:Rm,isResponse:Pm,isHeaders:Om,isUndefined:kr,isDate:Tm,isFile:km,isBlob:Im,isRegExp:qm,isFunction:$t,isStream:Nm,isURLSearchParams:_m,isTypedArray:Hm,isFileList:Em,forEach:Gr,merge:ui,extend:Dm,trim:Mm,stripBOM:Lm,inherits:$m,toFlatObject:Fm,kindOf:No,kindOfTest:tn,endsWith:Bm,toArray:zm,forEachEntry:Um,matchAll:Wm,isHTMLForm:Vm,hasOwnProperty:Il,hasOwnProp:Il,reduceDescriptors:El,freezeMethods:Gm,toObjectSet:Ym,toCamelCase:Km,noop:Xm,toFiniteNumber:Jm,findKey:Tl,global:or,isContextDefined:kl,isSpecCompliantForm:Zm,toJSONObject:Qm,isAsyncFn:eg,isThenable:tg,setImmediate:Nl,asap:ng,isIterable:e=>e!=null&&$t(e[Eo])};function Le(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)}R.inherits(Le,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:R.toJSONObject(this.config),code:this.code,status:this.status}}});const Al=Le.prototype,_l={};["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=>{_l[e]={value:e}}),Object.defineProperties(Le,_l),Object.defineProperty(Al,"isAxiosError",{value:!0}),Le.from=(e,t,n,r,o,s)=>{const i=Object.create(Al);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Le.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 rg=null;function di(e){return R.isPlainObject(e)||R.isArray(e)}function jl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Rl(e,t,n){return e?e.concat(t).map(function(o,s){return o=jl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function og(e){return R.isArray(e)&&!e.some(di)}const sg=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function jo(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!R.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(b){if(b===null)return"";if(R.isDate(b))return b.toISOString();if(R.isBoolean(b))return b.toString();if(!l&&R.isBlob(b))throw new Le("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(b)||R.isTypedArray(b)?l&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,x,g){let v=b;if(b&&!g&&typeof b=="object"){if(R.endsWith(x,"{}"))x=r?x:x.slice(0,-2),b=JSON.stringify(b);else if(R.isArray(b)&&og(b)||(R.isFileList(b)||R.endsWith(x,"[]"))&&(v=R.toArray(b)))return x=jl(x),v.forEach(function(S,N){!(R.isUndefined(S)||S===null)&&t.append(i===!0?Rl([x],N,s):i===null?x:x+"[]",u(S))}),!1}return di(b)?!0:(t.append(Rl(g,x,s),u(b)),!1)}const f=[],h=Object.assign(sg,{defaultVisitor:d,convertValue:u,isVisitable:di});function p(b,x){if(!R.isUndefined(b)){if(f.indexOf(b)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(b),R.forEach(b,function(v,w){(!(R.isUndefined(v)||v===null)&&o.call(t,v,R.isString(w)?w.trim():w,x,h))===!0&&p(v,x?x.concat(w):[w])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Pl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function fi(e,t){this._pairs=[],e&&jo(e,this,t)}const Ol=fi.prototype;Ol.append=function(t,n){this._pairs.push([t,n])},Ol.toString=function(t){const n=t?function(r){return t.call(this,r,Pl)}:Pl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ig(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ml(e,t,n){if(!t)return e;const r=n&&n.encode||ig;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new fi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Dl{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){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ll={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ag={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:fi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},hi=typeof window<"u"&&typeof document<"u",pi=typeof navigator=="object"&&navigator||void 0,lg=hi&&(!pi||["ReactNative","NativeScript","NS"].indexOf(pi.product)<0),cg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ug=hi&&window.location.href||"http://localhost",It={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:hi,hasStandardBrowserEnv:lg,hasStandardBrowserWebWorkerEnv:cg,navigator:pi,origin:ug},Symbol.toStringTag,{value:"Module"})),...ag};function dg(e,t){return jo(e,new It.classes.URLSearchParams,{visitor:function(n,r,o,s){return It.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fg(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hg(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 $l(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&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=hg(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(fg(r),o,n,0)}),n}return null}function pg(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Yr={transitional:Ll,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify($l(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 dg(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return jo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pg(t)):t}],transformResponse:[function(t){const n=this.transitional||Yr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.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"?Le.from(a,Le.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:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Yr.headers[e]={}});const mg=R.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"]),gg=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]&&mg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Fl=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Ro(e){return e===!1||e==null?e:R.isArray(e)?e.map(Ro):String(e)}function xg(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 vg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function mi(e,t,n,r,o){if(R.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function bg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function wg(e,t){const n=R.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 Ft=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const f=R.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=Ro(a))}const i=(a,l)=>R.forEach(a,(u,d)=>s(u,d,l));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!vg(t))i(gg(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},l,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?R.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=Xr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xg(o);if(R.isFunction(n))return n.call(this,o,r);if(R.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Xr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||mi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Xr(i),i){const a=R.findKey(r,i);a&&(!n||mi(r,r[a],a,n))&&(delete r[a],o=!0)}}return R.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||mi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return R.forEach(this,(o,s)=>{const i=R.findKey(r,s);if(i){n[i]=Ro(o),delete n[s];return}const a=t?bg(s):String(s).trim();a!==s&&delete n[s],n[a]=Ro(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return R.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&R.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[Fl]=this[Fl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(wg(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(Ft);function gi(e,t){const n=this||Yr,r=t||n,o=Ft.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Bl(e){return!!(e&&e.__CANCEL__)}function Ir(e,t,n){Le.call(this,e??"canceled",Le.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Ir,Le,{__CANCEL__:!0});function zl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Le("Request failed with status code "+n.status,[Le.ERR_BAD_REQUEST,Le.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Cg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Po=(e,t,n=3)=>{let r=0;const o=Sg(50,250);return Cg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Hl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ul=e=>(...t)=>R.asap(()=>e(...t)),Tg=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,kg=It.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.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 Ig(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Eg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Wl(e,t,n){let r=!Ig(t);return e&&(r||n==!1)?Eg(e,t):t}const Vl=e=>e instanceof Ft?{...e}:e;function sr(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Vl(u),Vl(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Kl=e=>{const t=sr({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.from(i),t.url=Ml(Wl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(It.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Tg(t.url))){const l=o&&s&&kg.read(s);l&&i.set(o,l)}return t},Ng=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Kl(e);let s=o.data;const i=Ft.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,b;function x(){p&&p(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function v(){if(!g)return;const S=Ft.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};zl(function(E){n(E),x()},function(E){r(E),x()},T),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(r(new Le("Request aborted",Le.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const T=N&&N.message?N.message:"Network Error",k=new Le(T,Le.ERR_NETWORK,e,g);k.event=N||null,r(k),g=null},g.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Ll;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new Le(N,T.clarifyTimeoutError?Le.ETIMEDOUT:Le.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(N,T){g.setRequestHeader(T,N)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,b]=Po(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Po(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Ir(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=yg(o.url);if(w&&It.protocols.indexOf(w)===-1){r(new Le("Unsupported protocol "+w+":",Le.ERR_BAD_REQUEST,e));return}g.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(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Le?d:new Ir(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Le(`timeout ${t} of ms exceeded`,Le.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>R.asap(a),l}},_g=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},jg=async function*(e,t){for await(const n of Rg(e))yield*_g(n,t)},Rg=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},ql=(e,t,n,r)=>{const o=jg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Gl=64*1024,{isFunction:Oo}=R,Pg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Yl,TextEncoder:Xl}=R.global,Jl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Og=e=>{e=R.merge.call({skipUndefined:!0},Pg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Oo(t):typeof fetch=="function",s=Oo(n),i=Oo(r);if(!o)return!1;const a=o&&Oo(Yl),l=o&&(typeof Xl=="function"?(b=>x=>b.encode(x))(new Xl):async b=>new Uint8Array(await new n(b).arrayBuffer())),u=s&&a&&Jl(()=>{let b=!1;const x=new n(It.origin,{body:new Yl,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!x}),d=i&&a&&Jl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!f[b]&&(f[b]=(x,g)=>{let v=x&&x[b];if(v)return v.call(x);throw new Le(`Response type '${b}' is not supported`,Le.ERR_NOT_SUPPORT,g)})});const h=async b=>{if(b==null)return 0;if(R.isBlob(b))return b.size;if(R.isSpecCompliantForm(b))return(await new n(It.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(R.isArrayBufferView(b)||R.isArrayBuffer(b))return b.byteLength;if(R.isURLSearchParams(b)&&(b=b+""),R.isString(b))return(await l(b)).byteLength},p=async(b,x)=>{const g=R.toFiniteNumber(b.getContentLength());return g??h(x)};return async b=>{let{url:x,method:g,data:v,signal:w,cancelToken:S,timeout:N,onDownloadProgress:T,onUploadProgress:k,responseType:E,headers:A,withCredentials:j="same-origin",fetchOptions:P}=Kl(b),L=t||fetch;E=E?(E+"").toLowerCase():"text";let $=Ag([w,S&&S.toAbortSignal()],N),V=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let G;try{if(k&&u&&g!=="get"&&g!=="head"&&(G=await p(A,v))!==0){let D=new n(x,{method:"POST",body:v,duplex:"half"}),Q;if(R.isFormData(v)&&(Q=D.headers.get("content-type"))&&A.setContentType(Q),D.body){const[fe,we]=Hl(G,Po(Ul(k)));v=ql(D.body,Gl,fe,we)}}R.isString(j)||(j=j?"include":"omit");const K=s&&"credentials"in n.prototype,W={...P,signal:$,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:v,duplex:"half",credentials:K?j:void 0};V=s&&new n(x,W);let B=await(s?L(V,P):L(x,W));const F=d&&(E==="stream"||E==="response");if(d&&(T||F&&M)){const D={};["status","statusText","headers"].forEach(ye=>{D[ye]=B[ye]});const Q=R.toFiniteNumber(B.headers.get("content-length")),[fe,we]=T&&Hl(Q,Po(Ul(T),!0))||[];B=new r(ql(B.body,Gl,fe,()=>{we&&we(),M&&M()}),D)}E=E||"text";let ue=await f[R.findKey(f,E)||"text"](B,b);return!F&&M&&M(),await new Promise((D,Q)=>{zl(D,Q,{data:ue,headers:Ft.from(B.headers),status:B.status,statusText:B.statusText,config:b,request:V})})}catch(K){throw M&&M(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Le("Network Error",Le.ERR_NETWORK,b,V),{cause:K.cause||K}):Le.from(K,K&&K.code,b,V)}}},Mg=new Map,Zl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Mg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Og(t)),d=u;return u};Zl();const xi={http:rg,xhr:Ng,fetch:{get:Zl}};R.forEach(xi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ql=e=>`- ${e}`,Dg=e=>R.isFunction(e)||e===null||e===!1,ec={getAdapter:(e,t)=>{e=R.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,!Dg(r)&&(o=xi[(a=String(r)).toLowerCase()],o===void 0))throw new Le(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
- `+i.map(Ql).join(`
34
- `):" "+Ql(i[0]):"as no adapter specified";throw new Le("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:xi};function vi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ir(null,e)}function tc(e){return vi(e),e.headers=Ft.from(e.headers),e.data=gi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ec.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return vi(e),r.data=gi.call(e,e.transformResponse,r),r.headers=Ft.from(r.headers),r},function(r){return Bl(r)||(vi(e),r&&r.response&&(r.response.data=gi.call(e,e.transformResponse,r.response),r.response.headers=Ft.from(r.response.headers))),Promise.reject(r)})}const nc="1.12.2",Mo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Mo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const rc={};Mo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+nc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Le(o(i," has been removed"+(n?" in "+n:"")),Le.ERR_DEPRECATED);return n&&!rc[i]&&(rc[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}},Mo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lg(e,t,n){if(typeof e!="object")throw new Le("options must be an object",Le.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 Le("option "+s+" must be "+l,Le.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Le("Unknown option "+s,Le.ERR_BAD_OPTION)}}const Do={assertOptions:Lg,validators:Mo},pn=Do.validators;let ir=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Dl,response:new Dl}}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=sr(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Do.assertOptions(r,{silentJSONParsing:pn.transitional(pn.boolean),forcedJSONParsing:pn.transitional(pn.boolean),clarifyTimeoutError:pn.transitional(pn.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:Do.assertOptions(o,{encode:pn.function,serialize:pn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Do.assertOptions(n,{baseUrl:pn.spelling("baseURL"),withXsrfToken:pn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=Ft.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const b=[tc.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,d=Promise.resolve(n);f<h;)d=d.then(b[f++],b[f++]);return d}h=a.length;let p=n;for(;f<h;){const b=a[f++],x=a[f++];try{p=b(p)}catch(g){x.call(this,g);break}}try{d=tc.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=sr(this.defaults,t);const n=Wl(t.baseURL,t.url,t.allowAbsoluteUrls);return Ml(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){ir.prototype[t]=function(n,r){return this.request(sr(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(sr(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}ir.prototype[t]=n(),ir.prototype[t+"Form"]=n(!0)});let $g=class pm{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 Ir(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 pm(function(o){t=o}),cancel:t}}};function Fg(e){return function(n){return e.apply(null,n)}}function Bg(e){return R.isObject(e)&&e.isAxiosError===!0}const bi={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(bi).forEach(([e,t])=>{bi[t]=e});function oc(e){const t=new ir(e),n=wl(ir.prototype.request,t);return R.extend(n,ir.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return oc(sr(e,o))},n}const mt=oc(Yr);mt.Axios=ir,mt.CanceledError=Ir,mt.CancelToken=$g,mt.isCancel=Bl,mt.VERSION=nc,mt.toFormData=jo,mt.AxiosError=Le,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Fg,mt.isAxiosError=Bg,mt.mergeConfig=sr,mt.AxiosHeaders=Ft,mt.formToJSON=e=>$l(R.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=ec.getAdapter,mt.HttpStatusCode=bi,mt.default=mt;const{Axios:NT,AxiosError:AT,CanceledError:_T,isCancel:jT,CancelToken:RT,VERSION:PT,all:OT,Cancel:MT,isAxiosError:DT,spread:LT,toFormData:$T,AxiosHeaders:FT,HttpStatusCode:BT,formToJSON:zT,getAdapter:HT,mergeConfig:UT}=mt,sc=typeof window<"u"?window.__API_BASE_URL__:void 0,ic=sc?Rn(sc):void 0;function Rn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Lo=null;const wi=new Set;function ac(){return Lo}function yi(e){Lo=e,wi.forEach(t=>t(e))}function lc(e){return wi.add(e),()=>wi.delete(e)}const Gt=mt.create({...ic?{baseURL:ic}:{},timeout:3e4,withCredentials:!0});Gt.interceptors.request.use(e=>(Lo&&(e.headers.Authorization=`Bearer ${Lo}`),e)),Gt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function nn(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Si(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function cc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function uc(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function rn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class dc{get baseUrl(){const t=Gt.defaults.baseURL;return t?Rn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=Rn(String(t.baseUrl))),t.authToken!==void 0&&yi(t.authToken)}getAuthToken(){return ac()}setAuthToken(t){yi(t)}onTokenChange(t){return lc(t)}async listThreads(){const t=await nn("/threads"),n=rn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Si("/threads",t?{title:t}:void 0);return rn(r)}async updateThread(t,n){const r=await cc(`/threads/${t}`,{title:n});return rn(r)}async deleteThread(t){const n=await uc(`/threads/${t}`);return rn(n)}async threadInfo(t){const n=await nn(`/threads/${t}/info`);return rn(n)}async listAgents(){const t=await nn("/agents"),n=rn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await nn(`/agents/${t}`);return rn(n)}async getAgentSchema(t){const n=await nn(`/agents/${t}/schema`);return rn(n)}async getMessages(t){const n=await nn(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return rn(n)}async getStateHistory(t){const n=await nn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return rn(n)}resumeStream(t){}async resume(t){const n=await Si("/runs/resume",{thread_id:t.threadId,value:t.value});return rn(n)}}const Fn=new dc,fc=y.createContext(null);function zg({children:e,apiConfig:t}){const n=Fn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(fc.Provider,{value:r,children:e})}function Ci(){const e=y.useContext(fc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Hg(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 Ug(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Hg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Wg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function Ti(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 $o(e,t){return`${e??""}::${t??""}`}function ki(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(!Ti(r))return{payload:{threadId:n,checkpointId:void 0,checkpointNs:void 0,messages:[],hasMore:!1,nextCursor:null,nextCursorNs:null},checkpoints:[],interrupt:null,snapshots:{}};const{summaries:o,snapshots:s}=Kg(t),i=hc(r,0);return{payload:{threadId:n,checkpointId:(i==null?void 0:i.checkpointId)??void 0,checkpointNs:(i==null?void 0:i.checkpointNs)??void 0,messages:(i==null?void 0:i.messages)??[],hasMore:!!(i!=null&&i.nextCursor),nextCursor:(i==null?void 0:i.nextCursor)??null,nextCursorNs:(i==null?void 0:i.nextCursorNs)??null,pendingInterrupt:(i==null?void 0:i.interrupt)??null},checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function hc(e,t){var h,p;if(!Ti(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((b,x)=>Jg(b,x)).filter(b=>!!b),i=zt((h=e.config)==null?void 0:h.configurable),a=ht(i,["checkpoint_id","checkpointId"]),l=ht(i,["checkpoint_ns","checkpointNs"]),u=zt((p=e.parentConfig)==null?void 0:p.configurable),d=ht(u,["checkpoint_id","checkpointId"])??null,f=ht(u,["checkpoint_ns","checkpointNs"])??null;return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:Vg(o,s,t)}}function Vg(e,t,n){const r=Yg(e,n);return r||Gg(t,n)}function Kg(e){const t=new Map,n={};e.forEach((o,s)=>{if(!Ti(o))return;const i=hc(o,s);if(!(i!=null&&i.checkpointId))return;const a=o==null?void 0:o.createdAt,l=typeof a=="string"&&a.trim()?a:new Date(Date.now()-s).toISOString(),u=qg(i.messages),d=i.messages[i.messages.length-1],f=zt(o==null?void 0:o.metadata),h=ht(f,["branch_label","branchLabel"]),p=zt(o==null?void 0:o.parentConfig),b=zt(p==null?void 0:p.configurable),x=ht(b,["checkpoint_id","checkpointId"]),g={checkpointId:i.checkpointId,checkpointNs:i.checkpointNs??"",createdAt:l,messagesLen:i.messages.length,preview:u??null,role:(d==null?void 0:d.role)??null,parentId:x??null,branchLabel:h??null,lastMessageId:(d==null?void 0:d.id)??null,hasMessages:i.messages.length>0},v=$o(g.checkpointId,g.checkpointNs);t.has(v)||t.set(v,g),n[v]||(n[v]=i)});const r=Array.from(t.values());return r.sort((o,s)=>mc(s.createdAt)-mc(o.createdAt)),{summaries:r,snapshots:n}}function qg(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function Gg(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 Yg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Xg(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=Jr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Jr(r.state,`${o}-state`);if(s)return s}}return null}function Xg(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,b=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:b,interrupts:x,state:g!==void 0?g:f}}const n=zt(e);if(!n)return null;const r=ht(n,["id","task_id","taskId"])??t,o=ht(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 Jr(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=pc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Jr(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=Jr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Jr(l,t,n+1,r);if(u)return u}}return null}function pc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=ht(n,["type","event","kind"]),o=ht(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=pc(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 mc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Jg(e,t){if(!e||typeof e!="object")return null;const n=e,r=zt(e)??{},o=zt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Wg[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=zt(o.additional_kwargs)??zt(o.additionalKwargs),d=zt(o.response_metadata)??zt(o.responseMetadata),f=ht(u,["createdAt","created_at"])??ht(o,["created_at","createdAt"]),h=ht(u,["checkpointId","checkpoint_id"]),p=ht(u,["checkpointNs","checkpoint_ns"]),b=Zg(o.content),x={id:l,role:i,content:b};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=rx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),v=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),v&&Object.keys(v).length&&(x.responseMetadata=v);const w=Qg((u==null?void 0:u.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=tx(o,x.content);S&&(x.content=S)}return x}function Zg(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>gc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=gc(e);return t?[t]:[]}return[]}function gc(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=ht(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=ht(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 ex(t)??null;if(n==="tool_end"){const o=ht(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=ht(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 Qg(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=ht(r,["id","call_id"]),s=zt(r.function),i=ht(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=xc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function ex(e){const t=ht(e,["id","call_id"]),n=ht(e,["name"]);if(!t||!n)return null;const r=xc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function tx(e,t){const n=ht(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?nx(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function xc(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 nx(e){try{return JSON.parse(e)}catch{return e}}function zt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ht(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function rx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function ox(e){return e.type!=="thread_info"&&e.type!=="token"}const sx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function ix(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ii(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ii(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ii(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return bc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>bc(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function vc(e=[]){const[t,n]=y.useReducer(ix,{...sx,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.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=y.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=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function bc(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=cx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ei(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Tc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:b,changed:x}=ax(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},v=wc(a,l,g),w={...d,[i]:b};return{...e,messages:v,messagesStreamMeta:w}}if(t.type==="message_end"){const i=e.assemblingId??Ei(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Sc(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=lx(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ei(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:Sc(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:yc(e.messages,l,f=>({...f,content:Cc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ii(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function wc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ei(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function yc(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Sc(e,t,n){return yc(e,t,r=>({...r,content:Cc(r.content,n)}))}function Cc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Ic(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Tc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function ax(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??Tc(e);let l="",u=e.slice();if(s){const f=Ic(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",b={...h,text:p+l};u=[...u.slice(0,u.length-1),b]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function kc(e){return e.replace(/\s+/g," ").trim()}function Ic(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=kc(e),o=kc(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 lx(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 wc(e,r,s)}return e}function cx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Ec(e={}){const t=y.useMemo(()=>Rn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,b]=y.useState(null),[x,g]=y.useState(0),[v,w]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),T=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),E=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),w(!1),T.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),b(null),d(null)},[]),j=y.useCallback((P,L,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const V=new AbortController;return S.current=V,(async()=>{var G,K,W,B,F,ue,D,Q;const M=fe=>{var we;try{const ye=JSON.parse(JSON.stringify(fe));return(we=ye==null?void 0:ye.payload)!=null&&we.files_info&&Array.isArray(ye.payload.files_info)&&(ye.payload.files_info=ye.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ye}catch{return fe}};try{let fe={};try{if(r)fe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const We=window.__AUTH_TOKEN__,ut=((G=window.localStorage)==null?void 0:G.getItem("authToken"))||null;let rt=null;try{const xt=(K=window.localStorage)==null?void 0:K.getItem("chat-settings");xt&&(rt=((W=JSON.parse(xt))==null?void 0:W.apiKey)||null)}catch{}const Ve=We||ut||rt||null;Ve&&(fe={Authorization:`Bearer ${Ve}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const we=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...fe,...s.current},body:JSON.stringify(P),signal:V.signal,credentials:i});if(!we.ok||!we.body){const Oe=await we.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",we.status,Oe==null?void 0:Oe.slice(0,500)),new Error(`stream ${we.status}${Oe?": "+Oe:""}`)}w(!0);const ye=we.body.getReader(),Se=new TextDecoder;let q="",O=[];T.current=0,g(0);let X=0,ee=null;const pe=()=>{if(O.length){const Oe=O.join("");O=[],N.current&&h(We=>We+Oe)}ee=null},oe=()=>{typeof window<"u"&&ee==null&&(ee=requestAnimationFrame(pe))};let me=Date.now();const et=setInterval(()=>{var Oe;if(Date.now()-me>6e4){const We="Stream idle timeout";d(We),V.abort(),(Oe=$==null?void 0:$.onError)==null||Oe.call($,We)}},5e3),tt=1024*1024;try{const Oe=we.headers.get("X-Thread-Id")||we.headers.get("x-thread-id"),We=we.headers.get("X-Thread-Created")||we.headers.get("x-thread-created"),ut=Oe??null,rt=String(We??"").toLowerCase()==="true";for((B=$==null?void 0:$.onOpen)==null||B.call($,{threadId:ut,created:rt});;){const{value:Ve,done:xt}=await ye.read();if(xt)break;q+=Se.decode(Ve,{stream:!0}),q.length>tt&&(q="",console.warn("Stream buffer reset: exceeded 1MB"));let J;for(;(J=q.indexOf(`
30
+ <%s key={someKey} {...props} />`,Wr,Pn,gl,Pn),pn[Pn+Wr]=!0}}return I===r?Cr(mt):Qt(mt),mt}}function ke(I,H,re){return oe(I,H,re,!0)}function qe(I,H,re){return oe(I,H,re,!1)}var it=qe,Mt=ke;Kr.Fragment=r,Kr.jsx=it,Kr.jsxs=Mt}()),Kr}process.env.NODE_ENV==="production"?li.exports=bm():li.exports=wm();var c=li.exports;function yl(e,t){return function(){return e.apply(t,arguments)}}const{toString:ym}=Object.prototype,{getPrototypeOf:ci}=Object,{iterator:No,toStringTag:Sl}=Symbol,Ao=(e=>t=>{const n=ym.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),tn=e=>(e=e.toLowerCase(),t=>Ao(t)===e),_o=e=>t=>typeof t===e,{isArray:Tr}=Array,Ir=_o("undefined");function qr(e){return e!==null&&!Ir(e)&&e.constructor!==null&&!Ir(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Cl=tn("ArrayBuffer");function Sm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Cl(e.buffer),t}const Cm=_o("string"),Lt=_o("function"),kl=_o("number"),Gr=e=>e!==null&&typeof e=="object",km=e=>e===!0||e===!1,jo=e=>{if(Ao(e)!=="object")return!1;const t=ci(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Sl in e)&&!(No in e)},Tm=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Im=tn("Date"),Em=tn("File"),Nm=tn("Blob"),Am=tn("FileList"),_m=e=>Gr(e)&&Lt(e.pipe),jm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=Ao(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},Rm=tn("URLSearchParams"),[Pm,Om,Mm,Dm]=["ReadableStream","Request","Response","Headers"].map(tn),Lm=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Yr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Tr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(qr(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 Tl(e,t){if(qr(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 rr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Il=e=>!Ir(e)&&e!==rr;function ui(){const{caseless:e,skipUndefined:t}=Il(this)&&this||{},n={},r=(o,s)=>{const i=e&&Tl(n,s)||s;jo(n[i])&&jo(o)?n[i]=ui(n[i],o):jo(o)?n[i]=ui({},o):Tr(o)?n[i]=o.slice():(!t||!Ir(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Yr(arguments[o],r);return n}const $m=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Lt(o)?e[s]=yl(o,n):e[s]=o},{allOwnKeys:r}),e),Fm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Bm=(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)},zm=(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&&ci(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Hm=(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},Um=e=>{if(!e)return null;if(Tr(e))return e;let t=e.length;if(!kl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Wm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ci(Uint8Array)),Vm=(e,t)=>{const r=(e&&e[No]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Km=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},qm=tn("HTMLFormElement"),Gm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),El=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ym=tn("RegExp"),Nl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Yr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Xm=e=>{Nl(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(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+"'")})}})},Jm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Tr(e)?r(e):r(String(e).split(t)),n},Zm=()=>{},Qm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function eg(e){return!!(e&&Lt(e.append)&&e[Sl]==="FormData"&&e[No])}const tg=e=>{const t=new Array(10),n=(r,o)=>{if(Gr(r)){if(t.indexOf(r)>=0)return;if(qr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Tr(r)?[]:{};return Yr(r,(i,a)=>{const l=n(i,o+1);!Ir(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ng=tn("AsyncFunction"),rg=e=>e&&(Gr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),Al=((e,t)=>e?setImmediate:t?((n,r)=>(rr.addEventListener("message",({source:o,data:s})=>{o===rr&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),rr.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(rr.postMessage)),og=typeof queueMicrotask<"u"?queueMicrotask.bind(rr):typeof process<"u"&&process.nextTick||Al,R={isArray:Tr,isArrayBuffer:Cl,isBuffer:qr,isFormData:jm,isArrayBufferView:Sm,isString:Cm,isNumber:kl,isBoolean:km,isObject:Gr,isPlainObject:jo,isEmptyObject:Tm,isReadableStream:Pm,isRequest:Om,isResponse:Mm,isHeaders:Dm,isUndefined:Ir,isDate:Im,isFile:Em,isBlob:Nm,isRegExp:Ym,isFunction:Lt,isStream:_m,isURLSearchParams:Rm,isTypedArray:Wm,isFileList:Am,forEach:Yr,merge:ui,extend:$m,trim:Lm,stripBOM:Fm,inherits:Bm,toFlatObject:zm,kindOf:Ao,kindOfTest:tn,endsWith:Hm,toArray:Um,forEachEntry:Vm,matchAll:Km,isHTMLForm:qm,hasOwnProperty:El,hasOwnProp:El,reduceDescriptors:Nl,freezeMethods:Xm,toObjectSet:Jm,toCamelCase:Gm,noop:Zm,toFiniteNumber:Qm,findKey:Tl,global:rr,isContextDefined:Il,isSpecCompliantForm:eg,toJSONObject:tg,isAsyncFn:ng,isThenable:rg,setImmediate:Al,asap:og,isIterable:e=>e!=null&&Lt(e[No])};function $e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}R.inherits($e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const _l=$e.prototype,jl={};["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=>{jl[e]={value:e}}),Object.defineProperties($e,jl),Object.defineProperty(_l,"isAxiosError",{value:!0}),$e.from=(e,t,n,r,o,s)=>{const i=Object.create(_l);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return $e.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const sg=null;function di(e){return R.isPlainObject(e)||R.isArray(e)}function Rl(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Pl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Rl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ig(e){return R.isArray(e)&&!e.some(di)}const ag=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function Ro(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!R.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(b){if(b===null)return"";if(R.isDate(b))return b.toISOString();if(R.isBoolean(b))return b.toString();if(!l&&R.isBlob(b))throw new $e("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(b)||R.isTypedArray(b)?l&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,x,g){let v=b;if(b&&!g&&typeof b=="object"){if(R.endsWith(x,"{}"))x=r?x:x.slice(0,-2),b=JSON.stringify(b);else if(R.isArray(b)&&ig(b)||(R.isFileList(b)||R.endsWith(x,"[]"))&&(v=R.toArray(b)))return x=Rl(x),v.forEach(function(S,N){!(R.isUndefined(S)||S===null)&&t.append(i===!0?Pl([x],N,s):i===null?x:x+"[]",u(S))}),!1}return di(b)?!0:(t.append(Pl(g,x,s),u(b)),!1)}const f=[],h=Object.assign(ag,{defaultVisitor:d,convertValue:u,isVisitable:di});function p(b,x){if(!R.isUndefined(b)){if(f.indexOf(b)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(b),R.forEach(b,function(v,w){(!(R.isUndefined(v)||v===null)&&o.call(t,v,R.isString(w)?w.trim():w,x,h))===!0&&p(v,x?x.concat(w):[w])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ol(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function fi(e,t){this._pairs=[],e&&Ro(e,this,t)}const Ml=fi.prototype;Ml.append=function(t,n){this._pairs.push([t,n])},Ml.toString=function(t){const n=t?function(r){return t.call(this,r,Ol)}:Ol;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function lg(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Dl(e,t,n){if(!t)return e;const r=n&&n.encode||lg;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new fi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Ll{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){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const $l={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:fi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},hi=typeof window<"u"&&typeof document<"u",pi=typeof navigator=="object"&&navigator||void 0,ug=hi&&(!pi||["ReactNative","NativeScript","NS"].indexOf(pi.product)<0),dg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",fg=hi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:hi,hasStandardBrowserEnv:ug,hasStandardBrowserWebWorkerEnv:dg,navigator:pi,origin:fg},Symbol.toStringTag,{value:"Module"})),...cg};function hg(e,t){return Ro(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function pg(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function mg(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 Fl(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&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=mg(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(pg(r),o,n,0)}),n}return null}function gg(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Xr={transitional:$l,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(Fl(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.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 hg(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ro(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),gg(t)):t}],transformResponse:[function(t){const n=this.transitional||Xr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?$e.from(a,$e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Xr.headers[e]={}});const xg=R.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"]),vg=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]&&xg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Bl=Symbol("internals");function Jr(e){return e&&String(e).trim().toLowerCase()}function Po(e){return e===!1||e==null?e:R.isArray(e)?e.map(Po):String(e)}function bg(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 wg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function mi(e,t,n,r,o){if(R.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function yg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Sg(e,t){const n=R.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 $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Jr(l);if(!d)throw new Error("header name must be a non-empty string");const f=R.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=Po(a))}const i=(a,l)=>R.forEach(a,(u,d)=>s(u,d,l));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!wg(t))i(vg(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},l,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?R.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=Jr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return bg(o);if(R.isFunction(n))return n.call(this,o,r);if(R.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Jr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||mi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Jr(i),i){const a=R.findKey(r,i);a&&(!n||mi(r,r[a],a,n))&&(delete r[a],o=!0)}}return R.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||mi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return R.forEach(this,(o,s)=>{const i=R.findKey(r,s);if(i){n[i]=Po(o),delete n[s];return}const a=t?yg(s):String(s).trim();a!==s&&delete n[s],n[a]=Po(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return R.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&R.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Bl]=this[Bl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Jr(i);r[a]||(Sg(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods($t);function gi(e,t){const n=this||Xr,r=t||n,o=$t.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function zl(e){return!!(e&&e.__CANCEL__)}function Er(e,t,n){$e.call(this,e??"canceled",$e.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(Er,$e,{__CANCEL__:!0});function Hl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new $e("Request failed with status code "+n.status,[$e.ERR_BAD_REQUEST,$e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Cg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function kg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Tg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Oo=(e,t,n=3)=>{let r=0;const o=kg(50,250);return Tg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Ul=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Wl=e=>(...t)=>R.asap(()=>e(...t)),Ig=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Eg=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.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 Ng(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ag(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vl(e,t,n){let r=!Ng(t);return e&&(r||n==!1)?Ag(e,t):t}const Kl=e=>e instanceof $t?{...e}:e;function or(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Kl(u),Kl(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const ql=e=>{const t=or({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=Dl(Vl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Nt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Ig(t.url))){const l=o&&s&&Eg.read(s);l&&i.set(o,l)}return t},_g=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ql(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,b;function x(){p&&p(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function v(){if(!g)return;const S=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Hl(function(E){n(E),x()},function(E){r(E),x()},k),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(r(new $e("Request aborted",$e.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const k=N&&N.message?N.message:"Network Error",T=new $e(k,$e.ERR_NETWORK,e,g);T.event=N||null,r(T),g=null},g.ontimeout=function(){let N=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const k=o.transitional||$l;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new $e(N,k.clarifyTimeoutError?$e.ETIMEDOUT:$e.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(N,k){g.setRequestHeader(k,N)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,b]=Oo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Oo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new Er(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Cg(o.url);if(w&&Nt.protocols.indexOf(w)===-1){r(new $e("Unsupported protocol "+w+":",$e.ERR_BAD_REQUEST,e));return}g.send(s||null)})},jg=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof $e?d:new Er(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new $e(`timeout ${t} of ms exceeded`,$e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>R.asap(a),l}},Rg=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},Pg=async function*(e,t){for await(const n of Og(e))yield*Rg(n,t)},Og=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()}},Gl=(e,t,n,r)=>{const o=Pg(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Yl=64*1024,{isFunction:Mo}=R,Mg=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Xl,TextEncoder:Jl}=R.global,Zl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Dg=e=>{e=R.merge.call({skipUndefined:!0},Mg,e);const{fetch:t,Request:n,Response:r}=e,o=t?Mo(t):typeof fetch=="function",s=Mo(n),i=Mo(r);if(!o)return!1;const a=o&&Mo(Xl),l=o&&(typeof Jl=="function"?(b=>x=>b.encode(x))(new Jl):async b=>new Uint8Array(await new n(b).arrayBuffer())),u=s&&a&&Zl(()=>{let b=!1;const x=new n(Nt.origin,{body:new Xl,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!x}),d=i&&a&&Zl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!f[b]&&(f[b]=(x,g)=>{let v=x&&x[b];if(v)return v.call(x);throw new $e(`Response type '${b}' is not supported`,$e.ERR_NOT_SUPPORT,g)})});const h=async b=>{if(b==null)return 0;if(R.isBlob(b))return b.size;if(R.isSpecCompliantForm(b))return(await new n(Nt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(R.isArrayBufferView(b)||R.isArrayBuffer(b))return b.byteLength;if(R.isURLSearchParams(b)&&(b=b+""),R.isString(b))return(await l(b)).byteLength},p=async(b,x)=>{const g=R.toFiniteNumber(b.getContentLength());return g??h(x)};return async b=>{let{url:x,method:g,data:v,signal:w,cancelToken:S,timeout:N,onDownloadProgress:k,onUploadProgress:T,responseType:E,headers:A,withCredentials:j="same-origin",fetchOptions:P}=ql(b),L=t||fetch;E=E?(E+"").toLowerCase():"text";let $=jg([w,S&&S.toAbortSignal()],N),V=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let G;try{if(T&&u&&g!=="get"&&g!=="head"&&(G=await p(A,v))!==0){let D=new n(x,{method:"POST",body:v,duplex:"half"}),te;if(R.isFormData(v)&&(te=D.headers.get("content-type"))&&A.setContentType(te),D.body){const[he,we]=Ul(G,Oo(Wl(T)));v=Gl(D.body,Yl,he,we)}}R.isString(j)||(j=j?"include":"omit");const K=s&&"credentials"in n.prototype,W={...P,signal:$,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:v,duplex:"half",credentials:K?j:void 0};V=s&&new n(x,W);let z=await(s?L(V,P):L(x,W));const B=d&&(E==="stream"||E==="response");if(d&&(k||B&&M)){const D={};["status","statusText","headers"].forEach(ye=>{D[ye]=z[ye]});const te=R.toFiniteNumber(z.headers.get("content-length")),[he,we]=k&&Ul(te,Oo(Wl(k),!0))||[];z=new r(Gl(z.body,Yl,he,()=>{we&&we(),M&&M()}),D)}E=E||"text";let ue=await f[R.findKey(f,E)||"text"](z,b);return!B&&M&&M(),await new Promise((D,te)=>{Hl(D,te,{data:ue,headers:$t.from(z.headers),status:z.status,statusText:z.statusText,config:b,request:V})})}catch(K){throw M&&M(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new $e("Network Error",$e.ERR_NETWORK,b,V),{cause:K.cause||K}):$e.from(K,K&&K.code,b,V)}}},Lg=new Map,Ql=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Lg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Dg(t)),d=u;return u};Ql();const xi={http:sg,xhr:_g,fetch:{get:Ql}};R.forEach(xi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ec=e=>`- ${e}`,$g=e=>R.isFunction(e)||e===null||e===!1,tc={getAdapter:(e,t)=>{e=R.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,!$g(r)&&(o=xi[(a=String(r)).toLowerCase()],o===void 0))throw new $e(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
+ `+i.map(ec).join(`
34
+ `):" "+ec(i[0]):"as no adapter specified";throw new $e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:xi};function vi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Er(null,e)}function nc(e){return vi(e),e.headers=$t.from(e.headers),e.data=gi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),tc.getAdapter(e.adapter||Xr.adapter,e)(e).then(function(r){return vi(e),r.data=gi.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return zl(r)||(vi(e),r&&r.response&&(r.response.data=gi.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const rc="1.12.2",Do={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Do[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const oc={};Do.transitional=function(t,n,r){function o(s,i){return"[Axios v"+rc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new $e(o(i," has been removed"+(n?" in "+n:"")),$e.ERR_DEPRECATED);return n&&!oc[i]&&(oc[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}},Do.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Fg(e,t,n){if(typeof e!="object")throw new $e("options must be an object",$e.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new $e("option "+s+" must be "+l,$e.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new $e("Unknown option "+s,$e.ERR_BAD_OPTION)}}const Lo={assertOptions:Fg,validators:Do},gn=Lo.validators;let sr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ll,response:new Ll}}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=or(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Lo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:Lo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Lo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=$t.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const b=[nc.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,d=Promise.resolve(n);f<h;)d=d.then(b[f++],b[f++]);return d}h=a.length;let p=n;for(;f<h;){const b=a[f++],x=a[f++];try{p=b(p)}catch(g){x.call(this,g);break}}try{d=nc.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=or(this.defaults,t);const n=Vl(t.baseURL,t.url,t.allowAbsoluteUrls);return Dl(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){sr.prototype[t]=function(n,r){return this.request(or(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(or(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}sr.prototype[t]=n(),sr.prototype[t+"Form"]=n(!0)});let Bg=class gm{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 Er(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 gm(function(o){t=o}),cancel:t}}};function zg(e){return function(n){return e.apply(null,n)}}function Hg(e){return R.isObject(e)&&e.isAxiosError===!0}const bi={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(bi).forEach(([e,t])=>{bi[t]=e});function sc(e){const t=new sr(e),n=yl(sr.prototype.request,t);return R.extend(n,sr.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return sc(or(e,o))},n}const gt=sc(Xr);gt.Axios=sr,gt.CanceledError=Er,gt.CancelToken=Bg,gt.isCancel=zl,gt.VERSION=rc,gt.toFormData=Ro,gt.AxiosError=$e,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=zg,gt.isAxiosError=Hg,gt.mergeConfig=or,gt.AxiosHeaders=$t,gt.formToJSON=e=>Fl(R.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=tc.getAdapter,gt.HttpStatusCode=bi,gt.default=gt;const{Axios:jk,AxiosError:Rk,CanceledError:Pk,isCancel:Ok,CancelToken:Mk,VERSION:Dk,all:Lk,Cancel:$k,isAxiosError:Fk,spread:Bk,toFormData:zk,AxiosHeaders:Hk,HttpStatusCode:Uk,formToJSON:Wk,getAdapter:Vk,mergeConfig:Kk}=gt,ic=typeof window<"u"?window.__API_BASE_URL__:void 0,ac=ic?On(ic):void 0;function On(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let $o=null;const wi=new Set;function lc(){return $o}function yi(e){$o=e,wi.forEach(t=>t(e))}function cc(e){return wi.add(e),()=>wi.delete(e)}const Kt=gt.create({...ac?{baseURL:ac}:{},timeout:3e4,withCredentials:!0});Kt.interceptors.request.use(e=>($o&&(e.headers.Authorization=`Bearer ${$o}`),e)),Kt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function nn(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Si(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function uc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function dc(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function rn(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class fc{get baseUrl(){const t=Kt.defaults.baseURL;return t?On(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=On(String(t.baseUrl))),t.authToken!==void 0&&yi(t.authToken)}getAuthToken(){return lc()}setAuthToken(t){yi(t)}onTokenChange(t){return cc(t)}async listThreads(){const t=await nn("/threads"),n=rn(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Si("/threads",t?{title:t}:void 0);return rn(r)}async updateThread(t,n){const r=await uc(`/threads/${t}`,{title:n});return rn(r)}async deleteThread(t){const n=await dc(`/threads/${t}`);return rn(n)}async threadInfo(t){const n=await nn(`/threads/${t}/info`);return rn(n)}async listAgents(){const t=await nn("/agents"),n=rn(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await nn(`/agents/${t}`);return rn(n)}async getAgentSchema(t){const n=await nn(`/agents/${t}/schema`);return rn(n)}async getMessages(t){const n=await nn(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return rn(n)}async getStateHistory(t){const n=await nn(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return rn(n)}resumeStream(t){}async resume(t){const n=await Si("/runs/resume",{thread_id:t.threadId,value:t.value});return rn(n)}}const Bn=new fc,hc=y.createContext(null);function Ug({children:e,apiConfig:t}){const n=Bn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(hc.Provider,{value:r,children:e})}function Ci(){const e=y.useContext(hc);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 Vg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Wg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Kg={human:"user",user:"user",ai:"assistant",assistant:"assistant",tool:"tool",function:"tool",system:"system"};function ki(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 Fo(e,t){return`${e??""}::${t??""}`}function Ti(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(!ki(r))return{payload:{threadId:n,checkpointId:void 0,checkpointNs:void 0,messages:[],hasMore:!1,nextCursor:null,nextCursorNs:null},checkpoints:[],interrupt:null,snapshots:{}};const{summaries:o,snapshots:s}=Gg(t),i=pc(r,0);return{payload:{threadId:n,checkpointId:(i==null?void 0:i.checkpointId)??void 0,checkpointNs:(i==null?void 0:i.checkpointNs)??void 0,messages:(i==null?void 0:i.messages)??[],hasMore:!!(i!=null&&i.nextCursor),nextCursor:(i==null?void 0:i.nextCursor)??null,nextCursorNs:(i==null?void 0:i.nextCursorNs)??null,pendingInterrupt:(i==null?void 0:i.interrupt)??null},checkpoints:o,interrupt:(i==null?void 0:i.interrupt)??null,snapshots:s}}function pc(e,t){var h,p;if(!ki(e))return null;const n=e.values??{},r=Array.isArray(n==null?void 0:n.messages)?n.messages:[],o=e.tasks,s=r.map((b,x)=>Qg(b,x)).filter(b=>!!b),i=Bt((h=e.config)==null?void 0:h.configurable),a=pt(i,["checkpoint_id","checkpointId"]),l=pt(i,["checkpoint_ns","checkpointNs"]),u=Bt((p=e.parentConfig)==null?void 0:p.configurable),d=pt(u,["checkpoint_id","checkpointId"])??null,f=pt(u,["checkpoint_ns","checkpointNs"])??null;return{messages:s,checkpointId:a??null,checkpointNs:l??null,nextCursor:d,nextCursorNs:f,interrupt:qg(o,s,t)}}function qg(e,t,n){const r=Jg(e,n);return r||Xg(t,n)}function Gg(e){const t=new Map,n={};e.forEach((o,s)=>{if(!ki(o))return;const i=pc(o,s);if(!(i!=null&&i.checkpointId))return;const a=o==null?void 0:o.createdAt,l=typeof a=="string"&&a.trim()?a:new Date(Date.now()-s).toISOString(),u=Yg(i.messages),d=i.messages[i.messages.length-1],f=Bt(o==null?void 0:o.metadata),h=pt(f,["branch_label","branchLabel"]),p=Bt(o==null?void 0:o.parentConfig),b=Bt(p==null?void 0:p.configurable),x=pt(b,["checkpoint_id","checkpointId"]),g={checkpointId:i.checkpointId,checkpointNs:i.checkpointNs??"",createdAt:l,messagesLen:i.messages.length,preview:u??null,role:(d==null?void 0:d.role)??null,parentId:x??null,branchLabel:h??null,lastMessageId:(d==null?void 0:d.id)??null,hasMessages:i.messages.length>0},v=Fo(g.checkpointId,g.checkpointNs);t.has(v)||t.set(v,g),n[v]||(n[v]=i)});const r=Array.from(t.values());return r.sort((o,s)=>gc(s.createdAt)-gc(o.createdAt)),{summaries:r,snapshots:n}}function Yg(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=0;o<r.length;o++){const s=r[o];if(s&&s.type==="text"&&typeof s.text=="string"){const i=s.text.trim();if(i)return i}}}return null}function Xg(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 Jg(e,t){if(!Array.isArray(e)||!e.length)return null;for(let n=e.length-1;n>=0;n--){const r=Zg(e[n],`task-${t}-${n}`);if(!r)continue;const o=r.id||`task-${t}-${n}`;if(Array.isArray(r.interrupts)&&r.interrupts.length)for(let s=r.interrupts.length-1;s>=0;s--){const i=Zr(r.interrupts[s],`${o}-interrupt-${s}`);if(i)return i}if(r.state!==void 0&&r.state!==null){const s=Zr(r.state,`${o}-state`);if(s)return s}}return null}function Zg(e,t){if(!e)return null;if(Array.isArray(e)){const[a,l,u,,d,,f,...h]=e,p=typeof a=="string"&&a.trim()?a:t,b=typeof l=="string"&&l.trim()?l:Array.isArray(u)&&typeof u[0]=="string"?String(u[0]):"task",x=Array.isArray(d)?d:void 0,g=h.length?h[h.length-1]:void 0;return{id:p,name:b,interrupts:x,state:g!==void 0?g:f}}const n=Bt(e);if(!n)return null;const r=pt(n,["id","task_id","taskId"])??t,o=pt(n,["name"])??"task",s=Array.isArray(n.interrupts)?n.interrupts:void 0,i=Object.prototype.hasOwnProperty.call(n,"state")?n.state:void 0;return{id:r,name:o,interrupts:s,state:i}}function Zr(e,t,n=0,r=new Set){if(n>6||e==null)return null;if(typeof e=="object"){if(r.has(e))return null;r.add(e)}const o=mc(e,t);if(o)return o;if(Array.isArray(e)){for(let s=e.length-1;s>=0;s--){const i=Zr(e[s],t,n+1,r);if(i)return i}return null}if(typeof e=="object"){const s=e,i=["interrupt","pending_interrupt","pendingInterrupt","value","data","payload","result","response"];for(const a of i)if(a in s){const l=Zr(s[a],t,n+1,r);if(l)return l}for(const[a,l]of Object.entries(s)){if(i.includes(a)||a==="messages"||a==="results")continue;const u=Zr(l,t,n+1,r);if(u)return u}}return null}function mc(e,t){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){const n=e,r=pt(n,["type","event","kind"]),o=pt(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=mc(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 gc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Qg(e,t){if(!e||typeof e!="object")return null;const n=e,r=Bt(e)??{},o=Bt(n.data)??r,s=String(n.type??o.type??o.role??"").toLowerCase(),i=Kg[s];if(!i)return null;const a=o.id??o.message_id??o.run_id??null,l=typeof a=="string"&&a.trim()?a:`history-${i}-${t}`,u=Bt(o.additional_kwargs)??Bt(o.additionalKwargs),d=Bt(o.response_metadata)??Bt(o.responseMetadata),f=pt(u,["createdAt","created_at"])??pt(o,["created_at","createdAt"]),h=pt(u,["checkpointId","checkpoint_id"]),p=pt(u,["checkpointNs","checkpoint_ns"]),b=ex(o.content),x={id:l,role:i,content:b};f&&(x.createdAt=f),typeof o.name=="string"&&o.name.trim()&&(x.name=o.name),typeof(d==null?void 0:d.model_name)=="string"&&(x.model=String(d.model_name)),!x.model&&typeof o.model=="string"&&(x.model=o.model),h&&(x.checkpointId=h),p&&(x.checkpointNs=p);const g=sx(u,["createdAt","created_at","checkpointId","checkpoint_id","checkpointNs","checkpoint_ns","tool_calls"]),v=d?{...d}:void 0;g&&Object.keys(g).length&&(x.additionalKwargs=g),v&&Object.keys(v).length&&(x.responseMetadata=v);const w=tx((u==null?void 0:u.tool_calls)??o.tool_calls);if(w.length&&(x.content=[...x.content,...w]),i==="tool"){const S=rx(o,x.content);S&&(x.content=S)}return x}function ex(e){if(!e)return[];if(Array.isArray(e))return e.map(t=>xc(t)).filter(t=>!!t);if(typeof e=="string")return e.trim()?[{type:"text",text:e.trim()}]:[];if(typeof e=="object"){const t=xc(e);return t?[t]:[]}return[]}function xc(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=pt(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=pt(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 nx(t)??null;if(n==="tool_end"){const o=pt(t,["tool_call_id","toolCallId","id"]);if(!o)return null;const s={type:"tool_end",toolCallId:o,output:"output"in t?t.output:t.content};return typeof t.error=="string"&&(s.error=t.error),s}if(n==="interrupt")return{type:"interrupt",value:t.value,...t};if(n==="tool"){const o=pt(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 tx(e){return Array.isArray(e)?e.map((t,n)=>{if(!t||typeof t!="object")return null;const r=t,o=pt(r,["id","call_id"]),s=Bt(r.function),i=pt(s,["name"])??"tool",a=s==null?void 0:s.arguments,l=vc(a);return{type:"tool_call",id:o??`tool_call_${n}`,name:i,args:l}}).filter(t=>!!t):[]}function nx(e){const t=pt(e,["id","call_id"]),n=pt(e,["name"]);if(!t||!n)return null;const r=vc(e.args??e.arguments);return{type:"tool_call",id:t,name:n,args:r}}function rx(e,t){const n=pt(e,["tool_call_id","toolCallId","id"]);if(!n)return t;const r=e.content??e.output,o=typeof r=="string"?ox(r):r,s={type:"tool_end",toolCallId:n,output:o};return typeof e.error=="string"&&(s.error=e.error),[s]}function vc(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 ox(e){try{return JSON.parse(e)}catch{return e}}function Bt(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function pt(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r}}function sx(e,t){if(!e)return;const n={};let r=!1;for(const[o,s]of Object.entries(e)){if(t.includes(o)){r=!0;continue}s!==void 0&&(n[o]=s)}return r?Object.keys(n).length?n:void 0:e}function ix(e){return e.type!=="thread_info"&&e.type!=="token"}const ax={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,messagesStreamMeta:{},pendingInterrupt:null};function lx(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Ii(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null,pendingInterrupt:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ii(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Ii(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return wc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>wc(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function bc(e=[]){const[t,n]=y.useReducer(lx,{...ax,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.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=y.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=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function wc(e,t){var n,r,o,s;if(t.type==="message_start"&&t.role==="assistant"){const i=t.id,a=dx(t.model);if(e.messages.some(d=>d.id===i)){const d=e.messagesStreamMeta??{},f={...d,[i]:d[i]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:i,messagesStreamMeta:f}}const u={id:i,role:"assistant",name:a||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:i,messages:[...e.messages,u]}}if(t.type==="message_delta"){const i=e.assemblingId??Ei(e.messages);if(!i)return e;const a=e.messages,l=a.findIndex(S=>S.id===i&&S.role==="assistant");if(l===-1)return e;const u=a[l],d=e.messagesStreamMeta??{},f=d[i]??{lastSeq:null,lastText:Tc(u.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof f.lastSeq=="number"&&h<=f.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:f.lastSeq}),e;const{newParts:p,newMeta:b,changed:x}=cx(u.content,t.delta,f,h);if(!x)return e;const g={...u,content:p},v=yc(a,l,g),w={...d,[i]:b};return{...e,messages:v,messagesStreamMeta:w}}if(t.type==="message_end"){const i=e.assemblingId??Ei(e.messages);if(!i)return{...e,assemblingId:null};const a=e.messages,l=a.findIndex(u=>u.id===i&&u.role==="assistant");if(l>=0){const u=a[l];if(!((n=u.content)==null?void 0:n.some(f=>{var h;return(f==null?void 0:f.type)==="text"&&((h=f.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:u.id,contentTypes:(r=u.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=u.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const f=[...a.slice(0,l),...a.slice(l+1)];return{...e,assemblingId:null,messages:f}}}return e}if(t.type==="tool_start"){const i=t.id??t.call_id,a=t.name??t.tool??"tool";if(!i)return e;const l=`tool-${i}`,u={type:"tool_call",id:i,name:a,args:t.args};if(e.messages.find(h=>h.id===l))return{...e,toolIndex:{...e.toolIndex,[i]:l}};const f={id:l,role:"tool",name:a,createdAt:new Date().toISOString(),content:[u]};return{...e,messages:[...e.messages,f],toolIndex:{...e.toolIndex,[i]:l}}}if(t.type==="tool_end"){const i=t.id??t.call_id;if(!i)return e;const a=e.toolIndex[i]??`tool-${i}`,l={type:"tool_end",toolCallId:i,output:t.output,error:t.error},u=e.messages.find(h=>h.id===a),d={id:a,role:"tool",name:t.name??((s=e.messages.find(h=>h.id===a))==null?void 0:s.name),content:[l],createdAt:new Date().toISOString()},f=u?Cc(e.messages,a,[l]):[...e.messages,d];return{...e,messages:f,toolIndex:{...e.toolIndex,[i]:a}}}if(t.type==="checkpoint"){const i=t.checkpointNs??e.lastCheckpointNs??null,a=ux(e.messages,t.checkpointId,i);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:i,messages:a}}if(t.type==="branch"){const i=t.checkpointId??e.lastCheckpointId,a=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:i??null,lastCheckpointNs:a??null}}if(t.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,i]}}if(t.type==="interrupt"){const i=e.assemblingId??Ei(e.messages),a={type:"interrupt",value:t.value,id:t.id};if(i)return{...e,assemblingId:null,messages:Cc(e.messages,i,[a]),pendingInterrupt:{id:t.id,value:t.value}};const l=`interrupt-${t.id}`;if(e.messages.findIndex(f=>f.id===l)!==-1)return{...e,assemblingId:null,messages:Sc(e.messages,l,f=>({...f,content:kc(f.content??[],[a])})),pendingInterrupt:{id:t.id,value:t.value}};const d={id:l,role:"system",createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,d],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ii(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function yc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ei(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Sc(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Cc(e,t,n){return Sc(e,t,r=>({...r,content:kc(r.content,n)}))}function kc(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){let i=function(p){return p.replace(/\s+/g," ").trim()};const a=o,l=a.text??"";if(console.debug("[MessageReducer] mergeParts",{incomingLength:s.length,previousLength:l.length,incomingSnippet:s.slice(0,100),previousSnippet:l.slice(-100)}),!l){a.text=s;continue}const u=i(s),d=i(l);if(u.startsWith(d)||s.startsWith(l)){console.debug("[MessageReducer] incoming startsWith previous (norm/raw) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(u.includes(d)){console.debug("[MessageReducer] incoming includes previous (normalized) - replacing",{incomingLength:s.length,previousLength:l.length}),a.text=s;continue}if(d.includes(u)&&u.length<=3){console.debug("[MessageReducer] previous includes incoming (normalized) - skipping trivial incoming",{incomingLength:s.length,previousLength:l.length});continue}const h=Ec(l,s);h?(console.debug("[MessageReducer] suffix computed",{suffixLength:h.length}),a.text=l+h):(console.debug("[MessageReducer] no overlap detected - appending incoming",{incomingLength:s.length}),a.text=l+s)}else n.push({type:"text",text:s})}else n.push(r);return n}function Tc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function cx(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??Tc(e);let l="",u=e.slice();if(s){const f=Ec(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",b={...h,text:p+l};u=[...u.slice(0,u.length-1),b]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function Ic(e){return e.replace(/\s+/g," ").trim()}function Ec(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 ux(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 yc(e,r,s)}return e}function dx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Nc(e={}){const t=y.useMemo(()=>On(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,b]=y.useState(null),[x,g]=y.useState(0),[v,w]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),k=y.useRef(0),T=y.useCallback(P=>{o(P)},[]),E=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),w(!1),k.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),b(null),d(null)},[]),j=y.useCallback((P,L,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const V=new AbortController;return S.current=V,(async()=>{var G,K,W,z,B,ue,D,te;const M=he=>{var we;try{const ye=JSON.parse(JSON.stringify(he));return(we=ye==null?void 0:ye.payload)!=null&&we.files_info&&Array.isArray(ye.payload.files_info)&&(ye.payload.files_info=ye.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ye}catch{return he}};try{let he={};try{if(r)he={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,ut=((G=window.localStorage)==null?void 0:G.getItem("authToken"))||null;let nt=null;try{const vt=(K=window.localStorage)==null?void 0:K.getItem("chat-settings");vt&&(nt=((W=JSON.parse(vt))==null?void 0:W.apiKey)||null)}catch{}const Ke=Ve||ut||nt||null;Ke&&(he={Authorization:`Bearer ${Ke}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const we=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...he,...s.current},body:JSON.stringify(P),signal:V.signal,credentials:i});if(!we.ok||!we.body){const Pe=await we.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",we.status,Pe==null?void 0:Pe.slice(0,500)),new Error(`stream ${we.status}${Pe?": "+Pe:""}`)}w(!0);const ye=we.body.getReader(),Se=new TextDecoder;let q="",O=[];k.current=0,g(0);let X=0,ne=null;const pe=()=>{if(O.length){const Pe=O.join("");O=[],N.current&&h(Ve=>Ve+Pe)}ne=null},se=()=>{typeof window<"u"&&ne==null&&(ne=requestAnimationFrame(pe))};let me=Date.now();const et=setInterval(()=>{var Pe;if(Date.now()-me>6e4){const Ve="Stream idle timeout";d(Ve),V.abort(),(Pe=$==null?void 0:$.onError)==null||Pe.call($,Ve)}},5e3),tt=1024*1024;try{const Pe=we.headers.get("X-Thread-Id")||we.headers.get("x-thread-id"),Ve=we.headers.get("X-Thread-Created")||we.headers.get("x-thread-created"),ut=Pe??null,nt=String(Ve??"").toLowerCase()==="true";for((z=$==null?void 0:$.onOpen)==null||z.call($,{threadId:ut,created:nt});;){const{value:Ke,done:vt}=await ye.read();if(vt)break;q+=Se.decode(Ke,{stream:!0}),q.length>tt&&(q="",console.warn("Stream buffer reset: exceeded 1MB"));let Q;for(;(Q=q.indexOf(`
36
36
 
37
- `))>=0;){const se=q.slice(0,J);q=q.slice(J+2);const ge=dx(se);if(!ge)continue;let Ce;try{Ce=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const xe=ux(Ce)?Ce.data:Ce;me=Date.now();const Me=xe.seq;if(Me!==void 0){if(Me<=X){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Me,lastProcessedSeq:X,type:xe.type});continue}X>0&&Me>X+1&&((F=$==null?void 0:$.onGap)==null||F.call($,{from:X,to:Me})),X=Me,T.current=Me,g(Me)}if(console.debug("[use-chat] received event",{seq:xe.seq,type:xe.type,preview:(()=>{var at;try{return xe.type==="message_delta"?{deltaTypes:(at=xe.delta)==null?void 0:at.map(De=>De.type),textLen:(xe.delta||[]).filter(De=>De.type==="text").map(De=>String(De.text||"").length)}:xe.content||xe.delta?{hasContent:!0}:{}}catch(De){return{err:String(De)}}})()}),L==null||L(xe),xe.type==="token"&&e.autoAppendAssistant!==!1)O.push(xe.content),oe();else if(xe.type==="message_delta"){const at=xe.delta.filter(De=>De.type==="text").map(De=>De.text).join("");at&&e.autoAppendAssistant!==!1&&(O.push(at),oe())}else xe.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ee!==null&&cancelAnimationFrame(ee),pe(),xe.type==="checkpoint"?b(xe.checkpointId):xe.type==="error"&&d(xe.message))}}pe()}catch(Oe){if(Oe.name!=="AbortError"){const We=Oe.message||String(Oe);d(We),(ue=$==null?void 0:$.onError)==null||ue.call($,We)}}finally{try{await ye.cancel()}catch{}finally{(D=ye.releaseLock)==null||D.call(ye)}ee!==null&&typeof window<"u"&&window.cancelAnimationFrame(ee),clearInterval(et),l(!1),w(!1),S.current=null,T.current=0,g(0)}}catch(fe){if(fe.name!=="AbortError"){const we=fe.message||String(fe);d(we),(Q=$==null?void 0:$.onError)==null||Q.call($,we)}}finally{l(!1),w(!1),S.current=null,T.current=0,g(0)}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;N.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:v,stream:j,stop:E,clear:A,setToken:k}}function ux(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function dx(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 fx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const b=p.seq??null;if(b!==null){const x=s.current;if(x!==null){if(b<=x)return;b>x+1&&(o==null||o({from:x,to:b}))}s.current=b}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(ox(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Ec({baseUrl:e,token:null}),h=y.useCallback((p,b)=>{s.current=null,a(p,i,{onOpen:b==null?void 0:b.onOpen,onError:x=>{var g;(g=b==null?void 0:b.onError)==null||g.call(b,x)},onGap:(b==null?void 0:b.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Nc=y.createContext(null),Ac=y.createContext(null),_c=y.createContext(null),hx=y.createContext(!1),px="cachedThreads",mx="v1",Fo=300,Ni=200;function gx(e,t,n){return`${e}__${t??""}__${n??""}`}function xx(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}function vx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function jc(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,Fo)}function Er(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ai(e){if(!Er())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Rc(e,t){if(Er())try{window.localStorage.setItem(e,t)}catch{}}function _i(e){if(Er())try{window.localStorage.removeItem(e)}catch{}}function bx(){const e=Ai(px);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function wx(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function ji(e,t){return`cachedThreads:v1:${e}:${wx(t||"anon")}`}function yx(e){const t=Ai(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function Ri(e,t){try{Rc(e,JSON.stringify(t))}catch{}}function Pi(e){const t=yx(e);if(t.length>0)return t;const n=bx();if(n.length>0)try{Ri(e,n.slice(0,Ni))}catch{}return n}function Bo(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Oi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function Sx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ci(),d=y.useMemo(()=>Rn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${mx}:${f}:`,[f]),p=y.useCallback(C=>`${h}${C}`,[h]),b=y.useCallback(C=>{if(!C||typeof C!="object")return null;const _=C;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,nextCursorNs:_.nextCursorNs??null,pendingInterrupt:_.pendingInterrupt??null}},[]),x=y.useCallback(C=>{const _=Ai(p(C));if(!_)return null;try{const z=JSON.parse(_);return b(z)}catch{return null}},[p,b]),g=y.useCallback((C,_=100)=>{const z={...C,messages:Array.isArray(C.messages)?C.messages.slice(-_):[]};try{Rc(p(C.threadId),JSON.stringify(z))}catch{}},[p]),v=y.useCallback(C=>{_i(p(C))},[p]),w=y.useCallback(()=>{if(Er())try{const C=h;for(let _=0;_<window.localStorage.length;_++){const z=window.localStorage.key(_);z&&z.startsWith(C)&&window.localStorage.removeItem(z)}}catch{}},[h]),[S,N]=y.useState(()=>{var C;return ji(f,(C=l.getAuthToken)==null?void 0:C.call(l))}),[T,k]=y.useState(()=>{var _;const C=Pi(ji(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return Bo(C)}),E=y.useMemo(()=>Oi(T),[T]),[A,j]=y.useState(t),[P,L]=y.useState(!1),[$,V]=y.useState(!1),[M,G]=y.useState(null),[K,W]=y.useState(null),[B,F]=y.useState(null),ue=y.useCallback(()=>{const C=Pi(S);y.startTransition(()=>{k(Bo(C))})},[S]),[D,Q]=y.useState(!1),[fe,we]=y.useState(!1),[ye,Se]=y.useState(null),[q,O]=y.useState(void 0),[X,ee]=y.useState(void 0),[pe,oe]=y.useState(void 0),{state:me,dispatch:et,seed:tt,prepend:Oe,pushUser:We,onEvent:ut,reset:rt}=vc(),Ve=y.useRef(A);y.useEffect(()=>{Ve.current=A},[A]);const xt=y.useRef(!1),J=y.useRef([]),se=y.useRef(null),ge=y.useRef(null),Ce=y.useRef(new Map),xe=y.useRef(A),Me=y.useRef(!1),at=y.useRef(null),De=y.useRef(new Map),it=y.useRef(new Map),vt=y.useRef(new Map),_t=y.useCallback((C,_,z)=>{if(!C)return;const he=z==="replace"?[]:De.current.get(C)??[],te=z==="replace"?_:[..._,...he];if(!te.length){z==="replace"&&De.current.set(C,[]);return}const re=new Map;for(const Ue of te){if(!(Ue!=null&&Ue.checkpointId))continue;const Be=`${Ue.checkpointId}::${Ue.checkpointNs??""}`;re.has(Be)||re.set(Be,Ue)}const Fe=Array.from(re.values()).sort((Ue,Be)=>{const ve=Number.isFinite(Date.parse(Ue.createdAt))?Date.parse(Ue.createdAt):0;return(Number.isFinite(Date.parse(Be.createdAt))?Date.parse(Be.createdAt):0)-ve});De.current.set(C,Fe)},[]),jt=y.useCallback((C,_,z)=>{if(!C)return;const he=it.current.get(C),te=z==="replace"||!he?new Map:new Map(he);if(_&&typeof _=="object")for(const[re,Fe]of Object.entries(_)){if(!(Fe!=null&&Fe.checkpointId))continue;const Ue=re||$o(Fe.checkpointId,Fe.checkpointNs??null);te.set(Ue,Fe)}it.current.set(C,te)},[]),dn=y.useCallback((C,_)=>{const{threadId:z,checkpointId:he=null,checkpointNs:te=null}=C,re=gx(z,he,te);if(_!=null&&_.force)vt.current.delete(re);else{const Be=vt.current.get(re);if(Be)return Be}const Ue=l.getStateHistory({threadId:z,checkpointId:he??void 0,checkpointNs:te??void 0}).finally(()=>{vt.current.get(re)===Ue&&vt.current.delete(re)});return vt.current.set(re,Ue),Ue},[l]),In=y.useCallback((C,_)=>new Promise((z,he)=>{const te=async()=>{xt.current=!0;try{await C(),z()}catch(re){he(re)}finally{xt.current=!1;const re=J.current.shift();re&&re().catch(()=>{})}};xt.current?J.current.push(te):te().catch(re=>{he(re)})}),[]),Hr=y.useRef(E.length),[oi,Sr]=y.useState(!1),Zn=y.useRef(!1);y.useEffect(()=>{Hr.current=E.length},[E.length]),y.useEffect(()=>{const C=me.pendingInterrupt??vx(me.messages);xx(B,C)||F(C??null)},[B,me.messages,me.pendingInterrupt]);const bt=y.useCallback(async()=>{const C=Hr.current>0;C||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{k(z=>{const he=Fe=>Fe.map(Ue=>`${Ue.threadId}:${Ue.updatedAt??""}:${Ue.messageCount??""}`).join("|"),te=Oi(z);return he(te)===he(_)||_.length===0&&te.length>0&&!Zn.current?z:Bo(_)})}),G(null),Zn.current||(Zn.current=!0,Sr(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),G(String(_))}finally{C||L(!1)}},[l,i]),Dn=y.useRef(!1),Ln=y.useRef(null),St=y.useRef(null),En=y.useRef(""),Nn=y.useCallback((C,_)=>{if(!Er())return;St.current!==null&&(window.clearTimeout(St.current),St.current=null);const z=C.map(te=>`${te.threadId}:${te.updatedAt??""}:${te.messageCount??""}`).join("|");if(C.length===0){try{_i(S)}catch{}En.current="";return}if(z===En.current)return;const he=()=>{try{const te=C.slice(0,Ni);Ri(S,te),En.current=z}catch{}finally{St.current=null}};if(_!=null&&_.immediate){he();return}St.current=window.setTimeout(()=>{jc(he)},Fo)},[S]),Ur=y.useCallback(()=>{Nn(E,{immediate:!0})},[Nn,E]),qt=y.useCallback((C,_,z,he)=>{const te=Array.isArray(C==null?void 0:C.messages)?C.messages:[],re=z??(C==null?void 0:C.threadId)??Ve.current,Fe=re!=null&&re===Ve.current,Ue=(C==null?void 0:C.pendingInterrupt)??null,Be=(he==null?void 0:he.persist)!==!1;if(_==="replace"){if(Be&&re){const ve={threadId:re,messages:te.slice(),hasMore:!!(C!=null&&C.hasMore),nextCursor:(C==null?void 0:C.nextCursor)??null,checkpointId:(C==null?void 0:C.checkpointId)??null,checkpointNs:(C==null?void 0:C.checkpointNs)??null,nextCursorNs:(C==null?void 0:C.nextCursorNs)??null,pendingInterrupt:Ue};Ce.current.set(re,ve),xe.current=re}if(!Fe)return;tt(te,{checkpointId:(C==null?void 0:C.checkpointId)??null,checkpointNs:(C==null?void 0:C.checkpointNs)??null,pendingInterrupt:Ue}),F(Ue??null)}else if(_==="prepend"&&te.length&&re){const ve=Ce.current.get(re),Pt=(ve==null?void 0:ve.messages)??[],hn=new Set,en=[...te,...Pt].filter(Cr=>{const nr=Cr==null?void 0:Cr.id;return nr?hn.has(nr)?!1:(hn.add(nr),!0):!0}),tr={threadId:re,messages:en,hasMore:(C==null?void 0:C.hasMore)??(ve==null?void 0:ve.hasMore)??!1,nextCursor:(C==null?void 0:C.nextCursor)??(ve==null?void 0:ve.nextCursor)??null,checkpointId:(ve==null?void 0:ve.checkpointId)??(C==null?void 0:C.checkpointId)??null,checkpointNs:(ve==null?void 0:ve.checkpointNs)??(C==null?void 0:C.checkpointNs)??null,nextCursorNs:(C==null?void 0:C.nextCursorNs)??(ve==null?void 0:ve.nextCursorNs)??null,pendingInterrupt:(ve==null?void 0:ve.pendingInterrupt)??Ue??null};if(Ce.current.set(re,tr),!Fe)return;Oe(te)}else _==="prepend"&&te.length&&Oe(te);Fe&&(_==="replace"?(Se((C==null?void 0:C.nextCursor)??null),Q(!!(C!=null&&C.hasMore)),O((C==null?void 0:C.checkpointId)??void 0),ee((C==null?void 0:C.checkpointNs)??void 0),oe((C==null?void 0:C.nextCursorNs)??void 0)):(Se(ve=>(C==null?void 0:C.nextCursor)??ve??null),Q(ve=>(C==null?void 0:C.hasMore)!==void 0?!!(C!=null&&C.hasMore):ve),O(ve=>(C==null?void 0:C.checkpointId)??ve??void 0),ee(ve=>(C==null?void 0:C.checkpointNs)??ve??void 0),oe(ve=>(C==null?void 0:C.nextCursorNs)!==void 0?C.nextCursorNs??void 0:ve)))},[Oe,tt,F]),Qn=y.useCallback(C=>{C.threadId!=null&&C.threadId!==Ve.current||(tt(C.messages,{checkpointId:C.checkpointId,checkpointNs:C.checkpointNs,pendingInterrupt:C.pendingInterrupt??null}),F(C.pendingInterrupt??null),Se(C.nextCursor),Q(C.hasMore),O(C.checkpointId??void 0),ee(C.checkpointNs??void 0),oe(C.nextCursorNs??void 0),xe.current=C.threadId)},[tt,F]),An=y.useCallback(C=>{C&&(Ce.current.delete(C),v(C),De.current.delete(C),it.current.delete(C),xe.current===C&&(xe.current=null))},[v]),_n=y.useCallback(()=>{const C=Ve.current;C&&An(C),rt([]),Q(!1),we(!1),Se(null),O(void 0),ee(void 0),oe(void 0)},[An,rt]),er=y.useCallback(({from:C,to:_})=>{const z=Ve.current;z&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${C} -> ${_}) for thread ${z}`)},[]),le=y.useCallback(C=>{const _=C.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:C.title,created:C.created,currentThreads:E.length});const z={threadId:_,title:C.title||`Thread ${_.slice(0,8)}`,createdAt:C.createdAt||new Date().toISOString(),updatedAt:C.updatedAt||new Date().toISOString(),messageCount:C.messageCount||0};Ve.current!==_&&(!Ve.current&&me.messages.length<=1&&(ge.current=_),j(_)),y.startTransition(()=>{k(he=>{const te=he.byId[_];return te?te.title===z.title&&te.updatedAt===z.updatedAt&&te.messageCount===z.messageCount?he:{byId:{...he.byId,[_]:z},order:he.order}:{byId:{...he.byId,[_]:z},order:[_,...he.order]}})})},[me.messages.length]),{startStream:Ie,stop:Ke,isStreaming:nt,error:Dt,setAuthToken:I}=fx({baseUrl:d,onThreadInfo:le,onMessageEvent:ut,onUnhandledEvent:C=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${C.type}`,C)},onSequenceGap:er});y.useEffect(()=>{Dn.current=nt},[nt]),y.useEffect(()=>{if(!Er())return;St.current!==null&&(window.clearTimeout(St.current),St.current=null);const C=E.map(z=>`${z.threadId}:${z.updatedAt??""}:${z.messageCount??""}`).join("|");if(E.length===0){try{_i(S)}catch{}En.current="";return}if(C===En.current)return;const _=()=>{try{const z=E.slice(0,Ni);Ri(S,z),En.current=C}catch{}finally{St.current=null}};return St.current=window.setTimeout(()=>{jc(_),St.current=null},Fo),()=>{St.current!==null&&(window.clearTimeout(St.current),St.current=null)}},[E,Nn]),y.useEffect(()=>{var he;const C=l.getAuthToken();I(C);const _=te=>{const re=ji(f,te);at.current!==re&&(at.current=re,Me.current=!1),N(re);const Fe=Pi(re);y.startTransition(()=>{k(Bo(Fe))}),Me.current||(Me.current=!0,bt().catch(()=>{}))};_(C);const z=(he=l.onTokenChange)==null?void 0:he.call(l,te=>{I(te),w(),_(te)});return()=>{z==null||z()}},[l,f,I,w,bt]);const H=y.useCallback(async C=>{var he;const _=`Thread ${(he=crypto.randomUUID)==null?void 0:he.call(crypto)}`,z={threadId:_,title:C||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(te=>({byId:{...te.byId,[_]:z},order:[_,...te.order]})),j(_);try{const te=await l.createThread(C),re=typeof te=="string"?te:te.threadId;return k(Fe=>{const Ue=Fe.byId[_];if(!Ue)return Fe;const Be={...Fe.byId};delete Be[_],Be[re]={...Ue,threadId:re};const ve=Fe.order.map(Pt=>Pt===_?re:Pt);return{byId:Be,order:ve}}),j(re),setTimeout(()=>bt(),10),G(null),re}catch(te){throw k(re=>{if(!re.byId[_])return re;const Fe={...re.byId};delete Fe[_];const Ue=re.order.filter(Be=>Be!==_);return{byId:Fe,order:Ue}}),j(null),G(String(te)),te}},[l,bt]),ne=y.useCallback(async C=>{try{await l.deleteThread(C);let _=null;k(z=>{if(!z.byId[C])return z;const he={...z.byId};delete he[C];const te=z.order.filter(Fe=>Fe!==C),re={byId:he,order:te};return _=Oi(re),re}),_&&Nn(_,{immediate:!0}),An(C),Ve.current===C&&(ge.current=C,j(null),Ve.current=null,xe.current=null,_n()),await bt(),G(null)}catch(_){throw G(String(_)),_}},[l,_n,An,bt,Nn]),Ee=y.useCallback(async(C,_)=>{try{await l.updateThread(C,_),k(z=>{const he=z.byId[C];return he?{byId:{...z.byId,[C]:{...he,title:_}},order:z.order}:z}),G(null)}catch(z){throw await bt(),G(String(z)),z}},[l,bt]),_e=y.useCallback(async(C,_,z,he=!1)=>{await In(async()=>{if(ge.current===C&&!he){ge.current=null;return}if(se.current===C&&!he)return;j(Be=>Be===C?Be:C),Ve.current=C;const te=!he&&!_&&!z;let re=!1;if(te){const Be=Ce.current.get(C);if(Be)Qn(Be),re=!0;else{const ve=x(C);ve&&(Ce.current.set(C,ve),Qn(ve),re=!0)}}const Fe=he||!re||!!_||!!z,Ue=async Be=>{Be&&V(!0),se.current=C;try{const ve=await dn({threadId:C,checkpointId:_,checkpointNs:z},{force:he}),{payload:Pt,checkpoints:hn,snapshots:en}=ki(ve);qt(Pt,"replace",C),_t(C,hn,"replace"),jt(C,en,"replace"),W(null)}catch(ve){throw(!re||he||Be)&&(i==null||i(String(ve))),W(String(ve)),ve}finally{se.current=null,Be&&V(!1)}};Fe?await Ue(!0):te&&re&&Ue(!1).catch(Be=>{console.warn("[ChatSessionProvider] Background refresh failed:",Be)})},`loadThread-${C}`)},[Qn,qt,In,dn,i,_t,jt]),Xe=y.useCallback(async()=>{await In(async()=>{const C=Ve.current;C&&An(C),ge.current=null,j(null),Ve.current=null,xe.current=null,_n(),O(void 0),ee(void 0),oe(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[_n,An,In]),qe=y.useCallback(async C=>{const _=De.current.get(C);if(_)return{threadId:C,checkpoints:_.slice()};const z=await dn({threadId:C}),{checkpoints:he,snapshots:te}=ki(z);_t(C,he,"replace"),jt(C,te,"replace");const re=De.current.get(C)??[];return{threadId:C,checkpoints:re.slice()}},[dn,_t,jt]),He=y.useCallback(async(C,_)=>{var re;const z=Ve.current;if(!z)throw new Error("No active thread");const he=$o(C,_??null),te=(re=it.current.get(z))==null?void 0:re.get(he);if(te){await In(async()=>{qt({threadId:z,checkpointId:te.checkpointId??void 0,checkpointNs:te.checkpointNs??void 0,messages:te.messages??[],hasMore:!!te.nextCursor,nextCursor:te.nextCursor??null,nextCursorNs:te.nextCursorNs??null,pendingInterrupt:te.interrupt??null},"replace",z,{persist:!1})},`navigateToCheckpoint-${z}-${he}`);return}await _e(z,C,_??void 0,!0)},[qt,In,_e]),Tt=y.useCallback(async()=>{if(!Ve.current)throw new Error("No active thread");await _e(Ve.current,void 0,void 0,!0)},[_e]),ft=y.useCallback(async()=>{if(!Ve.current)throw new Error("No active thread");if(fe||!D)return;const C=ye;if(C){we(!0);try{const _=Ve.current,z=await dn({threadId:_,checkpointId:C??q??null,checkpointNs:pe??X??null}),{payload:he,checkpoints:te,snapshots:re}=ki(z);qt(he,"prepend",_??void 0),_&&(_t(_,te,"prepend"),jt(_,re,"prepend")),W(null)}catch(_){throw W(String(_)),_}finally{we(!1)}}},[qt,dn,D,q,X,pe,ye,fe,_t,jt]),pt=y.useCallback(C=>{if(!(C!=null&&C.threadId))return;const _={threadId:C.threadId,checkpointId:C.checkpointId??void 0,checkpointNs:C.checkpointNs??void 0,messages:C.messages??[],hasMore:C.hasMore,nextCursor:C.nextCursor??null,nextCursorNs:C.nextCursorNs??null,pendingInterrupt:C.pendingInterrupt??null};if(C.checkpointId){const z=$o(C.checkpointId,C.checkpointNs??null);jt(C.threadId,{[z]:{messages:C.messages??[],checkpointId:C.checkpointId??null,checkpointNs:C.checkpointNs??null,nextCursor:C.nextCursor??null,nextCursorNs:C.nextCursorNs??null,interrupt:C.pendingInterrupt??null}},"prepend")}qt(_,"replace",C.threadId)},[qt,jt]),Lt=y.useCallback(async(C,_)=>{var ii;const z=Ve.current,he=(C==null?void 0:C.text)??"",te=(C==null?void 0:C.attachments)??[],re=te.length?te:(_==null?void 0:_.attachments)??[],Fe={...(_==null?void 0:_.payloadExtras)??{},...(C==null?void 0:C.payload)??{}};if(!z&&!Object.keys(Fe).length&&re.length===0&&!he.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!z&&!Fe.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:Ue,filesInfo:Be}=await Ug(l,re),ve=[...Ue];he&&he.trim()&&ve.push({type:"text",text:he.trim()});const Pt=!!z,hn=Pt?(_==null?void 0:_.checkpointId)??me.lastCheckpointId??void 0:void 0,en=Pt?(_==null?void 0:_.checkpointNs)??me.lastCheckpointNs??void 0:void 0,tr={id:((ii=crypto.randomUUID)==null?void 0:ii.call(crypto))||`user-${Date.now()}`,role:"user",content:ve,createdAt:new Date().toISOString(),...hn!=null?{checkpointId:hn}:{},...en!=null?{checkpointNs:en}:{}};ve.length>0&&We(tr);const Cr={...tr,content:ve},nr=re.length>0,si={...z?{threadId:z}:{},payload:{messages:ve.length>0?[Cr]:[],files_info:Be,...o&&nr&&s?{active_agent:s}:{},...Fe},...hn!=null?{checkpointId:hn}:{},...en!=null?{checkpointNs:en}:{},nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};Ie(si,{onError:$n=>{console.warn("[ChatSessionProvider] Stream error:",$n)},onOpen:({threadId:$n})=>{!Ve.current&&$n&&(me.messages.length<=1&&(ge.current=$n),j($n))},onGap:er})},[l,o,s,er,me.lastCheckpointId,me.lastCheckpointNs,me.messages.length,We,Ie]),fn=y.useCallback(async(C,_,z)=>{var te,re;const he=Ve.current;if(!he)throw new Error("No active thread to handle interrupt");try{const Fe=_?z??!0:!1;try{et({type:"interrupt_response",payload:{interruptId:C}})}catch(tr){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",tr)}const Ue=`${d}/runs/resume`,Be=(te=l.getAuthToken)==null?void 0:te.call(l),ve=await fetch(Ue,{method:"POST",headers:{"Content-Type":"application/json",...Be?{Authorization:`Bearer ${Be}`}:{}},body:JSON.stringify({thread_id:he,value:Fe})});if(!ve.ok)throw new Error(`Resume failed with status ${ve.status}`);const Pt=(re=ve.body)==null?void 0:re.getReader();if(!Pt)throw new Error("No response body for resume stream");const hn=new TextDecoder;let en="";for(;;){const{done:tr,value:Cr}=await Pt.read();if(tr)break;en+=hn.decode(Cr,{stream:!0});const nr=en.split(`
39
- `);en=nr.pop()||"";for(const si of nr)if(si.startsWith("data: ")){const ii=si.slice(6);try{const $n=JSON.parse(ii);et({type:"event",payload:{ev:$n}})}catch($n){console.warn("[ChatSessionProvider] Failed to parse resume SSE event:",$n)}}}F(null)}catch(Fe){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${C}:`,Fe),Fe}},[l,et,d]),jn=y.useCallback(C=>fn(C.interruptId,C.approved,C.value),[fn]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(C){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",C)}},[A,a]),y.useEffect(()=>((async()=>{try{if(bt().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(j(_),n&&await _e(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await _e(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{var te,re,Fe,Ue;const C=Ve.current;if(!C||xe.current!==C)return;const _={threadId:C,messages:me.messages.slice(),hasMore:D,nextCursor:ye,checkpointId:me.lastCheckpointId??null,checkpointNs:me.lastCheckpointNs??null,nextCursorNs:pe??null,pendingInterrupt:me.pendingInterrupt??B??null},z=Ce.current.get(C);(!z||z.messages.length!==_.messages.length||z.messages.some((Be,ve)=>{var Pt;return(Be==null?void 0:Be.id)!==((Pt=_.messages[ve])==null?void 0:Pt.id)})||(z==null?void 0:z.hasMore)!==_.hasMore||(z==null?void 0:z.nextCursor)!==_.nextCursor||(z==null?void 0:z.nextCursorNs)!==_.nextCursorNs||(z==null?void 0:z.checkpointId)!==_.checkpointId||(z==null?void 0:z.checkpointNs)!==_.checkpointNs||(((te=z==null?void 0:z.pendingInterrupt)==null?void 0:te.id)??null)!==(((re=_.pendingInterrupt)==null?void 0:re.id)??null)||JSON.stringify((Fe=z==null?void 0:z.pendingInterrupt)==null?void 0:Fe.value)!==JSON.stringify((Ue=_.pendingInterrupt)==null?void 0:Ue.value))&&(Ce.current.set(C,_),Ln.current&&window.clearTimeout(Ln.current),Ln.current=window.setTimeout(()=>{try{g(_,100)}catch(Be){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Be)}},Fo))},[D,ye,pe,me.lastCheckpointId,me.lastCheckpointNs,me.messages,me.pendingInterrupt,B]);const Rt=y.useMemo(()=>({threads:E,currentThreadId:A,setCurrentThreadId:j,isLoading:P,error:M,actions:{createThread:H,deleteThread:ne,renameThread:Ee,refreshThreads:()=>bt()},persistThreadsCache:Ur,hydrateFromCache:ue}),[E,A,P,M,H,ne,Ee,bt,Ur,ue,j]),To=y.useMemo(()=>{const C=me.lastBranch??null,_=me.assemblingId??null,z=C||_?{branchLabel:(C==null?void 0:C.branchLabel)??null,lastBranch:C,assemblingMessageId:_}:null;return{threadId:A,messages:me.messages,interrupt:B,checkpoint:{id:me.lastCheckpointId??null,namespace:me.lastCheckpointNs??null},metadata:z,isLoading:$,isHistoryLoading:fe,error:K,hasMore:D,loadOlder:ft,seedFromSnapshot:pt,clearState:_n,listCheckpoints:qe,navigateToCheckpoint:He,returnToLatest:Tt,loadThread:_e,clearThread:Xe,respondToInterrupt:fn}},[Xe,_n,A,B,D,fe,$,qe,ft,_e,me.assemblingId,me.lastBranch,me.lastCheckpointId,me.lastCheckpointNs,me.messages,He,fn,Tt,pt,K]),gl=y.useMemo(()=>({isStreaming:nt,error:Dt,submit:Lt,stop:Ke,resume:jn,setAuthToken:I}),[nt,Dt,Lt,Ke,jn,I]);return c.jsx(hx.Provider,{value:!0,children:c.jsx(_c.Provider,{value:gl,children:c.jsx(Nc.Provider,{value:Rt,children:c.jsx(Ac.Provider,{value:To,children:e})})})})}function zo(){const e=y.useContext(Nc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Ho(){const e=y.useContext(Ac);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Pc(){const e=y.useContext(_c);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Uo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(zg,{apiConfig:t,children:c.jsx(Sx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Z(...e){return gm.twMerge(mm.clsx(e))}const Cx=ko.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"}}),Je=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?rr.Slot:"button";return c.jsx(i,{className:Z(Cx({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";const Oc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Z("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}));Oc.displayName="Textarea";function Tx({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=y.useState(e),[b,x]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const v=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{v()},[v]);const w=y.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||x(()=>{try{const P=i(j);P&&typeof P.then=="function"?P.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),N=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),w()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[w,t,a]),E=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void w(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Oc,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:E,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Je,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ie.Square,{size:16})}):c.jsx(Je,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:c.jsx(ie.Send,{size:16})})})]})})}const kx=y.memo(Tx),Wo=0,Bn=1,Nr=2,Mc=4;function Dc(e){return()=>e}function Ix(e){e()}function Lc(e,t){return n=>e(t(n))}function $c(e,t){return()=>e(t)}function Ex(e,t){return n=>e(t,n)}function Mi(e){return e!==void 0}function Nx(...e){return()=>{e.map(Ix)}}function Ar(){}function Vo(e,t){return t(e),e}function Ax(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(Bn,t)}function $e(e,t){e(Wo,t)}function Di(e){e(Nr)}function gt(e){return e(Mc)}function be(e,t){return Qe(e,Ex(t,Wo))}function on(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Fc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Bc(e,t){return e===t}function ct(e=Bc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function ae(e){return t=>Lc(t,e)}function mn(e){return t=>()=>{t(e)}}function U(e,...t){const n=_x(...t);return(r,o)=>{switch(r){case Nr:Di(e);return;case Bn:return Qe(e,n(o))}}}function gn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function ze(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function _x(...e){return t=>e.reduceRight(Ax,t)}function jx(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Ar);case Nr:r(),n=null;return}}}function Y(e){let t=e;const n=Ye();return(r,o)=>{switch(r){case Wo:t=o;break;case Bn:{o(t);break}case Mc:return t}return n(r,o)}}function Et(e,t){return Vo(Y(t),n=>be(e,n))}function Ye(){const e=[];return(t,n)=>{switch(t){case Wo:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ht(e){return Vo(Ye(),t=>be(e,t))}function Ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Rx(),singleton:n}}const Rx=()=>Symbol();function Px(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 wt(...e){const t=Ye(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{n[i]=l,r=r|a,r===o&&$e(t,n)})}),function(s,i){switch(s){case Nr:{Di(t);return}case Bn:return r===o&&i(n),Qe(t,i)}}}function Ne(e,t=Bc){return U(e,ct(t))}function Li(...e){return function(t,n){switch(t){case Nr:return;case Bn:return Nx(...e.map(r=>Qe(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const Ox={0:"debug",3:"error",1:"log",2:"warn"},Mx=()=>typeof globalThis>"u"?window:globalThis,zn=Ze(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=Mx().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[Ox[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return $i(e,t,n).callbackRef}function $i(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.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 Dx(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Lx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let b;p&&(b=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:v}),s==null||s(a?zc("column-gap",getComputedStyle(d).columnGap,o):zc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return $i(u,n,l)}function Lx(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function zc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Hc(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),b=u.top-p.top;h=p.height-Math.max(0,b),f=b+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$i(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Ot=Ze(()=>{const e=Ye(),t=Ye(),n=Y(0),r=Ye(),o=Y(0),s=Ye(),i=Ye(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=Ye(),h=Ye(),p=Y(!1),b=Y(!1),x=Y(!1);return be(U(e,ae(({scrollTop:g})=>g)),t),be(U(e,ae(({scrollHeight:g})=>g)),i),be(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Zr={lvl:0};function Uc(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===Zr}function Qr(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?Qr(e.l,t):Qr(e.r,t)}function sn(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=sn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return sn(e.l,t,n)}function Ut(e,t,n){return ot(e)?Kc(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?qc(yt(e,{l:Ut(e.l,t,n)})):qc(yt(e,{r:Ut(e.r,t,n)}))}function _r(){return Zr}function Ko(e,t,n){if(ot(e))return[];const r=sn(e,t)[0];return $x(Bi(e,r,n))}function Fi(e,t){if(ot(e))return Zr;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Vc(r);return qo(yt(e,{k:s,l:Wc(r),v:i}))}}else return t<n?qo(yt(e,{l:Fi(r,t)})):qo(yt(e,{r:Fi(o,t)}))}function cr(e){return ot(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function Bi(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Bi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Bi(s,t,n))),a}function qo(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(zi(t))return Gc(yt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(zi(e))return Hi(yt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=zi(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Hi(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return Kc(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 Wc(e){return ot(e.r)?e.l:qo(yt(e,{r:Wc(e.r)}))}function zi(e){return ot(e)||e.lvl>e.r.lvl}function Vc(e){return ot(e.r)?[e.k,e.v]:Vc(e.r)}function Kc(e,t,n,r=Zr,o=Zr){return{k:e,l:r,lvl:n,r:o,v:t}}function qc(e){return Hi(Gc(e))}function Gc(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Hi(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function $x(e){return Uc(e,({k:t,v:n})=>({index:t,value:n}))}function Yc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function eo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ui=Ze(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function Xc(e,t,n){return e[Go(e,t,n)]}function Go(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 Fx(e,t,n,r){const o=Go(e,t,r),s=Go(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Yo(e){return!ot(e.groupOffsetTree)}function Wi({index:e},t){return t===e?0:t<e?-1:1}function Bx(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function zx(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Ut(e,0,s);continue}const a=Ko(e,i-1,o+1);if(a.some(Gx(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Fi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ut(e,o+1,h));u&&(e=Ut(e,i,s))}return[e,n]}function Hx(e){return typeof e.groupIndex<"u"}function Ux({offset:e},t){return t===e?0:t<e?-1:1}function to(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Xc(t,e,Wi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Jc(e,t){if(!Yo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Zc(e,t,n){if(Hx(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Jc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Wx(e,t,n,r=0){return r>0&&(t=Math.max(t,Xc(e,r,Wi).offset)),Uc(Fx(e,t,n,Ux),qx)}function Vx(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((b,x)=>Ut(Ut(b,x,h),x+1,p),i)}else[i,a]=zx(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Vi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ut(h,p,to(p,f,o)),_r()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Kx(e){return cr(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 Qc(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 Vi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Go(o,t-1,Wi),a=o[l].offset;const u=sn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===sn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of Ko(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function qx(e){return{index:e.index,value:e}}function Gx(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 Yx={offsetHeight:"height",offsetWidth:"width"},xn=Ze(([{log:e},{recalcInProgress:t}])=>{const n=Ye(),r=Ye(),o=Et(r,0),s=Ye(),i=Ye(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((T,k)=>Hn(T,Yx[k])),h=Y(void 0),p=Y(0),b=Bx(),x=Et(U(n,ze(l,e,p),gn(Vx,b),ct()),b),g=Et(U(l,ct(),gn((T,k)=>({current:k,prev:T.current}),{current:[],prev:[]}),ae(({prev:T})=>T)),[]);be(U(l,Ae(T=>T.length>0),ze(x,p),ae(([T,k,E])=>{const A=T.reduce((j,P,L)=>Ut(j,P,to(P,k.offsetTree,E)||L),_r());return{...k,groupIndices:T,groupOffsetTree:A}})),x),be(U(r,ze(x),Ae(([T,{lastIndex:k}])=>T<k),ae(([T,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:T}])),n),be(u,d);const v=Et(U(u,ae(T=>T===void 0)),!0);be(U(d,Ae(T=>T!==void 0&&ot(gt(x).sizeTree)),ae(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Ht(U(n,ze(x),gn(({sizes:T},[k,E])=>({changed:E!==T,sizes:E}),{changed:!1,sizes:b}),ae(T=>T.changed)));Qe(U(a,gn((T,k)=>({diff:T.prev-k,prev:k}),{diff:0,prev:0}),ae(T=>T.diff)),T=>{const{groupIndices:k}=gt(x);if(T>0)$e(t,!0),$e(s,T+Qc(T,k));else if(T<0){const E=gt(g);E.length>0&&(T-=Qc(-T,E)),$e(i,T)}}),Qe(U(a,ze(e)),([T,k])=>{T<0&&k("`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},Bt.ERROR)});const S=Ht(s);be(U(s,ze(x),ae(([T,k])=>{const E=k.groupIndices.length>0,A=[],j=k.lastSize;if(E){const P=Qr(k.sizeTree,0);let L=0,$=0;for(;L<T;){const M=k.groupIndices[$],G=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+G-1,size:j,startIndex:M+1}),$++,L+=G+1}const V=cr(k.sizeTree);return L!==T&&V.shift(),V.reduce((M,{k:G,v:K})=>{let W=M.ranges;return M.prevSize!==0&&(W=[...M.ranges,{endIndex:G+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:G+T,prevSize:K,ranges:W}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(k.sizeTree).reduce((P,{k:L,v:$})=>({prevIndex:L+T,prevSize:$,ranges:[...P.ranges,{endIndex:L+T-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const N=Ht(U(i,ze(x,p),ae(([T,{offsetTree:k},E])=>{const A=-T;return to(A,k,E)})));return be(U(i,ze(x,p),ae(([T,k,E])=>{if(k.groupIndices.length>0){if(ot(k.sizeTree))return k;let A=_r();const j=gt(g);let P=0,L=0,$=0;for(;P<-T;){$=j[L];const V=j[L+1]-$-1;L++,P+=V+1}if(A=cr(k.sizeTree).reduce((V,{k:M,v:G})=>Ut(V,Math.max(0,M+T),G),A),P!==-T){const V=Qr(k.sizeTree,$);A=Ut(A,0,V);const M=sn(k.sizeTree,-T+1)[1];A=Ut(A,1,M)}return{...k,sizeTree:A,...Vi(k.offsetTree,0,A,E)}}else{const A=cr(k.sizeTree).reduce((j,{k:P,v:L})=>Ut(j,Math.max(0,P+T),L),_r());return{...k,sizeTree:A,...Vi(k.offsetTree,0,A,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},lt(zn,Ui),{singleton:!0});function Xx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const eu=Ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ye(),i=Ye(),a=Ht(U(s,ae(Xx)));return be(U(a,ae(l=>l.totalCount)),n),be(U(a,ae(l=>l.groupIndices)),e),be(U(wt(o,t,r),Ae(([l,u])=>Yo(u)),ae(([l,u,d])=>sn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),ae(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(xn,Ot)),Un=Ze(([{log:e}])=>{const t=Y(!1),n=Ht(U(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&gt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},lt(zn),{singleton:!0}),Jx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function tu(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Jx)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const no=Ze(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ye(),b=Ye(),x=Y(0);let g=null,v=null,w=null;function S(){g&&(g(),g=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),$e(l,!1)}return be(U(p,ze(n,f,r,x,a,i,h),ze(e,s,o),ae(([[N,T,k,E,A,j,P,L],$,V,M])=>{const G=tu(N),{align:K,behavior:W,offset:B}=G,F=E-1,ue=Zc(G,T,F);let D=to(ue,T.offsetTree,$)+j;K==="end"?(D+=V+sn(T.sizeTree,ue)[1]-k+M,ue===F&&(D+=P)):K==="center"?D+=(V+sn(T.sizeTree,ue)[1]-k+M)/2:D-=A,B&&(D+=B);const Q=fe=>{S(),fe?(L("retrying to scroll to",{location:N},Bt.DEBUG),$e(p,N)):($e(b,!0),L("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),W==="smooth"){let fe=!1;w=Qe(t,we=>{fe=fe||we}),g=on(d,()=>{Q(fe)})}else g=on(U(t,Zx(150)),Q);return v=setTimeout(()=>{S()},1200),$e(l,!0),L("scrolling from index to",{behavior:W,index:ue,top:D},Bt.DEBUG),{behavior:W,top:D}})),u),{scrollTargetReached:b,scrollToIndex:p,topListHeight:x}},lt(xn,Ot,zn),{singleton:!0});function Zx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ki(e,t){e==0?t():requestAnimationFrame(()=>{Ki(e-1,t)})}function qi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ro=Ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),u=Y(!0);return be(U(i,ze(l),Ae(([d,f])=>!!f),mn(!1)),a),be(U(i,ze(l),Ae(([d,f])=>!!f),mn(!1)),u),Qe(U(wt(t,i),ze(a,n,e,u),Ae(([[,d],f,{sizeTree:h},p,b])=>d&&(!ot(h)||Mi(p))&&!f&&!b),ze(l)),([,d])=>{on(o,()=>{$e(u,!0)}),Ki(4,()=>{on(r,()=>{$e(a,!0)}),$e(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(xn,Ot,no,Un),{singleton:!0});function nu(e,t){return Math.abs(e-t)<1.01}const oo="up",so="down",Qx="none",ev={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},tv=0,io=Ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ye(),u=Ye(),d=Y(4),f=Y(tv),h=Et(U(Li(U(Ne(o),ar(1),mn(!0)),U(Ne(o),ar(1),mn(!1),Fc(100))),ct()),!1),p=Et(U(Li(U(n,mn(!0)),U(n,mn(!1),Fc(200))),ct()),!1);be(U(wt(Ne(o),Ne(f)),ae(([w,S])=>w<=S),ct()),a),be(U(a,Pn(50)),u);const b=Ht(U(wt(r,Ne(s),Ne(t),Ne(e),Ne(d)),gn((w,[{scrollHeight:S,scrollTop:N},T,k,E,A])=>{const j=N+T-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:T};if(j){let $,V;return N>w.state.scrollTop?($="SCROLLED_DOWN",V=w.state.scrollTop-N):($="SIZE_DECREASED",V=w.state.scrollTop-N||w.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:V,state:P}}let L;return P.scrollHeight>w.state.scrollHeight?L="SIZE_INCREASED":T<w.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<w.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},ev),ct((w,S)=>w&&w.atBottom===S.atBottom))),x=Et(U(r,gn((w,{scrollHeight:S,scrollTop:N,viewportHeight:T})=>{if(nu(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const k=S-(N+T)<1;return w.scrollTop!==N&&k?{changed:!0,jump:w.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(w=>w.changed),ae(w=>w.jump)),0);be(U(b,ae(w=>w.atBottom)),i),be(U(i,Pn(50)),l);const g=Y(so);be(U(r,ae(({scrollTop:w})=>w),ct(),gn((w,S)=>gt(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?oo:so,prevScrollTop:S},{direction:so,prevScrollTop:0}),ae(w=>w.direction)),g),be(U(r,Pn(50),mn(Qx)),g);const v=Y(0);return be(U(h,Ae(w=>!w),mn(0)),v),be(U(o,Pn(100),ze(h),Ae(([w,S])=>!!S),gn(([w,S],[N])=>[S,N],[0,0]),ae(([w,S])=>S-w)),v),{atBottomState:b,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:v}},lt(Ot)),Xo="top",Jo="bottom",ru="none";function ou(e,t,n){return typeof e=="number"?n===oo&&t===Xo||n===so&&t===Jo?e:0:n===oo?t===Xo?e.main:e.reverse:t===Jo?e.main:e.reverse}function su(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Gi=Ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ye(),i=Y(0),a=Y(0),l=Y(0),u=Et(U(wt(Ne(r),Ne(o),Ne(n),Ne(s,eo),Ne(l),Ne(i),Ne(t),Ne(e),Ne(a)),ae(([d,f,h,[p,b],x,g,v,w,S])=>{const N=d-w,T=g+v,k=Math.max(h-N,0);let E=ru;const A=su(S,Xo),j=su(S,Jo);return p-=w,p+=h+v,b+=h+v,b-=w,p>d+T-A&&(E=oo),b<d-k+f+j&&(E=so),E!==ru?[Math.max(N-h-ou(x,Xo,E)-A,0),N-k-v+f+ou(x,Jo,E)+j]:null}),Ae(d=>d!=null),ct(eo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},lt(Ot),{singleton:!0});function nv(e,t,n){if(Yo(t)){const r=Jc(e,t);return[{index:sn(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 Yi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Zo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,b=h-d;return{bottom:d,firstItemIndex:s,items:au(e,o,s),offsetBottom:b,offsetTop:u,top:p,topItems:au(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function iu(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=qi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Zo(u,[],a,o,n,r)}function au(e,t,n){if(e.length===0)return[];if(!Yo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Ko(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const ur=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:b}])=>{const x=Y([]),g=Y(0),v=Ye();be(s.topItemsIndexes,x);const w=Et(U(wt(p,b,Ne(l,eo),Ne(o),Ne(r),Ne(u),d,Ne(x),Ne(t),Ne(n),e),Ae(([k,E,,A,,,,,,,j])=>{const P=j&&j.length!==A;return k&&!E&&!P}),ae(([,,[k,E],A,j,P,L,$,V,M,G])=>{const K=j,{offsetTree:W,sizeTree:B}=K,F=gt(g);if(A===0)return{...Yi,totalCount:A};if(k===0&&E===0)return F===0?{...Yi,totalCount:A}:iu(F,P,j,V,M,G||[]);if(ot(B))return F>0?null:Zo(nv(qi(P,A),K,G),[],A,M,K,V);const ue=[];if($.length>0){const ye=$[0],Se=$[$.length-1];let q=0;for(const O of Ko(B,ye,Se)){const X=O.value,ee=Math.max(O.start,ye),pe=Math.min(O.end,Se);for(let oe=ee;oe<=pe;oe++)ue.push({data:G==null?void 0:G[oe],index:oe,offset:q,size:X}),q+=X}}if(!L)return Zo([],ue,A,M,K,V);const D=$.length>0?$[$.length-1]+1:0,Q=Wx(W,k,E,D);if(Q.length===0)return null;const fe=A-1,we=Vo([],ye=>{for(const Se of Q){const q=Se.value;let O=q.offset,X=Se.start;const ee=q.size;if(q.offset<k){X+=Math.floor((k-q.offset+M)/(ee+M));const oe=X-Se.start;O+=oe*ee+oe*M}X<D&&(O+=(D-X)*ee,X=D);const pe=Math.min(Se.end,fe);for(let oe=X;oe<=pe&&!(O>=E);oe++)ye.push({data:G==null?void 0:G[oe],index:oe,offset:O,size:ee}),O+=ee+M}});return Zo(we,ue,A,M,K,V)}),Ae(k=>k!==null),ct()),Yi);be(U(e,Ae(Mi),ae(k=>k==null?void 0:k.length)),o),be(U(w,ae(k=>k.topListHeight)),f),be(f,a),be(U(w,ae(k=>[k.top,k.bottom])),i),be(U(w,ae(k=>k.items)),v);const S=Ht(U(w,Ae(({items:k})=>k.length>0),ze(o,e),Ae(([{items:k},E])=>k[k.length-1].originalIndex===E-1),ae(([,k,E])=>[k-1,E]),ct(eo),ae(([k])=>k))),N=Ht(U(w,Pn(200),Ae(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ae(({items:k})=>k[0].index),ct())),T=Ht(U(w,Ae(({items:k})=>k.length>0),ae(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),ct(Yc)));return{endReached:S,initialItemCount:g,itemsRendered:v,listState:w,rangeChanged:T,startReached:N,topItemsIndexes:x,...h}},lt(xn,eu,Gi,ro,no,io,Un,Ui),{singleton:!0}),lu=Ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ye(),i=Et(U(wt(n,e,r,t,o),ae(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return be(Ne(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Ot,ur),{singleton:!0}),rv=Ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=Et(U(wt(n,e,t),Ae(([o])=>o),ae(([,o,s])=>Math.max(0,o-s)),Pn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Ot,lu),{singleton:!0}),cu=Ze(()=>({context:Y(null)})),ov=({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,uu=Ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ye();return be(U(d,ze(t,l,n,s,o,r,a),ze(e),ae(([[f,h,p,b,x,g,v,w],S])=>{const{align:N,behavior:T,calculateViewLocation:k=ov,done:E,...A}=f,j=Zc(f,h,b-1),P=to(j,h.offsetTree,S)+x+g,L=P+sn(h.sizeTree,j)[1],$=w+g,V=w+p-v,M=k({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:T,...A},viewportBottom:V,viewportTop:$});return M?E&&on(U(i,Ae(G=>!G),ar(gt(i)?1:2)),E):E&&E(),M}),Ae(f=>f!==null)),u),{scrollIntoView:d}},lt(xn,Ot,no,ur,zn),{singleton:!0});function du(e){return e?e==="smooth"?"smooth":"auto":!1}const sv=(e,t)=>typeof e=="function"?du(e(t)):t&&du(e),iv=Ze(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const b=Y(!1),x=Ye();let g=null;function v(T){$e(i,{align:"end",behavior:T,index:"LAST"})}Qe(U(wt(U(Ne(t),ar(1)),l),ze(Ne(b),s,a,f),ae(([[T,k],E,A,j,P])=>{let L=k&&j,$="auto";return L&&($=sv(E,A||P),L=L&&!!$),{followOutputBehavior:$,shouldFollow:L,totalCount:T}}),Ae(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:k})=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(T)}):g=on(e,()=>{gt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(T),g=null})});function w(T){const k=on(o,E=>{T&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(gt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),v("auto"))});setTimeout(k,100)}Qe(U(wt(Ne(b),t,u),Ae(([T,,k])=>T&&k),gn(({value:T},[,k])=>({refreshed:T===k,value:k}),{refreshed:!1,value:0}),Ae(({refreshed:T})=>T),ze(b,t)),([,T])=>{gt(a)&&w(T!==!1)}),Qe(x,()=>{w(gt(b)!==!1)}),Qe(wt(Ne(b),o),([T,k])=>{T&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=Y(null),N=Ye();return be(Li(U(Ne(r),ae(T=>{var k;return(k=T==null?void 0:T.length)!=null?k:0})),U(Ne(t))),N),Qe(U(wt(U(N,ar(1)),l),ze(Ne(S),a,f,h),ae(([[T,k],E,A,j,P])=>k&&A&&(E==null?void 0:E({context:P,totalCount:T,scrollingInProgress:j}))),Ae(T=>!!T),Pn(0)),T=>{g&&(g(),g=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),$e(p,T)}):g=on(e,()=>{gt(d)("scrolling into view",{}),$e(p,T),g=null})}),{autoscrollToBottom:x,followOutput:b,scrollIntoViewOnChange:S}},lt(xn,io,no,ro,Un,zn,Ot,cu,uu)),av=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(U(a,ze(s),Ae(([,l])=>l!==0),ze(o,r,t,n,e),ae(([[,l],u,d,f,h,p=[]])=>iu(l,u,d,f,h,p))),i),{}),lt(xn,ro,ur,Un),{singleton:!0}),lv=Ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Qe(U(e,ze(r),Ae(([,o])=>o!==0),ae(([,o])=>({top:o}))),o=>{on(U(n,ar(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{$e(t,o)})})}),{initialScrollTop:r}},lt(Un,Ot,ur),{singleton:!0}),fu=Ze(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ye(),r=Y(!1);return be(U(e,ze(r,t,n),Ae(([o,s])=>!!s),ae(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Qe(U(wt(t,e,n),ze(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(io),{singleton:!0}),Xi=Ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ye(),r=Ye(),o=Ye(),s=Y(!1),i=Y(void 0);return be(U(wt(n,r),ae(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),be(U(t,ze(r),ae(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Ot)),cv=Ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ye(),d=Y(void 0),f=Y(null),h=Y(null);return be(a,f),be(l,h),Qe(U(u,ze(t,r,i,f,h,n)),([p,b,x,g,v,w,S])=>{const N=Kx(b.sizeTree);g&&v!==null&&w!==null&&(x=v.scrollTop-w.offsetTop),x-=S,p({ranges:N,scrollTop:x})}),be(U(d,Ae(Mi),ae(uv)),o),be(U(s,ze(d),Ae(([,p])=>p!==void 0),ct(),ae(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},lt(xn,Ot,ro,Un,Xi));function uv(e){return{align:"start",index:0,offset:e.scrollTop}}const dv=Ze(([{topItemsIndexes:e}])=>{const t=Y(0);return be(U(t,Ae(n=>n>=0),ae(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(ur));function hu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const fv=hu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),hv=Ze(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:b}])=>{const x=Ht(U(l,ze(i),gn(([,v,w,S],[{bottom:N,items:T,offsetBottom:k,totalCount:E},A])=>{const j=N+k;let P=0;return w===E&&v.length>0&&T.length>0&&(T[0].originalIndex===0&&v[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,T,E,j]},[0,[],0,0]),Ae(([v])=>v!==0),ze(r,a,n,o,p,b),Ae(([,v,w,S,,,N])=>!N&&!S&&v!==0&&w===oo),ae(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},Bt.DEBUG),v))));function g(v){v>0?($e(t,{behavior:"auto",top:-v}),$e(e,0)):($e(e,0),$e(t,{behavior:"auto",top:-v}))}return Qe(U(x,ze(e,s)),([v,w,S])=>{S&&fv()?$e(e,w-v):g(-v)}),Qe(U(wt(Et(s,!1),e,b),Ae(([v,w,S])=>!v&&!S&&w!==0),ae(([v,w])=>w),Pn(1)),g),be(U(f,ae(v=>({top:-v}))),t),Qe(U(u,ze(h,d),ae(([v,{groupIndices:w,lastSize:S,sizeTree:N},T])=>{function k(E){return E*(S+T)}if(w.length===0)return k(v);{let E=0;const A=Qr(N,0);let j=0,P=0;for(;j<v;){j++,E+=A;let L=w.length===P+1?1/0:w[P+1]-w[P]-1;j+L>v&&(E-=A,L=v-j+1),j+=L,E+=k(L),P++}return E}})),v=>{$e(e,v),requestAnimationFrame(()=>{$e(t,{top:v}),requestAnimationFrame(()=>{$e(e,0),$e(b,!1)})})}),{deviation:e}},lt(Ot,io,ur,xn,zn,Ui)),pv=Ze(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),lt(Gi,av,Un,fu,lu,lv,rv,Xi,uu,zn,cu)),pu=Ze(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:b},x,g,v,{listState:w,topItemsIndexes:S,...N},{scrollToIndex:T},k,{topItemCount:E},{groupCounts:A},j])=>(be(N.rangeChanged,j.scrollSeekRangeChanged),be(U(j.windowViewportRect,ae(P=>P.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:b,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...v,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:u,trackItemSizes:f,...N,...j,...x,sizes:l,...g}),lt(xn,ro,Ot,cv,iv,ur,no,hv,dv,eu,pv));function mv(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 Qo=typeof document<"u"?y.useLayoutEffect:y.useEffect;function mu(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=y.createContext({});function l(g,v){g.propsReady&&$e(g.propsReady,!1);for(const w of r){const S=g[t.required[w]];$e(S,v[w])}for(const w of o)if(w in v){const S=g[t.optional[w]];$e(S,v[w])}g.propsReady&&$e(g.propsReady,!0)}function u(g){return s.reduce((v,w)=>(v[w]=S=>{const N=g[t.methods[w]];$e(N,S)},v),{})}function d(g){return i.reduce((v,w)=>(v[w]=jx(g[t.events[w]]),v),{})}const f=y.forwardRef((g,v)=>{const{children:w,...S}=g,[N]=y.useState(()=>Vo(Px(e),E=>{l(E,S)})),[T]=y.useState($c(d,N));Qo(()=>{for(const E of i)E in S&&Qe(T[E],S[E]);return()=>{Object.values(T).map(Di)}},[S,T,N]),Qo(()=>{l(N,S)}),y.useImperativeHandle(v,Dc(u(N)));const k=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(k,{...mv([...r,...o,...i],S),children:w}):w})}),h=g=>{const v=y.useContext(a);return y.useCallback(w=>{$e(v[g],w)},[v,g])},p=g=>{const v=y.useContext(a)[g],w=y.useCallback(S=>Qe(v,S),[v]);return y.useSyncExternalStore(w,()=>gt(v),()=>gt(v))},b=g=>{const v=y.useContext(a)[g],[w,S]=y.useState($c(gt,v));return Qo(()=>Qe(v,N=>{N!==w&&S(Dc(N))}),[v,w]),w},x=y.version.startsWith("18")?p:b;return{Component:f,useEmitter:(g,v)=>{const w=y.useContext(a)[g];Qo(()=>Qe(w,v),[v,w])},useEmitterValue:x,usePublisher:h}}const gu=y.createContext(void 0),xu=y.createContext(void 0),vu=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Ji(e){return"self"in e}function gv(e){return"body"in e}function bu(e,t,n,r=Ar,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,b,x;const g=h.target;if(gv(g)||Ji(g)){const w=Ji(g)?g:g.defaultView;x=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:b})};h.suppressFlushSync?v():ai.flushSync(v),a.current!==null&&(x===a.current||x<=0||x===p-b)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const b=h.behavior==="smooth";let x,g,v;Ji(p)?(g=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Hn(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const w=g-x;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),nu(x,g)||h.top===v){e({scrollHeight:g,scrollTop:v,viewportHeight:x}),b&&t(!0);return}b?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Zi="-webkit-sticky",wu="sticky",Qi=hu(()=>{if(typeof document>"u")return wu;const e=document.createElement("div");return e.style.position=Zi,e.style.position===Zi?Zi:wu});function ea(e){return e}const xv=Ze(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(ea),o=Y("div"),s=Y(Ar),i=(a,l=null)=>Et(U(n,ae(u=>u[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),vv=Ze(([e,t])=>({...e,...t}),lt(pu,xv)),bv=({height:e})=>c.jsx("div",{style:{height:e}}),wv={overflowAnchor:"none",position:Qi(),zIndex:1},yu={overflowAnchor:"none"},yv={...yu,display:"inline-block",height:"100%"},Su=y.memo(function({showTopList:e=!1}){const t=Pe("listState"),n=Yt("sizeRanges"),r=Pe("useWindowScroll"),o=Pe("customScrollParent"),s=Yt("windowScrollContainerState"),i=Yt("scrollContainerState"),a=o||r?s:i,l=Pe("itemContent"),u=Pe("context"),d=Pe("groupContent"),f=Pe("trackItemSizes"),h=Pe("itemSize"),p=Pe("log"),b=Yt("gap"),x=Pe("horizontalDirection"),{callbackRef:g}=Dx(n,h,f,e?Ar:a,p,b,o,x,Pe("skipAnimationFrameInResizeObserver")),[v,w]=y.useState(0);ta("deviation",M=>{v!==M&&w(M)});const S=Pe("EmptyPlaceholder"),N=Pe("ScrollSeekPlaceholder")||bv,T=Pe("ListComponent"),k=Pe("ItemComponent"),E=Pe("GroupComponent"),A=Pe("computeItemKey"),j=Pe("isSeeking"),P=Pe("groupIndices").length>0,L=Pe("alignToBottom"),$=Pe("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:v!==0?v:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Nt(S,u)}):c.jsx(T,{...Nt(T,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(M=>{const G=M.originalIndex,K=A(G+t.firstItemIndex,M.data,u);return j?y.createElement(N,{...Nt(N,u),height:M.size,index:M.index,key:K,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(E,{...Nt(E,u),"data-index":G,"data-item-index":M.index,"data-known-size":M.size,key:K,style:wv},d(M.index,u)):y.createElement(k,{...Nt(k,u),...kv(k,M.data),"data-index":G,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:K,style:x?yv:yu},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),Sv={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Cv={outline:"none",overflowX:"auto",position:"relative"},es=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Tv={position:Qi(),top:0,width:"100%",zIndex:1};function Nt(e,t){if(typeof e!="string")return{context:t}}function kv(e,t){return{item:typeof e=="string"?void 0:t}}const Iv=y.memo(function(){const e=Pe("HeaderComponent"),t=Yt("headerHeight"),n=Pe("HeaderFooterTag"),r=lr(y.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),Ev=y.memo(function(){const e=Pe("FooterComponent"),t=Yt("footerHeight"),n=Pe("HeaderFooterTag"),r=lr(y.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null});function Cu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:b}=bu(a,u,l,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Cv:Sv,...o},tabIndex:0,...i,...Nt(l,s),children:r})})}function Tu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),b=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:v}=bu(a,u,l,b,h);return vu(()=>{var w;return g.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",v),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Nt(l,s),children:r})})}const Nv=({children:e})=>{const t=y.useContext(gu),n=Yt("viewportHeight"),r=Yt("fixedItemHeight"),o=Pe("alignToBottom"),s=Pe("horizontalDirection"),i=y.useMemo(()=>Lc(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Pe("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:es(o),children:e})},Av=({children:e})=>{const t=y.useContext(gu),n=Yt("windowViewportRect"),r=Yt("fixedItemHeight"),o=Pe("customScrollParent"),s=Hc(n,o,Pe("skipAnimationFrameInResizeObserver")),i=Pe("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:es(i),children:e})},_v=({children:e})=>{const t=Pe("TopItemListComponent")||"div",n=Pe("headerHeight"),r={...Tv,marginTop:`${n}px`},o=Pe("context");return c.jsx(t,{style:r,...Nt(t,o),children:e})},jv=y.memo(function(e){const t=Pe("useWindowScroll"),n=Pe("topItemsIndexes").length>0,r=Pe("customScrollParent"),o=Pe("context");return c.jsxs(r||t?Ov:Pv,{...e,context:o,children:[n&&c.jsx(_v,{children:c.jsx(Su,{showTopList:!0})}),c.jsxs(r||t?Av:Nv,{children:[c.jsx(Iv,{}),c.jsx(Su,{}),c.jsx(Ev,{})]})]})}),{Component:Rv,useEmitter:ta,useEmitterValue:Pe,usePublisher:Yt}=mu(vv,{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"}},jv),Pv=Cu({useEmitter:ta,useEmitterValue:Pe,usePublisher:Yt}),Ov=Tu({useEmitter:ta,useEmitterValue:Pe,usePublisher:Yt}),Mv=Rv;lt(pu,Ze(()=>{const e=Y(u=>c.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(ea),a=Y(Ar),l=(u,d=null)=>Et(U(s,ae(f=>f[u]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Qi();const ku={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dv={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Iu,floor:ts,max:ao,min:na,round:Eu}=Math;function Nu(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Lv(e){return{...Dv,items:e}}function ns(e,t){return e&&e.width===t.width&&e.height===t.height}function $v(e,t){return e&&e.column===t.column&&e.row===t.row}const Fv=Ze(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:b,propsReady:x},{customScrollParent:g,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:N},T])=>{const k=Y(0),E=Y(0),A=Y(ku),j=Y({height:0,width:0}),P=Y({height:0,width:0}),L=Ye(),$=Ye(),V=Y(0),M=Y(null),G=Y({column:0,row:0}),K=Ye(),W=Ye(),B=Y(!1),F=Y(0),ue=Y(!0),D=Y(!1),Q=Y(!1);Qe(U(b,ze(F),Ae(([O,X])=>!!X)),()=>{$e(ue,!1)}),Qe(U(wt(b,ue,P,j,F,D),Ae(([O,X,ee,pe,,oe])=>O&&!X&&ee.height!==0&&pe.height!==0&&!oe)),([,,,,O])=>{$e(D,!0),Ki(1,()=>{$e(L,O)}),on(U(u),()=>{$e(t,[0,0]),$e(ue,!0)})}),be(U(W,Ae(O=>O!=null&&O.scrollTop>0),mn(0)),E),Qe(U(b,ze(W),Ae(([,O])=>O!=null)),([,O])=>{O&&($e(j,O.viewport),$e(P,O.item),$e(G,O.gap),O.scrollTop>0&&($e(B,!0),on(U(u,ar(1)),X=>{$e(B,!1)}),$e(l,{top:O.scrollTop})))}),be(U(j,ae(({height:O})=>O)),f),be(U(wt(Ne(j,ns),Ne(P,ns),Ne(G,(O,X)=>O&&O.column===X.column&&O.row===X.row),Ne(u)),ae(([O,X,ee,pe])=>({gap:ee,item:X,scrollTop:pe,viewport:O}))),K),be(U(wt(Ne(k),r,Ne(G,$v),Ne(P,ns),Ne(j,ns),Ne(M),Ne(E),Ne(B),Ne(ue),Ne(F)),Ae(([,,,,,,,O])=>!O),ae(([O,[X,ee],pe,oe,me,et,tt,,Oe,We])=>{const{column:ut,row:rt}=pe,{height:Ve,width:xt}=oe,{width:J}=me;if(tt===0&&(O===0||J===0))return ku;if(xt===0){const vt=qi(We,O),_t=vt+Math.max(tt-1,0);return Lv(Nu(vt,_t,et))}const se=Au(J,xt,ut);let ge,Ce;Oe?X===0&&ee===0&&tt>0?(ge=0,Ce=tt-1):(ge=se*ts((X+rt)/(Ve+rt)),Ce=se*Iu((ee+rt)/(Ve+rt))-1,Ce=na(O-1,ao(Ce,se-1)),ge=na(Ce,ao(0,ge))):(ge=0,Ce=-1);const xe=Nu(ge,Ce,et),{bottom:Me,top:at}=_u(me,pe,oe,xe),De=Iu(O/se),it=De*Ve+(De-1)*rt-Me;return{bottom:Me,itemHeight:Ve,items:xe,itemWidth:xt,offsetBottom:it,offsetTop:at,top:at}})),A),be(U(M,Ae(O=>O!==null),ae(O=>O.length)),k),be(U(wt(j,P,A,G),Ae(([O,X,{items:ee}])=>ee.length>0&&X.height!==0&&O.height!==0),ae(([O,X,{items:ee},pe])=>{const{bottom:oe,top:me}=_u(O,pe,X,ee);return[me,oe]}),ct(eo)),t);const fe=Y(!1);be(U(u,ze(fe),ae(([O,X])=>X||O!==0)),fe);const we=Ht(U(wt(A,k),Ae(([{items:O}])=>O.length>0),ze(fe),Ae(([[O,X],ee])=>{const pe=O.items[O.items.length-1].index===X-1;return(ee||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===X)&&pe}),ae(([[,O]])=>O-1),ct())),ye=Ht(U(Ne(A),Ae(({items:O})=>O.length>0&&O[0].index===0),mn(0),ct())),Se=Ht(U(Ne(A),ze(B),Ae(([{items:O},X])=>O.length>0&&!X),ae(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),ct(Yc),Pn(0)));be(Se,p.scrollSeekRangeChanged),be(U(L,ze(j,P,k,G),ae(([O,X,ee,pe,oe])=>{const me=tu(O),{align:et,behavior:tt,offset:Oe}=me;let We=me.index;We==="LAST"&&(We=pe-1),We=ao(0,We,na(pe-1,We));let ut=ra(X,oe,ee,We);return et==="end"?ut=Eu(ut-X.height+ee.height):et==="center"&&(ut=Eu(ut-X.height/2+ee.height/2)),Oe&&(ut+=Oe),{behavior:tt,top:ut}})),l);const q=Et(U(A,ae(O=>O.offsetBottom+O.bottom)),0);return be(U(N,ae(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:V,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:P,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:v,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:Q,initialTopMostItemIndex:F,totalListHeight:q,...h,endReached:we,propsReady:x,rangeChanged:Se,startReached:ye,stateChanged:K,stateRestoreInProgress:B,...T}},lt(Gi,Ot,io,fu,Un,Xi,zn));function Au(e,t,n){return ao(1,ts((e+n)/(ts(t)+n)))}function _u(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ra(e,t,n,r[0].index);return{bottom:ra(e,t,n,r[r.length-1].index)+o,top:s}}function ra(e,t,n,r){const o=Au(e.width,n.width,t.column),s=ts(r/o),i=s*n.height+ao(0,s-1)*t.row;return i>0?i+t.row:i}const Bv=Ze(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(ea),i=Y("div"),a=Y(Ar),l=(f,h=null)=>Et(U(t,ae(p=>p[f]),ct()),h),u=Y(!1),d=Y(!1);return be(Ne(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),zv=Ze(([e,t])=>({...e,...t}),lt(Fv,Bv)),Hv=y.memo(function(){const e=dt("gridState"),t=dt("listClassName"),n=dt("itemClassName"),r=dt("itemContent"),o=dt("computeItemKey"),s=dt("isSeeking"),i=Xt("scrollHeight"),a=dt("ItemComponent"),l=dt("ListComponent"),u=dt("ScrollSeekPlaceholder"),d=dt("context"),f=Xt("itemDimensions"),h=Xt("gap"),p=dt("log"),b=dt("stateRestoreInProgress"),x=Xt("reportReadyState"),g=lr(y.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;i(w);const S=v.firstChild;if(S){const{height:N,width:T}=S.getBoundingClientRect();f({height:N,width:T})}h({column:Ru("column-gap",getComputedStyle(v).columnGap,p),row:Ru("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return vu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),b?null:c.jsx(l,{className:t,ref:g,...Nt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=o(v.index,v.data,d);return s?c.jsx(u,{...Nt(u,d),height:e.itemHeight,index:v.index,width:e.itemWidth},w):y.createElement(a,{...Nt(a,d),className:n,"data-index":v.index,key:w},r(v.index,v.data,d))})})}),Uv=y.memo(function(){const e=dt("HeaderComponent"),t=Xt("headerHeight"),n=dt("headerFooterTag"),r=lr(y.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),Wv=y.memo(function(){const e=dt("FooterComponent"),t=Xt("footerHeight"),n=dt("headerFooterTag"),r=lr(y.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=dt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Nt(e,o)})}):null}),Vv=({children:e})=>{const t=y.useContext(xu),n=Xt("itemDimensions"),r=Xt("viewportDimensions"),o=lr(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:es(!1),children:e})},Kv=({children:e})=>{const t=y.useContext(xu),n=Xt("windowViewportRect"),r=Xt("itemDimensions"),o=dt("customScrollParent"),s=Hc(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:es(!1),children:e})},qv=y.memo(function({...e}){const t=dt("useWindowScroll"),n=dt("customScrollParent"),r=n||t?Yv:Gv,o=n||t?Kv:Vv,s=dt("context");return c.jsx(r,{...e,...Nt(r,s),children:c.jsxs(o,{children:[c.jsx(Uv,{}),c.jsx(Hv,{}),c.jsx(Wv,{})]})})}),{useEmitter:ju,useEmitterValue:dt,usePublisher:Xt}=mu(zv,{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"}},qv),Gv=Cu({useEmitter:ju,useEmitterValue:dt,usePublisher:Xt}),Yv=Tu({useEmitter:ju,useEmitterValue:dt,usePublisher:Xt});function Ru(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Xv=ko.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 oa({className:e,variant:t,...n}){return c.jsx("div",{className:Z(Xv({variant:t}),e),...n})}function de(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 Jv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function vn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var v;const{scope:h,children:p,...b}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,g=m.useMemo(()=>b,Object.values(b));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,b=m.useContext(p);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Zv(o,...t)]}function Zv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Ct=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Qv=m[" useInsertionEffect ".trim().toString()]||Ct;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=eb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=tb(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function eb({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Qv(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function tb(e){return typeof e=="function"}function Pu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function sa(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Pu(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():Pu(e[o],null)}}}}function Ge(...e){return m.useCallback(sa(...e),e)}var nb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],je=nb.reduce((e,t)=>{const n=rr.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ou(e,t){e&&Io.flushSync(()=>e.dispatchEvent(t))}function rb(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=ob(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ge(r.ref,sb(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function ob(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=rb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=rs(r.current);s.current=a==="mounted"?u:"none"},[a]),Ct(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=rs(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Ct(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=rs(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=rs(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function rs(e){return(e==null?void 0:e.animationName)||"none"}function sb(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 ib=m[" useId ".trim().toString()]||(()=>{}),ab=0;function bn(e){const[t,n]=m.useState(ib());return Ct(()=>{n(r=>r??String(ab++))},[e]),e||(t?`radix-${t}`:"")}var os="Collapsible",[lb,VT]=vn(os),[cb,ia]=lb(os),Mu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=dr({prop:r,defaultProp:o??!1,onChange:i,caller:os});return c.jsx(cb,{scope:n,disabled:s,contentId:bn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(je.div,{"data-state":la(l),"data-disabled":s?"":void 0,...a,ref:t})})});Mu.displayName=os;var Du="CollapsibleTrigger",Lu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ia(Du,n);return c.jsx(je.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":la(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:de(e.onClick,o.onOpenToggle)})});Lu.displayName=Du;var aa="CollapsibleContent",ub=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ia(aa,e.__scopeCollapsible);return c.jsx(Wt,{present:n||o.open,children:({present:s})=>c.jsx(db,{...r,ref:t,present:s})})});ub.displayName=aa;var db=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ia(aa,n),[a,l]=m.useState(r),u=m.useRef(null),d=Ge(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),b=p.current,x=i.open||a,g=m.useRef(x),v=m.useRef(void 0);return m.useEffect(()=>{const w=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(w)},[]),Ct(()=>{const w=u.current;if(w){v.current=v.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(w.style.transitionDuration=v.current.transitionDuration,w.style.animationName=v.current.animationName),l(r)}},[i.open,r]),c.jsx(je.div,{"data-state":la(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:x&&o})});function la(e){return e?"open":"closed"}var fb=Mu;const $u=fb,Fu=Lu,lo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Z("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Z("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Z("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const Bu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Bu.displayName="CardDescription";const ss=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Z("p-6 pt-0",e),...t}));ss.displayName="CardContent";const zu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Z("flex items-center p-6 pt-0",e),...t}));zu.displayName="CardFooter";function Hu(){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 fr=Hu();function hb(e){fr=e}const Uu=/[&<>"']/,pb=new RegExp(Uu.source,"g"),Wu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,mb=new RegExp(Wu.source,"g"),gb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Vu=e=>gb[e];function At(e,t){if(t){if(Uu.test(e))return e.replace(pb,Vu)}else if(Wu.test(e))return e.replace(mb,Vu);return e}const xb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ku(e){return e.replace(xb,(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 vb=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(vb,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const bb=/[^\w:]/g,wb=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function qu(e,t,n){if(e){let r;try{r=decodeURIComponent(Ku(n)).replace(bb,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!wb.test(n)&&(n=Tb(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const is={},yb=/^[^:]+:\/*[^/]*$/,Sb=/^([^:]+:)[\s\S]*$/,Cb=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Tb(e,t){is[" "+e]||(yb.test(e)?is[" "+e]=e+"/":is[" "+e]=ls(e,"/",!0)),e=is[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(Sb,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Cb,"$1")+t:e+t}const as={exec:function(){}};function Gu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function ls(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 kb(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 Ib(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 Yu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Xu(e,t,n,r){const o=t.href,s=t.title?At(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:At(i)}}function Eb(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const ie=q.slice(0,Q);q=q.slice(Q+2);const xe=hx(ie);if(!xe)continue;let Ce;try{Ce=JSON.parse(xe)}catch{console.debug("[use-chat] malformed SSE:",xe.slice(0,200));continue}const ve=fx(Ce)?Ce.data:Ce;me=Date.now();const Oe=ve.seq;if(Oe!==void 0){if(Oe<=X){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Oe,lastProcessedSeq:X,type:ve.type});continue}X>0&&Oe>X+1&&((B=$==null?void 0:$.onGap)==null||B.call($,{from:X,to:Oe})),X=Oe,k.current=Oe,g(Oe)}if(console.debug("[use-chat] received event",{seq:ve.seq,type:ve.type,preview:(()=>{var at;try{return ve.type==="message_delta"?{deltaTypes:(at=ve.delta)==null?void 0:at.map(Me=>Me.type),textLen:(ve.delta||[]).filter(Me=>Me.type==="text").map(Me=>String(Me.text||"").length)}:ve.content||ve.delta?{hasContent:!0}:{}}catch(Me){return{err:String(Me)}}})()}),L==null||L(ve),ve.type==="token"&&e.autoAppendAssistant!==!1)O.push(ve.content),se();else if(ve.type==="message_delta"){const at=ve.delta.filter(Me=>Me.type==="text").map(Me=>Me.text).join("");at&&e.autoAppendAssistant!==!1&&(O.push(at),se())}else ve.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(ne!==null&&cancelAnimationFrame(ne),pe(),ve.type==="checkpoint"?b(ve.checkpointId):ve.type==="error"&&d(ve.message))}}pe()}catch(Pe){if(Pe.name!=="AbortError"){const Ve=Pe.message||String(Pe);d(Ve),(ue=$==null?void 0:$.onError)==null||ue.call($,Ve)}}finally{try{await ye.cancel()}catch{}finally{(D=ye.releaseLock)==null||D.call(ye)}ne!==null&&typeof window<"u"&&window.cancelAnimationFrame(ne),clearInterval(et),l(!1),w(!1),S.current=null,k.current=0,g(0)}}catch(he){if(he.name!=="AbortError"){const we=he.message||String(he);d(we),(te=$==null?void 0:$.onError)==null||te.call($,we)}}finally{l(!1),w(!1),S.current=null,k.current=0,g(0)}})(),{close:()=>V.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;N.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:v,stream:j,stop:E,clear:A,setToken:T}}function fx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function hx(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 px({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const b=p.seq??null;if(b!==null){const x=s.current;if(x!==null){if(b<=x)return;b>x+1&&(o==null||o({from:x,to:b}))}s.current=b}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(ix(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Nc({baseUrl:e,token:null}),h=y.useCallback((p,b)=>{s.current=null,a(p,i,{onOpen:b==null?void 0:b.onOpen,onError:x=>{var g;(g=b==null?void 0:b.onError)==null||g.call(b,x)},onGap:(b==null?void 0:b.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ac=y.createContext(null),_c=y.createContext(null),jc=y.createContext(null),mx=y.createContext(!1),gx="cachedThreads",xx="v1",Bo=300,Ni=200,Rc=50;function vx(e,t,n){return`${e}__${t??""}__${n??""}`}function bx(e,t){if(!e&&!t)return!0;if(!e||!t||e.id!==t.id)return!1;try{return JSON.stringify(e.value)===JSON.stringify(t.value)}catch{return e.value===t.value}}function wx(e){var t;for(let n=e.length-1;n>=0;n--){const r=((t=e[n])==null?void 0:t.content)??[];for(let o=r.length-1;o>=0;o--){const s=r[o];if((s==null?void 0:s.type)==="interrupt"){const i=s.id;return{id:(typeof i=="string"?i:null)??`interrupt-${e[n].id??o}`,value:s.value}}}}return null}function Pc(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,Bo)}function Nr(){return typeof window<"u"&&typeof window.localStorage<"u"}function Ai(e){if(!Nr())return null;try{return window.localStorage.getItem(e)}catch{return null}}function Oc(e,t){if(Nr())try{window.localStorage.setItem(e,t)}catch{}}function _i(e){if(Nr())try{window.localStorage.removeItem(e)}catch{}}function yx(){const e=Ai(gx);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.threadId=="string"&&typeof r.title=="string"}):[]}catch{return[]}}function Sx(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function ji(e,t){return`cachedThreads:v1:${e}:${Sx(t||"anon")}`}function Cx(e){const t=Ai(e);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(r=>{if(!r||typeof r!="object")return!1;const o=r;return typeof o.threadId=="string"&&typeof o.title=="string"}):[]}catch{return[]}}function Ri(e,t){try{Oc(e,JSON.stringify(t))}catch{}}function Pi(e){const t=Cx(e);if(t.length>0)return t;const n=yx();if(n.length>0)try{Ri(e,n.slice(0,Ni))}catch{}return n}function zo(e){const t={},n=[];for(const r of e)!r||typeof r.threadId!="string"||t[r.threadId]||(t[r.threadId]=r,n.push(r.threadId));return{byId:t,order:n}}function Oi(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function kx({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=Ci(),d=y.useMemo(()=>On(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${xx}:${f}:`,[f]),p=y.useCallback(C=>`${h}${C}`,[h]),b=y.useCallback(C=>{if(!C||typeof C!="object")return null;const _=C;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null,nextCursorNs:_.nextCursorNs??null,pendingInterrupt:_.pendingInterrupt??null}},[]),x=y.useCallback(C=>{const _=Ai(p(C));if(!_)return null;try{const F=JSON.parse(_);return b(F)}catch{return null}},[p,b]),g=y.useCallback((C,_=100)=>{const F={...C,messages:Array.isArray(C.messages)?C.messages.slice(-_):[]};try{Oc(p(C.threadId),JSON.stringify(F))}catch{}},[p]),v=y.useCallback(C=>{_i(p(C))},[p]),w=y.useCallback(()=>{if(Nr())try{const C=h;for(let _=0;_<window.localStorage.length;_++){const F=window.localStorage.key(_);F&&F.startsWith(C)&&window.localStorage.removeItem(F)}}catch{}},[h]),[S,N]=y.useState(()=>{var C;return ji(f,(C=l.getAuthToken)==null?void 0:C.call(l))}),[k,T]=y.useState(()=>{var _;const C=Pi(ji(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return zo(C)}),E=y.useMemo(()=>Oi(k),[k]),[A,j]=y.useState(t),[P,L]=y.useState(!1),[$,V]=y.useState(!1),[M,G]=y.useState(null),[K,W]=y.useState(null),[z,B]=y.useState(null),ue=y.useCallback(()=>{const C=Pi(S);y.startTransition(()=>{T(zo(C))})},[S]),[D,te]=y.useState(!1),[he,we]=y.useState(!1),[ye,Se]=y.useState(null),[q,O]=y.useState(void 0),[X,ne]=y.useState(void 0),[pe,se]=y.useState(void 0),{state:me,dispatch:et,seed:tt,prepend:Pe,pushUser:Ve,onEvent:ut,reset:nt}=bc(),Ke=y.useRef(A);y.useEffect(()=>{Ke.current=A},[A]);const vt=y.useRef(!1),Q=y.useRef([]),ie=y.useRef(null),xe=y.useRef(null),Ce=y.useRef(new Map),ve=y.useRef(A),Oe=y.useRef(!1),at=y.useRef(null),Me=y.useRef(new Map),st=y.useRef(new Map),ft=y.useRef(new Map),It=y.useRef(new Map),Nn=y.useCallback(()=>{var de;const C=It.current;if(C.size<=Rc)return;const _=Array.from(C.entries()).sort((J,Z)=>J[1].timestamp-Z[1].timestamp),F=C.size-Rc;for(let J=0;J<F;J++){const Z=(de=_[J])==null?void 0:de[0];Z&&C.delete(Z)}},[]),dn=y.useCallback((C,_,F)=>{if(!C)return;const de=F==="replace"?[]:Me.current.get(C)??[],J=F==="replace"?_:[..._,...de];if(!J.length){F==="replace"&&Me.current.set(C,[]);return}const Z=new Map;for(const We of J){if(!(We!=null&&We.checkpointId))continue;const Le=`${We.checkpointId}::${We.checkpointNs??""}`;Z.has(Le)||Z.set(Le,We)}const ze=Array.from(Z.values()).sort((We,Le)=>{const ge=Number.isFinite(Date.parse(We.createdAt))?Date.parse(We.createdAt):0;return(Number.isFinite(Date.parse(Le.createdAt))?Date.parse(Le.createdAt):0)-ge});Me.current.set(C,ze)},[]),Zt=y.useCallback((C,_,F)=>{if(!C)return;const de=st.current.get(C),J=F==="replace"||!de?new Map:new Map(de);if(_&&typeof _=="object")for(const[Z,ze]of Object.entries(_)){if(!(ze!=null&&ze.checkpointId))continue;const We=Z||Fo(ze.checkpointId,ze.checkpointNs??null);J.set(We,ze)}st.current.set(C,J)},[]),An=y.useCallback((C,_)=>{const{threadId:F,checkpointId:de=null,checkpointNs:J=null}=C,Z=vx(F,de,J);if(_!=null&&_.force)ft.current.delete(Z),It.current.delete(Z);else{if(_!=null&&_.preferCache){const ge=It.current.get(Z);if(ge)return Promise.resolve(ge.payload)}const Le=ft.current.get(Z);if(Le)return Le}const We=l.getStateHistory({threadId:F,checkpointId:de??void 0,checkpointNs:J??void 0}).then(Le=>(It.current.set(Z,{payload:Le,timestamp:Date.now()}),Nn(),Le)).finally(()=>{ft.current.get(Z)===We&&ft.current.delete(Z)});return ft.current.set(Z,We),We},[l,Nn]),_n=y.useCallback((C,_)=>new Promise((F,de)=>{const J=async()=>{vt.current=!0;try{await C(),F()}catch(Z){de(Z)}finally{vt.current=!1;const Z=Q.current.shift();Z&&Z().catch(()=>{})}};vt.current?Q.current.push(J):J().catch(Z=>{de(Z)})}),[]),Qn=y.useRef(E.length),[To,fn]=y.useState(!1),hn=y.useRef(!1);y.useEffect(()=>{Qn.current=E.length},[E.length]),y.useEffect(()=>{const C=me.pendingInterrupt??wx(me.messages);bx(z,C)||B(C??null)},[z,me.messages,me.pendingInterrupt]);const Et=y.useCallback(async()=>{const C=Qn.current>0;C||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{T(F=>{const de=ze=>ze.map(We=>`${We.threadId}:${We.updatedAt??""}:${We.messageCount??""}`).join("|"),J=Oi(F);return de(J)===de(_)||_.length===0&&J.length>0&&!hn.current?F:zo(_)})}),G(null),hn.current||(hn.current=!0,fn(!0))}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_),G(String(_))}finally{C||L(!1)}},[l,i]),Ur=y.useRef(!1),yr=y.useRef(null),yt=y.useRef(null),jn=y.useRef(""),Rn=y.useCallback((C,_)=>{if(!Nr())return;yt.current!==null&&(window.clearTimeout(yt.current),yt.current=null);const F=C.map(J=>`${J.threadId}:${J.updatedAt??""}:${J.messageCount??""}`).join("|");if(C.length===0){try{_i(S)}catch{}jn.current="";return}if(F===jn.current)return;const de=()=>{try{const J=C.slice(0,Ni);Ri(S,J),jn.current=F}catch{}finally{yt.current=null}};if(_!=null&&_.immediate){de();return}yt.current=window.setTimeout(()=>{Pc(de)},Bo)},[S]),Sr=y.useCallback(()=>{Rn(E,{immediate:!0})},[Rn,E]),Qt=y.useCallback((C,_,F,de)=>{const J=Array.isArray(C==null?void 0:C.messages)?C.messages:[],Z=F??(C==null?void 0:C.threadId)??Ke.current,ze=Z!=null&&Z===Ke.current,We=(C==null?void 0:C.pendingInterrupt)??null,Le=(de==null?void 0:de.persist)!==!1;if(_==="replace"){if(Le&&Z){const ge={threadId:Z,messages:J.slice(),hasMore:!!(C!=null&&C.hasMore),nextCursor:(C==null?void 0:C.nextCursor)??null,checkpointId:(C==null?void 0:C.checkpointId)??null,checkpointNs:(C==null?void 0:C.checkpointNs)??null,nextCursorNs:(C==null?void 0:C.nextCursorNs)??null,pendingInterrupt:We};Ce.current.set(Z,ge),ve.current=Z}if(!ze)return;tt(J,{checkpointId:(C==null?void 0:C.checkpointId)??null,checkpointNs:(C==null?void 0:C.checkpointNs)??null,pendingInterrupt:We}),B(We??null)}else if(_==="prepend"&&J.length&&Z){const ge=Ce.current.get(Z),Rt=(ge==null?void 0:ge.messages)??[],mn=new Set,en=[...J,...Rt].filter(kr=>{const tr=kr==null?void 0:kr.id;return tr?mn.has(tr)?!1:(mn.add(tr),!0):!0}),er={threadId:Z,messages:en,hasMore:(C==null?void 0:C.hasMore)??(ge==null?void 0:ge.hasMore)??!1,nextCursor:(C==null?void 0:C.nextCursor)??(ge==null?void 0:ge.nextCursor)??null,checkpointId:(ge==null?void 0:ge.checkpointId)??(C==null?void 0:C.checkpointId)??null,checkpointNs:(ge==null?void 0:ge.checkpointNs)??(C==null?void 0:C.checkpointNs)??null,nextCursorNs:(C==null?void 0:C.nextCursorNs)??(ge==null?void 0:ge.nextCursorNs)??null,pendingInterrupt:(ge==null?void 0:ge.pendingInterrupt)??We??null};if(Ce.current.set(Z,er),!ze)return;Pe(J)}else _==="prepend"&&J.length&&Pe(J);ze&&(_==="replace"?(Se((C==null?void 0:C.nextCursor)??null),te(!!(C!=null&&C.hasMore)),O((C==null?void 0:C.checkpointId)??void 0),ne((C==null?void 0:C.checkpointNs)??void 0),se((C==null?void 0:C.nextCursorNs)??void 0)):(Se(ge=>(C==null?void 0:C.nextCursor)??ge??null),te(ge=>(C==null?void 0:C.hasMore)!==void 0?!!(C!=null&&C.hasMore):ge),O(ge=>(C==null?void 0:C.checkpointId)??ge??void 0),ne(ge=>(C==null?void 0:C.checkpointNs)??ge??void 0),se(ge=>(C==null?void 0:C.nextCursorNs)!==void 0?C.nextCursorNs??void 0:ge)))},[Pe,tt,B]),Cr=y.useCallback(C=>{C.threadId!=null&&C.threadId!==Ke.current||(tt(C.messages,{checkpointId:C.checkpointId,checkpointNs:C.checkpointNs,pendingInterrupt:C.pendingInterrupt??null}),B(C.pendingInterrupt??null),Se(C.nextCursor),te(C.hasMore),O(C.checkpointId??void 0),ne(C.checkpointNs??void 0),se(C.nextCursorNs??void 0),ve.current=C.threadId)},[tt,B]),pn=y.useCallback(C=>{if(!C)return;Ce.current.delete(C),v(C),Me.current.delete(C),st.current.delete(C);const _=`${C}__`;for(const F of ft.current.keys())F.startsWith(_)&&ft.current.delete(F);for(const F of It.current.keys())F.startsWith(_)&&It.current.delete(F);ve.current===C&&(ve.current=null)},[v]),oe=y.useCallback(()=>{const C=Ke.current;C&&pn(C),nt([]),te(!1),we(!1),Se(null),O(void 0),ne(void 0),se(void 0)},[pn,nt]),ke=y.useCallback(({from:C,to:_})=>{const F=Ke.current;F&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${C} -> ${_}) for thread ${F}`)},[]),qe=y.useCallback(C=>{const _=C.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:C.title,created:C.created,currentThreads:E.length});const F={threadId:_,title:C.title||`Thread ${_.slice(0,8)}`,createdAt:C.createdAt||new Date().toISOString(),updatedAt:C.updatedAt||new Date().toISOString(),messageCount:C.messageCount||0};Ke.current!==_&&(!Ke.current&&me.messages.length<=1&&(xe.current=_),j(_)),y.startTransition(()=>{T(de=>{const J=de.byId[_];return J?J.title===F.title&&J.updatedAt===F.updatedAt&&J.messageCount===F.messageCount?de:{byId:{...de.byId,[_]:F},order:de.order}:{byId:{...de.byId,[_]:F},order:[_,...de.order]}})})},[me.messages.length]),{startStream:it,stop:Mt,isStreaming:I,error:H,setAuthToken:re}=px({baseUrl:d,onThreadInfo:qe,onMessageEvent:ut,onUnhandledEvent:C=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${C.type}`,C)},onSequenceGap:ke});y.useEffect(()=>{Ur.current=I},[I]),y.useEffect(()=>{if(!Nr())return;yt.current!==null&&(window.clearTimeout(yt.current),yt.current=null);const C=E.map(F=>`${F.threadId}:${F.updatedAt??""}:${F.messageCount??""}`).join("|");if(E.length===0){try{_i(S)}catch{}jn.current="";return}if(C===jn.current)return;const _=()=>{try{const F=E.slice(0,Ni);Ri(S,F),jn.current=C}catch{}finally{yt.current=null}};return yt.current=window.setTimeout(()=>{Pc(_),yt.current=null},Bo),()=>{yt.current!==null&&(window.clearTimeout(yt.current),yt.current=null)}},[E,Rn]),y.useEffect(()=>{var de;const C=l.getAuthToken();re(C);const _=J=>{const Z=ji(f,J);at.current!==Z&&(at.current=Z,Oe.current=!1),N(Z);const ze=Pi(Z);y.startTransition(()=>{T(zo(ze))}),Oe.current||(Oe.current=!0,Et().catch(()=>{}))};_(C);const F=(de=l.onTokenChange)==null?void 0:de.call(l,J=>{re(J),w(),ft.current.clear(),It.current.clear(),_(J)});return()=>{F==null||F()}},[l,f,re,w,Et]);const Ee=y.useCallback(async C=>{var de;const _=`Thread ${(de=crypto.randomUUID)==null?void 0:de.call(crypto)}`,F={threadId:_,title:C||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};T(J=>({byId:{...J.byId,[_]:F},order:[_,...J.order]})),j(_);try{const J=await l.createThread(C),Z=typeof J=="string"?J:J.threadId;return T(ze=>{const We=ze.byId[_];if(!We)return ze;const Le={...ze.byId};delete Le[_],Le[Z]={...We,threadId:Z};const ge=ze.order.map(Rt=>Rt===_?Z:Rt);return{byId:Le,order:ge}}),j(Z),setTimeout(()=>Et(),10),G(null),Z}catch(J){throw T(Z=>{if(!Z.byId[_])return Z;const ze={...Z.byId};delete ze[_];const We=Z.order.filter(Le=>Le!==_);return{byId:ze,order:We}}),j(null),G(String(J)),J}},[l,Et]),Be=y.useCallback(async C=>{try{await l.deleteThread(C);let _=null;T(F=>{if(!F.byId[C])return F;const de={...F.byId};delete de[C];const J=F.order.filter(ze=>ze!==C),Z={byId:de,order:J};return _=Oi(Z),Z}),_&&Rn(_,{immediate:!0}),pn(C),Ke.current===C&&(xe.current=C,j(null),Ke.current=null,ve.current=null,oe()),await Et(),G(null)}catch(_){throw G(String(_)),_}},[l,oe,pn,Et,Rn]),Xe=y.useCallback(async(C,_)=>{try{await l.updateThread(C,_),T(F=>{const de=F.byId[C];return de?{byId:{...F.byId,[C]:{...de,title:_}},order:F.order}:F}),G(null)}catch(F){throw await Et(),G(String(F)),F}},[l,Et]),De=y.useCallback(async(C,_,F,de=!1)=>{await _n(async()=>{if(xe.current===C&&!de){xe.current=null;return}if(ie.current===C&&!de)return;j(Le=>Le===C?Le:C),Ke.current=C;const J=!de&&!_&&!F;let Z=!1;if(J){const Le=Ce.current.get(C);if(Le)Cr(Le),Z=!0;else{const ge=x(C);ge&&(Ce.current.set(C,ge),Cr(ge),Z=!0)}}const ze=de||!Z||!!_||!!F,We=async Le=>{Le&&V(!0),ie.current=C;try{const ge=await An({threadId:C,checkpointId:_,checkpointNs:F},{force:de}),{payload:Rt,checkpoints:mn,snapshots:en}=Ti(ge);Qt(Rt,"replace",C),dn(C,mn,"replace"),Zt(C,en,"replace"),W(null)}catch(ge){throw(!Z||de||Le)&&(i==null||i(String(ge))),W(String(ge)),ge}finally{ie.current=null,Le&&V(!1)}};ze?await We(!0):J&&Z&&We(!1).catch(Le=>{console.warn("[ChatSessionProvider] Background refresh failed:",Le)})},`loadThread-${C}`)},[Cr,Qt,_n,An,i,dn,Zt]),Ue=y.useCallback(async()=>{await _n(async()=>{const C=Ke.current;C&&pn(C),xe.current=null,j(null),Ke.current=null,ve.current=null,oe(),O(void 0),ne(void 0),se(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[oe,pn,_n]),kt=y.useCallback(async C=>{const _=Me.current.get(C);if(_)return{threadId:C,checkpoints:_.slice()};const F=await An({threadId:C},{preferCache:!0}),{checkpoints:de,snapshots:J}=Ti(F);dn(C,de,"replace"),Zt(C,J,"replace");const Z=Me.current.get(C)??[];return{threadId:C,checkpoints:Z.slice()}},[An,dn,Zt]),ht=y.useCallback(async(C,_)=>{var Z;const F=Ke.current;if(!F)throw new Error("No active thread");const de=Fo(C,_??null),J=(Z=st.current.get(F))==null?void 0:Z.get(de);if(J){await _n(async()=>{Qt({threadId:F,checkpointId:J.checkpointId??void 0,checkpointNs:J.checkpointNs??void 0,messages:J.messages??[],hasMore:!!J.nextCursor,nextCursor:J.nextCursor??null,nextCursorNs:J.nextCursorNs??null,pendingInterrupt:J.interrupt??null},"replace",F,{persist:!1})},`navigateToCheckpoint-${F}-${de}`);return}await De(F,C,_??void 0,!0)},[Qt,_n,De]),mt=y.useCallback(async()=>{if(!Ke.current)throw new Error("No active thread");await De(Ke.current,void 0,void 0,!0)},[De]),Dt=y.useCallback(async()=>{if(!Ke.current)throw new Error("No active thread");if(he||!D)return;const C=ye;if(C){we(!0);try{const _=Ke.current,F=await An({threadId:_,checkpointId:C??q??null,checkpointNs:pe??X??null}),{payload:de,checkpoints:J,snapshots:Z}=Ti(F);Qt(de,"prepend",_??void 0),_&&(dn(_,J,"prepend"),Zt(_,Z,"prepend")),W(null)}catch(_){throw W(String(_)),_}finally{we(!1)}}},[Qt,An,D,q,X,pe,ye,he,dn,Zt]),$n=y.useCallback(C=>{if(!(C!=null&&C.threadId))return;const _={threadId:C.threadId,checkpointId:C.checkpointId??void 0,checkpointNs:C.checkpointNs??void 0,messages:C.messages??[],hasMore:C.hasMore,nextCursor:C.nextCursor??null,nextCursorNs:C.nextCursorNs??null,pendingInterrupt:C.pendingInterrupt??null};if(C.checkpointId){const F=Fo(C.checkpointId,C.checkpointNs??null);Zt(C.threadId,{[F]:{messages:C.messages??[],checkpointId:C.checkpointId??null,checkpointNs:C.checkpointNs??null,nextCursor:C.nextCursor??null,nextCursorNs:C.nextCursorNs??null,interrupt:C.pendingInterrupt??null}},"prepend")}Qt(_,"replace",C.threadId)},[Qt,Zt]),Pn=y.useCallback(async(C,_)=>{var ii;const F=Ke.current,de=(C==null?void 0:C.text)??"",J=(C==null?void 0:C.attachments)??[],Z=J.length?J:(_==null?void 0:_.attachments)??[],ze={...(_==null?void 0:_.payloadExtras)??{},...(C==null?void 0:C.payload)??{}};if(!F&&!Object.keys(ze).length&&Z.length===0&&!de.trim()){console.warn("[ChatSessionProvider] Nothing to submit - skipping");return}!F&&!ze.messages&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const{contentParts:We,filesInfo:Le}=await Vg(l,Z),ge=[...We];de&&de.trim()&&ge.push({type:"text",text:de.trim()});const Rt=!!F,mn=Rt?(_==null?void 0:_.checkpointId)??me.lastCheckpointId??void 0:void 0,en=Rt?(_==null?void 0:_.checkpointNs)??me.lastCheckpointNs??void 0:void 0,er={id:((ii=crypto.randomUUID)==null?void 0:ii.call(crypto))||`user-${Date.now()}`,role:"user",content:ge,createdAt:new Date().toISOString(),...mn!=null?{checkpointId:mn}:{},...en!=null?{checkpointNs:en}:{}};ge.length>0&&Ve(er);const kr={...er,content:ge},tr=Z.length>0,si={...F?{threadId:F}:{},payload:{messages:ge.length>0?[kr]:[],files_info:Le,...o&&tr&&s?{active_agent:s}:{},...ze},...mn!=null?{checkpointId:mn}:{},...en!=null?{checkpointNs:en}:{},nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};it(si,{onError:Fn=>{console.warn("[ChatSessionProvider] Stream error:",Fn)},onOpen:({threadId:Fn})=>{!Ke.current&&Fn&&(me.messages.length<=1&&(xe.current=Fn),j(Fn))},onGap:ke})},[l,o,s,ke,me.lastCheckpointId,me.lastCheckpointNs,me.messages.length,Ve,it]),St=y.useCallback(async(C,_,F)=>{var J,Z;const de=Ke.current;if(!de)throw new Error("No active thread to handle interrupt");try{const ze=_?F??!0:!1;try{et({type:"interrupt_response",payload:{interruptId:C}})}catch(er){console.warn("[ChatSessionProvider] optimistic interrupt_response dispatch failed:",er)}const We=`${d}/runs/resume`,Le=(J=l.getAuthToken)==null?void 0:J.call(l),ge=await fetch(We,{method:"POST",headers:{"Content-Type":"application/json",...Le?{Authorization:`Bearer ${Le}`}:{}},body:JSON.stringify({thread_id:de,value:ze})});if(!ge.ok)throw new Error(`Resume failed with status ${ge.status}`);const Rt=(Z=ge.body)==null?void 0:Z.getReader();if(!Rt)throw new Error("No response body for resume stream");const mn=new TextDecoder;let en="";for(;;){const{done:er,value:kr}=await Rt.read();if(er)break;en+=mn.decode(kr,{stream:!0});const tr=en.split(`
39
+ `);en=tr.pop()||"";for(const si of tr)if(si.startsWith("data: ")){const ii=si.slice(6);try{const Fn=JSON.parse(ii);et({type:"event",payload:{ev:Fn}})}catch(Fn){console.warn("[ChatSessionProvider] Failed to parse resume SSE event:",Fn)}}}B(null)}catch(ze){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${C}:`,ze),ze}},[l,et,d]),Wr=y.useCallback(C=>St(C.interruptId,C.approved,C.value),[St]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(C){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",C)}},[A,a]),y.useEffect(()=>((async()=>{try{if(Et().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(j(_),n&&await De(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await De(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{var J,Z,ze,We;const C=Ke.current;if(!C||ve.current!==C)return;const _={threadId:C,messages:me.messages.slice(),hasMore:D,nextCursor:ye,checkpointId:me.lastCheckpointId??null,checkpointNs:me.lastCheckpointNs??null,nextCursorNs:pe??null,pendingInterrupt:me.pendingInterrupt??z??null},F=Ce.current.get(C);(!F||F.messages.length!==_.messages.length||F.messages.some((Le,ge)=>{var Rt;return(Le==null?void 0:Le.id)!==((Rt=_.messages[ge])==null?void 0:Rt.id)})||(F==null?void 0:F.hasMore)!==_.hasMore||(F==null?void 0:F.nextCursor)!==_.nextCursor||(F==null?void 0:F.nextCursorNs)!==_.nextCursorNs||(F==null?void 0:F.checkpointId)!==_.checkpointId||(F==null?void 0:F.checkpointNs)!==_.checkpointNs||(((J=F==null?void 0:F.pendingInterrupt)==null?void 0:J.id)??null)!==(((Z=_.pendingInterrupt)==null?void 0:Z.id)??null)||JSON.stringify((ze=F==null?void 0:F.pendingInterrupt)==null?void 0:ze.value)!==JSON.stringify((We=_.pendingInterrupt)==null?void 0:We.value))&&(Ce.current.set(C,_),yr.current&&window.clearTimeout(yr.current),yr.current=window.setTimeout(()=>{try{g(_,100)}catch(Le){console.warn("[ChatSessionProvider] Failed to persist thread payload:",Le)}},Bo))},[D,ye,pe,me.lastCheckpointId,me.lastCheckpointNs,me.messages,me.pendingInterrupt,z]);const gl=y.useMemo(()=>({threads:E,currentThreadId:A,setCurrentThreadId:j,isLoading:P,error:M,actions:{createThread:Ee,deleteThread:Be,renameThread:Xe,refreshThreads:()=>Et()},persistThreadsCache:Sr,hydrateFromCache:ue}),[E,A,P,M,Ee,Be,Xe,Et,Sr,ue,j]),xl=y.useMemo(()=>{const C=me.lastBranch??null,_=me.assemblingId??null,F=C||_?{branchLabel:(C==null?void 0:C.branchLabel)??null,lastBranch:C,assemblingMessageId:_}:null;return{threadId:A,messages:me.messages,interrupt:z,checkpoint:{id:me.lastCheckpointId??null,namespace:me.lastCheckpointNs??null},metadata:F,isLoading:$,isHistoryLoading:he,error:K,hasMore:D,loadOlder:Dt,seedFromSnapshot:$n,clearState:oe,listCheckpoints:kt,navigateToCheckpoint:ht,returnToLatest:mt,loadThread:De,clearThread:Ue,respondToInterrupt:St}},[Ue,oe,A,z,D,he,$,kt,Dt,De,me.assemblingId,me.lastBranch,me.lastCheckpointId,me.lastCheckpointNs,me.messages,ht,St,mt,$n,K]),Sk=y.useMemo(()=>({isStreaming:I,error:H,submit:Pn,stop:Mt,resume:Wr,setAuthToken:re}),[I,H,Pn,Mt,Wr,re]);return c.jsx(mx.Provider,{value:!0,children:c.jsx(jc.Provider,{value:Sk,children:c.jsx(Ac.Provider,{value:gl,children:c.jsx(_c.Provider,{value:xl,children:e})})})})}function Ho(){const e=y.useContext(Ac);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Uo(){const e=y.useContext(_c);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Mc(){const e=y.useContext(jc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Wo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Ug,{apiConfig:t,children:c.jsx(kx,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ee(...e){return vm.twMerge(xm.clsx(e))}const Tx=Io.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"}}),Je=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?nr.Slot:"button";return c.jsx(i,{className:ee(Tx({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";const Dc=m.forwardRef(({className:e,...t},n)=>c.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}));Dc.displayName="Textarea";function Ix({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=y.useState(e),[b,x]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const v=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{v()},[v]);const w=y.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||x(()=>{try{const P=i(j);P&&typeof P.then=="function"?P.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),N=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),w()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[w,t,a]),E=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void w(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Dc,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:E,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Je,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ae.Square,{size:16})}):c.jsx(Je,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:c.jsx(ae.Send,{size:16})})})]})})}const Ex=y.memo(Ix),Vo=0,zn=1,Ar=2,Lc=4;function $c(e){return()=>e}function Nx(e){e()}function Fc(e,t){return n=>e(t(n))}function Bc(e,t){return()=>e(t)}function Ax(e,t){return n=>e(t,n)}function Mi(e){return e!==void 0}function _x(...e){return()=>{e.map(Nx)}}function _r(){}function Ko(e,t){return t(e),e}function jx(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(zn,t)}function Fe(e,t){e(Vo,t)}function Di(e){e(Ar)}function xt(e){return e(Lc)}function be(e,t){return Qe(e,Ax(t,Vo))}function on(e,t){const n=e(zn,r=>{n(),t(r)});return n}function zc(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Hc(e,t){return e===t}function ct(e=Hc){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function le(e){return t=>Fc(t,e)}function xn(e){return t=>()=>{t(e)}}function U(e,...t){const n=Rx(...t);return(r,o)=>{switch(r){case Ar:Di(e);return;case zn:return Qe(e,n(o))}}}function vn(e,t){return n=>r=>{n(t=e(t,r))}}function ir(e){return t=>n=>{e>0?e--:t(n)}}function Mn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function He(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Rx(...e){return t=>e.reduceRight(jx,t)}function Px(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),_r);case Ar:r(),n=null;return}}}function Y(e){let t=e;const n=Ye();return(r,o)=>{switch(r){case Vo:t=o;break;case zn:{o(t);break}case Lc:return t}return n(r,o)}}function At(e,t){return Ko(Y(t),n=>be(e,n))}function Ye(){const e=[];return(t,n)=>{switch(t){case Vo:e.slice().forEach(r=>{r(n)});return;case Ar:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function zt(e){return Ko(Ye(),t=>be(e,t))}function Ze(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ox(),singleton:n}}const Ox=()=>Symbol();function Mx(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function bt(...e){const t=Ye(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Fe(t,n)})}),function(s,i){switch(s){case Ar:{Di(t);return}case zn:return r===o&&i(n),Qe(t,i)}}}function Ne(e,t=Hc){return U(e,ct(t))}function Li(...e){return function(t,n){switch(t){case Ar:return;case zn:return _x(...e.map(r=>Qe(r,n)))}}}var Ft=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ft||{});const Dx={0:"debug",3:"error",1:"log",2:"warn"},Lx=()=>typeof globalThis>"u"?window:globalThis,Hn=Ze(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=Lx().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[Dx[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ar(e,t,n){return $i(e,t,n).callbackRef}function $i(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.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 $x(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Fx(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let b;p&&(b=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:v}),s==null||s(a?Uc("column-gap",getComputedStyle(d).columnGap,o):Uc("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return $i(u,n,l)}function Fx(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ft.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Uc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ft.WARN),t==="normal"?0:parseInt(t??"0",10)}function Wc(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),b=u.top-p.top;h=p.height-Math.max(0,b),f=b+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$i(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Pt=Ze(()=>{const e=Ye(),t=Ye(),n=Y(0),r=Ye(),o=Y(0),s=Ye(),i=Ye(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=Ye(),h=Ye(),p=Y(!1),b=Y(!1),x=Y(!1);return be(U(e,le(({scrollTop:g})=>g)),t),be(U(e,le(({scrollHeight:g})=>g)),i),be(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Qr={lvl:0};function Vc(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 rt(e){return e===Qr}function eo(e,t){if(!rt(e))return t===e.k?e.v:t<e.k?eo(e.l,t):eo(e.r,t)}function sn(e,t,n="k"){if(rt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=sn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return sn(e.l,t,n)}function Ht(e,t,n){return rt(e)?Gc(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?Yc(wt(e,{l:Ht(e.l,t,n)})):Yc(wt(e,{r:Ht(e.r,t,n)}))}function jr(){return Qr}function qo(e,t,n){if(rt(e))return[];const r=sn(e,t)[0];return Bx(Bi(e,r,n))}function Fi(e,t){if(rt(e))return Qr;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(o))return r;{const[s,i]=qc(r);return Go(wt(e,{k:s,l:Kc(r),v:i}))}}else return t<n?Go(wt(e,{l:Fi(r,t)})):Go(wt(e,{r:Fi(o,t)}))}function lr(e){return rt(e)?[]:[...lr(e.l),{k:e.k,v:e.v},...lr(e.r)]}function Bi(e,t,n){if(rt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Bi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Bi(s,t,n))),a}function Go(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(zi(t))return Xc(wt(e,{lvl:n-1}));if(!rt(t)&&!rt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(zi(e))return Hi(wt(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=zi(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Hi(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return Gc(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 Kc(e){return rt(e.r)?e.l:Go(wt(e,{r:Kc(e.r)}))}function zi(e){return rt(e)||e.lvl>e.r.lvl}function qc(e){return rt(e.r)?[e.k,e.v]:qc(e.r)}function Gc(e,t,n,r=Qr,o=Qr){return{k:e,l:r,lvl:n,r:o,v:t}}function Yc(e){return Hi(Xc(e))}function Xc(e){const{l:t}=e;return!rt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Hi(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function Bx(e){return Vc(e,({k:t,v:n})=>({index:t,value:n}))}function Jc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function to(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ui=Ze(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function Zc(e,t,n){return e[Yo(e,t,n)]}function Yo(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function zx(e,t,n,r){const o=Yo(e,t,r),s=Yo(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function Xo(e){return!rt(e.groupOffsetTree)}function Wi({index:e},t){return t===e?0:t<e?-1:1}function Hx(){return{groupIndices:[],groupOffsetTree:jr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:jr()}}function Ux(e,t){let n=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=Ht(e,0,s);continue}const a=qo(e,i-1,o+1);if(a.some(Xx(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=Fi(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ht(e,o+1,h));u&&(e=Ht(e,i,s))}return[e,n]}function Wx(e){return typeof e.groupIndex<"u"}function Vx({offset:e},t){return t===e?0:t<e?-1:1}function no(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Zc(t,e,Wi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Qc(e,t){if(!Xo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function eu(e,t,n){if(Wx(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Qc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Kx(e,t,n,r=0){return r>0&&(t=Math.max(t,Zc(e,r,Wi).offset)),Vc(zx(e,t,n,Vx),Yx)}function qx(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ft.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&rt(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((b,x)=>Ht(Ht(b,x,h),x+1,p),i)}else[i,a]=Ux(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Vi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ht(h,p,no(p,f,o)),jr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Gx(e){return lr(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 tu(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 Vi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Yo(o,t-1,Wi),a=o[l].offset;const u=sn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===sn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of qo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Yx(e){return{index:e.index,value:e}}function Xx(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 Jx={offsetHeight:"height",offsetWidth:"width"},bn=Ze(([{log:e},{recalcInProgress:t}])=>{const n=Ye(),r=Ye(),o=At(r,0),s=Ye(),i=Ye(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((k,T)=>Un(k,Jx[T])),h=Y(void 0),p=Y(0),b=Hx(),x=At(U(n,He(l,e,p),vn(qx,b),ct()),b),g=At(U(l,ct(),vn((k,T)=>({current:T,prev:k.current}),{current:[],prev:[]}),le(({prev:k})=>k)),[]);be(U(l,Ae(k=>k.length>0),He(x,p),le(([k,T,E])=>{const A=k.reduce((j,P,L)=>Ht(j,P,no(P,T.offsetTree,E)||L),jr());return{...T,groupIndices:k,groupOffsetTree:A}})),x),be(U(r,He(x),Ae(([k,{lastIndex:T}])=>k<T),le(([k,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:k}])),n),be(u,d);const v=At(U(u,le(k=>k===void 0)),!0);be(U(d,Ae(k=>k!==void 0&&rt(xt(x).sizeTree)),le(k=>[{endIndex:0,size:k,startIndex:0}])),n);const w=zt(U(n,He(x),vn(({sizes:k},[T,E])=>({changed:E!==k,sizes:E}),{changed:!1,sizes:b}),le(k=>k.changed)));Qe(U(a,vn((k,T)=>({diff:k.prev-T,prev:T}),{diff:0,prev:0}),le(k=>k.diff)),k=>{const{groupIndices:T}=xt(x);if(k>0)Fe(t,!0),Fe(s,k+tu(k,T));else if(k<0){const E=xt(g);E.length>0&&(k-=tu(-k,E)),Fe(i,k)}}),Qe(U(a,He(e)),([k,T])=>{k<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ft.ERROR)});const S=zt(s);be(U(s,He(x),le(([k,T])=>{const E=T.groupIndices.length>0,A=[],j=T.lastSize;if(E){const P=eo(T.sizeTree,0);let L=0,$=0;for(;L<k;){const M=T.groupIndices[$],G=T.groupIndices.length===$+1?1/0:T.groupIndices[$+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+G-1,size:j,startIndex:M+1}),$++,L+=G+1}const V=lr(T.sizeTree);return L!==k&&V.shift(),V.reduce((M,{k:G,v:K})=>{let W=M.ranges;return M.prevSize!==0&&(W=[...M.ranges,{endIndex:G+k-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:G+k,prevSize:K,ranges:W}},{prevIndex:k,prevSize:0,ranges:A}).ranges}return lr(T.sizeTree).reduce((P,{k:L,v:$})=>({prevIndex:L+k,prevSize:$,ranges:[...P.ranges,{endIndex:L+k-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const N=zt(U(i,He(x,p),le(([k,{offsetTree:T},E])=>{const A=-k;return no(A,T,E)})));return be(U(i,He(x,p),le(([k,T,E])=>{if(T.groupIndices.length>0){if(rt(T.sizeTree))return T;let A=jr();const j=xt(g);let P=0,L=0,$=0;for(;P<-k;){$=j[L];const V=j[L+1]-$-1;L++,P+=V+1}if(A=lr(T.sizeTree).reduce((V,{k:M,v:G})=>Ht(V,Math.max(0,M+k),G),A),P!==-k){const V=eo(T.sizeTree,$);A=Ht(A,0,V);const M=sn(T.sizeTree,-k+1)[1];A=Ht(A,1,M)}return{...T,sizeTree:A,...Vi(T.offsetTree,0,A,E)}}else{const A=lr(T.sizeTree).reduce((j,{k:P,v:L})=>Ht(j,Math.max(0,P+k),L),jr());return{...T,sizeTree:A,...Vi(T.offsetTree,0,A,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},lt(Hn,Ui),{singleton:!0});function Zx(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const nu=Ze(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ye(),i=Ye(),a=zt(U(s,le(Zx)));return be(U(a,le(l=>l.totalCount)),n),be(U(a,le(l=>l.groupIndices)),e),be(U(bt(o,t,r),Ae(([l,u])=>Xo(u)),le(([l,u,d])=>sn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),le(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(bn,Pt)),Wn=Ze(([{log:e}])=>{const t=Y(!1),n=zt(U(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&xt(e)("props updated",{},Ft.DEBUG)}),{didMount:n,propsReady:t}},lt(Hn),{singleton:!0}),Qx=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ru(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Qx)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ro=Ze(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Ye(),b=Ye(),x=Y(0);let g=null,v=null,w=null;function S(){g&&(g(),g=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Fe(l,!1)}return be(U(p,He(n,f,r,x,a,i,h),He(e,s,o),le(([[N,k,T,E,A,j,P,L],$,V,M])=>{const G=ru(N),{align:K,behavior:W,offset:z}=G,B=E-1,ue=eu(G,k,B);let D=no(ue,k.offsetTree,$)+j;K==="end"?(D+=V+sn(k.sizeTree,ue)[1]-T+M,ue===B&&(D+=P)):K==="center"?D+=(V+sn(k.sizeTree,ue)[1]-T+M)/2:D-=A,z&&(D+=z);const te=he=>{S(),he?(L("retrying to scroll to",{location:N},Ft.DEBUG),Fe(p,N)):(Fe(b,!0),L("list did not change, scroll successful",{},Ft.DEBUG))};if(S(),W==="smooth"){let he=!1;w=Qe(t,we=>{he=he||we}),g=on(d,()=>{te(he)})}else g=on(U(t,ev(150)),te);return v=setTimeout(()=>{S()},1200),Fe(l,!0),L("scrolling from index to",{behavior:W,index:ue,top:D},Ft.DEBUG),{behavior:W,top:D}})),u),{scrollTargetReached:b,scrollToIndex:p,topListHeight:x}},lt(bn,Pt,Hn),{singleton:!0});function ev(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ki(e,t){e==0?t():requestAnimationFrame(()=>{Ki(e-1,t)})}function qi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const oo=Ze(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=Y(!0),l=Y(0),u=Y(!0);return be(U(i,He(l),Ae(([d,f])=>!!f),xn(!1)),a),be(U(i,He(l),Ae(([d,f])=>!!f),xn(!1)),u),Qe(U(bt(t,i),He(a,n,e,u),Ae(([[,d],f,{sizeTree:h},p,b])=>d&&(!rt(h)||Mi(p))&&!f&&!b),He(l)),([,d])=>{on(o,()=>{Fe(u,!0)}),Ki(4,()=>{on(r,()=>{Fe(a,!0)}),Fe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(bn,Pt,ro,Wn),{singleton:!0});function ou(e,t){return Math.abs(e-t)<1.01}const so="up",io="down",tv="none",nv={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rv=0,ao=Ze(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=Ye(),u=Ye(),d=Y(4),f=Y(rv),h=At(U(Li(U(Ne(o),ir(1),xn(!0)),U(Ne(o),ir(1),xn(!1),zc(100))),ct()),!1),p=At(U(Li(U(n,xn(!0)),U(n,xn(!1),zc(200))),ct()),!1);be(U(bt(Ne(o),Ne(f)),le(([w,S])=>w<=S),ct()),a),be(U(a,Mn(50)),u);const b=zt(U(bt(r,Ne(s),Ne(t),Ne(e),Ne(d)),vn((w,[{scrollHeight:S,scrollTop:N},k,T,E,A])=>{const j=N+k-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:k};if(j){let $,V;return N>w.state.scrollTop?($="SCROLLED_DOWN",V=w.state.scrollTop-N):($="SIZE_DECREASED",V=w.state.scrollTop-N||w.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:V,state:P}}let L;return P.scrollHeight>w.state.scrollHeight?L="SIZE_INCREASED":k<w.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<w.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},nv),ct((w,S)=>w&&w.atBottom===S.atBottom))),x=At(U(r,vn((w,{scrollHeight:S,scrollTop:N,viewportHeight:k})=>{if(ou(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const T=S-(N+k)<1;return w.scrollTop!==N&&T?{changed:!0,jump:w.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(w=>w.changed),le(w=>w.jump)),0);be(U(b,le(w=>w.atBottom)),i),be(U(i,Mn(50)),l);const g=Y(io);be(U(r,le(({scrollTop:w})=>w),ct(),vn((w,S)=>xt(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?so:io,prevScrollTop:S},{direction:io,prevScrollTop:0}),le(w=>w.direction)),g),be(U(r,Mn(50),xn(tv)),g);const v=Y(0);return be(U(h,Ae(w=>!w),xn(0)),v),be(U(o,Mn(100),He(h),Ae(([w,S])=>!!S),vn(([w,S],[N])=>[S,N],[0,0]),le(([w,S])=>S-w)),v),{atBottomState:b,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:v}},lt(Pt)),Jo="top",Zo="bottom",su="none";function iu(e,t,n){return typeof e=="number"?n===so&&t===Jo||n===io&&t===Zo?e:0:n===so?t===Jo?e.main:e.reverse:t===Zo?e.main:e.reverse}function au(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Gi=Ze(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ye(),i=Y(0),a=Y(0),l=Y(0),u=At(U(bt(Ne(r),Ne(o),Ne(n),Ne(s,to),Ne(l),Ne(i),Ne(t),Ne(e),Ne(a)),le(([d,f,h,[p,b],x,g,v,w,S])=>{const N=d-w,k=g+v,T=Math.max(h-N,0);let E=su;const A=au(S,Jo),j=au(S,Zo);return p-=w,p+=h+v,b+=h+v,b-=w,p>d+k-A&&(E=so),b<d-T+f+j&&(E=io),E!==su?[Math.max(N-h-iu(x,Jo,E)-A,0),N-T-v+f+iu(x,Zo,E)+j]:null}),Ae(d=>d!=null),ct(to)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},lt(Pt),{singleton:!0});function ov(e,t,n){if(Xo(t)){const r=Qc(e,t);return[{index:sn(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 Yi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Qo(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,b=h-d;return{bottom:d,firstItemIndex:s,items:cu(e,o,s),offsetBottom:b,offsetTop:u,top:p,topItems:cu(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function lu(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=qi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Qo(u,[],a,o,n,r)}function cu(e,t,n){if(e.length===0)return[];if(!Xo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=qo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const cr=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:b}])=>{const x=Y([]),g=Y(0),v=Ye();be(s.topItemsIndexes,x);const w=At(U(bt(p,b,Ne(l,to),Ne(o),Ne(r),Ne(u),d,Ne(x),Ne(t),Ne(n),e),Ae(([T,E,,A,,,,,,,j])=>{const P=j&&j.length!==A;return T&&!E&&!P}),le(([,,[T,E],A,j,P,L,$,V,M,G])=>{const K=j,{offsetTree:W,sizeTree:z}=K,B=xt(g);if(A===0)return{...Yi,totalCount:A};if(T===0&&E===0)return B===0?{...Yi,totalCount:A}:lu(B,P,j,V,M,G||[]);if(rt(z))return B>0?null:Qo(ov(qi(P,A),K,G),[],A,M,K,V);const ue=[];if($.length>0){const ye=$[0],Se=$[$.length-1];let q=0;for(const O of qo(z,ye,Se)){const X=O.value,ne=Math.max(O.start,ye),pe=Math.min(O.end,Se);for(let se=ne;se<=pe;se++)ue.push({data:G==null?void 0:G[se],index:se,offset:q,size:X}),q+=X}}if(!L)return Qo([],ue,A,M,K,V);const D=$.length>0?$[$.length-1]+1:0,te=Kx(W,T,E,D);if(te.length===0)return null;const he=A-1,we=Ko([],ye=>{for(const Se of te){const q=Se.value;let O=q.offset,X=Se.start;const ne=q.size;if(q.offset<T){X+=Math.floor((T-q.offset+M)/(ne+M));const se=X-Se.start;O+=se*ne+se*M}X<D&&(O+=(D-X)*ne,X=D);const pe=Math.min(Se.end,he);for(let se=X;se<=pe&&!(O>=E);se++)ye.push({data:G==null?void 0:G[se],index:se,offset:O,size:ne}),O+=ne+M}});return Qo(we,ue,A,M,K,V)}),Ae(T=>T!==null),ct()),Yi);be(U(e,Ae(Mi),le(T=>T==null?void 0:T.length)),o),be(U(w,le(T=>T.topListHeight)),f),be(f,a),be(U(w,le(T=>[T.top,T.bottom])),i),be(U(w,le(T=>T.items)),v);const S=zt(U(w,Ae(({items:T})=>T.length>0),He(o,e),Ae(([{items:T},E])=>T[T.length-1].originalIndex===E-1),le(([,T,E])=>[T-1,E]),ct(to),le(([T])=>T))),N=zt(U(w,Mn(200),Ae(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),le(({items:T})=>T[0].index),ct())),k=zt(U(w,Ae(({items:T})=>T.length>0),le(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),ct(Jc)));return{endReached:S,initialItemCount:g,itemsRendered:v,listState:w,rangeChanged:k,startReached:N,topItemsIndexes:x,...h}},lt(bn,nu,Gi,oo,ro,ao,Wn,Ui),{singleton:!0}),uu=Ze(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ye(),i=At(U(bt(n,e,r,t,o),le(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return be(Ne(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Pt,cr),{singleton:!0}),sv=Ze(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=At(U(bt(n,e,t),Ae(([o])=>o),le(([,o,s])=>Math.max(0,o-s)),Mn(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Pt,uu),{singleton:!0}),du=Ze(()=>({context:Y(null)})),iv=({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,fu=Ze(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Ye();return be(U(d,He(t,l,n,s,o,r,a),He(e),le(([[f,h,p,b,x,g,v,w],S])=>{const{align:N,behavior:k,calculateViewLocation:T=iv,done:E,...A}=f,j=eu(f,h,b-1),P=no(j,h.offsetTree,S)+x+g,L=P+sn(h.sizeTree,j)[1],$=w+g,V=w+p-v,M=T({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:k,...A},viewportBottom:V,viewportTop:$});return M?E&&on(U(i,Ae(G=>!G),ir(xt(i)?1:2)),E):E&&E(),M}),Ae(f=>f!==null)),u),{scrollIntoView:d}},lt(bn,Pt,ro,cr,Hn),{singleton:!0});function hu(e){return e?e==="smooth"?"smooth":"auto":!1}const av=(e,t)=>typeof e=="function"?hu(e(t)):t&&hu(e),lv=Ze(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const b=Y(!1),x=Ye();let g=null;function v(k){Fe(i,{align:"end",behavior:k,index:"LAST"})}Qe(U(bt(U(Ne(t),ir(1)),l),He(Ne(b),s,a,f),le(([[k,T],E,A,j,P])=>{let L=T&&j,$="auto";return L&&($=av(E,A||P),L=L&&!!$),{followOutputBehavior:$,shouldFollow:L,totalCount:k}}),Ae(({shouldFollow:k})=>k)),({followOutputBehavior:k,totalCount:T})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:T},Ft.DEBUG),v(k)}):g=on(e,()=>{xt(d)("following output to ",{totalCount:T},Ft.DEBUG),v(k),g=null})});function w(k){const T=on(o,E=>{k&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Ft.DEBUG),v("auto"))});setTimeout(T,100)}Qe(U(bt(Ne(b),t,u),Ae(([k,,T])=>k&&T),vn(({value:k},[,T])=>({refreshed:k===T,value:T}),{refreshed:!1,value:0}),Ae(({refreshed:k})=>k),He(b,t)),([,k])=>{xt(a)&&w(k!==!1)}),Qe(x,()=>{w(xt(b)!==!1)}),Qe(bt(Ne(b),o),([k,T])=>{k&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=Y(null),N=Ye();return be(Li(U(Ne(r),le(k=>{var T;return(T=k==null?void 0:k.length)!=null?T:0})),U(Ne(t))),N),Qe(U(bt(U(N,ir(1)),l),He(Ne(S),a,f,h),le(([[k,T],E,A,j,P])=>T&&A&&(E==null?void 0:E({context:P,totalCount:k,scrollingInProgress:j}))),Ae(k=>!!k),Mn(0)),k=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Fe(p,k)}):g=on(e,()=>{xt(d)("scrolling into view",{}),Fe(p,k),g=null})}),{autoscrollToBottom:x,followOutput:b,scrollIntoViewOnChange:S}},lt(bn,ao,ro,oo,Wn,Hn,Pt,du,fu)),cv=Ze(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(U(a,He(s),Ae(([,l])=>l!==0),He(o,r,t,n,e),le(([[,l],u,d,f,h,p=[]])=>lu(l,u,d,f,h,p))),i),{}),lt(bn,oo,cr,Wn),{singleton:!0}),uv=Ze(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Qe(U(e,He(r),Ae(([,o])=>o!==0),le(([,o])=>({top:o}))),o=>{on(U(n,ir(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(t,o)})})}),{initialScrollTop:r}},lt(Wn,Pt,cr),{singleton:!0}),pu=Ze(([{scrollVelocity:e}])=>{const t=Y(!1),n=Ye(),r=Y(!1);return be(U(e,He(r,t,n),Ae(([o,s])=>!!s),le(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Qe(U(bt(t,e,n),He(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(ao),{singleton:!0}),Xi=Ze(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ye(),r=Ye(),o=Ye(),s=Y(!1),i=Y(void 0);return be(U(bt(n,r),le(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),be(U(t,He(r),le(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Pt)),dv=Ze(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Ye(),d=Y(void 0),f=Y(null),h=Y(null);return be(a,f),be(l,h),Qe(U(u,He(t,r,i,f,h,n)),([p,b,x,g,v,w,S])=>{const N=Gx(b.sizeTree);g&&v!==null&&w!==null&&(x=v.scrollTop-w.offsetTop),x-=S,p({ranges:N,scrollTop:x})}),be(U(d,Ae(Mi),le(fv)),o),be(U(s,He(d),Ae(([,p])=>p!==void 0),ct(),le(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},lt(bn,Pt,oo,Wn,Xi));function fv(e){return{align:"start",index:0,offset:e.scrollTop}}const hv=Ze(([{topItemsIndexes:e}])=>{const t=Y(0);return be(U(t,Ae(n=>n>=0),le(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(cr));function mu(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pv=mu(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mv=Ze(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:b}])=>{const x=zt(U(l,He(i),vn(([,v,w,S],[{bottom:N,items:k,offsetBottom:T,totalCount:E},A])=>{const j=N+T;let P=0;return w===E&&v.length>0&&k.length>0&&(k[0].originalIndex===0&&v[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,k,E,j]},[0,[],0,0]),Ae(([v])=>v!==0),He(r,a,n,o,p,b),Ae(([,v,w,S,,,N])=>!N&&!S&&v!==0&&w===so),le(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},Ft.DEBUG),v))));function g(v){v>0?(Fe(t,{behavior:"auto",top:-v}),Fe(e,0)):(Fe(e,0),Fe(t,{behavior:"auto",top:-v}))}return Qe(U(x,He(e,s)),([v,w,S])=>{S&&pv()?Fe(e,w-v):g(-v)}),Qe(U(bt(At(s,!1),e,b),Ae(([v,w,S])=>!v&&!S&&w!==0),le(([v,w])=>w),Mn(1)),g),be(U(f,le(v=>({top:-v}))),t),Qe(U(u,He(h,d),le(([v,{groupIndices:w,lastSize:S,sizeTree:N},k])=>{function T(E){return E*(S+k)}if(w.length===0)return T(v);{let E=0;const A=eo(N,0);let j=0,P=0;for(;j<v;){j++,E+=A;let L=w.length===P+1?1/0:w[P+1]-w[P]-1;j+L>v&&(E-=A,L=v-j+1),j+=L,E+=T(L),P++}return E}})),v=>{Fe(e,v),requestAnimationFrame(()=>{Fe(t,{top:v}),requestAnimationFrame(()=>{Fe(e,0),Fe(b,!1)})})}),{deviation:e}},lt(Pt,ao,cr,bn,Hn,Ui)),gv=Ze(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),lt(Gi,cv,Wn,pu,uu,uv,sv,Xi,fu,Hn,du)),gu=Ze(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:b},x,g,v,{listState:w,topItemsIndexes:S,...N},{scrollToIndex:k},T,{topItemCount:E},{groupCounts:A},j])=>(be(N.rangeChanged,j.scrollSeekRangeChanged),be(U(j.windowViewportRect,le(P=>P.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:b,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...v,groupIndices:s,itemSize:i,listState:w,scrollToIndex:k,statefulTotalCount:u,trackItemSizes:f,...N,...j,...x,sizes:l,...g}),lt(bn,oo,Pt,dv,lv,cr,ro,mv,hv,nu,gv));function xv(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 es=typeof document<"u"?y.useLayoutEffect:y.useEffect;function xu(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=y.createContext({});function l(g,v){g.propsReady&&Fe(g.propsReady,!1);for(const w of r){const S=g[t.required[w]];Fe(S,v[w])}for(const w of o)if(w in v){const S=g[t.optional[w]];Fe(S,v[w])}g.propsReady&&Fe(g.propsReady,!0)}function u(g){return s.reduce((v,w)=>(v[w]=S=>{const N=g[t.methods[w]];Fe(N,S)},v),{})}function d(g){return i.reduce((v,w)=>(v[w]=Px(g[t.events[w]]),v),{})}const f=y.forwardRef((g,v)=>{const{children:w,...S}=g,[N]=y.useState(()=>Ko(Mx(e),E=>{l(E,S)})),[k]=y.useState(Bc(d,N));es(()=>{for(const E of i)E in S&&Qe(k[E],S[E]);return()=>{Object.values(k).map(Di)}},[S,k,N]),es(()=>{l(N,S)}),y.useImperativeHandle(v,$c(u(N)));const T=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(T,{...xv([...r,...o,...i],S),children:w}):w})}),h=g=>{const v=y.useContext(a);return y.useCallback(w=>{Fe(v[g],w)},[v,g])},p=g=>{const v=y.useContext(a)[g],w=y.useCallback(S=>Qe(v,S),[v]);return y.useSyncExternalStore(w,()=>xt(v),()=>xt(v))},b=g=>{const v=y.useContext(a)[g],[w,S]=y.useState(Bc(xt,v));return es(()=>Qe(v,N=>{N!==w&&S($c(N))}),[v,w]),w},x=y.version.startsWith("18")?p:b;return{Component:f,useEmitter:(g,v)=>{const w=y.useContext(a)[g];es(()=>Qe(w,v),[v,w])},useEmitterValue:x,usePublisher:h}}const vu=y.createContext(void 0),bu=y.createContext(void 0),wu=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Ji(e){return"self"in e}function vv(e){return"body"in e}function yu(e,t,n,r=_r,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,b,x;const g=h.target;if(vv(g)||Ji(g)){const w=Ji(g)?g:g.defaultView;x=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:b})};h.suppressFlushSync?v():ai.flushSync(v),a.current!==null&&(x===a.current||x<=0||x===p-b)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const b=h.behavior==="smooth";let x,g,v;Ji(p)?(g=Math.max(Un(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Un(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const w=g-x;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),ou(x,g)||h.top===v){e({scrollHeight:g,scrollTop:v,viewportHeight:x}),b&&t(!0);return}b?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Zi="-webkit-sticky",Su="sticky",Qi=mu(()=>{if(typeof document>"u")return Su;const e=document.createElement("div");return e.style.position=Zi,e.style.position===Zi?Zi:Su});function ea(e){return e}const bv=Ze(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(ea),o=Y("div"),s=Y(_r),i=(a,l=null)=>At(U(n,le(u=>u[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),wv=Ze(([e,t])=>({...e,...t}),lt(gu,bv)),yv=({height:e})=>c.jsx("div",{style:{height:e}}),Sv={overflowAnchor:"none",position:Qi(),zIndex:1},Cu={overflowAnchor:"none"},Cv={...Cu,display:"inline-block",height:"100%"},ku=y.memo(function({showTopList:e=!1}){const t=Re("listState"),n=qt("sizeRanges"),r=Re("useWindowScroll"),o=Re("customScrollParent"),s=qt("windowScrollContainerState"),i=qt("scrollContainerState"),a=o||r?s:i,l=Re("itemContent"),u=Re("context"),d=Re("groupContent"),f=Re("trackItemSizes"),h=Re("itemSize"),p=Re("log"),b=qt("gap"),x=Re("horizontalDirection"),{callbackRef:g}=$x(n,h,f,e?_r:a,p,b,o,x,Re("skipAnimationFrameInResizeObserver")),[v,w]=y.useState(0);ta("deviation",M=>{v!==M&&w(M)});const S=Re("EmptyPlaceholder"),N=Re("ScrollSeekPlaceholder")||yv,k=Re("ListComponent"),T=Re("ItemComponent"),E=Re("GroupComponent"),A=Re("computeItemKey"),j=Re("isSeeking"),P=Re("groupIndices").length>0,L=Re("alignToBottom"),$=Re("initialItemFinalLocationReached"),V=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:v!==0?v:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{..._t(S,u)}):c.jsx(k,{..._t(k,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:V,children:(e?t.topItems:t.items).map(M=>{const G=M.originalIndex,K=A(G+t.firstItemIndex,M.data,u);return j?y.createElement(N,{..._t(N,u),height:M.size,index:M.index,key:K,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(E,{..._t(E,u),"data-index":G,"data-item-index":M.index,"data-known-size":M.size,key:K,style:Sv},d(M.index,u)):y.createElement(T,{..._t(T,u),...Ev(T,M.data),"data-index":G,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:K,style:x?Cv:Cu},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),kv={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Tv={outline:"none",overflowX:"auto",position:"relative"},ts=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Iv={position:Qi(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function Ev(e,t){return{item:typeof e=="string"?void 0:t}}const Nv=y.memo(function(){const e=Re("HeaderComponent"),t=qt("headerHeight"),n=Re("HeaderFooterTag"),r=ar(y.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),Av=y.memo(function(){const e=Re("FooterComponent"),t=qt("footerHeight"),n=Re("HeaderFooterTag"),r=ar(y.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null});function Tu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:b}=yu(a,u,l,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Tv:kv,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function Iu({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),b=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:v}=yu(a,u,l,b,h);return wu(()=>{var w;return g.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",v),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,..._t(l,s),children:r})})}const _v=({children:e})=>{const t=y.useContext(vu),n=qt("viewportHeight"),r=qt("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=y.useMemo(()=>Fc(n,l=>Un(l,s?"width":"height")),[n,s]),a=ar(i,!0,Re("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:ts(o),children:e})},jv=({children:e})=>{const t=y.useContext(vu),n=qt("windowViewportRect"),r=qt("fixedItemHeight"),o=Re("customScrollParent"),s=Wc(n,o,Re("skipAnimationFrameInResizeObserver")),i=Re("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:ts(i),children:e})},Rv=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...Iv,marginTop:`${n}px`},o=Re("context");return c.jsx(t,{style:r,..._t(t,o),children:e})},Pv=y.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return c.jsxs(r||t?Dv:Mv,{...e,context:o,children:[n&&c.jsx(Rv,{children:c.jsx(ku,{showTopList:!0})}),c.jsxs(r||t?jv:_v,{children:[c.jsx(Nv,{}),c.jsx(ku,{}),c.jsx(Av,{})]})]})}),{Component:Ov,useEmitter:ta,useEmitterValue:Re,usePublisher:qt}=xu(wv,{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"}},Pv),Mv=Tu({useEmitter:ta,useEmitterValue:Re,usePublisher:qt}),Dv=Iu({useEmitter:ta,useEmitterValue:Re,usePublisher:qt}),Lv=Ov;lt(gu,Ze(()=>{const e=Y(u=>c.jsxs("td",{children:["Item $",u]})),t=Y(null),n=Y(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=Y(null),o=Y(null),s=Y({}),i=Y(ea),a=Y(_r),l=(u,d=null)=>At(U(s,le(f=>f[u]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Qi();const Eu={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},$v={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Nu,floor:ns,max:lo,min:na,round:Au}=Math;function _u(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Fv(e){return{...$v,items:e}}function rs(e,t){return e&&e.width===t.width&&e.height===t.height}function Bv(e,t){return e&&e.column===t.column&&e.row===t.row}const zv=Ze(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:b,propsReady:x},{customScrollParent:g,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:N},k])=>{const T=Y(0),E=Y(0),A=Y(Eu),j=Y({height:0,width:0}),P=Y({height:0,width:0}),L=Ye(),$=Ye(),V=Y(0),M=Y(null),G=Y({column:0,row:0}),K=Ye(),W=Ye(),z=Y(!1),B=Y(0),ue=Y(!0),D=Y(!1),te=Y(!1);Qe(U(b,He(B),Ae(([O,X])=>!!X)),()=>{Fe(ue,!1)}),Qe(U(bt(b,ue,P,j,B,D),Ae(([O,X,ne,pe,,se])=>O&&!X&&ne.height!==0&&pe.height!==0&&!se)),([,,,,O])=>{Fe(D,!0),Ki(1,()=>{Fe(L,O)}),on(U(u),()=>{Fe(t,[0,0]),Fe(ue,!0)})}),be(U(W,Ae(O=>O!=null&&O.scrollTop>0),xn(0)),E),Qe(U(b,He(W),Ae(([,O])=>O!=null)),([,O])=>{O&&(Fe(j,O.viewport),Fe(P,O.item),Fe(G,O.gap),O.scrollTop>0&&(Fe(z,!0),on(U(u,ir(1)),X=>{Fe(z,!1)}),Fe(l,{top:O.scrollTop})))}),be(U(j,le(({height:O})=>O)),f),be(U(bt(Ne(j,rs),Ne(P,rs),Ne(G,(O,X)=>O&&O.column===X.column&&O.row===X.row),Ne(u)),le(([O,X,ne,pe])=>({gap:ne,item:X,scrollTop:pe,viewport:O}))),K),be(U(bt(Ne(T),r,Ne(G,Bv),Ne(P,rs),Ne(j,rs),Ne(M),Ne(E),Ne(z),Ne(ue),Ne(B)),Ae(([,,,,,,,O])=>!O),le(([O,[X,ne],pe,se,me,et,tt,,Pe,Ve])=>{const{column:ut,row:nt}=pe,{height:Ke,width:vt}=se,{width:Q}=me;if(tt===0&&(O===0||Q===0))return Eu;if(vt===0){const ft=qi(Ve,O),It=ft+Math.max(tt-1,0);return Fv(_u(ft,It,et))}const ie=ju(Q,vt,ut);let xe,Ce;Pe?X===0&&ne===0&&tt>0?(xe=0,Ce=tt-1):(xe=ie*ns((X+nt)/(Ke+nt)),Ce=ie*Nu((ne+nt)/(Ke+nt))-1,Ce=na(O-1,lo(Ce,ie-1)),xe=na(Ce,lo(0,xe))):(xe=0,Ce=-1);const ve=_u(xe,Ce,et),{bottom:Oe,top:at}=Ru(me,pe,se,ve),Me=Nu(O/ie),st=Me*Ke+(Me-1)*nt-Oe;return{bottom:Oe,itemHeight:Ke,items:ve,itemWidth:vt,offsetBottom:st,offsetTop:at,top:at}})),A),be(U(M,Ae(O=>O!==null),le(O=>O.length)),T),be(U(bt(j,P,A,G),Ae(([O,X,{items:ne}])=>ne.length>0&&X.height!==0&&O.height!==0),le(([O,X,{items:ne},pe])=>{const{bottom:se,top:me}=Ru(O,pe,X,ne);return[me,se]}),ct(to)),t);const he=Y(!1);be(U(u,He(he),le(([O,X])=>X||O!==0)),he);const we=zt(U(bt(A,T),Ae(([{items:O}])=>O.length>0),He(he),Ae(([[O,X],ne])=>{const pe=O.items[O.items.length-1].index===X-1;return(ne||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===X)&&pe}),le(([[,O]])=>O-1),ct())),ye=zt(U(Ne(A),Ae(({items:O})=>O.length>0&&O[0].index===0),xn(0),ct())),Se=zt(U(Ne(A),He(z),Ae(([{items:O},X])=>O.length>0&&!X),le(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),ct(Jc),Mn(0)));be(Se,p.scrollSeekRangeChanged),be(U(L,He(j,P,T,G),le(([O,X,ne,pe,se])=>{const me=ru(O),{align:et,behavior:tt,offset:Pe}=me;let Ve=me.index;Ve==="LAST"&&(Ve=pe-1),Ve=lo(0,Ve,na(pe-1,Ve));let ut=ra(X,se,ne,Ve);return et==="end"?ut=Au(ut-X.height+ne.height):et==="center"&&(ut=Au(ut-X.height/2+ne.height/2)),Pe&&(ut+=Pe),{behavior:tt,top:ut}})),l);const q=At(U(A,le(O=>O.offsetBottom+O.bottom)),0);return be(U(N,le(O=>({height:O.visibleHeight,width:O.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:V,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:P,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:v,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:te,initialTopMostItemIndex:B,totalListHeight:q,...h,endReached:we,propsReady:x,rangeChanged:Se,startReached:ye,stateChanged:K,stateRestoreInProgress:z,...k}},lt(Gi,Pt,ao,pu,Wn,Xi,Hn));function ju(e,t,n){return lo(1,ns((e+n)/(ns(t)+n)))}function Ru(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ra(e,t,n,r[0].index);return{bottom:ra(e,t,n,r[r.length-1].index)+o,top:s}}function ra(e,t,n,r){const o=ju(e.width,n.width,t.column),s=ns(r/o),i=s*n.height+lo(0,s-1)*t.row;return i>0?i+t.row:i}const Hv=Ze(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(ea),i=Y("div"),a=Y(_r),l=(f,h=null)=>At(U(t,le(p=>p[f]),ct()),h),u=Y(!1),d=Y(!1);return be(Ne(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Uv=Ze(([e,t])=>({...e,...t}),lt(zv,Hv)),Wv=y.memo(function(){const e=dt("gridState"),t=dt("listClassName"),n=dt("itemClassName"),r=dt("itemContent"),o=dt("computeItemKey"),s=dt("isSeeking"),i=Gt("scrollHeight"),a=dt("ItemComponent"),l=dt("ListComponent"),u=dt("ScrollSeekPlaceholder"),d=dt("context"),f=Gt("itemDimensions"),h=Gt("gap"),p=dt("log"),b=dt("stateRestoreInProgress"),x=Gt("reportReadyState"),g=ar(y.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;i(w);const S=v.firstChild;if(S){const{height:N,width:k}=S.getBoundingClientRect();f({height:N,width:k})}h({column:Ou("column-gap",getComputedStyle(v).columnGap,p),row:Ou("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return wu(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),b?null:c.jsx(l,{className:t,ref:g,..._t(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=o(v.index,v.data,d);return s?c.jsx(u,{..._t(u,d),height:e.itemHeight,index:v.index,width:e.itemWidth},w):y.createElement(a,{..._t(a,d),className:n,"data-index":v.index,key:w},r(v.index,v.data,d))})})}),Vv=y.memo(function(){const e=dt("HeaderComponent"),t=Gt("headerHeight"),n=dt("headerFooterTag"),r=ar(y.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=dt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),Kv=y.memo(function(){const e=dt("FooterComponent"),t=Gt("footerHeight"),n=dt("headerFooterTag"),r=ar(y.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=dt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{..._t(e,o)})}):null}),qv=({children:e})=>{const t=y.useContext(bu),n=Gt("itemDimensions"),r=Gt("viewportDimensions"),o=ar(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:ts(!1),children:e})},Gv=({children:e})=>{const t=y.useContext(bu),n=Gt("windowViewportRect"),r=Gt("itemDimensions"),o=dt("customScrollParent"),s=Wc(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:ts(!1),children:e})},Yv=y.memo(function({...e}){const t=dt("useWindowScroll"),n=dt("customScrollParent"),r=n||t?Jv:Xv,o=n||t?Gv:qv,s=dt("context");return c.jsx(r,{...e,..._t(r,s),children:c.jsxs(o,{children:[c.jsx(Vv,{}),c.jsx(Wv,{}),c.jsx(Kv,{})]})})}),{useEmitter:Pu,useEmitterValue:dt,usePublisher:Gt}=xu(Uv,{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"}},Yv),Xv=Tu({useEmitter:Pu,useEmitterValue:dt,usePublisher:Gt}),Jv=Iu({useEmitter:Pu,useEmitterValue:dt,usePublisher:Gt});function Ou(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ft.WARN),t==="normal"?0:parseInt(t??"0",10)}const Zv=Io.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 oa({className:e,variant:t,...n}){return c.jsx("div",{className:ee(Zv({variant:t}),e),...n})}function fe(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 Qv(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function wn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var v;const{scope:h,children:p,...b}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,g=m.useMemo(()=>b,Object.values(b));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,b=m.useContext(p);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,eb(o,...t)]}function eb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Ct=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},tb=m[" useInsertionEffect ".trim().toString()]||Ct;function ur({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=nb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=rb(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function nb({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return tb(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function rb(e){return typeof e=="function"}function Mu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function sa(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Mu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Mu(e[o],null)}}}}function Ge(...e){return m.useCallback(sa(...e),e)}var ob=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_e=ob.reduce((e,t)=>{const n=nr.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Du(e,t){e&&Eo.flushSync(()=>e.dispatchEvent(t))}function sb(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ut=e=>{const{present:t,children:n}=e,r=ib(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Ge(r.ref,ab(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Ut.displayName="Presence";function ib(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=sb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=os(r.current);s.current=a==="mounted"?u:"none"},[a]),Ct(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=os(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Ct(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const x=os(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=os(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function os(e){return(e==null?void 0:e.animationName)||"none"}function ab(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 lb=m[" useId ".trim().toString()]||(()=>{}),cb=0;function yn(e){const[t,n]=m.useState(lb());return Ct(()=>{n(r=>r??String(cb++))},[e]),e||(t?`radix-${t}`:"")}var ss="Collapsible",[ub,Gk]=wn(ss),[db,ia]=ub(ss),Lu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=ur({prop:r,defaultProp:o??!1,onChange:i,caller:ss});return c.jsx(db,{scope:n,disabled:s,contentId:yn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(_e.div,{"data-state":la(l),"data-disabled":s?"":void 0,...a,ref:t})})});Lu.displayName=ss;var $u="CollapsibleTrigger",Fu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ia($u,n);return c.jsx(_e.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":la(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});Fu.displayName=$u;var aa="CollapsibleContent",fb=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ia(aa,e.__scopeCollapsible);return c.jsx(Ut,{present:n||o.open,children:({present:s})=>c.jsx(hb,{...r,ref:t,present:s})})});fb.displayName=aa;var hb=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ia(aa,n),[a,l]=m.useState(r),u=m.useRef(null),d=Ge(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),b=p.current,x=i.open||a,g=m.useRef(x),v=m.useRef(void 0);return m.useEffect(()=>{const w=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(w)},[]),Ct(()=>{const w=u.current;if(w){v.current=v.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(w.style.transitionDuration=v.current.transitionDuration,w.style.animationName=v.current.animationName),l(r)}},[i.open,r]),c.jsx(_e.div,{"data-state":la(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:x&&o})});function la(e){return e?"open":"closed"}var pb=Lu;const Bu=pb,zu=Fu,co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));co.displayName="Card";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));uo.displayName="CardHeader";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));fo.displayName="CardTitle";const Hu=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Hu.displayName="CardDescription";const is=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));is.displayName="CardContent";const Uu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));Uu.displayName="CardFooter";function Wu(){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 dr=Wu();function mb(e){dr=e}const Vu=/[&<>"']/,gb=new RegExp(Vu.source,"g"),Ku=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,xb=new RegExp(Ku.source,"g"),vb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qu=e=>vb[e];function jt(e,t){if(t){if(Vu.test(e))return e.replace(gb,qu)}else if(Ku.test(e))return e.replace(xb,qu);return e}const bb=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Gu(e){return e.replace(bb,(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 wb=/(^|[^\[])\^/g;function ot(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(wb,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const yb=/[^\w:]/g,Sb=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Yu(e,t,n){if(e){let r;try{r=decodeURIComponent(Gu(n)).replace(yb,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Sb.test(n)&&(n=Ib(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const as={},Cb=/^[^:]+:\/*[^/]*$/,kb=/^([^:]+:)[\s\S]*$/,Tb=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Ib(e,t){as[" "+e]||(Cb.test(e)?as[" "+e]=e+"/":as[" "+e]=cs(e,"/",!0)),e=as[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kb,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Tb,"$1")+t:e+t}const ls={exec:function(){}};function Xu(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function cs(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 Eb(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 Nb(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 Ju(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Zu(e,t,n,r){const o=t.href,s=t.title?jt(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:jt(i)}}function Ab(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
40
40
  `).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(`
41
- `)}class ca{constructor(t){this.options=t||fr}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:ls(r,`
42
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Eb(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=ls(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,b,x=n[1].trim();const g=x.length>1,v={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const w=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(b=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
41
+ `)}class ca{constructor(t){this.options=t||dr}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:cs(r,`
42
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=Ab(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=cs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,b,x=n[1].trim();const g=x.length>1,v={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const w=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(b=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
43
43
  `,1)[0].replace(/^\t+/,N=>" ".repeat(3*N.length)),f=t.split(`
44
44
  `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
45
- `,t=t.substring(f.length+1),b=!0),!b){const N=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+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
46
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||N.test(f)||T.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
47
- `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||T.test(d))break;p+=`
45
+ `,t=t.substring(f.length+1),b=!0),!b){const N=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
46
+ `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||E.test(f)||N.test(f)||k.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
47
+ `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||k.test(d))break;p+=`
48
48
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
49
- `,t=t.substring(h.length+1),d=f.slice(i)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=p.trimRight(),v.raw=v.raw.trimRight();const S=v.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,v.items[a].tokens=this.lexer.blockTokens(v.items[a].text,[]),!v.loose){const N=v.items[a].tokens.filter(k=>k.type==="space"),T=N.length>0&&N.some(k=>/\n.*\n/.test(k.raw));v.loose=T}if(v.loose)for(a=0;a<S;a++)v.items[a].loose=!0;return v}}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]):At(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:Gu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
50
- `):[]};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]=Gu(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
51
- `?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:At(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]):At(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=ls(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=kb(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)),Xu(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 Xu(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=At(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=At(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=At(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=At(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=At(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]):At(r[0]):r[0]:o=At(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Te={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:as,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Te._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Te._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Te.def=st(Te.def).replace("label",Te._label).replace("title",Te._title).getRegex(),Te.bullet=/(?:[*+-]|\d{1,9}[.)])/,Te.listItemStart=st(/^( *)(bull) */).replace("bull",Te.bullet).getRegex(),Te.list=st(Te.list).replace(/bull/g,Te.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Te.def.source+")").getRegex(),Te._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",Te._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Te.html=st(Te.html,"i").replace("comment",Te._comment).replace("tag",Te._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te.paragraph=st(Te._paragraph).replace("hr",Te.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",Te._tag).getRegex(),Te.blockquote=st(Te.blockquote).replace("paragraph",Te.paragraph).getRegex(),Te.normal={...Te},Te.gfm={...Te.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Te.gfm.table=st(Te.gfm.table).replace("hr",Te.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",Te._tag).getRegex(),Te.gfm.paragraph=st(Te._paragraph).replace("hr",Te.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Te.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",Te._tag).getRegex(),Te.pedantic={...Te.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Te._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:as,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(Te.normal._paragraph).replace("hr",Te.hr).replace("heading",` *#{1,6} *[^
52
- ]`).replace("lheading",Te.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:as,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:as,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ce._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ce.punctuation=st(ce.punctuation).replace(/punctuation/g,ce._punctuation).getRegex(),ce.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ce.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ce._comment=st(Te._comment).replace("(?:-->|$)","-->").getRegex(),ce.emStrong.lDelim=st(ce.emStrong.lDelim).replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimAst=st(ce.emStrong.rDelimAst,"g").replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimUnd=st(ce.emStrong.rDelimUnd,"g").replace(/punct/g,ce._punctuation).getRegex(),ce._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ce._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ce._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])?)+(?![-_])/,ce.autolink=st(ce.autolink).replace("scheme",ce._scheme).replace("email",ce._email).getRegex(),ce._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ce.tag=st(ce.tag).replace("comment",ce._comment).replace("attribute",ce._attribute).getRegex(),ce._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ce._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ce._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ce.link=st(ce.link).replace("label",ce._label).replace("href",ce._href).replace("title",ce._title).getRegex(),ce.reflink=st(ce.reflink).replace("label",ce._label).replace("ref",Te._label).getRegex(),ce.nolink=st(ce.nolink).replace("ref",Te._label).getRegex(),ce.reflinkSearch=st(ce.reflinkSearch,"g").replace("reflink",ce.reflink).replace("nolink",ce.nolink).getRegex(),ce.normal={...ce},ce.pedantic={...ce.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:st(/^!?\[(label)\]\((.*?)\)/).replace("label",ce._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce._label).getRegex()},ce.gfm={...ce.normal,escape:st(ce.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ce.gfm.url=st(ce.gfm.url,"i").replace("email",ce.gfm._extended_email).getRegex(),ce.breaks={...ce.gfm,br:st(ce.br).replace("{2,}","*").getRegex(),text:st(ce.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function Nb(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 Ju(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 Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||fr,this.options.tokenizer=this.options.tokenizer||new ca,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:Te.normal,inline:ce.normal};this.options.pedantic?(n.block=Te.pedantic,n.inline=ce.pedantic):this.options.gfm&&(n.block=Te.gfm,this.options.breaks?n.inline=ce.breaks:n.inline=ce.gfm),this.tokenizer.rules=n}static get rules(){return{block:Te,inline:ce}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
49
+ `,t=t.substring(h.length+1),d=f.slice(i)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=p.trimRight(),v.raw=v.raw.trimRight();const S=v.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,v.items[a].tokens=this.lexer.blockTokens(v.items[a].text,[]),!v.loose){const N=v.items[a].tokens.filter(T=>T.type==="space"),k=N.length>0&&N.some(T=>/\n.*\n/.test(T.raw));v.loose=k}if(v.loose)for(a=0;a<S;a++)v.items[a].loose=!0;return v}}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]):jt(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:Xu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
50
+ `):[]};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]=Xu(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
51
+ `?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:jt(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]):jt(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=cs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Eb(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)),Zu(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 Zu(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=jt(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=jt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=jt(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=jt(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=jt(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]):jt(r[0]):r[0]:o=jt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Te={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:ls,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Te._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Te._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Te.def=ot(Te.def).replace("label",Te._label).replace("title",Te._title).getRegex(),Te.bullet=/(?:[*+-]|\d{1,9}[.)])/,Te.listItemStart=ot(/^( *)(bull) */).replace("bull",Te.bullet).getRegex(),Te.list=ot(Te.list).replace(/bull/g,Te.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Te.def.source+")").getRegex(),Te._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",Te._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Te.html=ot(Te.html,"i").replace("comment",Te._comment).replace("tag",Te._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te.paragraph=ot(Te._paragraph).replace("hr",Te.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",Te._tag).getRegex(),Te.blockquote=ot(Te.blockquote).replace("paragraph",Te.paragraph).getRegex(),Te.normal={...Te},Te.gfm={...Te.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Te.gfm.table=ot(Te.gfm.table).replace("hr",Te.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",Te._tag).getRegex(),Te.gfm.paragraph=ot(Te._paragraph).replace("hr",Te.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Te.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",Te._tag).getRegex(),Te.pedantic={...Te.normal,html:ot(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Te._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:ls,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ot(Te.normal._paragraph).replace("hr",Te.hr).replace("heading",` *#{1,6} *[^
52
+ ]`).replace("lheading",Te.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ce={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ls,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:ls,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ce._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ce.punctuation=ot(ce.punctuation).replace(/punctuation/g,ce._punctuation).getRegex(),ce.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ce.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ce._comment=ot(Te._comment).replace("(?:-->|$)","-->").getRegex(),ce.emStrong.lDelim=ot(ce.emStrong.lDelim).replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimAst=ot(ce.emStrong.rDelimAst,"g").replace(/punct/g,ce._punctuation).getRegex(),ce.emStrong.rDelimUnd=ot(ce.emStrong.rDelimUnd,"g").replace(/punct/g,ce._punctuation).getRegex(),ce._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ce._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ce._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])?)+(?![-_])/,ce.autolink=ot(ce.autolink).replace("scheme",ce._scheme).replace("email",ce._email).getRegex(),ce._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ce.tag=ot(ce.tag).replace("comment",ce._comment).replace("attribute",ce._attribute).getRegex(),ce._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ce._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ce._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ce.link=ot(ce.link).replace("label",ce._label).replace("href",ce._href).replace("title",ce._title).getRegex(),ce.reflink=ot(ce.reflink).replace("label",ce._label).replace("ref",Te._label).getRegex(),ce.nolink=ot(ce.nolink).replace("ref",Te._label).getRegex(),ce.reflinkSearch=ot(ce.reflinkSearch,"g").replace("reflink",ce.reflink).replace("nolink",ce.nolink).getRegex(),ce.normal={...ce},ce.pedantic={...ce.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:ot(/^!?\[(label)\]\((.*?)\)/).replace("label",ce._label).getRegex(),reflink:ot(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ce._label).getRegex()},ce.gfm={...ce.normal,escape:ot(ce.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ce.gfm.url=ot(ce.gfm.url,"i").replace("email",ce.gfm._extended_email).getRegex(),ce.breaks={...ce.gfm,br:ot(ce.br).replace("{2,}","*").getRegex(),text:ot(ce.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function _b(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 Qu(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Vn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||dr,this.options.tokenizer=this.options.tokenizer||new ca,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:Te.normal,inline:ce.normal};this.options.pedantic?(n.block=Te.pedantic,n.inline=ce.pedantic):this.options.gfm&&(n.block=Te.gfm,this.options.breaks?n.inline=ce.breaks:n.inline=ce.gfm),this.tokenizer.rules=n}static get rules(){return{block:Te,inline:ce}}static lex(t,n){return new Vn(n).lex(t)}static lexInline(t,n){return new Vn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
53
53
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
54
54
  `: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+=`
55
55
  `+r.raw,o.text+=`
@@ -59,9 +59,9 @@ React keys must be passed directly to JSX without using spread:
59
59
  `+r.raw,o.text+=`
60
60
  `+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+=`
61
61
  `+r.raw,o.text+=`
62
- `+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,u;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)+"["+Yu("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)+"["+Yu("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||(u=""),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,u)){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,Ju)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Ju))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,Nb)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=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 ua{constructor(t){this.options=t||fr}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$/,"")+`
63
- `,o?'<pre><code class="'+this.options.langPrefix+At(o)+'">'+(r?t:At(t,!0))+`</code></pre>
64
- `:"<pre><code>"+(r?t:At(t,!0))+`</code></pre>
62
+ `+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,u;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)+"["+Ju("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)+"["+Ju("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||(u=""),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,u)){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,Qu)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Qu))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,_b)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=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 ua{constructor(t){this.options=t||dr}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$/,"")+`
63
+ `,o?'<pre><code class="'+this.options.langPrefix+jt(o)+'">'+(r?t:jt(t,!0))+`</code></pre>
64
+ `:"<pre><code>"+(r?t:jt(t,!0))+`</code></pre>
65
65
  `}blockquote(t){return`<blockquote>
66
66
  ${t}</blockquote>
67
67
  `}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
@@ -79,14 +79,14 @@ ${t}</blockquote>
79
79
  `}tablerow(t){return`<tr>
80
80
  ${t}</tr>
81
81
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
82
- `}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=qu(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=qu(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 Zu{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 Qu{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 Vn{constructor(t){this.options=t||fr,this.options.renderer=this.options.renderer||new ua,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Zu,this.slugger=new Qu}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,b,x,g,v,w,S,N,T,k;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Ku(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(b=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)w=p.items[s],S=w.checked,N=w.task,v="",w.task&&(T=this.renderer.checkbox(S),g?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=T+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=T+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:T}):v+=T),v+=this.parse(w.tokens,g),h+=this.renderer.listitem(v,N,S);r+=this.renderer.list(h,b,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],h+=`
83
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}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 cs{constructor(t){this.options=t||fr}preprocess(t){return t}postprocess(t){return t}}hm(cs,"passThroughHooks",new Set(["preprocess","postprocess"]));function Ab(e,t,n){return r=>{if(r.message+=`
84
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+At(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 ed(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ke.defaults,...s};const i=Ab(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(Ib(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&ke.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;ke.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ke.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&&ke.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ke(e,t,n){return ed(Wn.lex,Vn.parse)(e,t,n)}ke.options=ke.setOptions=function(e){return ke.defaults={...ke.defaults,...e},hb(ke.defaults),ke},ke.getDefaults=Hu,ke.defaults=fr,ke.use=function(...e){const t=ke.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ke.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=ke.defaults.renderer||new ua;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=ke.defaults.tokenizer||new ca;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=ke.defaults.hooks||new cs;for(const s in n.hooks){const i=o[s];cs.passThroughHooks.has(s)?o[s]=a=>{if(ke.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ke.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}}ke.setOptions(r)})},ke.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ke,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ke.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ke.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ke.walkTokens(r.items,t));break}default:ke.defaults.extensions&&ke.defaults.extensions.childTokens&&ke.defaults.extensions.childTokens[r.type]?ke.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ke.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ke.walkTokens(r.tokens,t)))}return n},ke.parseInline=ed(Wn.lexInline,Vn.parseInline),ke.Parser=Vn,ke.parser=Vn.parse,ke.Renderer=ua,ke.TextRenderer=Zu,ke.Lexer=Wn,ke.lexer=Wn.lex,ke.Tokenizer=ca,ke.Slugger=Qu,ke.Hooks=cs,ke.parse=ke,ke.options,ke.setOptions,ke.use,ke.walkTokens,ke.parseInline,Vn.parse,Wn.lex;function da({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.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 ke.parse(i)}return ke.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:Z("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function td(e,t){return await nn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function nd(e,t){return await(await td(`/files/${e}/view`,t)).text()}async function _b(e,t){const n=await td(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await nn(`/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 jb(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await nn("/files",{params:r})}const Rb=1,Pb=1e6;let fa=0;function Ob(){return fa=(fa+1)%Number.MAX_SAFE_INTEGER,fa.toString()}const ha=new Map,rd=e=>{if(ha.has(e))return;const t=setTimeout(()=>{ha.delete(e),fo({type:"REMOVE_TOAST",toastId:e})},Pb);ha.set(e,t)},Mb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Rb)};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?rd(n):e.toasts.forEach(r=>{rd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},us=[];let ds={toasts:[]};function fo(e){ds=Mb(ds,e),us.forEach(t=>{t(ds)})}function Db({...e}){const t=Ob(),n=o=>fo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>fo({type:"DISMISS_TOAST",toastId:t});return fo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function pa(){const[e,t]=m.useState(ds);return m.useEffect(()=>(us.push(t),()=>{const n=us.indexOf(t);n>-1&&us.splice(n,1)}),[e]),{...e,toast:Db,dismiss:n=>fo({type:"DISMISS_TOAST",toastId:n})}}function kt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Lb(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var $b="DismissableLayer",ma="dismissableLayer.update",Fb="dismissableLayer.pointerDownOutside",Bb="dismissableLayer.focusOutside",od,sd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(sd),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),b=Ge(t,E=>f(E)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(g),w=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=w>=v,T=Ub(E=>{const A=E.target,j=[...u.branches].some(P=>P.contains(A));!N||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Wb(E=>{const A=E.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Lb(E=>{w===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(od=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),id(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=od)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),id())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(ma,E),()=>document.removeEventListener(ma,E)},[]),c.jsx(je.div,{...l,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,k.onFocusCapture),onBlurCapture:de(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,T.onPointerDownCapture)})});fs.displayName=$b;var zb="DismissableLayerBranch",Hb=m.forwardRef((e,t)=>{const n=m.useContext(sd),r=m.useRef(null),o=Ge(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(je.div,{...e,ref:o})});Hb.displayName=zb;function Ub(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ad(Fb,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Wb(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&ad(Bb,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 id(){const e=new CustomEvent(ma);document.dispatchEvent(e)}function ad(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?Ou(o,s):o.dispatchEvent(s)}var ga="focusScope.autoFocusOnMount",xa="focusScope.autoFocusOnUnmount",ld={bubbles:!1,cancelable:!0},Vb="FocusScope",hs=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=kt(o),d=kt(s),f=m.useRef(null),h=Ge(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:Kn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||Kn(f.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const T of S)T.removedNodes.length>0&&Kn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const w=new MutationObserver(v);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),w.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){dd.add(p);const x=document.activeElement;if(!a.contains(x)){const v=new CustomEvent(ga,ld);a.addEventListener(ga,u),a.dispatchEvent(v),v.defaultPrevented||(Kb(Jb(cd(a)),{select:!0}),document.activeElement===x&&Kn(a))}return()=>{a.removeEventListener(ga,u),setTimeout(()=>{const v=new CustomEvent(xa,ld);a.addEventListener(xa,d),a.dispatchEvent(v),v.defaultPrevented||Kn(x??document.body,{select:!0}),a.removeEventListener(xa,d),dd.remove(p)},0)}}},[a,u,d,p]);const b=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(g&&v){const w=x.currentTarget,[S,N]=qb(w);S&&N?!x.shiftKey&&v===N?(x.preventDefault(),n&&Kn(S,{select:!0})):x.shiftKey&&v===S&&(x.preventDefault(),n&&Kn(N,{select:!0})):v===w&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(je.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});hs.displayName=Vb;function Kb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Kn(r,{select:t}),document.activeElement!==n)return}function qb(e){const t=cd(e),n=ud(t,e),r=ud(t.reverse(),e);return[n,r]}function cd(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 ud(e,t){for(const n of e)if(!Gb(n,{upTo:t}))return n}function Gb(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 Yb(e){return e instanceof HTMLInputElement&&"select"in e}function Kn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yb(e)&&t&&e.select()}}var dd=Xb();function Xb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=fd(e,t),e.unshift(t)},remove(t){var n;e=fd(e,t),(n=e[0])==null||n.resume()}}}function fd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jb(e){return e.filter(t=>t.tagName!=="A")}var Zb="Portal",ps=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Ct(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?ai.createPortal(c.jsx(je.div,{...r,ref:t}),i):null});ps.displayName=Zb;var va=0;function ba(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??hd()),document.body.insertAdjacentElement("beforeend",e[1]??hd()),va++,()=>{va===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),va--}},[])}function hd(){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 wn=function(){return wn=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},wn.apply(this,arguments)};function pd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Qb(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 ms="right-scroll-bar-position",gs="width-before-scroll-bar",ew="with-scroll-bars-hidden",tw="--removed-body-scroll-bar-size";function wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function nw(e,t){var n=y.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 rw=typeof window<"u"?m.useLayoutEffect:m.useEffect,md=new WeakMap;function ow(e,t){var n=nw(null,function(r){return e.forEach(function(o){return wa(o,r)})});return rw(function(){var r=md.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||wa(a,null)}),s.forEach(function(a){o.has(a)||wa(a,i)})}md.set(n,e)},[e]),n}function sw(e){return e}function iw(e,t){t===void 0&&(t=sw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function aw(e){e===void 0&&(e={});var t=iw(null);return t.options=wn({async:!0,ssr:!1},e),t}var gd=function(e){var t=e.sideCar,n=pd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,wn({},n))};gd.isSideCarExport=!0;function lw(e,t){return e.useMedium(t),gd}var xd=aw(),ya=function(){},xs=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ya,onWheelCapture:ya,onTouchMoveCapture:ya}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,b=e.noIsolation,x=e.inert,g=e.allowPinchZoom,v=e.as,w=v===void 0?"div":v,S=e.gapMode,N=pd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,k=ow([n,t]),E=wn(wn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(T,{sideCar:xd,removeScrollBar:u,shards:f,noRelative:p,noIsolation:b,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),wn(wn({},E),{ref:k})):m.createElement(w,wn({},E,{className:l,ref:k}),a))});xs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xs.classNames={fullWidth:gs,zeroRight:ms};var cw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function uw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=cw();return t&&e.setAttribute("nonce",t),e}function dw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function fw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var hw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=uw())&&(dw(t,n),fw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},pw=function(){var e=hw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},vd=function(){var e=pw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},mw={left:0,top:0,right:0,gap:0},Sa=function(e){return parseInt(e||"",10)||0},gw=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[Sa(n),Sa(r),Sa(o)]},xw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return mw;var t=gw(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])}},vw=vd(),jr="data-scroll-locked",bw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
85
- .`.concat(ew,` {
82
+ `}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=Yu(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=Yu(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 ed{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 td{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Kn{constructor(t){this.options=t||dr,this.options.renderer=this.options.renderer||new ua,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ed,this.slugger=new td}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,b,x,g,v,w,S,N,k,T;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Gu(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(b=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)w=p.items[s],S=w.checked,N=w.task,v="",w.task&&(k=this.renderer.checkbox(S),g?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=k+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=k+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:k}):v+=k),v+=this.parse(w.tokens,g),h+=this.renderer.listitem(v,N,S);r+=this.renderer.list(h,b,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],h+=`
83
+ `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}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 us{constructor(t){this.options=t||dr}preprocess(t){return t}postprocess(t){return t}}mm(us,"passThroughHooks",new Set(["preprocess","postprocess"]));function jb(e,t,n){return r=>{if(r.message+=`
84
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+jt(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 nd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Ie.defaults,...s};const i=jb(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(Nb(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&Ie.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;Ie.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Ie.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&&Ie.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Ie(e,t,n){return nd(Vn.lex,Kn.parse)(e,t,n)}Ie.options=Ie.setOptions=function(e){return Ie.defaults={...Ie.defaults,...e},mb(Ie.defaults),Ie},Ie.getDefaults=Wu,Ie.defaults=dr,Ie.use=function(...e){const t=Ie.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Ie.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=Ie.defaults.renderer||new ua;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=Ie.defaults.tokenizer||new ca;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=Ie.defaults.hooks||new us;for(const s in n.hooks){const i=o[s];us.passThroughHooks.has(s)?o[s]=a=>{if(Ie.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Ie.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}}Ie.setOptions(r)})},Ie.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Ie,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Ie.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Ie.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Ie.walkTokens(r.items,t));break}default:Ie.defaults.extensions&&Ie.defaults.extensions.childTokens&&Ie.defaults.extensions.childTokens[r.type]?Ie.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Ie.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Ie.walkTokens(r.tokens,t)))}return n},Ie.parseInline=nd(Vn.lexInline,Kn.parseInline),Ie.Parser=Kn,Ie.parser=Kn.parse,Ie.Renderer=ua,Ie.TextRenderer=ed,Ie.Lexer=Vn,Ie.lexer=Vn.lex,Ie.Tokenizer=ca,Ie.Slugger=td,Ie.Hooks=us,Ie.parse=Ie,Ie.options,Ie.setOptions,Ie.use,Ie.walkTokens,Ie.parseInline,Kn.parse,Vn.lex;function da({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.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 Ie.parse(i)}return Ie.parse(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre>Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{if(r&&r.color){const i=r.color;return{...r,"--tw-prose-body":i,"--tw-prose-headings":i,"--tw-prose-links":i,"--tw-prose-bold":i,"--tw-prose-counters":i,"--tw-prose-bullets":i,"--tw-prose-hr":i,"--tw-prose-quotes":i,"--tw-prose-quote-borders":i,"--tw-prose-captions":i,"--tw-prose-code":i,"--tw-prose-pre-code":i,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":i,"--tw-prose-td-borders":i}}return r},[r]);return c.jsx("div",{className:ee("markdown prose max-w-none break-words dark:prose-invert",t),style:s,dangerouslySetInnerHTML:{__html:o}})}async function rd(e,t){return await nn(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function od(e,t){return await(await rd(`/files/${e}/view`,t)).text()}async function Rb(e,t){const n=await rd(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await nn(`/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 Pb(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await nn("/files",{params:r})}const Ob=1,Mb=1e6;let fa=0;function Db(){return fa=(fa+1)%Number.MAX_SAFE_INTEGER,fa.toString()}const ha=new Map,sd=e=>{if(ha.has(e))return;const t=setTimeout(()=>{ha.delete(e),ho({type:"REMOVE_TOAST",toastId:e})},Mb);ha.set(e,t)},Lb=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Ob)};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?sd(n):e.toasts.forEach(r=>{sd(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)}}},ds=[];let fs={toasts:[]};function ho(e){fs=Lb(fs,e),ds.forEach(t=>{t(fs)})}function $b({...e}){const t=Db(),n=o=>ho({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ho({type:"DISMISS_TOAST",toastId:t});return ho({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function pa(){const[e,t]=m.useState(fs);return m.useEffect(()=>(ds.push(t),()=>{const n=ds.indexOf(t);n>-1&&ds.splice(n,1)}),[e]),{...e,toast:$b,dismiss:n=>ho({type:"DISMISS_TOAST",toastId:n})}}function Tt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Fb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bb="DismissableLayer",ma="dismissableLayer.update",zb="dismissableLayer.pointerDownOutside",Hb="dismissableLayer.focusOutside",id,ad=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),hs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(ad),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),b=Ge(t,E=>f(E)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(g),w=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=w>=v,k=Vb(E=>{const A=E.target,j=[...u.branches].some(P=>P.contains(A));!N||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),T=Kb(E=>{const A=E.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Fb(E=>{w===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(id=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),ld(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=id)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),ld())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(ma,E),()=>document.removeEventListener(ma,E)},[]),c.jsx(_e.div,{...l,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,k.onPointerDownCapture)})});hs.displayName=Bb;var Ub="DismissableLayerBranch",Wb=m.forwardRef((e,t)=>{const n=m.useContext(ad),r=m.useRef(null),o=Ge(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(_e.div,{...e,ref:o})});Wb.displayName=Ub;function Vb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){cd(zb,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Kb(e,t=globalThis==null?void 0:globalThis.document){const n=Tt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&cd(Hb,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 ld(){const e=new CustomEvent(ma);document.dispatchEvent(e)}function cd(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?Du(o,s):o.dispatchEvent(s)}var ga="focusScope.autoFocusOnMount",xa="focusScope.autoFocusOnUnmount",ud={bubbles:!1,cancelable:!0},qb="FocusScope",ps=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=Tt(o),d=Tt(s),f=m.useRef(null),h=Ge(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:qn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||qn(f.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const k of S)k.removedNodes.length>0&&qn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const w=new MutationObserver(v);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),w.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){hd.add(p);const x=document.activeElement;if(!a.contains(x)){const v=new CustomEvent(ga,ud);a.addEventListener(ga,u),a.dispatchEvent(v),v.defaultPrevented||(Gb(Qb(dd(a)),{select:!0}),document.activeElement===x&&qn(a))}return()=>{a.removeEventListener(ga,u),setTimeout(()=>{const v=new CustomEvent(xa,ud);a.addEventListener(xa,d),a.dispatchEvent(v),v.defaultPrevented||qn(x??document.body,{select:!0}),a.removeEventListener(xa,d),hd.remove(p)},0)}}},[a,u,d,p]);const b=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(g&&v){const w=x.currentTarget,[S,N]=Yb(w);S&&N?!x.shiftKey&&v===N?(x.preventDefault(),n&&qn(S,{select:!0})):x.shiftKey&&v===S&&(x.preventDefault(),n&&qn(N,{select:!0})):v===w&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(_e.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});ps.displayName=qb;function Gb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(qn(r,{select:t}),document.activeElement!==n)return}function Yb(e){const t=dd(e),n=fd(t,e),r=fd(t.reverse(),e);return[n,r]}function dd(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 fd(e,t){for(const n of e)if(!Xb(n,{upTo:t}))return n}function Xb(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 Jb(e){return e instanceof HTMLInputElement&&"select"in e}function qn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Jb(e)&&t&&e.select()}}var hd=Zb();function Zb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=pd(e,t),e.unshift(t)},remove(t){var n;e=pd(e,t),(n=e[0])==null||n.resume()}}}function pd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Qb(e){return e.filter(t=>t.tagName!=="A")}var ew="Portal",ms=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Ct(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?ai.createPortal(c.jsx(_e.div,{...r,ref:t}),i):null});ms.displayName=ew;var va=0;function ba(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??md()),document.body.insertAdjacentElement("beforeend",e[1]??md()),va++,()=>{va===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),va--}},[])}function md(){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 Sn=function(){return Sn=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},Sn.apply(this,arguments)};function gd(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 tw(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 gs="right-scroll-bar-position",xs="width-before-scroll-bar",nw="with-scroll-bars-hidden",rw="--removed-body-scroll-bar-size";function wa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function ow(e,t){var n=y.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 sw=typeof window<"u"?m.useLayoutEffect:m.useEffect,xd=new WeakMap;function iw(e,t){var n=ow(null,function(r){return e.forEach(function(o){return wa(o,r)})});return sw(function(){var r=xd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||wa(a,null)}),s.forEach(function(a){o.has(a)||wa(a,i)})}xd.set(n,e)},[e]),n}function aw(e){return e}function lw(e,t){t===void 0&&(t=aw);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function cw(e){e===void 0&&(e={});var t=lw(null);return t.options=Sn({async:!0,ssr:!1},e),t}var vd=function(e){var t=e.sideCar,n=gd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,Sn({},n))};vd.isSideCarExport=!0;function uw(e,t){return e.useMedium(t),vd}var bd=cw(),ya=function(){},vs=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:ya,onWheelCapture:ya,onTouchMoveCapture:ya}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,b=e.noIsolation,x=e.inert,g=e.allowPinchZoom,v=e.as,w=v===void 0?"div":v,S=e.gapMode,N=gd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=h,T=iw([n,t]),E=Sn(Sn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(k,{sideCar:bd,removeScrollBar:u,shards:f,noRelative:p,noIsolation:b,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),Sn(Sn({},E),{ref:T})):m.createElement(w,Sn({},E,{className:l,ref:T}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vs.classNames={fullWidth:xs,zeroRight:gs};var dw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function fw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=dw();return t&&e.setAttribute("nonce",t),e}function hw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function pw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var mw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=fw())&&(hw(t,n),pw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},gw=function(){var e=mw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wd=function(){var e=gw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},xw={left:0,top:0,right:0,gap:0},Sa=function(e){return parseInt(e||"",10)||0},vw=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[Sa(n),Sa(r),Sa(o)]},bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return xw;var t=vw(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])}},ww=wd(),Rr="data-scroll-locked",yw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
85
+ .`.concat(nw,` {
86
86
  overflow: hidden `).concat(r,`;
87
87
  padding-right: `).concat(a,"px ").concat(r,`;
88
88
  }
89
- body[`).concat(jr,`] {
89
+ body[`).concat(Rr,`] {
90
90
  overflow: hidden `).concat(r,`;
91
91
  overscroll-behavior: contain;
92
92
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -99,37 +99,37 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
99
99
  `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
100
100
  }
101
101
 
102
- .`).concat(ms,` {
102
+ .`).concat(gs,` {
103
103
  right: `).concat(a,"px ").concat(r,`;
104
104
  }
105
105
 
106
- .`).concat(gs,` {
106
+ .`).concat(xs,` {
107
107
  margin-right: `).concat(a,"px ").concat(r,`;
108
108
  }
109
109
 
110
- .`).concat(ms," .").concat(ms,` {
110
+ .`).concat(gs," .").concat(gs,` {
111
111
  right: 0 `).concat(r,`;
112
112
  }
113
113
 
114
- .`).concat(gs," .").concat(gs,` {
114
+ .`).concat(xs," .").concat(xs,` {
115
115
  margin-right: 0 `).concat(r,`;
116
116
  }
117
117
 
118
- body[`).concat(jr,`] {
119
- `).concat(tw,": ").concat(a,`px;
118
+ body[`).concat(Rr,`] {
119
+ `).concat(rw,": ").concat(a,`px;
120
120
  }
121
- `)},bd=function(){var e=parseInt(document.body.getAttribute(jr)||"0",10);return isFinite(e)?e:0},ww=function(){m.useEffect(function(){return document.body.setAttribute(jr,(bd()+1).toString()),function(){var e=bd()-1;e<=0?document.body.removeAttribute(jr):document.body.setAttribute(jr,e.toString())}},[])},yw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;ww();var s=m.useMemo(function(){return xw(o)},[o]);return m.createElement(vw,{styles:bw(s,!t,o,n?"":"!important")})},Ca=!1;if(typeof window<"u")try{var vs=Object.defineProperty({},"passive",{get:function(){return Ca=!0,!0}});window.addEventListener("test",vs,vs),window.removeEventListener("test",vs,vs)}catch{Ca=!1}var Rr=Ca?{passive:!1}:!1,Sw=function(e){return e.tagName==="TEXTAREA"},wd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Sw(e)&&n[t]==="visible")},Cw=function(e){return wd(e,"overflowY")},Tw=function(e){return wd(e,"overflowX")},yd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Sd(e,r);if(o){var s=Cd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},kw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Iw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Sd=function(e,t){return e==="v"?Cw(t):Tw(t)},Cd=function(e,t){return e==="v"?kw(t):Iw(t)},Ew=function(e,t){return e==="h"&&t==="rtl"?-1:1},Nw=function(e,t,n,r,o){var s=Ew(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Cd(e,a),b=p[0],x=p[1],g=p[2],v=x-g-s*b;(b||v)&&Sd(e,a)&&(f+=v,h+=b);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},bs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Td=function(e){return[e.deltaX,e.deltaY]},kd=function(e){return e&&"current"in e?e.current:e},Aw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},_w=function(e){return`
121
+ `)},yd=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},Sw=function(){m.useEffect(function(){return document.body.setAttribute(Rr,(yd()+1).toString()),function(){var e=yd()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},Cw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Sw();var s=m.useMemo(function(){return bw(o)},[o]);return m.createElement(ww,{styles:yw(s,!t,o,n?"":"!important")})},Ca=!1;if(typeof window<"u")try{var bs=Object.defineProperty({},"passive",{get:function(){return Ca=!0,!0}});window.addEventListener("test",bs,bs),window.removeEventListener("test",bs,bs)}catch{Ca=!1}var Pr=Ca?{passive:!1}:!1,kw=function(e){return e.tagName==="TEXTAREA"},Sd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!kw(e)&&n[t]==="visible")},Tw=function(e){return Sd(e,"overflowY")},Iw=function(e){return Sd(e,"overflowX")},Cd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=kd(e,r);if(o){var s=Td(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ew=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Nw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},kd=function(e,t){return e==="v"?Tw(t):Iw(t)},Td=function(e,t){return e==="v"?Ew(t):Nw(t)},Aw=function(e,t){return e==="h"&&t==="rtl"?-1:1},_w=function(e,t,n,r,o){var s=Aw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Td(e,a),b=p[0],x=p[1],g=p[2],v=x-g-s*b;(b||v)&&kd(e,a)&&(f+=v,h+=b);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},ws=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Id=function(e){return[e.deltaX,e.deltaY]},Ed=function(e){return e&&"current"in e?e.current:e},jw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Rw=function(e){return`
122
122
  .block-interactivity-`.concat(e,` {pointer-events: none;}
123
123
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
124
- `)},jw=0,Pr=[];function Rw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(jw++)[0],s=m.useState(vd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Qb([e.lockRef.current],(e.shards||[]).map(kd),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=bs(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-v[0],N="deltaY"in x?x.deltaY:w[1]-v[1],T,k=x.target,E=Math.abs(S)>Math.abs(N)?"h":"v";if("touches"in x&&E==="h"&&k.type==="range")return!1;var A=yd(E,k);if(!A)return!0;if(A?T=E:(T=E==="v"?"h":"v",A=yd(E,k)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||N)&&(r.current=T),!T)return!0;var j=r.current||T;return Nw(j,g,x,j==="h"?S:N)},[]),l=m.useCallback(function(x){var g=x;if(!(!Pr.length||Pr[Pr.length-1]!==s)){var v="deltaY"in g?Td(g):bs(g),w=t.current.filter(function(T){return T.name===g.type&&(T.target===g.target||g.target===T.shadowParent)&&Aw(T.delta,v)})[0];if(w&&w.should){g.cancelable&&g.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(kd).filter(Boolean).filter(function(T){return T.contains(g.target)}),N=S.length>0?a(g,S[0]):!i.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,v,w){var S={name:x,delta:g,target:v,should:w,shadowParent:Pw(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(N){return N!==S})},1)},[]),d=m.useCallback(function(x){n.current=bs(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Td(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,bs(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Pr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",d,Rr),function(){Pr=Pr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",d,Rr)}},[]);var p=e.removeScrollBar,b=e.inert;return m.createElement(m.Fragment,null,b?m.createElement(s,{styles:_w(o)}):null,p?m.createElement(yw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Pw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Ow=lw(xd,Rw);var ws=m.forwardRef(function(e,t){return m.createElement(xs,wn({},e,{ref:t,sideCar:Ow}))});ws.classNames=xs.classNames;var Mw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Or=new WeakMap,ys=new WeakMap,Ss={},Ta=0,Id=function(e){return e&&(e.host||Id(e.parentNode))},Dw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Id(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})},Lw=function(e,t,n,r){var o=Dw(t,Array.isArray(e)?e:[e]);Ss[n]||(Ss[n]=new WeakMap);var s=Ss[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),b=p!==null&&p!=="false",x=(Or.get(h)||0)+1,g=(s.get(h)||0)+1;Or.set(h,x),s.set(h,g),i.push(h),x===1&&b&&ys.set(h,!0),g===1&&h.setAttribute(n,"true"),b||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return d(t),a.clear(),Ta++,function(){i.forEach(function(f){var h=Or.get(f)-1,p=s.get(f)-1;Or.set(f,h),s.set(f,p),h||(ys.has(f)||f.removeAttribute(r),ys.delete(f)),p||f.removeAttribute(n)}),Ta--,Ta||(Or=new WeakMap,Or=new WeakMap,ys=new WeakMap,Ss={})}},ka=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Mw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Lw(r,o,n,"aria-hidden")):function(){return null}},Cs="Dialog",[Ed,KT]=vn(Cs),[$w,an]=Ed(Cs),Nd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Cs});return c.jsx($w,{scope:t,triggerRef:a,contentRef:l,contentId:bn(),titleId:bn(),descriptionId:bn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Nd.displayName=Cs;var Ad="DialogTrigger",_d=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ad,n),s=Ge(t,o.triggerRef);return c.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:de(e.onClick,o.onOpenToggle)})});_d.displayName=Ad;var Ia="DialogPortal",[Fw,jd]=Ed(Ia,{forceMount:void 0}),Rd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=an(Ia,t);return c.jsx(Fw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Wt,{present:n||s.open,children:c.jsx(ps,{asChild:!0,container:o,children:i})}))})};Rd.displayName=Ia;var Ts="DialogOverlay",Pd=m.forwardRef((e,t)=>{const n=jd(Ts,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(Ts,e.__scopeDialog);return s.modal?c.jsx(Wt,{present:r||s.open,children:c.jsx(zw,{...o,ref:t})}):null});Pd.displayName=Ts;var Bw=rr.createSlot("DialogOverlay.RemoveScroll"),zw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ts,n);return c.jsx(ws,{as:Bw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(je.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),hr="DialogContent",Od=m.forwardRef((e,t)=>{const n=jd(hr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(hr,e.__scopeDialog);return c.jsx(Wt,{present:r||s.open,children:s.modal?c.jsx(Hw,{...o,ref:t}):c.jsx(Uw,{...o,ref:t})})});Od.displayName=hr;var Hw=m.forwardRef((e,t)=>{const n=an(hr,e.__scopeDialog),r=m.useRef(null),o=Ge(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return ka(s)},[]),c.jsx(Md,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:de(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:de(e.onFocusOutside,s=>s.preventDefault())})}),Uw=m.forwardRef((e,t)=>{const n=an(hr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Md,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Md=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=an(hr,n),l=m.useRef(null),u=Ge(t,l);return ba(),c.jsxs(c.Fragment,{children:[c.jsx(hs,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(fs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(Ww,{titleId:a.titleId}),c.jsx(Kw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ea="DialogTitle",Dd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ea,n);return c.jsx(je.h2,{id:o.titleId,...r,ref:t})});Dd.displayName=Ea;var Ld="DialogDescription",$d=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ld,n);return c.jsx(je.p,{id:o.descriptionId,...r,ref:t})});$d.displayName=Ld;var Fd="DialogClose",Bd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Fd,n);return c.jsx(je.button,{type:"button",...r,ref:t,onClick:de(e.onClick,()=>o.onOpenChange(!1))})});Bd.displayName=Fd;function Na(e){return e?"open":"closed"}var zd="DialogTitleWarning",[qT,Hd]=Jv(zd,{contentName:hr,titleName:Ea,docsSlug:"dialog"}),Ww=({titleId:e})=>{const t=Hd(zd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
124
+ `)},Pw=0,Or=[];function Ow(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Pw++)[0],s=m.useState(wd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=tw([e.lockRef.current],(e.shards||[]).map(Ed),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=ws(x),w=n.current,S="deltaX"in x?x.deltaX:w[0]-v[0],N="deltaY"in x?x.deltaY:w[1]-v[1],k,T=x.target,E=Math.abs(S)>Math.abs(N)?"h":"v";if("touches"in x&&E==="h"&&T.type==="range")return!1;var A=Cd(E,T);if(!A)return!0;if(A?k=E:(k=E==="v"?"h":"v",A=Cd(E,T)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||N)&&(r.current=k),!k)return!0;var j=r.current||k;return _w(j,g,x,j==="h"?S:N)},[]),l=m.useCallback(function(x){var g=x;if(!(!Or.length||Or[Or.length-1]!==s)){var v="deltaY"in g?Id(g):ws(g),w=t.current.filter(function(k){return k.name===g.type&&(k.target===g.target||g.target===k.shadowParent)&&jw(k.delta,v)})[0];if(w&&w.should){g.cancelable&&g.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Ed).filter(Boolean).filter(function(k){return k.contains(g.target)}),N=S.length>0?a(g,S[0]):!i.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,v,w){var S={name:x,delta:g,target:v,should:w,shadowParent:Mw(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(N){return N!==S})},1)},[]),d=m.useCallback(function(x){n.current=ws(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Id(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,ws(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Pr),document.addEventListener("touchmove",l,Pr),document.addEventListener("touchstart",d,Pr),function(){Or=Or.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,Pr),document.removeEventListener("touchmove",l,Pr),document.removeEventListener("touchstart",d,Pr)}},[]);var p=e.removeScrollBar,b=e.inert;return m.createElement(m.Fragment,null,b?m.createElement(s,{styles:Rw(o)}):null,p?m.createElement(Cw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Mw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Dw=uw(bd,Ow);var ys=m.forwardRef(function(e,t){return m.createElement(vs,Sn({},e,{ref:t,sideCar:Dw}))});ys.classNames=vs.classNames;var Lw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,Ss=new WeakMap,Cs={},ka=0,Nd=function(e){return e&&(e.host||Nd(e.parentNode))},$w=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Nd(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})},Fw=function(e,t,n,r){var o=$w(t,Array.isArray(e)?e:[e]);Cs[n]||(Cs[n]=new WeakMap);var s=Cs[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),b=p!==null&&p!=="false",x=(Mr.get(h)||0)+1,g=(s.get(h)||0)+1;Mr.set(h,x),s.set(h,g),i.push(h),x===1&&b&&Ss.set(h,!0),g===1&&h.setAttribute(n,"true"),b||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return d(t),a.clear(),ka++,function(){i.forEach(function(f){var h=Mr.get(f)-1,p=s.get(f)-1;Mr.set(f,h),s.set(f,p),h||(Ss.has(f)||f.removeAttribute(r),Ss.delete(f)),p||f.removeAttribute(n)}),ka--,ka||(Mr=new WeakMap,Mr=new WeakMap,Ss=new WeakMap,Cs={})}},Ta=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Lw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fw(r,o,n,"aria-hidden")):function(){return null}},ks="Dialog",[Ad,Yk]=wn(ks),[Bw,an]=Ad(ks),_d=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=ur({prop:r,defaultProp:o??!1,onChange:s,caller:ks});return c.jsx(Bw,{scope:t,triggerRef:a,contentRef:l,contentId:yn(),titleId:yn(),descriptionId:yn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};_d.displayName=ks;var jd="DialogTrigger",Rd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(jd,n),s=Ge(t,o.triggerRef);return c.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Na(o.open),...r,ref:s,onClick:fe(e.onClick,o.onOpenToggle)})});Rd.displayName=jd;var Ia="DialogPortal",[zw,Pd]=Ad(Ia,{forceMount:void 0}),Od=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=an(Ia,t);return c.jsx(zw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Ut,{present:n||s.open,children:c.jsx(ms,{asChild:!0,container:o,children:i})}))})};Od.displayName=Ia;var Ts="DialogOverlay",Md=m.forwardRef((e,t)=>{const n=Pd(Ts,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(Ts,e.__scopeDialog);return s.modal?c.jsx(Ut,{present:r||s.open,children:c.jsx(Uw,{...o,ref:t})}):null});Md.displayName=Ts;var Hw=nr.createSlot("DialogOverlay.RemoveScroll"),Uw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ts,n);return c.jsx(ys,{as:Hw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(_e.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),fr="DialogContent",Dd=m.forwardRef((e,t)=>{const n=Pd(fr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(fr,e.__scopeDialog);return c.jsx(Ut,{present:r||s.open,children:s.modal?c.jsx(Ww,{...o,ref:t}):c.jsx(Vw,{...o,ref:t})})});Dd.displayName=fr;var Ww=m.forwardRef((e,t)=>{const n=an(fr,e.__scopeDialog),r=m.useRef(null),o=Ge(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Ta(s)},[]),c.jsx(Ld,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault())})}),Vw=m.forwardRef((e,t)=>{const n=an(fr,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Ld,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Ld=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=an(fr,n),l=m.useRef(null),u=Ge(t,l);return ba(),c.jsxs(c.Fragment,{children:[c.jsx(ps,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(hs,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(Kw,{titleId:a.titleId}),c.jsx(Gw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ea="DialogTitle",$d=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ea,n);return c.jsx(_e.h2,{id:o.titleId,...r,ref:t})});$d.displayName=Ea;var Fd="DialogDescription",Bd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Fd,n);return c.jsx(_e.p,{id:o.descriptionId,...r,ref:t})});Bd.displayName=Fd;var zd="DialogClose",Hd=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(zd,n);return c.jsx(_e.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});Hd.displayName=zd;function Na(e){return e?"open":"closed"}var Ud="DialogTitleWarning",[Xk,Wd]=Qv(Ud,{contentName:fr,titleName:Ea,docsSlug:"dialog"}),Kw=({titleId:e})=>{const t=Wd(Ud),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
125
125
 
126
126
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
127
127
 
128
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Vw="DialogDescriptionWarning",Kw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Hd(Vw).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ud=Nd,qw=_d,Wd=Rd,ks=Pd,Is=Od,pr=Dd,Es=$d,Vd=Bd;const Gw=Ud,Yw=Wd,Kd=m.forwardRef(({className:e,...t},n)=>c.jsx(ks,{ref:n,className:Z("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}));Kd.displayName=ks.displayName;const qd=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===pr||(u==null?void 0:u.displayName)===pr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(Yw,{children:[c.jsx(Kd,{}),c.jsxs(Is,{ref:r,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(pr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Vd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ie.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});qd.displayName=Is.displayName;const Gd=({className:e,...t})=>c.jsx("div",{className:Z("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Gd.displayName="DialogHeader";const Yd=m.forwardRef(({className:e,...t},n)=>c.jsx(pr,{ref:n,className:Z("text-lg font-semibold leading-none tracking-tight",e),...t}));Yd.displayName=pr.displayName;const Xw=m.forwardRef(({className:e,...t},n)=>c.jsx(Es,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));Xw.displayName=Es.displayName;function Jw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=pa(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const v=await nd(n);l(v)}catch(v){console.error("Failed to load file:",v),d(v instanceof Error?v.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await _b(n),f({title:"Download started",description:`Downloading ${r}`})}catch(v){console.error("Failed to download file:",v),f({title:"Download failed",description:String(v),variant:"destructive"})}},b=async()=>{if(n)try{const v=await nd(n),w=new Blob([v],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(v){console.error("Failed to open file externally:",v),f({title:"Failed to open file",description:String(v),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ie.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Je,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ie.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ie.Image,{className:"h-5 w-5"}):c.jsx(ie.FileText,{className:"h-5 w-5"});return c.jsx(Gw,{open:e,onOpenChange:t,children:c.jsxs(qd,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Gd,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(Yd,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Je,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[c.jsx(ie.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Je,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ie.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function Xd(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 Jd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function ho(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(ho).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Jd(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=ho(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 Aa(e){if(typeof e=="string")return e;if(Jd(e))return"";try{const t=ho(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Zd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return Zd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),b=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=b?b[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Ns="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",mr=1e5;function Zw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Qw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function ey(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function ty(e){const t=(r,o=mr)=>{try{const s=ho(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
129
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function ny(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function ry(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Qd(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function oy({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:Z("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const ef=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:b,onRegenerate:x,onCancelEdit:g,onCopy:v}){const[w,S]=y.useState(!1),[N,T]=y.useState("collapsed"),[k,E]=y.useState(!1),{currentThreadId:A}=zo(),{respondToInterrupt:j}=Ho(),{toast:P}=pa(),[L,$]=y.useState({}),[V,M]=y.useState(!1),[G,K]=y.useState(null),W=l==="phone"||l==="half-screen",B=t.role,F=B==="tool",ue=!(r&&B!=="user"),D=y.useMemo(()=>{switch(B){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))]"}},[B]),Q=y.useMemo(()=>Zw(t.content),[t.content]),fe=y.useMemo(()=>Qw(t.content),[t.content]),we=y.useMemo(()=>t.content.filter(J=>J.type==="image_url"),[t.content]),ye=y.useMemo(()=>t.content.filter(J=>J.type==="file"),[t.content]),Se=y.useMemo(()=>t.content.filter(J=>J.type==="interrupt"),[t.content]),q=y.useMemo(()=>ty(t.content),[t.content]);y.useMemo(()=>ny(t.content),[t.content]);const O=y.useMemo(()=>q.length<=mr?q:`${q.slice(0,mr)}
130
- … [truncated ${q.length-mr} chars]`,[q]),X=y.useCallback(async(J="all")=>{const ge=J==="visible"&&F?O:F?q:Q;async function Ce(xe){try{await navigator.clipboard.writeText(xe)}catch{try{const Me=document.createElement("textarea");Me.value=xe,Me.setAttribute("readonly",""),Me.style.position="absolute",Me.style.left="-9999px",document.body.appendChild(Me),Me.select(),document.execCommand("copy"),document.body.removeChild(Me)}catch(Me){throw console.error("Failed to copy:",Me),Me}}}try{await Ce(ge),S(!0),setTimeout(()=>S(!1),2e3),v==null||v(ge)}catch(xe){console.error("Failed to copy:",xe)}},[F,q,Q,O,v]),ee=y.useCallback(()=>{if(!b)return;const J=F?q:Q;b(t.id,J)},[b,t.id,F,q,Q]),pe=y.useCallback(()=>{x==null||x(n)},[x,n]),oe=y.useCallback(async(J,se,ge)=>{if(!ue){J.preventDefault();return}if(L[ge]){J.preventDefault();return}try{const Ce=String(se.url??""),xe=Ce.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(xe){J.preventDefault();const Me=xe[1],at=se.name||`file_${Me}`,De=se.mimeType||"application/octet-stream";K({id:Me,name:at,mimeType:De}),M(!0);return}if(Ce.startsWith("data:")){J.preventDefault(),$(De=>({...De,[ge]:!0}));const Me=`${se.name}_${se.size}_${Date.now()}`,at=P({title:"Fetching file...",description:"",open:!0});try{const De=await jb(A??void 0);if(!De||!Array.isArray(De))throw new Error("Invalid file list response");const it=De.find(vt=>!vt||typeof vt!="object"||!((vt.filename??"")===(se.name??""))?!1:typeof se.size=="number"&&typeof vt.size=="number"?vt.size===se.size:!0);if(!(it!=null&&it.id))throw new Error(`File "${se.name}" is not yet available on the server`);if(!it.id||!it.filename)throw new Error("Invalid file data received from server");K({id:it.id,name:se.name||it.filename||`file_${it.id}`,mimeType:se.mimeType||it.mime_type||"application/octet-stream"}),M(!0),at.update({id:at.id,title:"Success",description:`Opened ${se.name}`,open:!0})}catch(De){console.error("Failed to fetch server file:",De);const it=De instanceof Error?De.message:"Unknown error occurred";at.update({id:at.id,title:"Failed",description:it}),P({title:"Failed to fetch file",description:it,open:!0})}finally{$(De=>({...De,[ge]:!1}))}}}catch(Ce){console.error("File click error:",Ce),$(xe=>({...xe,[ge]:!1}))}},[ue,L,P,A]),me=y.useCallback(()=>{const se=Z(W?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(B){case"user":return c.jsx(ie.User,{className:se});case"assistant":return c.jsx(ie.Bot,{className:se});case"tool":return c.jsx(ie.Wrench,{className:se});default:return c.jsx(ie.Bot,{className:se})}},[W,D,B]),et=y.useCallback(()=>{const J="group relative mb-4 flex w-full";switch(B){case"user":return Z(J,"justify-end");case"assistant":case"tool":case"system":return Z(J,"justify-start");default:return J}},[B]),tt=y.useCallback(()=>{const J=Z("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",W&&"px-3 py-2 text-sm");switch(B){case"user":return Z(J,"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 Z(J,"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 Z(J,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Z(J,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Z(J,"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")}},[W,B]),Oe=y.useCallback(async J=>{try{const se=(J==null?void 0:J.id)||(J==null?void 0:J.interrupt_id);if(!se){console.warn("Interrupt part missing id",J);return}await j(se,!0)}catch(se){console.error("Failed to approve interrupt:",se)}},[j]),We=y.useCallback(async J=>{try{const se=(J==null?void 0:J.id)||(J==null?void 0:J.interrupt_id);if(!se){console.warn("Interrupt part missing id",J);return}await j(se,!1)}catch(se){console.error("Failed to reject interrupt:",se)}},[j]),ut=y.useCallback(({part:J,i:se})=>{if(J.type==="text"){const ge=J.text??"",Ce=ge.trim(),xe=Xd(Ce);return xe&&B!=="tool"?c.jsx(sy,{data:xe},se):B==="user"&&f&&Ce.length>h?c.jsxs($u,{open:k,onOpenChange:E,children:[c.jsx("div",{className:Z("text-sm text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:k?c.jsx(da,{content:Ce,allowHtml:!1}):c.jsxs("pre",{className:Z("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:[Ce.substring(0,h),"..."]})}),c.jsx(Fu,{asChild:!0,children:c.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:k?c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ce.length-h," chars)"]})})})]},se):c.jsx(da,{content:ge,allowHtml:!1},se)}if(J.type==="image_url"){const ge=J;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ge.url,alt:ge.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},se)}if(J.type==="file"){const ge=J,Ce=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:xe=>oe(xe,ge,se),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
131
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[se]?c.jsx(ie.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ce,L[se]?" (processing)":""]})]},se)}return J.type==="interrupt"?c.jsx(ay,{interruptPart:J,onApprove:Oe,onReject:We},se):null},[oe,L,Oe,We,B,f,h,k,W]),rt=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ie.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ve=y.useCallback(()=>{const J=Q.trim().length>0||we.length>0||ye.length>0||Se.length>0;if(!F&&!J&&!r)return rt();if(t.model==="reflection"){const se=Q.trim(),ge=Xd(se);if(ge&&typeof ge=="object")return c.jsx(ly,{data:ge})}if(F&&fe.name==="get_issues"){const se=t.content.find(xe=>xe.type==="tool_end"),ge=(se==null?void 0:se.output)??q,Ce=Zd(ge);if(Ce)return c.jsx(cy,{issues:Ce})}if(F){const se=ey(t.content);if(se.length>0)return c.jsx("div",{className:"space-y-2",children:se.map((ge,Ce)=>{const xe=typeof ge.output=="string"?ge.output:Aa(ge.output),Me=xe.length>mr?`${xe.slice(0,mr)}
132
- … [truncated ${xe.length-mr} chars]`:xe,at=N==="expanded";return c.jsxs($u,{open:at,onOpenChange:De=>T(De?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(oa,{variant:"outline",children:(ge.name??"tool")+(ge.toolCallId?` • ${ge.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:at?Me:Me.slice(0,d)+(Me.length>d?"...":"")})}),c.jsx(Fu,{asChild:!0,children:c.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:at?c.jsxs(c.Fragment,{children:[" ",c.jsx(ie.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ie.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ge.toolCallId??Ce)})})}if(!F){const se=c.jsx("div",{className:"space-y-2",children:t.content.map((ge,Ce)=>c.jsx(ut,{part:ge,i:Ce},Ce))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[se,c.jsx(oy,{className:D})]}):se}},[Q,we.length,ye.length,Se.length,r,t.model,F,fe.name,q,N,u,rt,D]),xt=y.useMemo(()=>ry(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Z(et(),p.container),children:c.jsxs("div",{className:Z(tt(),p.content),children:[(i||a||F)&&c.jsxs("div",{className:Z("flex items-center justify-between mb-2 pb-2 border-b border-current/10",W&&"mb-1 pb-1",D,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[me(),a&&xt&&c.jsx("span",{className:Z("font-medium",W?"text-xs":"text-sm"),children:xt}),F&&fe.name&&c.jsxs(oa,{variant:"outline",className:Z("text-xs flex items-center gap-1 cursor-pointer",D,"border border-current/40",W&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),T(se=>se==="collapsed"?"preview":"collapsed"))},onClick:()=>T(J=>J==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:fe.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})})]}),F&&!fe.name&&c.jsx(Je,{variant:"ghost",size:"sm",className:Z("h-6 px-1",D,"hover:bg-foreground/10"),onClick:()=>T(J=>J==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(ie.ChevronUp,{className:"h-3 w-3"}):c.jsx(ie.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Z("text-xs opacity-60",D,W&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:Z("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X(F?"visible":"all"),className:Z("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":F?"Copy visible":"Copy message",title:F?"Copy visible portion":"Copy message",children:c.jsx(ie.Copy,{className:Z(w?"text-success":D,W?"h-3 w-3":"h-4 w-4")})}),F&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X("all"),className:Z("h-6 px-1 text-xs hover:bg-foreground/10",D),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),B==="user"&&b&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ie.Edit,{className:Z(D,W?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:pe,className:Z("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ie.RotateCcw,{className:Z(D,W?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Ve()}),F&&N==="expanded"&&(fe.toolCallId||fe.name)&&c.jsxs("div",{className:Z("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",W&&"text-xs"),children:[fe.name&&c.jsxs("div",{children:["Function: ",fe.name]}),fe.toolCallId&&c.jsxs("div",{children:["Call ID: ",fe.toolCallId]})]}),!(i||a||F)&&s&&!o&&c.jsxs("div",{className:Z("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X(),className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Copy,{className:Z(w?"text-success":"text-current",W?"h-3 w-3":"h-4 w-4")})}),B==="user"&&b&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:ee,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.Edit,{className:Z("text-current",W?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:pe,className:Z("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ie.RotateCcw,{className:Z("text-current",W?"h-3 w-3":"h-4 w-4")})})]})]})}),G&&c.jsx(Jw,{isOpen:V,onClose:()=>{M(!1),K(null)},fileId:G.id,fileName:G.name,mimeType:G.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Qd(e.message)===Qd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function sy({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Ns,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Aa(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:Ns,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Ns,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:iy(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Aa(e)})}function iy(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(ho(e))})}catch{return String(e)}}function ay({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(lo,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(co,{className:"pb-3",children:[c.jsx(uo,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Bu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(zu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Je,{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",children:"Reject"}),c.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function ly({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function cy({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Ns,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const tf=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,_a=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:b=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:v},w)=>{const S=y.useRef(null),N=y.useRef(null),T=y.useRef(!1),[k,E]=y.useState(!0),A=y.useCallback(L=>{E(L),g&&g(!L),v&&v(L)},[g,v]),j=y.useMemo(()=>{if(a)return async()=>{if(!T.current){T.current=!0;try{await a()}finally{T.current=!1}}}},[a]),P=y.useMemo(()=>!b||x?!1:k?"auto":!1,[k,b,x]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Mv,{ref:L=>{S.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,$)=>tf($,L),itemContent:(L,$)=>{const V=tf($,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(ef,{message:$,messageIndex:L,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(L),onCancelEdit:d})})}})})});_a.displayName="MessageList";const As=1e4;function uy(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,`
128
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},qw="DialogDescriptionWarning",Gw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wd(qw).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Vd=_d,Yw=Rd,Kd=Od,Is=Md,Es=Dd,hr=$d,Ns=Bd,qd=Hd;const Xw=Vd,Jw=Kd,Gd=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{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}));Gd.displayName=Is.displayName;const Yd=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===hr||(u==null?void 0:u.displayName)===hr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(Jw,{children:[c.jsx(Gd,{}),c.jsxs(Es,{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&&c.jsx(hr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(qd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Yd.displayName=Es.displayName;const Xd=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Xd.displayName="DialogHeader";const Jd=m.forwardRef(({className:e,...t},n)=>c.jsx(hr,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));Jd.displayName=hr.displayName;const Zw=m.forwardRef(({className:e,...t},n)=>c.jsx(Ns,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Zw.displayName=Ns.displayName;function Qw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=pa(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const v=await od(n);l(v)}catch(v){console.error("Failed to load file:",v),d(v instanceof Error?v.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Rb(n),f({title:"Download started",description:`Downloading ${r}`})}catch(v){console.error("Failed to download file:",v),f({title:"Download failed",description:String(v),variant:"destructive"})}},b=async()=>{if(n)try{const v=await od(n),w=new Blob([v],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(v){console.error("Failed to open file externally:",v),f({title:"Failed to open file",description:String(v),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Je,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ae.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(Xw,{open:e,onOpenChange:t,children:c.jsxs(Yd,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Xd,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(Jd,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Je,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Je,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function Zd(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 Qd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function po(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(po).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Qd(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=po(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 Aa(e){if(typeof e=="string")return e;if(Qd(e))return"";try{const t=po(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ef(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return ef(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),b=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),x=p?p[2].trim():"",g=b?b[2].trim():"";n[i].push({title:x,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const As="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",pr=1e5;function ey(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function ty(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function ny(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function ry(e){const t=(r,o=pr)=>{try{const s=po(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
129
+ … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function oy(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function sy(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function tf(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function iy({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ee("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const nf=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:b,onRegenerate:x,onCancelEdit:g,onCopy:v}){const[w,S]=y.useState(!1),[N,k]=y.useState("collapsed"),[T,E]=y.useState(!1),{currentThreadId:A}=Ho(),{respondToInterrupt:j}=Uo(),{toast:P}=pa(),[L,$]=y.useState({}),[V,M]=y.useState(!1),[G,K]=y.useState(null),W=l==="phone"||l==="half-screen",z=t.role,B=z==="tool",ue=!(r&&z!=="user"),D=y.useMemo(()=>{switch(z){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))]"}},[z]),te=y.useMemo(()=>ey(t.content),[t.content]),he=y.useMemo(()=>ty(t.content),[t.content]),we=y.useMemo(()=>t.content.filter(Q=>Q.type==="image_url"),[t.content]),ye=y.useMemo(()=>t.content.filter(Q=>Q.type==="file"),[t.content]),Se=y.useMemo(()=>t.content.filter(Q=>Q.type==="interrupt"),[t.content]),q=y.useMemo(()=>ry(t.content),[t.content]);y.useMemo(()=>oy(t.content),[t.content]);const O=y.useMemo(()=>q.length<=pr?q:`${q.slice(0,pr)}
130
+ … [truncated ${q.length-pr} chars]`,[q]),X=y.useCallback(async(Q="all")=>{const xe=Q==="visible"&&B?O:B?q:te;async function Ce(ve){try{await navigator.clipboard.writeText(ve)}catch{try{const Oe=document.createElement("textarea");Oe.value=ve,Oe.setAttribute("readonly",""),Oe.style.position="absolute",Oe.style.left="-9999px",document.body.appendChild(Oe),Oe.select(),document.execCommand("copy"),document.body.removeChild(Oe)}catch(Oe){throw console.error("Failed to copy:",Oe),Oe}}}try{await Ce(xe),S(!0),setTimeout(()=>S(!1),2e3),v==null||v(xe)}catch(ve){console.error("Failed to copy:",ve)}},[B,q,te,O,v]),ne=y.useCallback(()=>{if(!b)return;const Q=B?q:te;b(t.id,Q)},[b,t.id,B,q,te]),pe=y.useCallback(()=>{x==null||x(n)},[x,n]),se=y.useCallback(async(Q,ie,xe)=>{if(!ue){Q.preventDefault();return}if(L[xe]){Q.preventDefault();return}try{const Ce=String(ie.url??""),ve=Ce.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(ve){Q.preventDefault();const Oe=ve[1],at=ie.name||`file_${Oe}`,Me=ie.mimeType||"application/octet-stream";K({id:Oe,name:at,mimeType:Me}),M(!0);return}if(Ce.startsWith("data:")){Q.preventDefault(),$(Me=>({...Me,[xe]:!0}));const Oe=`${ie.name}_${ie.size}_${Date.now()}`,at=P({title:"Fetching file...",description:"",open:!0});try{const Me=await Pb(A??void 0);if(!Me||!Array.isArray(Me))throw new Error("Invalid file list response");const st=Me.find(ft=>!ft||typeof ft!="object"||!((ft.filename??"")===(ie.name??""))?!1:typeof ie.size=="number"&&typeof ft.size=="number"?ft.size===ie.size:!0);if(!(st!=null&&st.id))throw new Error(`File "${ie.name}" is not yet available on the server`);if(!st.id||!st.filename)throw new Error("Invalid file data received from server");K({id:st.id,name:ie.name||st.filename||`file_${st.id}`,mimeType:ie.mimeType||st.mime_type||"application/octet-stream"}),M(!0),at.update({id:at.id,title:"Success",description:`Opened ${ie.name}`,open:!0})}catch(Me){console.error("Failed to fetch server file:",Me);const st=Me instanceof Error?Me.message:"Unknown error occurred";at.update({id:at.id,title:"Failed",description:st}),P({title:"Failed to fetch file",description:st,open:!0})}finally{$(Me=>({...Me,[xe]:!1}))}}}catch(Ce){console.error("File click error:",Ce),$(ve=>({...ve,[xe]:!1}))}},[ue,L,P,A]),me=y.useCallback(()=>{const ie=ee(W?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(z){case"user":return c.jsx(ae.User,{className:ie});case"assistant":return c.jsx(ae.Bot,{className:ie});case"tool":return c.jsx(ae.Wrench,{className:ie});default:return c.jsx(ae.Bot,{className:ie})}},[W,D,z]),et=y.useCallback(()=>{const Q="group relative mb-4 flex w-full";switch(z){case"user":return ee(Q,"justify-end");case"assistant":case"tool":case"system":return ee(Q,"justify-start");default:return Q}},[z]),tt=y.useCallback(()=>{const Q=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",W&&"px-3 py-2 text-sm");switch(z){case"user":return ee(Q,"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(Q,"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(Q,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(Q,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(Q,"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")}},[W,z]),Pe=y.useCallback(async Q=>{try{const ie=(Q==null?void 0:Q.id)||(Q==null?void 0:Q.interrupt_id);if(!ie){console.warn("Interrupt part missing id",Q);return}await j(ie,!0)}catch(ie){console.error("Failed to approve interrupt:",ie)}},[j]),Ve=y.useCallback(async Q=>{try{const ie=(Q==null?void 0:Q.id)||(Q==null?void 0:Q.interrupt_id);if(!ie){console.warn("Interrupt part missing id",Q);return}await j(ie,!1)}catch(ie){console.error("Failed to reject interrupt:",ie)}},[j]),ut=y.useCallback(({part:Q,i:ie})=>{if(Q.type==="text"){const xe=Q.text??"",Ce=xe.trim(),ve=Zd(Ce);return ve&&z!=="tool"?c.jsx(ay,{data:ve},ie):z==="user"&&f&&Ce.length>h?c.jsxs(Bu,{open:T,onOpenChange:E,children:[c.jsx("div",{className:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:T?c.jsx(da,{content:Ce,allowHtml:!1}):c.jsxs("pre",{className:ee("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",W&&"text-xs"),children:[Ce.substring(0,h),"..."]})}),c.jsx(zu,{asChild:!0,children:c.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ce.length-h," chars)"]})})})]},ie):c.jsx(da,{content:xe,allowHtml:!1},ie)}if(Q.type==="image_url"){const xe=Q;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:xe.url,alt:xe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ie)}if(Q.type==="file"){const xe=Q,Ce=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:ve=>se(ve,xe,ie),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
131
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[ie]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ce,L[ie]?" (processing)":""]})]},ie)}return Q.type==="interrupt"?c.jsx(cy,{interruptPart:Q,onApprove:Pe,onReject:Ve},ie):null},[se,L,Pe,Ve,z,f,h,T,W]),nt=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Ke=y.useCallback(()=>{const Q=te.trim().length>0||we.length>0||ye.length>0||Se.length>0;if(!B&&!Q&&!r)return nt();if(t.model==="reflection"){const ie=te.trim(),xe=Zd(ie);if(xe&&typeof xe=="object")return c.jsx(uy,{data:xe})}if(B&&he.name==="get_issues"){const ie=t.content.find(ve=>ve.type==="tool_end"),xe=(ie==null?void 0:ie.output)??q,Ce=ef(xe);if(Ce)return c.jsx(dy,{issues:Ce})}if(B){const ie=ny(t.content);if(ie.length>0)return c.jsx("div",{className:"space-y-2",children:ie.map((xe,Ce)=>{const ve=typeof xe.output=="string"?xe.output:Aa(xe.output),Oe=ve.length>pr?`${ve.slice(0,pr)}
132
+ … [truncated ${ve.length-pr} chars]`:ve,at=N==="expanded";return c.jsxs(Bu,{open:at,onOpenChange:Me=>k(Me?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(oa,{variant:"outline",children:(xe.name??"tool")+(xe.toolCallId?` • ${xe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:at?Oe:Oe.slice(0,d)+(Oe.length>d?"...":"")})}),c.jsx(zu,{asChild:!0,children:c.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:at?c.jsxs(c.Fragment,{children:[" ",c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Ce)})})}if(!B){const ie=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Ce)=>c.jsx(ut,{part:xe,i:Ce},Ce))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ie,c.jsx(iy,{className:D})]}):ie}},[te,we.length,ye.length,Se.length,r,t.model,B,he.name,q,N,u,nt,D]),vt=y.useMemo(()=>sy(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ee(et(),p.container),children:c.jsxs("div",{className:ee(tt(),p.content),children:[(i||a||B)&&c.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",W&&"mb-1 pb-1",D,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[me(),a&&vt&&c.jsx("span",{className:ee("font-medium",W?"text-xs":"text-sm"),children:vt}),B&&he.name&&c.jsxs(oa,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer",D,"border border-current/40",W&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),k(ie=>ie==="collapsed"?"preview":"collapsed"))},onClick:()=>k(Q=>Q==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:he.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})})]}),B&&!he.name&&c.jsx(Je,{variant:"ghost",size:"sm",className:ee("h-6 px-1",D,"hover:bg-foreground/10"),onClick:()=>k(Q=>Q==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:ee("text-xs opacity-60",D,W&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:ee("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X(B?"visible":"all"),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":B?"Copy visible":"Copy message",title:B?"Copy visible portion":"Copy message",children:c.jsx(ae.Copy,{className:ee(w?"text-success":D,W?"h-3 w-3":"h-4 w-4")})}),B&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X("all"),className:ee("h-6 px-1 text-xs hover:bg-foreground/10",D),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),z==="user"&&b&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:ne,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:ee(D,W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:pe,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",D,W&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:ee(D,W?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Ke()}),B&&N==="expanded"&&(he.toolCallId||he.name)&&c.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",W&&"text-xs"),children:[he.name&&c.jsxs("div",{children:["Function: ",he.name]}),he.toolCallId&&c.jsxs("div",{children:["Call ID: ",he.toolCallId]})]}),!(i||a||B)&&s&&!o&&c.jsxs("div",{className:ee("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>X(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:ee(w?"text-success":"text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="user"&&b&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:ne,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:ee("text-current",W?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:pe,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",W&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:ee("text-current",W?"h-3 w-3":"h-4 w-4")})})]})]})}),G&&c.jsx(Qw,{isOpen:V,onClose:()=>{M(!1),K(null)},fileId:G.id,fileName:G.name,mimeType:G.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&tf(e.message)===tf(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function ay({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:As,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Aa(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:As,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:As,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:ly(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Aa(e)})}function ly(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(po(e))})}catch{return String(e)}}function cy({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(co,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(uo,{className:"pb-3",children:[c.jsx(fo,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Hu,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Uu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Je,{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",children:"Reject"}),c.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function uy({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function dy({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:As,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const rf=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,_a=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:b=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:v},w)=>{const S=y.useRef(null),N=y.useRef(null),k=y.useRef(!1),[T,E]=y.useState(!0),A=y.useCallback(L=>{E(L),g&&g(!L),v&&v(L)},[g,v]),j=y.useMemo(()=>{if(a)return async()=>{if(!k.current){k.current=!0;try{await a()}finally{k.current=!1}}}},[a]),P=y.useMemo(()=>!b||x?!1:T?"auto":!1,[T,b,x]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Lv,{ref:L=>{S.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:e,followOutput:P,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{j&&j()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,$)=>rf($,L),itemContent:(L,$)=>{const V=rf($,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":V,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(nf,{message:$,messageIndex:L,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(L),onCancelEdit:d})})}})})});_a.displayName="MessageList";const _s=1e4;function fy(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,`
133
133
  `).replace(/<p>(.*?)<\/p>/gi,`$1
134
134
 
135
135
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -137,4 +137,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
137
137
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
138
138
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
139
139
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
140
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function dy(e,t=As){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 fy(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),dy(t),uy(t)}function ja(e){const t=e+"CollectionProvider",[n,r]=vn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:v}=x,w=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:w,children:v})};i.displayName=t;const a=e+"CollectionSlot",l=rr.createSlot(a),u=y.forwardRef((x,g)=>{const{scope:v,children:w}=x,S=s(a,v),N=Ge(g,S.collectionRef);return c.jsx(l,{ref:N,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=rr.createSlot(d),p=y.forwardRef((x,g)=>{const{scope:v,children:w,...S}=x,N=y.useRef(null),T=Ge(g,N),k=s(d,v);return y.useEffect(()=>(k.itemMap.set(N,{ref:N,...S}),()=>void k.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:T,children:w})});p.displayName=d;function b(x){const g=s(e+"CollectionConsumer",x);return y.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},b,r]}var hy=m.createContext(void 0);function _s(e){const t=m.useContext(hy);return e||t||"ltr"}const py=["top","right","bottom","left"],qn=Math.min,Vt=Math.max,js=Math.round,Rs=Math.floor,yn=e=>({x:e,y:e}),my={left:"right",right:"left",bottom:"top",top:"bottom"},gy={start:"end",end:"start"};function Ra(e,t,n){return Vt(e,qn(t,n))}function On(e,t){return typeof e=="function"?e(t):e}function Mn(e){return e.split("-")[0]}function Mr(e){return e.split("-")[1]}function Pa(e){return e==="x"?"y":"x"}function Oa(e){return e==="y"?"height":"width"}const xy=new Set(["top","bottom"]);function Sn(e){return xy.has(Mn(e))?"y":"x"}function Ma(e){return Pa(Sn(e))}function vy(e,t,n){n===void 0&&(n=!1);const r=Mr(e),o=Ma(e),s=Oa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Ps(i)),[i,Ps(i)]}function by(e){const t=Ps(e);return[Da(e),t,Da(t)]}function Da(e){return e.replace(/start|end/g,t=>gy[t])}const nf=["left","right"],rf=["right","left"],wy=["top","bottom"],yy=["bottom","top"];function Sy(e,t,n){switch(e){case"top":case"bottom":return n?t?rf:nf:t?nf:rf;case"left":case"right":return t?wy:yy;default:return[]}}function Cy(e,t,n,r){const o=Mr(e);let s=Sy(Mn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Da)))),s}function Ps(e){return e.replace(/left|right|bottom|top/g,t=>my[t])}function Ty(e){return{top:0,right:0,bottom:0,left:0,...e}}function of(e){return typeof e!="number"?Ty(e):{top:e,right:e,bottom:e,left:e}}function Os(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 sf(e,t,n){let{reference:r,floating:o}=e;const s=Sn(t),i=Ma(t),a=Oa(i),l=Mn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Mr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const ky=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=sf(u,r,l),h=r,p={},b=0;for(let x=0;x<a.length;x++){const{name:g,fn:v}=a[x],{x:w,y:S,data:N,reset:T}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[g]:{...p[g],...N}},T&&b<=50&&(b++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(u=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=sf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function po(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=On(t,e),b=of(p),g=a[h?f==="floating"?"reference":"floating":f],v=Os(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=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=Os(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(v.top-T.top+b.top)/N.y,bottom:(T.bottom-v.bottom+b.bottom)/N.y,left:(v.left-T.left+b.left)/N.x,right:(T.right-v.right+b.right)/N.x}}const Iy=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=On(e,t)||{};if(u==null)return{};const f=of(d),h={x:n,y:r},p=Ma(o),b=Oa(p),x=await i.getDimensions(u),g=p==="y",v=g?"top":"left",w=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[b]+s.reference[p]-h[p]-s.floating[b],T=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[b]);const A=N/2-T/2,j=E/2-x[b]/2-1,P=qn(f[v],j),L=qn(f[w],j),$=P,V=E-x[b]-L,M=E/2-x[b]/2+A,G=Ra($,M,V),K=!l.arrow&&Mr(o)!=null&&M!==G&&s.reference[b]/2-(M<$?P:L)-x[b]/2<0,W=K?M<$?M-$:M-V:0;return{[p]:h[p]+W,data:{[p]:G,centerOffset:M-G-W,...K&&{alignmentOffset:W}},reset:K}}}),Ey=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...g}=On(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Mn(o),w=Sn(a),S=Mn(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),T=h||(S||!x?[Ps(a)]:by(a)),k=b!=="none";!h&&k&&T.push(...Cy(a,x,b,N));const E=[a,...T],A=await po(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[v]),f){const M=vy(o,i,N);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var L,$;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,G=E[M];if(G&&(!(f==="alignment"?w!==Sn(G):!1)||P.every(B=>Sn(B.placement)===w?B.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:G}};let K=($=P.filter(W=>W.overflows[0]<=0).sort((W,B)=>W.overflows[1]-B.overflows[1])[0])==null?void 0:$.placement;if(!K)switch(p){case"bestFit":{var V;const W=(V=P.filter(B=>{if(k){const F=Sn(B.placement);return F===w||F==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(F=>F>0).reduce((F,ue)=>F+ue,0)]).sort((B,F)=>B[1]-F[1])[0])==null?void 0:V[0];W&&(K=W);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function af(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function lf(e){return py.some(t=>e[t]>=0)}const Ny=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=On(e,t);switch(r){case"referenceHidden":{const s=await po(t,{...o,elementContext:"reference"}),i=af(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:lf(i)}}}case"escaped":{const s=await po(t,{...o,altBoundary:!0}),i=af(s,n.floating);return{data:{escapedOffsets:i,escaped:lf(i)}}}default:return{}}}}},cf=new Set(["left","top"]);async function Ay(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Mn(n),a=Mr(n),l=Sn(n)==="y",u=cf.has(i)?-1:1,d=s&&l?-1:1,f=On(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(p=a==="end"?b*-1:b),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const _y=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 Ay(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}}}}},jy=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:v,y:w}=g;return{x:v,y:w}}},...l}=On(e,t),u={x:n,y:r},d=await po(t,l),f=Sn(Mn(o)),h=Pa(f);let p=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=p+d[g],S=p-d[v];p=Ra(w,p,S)}if(i){const g=f==="y"?"top":"left",v=f==="y"?"bottom":"right",w=b+d[g],S=b-d[v];b=Ra(w,b,S)}const x=a.fn({...t,[h]:p,[f]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Ry=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=On(e,t),d={x:n,y:r},f=Sn(o),h=Pa(f);let p=d[h],b=d[f];const x=On(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,T=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>T&&(p=T)}if(u){var v,w;const S=h==="y"?"width":"height",N=cf.has(Mn(o)),T=s.reference[f]-s.floating[S]+(N&&((v=i.offset)==null?void 0:v[f])||0)+(N?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(N?0:((w=i.offset)==null?void 0:w[f])||0)-(N?g.crossAxis:0);b<T?b=T:b>k&&(b=k)}return{[h]:p,[f]:b}}}},Py=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=On(e,t),d=await po(t,u),f=Mn(o),h=Mr(o),p=Sn(o)==="y",{width:b,height:x}=s.floating;let g,v;f==="top"||f==="bottom"?(g=f,v=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,g=h==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=b-d.left-d.right,N=qn(x-d[g],w),T=qn(b-d[v],S),k=!t.middlewareData.shift;let E=N,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),k&&!h){const P=Vt(d.left,0),L=Vt(d.right,0),$=Vt(d.top,0),V=Vt(d.bottom,0);p?A=b-2*(P!==0||L!==0?P+L:Vt(d.left,d.right)):E=x-2*($!==0||V!==0?$+V:Vt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return b!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function Ms(){return typeof window<"u"}function Dr(e){return uf(e)?(e.nodeName||"").toLowerCase():"#document"}function Kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Cn(e){var t;return(t=(uf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function uf(e){return Ms()?e instanceof Node||e instanceof Kt(e).Node:!1}function ln(e){return Ms()?e instanceof Element||e instanceof Kt(e).Element:!1}function Tn(e){return Ms()?e instanceof HTMLElement||e instanceof Kt(e).HTMLElement:!1}function df(e){return!Ms()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Kt(e).ShadowRoot}const Oy=new Set(["inline","contents"]);function mo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Oy.has(o)}const My=new Set(["table","td","th"]);function Dy(e){return My.has(Dr(e))}const Ly=[":popover-open",":modal"];function Ds(e){return Ly.some(t=>{try{return e.matches(t)}catch{return!1}})}const $y=["transform","translate","scale","rotate","perspective"],Fy=["transform","translate","scale","rotate","perspective","filter"],By=["paint","layout","strict","content"];function La(e){const t=$a(),n=ln(e)?cn(e):e;return $y.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)||Fy.some(r=>(n.willChange||"").includes(r))||By.some(r=>(n.contain||"").includes(r))}function zy(e){let t=Gn(e);for(;Tn(t)&&!Lr(t);){if(La(t))return t;if(Ds(t))return null;t=Gn(t)}return null}function $a(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Hy=new Set(["html","body","#document"]);function Lr(e){return Hy.has(Dr(e))}function cn(e){return Kt(e).getComputedStyle(e)}function Ls(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gn(e){if(Dr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||df(e)&&e.host||Cn(e);return df(t)?t.host:t}function ff(e){const t=Gn(e);return Lr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Tn(t)&&mo(t)?t:ff(t)}function go(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ff(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Kt(o);if(s){const a=Fa(i);return t.concat(i,i.visualViewport||[],mo(o)?o:[],a&&n?go(a):[])}return t.concat(o,go(o,[],n))}function Fa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hf(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Tn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=js(n)!==s||js(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ba(e){return ln(e)?e:e.contextElement}function $r(e){const t=Ba(e);if(!Tn(t))return yn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=hf(t);let i=(s?js(n.width):n.width)/r,a=(s?js(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Uy=yn(0);function pf(e){const t=Kt(e);return!$a()||!t.visualViewport?Uy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wy(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Kt(e)?!1:t}function gr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ba(e);let i=yn(1);t&&(r?ln(r)&&(i=$r(r)):i=$r(e));const a=Wy(s,n,r)?pf(s):yn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Kt(s),p=r&&ln(r)?Kt(r):r;let b=h,x=Fa(b);for(;x&&r&&p!==b;){const g=$r(x),v=x.getBoundingClientRect(),w=cn(x),S=v.left+(x.clientLeft+parseFloat(w.paddingLeft))*g.x,N=v.top+(x.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,b=Kt(x),x=Fa(b)}}return Os({width:d,height:f,x:l,y:u})}function $s(e,t){const n=Ls(e).scrollLeft;return t?t.left+n:gr(Cn(e)).left+n}function mf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-$s(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Vy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Cn(r),a=t?Ds(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=yn(1);const d=yn(0),f=Tn(r);if((f||!f&&!s)&&((Dr(r)!=="body"||mo(i))&&(l=Ls(r)),Tn(r))){const p=gr(r);u=$r(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?mf(i,l):yn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Ky(e){return Array.from(e.getClientRects())}function qy(e){const t=Cn(e),n=Ls(e),r=e.ownerDocument.body,o=Vt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Vt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+$s(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Vt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const gf=25;function Gy(e,t){const n=Kt(e),r=Cn(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=$a();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=$s(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,b=Math.abs(r.clientWidth-f.clientWidth-p);b<=gf&&(s-=b)}else u<=gf&&(s+=u);return{width:s,height:i,x:a,y:l}}const Yy=new Set(["absolute","fixed"]);function Xy(e,t){const n=gr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Tn(e)?$r(e):yn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function xf(e,t,n){let r;if(t==="viewport")r=Gy(e,n);else if(t==="document")r=qy(Cn(e));else if(ln(t))r=Xy(t,n);else{const o=pf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Os(r)}function vf(e,t){const n=Gn(e);return n===t||!ln(n)||Lr(n)?!1:cn(n).position==="fixed"||vf(n,t)}function Jy(e,t){const n=t.get(e);if(n)return n;let r=go(e,[],!1).filter(a=>ln(a)&&Dr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?Gn(e):e;for(;ln(i)&&!Lr(i);){const a=cn(i),l=La(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Yy.has(o.position)||mo(i)&&!l&&vf(e,i))?r=r.filter(d=>d!==i):o=a,i=Gn(i)}return t.set(e,r),r}function Zy(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ds(t)?[]:Jy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=xf(t,d,o);return u.top=Vt(f.top,u.top),u.right=qn(f.right,u.right),u.bottom=qn(f.bottom,u.bottom),u.left=Vt(f.left,u.left),u},xf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Qy(e){const{width:t,height:n}=hf(e);return{width:t,height:n}}function e0(e,t,n){const r=Tn(t),o=Cn(t),s=n==="fixed",i=gr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=yn(0);function u(){l.x=$s(o)}if(r||!r&&!s)if((Dr(t)!=="body"||mo(o))&&(a=Ls(t)),r){const p=gr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?mf(o,a):yn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function za(e){return cn(e).position==="static"}function bf(e,t){if(!Tn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Cn(e)===n&&(n=n.ownerDocument.body),n}function wf(e,t){const n=Kt(e);if(Ds(e))return n;if(!Tn(e)){let o=Gn(e);for(;o&&!Lr(o);){if(ln(o)&&!za(o))return o;o=Gn(o)}return n}let r=bf(e,t);for(;r&&Dy(r)&&za(r);)r=bf(r,t);return r&&Lr(r)&&za(r)&&!La(r)?n:r||zy(e)||n}const t0=async function(e){const t=this.getOffsetParent||wf,n=this.getDimensions,r=await n(e.floating);return{reference:e0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function n0(e){return cn(e).direction==="rtl"}const r0={convertOffsetParentRelativeRectToViewportRelativeRect:Vy,getDocumentElement:Cn,getClippingRect:Zy,getOffsetParent:wf,getElementRects:t0,getClientRects:Ky,getDimensions:Qy,getScale:$r,isElement:ln,isRTL:n0};function yf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function o0(e,t){let n=null,r;const o=Cn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const b=Rs(f),x=Rs(o.clientWidth-(d+h)),g=Rs(o.clientHeight-(f+p)),v=Rs(d),S={rootMargin:-b+"px "+-x+"px "+-g+"px "+-v+"px",threshold:Vt(0,qn(1,l))||1};let N=!0;function T(k){const E=k[0].intersectionRatio;if(E!==l){if(!N)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!yf(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(T,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,S)}n.observe(e)}return i(!0),s}function s0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Ba(e),d=o||s?[...u?go(u):[],...go(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?o0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(v=>{let[w]=v;w&&w.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let b,x=l?gr(e):null;l&&g();function g(){const v=gr(e);x&&!yf(x,v)&&n(),x=v,b=requestAnimationFrame(g)}return n(),()=>{var v;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(b)}}const i0=_y,a0=jy,l0=Ey,c0=Py,u0=Ny,Sf=Iy,d0=Ry,f0=(e,t,n)=>{const r=new Map,o={platform:r0,...n},s={...o.platform,_c:r};return ky(e,t,{...o,platform:s})};var h0=typeof document<"u",p0=function(){},Fs=h0?y.useLayoutEffect:p0;function Bs(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(!Bs(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)&&!Bs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Cf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tf(e,t){const n=Cf(e);return Math.round(t*n)/n}function Ha(e){const t=m.useRef(e);return Fs(()=>{t.current=e}),t}function m0(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Bs(h,r)||p(r);const[b,x]=m.useState(null),[g,v]=m.useState(null),w=m.useCallback(B=>{B!==k.current&&(k.current=B,x(B))},[]),S=m.useCallback(B=>{B!==E.current&&(E.current=B,v(B))},[]),N=s||b,T=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=Ha(l),L=Ha(o),$=Ha(u),V=m.useCallback(()=>{if(!k.current||!E.current)return;const B={placement:t,strategy:n,middleware:h};L.current&&(B.platform=L.current),f0(k.current,E.current,B).then(F=>{const ue={...F,isPositioned:$.current!==!1};M.current&&!Bs(A.current,ue)&&(A.current=ue,Io.flushSync(()=>{f(ue)}))})},[h,t,n,L,$]);Fs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[u]);const M=m.useRef(!1);Fs(()=>(M.current=!0,()=>{M.current=!1}),[]),Fs(()=>{if(N&&(k.current=N),T&&(E.current=T),N&&T){if(P.current)return P.current(N,T,V);V()}},[N,T,V,P,j]);const G=m.useMemo(()=>({reference:k,floating:E,setReference:w,setFloating:S}),[w,S]),K=m.useMemo(()=>({reference:N,floating:T}),[N,T]),W=m.useMemo(()=>{const B={position:n,left:0,top:0};if(!K.floating)return B;const F=Tf(K.floating,d.x),ue=Tf(K.floating,d.y);return a?{...B,transform:"translate("+F+"px, "+ue+"px)",...Cf(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:ue}},[n,a,K.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:G,elements:K,floatingStyles:W}),[d,V,G,K,W])}const g0=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?Sf({element:r.current,padding:o}).fn(n):{}:r?Sf({element:r,padding:o}).fn(n):{}}}},x0=(e,t)=>({...i0(e),options:[e,t]}),v0=(e,t)=>({...a0(e),options:[e,t]}),b0=(e,t)=>({...d0(e),options:[e,t]}),w0=(e,t)=>({...l0(e),options:[e,t]}),y0=(e,t)=>({...c0(e),options:[e,t]}),S0=(e,t)=>({...u0(e),options:[e,t]}),C0=(e,t)=>({...g0(e),options:[e,t]});var T0="Arrow",kf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(je.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});kf.displayName=T0;var k0=kf;function If(e){const[t,n]=m.useState(void 0);return Ct(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ua="Popper",[Ef,zs]=vn(Ua),[I0,Nf]=Ef(Ua),Af=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(I0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Af.displayName=Ua;var _f="PopperAnchor",jf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Nf(_f,n),i=m.useRef(null),a=Ge(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(je.div,{...o,ref:a})});jf.displayName=_f;var Wa="PopperContent",[E0,N0]=Ef(Wa),Rf=m.forwardRef((e,t)=>{var q,O,X,ee,pe,oe;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:b,...x}=e,g=Nf(Wa,n),[v,w]=m.useState(null),S=Ge(t,me=>w(me)),[N,T]=m.useState(null),k=If(N),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(u)?u:[u],$=L.length>0,V={padding:P,boundary:L.filter(_0),altBoundary:$},{refs:M,floatingStyles:G,placement:K,isPositioned:W,middlewareData:B}=m0({strategy:"fixed",placement:j,whileElementsMounted:(...me)=>s0(...me,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[x0({mainAxis:o+A,alignmentAxis:i}),l&&v0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?b0():void 0,...V}),l&&w0({...V}),y0({...V,apply:({elements:me,rects:et,availableWidth:tt,availableHeight:Oe})=>{const{width:We,height:ut}=et.reference,rt=me.floating.style;rt.setProperty("--radix-popper-available-width",`${tt}px`),rt.setProperty("--radix-popper-available-height",`${Oe}px`),rt.setProperty("--radix-popper-anchor-width",`${We}px`),rt.setProperty("--radix-popper-anchor-height",`${ut}px`)}}),N&&C0({element:N,padding:a}),j0({arrowWidth:E,arrowHeight:A}),h&&S0({strategy:"referenceHidden",...V})]}),[F,ue]=Mf(K),D=kt(b);Ct(()=>{W&&(D==null||D())},[W,D]);const Q=(q=B.arrow)==null?void 0:q.x,fe=(O=B.arrow)==null?void 0:O.y,we=((X=B.arrow)==null?void 0:X.centerOffset)!==0,[ye,Se]=m.useState();return Ct(()=>{v&&Se(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:W?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ye,"--radix-popper-transform-origin":[(ee=B.transformOrigin)==null?void 0:ee.x,(pe=B.transformOrigin)==null?void 0:pe.y].join(" "),...((oe=B.hide)==null?void 0:oe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(E0,{scope:n,placedSide:F,onArrowChange:T,arrowX:Q,arrowY:fe,shouldHideArrow:we,children:c.jsx(je.div,{"data-side":F,"data-align":ue,...x,ref:S,style:{...x.style,animation:W?void 0:"none"}})})})});Rf.displayName=Wa;var Pf="PopperArrow",A0={top:"bottom",right:"left",bottom:"top",left:"right"},Of=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=N0(Pf,r),i=A0[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(k0,{...o,ref:n,style:{...o.style,display:"block"}})})});Of.displayName=Pf;function _0(e){return e!==null}var j0=e=>({name:"transformOrigin",options:e,fn(t){var g,v,w;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Mf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let b="",x="";return u==="bottom"?(b=i?f:`${h}px`,x=`${-l}px`):u==="top"?(b=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(b=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(b=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:b,y:x}}}});function Mf(e){const[t,n="center"]=e.split("-");return[t,n]}var Df=Af,Lf=jf,$f=Rf,Ff=Of,Va="rovingFocusGroup.onEntryFocus",R0={bubbles:!1,cancelable:!0},xo="RovingFocusGroup",[Ka,Bf,P0]=ja(xo),[O0,zf]=vn(xo,[P0]),[M0,D0]=O0(xo),Hf=m.forwardRef((e,t)=>c.jsx(Ka.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ka.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(L0,{...e,ref:t})})}));Hf.displayName=xo;var L0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Ge(t,h),b=_s(s),[x,g]=dr({prop:i,defaultProp:a??null,onChange:l,caller:xo}),[v,w]=m.useState(!1),S=kt(u),N=Bf(n),T=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Va,S),()=>A.removeEventListener(Va,S)},[S]),c.jsx(M0,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(je.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{T.current=!0}),onFocus:de(e.onFocus,A=>{const j=!T.current;if(A.target===A.currentTarget&&j&&!v){const P=new CustomEvent(Va,R0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(K=>K.focusable),$=L.find(K=>K.active),V=L.find(K=>K.id===x),G=[$,V,...L].filter(Boolean).map(K=>K.ref.current);Vf(G,d)}}T.current=!1}),onBlur:de(e.onBlur,()=>w(!1))})})}),Uf="RovingFocusGroupItem",Wf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=bn(),u=s||l,d=D0(Uf,n),f=d.currentTabStopId===u,h=Bf(n),{onFocusableItemAdd:p,onFocusableItemRemove:b,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>b()},[r,p,b]),c.jsx(Ka.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(je.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:de(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:de(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:de(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const v=B0(g,d.orientation,d.dir);if(v!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?z0(S,N+1):S.slice(N+1)}setTimeout(()=>Vf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Wf.displayName=Uf;var $0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function F0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function B0(e,t,n){const r=F0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return $0[r]}function Vf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function z0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var H0=Hf,U0=Wf,qa=["Enter"," "],W0=["ArrowDown","PageUp","Home"],Kf=["ArrowUp","PageDown","End"],V0=[...W0,...Kf],K0={ltr:[...qa,"ArrowRight"],rtl:[...qa,"ArrowLeft"]},q0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},vo="Menu",[bo,G0,Y0]=ja(vo),[xr,qf]=vn(vo,[Y0,zs,zf]),Hs=zs(),Gf=zf(),[X0,vr]=xr(vo),[J0,wo]=xr(vo),Yf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Hs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=kt(s),h=_s(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),c.jsx(Df,{...a,children:c.jsx(X0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(J0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Yf.displayName=vo;var Z0="MenuAnchor",Ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hs(n);return c.jsx(Lf,{...o,...r,ref:t})});Ga.displayName=Z0;var Ya="MenuPortal",[Q0,Xf]=xr(Ya,{forceMount:void 0}),Jf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=vr(Ya,t);return c.jsx(Q0,{scope:t,forceMount:n,children:c.jsx(Wt,{present:n||s.open,children:c.jsx(ps,{asChild:!0,container:o,children:r})})})};Jf.displayName=Ya;var Jt="MenuContent",[eS,Xa]=xr(Jt),Zf=m.forwardRef((e,t)=>{const n=Xf(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=wo(Jt,e.__scopeMenu);return c.jsx(bo.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(bo.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(tS,{...o,ref:t}):c.jsx(nS,{...o,ref:t})})})})}),tS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu),r=m.useRef(null),o=Ge(t,r);return m.useEffect(()=>{const s=r.current;if(s)return ka(s)},[]),c.jsx(Ja,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:de(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),nS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu);return c.jsx(Ja,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),rS=rr.createSlot("MenuContent.ScrollLock"),Ja=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:b,...x}=e,g=vr(Jt,n),v=wo(Jt,n),w=Hs(n),S=Gf(n),N=G0(n),[T,k]=m.useState(null),E=m.useRef(null),A=Ge(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),L=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),G=b?ws:m.Fragment,K=b?{as:rS,allowPinchZoom:!0}:void 0,W=F=>{var q,O;const ue=P.current+F,D=N().filter(X=>!X.disabled),Q=document.activeElement,fe=(q=D.find(X=>X.ref.current===Q))==null?void 0:q.textValue,we=D.map(X=>X.textValue),ye=mS(we,ue,fe),Se=(O=D.find(X=>X.textValue===ye))==null?void 0:O.ref.current;(function X(ee){P.current=ee,window.clearTimeout(j.current),ee!==""&&(j.current=window.setTimeout(()=>X(""),1e3))})(ue),Se&&setTimeout(()=>Se.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),ba();const B=m.useCallback(F=>{var D,Q;return V.current===((D=$.current)==null?void 0:D.side)&&xS(F,(Q=$.current)==null?void 0:Q.area)},[]);return c.jsx(eS,{scope:n,searchRef:P,onItemEnter:m.useCallback(F=>{B(F)&&F.preventDefault()},[B]),onItemLeave:m.useCallback(F=>{var ue;B(F)||((ue=E.current)==null||ue.focus(),k(null))},[B]),onTriggerLeave:m.useCallback(F=>{B(F)&&F.preventDefault()},[B]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback(F=>{$.current=F},[]),children:c.jsx(G,{...K,children:c.jsx(hs,{asChild:!0,trapped:o,onMountAutoFocus:de(s,F=>{var ue;F.preventDefault(),(ue=E.current)==null||ue.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(fs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(H0,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:k,onEntryFocus:de(l,F=>{v.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx($f,{role:"menu","aria-orientation":"vertical","data-state":mh(g.open),"data-radix-menu-content":"",dir:v.dir,...w,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:de(x.onKeyDown,F=>{const D=F.target.closest("[data-radix-menu-content]")===F.currentTarget,Q=F.ctrlKey||F.altKey||F.metaKey,fe=F.key.length===1;D&&(F.key==="Tab"&&F.preventDefault(),!Q&&fe&&W(F.key));const we=E.current;if(F.target!==we||!V0.includes(F.key))return;F.preventDefault();const Se=N().filter(q=>!q.disabled).map(q=>q.ref.current);Kf.includes(F.key)&&Se.reverse(),hS(Se)}),onBlur:de(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:de(e.onPointerMove,So(F=>{const ue=F.target,D=M.current!==F.clientX;if(F.currentTarget.contains(ue)&&D){const Q=F.clientX>M.current?"right":"left";V.current=Q,M.current=F.clientX}}))})})})})})})});Zf.displayName=Jt;var oS="MenuGroup",Za=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{role:"group",...r,ref:t})});Za.displayName=oS;var sS="MenuLabel",Qf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{...r,ref:t})});Qf.displayName=sS;var Us="MenuItem",eh="menu.itemSelect",Ws=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=wo(Us,e.__scopeMenu),a=Xa(Us,e.__scopeMenu),l=Ge(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(eh,{bubbles:!0,cancelable:!0});f.addEventListener(eh,p=>r==null?void 0:r(p),{once:!0}),Ou(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(th,{...o,ref:l,disabled:n,onClick:de(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:de(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:de(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ws.displayName=Us;var th=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xa(Us,n),a=Gf(n),l=m.useRef(null),u=Ge(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const b=l.current;b&&p((b.textContent??"").trim())},[s.children]),c.jsx(bo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(U0,{asChild:!0,...a,focusable:!r,children:c.jsx(je.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:de(e.onPointerMove,So(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:de(e.onPointerLeave,So(b=>i.onItemLeave(b))),onFocus:de(e.onFocus,()=>f(!0)),onBlur:de(e.onBlur,()=>f(!1))})})})}),iS="MenuCheckboxItem",nh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(ah,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ws,{role:"menuitemcheckbox","aria-checked":Vs(n)?"mixed":n,...o,ref:t,"data-state":el(n),onSelect:de(o.onSelect,()=>r==null?void 0:r(Vs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nh.displayName=iS;var rh="MenuRadioGroup",[aS,lS]=xr(rh,{value:void 0,onValueChange:()=>{}}),oh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=kt(r);return c.jsx(aS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Za,{...o,ref:t})})});oh.displayName=rh;var sh="MenuRadioItem",ih=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=lS(sh,e.__scopeMenu),s=n===o.value;return c.jsx(ah,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":el(s),onSelect:de(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ih.displayName=sh;var Qa="MenuItemIndicator",[ah,cS]=xr(Qa,{checked:!1}),lh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=cS(Qa,n);return c.jsx(Wt,{present:r||Vs(s.checked)||s.checked===!0,children:c.jsx(je.span,{...o,ref:t,"data-state":el(s.checked)})})});lh.displayName=Qa;var uS="MenuSeparator",ch=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(je.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ch.displayName=uS;var dS="MenuArrow",uh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Hs(n);return c.jsx(Ff,{...o,...r,ref:t})});uh.displayName=dS;var fS="MenuSub",[GT,dh]=xr(fS),yo="MenuSubTrigger",fh=m.forwardRef((e,t)=>{const n=vr(yo,e.__scopeMenu),r=wo(yo,e.__scopeMenu),o=dh(yo,e.__scopeMenu),s=Xa(yo,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ga,{asChild:!0,...u,children:c.jsx(th,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":mh(n.open),...e,ref:sa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:de(e.onPointerMove,So(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:de(e.onPointerLeave,So(f=>{var p,b;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(b=n.content)==null?void 0:b.dataset.side,g=x==="right",v=g?-5:5,w=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:de(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||K0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});fh.displayName=yo;var hh="MenuSubContent",ph=m.forwardRef((e,t)=>{const n=Xf(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=wo(Jt,e.__scopeMenu),a=dh(hh,e.__scopeMenu),l=m.useRef(null),u=Ge(t,l);return c.jsx(bo.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(bo.Slot,{scope:e.__scopeMenu,children:c.jsx(Ja,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:de(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:de(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:de(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=q0[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});ph.displayName=hh;function mh(e){return e?"open":"closed"}function Vs(e){return e==="indeterminate"}function el(e){return Vs(e)?"indeterminate":e?"checked":"unchecked"}function hS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function pS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function mS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=pS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function gS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function xS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return gS(n,t)}function So(e){return t=>t.pointerType==="mouse"?e(t):void 0}var vS=Yf,bS=Ga,wS=Jf,yS=Zf,SS=Za,CS=Qf,TS=Ws,kS=nh,IS=oh,ES=ih,NS=lh,AS=ch,_S=uh,jS=fh,RS=ph,Ks="DropdownMenu",[PS,YT]=vn(Ks,[qf]),Mt=qf(),[OS,gh]=PS(Ks),xh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Mt(t),u=m.useRef(null),[d,f]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:Ks});return c.jsx(OS,{scope:t,triggerId:bn(),triggerRef:u,contentId:bn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(vS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};xh.displayName=Ks;var vh="DropdownMenuTrigger",bh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=gh(vh,n),i=Mt(n);return c.jsx(bS,{asChild:!0,...i,children:c.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:sa(t,s.triggerRef),onPointerDown:de(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:de(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});bh.displayName=vh;var MS="DropdownMenuPortal",wh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mt(t);return c.jsx(wS,{...r,...n})};wh.displayName=MS;var yh="DropdownMenuContent",Sh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=gh(yh,n),s=Mt(n),i=m.useRef(!1);return c.jsx(yS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:de(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Sh.displayName=yh;var DS="DropdownMenuGroup",LS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(SS,{...o,...r,ref:t})});LS.displayName=DS;var $S="DropdownMenuLabel",Ch=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(CS,{...o,...r,ref:t})});Ch.displayName=$S;var FS="DropdownMenuItem",Th=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(TS,{...o,...r,ref:t})});Th.displayName=FS;var BS="DropdownMenuCheckboxItem",kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(kS,{...o,...r,ref:t})});kh.displayName=BS;var zS="DropdownMenuRadioGroup",HS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(IS,{...o,...r,ref:t})});HS.displayName=zS;var US="DropdownMenuRadioItem",Ih=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(ES,{...o,...r,ref:t})});Ih.displayName=US;var WS="DropdownMenuItemIndicator",Eh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(NS,{...o,...r,ref:t})});Eh.displayName=WS;var VS="DropdownMenuSeparator",Nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(AS,{...o,...r,ref:t})});Nh.displayName=VS;var KS="DropdownMenuArrow",qS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(_S,{...o,...r,ref:t})});qS.displayName=KS;var GS="DropdownMenuSubTrigger",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(jS,{...o,...r,ref:t})});Ah.displayName=GS;var YS="DropdownMenuSubContent",_h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(RS,{...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)"}})});_h.displayName=YS;var XS=xh,JS=bh,ZS=wh,jh=Sh,Rh=Ch,Ph=Th,Oh=kh,Mh=Ih,Dh=Eh,Lh=Nh,$h=Ah,Fh=_h;const QS=XS,eC=JS,tC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs($h,{ref:o,className:Z("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ie.ChevronRight,{className:"ml-auto h-4 w-4"})]}));tC.displayName=$h.displayName;const nC=m.forwardRef(({className:e,...t},n)=>c.jsx(Fh,{ref:n,className:Z("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}));nC.displayName=Fh.displayName;const Bh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(ZS,{children:c.jsx(jh,{ref:r,sideOffset:t,className:Z("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})}));Bh.displayName=jh.displayName;const tl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ph,{ref:r,className:Z("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}));tl.displayName=Ph.displayName;const rC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Oh,{ref:o,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Dh,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),t]}));rC.displayName=Oh.displayName;const oC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Mh,{ref:r,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Dh,{children:c.jsx(ie.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));oC.displayName=Mh.displayName;const sC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Rh,{ref:r,className:Z("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));sC.displayName=Rh.displayName;const iC=m.forwardRef(({className:e,...t},n)=>c.jsx(Lh,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));iC.displayName=Lh.displayName;function qs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:b}=Ci(),{currentThreadId:x}=zo(),{threadId:g,messages:v,hasMore:w,isHistoryLoading:S,isLoading:N,loadOlder:T,listCheckpoints:k,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:L}=Ho(),{isStreaming:$,error:V,submit:M,stop:G}=Pc(),K=g??x??null,W=(j==null?void 0:j.id)??null,B=(j==null?void 0:j.namespace)??null,F=(L==null?void 0:L.assemblingMessageId)??null,[ue,D]=y.useState(null),[Q,fe]=y.useState(""),[we,ye]=y.useState(null),[Se,q]=y.useState([]),[O,X]=y.useState(0),[ee,pe]=y.useState(0),[oe,me]=y.useState(!1),[et,tt]=y.useState(null),[Oe,We]=y.useState(null),[ut,rt]=y.useState(!1),[Ve,xt]=y.useState(null),[J,se]=y.useState([]),[ge,Ce]=y.useState(null),[xe,Me]=y.useState(null),[at,De]=y.useState(!1),it=y.useRef(null),vt=y.useRef(null),_t=y.useRef(null),jt=y.useCallback(()=>{it.current&&(it.current.value=""),vt.current&&(vt.current.value=""),X(le=>le+1),pe(le=>le+1)},[]),dn=y.useRef(!1);y.useEffect(()=>{dn.current&&!$&&(q([]),jt()),dn.current=$},[$,jt]);const[In,Hr]=y.useState("desktop");y.useEffect(()=>{const le=()=>{const Ie=window.innerWidth;Hr(Ie<640?"phone":Ie<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),y.useEffect(()=>{let le=!1;if(!K){se([]),Ce(null),Me(null),_t.current=null;return}const Ie={threadId:K,checkpointId:W??null,checkpointNs:B??null},Ke=_t.current;if(!(Ke&&Ke.threadId===Ie.threadId&&Ke.checkpointId===Ie.checkpointId&&Ke.checkpointNs===Ie.checkpointNs))return k(K).then(nt=>{var Ee;if(le)return;const Dt=((nt==null?void 0:nt.checkpoints)??[]).slice().sort((_e,Xe)=>new Date(Xe.createdAt).getTime()-new Date(_e.createdAt).getTime());se(Dt);const I=ge,H=I&&Dt.some(_e=>_e.checkpointId===I)?I:((Ee=Dt[0])==null?void 0:Ee.checkpointId)??null;let ne=null;if(H){const _e=Dt.find(Xe=>Xe.checkpointId===H);ne=(_e==null?void 0:_e.checkpointNs)??null}Ce(H),Me(ne),_t.current=Ie}).catch(nt=>{console.error("ChatInterface - listCheckpoints error:",nt),le||(se([]),_t.current=null)}),()=>{le=!0}},[K,W,B,ge,k]),y.useEffect(()=>{W&&(Ce(W),Me(B??null))},[W,B]);const oi=y.useCallback(async()=>{if(!(!w||S))try{await T()}catch(le){console.warn("loadOlder failed",le)}},[w,S,T]);y.useEffect(()=>{(async()=>{if(!b.baseUrl){xt(null);return}try{const Ie=await b.getAgent("default");xt(Ie.uiDefaultMessage||null)}catch(Ie){console.warn("Failed to fetch default message:",Ie),xt(null)}})()},[b]),y.useEffect(()=>{V&&!ut&&(p==null||p(V))},[V,ut,p]);const Sr=le=>{if(le.length>As)return`Message too long (${le.length}/${As} characters)`;try{return fy(le),null}catch(Ie){return(Ie==null?void 0:Ie.message)||"Invalid message"}},Zn=async le=>{const Ie=le.trim();if(!(!Ie&&Se.length===0)){if(Ie){const Ke=Sr(Ie);if(Ke){ye(Ke);return}}try{await M({text:Ie||"",attachments:Se,payload:ue?{edit:!0,originalMessageId:ue}:void 0},{checkpointId:ge??W??void 0,checkpointNs:xe??B??void 0}),f==null||f(Ie),ye(null),q([]),jt(),D(null),fe("")}catch(Ke){const nt=(Ke==null?void 0:Ke.message)||"Failed to send message";ye(nt),p==null||p(nt)}}},bt=y.useCallback((le,Ie)=>{u&&(D(le),fe(Ie),ye(null))},[u]),Dn=y.useCallback(()=>{D(null),fe(""),ye(null)},[]),Ln=y.useCallback((le,Ie)=>{bt(le,Ie)},[bt]),St=y.useCallback(le=>{const Ie=Ke=>{const nt=Ke.content||[],Dt=nt.filter(I=>I.type==="text").map(I=>I.text).join("");if(Dt)return Dt;try{return JSON.stringify(nt,null,2)}catch{return String(nt)}};for(let Ke=le-1;Ke>=0;Ke--)if(v[Ke].role==="user"){const nt=Ie(v[Ke]);nt&&M({text:nt},{checkpointId:ge??W??void 0,checkpointNs:xe??B??void 0});break}},[v,M,ge,xe,W,B]),En=le=>{const Ie=Array.from(le.target.files||[]);q(Ke=>[...Ke,...Ie]),le.target.value=""},Nn=le=>{q(Ie=>{const Ke=Ie.filter((nt,Dt)=>le!==Dt);return Ke.length===0&&jt(),Ke})},Ur=async le=>{const Ie=(le.target.files||[])[0];if(Ie){tt(null),We(null),me(!0);try{await M({attachments:[Ie]},{checkpointId:ge??W??void 0,checkpointNs:xe??B??void 0});const Ke=`Uploaded ${Ie.name} - processing through chat stream`;We(Ke)}catch(Ke){const nt=Ke instanceof Error?Ke.message:"Failed to upload Excel file";console.error("Excel upload failed",Ke),tt(nt),p==null||p(nt)}finally{me(!1),le.target.value="",jt()}}},qt=le=>{if(!le)return"Unknown";const Ie=Date.parse(le);return Number.isNaN(Ie)?le:new Date(Ie).toLocaleString()},Qn=async le=>{if(x){De(!0);try{if(!le){await A(),Ce(null),Me(null);return}const Ie=J.find(nt=>nt.checkpointId===le),Ke=(Ie==null?void 0:Ie.checkpointNs)??null;await E(le,Ke),Ce(le),Me(Ke)}finally{De(!1)}}},An=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,_n=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,er=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:An,children:[!!V&&!ut&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>rt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ie.X,{size:16})})]}),x&&J.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:ge??"",onChange:le=>{const Ie=le.target.value||null;Qn(Ie)},children:[c.jsx("option",{value:"",children:"Latest"}),J.map(le=>c.jsxs("option",{value:le.checkpointId,children:[qt(le.createdAt),le.preview?` — ${le.preview.slice(0,40)}`:""]},le.checkpointId))]})]}),c.jsxs("div",{className:`relative ${_n}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(_a,{className:"h-full",style:{height:"100%"},messages:v,isStreaming:$,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:In,enableMessageEditing:u,editingMessageId:ue,onStartReached:()=>{oi()},onEdit:Ln,onRegenerate:St,onCancelEdit:Dn,emptyMessage:Ve??void 0,isNavigatingCheckpoint:at}),N&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:er,children:[ue&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ie.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:Dn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ie.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:it,type:"file",multiple:!0,onChange:le=>En(le),className:"hidden"},O),Se.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Se.map((le,Ie)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ie.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Nn(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 ${le.name}`,children:c.jsx(ie.X,{size:12})})]},Ie))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:vt,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ur,className:"hidden"},ee),oe&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ie.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Oe&&!oe&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Oe}),et&&!oe&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:et})]})]}),we&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(QS,{children:[c.jsx(eC,{asChild:!0,children:c.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:$,title:"More input actions",className:d.moreButton||"",children:c.jsx(ie.Plus,{size:16})})}),c.jsxs(Bh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(tl,{onClick:()=>{var le;return(le=it.current)==null?void 0:le.click()},className:"cursor-pointer",children:[c.jsx(ie.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(tl,{onClick:()=>{var le;oe||(le=vt.current)==null||le.click()},className:`cursor-pointer ${oe?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ie.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(kx,{initialValue:Q,editingMessageId:ue,placeholder:ue?"Edit your message...":t,isStreaming:$,disabled:!1,maxLength:As,onSend:Zn,onCancelEdit:Dn,onStop:G,allowEmptySend:Se.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ue?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Gs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Z("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}));Gs.displayName="Input";function nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function aC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var rl="ScrollArea",[zh,XT]=vn(rl),[lC,Zt]=zh(rl),Hh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,b]=m.useState(null),[x,g]=m.useState(null),[v,w]=m.useState(0),[S,N]=m.useState(0),[T,k]=m.useState(!1),[E,A]=m.useState(!1),j=Ge(t,L=>l(L)),P=_s(o);return c.jsx(lC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:b,scrollbarXEnabled:T,onScrollbarXEnabledChange:k,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:N,children:c.jsx(je.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Hh.displayName=rl;var Uh="ScrollAreaViewport",Wh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Zt(Uh,n),a=m.useRef(null),l=Ge(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(je.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Uh;var kn="ScrollAreaScrollbar",ol=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(kn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(cC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(uC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Vh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(sl,{...r,ref:t}):null});ol.displayName=kn;var cC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(kn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Wt,{present:n||s,children:c.jsx(Vh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),uC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(kn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Zs(()=>l("SCROLL_END"),100),[a,l]=aC("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Wt,{present:n||a!=="hidden",children:c.jsx(sl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:de(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:de(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Vh=m.forwardRef((e,t)=>{const n=Zt(kn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Zs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),c.jsx(Wt,{present:r||s,children:c.jsx(sl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),sl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Zt(kn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Xh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return gC(h,i.current,a,p)}return n==="horizontal"?c.jsx(dC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Jh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(fC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Jh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),dC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(kn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ge(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(qh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Js(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),Qh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Xs(i.paddingLeft),paddingEnd:Xs(i.paddingRight)}})}})}),fC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(kn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ge(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(qh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Js(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),Qh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Xs(i.paddingTop),paddingEnd:Xs(i.paddingBottom)}})}})}),[hC,Kh]=zh(kn),qh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Zt(kn,n),[b,x]=m.useState(null),g=Ge(t,j=>x(j)),v=m.useRef(null),w=m.useRef(""),S=p.viewport,N=r.content-r.viewport,T=kt(d),k=kt(l),E=Zs(f,10);function A(j){if(v.current){const P=j.clientX-v.current.left,L=j.clientY-v.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const j=P=>{const L=P.target;(b==null?void 0:b.contains(L))&&T(P,N)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,b,N,T]),m.useEffect(k,[r,k]),Fr(b,E),Fr(p.content,E),c.jsx(hC,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:kt(s),onThumbPointerUp:kt(i),onThumbPositionChange:k,onThumbPointerDown:kt(a),children:c.jsx(je.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:de(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),v.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:de(e.onPointerMove,A),onPointerUp:de(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),Ys="ScrollAreaThumb",Gh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kh(Ys,e.__scopeScrollArea);return c.jsx(Wt,{present:n||o.hasThumb,children:c.jsx(pC,{ref:t,...r})})}),pC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Zt(Ys,n),i=Kh(Ys,n),{onThumbPositionChange:a}=i,l=Ge(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Zs(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=xC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.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:de(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),b=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:b,y:x})}),onPointerUp:de(e.onPointerUp,i.onThumbPointerUp)})});Gh.displayName=Ys;var il="ScrollAreaCorner",Yh=m.forwardRef((e,t)=>{const n=Zt(il,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(mC,{...e,ref:t}):null});Yh.displayName=il;var mC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Zt(il,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.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 Xs(e){return e?parseInt(e,10):0}function Xh(e,t){const n=e/t;return isNaN(n)?0:n}function Js(e){const t=Xh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function gC(e,t,n,r="ltr"){const o=Js(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Zh([l,u],f)(e)}function Jh(e,t,n="ltr"){const r=Js(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=nl(e,l);return Zh([0,i],[0,a])(u)}function Zh(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 Qh(e,t){return e>0&&e<t}var xC=(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 Zs(e,t){const n=kt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Fr(e,t){const n=kt(t);Ct(()=>{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 ep=Hh,vC=Wh,bC=Yh;const tp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ep,{ref:r,className:Z("relative overflow-hidden",e),...n,children:[c.jsx(vC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(np,{}),c.jsx(bC,{})]}));tp.displayName=ep.displayName;const np=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ol,{ref:r,orientation:t,className:Z("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Gh,{className:"relative flex-1 rounded-full bg-border"})}));np.displayName=ol.displayName;function al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:b}=zo(),{loadThread:x}=Ho(),{createThread:g,deleteThread:v,renameThread:w}=b,[S,N]=y.useState(Array.isArray(f)?f:[]),T=y.useRef(S.length>0),[k,E]=y.useState(null),[A,j]=y.useState(""),[P,L]=y.useState(!1);y.useEffect(()=>{const D=Array.isArray(f)?f:[];if(D.length>0){T.current=!0,N(D);return}p||(T.current=!1,N(D))},[f,p]);const $=async D=>{try{await x(D),a==null||a(D),l==null||l(D)}catch(Q){console.error("Failed to select thread:",Q)}},V=async()=>{try{L(!0);const D=await g();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{L(!1)}},M=async(D,Q)=>{if(Q.stopPropagation(),!!confirm("Delete this thread?"))try{await v(D),d==null||d(D)}catch(fe){console.error("Failed to delete thread:",fe)}},G=(D,Q)=>{Q.stopPropagation(),E(D.threadId),j(D.title||`Thread ${D.threadId.slice(0,8)}`)},K=async D=>{if(A.trim())try{await w(D,A.trim()),E(null),j("")}catch(Q){console.error("Failed to update title:",Q)}},W=()=>{E(null),j("")},B=(D,Q)=>{D.key==="Enter"?K(Q):D.key==="Escape"&&W()},F=D=>{if(!D)return"";try{const Q=new Date(D),we=new Date().getTime()-Q.getTime(),ye=Math.floor(we/(1e3*60*60*24));return ye===0?Q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ye===1?"Yesterday":ye<7?`${ye} days ago`:Q.toLocaleDateString()}catch{return""}},ue=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Je,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ie.MessageSquarePlus,{size:20})})}),c.jsx(tp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ie.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ie.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((D,Q)=>new Date(Q.updatedAt||Q.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>c.jsxs("div",{onClick:()=>$(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===D.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:Q=>Q.stopPropagation(),children:[c.jsx(Gs,{value:A,onChange:Q=>j(Q.target.value),onKeyDown:Q=>B(Q,D.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>K(D.threadId),className:"h-6 w-6 p-0",children:c.jsx(ie.Check,{size:12})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:c.jsx(ie.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ue(D)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ie.Calendar,{size:10}),c.jsx("span",{children:F(D.updatedAt||D.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==D.threadId&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:Q=>G(D,Q),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ie.Edit3,{size:12})}),n&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:Q=>M(D.threadId,Q),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ie.Trash2,{size:12})})]})]}),i===D.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function Br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function wC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Rn(t)}function rp(){const e=[Br("__API_BASE_URL__"),Br("__CHAT_API_BASE_URL__"),Br("__CHAT_API_URL__")];for(const t of e){const n=wC(t);if(n)return n}}function op(){const e=[Br("__API_AUTH_TOKEN__"),Br("__CHAT_API_KEY__"),Br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function sp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Rn(t);return Rn()}function ip(){const e={},t=rp(),n=op();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ap(){const e=ip(),t=Fn.getAuthToken(),n=rp();return{apiBaseUrl:sp(e.baseUrl,Fn.baseUrl,n),apiKey:t||e.apiKey||op()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const lp="chat-settings";function yC(){try{const e=localStorage.getItem(lp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function SC(e){try{const t={...e,apiBaseUrl:Rn(e.apiBaseUrl)};localStorage.setItem(lp,JSON.stringify(t)),t.apiKey&&Fn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function CC(){const e=ap(),t=yC(),n=Fn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:sp(Fn.baseUrl,r,e.apiBaseUrl)}}function TC(e){Fn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),SC(e)}var kC="Label",cp=m.forwardRef((e,t)=>c.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())}}));cp.displayName=kC;var up=cp;const IC=ko.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Qt=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:Z(IC(),e),...t}));Qt.displayName=up.displayName;function dp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Qs="Switch",[EC,JT]=vn(Qs),[NC,AC]=EC(Qs),fp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),b=Ge(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[v,w]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:Qs});return c.jsxs(NC,{scope:n,checked:v,disabled:a,children:[c.jsx(je.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":gp(v),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:b,onClick:de(e.onClick,S=>{w(N=>!N),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(mp,{control:h,bubbles:!x.current,name:r,value:l,checked:v,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fp.displayName=Qs;var hp="SwitchThumb",pp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=AC(hp,n);return c.jsx(je.span,{"data-state":gp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});pp.displayName=hp;var _C="SwitchBubbleInput",mp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Ge(i,s),l=dp(n),u=If(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const b=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(b)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});mp.displayName=_C;function gp(e){return e?"checked":"unchecked"}var xp=fp,jC=pp;const Yn=m.forwardRef(({className:e,...t},n)=>c.jsx(xp,{className:Z("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(jC,{className:Z("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")})}));Yn.displayName=xp.displayName;var vp=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"}),RC="VisuallyHidden",PC=m.forwardRef((e,t)=>c.jsx(je.span,{...e,ref:t,style:{...vp,...e.style}}));PC.displayName=RC;var OC=[" ","Enter","ArrowUp","ArrowDown"],MC=[" ","Enter"],br="Select",[ei,ti,DC]=ja(br),[zr,ZT]=vn(br,[DC,zs]),ni=zs(),[LC,Xn]=zr(br),[$C,FC]=zr(br),bp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:b}=e,x=ni(t),[g,v]=m.useState(null),[w,S]=m.useState(null),[N,T]=m.useState(!1),k=_s(u),[E,A]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:br}),[j,P]=dr({prop:i,defaultProp:a,onChange:l,caller:br}),L=m.useRef(null),$=g?b||!!g.closest("form"):!0,[V,M]=m.useState(new Set),G=Array.from(V).map(K=>K.props.value).join(";");return c.jsx(Df,{...x,children:c.jsxs(LC,{required:p,scope:t,trigger:g,onTriggerChange:v,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:T,contentId:bn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(ei.Provider,{scope:t,children:c.jsx($C,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{M(W=>new Set(W).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{M(W=>{const B=new Set(W);return B.delete(K),B})},[]),children:n})}),$?c.jsxs(Up,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>P(K.target.value),disabled:h,form:b,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};bp.displayName=br;var wp="SelectTrigger",yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ni(n),i=Xn(wp,n),a=i.disabled||r,l=Ge(t,i.onTriggerChange),u=ti(n),d=m.useRef("touch"),[f,h,p]=Vp(x=>{const g=u().filter(S=>!S.disabled),v=g.find(S=>S.value===i.value),w=Kp(g,x,v);w!==void 0&&i.onValueChange(w.value)}),b=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Lf,{asChild:!0,...s,children:c.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":Wp(i.value)?"":void 0,...o,ref:l,onClick:de(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&b(x)}),onPointerDown:de(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(b(x),x.preventDefault())}),onKeyDown:de(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&OC.includes(x.key)&&(b(),x.preventDefault())})})})});yp.displayName=wp;var Sp="SelectValue",Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Xn(Sp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Ge(t,l.onValueNodeChange);return Ct(()=>{u(d)},[u,d]),c.jsx(je.span,{...a,ref:f,style:{pointerEvents:"none"},children:Wp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Cp.displayName=Sp;var BC="SelectIcon",Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(je.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Tp.displayName=BC;var zC="SelectPortal",kp=e=>c.jsx(ps,{asChild:!0,...e});kp.displayName=zC;var wr="SelectContent",Ip=m.forwardRef((e,t)=>{const n=Xn(wr,e.__scopeSelect),[r,o]=m.useState();if(Ct(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Io.createPortal(c.jsx(Ep,{scope:e.__scopeSelect,children:c.jsx(ei.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Np,{...e,ref:t})});Ip.displayName=wr;var un=10,[Ep,Jn]=zr(wr),HC="SelectContentImpl",UC=rr.createSlot("SelectContent.RemoveScroll"),Np=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:b,hideWhenDetached:x,avoidCollisions:g,...v}=e,w=Xn(wr,n),[S,N]=m.useState(null),[T,k]=m.useState(null),E=Ge(t,q=>N(q)),[A,j]=m.useState(null),[P,L]=m.useState(null),$=ti(n),[V,M]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(S)return ka(S)},[S]),ba();const K=m.useCallback(q=>{const[O,...X]=$().map(oe=>oe.ref.current),[ee]=X.slice(-1),pe=document.activeElement;for(const oe of q)if(oe===pe||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===O&&T&&(T.scrollTop=0),oe===ee&&T&&(T.scrollTop=T.scrollHeight),oe==null||oe.focus(),document.activeElement!==pe))return},[$,T]),W=m.useCallback(()=>K([A,S]),[K,A,S]);m.useEffect(()=>{V&&W()},[V,W]);const{onOpenChange:B,triggerPointerDownPosRef:F}=w;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=ee=>{var pe,oe;q={x:Math.abs(Math.round(ee.pageX)-(((pe=F.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((oe=F.current)==null?void 0:oe.y)??0))}},X=ee=>{q.x<=10&&q.y<=10?ee.preventDefault():S.contains(ee.target)||B(!1),document.removeEventListener("pointermove",O),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,B,F]),m.useEffect(()=>{const q=()=>B(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[B]);const[ue,D]=Vp(q=>{const O=$().filter(pe=>!pe.disabled),X=O.find(pe=>pe.ref.current===document.activeElement),ee=Kp(O,q,X);ee&&setTimeout(()=>ee.ref.current.focus())}),Q=m.useCallback((q,O,X)=>{const ee=!G.current&&!X;(w.value!==void 0&&w.value===O||ee)&&(j(q),ee&&(G.current=!0))},[w.value]),fe=m.useCallback(()=>S==null?void 0:S.focus(),[S]),we=m.useCallback((q,O,X)=>{const ee=!G.current&&!X;(w.value!==void 0&&w.value===O||ee)&&L(q)},[w.value]),ye=r==="popper"?ll:Ap,Se=ye===ll?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:b,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Ep,{scope:n,content:S,viewport:T,onViewportChange:k,itemRefCallback:Q,selectedItem:A,onItemLeave:fe,itemTextRefCallback:we,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:V,searchRef:ue,children:c.jsx(ws,{as:UC,allowPinchZoom:!0,children:c.jsx(hs,{asChild:!0,trapped:w.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:de(o,q=>{var O;(O=w.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(fs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:c.jsx(ye,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:q=>q.preventDefault(),...v,...Se,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:de(v.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&D(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ee=$().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const pe=q.target,oe=ee.indexOf(pe);ee=ee.slice(oe+1)}setTimeout(()=>K(ee)),q.preventDefault()}})})})})})})});Np.displayName=HC;var WC="SelectItemAlignedPosition",Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Xn(wr,n),i=Jn(wr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Ge(t,E=>d(E)),h=ti(n),p=m.useRef(!1),b=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:v,focusSelectedItem:w}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&v){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=v.getBoundingClientRect();if(s.dir!=="rtl"){const pe=P.left-A.left,oe=j.left-pe,me=E.left-oe,et=E.width+me,tt=Math.max(et,A.width),Oe=window.innerWidth-un,We=nl(oe,[un,Math.max(un,Oe-tt)]);a.style.minWidth=et+"px",a.style.left=We+"px"}else{const pe=A.right-P.right,oe=window.innerWidth-j.right-pe,me=window.innerWidth-E.right-oe,et=E.width+me,tt=Math.max(et,A.width),Oe=window.innerWidth-un,We=nl(oe,[un,Math.max(un,Oe-tt)]);a.style.minWidth=et+"px",a.style.right=We+"px"}const L=h(),$=window.innerHeight-un*2,V=x.scrollHeight,M=window.getComputedStyle(u),G=parseInt(M.borderTopWidth,10),K=parseInt(M.paddingTop,10),W=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),F=G+K+V+B+W,ue=Math.min(g.offsetHeight*5,F),D=window.getComputedStyle(x),Q=parseInt(D.paddingTop,10),fe=parseInt(D.paddingBottom,10),we=E.top+E.height/2-un,ye=$-we,Se=g.offsetHeight/2,q=g.offsetTop+Se,O=G+K+q,X=F-O;if(O<=we){const pe=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const oe=u.clientHeight-x.offsetTop-x.offsetHeight,me=Math.max(ye,Se+(pe?fe:0)+oe+W),et=O+me;a.style.height=et+"px"}else{const pe=L.length>0&&g===L[0].ref.current;a.style.top="0px";const me=Math.max(we,G+x.offsetTop+(pe?Q:0)+Se)+X;a.style.height=me+"px",x.scrollTop=O-we+x.offsetTop}a.style.margin=`${un}px 0`,a.style.minHeight=ue+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,v,s.dir,r]);Ct(()=>S(),[S]);const[N,T]=m.useState();Ct(()=>{u&&T(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&b.current===!0&&(S(),w==null||w(),b.current=!1)},[S,w]);return c.jsx(KC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx(je.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ap.displayName=WC;var VC="SelectPopperPosition",ll=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=un,...s}=e,i=ni(n);return c.jsx($f,{...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)"}})});ll.displayName=VC;var[KC,cl]=zr(wr,{}),ul="SelectViewport",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Jn(ul,n),i=cl(ul,n),a=Ge(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(ei.Slot,{scope:n,children:c.jsx(je.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:de(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const b=window.innerHeight-un*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),v=Math.max(x,g);if(v<b){const w=v+p,S=Math.min(b,w),N=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});_p.displayName=ul;var jp="SelectGroup",[qC,GC]=zr(jp),YC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=bn();return c.jsx(qC,{scope:n,id:o,children:c.jsx(je.div,{role:"group","aria-labelledby":o,...r,ref:t})})});YC.displayName=jp;var Rp="SelectLabel",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=GC(Rp,n);return c.jsx(je.div,{id:o.id,...r,ref:t})});Pp.displayName=Rp;var ri="SelectItem",[XC,Op]=zr(ri),Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Xn(ri,n),l=Jn(ri,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),b=Ge(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=bn(),g=m.useRef("touch"),v=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(XC,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:c.jsx(ei.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(je.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:de(i.onFocus,()=>p(!0)),onBlur:de(i.onBlur,()=>p(!1)),onClick:de(i.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:de(i.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:de(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:de(i.onPointerMove,w=>{var S;g.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:de(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:de(i.onKeyDown,w=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&w.key===" "||(MC.includes(w.key)&&v(),w.key===" "&&w.preventDefault())})})})})});Mp.displayName=ri;var Co="SelectItemText",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Xn(Co,n),a=Jn(Co,n),l=Op(Co,n),u=FC(Co,n),[d,f]=m.useState(null),h=Ge(t,v=>f(v),l.onItemTextChange,v=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,v,l.value,l.disabled)}),p=d==null?void 0:d.textContent,b=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Ct(()=>(x(b),()=>g(b)),[x,g,b]),c.jsxs(c.Fragment,{children:[c.jsx(je.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Io.createPortal(s.children,i.valueNode):null]})});Dp.displayName=Co;var Lp="SelectItemIndicator",$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Op(Lp,n).isSelected?c.jsx(je.span,{"aria-hidden":!0,...r,ref:t}):null});$p.displayName=Lp;var dl="SelectScrollUpButton",Fp=m.forwardRef((e,t)=>{const n=Jn(dl,e.__scopeSelect),r=cl(dl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ge(t,r.onScrollButtonChange);return Ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(zp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Fp.displayName=dl;var fl="SelectScrollDownButton",Bp=m.forwardRef((e,t)=>{const n=Jn(fl,e.__scopeSelect),r=cl(fl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ge(t,r.onScrollButtonChange);return Ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(zp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Bp.displayName=fl;var zp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Jn("SelectScrollButton",n),i=m.useRef(null),a=ti(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Ct(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(je.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:de(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:de(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:de(o.onPointerLeave,()=>{l()})})}),JC="SelectSeparator",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(je.div,{"aria-hidden":!0,...r,ref:t})});Hp.displayName=JC;var hl="SelectArrow",ZC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ni(n),s=Xn(hl,n),i=Jn(hl,n);return s.open&&i.position==="popper"?c.jsx(Ff,{...o,...r,ref:t}):null});ZC.displayName=hl;var QC="SelectBubbleInput",Up=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ge(r,o),i=dp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(je.select,{...n,style:{...vp,...n.style},ref:s,defaultValue:t})});Up.displayName=QC;function Wp(e){return e===""||e===void 0}function Vp(e){const t=kt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Kp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=eT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function eT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tT=bp,qp=yp,nT=Cp,rT=Tp,oT=kp,Gp=Ip,sT=_p,Yp=Pp,Xp=Mp,iT=Dp,aT=$p,Jp=Fp,Zp=Bp,Qp=Hp;const em=tT,tm=nT,pl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(qp,{ref:r,className:Z("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(rT,{asChild:!0,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pl.displayName=qp.displayName;const nm=m.forwardRef(({className:e,...t},n)=>c.jsx(Jp,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronUp,{className:"h-4 w-4"})}));nm.displayName=Jp.displayName;const rm=m.forwardRef(({className:e,...t},n)=>c.jsx(Zp,{ref:n,className:Z("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ie.ChevronDown,{className:"h-4 w-4"})}));rm.displayName=Zp.displayName;const ml=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(oT,{children:c.jsxs(Gp,{ref:o,className:Z("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(nm,{}),c.jsx(sT,{className:Z("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(rm,{})]})}));ml.displayName=Gp.displayName;const lT=m.forwardRef(({className:e,...t},n)=>c.jsx(Yp,{ref:n,className:Z("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));lT.displayName=Yp.displayName;const yr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Xp,{ref:r,className:Z("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(aT,{children:c.jsx(ie.Check,{className:"h-4 w-4"})})}),c.jsx(iT,{children:t})]}));yr.displayName=Xp.displayName;const cT=m.forwardRef(({className:e,...t},n)=>c.jsx(Qp,{ref:n,className:Z("-mx-1 my-1 h-px bg-muted",e),...t}));cT.displayName=Qp.displayName;var uT="Separator",om="horizontal",dT=["horizontal","vertical"],sm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=om,...o}=e,s=fT(r)?r:om,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(je.div,{"data-orientation":s,...a,...o,ref:t})});sm.displayName=uT;function fT(e){return dT.includes(e)}var im=sm;const am=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(im,{ref:o,decorative:n,orientation:t,className:Z("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));am.displayName=im.displayName;const hT=Ud,pT=qw,mT=Wd,lm=m.forwardRef(({className:e,...t},n)=>c.jsx(ks,{className:Z("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}));lm.displayName=ks.displayName;const gT=ko.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"}}),cm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(mT,{children:[c.jsx(lm,{}),c.jsxs(Is,{ref:o,className:Z(gT({side:e}),t),...r,children:[n,c.jsxs(Vd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ie.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cm.displayName=Is.displayName;const um=({className:e,...t})=>c.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});um.displayName="SheetHeader";const dm=m.forwardRef(({className:e,...t},n)=>c.jsx(pr,{ref:n,className:Z("text-lg font-semibold text-foreground",e),...t}));dm.displayName=pr.displayName;const fm=m.forwardRef(({className:e,...t},n)=>c.jsx(Es,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));fm.displayName=Es.displayName;const xT={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 vT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=pa();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(xT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const v=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${v.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(hT,{open:r,onOpenChange:o,children:[c.jsx(pT,{asChild:!0,children:c.jsxs(Je,{variant:"outline",size:"sm",className:n,children:[c.jsx(ie.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(oa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(cm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(um,{children:[c.jsx(dm,{children:"Chat Settings"}),c.jsx(fm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(ss,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Gs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(v=>({...v,api:{...v.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Je,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Yn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(v=>({...v,api:{...v.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Gs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(v=>({...v,api:{...v.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Je,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ie.EyeOff,{className:"h-4 w-4"}):c.jsx(ie.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(ss,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(em,{value:a.ui.layout,onValueChange:g=>l(v=>({...v,ui:{...v.ui,layout:g}})),children:[c.jsx(pl,{children:c.jsx(tm,{})}),c.jsxs(ml,{children:[c.jsx(yr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(yr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(yr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"theme",children:"Theme"}),c.jsxs(em,{value:a.ui.theme,onValueChange:g=>l(v=>({...v,ui:{...v.ui,theme:g}})),children:[c.jsx(pl,{children:c.jsx(tm,{})}),c.jsxs(ml,{children:[c.jsx(yr,{value:"light",children:"Light"}),c.jsx(yr,{value:"dark",children:"Dark"}),c.jsx(yr,{value:"system",children:"System"})]})]})]}),c.jsx(am,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Yn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Yn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Yn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ie.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(ss,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Yn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Yn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Yn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Je,{variant:"outline",onClick:p,children:[c.jsx(ie.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Je,{variant:"outline",onClick:b,children:"Cancel"}),c.jsxs(Je,{onClick:h,disabled:!u,children:[c.jsx(ie.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function bT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Uo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(qs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Uo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(qs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Uo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(qs,{onError:s.onError,enableFileUpload:!0})})]})})}Re.ChatApi=dc,Re.ChatInterface=qs,Re.ChatProviders=Uo,Re.ChatSettings=vT,Re.MarkdownContent=da,Re.MessageComponent=ef,Re.MessageList=_a,Re.ThreadManager=al,Re.applySettings=TC,Re.chatApiClient=Fn,Re.default=bT,Re.del=uc,Re.get=nn,Re.getChatToken=ac,Re.getCurrentSettings=CC,Re.getDefaultApiConfig=ip,Re.getDefaultChatSettings=ap,Re.onChatTokenChanged=lc,Re.post=Si,Re.put=cc,Re.setChatToken=yi,Re.useApi=Ci,Re.useChatStream=Ec,Re.useMessagesReducer=vc,Re.useStream=Pc,Re.useThreadState=Ho,Re.useThreads=zo,Object.defineProperties(Re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
140
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function hy(e,t=_s){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 py(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),hy(t),fy(t)}function ja(e){const t=e+"CollectionProvider",[n,r]=wn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:v}=x,w=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:w,children:v})};i.displayName=t;const a=e+"CollectionSlot",l=nr.createSlot(a),u=y.forwardRef((x,g)=>{const{scope:v,children:w}=x,S=s(a,v),N=Ge(g,S.collectionRef);return c.jsx(l,{ref:N,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=nr.createSlot(d),p=y.forwardRef((x,g)=>{const{scope:v,children:w,...S}=x,N=y.useRef(null),k=Ge(g,N),T=s(d,v);return y.useEffect(()=>(T.itemMap.set(N,{ref:N,...S}),()=>void T.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:k,children:w})});p.displayName=d;function b(x){const g=s(e+"CollectionConsumer",x);return y.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},b,r]}var my=m.createContext(void 0);function js(e){const t=m.useContext(my);return e||t||"ltr"}const gy=["top","right","bottom","left"],Gn=Math.min,Wt=Math.max,Rs=Math.round,Ps=Math.floor,Cn=e=>({x:e,y:e}),xy={left:"right",right:"left",bottom:"top",top:"bottom"},vy={start:"end",end:"start"};function Ra(e,t,n){return Wt(e,Gn(t,n))}function Dn(e,t){return typeof e=="function"?e(t):e}function Ln(e){return e.split("-")[0]}function Dr(e){return e.split("-")[1]}function Pa(e){return e==="x"?"y":"x"}function Oa(e){return e==="y"?"height":"width"}const by=new Set(["top","bottom"]);function kn(e){return by.has(Ln(e))?"y":"x"}function Ma(e){return Pa(kn(e))}function wy(e,t,n){n===void 0&&(n=!1);const r=Dr(e),o=Ma(e),s=Oa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Os(i)),[i,Os(i)]}function yy(e){const t=Os(e);return[Da(e),t,Da(t)]}function Da(e){return e.replace(/start|end/g,t=>vy[t])}const of=["left","right"],sf=["right","left"],Sy=["top","bottom"],Cy=["bottom","top"];function ky(e,t,n){switch(e){case"top":case"bottom":return n?t?sf:of:t?of:sf;case"left":case"right":return t?Sy:Cy;default:return[]}}function Ty(e,t,n,r){const o=Dr(e);let s=ky(Ln(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Da)))),s}function Os(e){return e.replace(/left|right|bottom|top/g,t=>xy[t])}function Iy(e){return{top:0,right:0,bottom:0,left:0,...e}}function af(e){return typeof e!="number"?Iy(e):{top:e,right:e,bottom:e,left:e}}function Ms(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 lf(e,t,n){let{reference:r,floating:o}=e;const s=kn(t),i=Ma(t),a=Oa(i),l=Ln(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Dr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const Ey=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=lf(u,r,l),h=r,p={},b=0;for(let x=0;x<a.length;x++){const{name:g,fn:v}=a[x],{x:w,y:S,data:N,reset:k}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[g]:{...p[g],...N}},k&&b<=50&&(b++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(u=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:d,y:f}=lf(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function mo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Dn(t,e),b=af(p),g=a[h?f==="floating"?"reference":"floating":f],v=Ms(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),N=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},k=Ms(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(v.top-k.top+b.top)/N.y,bottom:(k.bottom-v.bottom+b.bottom)/N.y,left:(v.left-k.left+b.left)/N.x,right:(k.right-v.right+b.right)/N.x}}const Ny=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=Dn(e,t)||{};if(u==null)return{};const f=af(d),h={x:n,y:r},p=Ma(o),b=Oa(p),x=await i.getDimensions(u),g=p==="y",v=g?"top":"left",w=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[b]+s.reference[p]-h[p]-s.floating[b],k=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[b]);const A=N/2-k/2,j=E/2-x[b]/2-1,P=Gn(f[v],j),L=Gn(f[w],j),$=P,V=E-x[b]-L,M=E/2-x[b]/2+A,G=Ra($,M,V),K=!l.arrow&&Dr(o)!=null&&M!==G&&s.reference[b]/2-(M<$?P:L)-x[b]/2<0,W=K?M<$?M-$:M-V:0;return{[p]:h[p]+W,data:{[p]:G,centerOffset:M-G-W,...K&&{alignmentOffset:W}},reset:K}}}),Ay=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...g}=Dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Ln(o),w=kn(a),S=Ln(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=h||(S||!x?[Os(a)]:yy(a)),T=b!=="none";!h&&T&&k.push(...Ty(a,x,b,N));const E=[a,...k],A=await mo(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[v]),f){const M=wy(o,i,N);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var L,$;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,G=E[M];if(G&&(!(f==="alignment"?w!==kn(G):!1)||P.every(z=>kn(z.placement)===w?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:G}};let K=($=P.filter(W=>W.overflows[0]<=0).sort((W,z)=>W.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!K)switch(p){case"bestFit":{var V;const W=(V=P.filter(z=>{if(T){const B=kn(z.placement);return B===w||B==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(B=>B>0).reduce((B,ue)=>B+ue,0)]).sort((z,B)=>z[1]-B[1])[0])==null?void 0:V[0];W&&(K=W);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function cf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function uf(e){return gy.some(t=>e[t]>=0)}const _y=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Dn(e,t);switch(r){case"referenceHidden":{const s=await mo(t,{...o,elementContext:"reference"}),i=cf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:uf(i)}}}case"escaped":{const s=await mo(t,{...o,altBoundary:!0}),i=cf(s,n.floating);return{data:{escapedOffsets:i,escaped:uf(i)}}}default:return{}}}}},df=new Set(["left","top"]);async function jy(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Ln(n),a=Dr(n),l=kn(n)==="y",u=df.has(i)?-1:1,d=s&&l?-1:1,f=Dn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(p=a==="end"?b*-1:b),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Ry=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 jy(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}}}}},Py=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:v,y:w}=g;return{x:v,y:w}}},...l}=Dn(e,t),u={x:n,y:r},d=await mo(t,l),f=kn(Ln(o)),h=Pa(f);let p=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=p+d[g],S=p-d[v];p=Ra(w,p,S)}if(i){const g=f==="y"?"top":"left",v=f==="y"?"bottom":"right",w=b+d[g],S=b-d[v];b=Ra(w,b,S)}const x=a.fn({...t,[h]:p,[f]:b});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Oy=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=Dn(e,t),d={x:n,y:r},f=kn(o),h=Pa(f);let p=d[h],b=d[f];const x=Dn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,k=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>k&&(p=k)}if(u){var v,w;const S=h==="y"?"width":"height",N=df.has(Ln(o)),k=s.reference[f]-s.floating[S]+(N&&((v=i.offset)==null?void 0:v[f])||0)+(N?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(N?0:((w=i.offset)==null?void 0:w[f])||0)-(N?g.crossAxis:0);b<k?b=k:b>T&&(b=T)}return{[h]:p,[f]:b}}}},My=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=Dn(e,t),d=await mo(t,u),f=Ln(o),h=Dr(o),p=kn(o)==="y",{width:b,height:x}=s.floating;let g,v;f==="top"||f==="bottom"?(g=f,v=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,g=h==="end"?"top":"bottom");const w=x-d.top-d.bottom,S=b-d.left-d.right,N=Gn(x-d[g],w),k=Gn(b-d[v],S),T=!t.middlewareData.shift;let E=N,A=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!h){const P=Wt(d.left,0),L=Wt(d.right,0),$=Wt(d.top,0),V=Wt(d.bottom,0);p?A=b-2*(P!==0||L!==0?P+L:Wt(d.left,d.right)):E=x-2*($!==0||V!==0?$+V:Wt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return b!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function Ds(){return typeof window<"u"}function Lr(e){return ff(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tn(e){var t;return(t=(ff(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ff(e){return Ds()?e instanceof Node||e instanceof Vt(e).Node:!1}function ln(e){return Ds()?e instanceof Element||e instanceof Vt(e).Element:!1}function In(e){return Ds()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function hf(e){return!Ds()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const Dy=new Set(["inline","contents"]);function go(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Dy.has(o)}const Ly=new Set(["table","td","th"]);function $y(e){return Ly.has(Lr(e))}const Fy=[":popover-open",":modal"];function Ls(e){return Fy.some(t=>{try{return e.matches(t)}catch{return!1}})}const By=["transform","translate","scale","rotate","perspective"],zy=["transform","translate","scale","rotate","perspective","filter"],Hy=["paint","layout","strict","content"];function La(e){const t=$a(),n=ln(e)?cn(e):e;return By.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)||zy.some(r=>(n.willChange||"").includes(r))||Hy.some(r=>(n.contain||"").includes(r))}function Uy(e){let t=Yn(e);for(;In(t)&&!$r(t);){if(La(t))return t;if(Ls(t))return null;t=Yn(t)}return null}function $a(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Wy=new Set(["html","body","#document"]);function $r(e){return Wy.has(Lr(e))}function cn(e){return Vt(e).getComputedStyle(e)}function $s(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Yn(e){if(Lr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||hf(e)&&e.host||Tn(e);return hf(t)?t.host:t}function pf(e){const t=Yn(e);return $r(t)?e.ownerDocument?e.ownerDocument.body:e.body:In(t)&&go(t)?t:pf(t)}function xo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=pf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(o);if(s){const a=Fa(i);return t.concat(i,i.visualViewport||[],go(o)?o:[],a&&n?xo(a):[])}return t.concat(o,xo(o,[],n))}function Fa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function mf(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=In(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Rs(n)!==s||Rs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ba(e){return ln(e)?e:e.contextElement}function Fr(e){const t=Ba(e);if(!In(t))return Cn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=mf(t);let i=(s?Rs(n.width):n.width)/r,a=(s?Rs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Vy=Cn(0);function gf(e){const t=Vt(e);return!$a()||!t.visualViewport?Vy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ky(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Vt(e)?!1:t}function mr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ba(e);let i=Cn(1);t&&(r?ln(r)&&(i=Fr(r)):i=Fr(e));const a=Ky(s,n,r)?gf(s):Cn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Vt(s),p=r&&ln(r)?Vt(r):r;let b=h,x=Fa(b);for(;x&&r&&p!==b;){const g=Fr(x),v=x.getBoundingClientRect(),w=cn(x),S=v.left+(x.clientLeft+parseFloat(w.paddingLeft))*g.x,N=v.top+(x.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,b=Vt(x),x=Fa(b)}}return Ms({width:d,height:f,x:l,y:u})}function Fs(e,t){const n=$s(e).scrollLeft;return t?t.left+n:mr(Tn(e)).left+n}function xf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Fs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function qy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Tn(r),a=t?Ls(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Cn(1);const d=Cn(0),f=In(r);if((f||!f&&!s)&&((Lr(r)!=="body"||go(i))&&(l=$s(r)),In(r))){const p=mr(r);u=Fr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?xf(i,l):Cn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Gy(e){return Array.from(e.getClientRects())}function Yy(e){const t=Tn(e),n=$s(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Fs(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const vf=25;function Xy(e,t){const n=Vt(e),r=Tn(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=$a();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Fs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,b=Math.abs(r.clientWidth-f.clientWidth-p);b<=vf&&(s-=b)}else u<=vf&&(s+=u);return{width:s,height:i,x:a,y:l}}const Jy=new Set(["absolute","fixed"]);function Zy(e,t){const n=mr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=In(e)?Fr(e):Cn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function bf(e,t,n){let r;if(t==="viewport")r=Xy(e,n);else if(t==="document")r=Yy(Tn(e));else if(ln(t))r=Zy(t,n);else{const o=gf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ms(r)}function wf(e,t){const n=Yn(e);return n===t||!ln(n)||$r(n)?!1:cn(n).position==="fixed"||wf(n,t)}function Qy(e,t){const n=t.get(e);if(n)return n;let r=xo(e,[],!1).filter(a=>ln(a)&&Lr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?Yn(e):e;for(;ln(i)&&!$r(i);){const a=cn(i),l=La(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Jy.has(o.position)||go(i)&&!l&&wf(e,i))?r=r.filter(d=>d!==i):o=a,i=Yn(i)}return t.set(e,r),r}function e0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Ls(t)?[]:Qy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=bf(t,d,o);return u.top=Wt(f.top,u.top),u.right=Gn(f.right,u.right),u.bottom=Gn(f.bottom,u.bottom),u.left=Wt(f.left,u.left),u},bf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function t0(e){const{width:t,height:n}=mf(e);return{width:t,height:n}}function n0(e,t,n){const r=In(t),o=Tn(t),s=n==="fixed",i=mr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Cn(0);function u(){l.x=Fs(o)}if(r||!r&&!s)if((Lr(t)!=="body"||go(o))&&(a=$s(t)),r){const p=mr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?xf(o,a):Cn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function za(e){return cn(e).position==="static"}function yf(e,t){if(!In(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function Sf(e,t){const n=Vt(e);if(Ls(e))return n;if(!In(e)){let o=Yn(e);for(;o&&!$r(o);){if(ln(o)&&!za(o))return o;o=Yn(o)}return n}let r=yf(e,t);for(;r&&$y(r)&&za(r);)r=yf(r,t);return r&&$r(r)&&za(r)&&!La(r)?n:r||Uy(e)||n}const r0=async function(e){const t=this.getOffsetParent||Sf,n=this.getDimensions,r=await n(e.floating);return{reference:n0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function o0(e){return cn(e).direction==="rtl"}const s0={convertOffsetParentRelativeRectToViewportRelativeRect:qy,getDocumentElement:Tn,getClippingRect:e0,getOffsetParent:Sf,getElementRects:r0,getClientRects:Gy,getDimensions:t0,getScale:Fr,isElement:ln,isRTL:o0};function Cf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function i0(e,t){let n=null,r;const o=Tn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const b=Ps(f),x=Ps(o.clientWidth-(d+h)),g=Ps(o.clientHeight-(f+p)),v=Ps(d),S={rootMargin:-b+"px "+-x+"px "+-g+"px "+-v+"px",threshold:Wt(0,Gn(1,l))||1};let N=!0;function k(T){const E=T[0].intersectionRatio;if(E!==l){if(!N)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Cf(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(k,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,S)}n.observe(e)}return i(!0),s}function a0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Ba(e),d=o||s?[...u?xo(u):[],...xo(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?i0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(v=>{let[w]=v;w&&w.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let b,x=l?mr(e):null;l&&g();function g(){const v=mr(e);x&&!Cf(x,v)&&n(),x=v,b=requestAnimationFrame(g)}return n(),()=>{var v;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(b)}}const l0=Ry,c0=Py,u0=Ay,d0=My,f0=_y,kf=Ny,h0=Oy,p0=(e,t,n)=>{const r=new Map,o={platform:s0,...n},s={...o.platform,_c:r};return Ey(e,t,{...o,platform:s})};var m0=typeof document<"u",g0=function(){},Bs=m0?y.useLayoutEffect:g0;function zs(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(!zs(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)&&!zs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Tf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function If(e,t){const n=Tf(e);return Math.round(t*n)/n}function Ha(e){const t=m.useRef(e);return Bs(()=>{t.current=e}),t}function x0(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);zs(h,r)||p(r);const[b,x]=m.useState(null),[g,v]=m.useState(null),w=m.useCallback(z=>{z!==T.current&&(T.current=z,x(z))},[]),S=m.useCallback(z=>{z!==E.current&&(E.current=z,v(z))},[]),N=s||b,k=i||g,T=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=Ha(l),L=Ha(o),$=Ha(u),V=m.useCallback(()=>{if(!T.current||!E.current)return;const z={placement:t,strategy:n,middleware:h};L.current&&(z.platform=L.current),p0(T.current,E.current,z).then(B=>{const ue={...B,isPositioned:$.current!==!1};M.current&&!zs(A.current,ue)&&(A.current=ue,Eo.flushSync(()=>{f(ue)}))})},[h,t,n,L,$]);Bs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Bs(()=>(M.current=!0,()=>{M.current=!1}),[]),Bs(()=>{if(N&&(T.current=N),k&&(E.current=k),N&&k){if(P.current)return P.current(N,k,V);V()}},[N,k,V,P,j]);const G=m.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),K=m.useMemo(()=>({reference:N,floating:k}),[N,k]),W=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!K.floating)return z;const B=If(K.floating,d.x),ue=If(K.floating,d.y);return a?{...z,transform:"translate("+B+"px, "+ue+"px)",...Tf(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:ue}},[n,a,K.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:G,elements:K,floatingStyles:W}),[d,V,G,K,W])}const v0=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?kf({element:r.current,padding:o}).fn(n):{}:r?kf({element:r,padding:o}).fn(n):{}}}},b0=(e,t)=>({...l0(e),options:[e,t]}),w0=(e,t)=>({...c0(e),options:[e,t]}),y0=(e,t)=>({...h0(e),options:[e,t]}),S0=(e,t)=>({...u0(e),options:[e,t]}),C0=(e,t)=>({...d0(e),options:[e,t]}),k0=(e,t)=>({...f0(e),options:[e,t]}),T0=(e,t)=>({...v0(e),options:[e,t]});var I0="Arrow",Ef=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ef.displayName=I0;var E0=Ef;function Nf(e){const[t,n]=m.useState(void 0);return Ct(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ua="Popper",[Af,Hs]=wn(Ua),[N0,_f]=Af(Ua),jf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(N0,{scope:t,anchor:r,onAnchorChange:o,children:n})};jf.displayName=Ua;var Rf="PopperAnchor",Pf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_f(Rf,n),i=m.useRef(null),a=Ge(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(_e.div,{...o,ref:a})});Pf.displayName=Rf;var Wa="PopperContent",[A0,_0]=Af(Wa),Of=m.forwardRef((e,t)=>{var q,O,X,ne,pe,se;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:b,...x}=e,g=_f(Wa,n),[v,w]=m.useState(null),S=Ge(t,me=>w(me)),[N,k]=m.useState(null),T=Nf(N),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(u)?u:[u],$=L.length>0,V={padding:P,boundary:L.filter(R0),altBoundary:$},{refs:M,floatingStyles:G,placement:K,isPositioned:W,middlewareData:z}=x0({strategy:"fixed",placement:j,whileElementsMounted:(...me)=>a0(...me,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[b0({mainAxis:o+A,alignmentAxis:i}),l&&w0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?y0():void 0,...V}),l&&S0({...V}),C0({...V,apply:({elements:me,rects:et,availableWidth:tt,availableHeight:Pe})=>{const{width:Ve,height:ut}=et.reference,nt=me.floating.style;nt.setProperty("--radix-popper-available-width",`${tt}px`),nt.setProperty("--radix-popper-available-height",`${Pe}px`),nt.setProperty("--radix-popper-anchor-width",`${Ve}px`),nt.setProperty("--radix-popper-anchor-height",`${ut}px`)}}),N&&T0({element:N,padding:a}),P0({arrowWidth:E,arrowHeight:A}),h&&k0({strategy:"referenceHidden",...V})]}),[B,ue]=Lf(K),D=Tt(b);Ct(()=>{W&&(D==null||D())},[W,D]);const te=(q=z.arrow)==null?void 0:q.x,he=(O=z.arrow)==null?void 0:O.y,we=((X=z.arrow)==null?void 0:X.centerOffset)!==0,[ye,Se]=m.useState();return Ct(()=>{v&&Se(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:W?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ye,"--radix-popper-transform-origin":[(ne=z.transformOrigin)==null?void 0:ne.x,(pe=z.transformOrigin)==null?void 0:pe.y].join(" "),...((se=z.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(A0,{scope:n,placedSide:B,onArrowChange:k,arrowX:te,arrowY:he,shouldHideArrow:we,children:c.jsx(_e.div,{"data-side":B,"data-align":ue,...x,ref:S,style:{...x.style,animation:W?void 0:"none"}})})})});Of.displayName=Wa;var Mf="PopperArrow",j0={top:"bottom",right:"left",bottom:"top",left:"right"},Df=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=_0(Mf,r),i=j0[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(E0,{...o,ref:n,style:{...o.style,display:"block"}})})});Df.displayName=Mf;function R0(e){return e!==null}var P0=e=>({name:"transformOrigin",options:e,fn(t){var g,v,w;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Lf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let b="",x="";return u==="bottom"?(b=i?f:`${h}px`,x=`${-l}px`):u==="top"?(b=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(b=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(b=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:b,y:x}}}});function Lf(e){const[t,n="center"]=e.split("-");return[t,n]}var $f=jf,Ff=Pf,Bf=Of,zf=Df,Va="rovingFocusGroup.onEntryFocus",O0={bubbles:!1,cancelable:!0},vo="RovingFocusGroup",[Ka,Hf,M0]=ja(vo),[D0,Uf]=wn(vo,[M0]),[L0,$0]=D0(vo),Wf=m.forwardRef((e,t)=>c.jsx(Ka.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ka.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(F0,{...e,ref:t})})}));Wf.displayName=vo;var F0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Ge(t,h),b=js(s),[x,g]=ur({prop:i,defaultProp:a??null,onChange:l,caller:vo}),[v,w]=m.useState(!1),S=Tt(u),N=Hf(n),k=m.useRef(!1),[T,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Va,S),()=>A.removeEventListener(Va,S)},[S]),c.jsx(L0,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(_e.div,{tabIndex:v||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{k.current=!0}),onFocus:fe(e.onFocus,A=>{const j=!k.current;if(A.target===A.currentTarget&&j&&!v){const P=new CustomEvent(Va,O0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(K=>K.focusable),$=L.find(K=>K.active),V=L.find(K=>K.id===x),G=[$,V,...L].filter(Boolean).map(K=>K.ref.current);qf(G,d)}}k.current=!1}),onBlur:fe(e.onBlur,()=>w(!1))})})}),Vf="RovingFocusGroupItem",Kf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=yn(),u=s||l,d=$0(Vf,n),f=d.currentTabStopId===u,h=Hf(n),{onFocusableItemAdd:p,onFocusableItemRemove:b,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>b()},[r,p,b]),c.jsx(Ka.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:fe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const v=H0(g,d.orientation,d.dir);if(v!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?U0(S,N+1):S.slice(N+1)}setTimeout(()=>qf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Kf.displayName=Vf;var B0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function z0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function H0(e,t,n){const r=z0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return B0[r]}function qf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function U0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var W0=Wf,V0=Kf,qa=["Enter"," "],K0=["ArrowDown","PageUp","Home"],Gf=["ArrowUp","PageDown","End"],q0=[...K0,...Gf],G0={ltr:[...qa,"ArrowRight"],rtl:[...qa,"ArrowLeft"]},Y0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bo="Menu",[wo,X0,J0]=ja(bo),[gr,Yf]=wn(bo,[J0,Hs,Uf]),Us=Hs(),Xf=Uf(),[Z0,xr]=gr(bo),[Q0,yo]=gr(bo),Jf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Us(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Tt(s),h=js(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),c.jsx($f,{...a,children:c.jsx(Z0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Q0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Jf.displayName=bo;var eS="MenuAnchor",Ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Us(n);return c.jsx(Ff,{...o,...r,ref:t})});Ga.displayName=eS;var Ya="MenuPortal",[tS,Zf]=gr(Ya,{forceMount:void 0}),Qf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=xr(Ya,t);return c.jsx(tS,{scope:t,forceMount:n,children:c.jsx(Ut,{present:n||s.open,children:c.jsx(ms,{asChild:!0,container:o,children:r})})})};Qf.displayName=Ya;var Yt="MenuContent",[nS,Xa]=gr(Yt),eh=m.forwardRef((e,t)=>{const n=Zf(Yt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=xr(Yt,e.__scopeMenu),i=yo(Yt,e.__scopeMenu);return c.jsx(wo.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{present:r||s.open,children:c.jsx(wo.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(rS,{...o,ref:t}):c.jsx(oS,{...o,ref:t})})})})}),rS=m.forwardRef((e,t)=>{const n=xr(Yt,e.__scopeMenu),r=m.useRef(null),o=Ge(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ta(s)},[]),c.jsx(Ja,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),oS=m.forwardRef((e,t)=>{const n=xr(Yt,e.__scopeMenu);return c.jsx(Ja,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),sS=nr.createSlot("MenuContent.ScrollLock"),Ja=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:b,...x}=e,g=xr(Yt,n),v=yo(Yt,n),w=Us(n),S=Xf(n),N=X0(n),[k,T]=m.useState(null),E=m.useRef(null),A=Ge(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),L=m.useRef(0),$=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),G=b?ys:m.Fragment,K=b?{as:sS,allowPinchZoom:!0}:void 0,W=B=>{var q,O;const ue=P.current+B,D=N().filter(X=>!X.disabled),te=document.activeElement,he=(q=D.find(X=>X.ref.current===te))==null?void 0:q.textValue,we=D.map(X=>X.textValue),ye=xS(we,ue,he),Se=(O=D.find(X=>X.textValue===ye))==null?void 0:O.ref.current;(function X(ne){P.current=ne,window.clearTimeout(j.current),ne!==""&&(j.current=window.setTimeout(()=>X(""),1e3))})(ue),Se&&setTimeout(()=>Se.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),ba();const z=m.useCallback(B=>{var D,te;return V.current===((D=$.current)==null?void 0:D.side)&&bS(B,(te=$.current)==null?void 0:te.area)},[]);return c.jsx(nS,{scope:n,searchRef:P,onItemEnter:m.useCallback(B=>{z(B)&&B.preventDefault()},[z]),onItemLeave:m.useCallback(B=>{var ue;z(B)||((ue=E.current)==null||ue.focus(),T(null))},[z]),onTriggerLeave:m.useCallback(B=>{z(B)&&B.preventDefault()},[z]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback(B=>{$.current=B},[]),children:c.jsx(G,{...K,children:c.jsx(ps,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,B=>{var ue;B.preventDefault(),(ue=E.current)==null||ue.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(hs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(W0,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:T,onEntryFocus:fe(l,B=>{v.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Bf,{role:"menu","aria-orientation":"vertical","data-state":xh(g.open),"data-radix-menu-content":"",dir:v.dir,...w,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,B=>{const D=B.target.closest("[data-radix-menu-content]")===B.currentTarget,te=B.ctrlKey||B.altKey||B.metaKey,he=B.key.length===1;D&&(B.key==="Tab"&&B.preventDefault(),!te&&he&&W(B.key));const we=E.current;if(B.target!==we||!q0.includes(B.key))return;B.preventDefault();const Se=N().filter(q=>!q.disabled).map(q=>q.ref.current);Gf.includes(B.key)&&Se.reverse(),mS(Se)}),onBlur:fe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:fe(e.onPointerMove,Co(B=>{const ue=B.target,D=M.current!==B.clientX;if(B.currentTarget.contains(ue)&&D){const te=B.clientX>M.current?"right":"left";V.current=te,M.current=B.clientX}}))})})})})})})});eh.displayName=Yt;var iS="MenuGroup",Za=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"group",...r,ref:t})});Za.displayName=iS;var aS="MenuLabel",th=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{...r,ref:t})});th.displayName=aS;var Ws="MenuItem",nh="menu.itemSelect",Vs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=yo(Ws,e.__scopeMenu),a=Xa(Ws,e.__scopeMenu),l=Ge(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(nh,{bubbles:!0,cancelable:!0});f.addEventListener(nh,p=>r==null?void 0:r(p),{once:!0}),Du(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(rh,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Vs.displayName=Ws;var rh=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xa(Ws,n),a=Xf(n),l=m.useRef(null),u=Ge(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const b=l.current;b&&p((b.textContent??"").trim())},[s.children]),c.jsx(wo.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(V0,{asChild:!0,...a,focusable:!r,children:c.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:fe(e.onPointerMove,Co(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,Co(b=>i.onItemLeave(b))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),lS="MenuCheckboxItem",oh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(ch,{scope:e.__scopeMenu,checked:n,children:c.jsx(Vs,{role:"menuitemcheckbox","aria-checked":Ks(n)?"mixed":n,...o,ref:t,"data-state":el(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(Ks(n)?!0:!n),{checkForDefaultPrevented:!1})})})});oh.displayName=lS;var sh="MenuRadioGroup",[cS,uS]=gr(sh,{value:void 0,onValueChange:()=>{}}),ih=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Tt(r);return c.jsx(cS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Za,{...o,ref:t})})});ih.displayName=sh;var ah="MenuRadioItem",lh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=uS(ah,e.__scopeMenu),s=n===o.value;return c.jsx(ch,{scope:e.__scopeMenu,checked:s,children:c.jsx(Vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":el(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lh.displayName=ah;var Qa="MenuItemIndicator",[ch,dS]=gr(Qa,{checked:!1}),uh=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=dS(Qa,n);return c.jsx(Ut,{present:r||Ks(s.checked)||s.checked===!0,children:c.jsx(_e.span,{...o,ref:t,"data-state":el(s.checked)})})});uh.displayName=Qa;var fS="MenuSeparator",dh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});dh.displayName=fS;var hS="MenuArrow",fh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Us(n);return c.jsx(zf,{...o,...r,ref:t})});fh.displayName=hS;var pS="MenuSub",[Jk,hh]=gr(pS),So="MenuSubTrigger",ph=m.forwardRef((e,t)=>{const n=xr(So,e.__scopeMenu),r=yo(So,e.__scopeMenu),o=hh(So,e.__scopeMenu),s=Xa(So,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Ga,{asChild:!0,...u,children:c.jsx(rh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xh(n.open),...e,ref:sa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,Co(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:fe(e.onPointerLeave,Co(f=>{var p,b;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(b=n.content)==null?void 0:b.dataset.side,g=x==="right",v=g?-5:5,w=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||G0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});ph.displayName=So;var mh="MenuSubContent",gh=m.forwardRef((e,t)=>{const n=Zf(Yt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=xr(Yt,e.__scopeMenu),i=yo(Yt,e.__scopeMenu),a=hh(mh,e.__scopeMenu),l=m.useRef(null),u=Ge(t,l);return c.jsx(wo.Provider,{scope:e.__scopeMenu,children:c.jsx(Ut,{present:r||s.open,children:c.jsx(wo.Slot,{scope:e.__scopeMenu,children:c.jsx(Ja,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Y0[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});gh.displayName=mh;function xh(e){return e?"open":"closed"}function Ks(e){return e==="indeterminate"}function el(e){return Ks(e)?"indeterminate":e?"checked":"unchecked"}function mS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function gS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function xS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=gS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function vS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function bS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return vS(n,t)}function Co(e){return t=>t.pointerType==="mouse"?e(t):void 0}var wS=Jf,yS=Ga,SS=Qf,CS=eh,kS=Za,TS=th,IS=Vs,ES=oh,NS=ih,AS=lh,_S=uh,jS=dh,RS=fh,PS=ph,OS=gh,qs="DropdownMenu",[MS,Zk]=wn(qs,[Yf]),Ot=Yf(),[DS,vh]=MS(qs),bh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),u=m.useRef(null),[d,f]=ur({prop:o,defaultProp:s??!1,onChange:i,caller:qs});return c.jsx(DS,{scope:t,triggerId:yn(),triggerRef:u,contentId:yn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(wS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};bh.displayName=qs;var wh="DropdownMenuTrigger",yh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vh(wh,n),i=Ot(n);return c.jsx(yS,{asChild:!0,...i,children:c.jsx(_e.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:sa(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yh.displayName=wh;var LS="DropdownMenuPortal",Sh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return c.jsx(SS,{...r,...n})};Sh.displayName=LS;var Ch="DropdownMenuContent",kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vh(Ch,n),s=Ot(n),i=m.useRef(!1);return c.jsx(CS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kh.displayName=Ch;var $S="DropdownMenuGroup",FS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(kS,{...o,...r,ref:t})});FS.displayName=$S;var BS="DropdownMenuLabel",Th=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(TS,{...o,...r,ref:t})});Th.displayName=BS;var zS="DropdownMenuItem",Ih=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(IS,{...o,...r,ref:t})});Ih.displayName=zS;var HS="DropdownMenuCheckboxItem",Eh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ES,{...o,...r,ref:t})});Eh.displayName=HS;var US="DropdownMenuRadioGroup",WS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(NS,{...o,...r,ref:t})});WS.displayName=US;var VS="DropdownMenuRadioItem",Nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(AS,{...o,...r,ref:t})});Nh.displayName=VS;var KS="DropdownMenuItemIndicator",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(_S,{...o,...r,ref:t})});Ah.displayName=KS;var qS="DropdownMenuSeparator",_h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(jS,{...o,...r,ref:t})});_h.displayName=qS;var GS="DropdownMenuArrow",YS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(RS,{...o,...r,ref:t})});YS.displayName=GS;var XS="DropdownMenuSubTrigger",jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(PS,{...o,...r,ref:t})});jh.displayName=XS;var JS="DropdownMenuSubContent",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(OS,{...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)"}})});Rh.displayName=JS;var ZS=bh,QS=yh,eC=Sh,Ph=kh,Oh=Th,Mh=Ih,Dh=Eh,Lh=Nh,$h=Ah,Fh=_h,Bh=jh,zh=Rh;const tC=ZS,nC=QS,rC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Bh,{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,c.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));rC.displayName=Bh.displayName;const oC=m.forwardRef(({className:e,...t},n)=>c.jsx(zh,{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}));oC.displayName=zh.displayName;const Hh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(eC,{children:c.jsx(Ph,{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})}));Hh.displayName=Ph.displayName;const tl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Mh,{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}));tl.displayName=Mh.displayName;const sC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Dh,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx($h,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));sC.displayName=Dh.displayName;const iC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Lh,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx($h,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));iC.displayName=Lh.displayName;const aC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Oh,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));aC.displayName=Oh.displayName;const lC=m.forwardRef(({className:e,...t},n)=>c.jsx(Fh,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));lC.displayName=Fh.displayName;function Gs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:b}=Ci(),{currentThreadId:x}=Ho(),{threadId:g,messages:v,hasMore:w,isHistoryLoading:S,isLoading:N,loadOlder:k,listCheckpoints:T,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:L}=Uo(),{isStreaming:$,error:V,submit:M,stop:G}=Mc(),K=g??x??null,W=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,B=(L==null?void 0:L.assemblingMessageId)??null,[ue,D]=y.useState(null),[te,he]=y.useState(""),[we,ye]=y.useState(null),[Se,q]=y.useState([]),[O,X]=y.useState(0),[ne,pe]=y.useState(0),[se,me]=y.useState(!1),[et,tt]=y.useState(null),[Pe,Ve]=y.useState(null),[ut,nt]=y.useState(!1),[Ke,vt]=y.useState(null),[Q,ie]=y.useState([]),[xe,Ce]=y.useState(null),[ve,Oe]=y.useState(null),[at,Me]=y.useState(!1),st=y.useRef(null),ft=y.useRef(null),It=y.useRef(null),Nn=y.useCallback(()=>{st.current&&(st.current.value=""),ft.current&&(ft.current.value=""),X(oe=>oe+1),pe(oe=>oe+1)},[]),dn=y.useRef(!1);y.useEffect(()=>{dn.current&&!$&&(q([]),Nn()),dn.current=$},[$,Nn]);const[Zt,An]=y.useState("desktop");y.useEffect(()=>{const oe=()=>{const ke=window.innerWidth;An(ke<640?"phone":ke<1024?"tablet":"desktop")};return oe(),window.addEventListener("resize",oe),()=>window.removeEventListener("resize",oe)},[]),y.useEffect(()=>{let oe=!1;if(!K){ie([]),Ce(null),Oe(null),It.current=null;return}const ke={threadId:K,checkpointId:W??null,checkpointNs:z??null},qe=It.current;if(!(qe&&qe.threadId===ke.threadId&&qe.checkpointId===ke.checkpointId&&qe.checkpointNs===ke.checkpointNs))return T(K).then(it=>{var Ee;if(oe)return;const Mt=((it==null?void 0:it.checkpoints)??[]).slice().sort((Be,Xe)=>new Date(Xe.createdAt).getTime()-new Date(Be.createdAt).getTime());ie(Mt);const I=xe,H=I&&Mt.some(Be=>Be.checkpointId===I)?I:((Ee=Mt[0])==null?void 0:Ee.checkpointId)??null;let re=null;if(H){const Be=Mt.find(Xe=>Xe.checkpointId===H);re=(Be==null?void 0:Be.checkpointNs)??null}Ce(H),Oe(re),It.current=ke}).catch(it=>{console.error("ChatInterface - listCheckpoints error:",it),oe||(ie([]),It.current=null)}),()=>{oe=!0}},[K,W,z,xe,T]),y.useEffect(()=>{W&&(Ce(W),Oe(z??null))},[W,z]);const _n=y.useCallback(async()=>{if(!(!w||S))try{await k()}catch(oe){console.warn("loadOlder failed",oe)}},[w,S,k]);y.useEffect(()=>{(async()=>{if(!b.baseUrl){vt(null);return}try{const ke=await b.getAgent("default");vt(ke.uiDefaultMessage||null)}catch(ke){console.warn("Failed to fetch default message:",ke),vt(null)}})()},[b]),y.useEffect(()=>{V&&!ut&&(p==null||p(V))},[V,ut,p]);const Qn=oe=>{if(oe.length>_s)return`Message too long (${oe.length}/${_s} characters)`;try{return py(oe),null}catch(ke){return(ke==null?void 0:ke.message)||"Invalid message"}},To=async oe=>{const ke=oe.trim();if(!(!ke&&Se.length===0)){if(ke){const qe=Qn(ke);if(qe){ye(qe);return}}try{await M({text:ke||"",attachments:Se,payload:ue?{edit:!0,originalMessageId:ue}:void 0},{checkpointId:xe??W??void 0,checkpointNs:ve??z??void 0}),f==null||f(ke),ye(null),q([]),Nn(),D(null),he("")}catch(qe){const it=(qe==null?void 0:qe.message)||"Failed to send message";ye(it),p==null||p(it)}}},fn=y.useCallback((oe,ke)=>{u&&(D(oe),he(ke),ye(null))},[u]),hn=y.useCallback(()=>{D(null),he(""),ye(null)},[]),Et=y.useCallback((oe,ke)=>{fn(oe,ke)},[fn]),Ur=y.useCallback(oe=>{const ke=qe=>{const it=qe.content||[],Mt=it.filter(I=>I.type==="text").map(I=>I.text).join("");if(Mt)return Mt;try{return JSON.stringify(it,null,2)}catch{return String(it)}};for(let qe=oe-1;qe>=0;qe--)if(v[qe].role==="user"){const it=ke(v[qe]);it&&M({text:it},{checkpointId:xe??W??void 0,checkpointNs:ve??z??void 0});break}},[v,M,xe,ve,W,z]),yr=oe=>{const ke=Array.from(oe.target.files||[]);q(qe=>[...qe,...ke]),oe.target.value=""},yt=oe=>{q(ke=>{const qe=ke.filter((it,Mt)=>oe!==Mt);return qe.length===0&&Nn(),qe})},jn=async oe=>{const ke=(oe.target.files||[])[0];if(ke){tt(null),Ve(null),me(!0);try{await M({attachments:[ke]},{checkpointId:xe??W??void 0,checkpointNs:ve??z??void 0});const qe=`Uploaded ${ke.name} - processing through chat stream`;Ve(qe)}catch(qe){const it=qe instanceof Error?qe.message:"Failed to upload Excel file";console.error("Excel upload failed",qe),tt(it),p==null||p(it)}finally{me(!1),oe.target.value="",Nn()}}},Rn=oe=>{if(!oe)return"Unknown";const ke=Date.parse(oe);return Number.isNaN(ke)?oe:new Date(ke).toLocaleString()},Sr=async oe=>{if(x){Me(!0);try{if(!oe){await A(),Ce(null),Oe(null);return}const ke=Q.find(it=>it.checkpointId===oe),qe=(ke==null?void 0:ke.checkpointNs)??null;await E(oe,qe),Ce(oe),Oe(qe)}finally{Me(!1)}}},Qt=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Cr=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,pn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Qt,children:[!!V&&!ut&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>nt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),x&&Q.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:xe??"",onChange:oe=>{const ke=oe.target.value||null;Sr(ke)},children:[c.jsx("option",{value:"",children:"Latest"}),Q.map(oe=>c.jsxs("option",{value:oe.checkpointId,children:[Rn(oe.createdAt),oe.preview?` — ${oe.preview.slice(0,40)}`:""]},oe.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Cr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(_a,{className:"h-full",style:{height:"100%"},messages:v,isStreaming:$,streamingAssistantId:B,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Zt,enableMessageEditing:u,editingMessageId:ue,onStartReached:()=>{_n()},onEdit:Et,onRegenerate:Ur,onCancelEdit:hn,emptyMessage:Ke??void 0,isNavigatingCheckpoint:at}),N&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:pn,children:[ue&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:hn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:st,type:"file",multiple:!0,onChange:oe=>yr(oe),className:"hidden"},O),Se.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Se.map((oe,ke)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:oe.name}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>yt(ke),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 ${oe.name}`,children:c.jsx(ae.X,{size:12})})]},ke))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ft,type:"file",accept:".xls,.xlsx,.xlsm",onChange:jn,className:"hidden"},ne),se&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Pe&&!se&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Pe}),et&&!se&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:et})]})]}),we&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(tC,{children:[c.jsx(nC,{asChild:!0,children:c.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:$,title:"More input actions",className:d.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(Hh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(tl,{onClick:()=>{var oe;return(oe=st.current)==null?void 0:oe.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(tl,{onClick:()=>{var oe;se||(oe=ft.current)==null||oe.click()},className:`cursor-pointer ${se?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Ex,{initialValue:te,editingMessageId:ue,placeholder:ue?"Edit your message...":t,isStreaming:$,disabled:!1,maxLength:_s,onSend:To,onCancelEdit:hn,onStop:G,allowEmptySend:Se.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ue?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ys=m.forwardRef(({className:e,type:t,...n},r)=>c.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}));Ys.displayName="Input";function nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function cC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var rl="ScrollArea",[Uh,Qk]=wn(rl),[uC,Xt]=Uh(rl),Wh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,b]=m.useState(null),[x,g]=m.useState(null),[v,w]=m.useState(0),[S,N]=m.useState(0),[k,T]=m.useState(!1),[E,A]=m.useState(!1),j=Ge(t,L=>l(L)),P=js(o);return c.jsx(uC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:b,scrollbarXEnabled:k,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:N,children:c.jsx(_e.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Wh.displayName=rl;var Vh="ScrollAreaViewport",Kh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Xt(Vh,n),a=m.useRef(null),l=Ge(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(_e.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Kh.displayName=Vh;var En="ScrollAreaScrollbar",ol=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(dC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(fC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(qh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(sl,{...r,ref:t}):null});ol.displayName=En;var dC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(En,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Ut,{present:n||s,children:c.jsx(qh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),fC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xt(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Qs(()=>l("SCROLL_END"),100),[a,l]=cC("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Ut,{present:n||a!=="hidden",children:c.jsx(sl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),qh=m.forwardRef((e,t)=>{const n=Xt(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Qs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Br(n.viewport,l),Br(n.content,l),c.jsx(Ut,{present:r||s,children:c.jsx(sl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),sl=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Xt(En,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Zh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return vC(h,i.current,a,p)}return n==="horizontal"?c.jsx(hC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Qh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(pC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Qh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),hC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Xt(En,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ge(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Yh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Zs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),tp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Js(i.paddingLeft),paddingEnd:Js(i.paddingRight)}})}})}),pC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Xt(En,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Ge(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Yh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Zs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),tp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Js(i.paddingTop),paddingEnd:Js(i.paddingBottom)}})}})}),[mC,Gh]=Uh(En),Yh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Xt(En,n),[b,x]=m.useState(null),g=Ge(t,j=>x(j)),v=m.useRef(null),w=m.useRef(""),S=p.viewport,N=r.content-r.viewport,k=Tt(d),T=Tt(l),E=Qs(f,10);function A(j){if(v.current){const P=j.clientX-v.current.left,L=j.clientY-v.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const j=P=>{const L=P.target;(b==null?void 0:b.contains(L))&&k(P,N)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,b,N,k]),m.useEffect(T,[r,T]),Br(b,E),Br(p.content,E),c.jsx(mC,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:Tt(s),onThumbPointerUp:Tt(i),onThumbPositionChange:T,onThumbPointerDown:Tt(a),children:c.jsx(_e.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),v.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:fe(e.onPointerMove,A),onPointerUp:fe(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),Xs="ScrollAreaThumb",Xh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gh(Xs,e.__scopeScrollArea);return c.jsx(Ut,{present:n||o.hasThumb,children:c.jsx(gC,{ref:t,...r})})}),gC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Xt(Xs,n),i=Gh(Xs,n),{onThumbPositionChange:a}=i,l=Ge(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Qs(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=bC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(_e.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:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),b=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:b,y:x})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});Xh.displayName=Xs;var il="ScrollAreaCorner",Jh=m.forwardRef((e,t)=>{const n=Xt(il,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(xC,{...e,ref:t}):null});Jh.displayName=il;var xC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Xt(il,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Br(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Br(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(_e.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 Js(e){return e?parseInt(e,10):0}function Zh(e,t){const n=e/t;return isNaN(n)?0:n}function Zs(e){const t=Zh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function vC(e,t,n,r="ltr"){const o=Zs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return ep([l,u],f)(e)}function Qh(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],u=nl(e,l);return ep([0,i],[0,a])(u)}function ep(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 tp(e,t){return e>0&&e<t}var bC=(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 Qs(e,t){const n=Tt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Br(e,t){const n=Tt(t);Ct(()=>{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 np=Wh,wC=Kh,yC=Jh;const rp=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(np,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(wC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(op,{}),c.jsx(yC,{})]}));rp.displayName=np.displayName;const op=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ol,{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:c.jsx(Xh,{className:"relative flex-1 rounded-full bg-border"})}));op.displayName=ol.displayName;function al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:b}=Ho(),{loadThread:x}=Uo(),{createThread:g,deleteThread:v,renameThread:w}=b,[S,N]=y.useState(Array.isArray(f)?f:[]),k=y.useRef(S.length>0),[T,E]=y.useState(null),[A,j]=y.useState(""),[P,L]=y.useState(!1);y.useEffect(()=>{const D=Array.isArray(f)?f:[];if(D.length>0){k.current=!0,N(D);return}p||(k.current=!1,N(D))},[f,p]);const $=async D=>{try{await x(D),a==null||a(D),l==null||l(D)}catch(te){console.error("Failed to select thread:",te)}},V=async()=>{try{L(!0);const D=await g();u==null||u(D),a==null||a(D)}catch(D){console.error("Failed to create thread:",D)}finally{L(!1)}},M=async(D,te)=>{if(te.stopPropagation(),!!confirm("Delete this thread?"))try{await v(D),d==null||d(D)}catch(he){console.error("Failed to delete thread:",he)}},G=(D,te)=>{te.stopPropagation(),E(D.threadId),j(D.title||`Thread ${D.threadId.slice(0,8)}`)},K=async D=>{if(A.trim())try{await w(D,A.trim()),E(null),j("")}catch(te){console.error("Failed to update title:",te)}},W=()=>{E(null),j("")},z=(D,te)=>{D.key==="Enter"?K(te):D.key==="Escape"&&W()},B=D=>{if(!D)return"";try{const te=new Date(D),we=new Date().getTime()-te.getTime(),ye=Math.floor(we/(1e3*60*60*24));return ye===0?te.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ye===1?"Yesterday":ye<7?`${ye} days ago`:te.toLocaleDateString()}catch{return""}},ue=D=>D.title||`Thread ${D.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Je,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(ae.MessageSquarePlus,{size:20})})}),c.jsx(rp,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((D,te)=>new Date(te.updatedAt||te.createdAt||"").getTime()-new Date(D.updatedAt||D.createdAt||"").getTime()).map(D=>c.jsxs("div",{onClick:()=>$(D.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===D.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===D.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:te=>te.stopPropagation(),children:[c.jsx(Ys,{value:A,onChange:te=>j(te.target.value),onKeyDown:te=>z(te,D.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>K(D.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:c.jsx(ae.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:ue(D)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:B(D.updatedAt||D.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==D.threadId&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>G(D,te),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ae.Edit3,{size:12})}),n&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>M(D.threadId,te),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ae.Trash2,{size:12})})]})]}),i===D.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},D.threadId))})})]})}function zr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function SC(e){if(typeof e!="string")return;const t=e.trim();if(t)return On(t)}function sp(){const e=[zr("__API_BASE_URL__"),zr("__CHAT_API_BASE_URL__"),zr("__CHAT_API_URL__")];for(const t of e){const n=SC(t);if(n)return n}}function ip(){const e=[zr("__API_AUTH_TOKEN__"),zr("__CHAT_API_KEY__"),zr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ap(...e){for(const t of e)if(typeof t=="string"&&t.trim())return On(t);return On()}function lp(){const e={},t=sp(),n=ip();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function cp(){const e=lp(),t=Bn.getAuthToken(),n=sp();return{apiBaseUrl:ap(e.baseUrl,Bn.baseUrl,n),apiKey:t||e.apiKey||ip()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const up="chat-settings";function CC(){try{const e=localStorage.getItem(up);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function kC(e){try{const t={...e,apiBaseUrl:On(e.apiBaseUrl)};localStorage.setItem(up,JSON.stringify(t)),t.apiKey&&Bn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function TC(){const e=cp(),t=CC(),n=Bn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ap(Bn.baseUrl,r,e.apiBaseUrl)}}function IC(e){Bn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),kC(e)}var EC="Label",dp=m.forwardRef((e,t)=>c.jsx(_e.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())}}));dp.displayName=EC;var fp=dp;const NC=Io.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Jt=m.forwardRef(({className:e,...t},n)=>c.jsx(fp,{ref:n,className:ee(NC(),e),...t}));Jt.displayName=fp.displayName;function hp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ei="Switch",[AC,eT]=wn(ei),[_C,jC]=AC(ei),pp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),b=Ge(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[v,w]=ur({prop:o,defaultProp:s??!1,onChange:u,caller:ei});return c.jsxs(_C,{scope:n,checked:v,disabled:a,children:[c.jsx(_e.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":vp(v),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:b,onClick:fe(e.onClick,S=>{w(N=>!N),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(xp,{control:h,bubbles:!x.current,name:r,value:l,checked:v,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});pp.displayName=ei;var mp="SwitchThumb",gp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=jC(mp,n);return c.jsx(_e.span,{"data-state":vp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});gp.displayName=mp;var RC="SwitchBubbleInput",xp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Ge(i,s),l=hp(n),u=Nf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const b=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(b)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xp.displayName=RC;function vp(e){return e?"checked":"unchecked"}var bp=pp,PC=gp;const Xn=m.forwardRef(({className:e,...t},n)=>c.jsx(bp,{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:c.jsx(PC,{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")})}));Xn.displayName=bp.displayName;var wp=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"}),OC="VisuallyHidden",MC=m.forwardRef((e,t)=>c.jsx(_e.span,{...e,ref:t,style:{...wp,...e.style}}));MC.displayName=OC;var DC=[" ","Enter","ArrowUp","ArrowDown"],LC=[" ","Enter"],vr="Select",[ti,ni,$C]=ja(vr),[Hr,tT]=wn(vr,[$C,Hs]),ri=Hs(),[FC,Jn]=Hr(vr),[BC,zC]=Hr(vr),yp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:b}=e,x=ri(t),[g,v]=m.useState(null),[w,S]=m.useState(null),[N,k]=m.useState(!1),T=js(u),[E,A]=ur({prop:r,defaultProp:o??!1,onChange:s,caller:vr}),[j,P]=ur({prop:i,defaultProp:a,onChange:l,caller:vr}),L=m.useRef(null),$=g?b||!!g.closest("form"):!0,[V,M]=m.useState(new Set),G=Array.from(V).map(K=>K.props.value).join(";");return c.jsx($f,{...x,children:c.jsxs(FC,{required:p,scope:t,trigger:g,onTriggerChange:v,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:k,contentId:yn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(ti.Provider,{scope:t,children:c.jsx(BC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{M(W=>new Set(W).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{M(W=>{const z=new Set(W);return z.delete(K),z})},[]),children:n})}),$?c.jsxs(Vp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>P(K.target.value),disabled:h,form:b,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};yp.displayName=vr;var Sp="SelectTrigger",Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ri(n),i=Jn(Sp,n),a=i.disabled||r,l=Ge(t,i.onTriggerChange),u=ni(n),d=m.useRef("touch"),[f,h,p]=qp(x=>{const g=u().filter(S=>!S.disabled),v=g.find(S=>S.value===i.value),w=Gp(g,x,v);w!==void 0&&i.onValueChange(w.value)}),b=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Ff,{asChild:!0,...s,children:c.jsx(_e.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":Kp(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&b(x)}),onPointerDown:fe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(b(x),x.preventDefault())}),onKeyDown:fe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&DC.includes(x.key)&&(b(),x.preventDefault())})})})});Cp.displayName=Sp;var kp="SelectValue",Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Jn(kp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Ge(t,l.onValueNodeChange);return Ct(()=>{u(d)},[u,d]),c.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Kp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Tp.displayName=kp;var HC="SelectIcon",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Ip.displayName=HC;var UC="SelectPortal",Ep=e=>c.jsx(ms,{asChild:!0,...e});Ep.displayName=UC;var br="SelectContent",Np=m.forwardRef((e,t)=>{const n=Jn(br,e.__scopeSelect),[r,o]=m.useState();if(Ct(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Eo.createPortal(c.jsx(Ap,{scope:e.__scopeSelect,children:c.jsx(ti.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(_p,{...e,ref:t})});Np.displayName=br;var un=10,[Ap,Zn]=Hr(br),WC="SelectContentImpl",VC=nr.createSlot("SelectContent.RemoveScroll"),_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:b,hideWhenDetached:x,avoidCollisions:g,...v}=e,w=Jn(br,n),[S,N]=m.useState(null),[k,T]=m.useState(null),E=Ge(t,q=>N(q)),[A,j]=m.useState(null),[P,L]=m.useState(null),$=ni(n),[V,M]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(S)return Ta(S)},[S]),ba();const K=m.useCallback(q=>{const[O,...X]=$().map(se=>se.ref.current),[ne]=X.slice(-1),pe=document.activeElement;for(const se of q)if(se===pe||(se==null||se.scrollIntoView({block:"nearest"}),se===O&&k&&(k.scrollTop=0),se===ne&&k&&(k.scrollTop=k.scrollHeight),se==null||se.focus(),document.activeElement!==pe))return},[$,k]),W=m.useCallback(()=>K([A,S]),[K,A,S]);m.useEffect(()=>{V&&W()},[V,W]);const{onOpenChange:z,triggerPointerDownPosRef:B}=w;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=ne=>{var pe,se;q={x:Math.abs(Math.round(ne.pageX)-(((pe=B.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((se=B.current)==null?void 0:se.y)??0))}},X=ne=>{q.x<=10&&q.y<=10?ne.preventDefault():S.contains(ne.target)||z(!1),document.removeEventListener("pointermove",O),B.current=null};return B.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,z,B]),m.useEffect(()=>{const q=()=>z(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[z]);const[ue,D]=qp(q=>{const O=$().filter(pe=>!pe.disabled),X=O.find(pe=>pe.ref.current===document.activeElement),ne=Gp(O,q,X);ne&&setTimeout(()=>ne.ref.current.focus())}),te=m.useCallback((q,O,X)=>{const ne=!G.current&&!X;(w.value!==void 0&&w.value===O||ne)&&(j(q),ne&&(G.current=!0))},[w.value]),he=m.useCallback(()=>S==null?void 0:S.focus(),[S]),we=m.useCallback((q,O,X)=>{const ne=!G.current&&!X;(w.value!==void 0&&w.value===O||ne)&&L(q)},[w.value]),ye=r==="popper"?ll:jp,Se=ye===ll?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:b,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Ap,{scope:n,content:S,viewport:k,onViewportChange:T,itemRefCallback:te,selectedItem:A,onItemLeave:he,itemTextRefCallback:we,focusSelectedItem:W,selectedItemText:P,position:r,isPositioned:V,searchRef:ue,children:c.jsx(ys,{as:VC,allowPinchZoom:!0,children:c.jsx(ps,{asChild:!0,trapped:w.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var O;(O=w.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(hs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:c.jsx(ye,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:q=>q.preventDefault(),...v,...Se,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:fe(v.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&D(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ne=$().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const pe=q.target,se=ne.indexOf(pe);ne=ne.slice(se+1)}setTimeout(()=>K(ne)),q.preventDefault()}})})})})})})});_p.displayName=WC;var KC="SelectItemAlignedPosition",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Jn(br,n),i=Zn(br,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Ge(t,E=>d(E)),h=ni(n),p=m.useRef(!1),b=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:v,focusSelectedItem:w}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&v){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=v.getBoundingClientRect();if(s.dir!=="rtl"){const pe=P.left-A.left,se=j.left-pe,me=E.left-se,et=E.width+me,tt=Math.max(et,A.width),Pe=window.innerWidth-un,Ve=nl(se,[un,Math.max(un,Pe-tt)]);a.style.minWidth=et+"px",a.style.left=Ve+"px"}else{const pe=A.right-P.right,se=window.innerWidth-j.right-pe,me=window.innerWidth-E.right-se,et=E.width+me,tt=Math.max(et,A.width),Pe=window.innerWidth-un,Ve=nl(se,[un,Math.max(un,Pe-tt)]);a.style.minWidth=et+"px",a.style.right=Ve+"px"}const L=h(),$=window.innerHeight-un*2,V=x.scrollHeight,M=window.getComputedStyle(u),G=parseInt(M.borderTopWidth,10),K=parseInt(M.paddingTop,10),W=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),B=G+K+V+z+W,ue=Math.min(g.offsetHeight*5,B),D=window.getComputedStyle(x),te=parseInt(D.paddingTop,10),he=parseInt(D.paddingBottom,10),we=E.top+E.height/2-un,ye=$-we,Se=g.offsetHeight/2,q=g.offsetTop+Se,O=G+K+q,X=B-O;if(O<=we){const pe=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const se=u.clientHeight-x.offsetTop-x.offsetHeight,me=Math.max(ye,Se+(pe?he:0)+se+W),et=O+me;a.style.height=et+"px"}else{const pe=L.length>0&&g===L[0].ref.current;a.style.top="0px";const me=Math.max(we,G+x.offsetTop+(pe?te:0)+Se)+X;a.style.height=me+"px",x.scrollTop=O-we+x.offsetTop}a.style.margin=`${un}px 0`,a.style.minHeight=ue+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,v,s.dir,r]);Ct(()=>S(),[S]);const[N,k]=m.useState();Ct(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(E=>{E&&b.current===!0&&(S(),w==null||w(),b.current=!1)},[S,w]);return c.jsx(GC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:c.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});jp.displayName=KC;var qC="SelectPopperPosition",ll=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=un,...s}=e,i=ri(n);return c.jsx(Bf,{...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)"}})});ll.displayName=qC;var[GC,cl]=Hr(br,{}),ul="SelectViewport",Rp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Zn(ul,n),i=cl(ul,n),a=Ge(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(ti.Slot,{scope:n,children:c.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const b=window.innerHeight-un*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),v=Math.max(x,g);if(v<b){const w=v+p,S=Math.min(b,w),N=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Rp.displayName=ul;var Pp="SelectGroup",[YC,XC]=Hr(Pp),JC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=yn();return c.jsx(YC,{scope:n,id:o,children:c.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});JC.displayName=Pp;var Op="SelectLabel",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=XC(Op,n);return c.jsx(_e.div,{id:o.id,...r,ref:t})});Mp.displayName=Op;var oi="SelectItem",[ZC,Dp]=Hr(oi),Lp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Jn(oi,n),l=Zn(oi,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),b=Ge(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),x=yn(),g=m.useRef("touch"),v=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(ZC,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:c.jsx(ti.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(_e.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:fe(i.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:fe(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:fe(i.onPointerMove,w=>{var S;g.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,w=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&w.key===" "||(LC.includes(w.key)&&v(),w.key===" "&&w.preventDefault())})})})})});Lp.displayName=oi;var ko="SelectItemText",$p=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Jn(ko,n),a=Zn(ko,n),l=Dp(ko,n),u=zC(ko,n),[d,f]=m.useState(null),h=Ge(t,v=>f(v),l.onItemTextChange,v=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,v,l.value,l.disabled)}),p=d==null?void 0:d.textContent,b=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Ct(()=>(x(b),()=>g(b)),[x,g,b]),c.jsxs(c.Fragment,{children:[c.jsx(_e.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Eo.createPortal(s.children,i.valueNode):null]})});$p.displayName=ko;var Fp="SelectItemIndicator",Bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dp(Fp,n).isSelected?c.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});Bp.displayName=Fp;var dl="SelectScrollUpButton",zp=m.forwardRef((e,t)=>{const n=Zn(dl,e.__scopeSelect),r=cl(dl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ge(t,r.onScrollButtonChange);return Ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Up,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});zp.displayName=dl;var fl="SelectScrollDownButton",Hp=m.forwardRef((e,t)=>{const n=Zn(fl,e.__scopeSelect),r=cl(fl,e.__scopeSelect),[o,s]=m.useState(!1),i=Ge(t,r.onScrollButtonChange);return Ct(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Up,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hp.displayName=fl;var Up=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Zn("SelectScrollButton",n),i=m.useRef(null),a=ni(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Ct(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),QC="SelectSeparator",Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});Wp.displayName=QC;var hl="SelectArrow",ek=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ri(n),s=Jn(hl,n),i=Zn(hl,n);return s.open&&i.position==="popper"?c.jsx(zf,{...o,...r,ref:t}):null});ek.displayName=hl;var tk="SelectBubbleInput",Vp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Ge(r,o),i=hp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(_e.select,{...n,style:{...wp,...n.style},ref:s,defaultValue:t})});Vp.displayName=tk;function Kp(e){return e===""||e===void 0}function qp(e){const t=Tt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=nk(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function nk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var rk=yp,Yp=Cp,ok=Tp,sk=Ip,ik=Ep,Xp=Np,ak=Rp,Jp=Mp,Zp=Lp,lk=$p,ck=Bp,Qp=zp,em=Hp,tm=Wp;const nm=rk,rm=ok,pl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Yp,{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,c.jsx(sk,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pl.displayName=Yp.displayName;const om=m.forwardRef(({className:e,...t},n)=>c.jsx(Qp,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));om.displayName=Qp.displayName;const sm=m.forwardRef(({className:e,...t},n)=>c.jsx(em,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));sm.displayName=em.displayName;const ml=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(ik,{children:c.jsxs(Xp,{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:[c.jsx(om,{}),c.jsx(ak,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(sm,{})]})}));ml.displayName=Xp.displayName;const uk=m.forwardRef(({className:e,...t},n)=>c.jsx(Jp,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uk.displayName=Jp.displayName;const wr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Zp,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(ck,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(lk,{children:t})]}));wr.displayName=Zp.displayName;const dk=m.forwardRef(({className:e,...t},n)=>c.jsx(tm,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));dk.displayName=tm.displayName;var fk="Separator",im="horizontal",hk=["horizontal","vertical"],am=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=im,...o}=e,s=pk(r)?r:im,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});am.displayName=fk;function pk(e){return hk.includes(e)}var lm=am;const cm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(lm,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));cm.displayName=lm.displayName;const mk=Vd,gk=Yw,xk=Kd,um=m.forwardRef(({className:e,...t},n)=>c.jsx(Is,{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}));um.displayName=Is.displayName;const vk=Io.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"}}),dm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(xk,{children:[c.jsx(um,{}),c.jsxs(Es,{ref:o,className:ee(vk({side:e}),t),...r,children:[n,c.jsxs(qd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));dm.displayName=Es.displayName;const fm=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});fm.displayName="SheetHeader";const hm=m.forwardRef(({className:e,...t},n)=>c.jsx(hr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));hm.displayName=hr.displayName;const pm=m.forwardRef(({className:e,...t},n)=>c.jsx(Ns,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));pm.displayName=Ns.displayName;const bk={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 wk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=pa();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(bk),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const v=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${v.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(mk,{open:r,onOpenChange:o,children:[c.jsx(gk,{asChild:!0,children:c.jsxs(Je,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(oa,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(dm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(fm,{children:[c.jsx(hm,{children:"Chat Settings"}),c.jsx(pm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(is,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ys,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(v=>({...v,api:{...v.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Je,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Xn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(v=>({...v,api:{...v.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ys,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(v=>({...v,api:{...v.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Je,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ae.EyeOff,{className:"h-4 w-4"}):c.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(is,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(nm,{value:a.ui.layout,onValueChange:g=>l(v=>({...v,ui:{...v.ui,layout:g}})),children:[c.jsx(pl,{children:c.jsx(rm,{})}),c.jsxs(ml,{children:[c.jsx(wr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(wr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(wr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Jt,{htmlFor:"theme",children:"Theme"}),c.jsxs(nm,{value:a.ui.theme,onValueChange:g=>l(v=>({...v,ui:{...v.ui,theme:g}})),children:[c.jsx(pl,{children:c.jsx(rm,{})}),c.jsxs(ml,{children:[c.jsx(wr,{value:"light",children:"Light"}),c.jsx(wr,{value:"dark",children:"Dark"}),c.jsx(wr,{value:"system",children:"System"})]})]})]}),c.jsx(cm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Xn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Xn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Jt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Xn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(is,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Xn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Xn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Jt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Xn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(v=>({...v,behavior:{...v.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Je,{variant:"outline",onClick:p,children:[c.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Je,{variant:"outline",onClick:b,children:"Cancel"}),c.jsxs(Je,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function yk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Wo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Gs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Wo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Gs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Wo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(al,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Gs,{onError:s.onError,enableFileUpload:!0})})]})})}je.ChatApi=fc,je.ChatInterface=Gs,je.ChatProviders=Wo,je.ChatSettings=wk,je.MarkdownContent=da,je.MessageComponent=nf,je.MessageList=_a,je.ThreadManager=al,je.applySettings=IC,je.chatApiClient=Bn,je.default=yk,je.del=dc,je.get=nn,je.getChatToken=lc,je.getCurrentSettings=TC,je.getDefaultApiConfig=lp,je.getDefaultChatSettings=cp,je.onChatTokenChanged=cc,je.post=Si,je.put=uc,je.setChatToken=yi,je.useApi=Ci,je.useChatStream=Nc,je.useMessagesReducer=bc,je.useStream=Mc,je.useThreadState=Uo,je.useThreads=Ho,Object.defineProperties(je,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});