teodor-new-chat-ui 4.1.21 → 4.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Ne,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):(Ne=typeof globalThis<"u"?globalThis:Ne||self,y(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,y,re,Rn,no,Np,Ap,Rs){"use strict";var CC=Object.defineProperty;var TC=(Ne,y,re)=>y in Ne?CC(Ne,y,{enumerable:!0,configurable:!0,writable:!0,value:re}):Ne[y]=re;var Ep=(Ne,y,re)=>TC(Ne,typeof y!="symbol"?y+"":y,re);function $a(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=$a(y),ro=$a(Rs);var Ps={exports:{}},Sr={};/**
1
+ (function(_e,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):(_e=typeof globalThis<"u"?globalThis:_e||self,y(_e.NewChatUI={},_e.React,_e.LucideReact,_e.reactSlot,_e.classVarianceAuthority,_e.clsx,_e.tailwindMerge,_e.ReactDOM))})(this,function(_e,y,oe,On,no,Ap,_p,Rs){"use strict";var CC=Object.defineProperty;var TC=(_e,y,oe)=>y in _e?CC(_e,y,{enumerable:!0,configurable:!0,writable:!0,value:oe}):_e[y]=oe;var Ip=(_e,y,oe)=>TC(_e,typeof y!="symbol"?y+"":y,oe);function $a(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=$a(y),ro=$a(Rs);var Ps={exports:{}},Cr={};/**
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 Fa;function _p(){if(Fa)return Sr;Fa=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 Sr.Fragment=n,Sr.jsx=i,Sr.jsxs=i,Sr}var Cr={};/**
9
+ */var Fa;function jp(){if(Fa)return Cr;Fa=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 Cr.Fragment=n,Cr.jsx=i,Cr.jsxs=i,Cr}var Tr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,36 +14,36 @@
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 Ba;function jp(){return Ba||(Ba=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"),w=Symbol.iterator,v="@@iterator";function g(T){if(T===null||typeof T!="object")return null;var F=w&&T[w]||T[v];return typeof F=="function"?F:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(T){{for(var F=arguments.length,te=new Array(F>1?F-1:0),ye=1;ye<F;ye++)te[ye-1]=arguments[ye];S("error",T,te)}}function S(T,F,te){{var ye=x.ReactDebugCurrentFrame,We=ye.getStackAddendum();We!==""&&(F+="%s",te=te.concat([We]));var Ve=te.map(function(ze){return String(ze)});Ve.unshift("Warning: "+F),Function.prototype.apply.call(console[T],console,Ve)}}var N=!1,C=!1,k=!1,I=!1,A=!1,R;R=Symbol.for("react.module.reference");function P(T){return!!(typeof T=="string"||typeof T=="function"||T===r||T===s||A||T===o||T===u||T===d||I||T===p||N||C||k||typeof T=="object"&&T!==null&&(T.$$typeof===h||T.$$typeof===f||T.$$typeof===i||T.$$typeof===a||T.$$typeof===l||T.$$typeof===R||T.getModuleId!==void 0))}function L(T,F,te){var ye=T.displayName;if(ye)return ye;var We=F.displayName||F.name||"";return We!==""?te+"("+We+")":te}function $(T){return T.displayName||"Context"}function H(T){if(T==null)return null;if(typeof T.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof T=="function")return T.displayName||T.name||null;if(typeof T=="string")return T;switch(T){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 T=="object")switch(T.$$typeof){case a:var F=T;return $(F)+".Consumer";case i:var te=T;return $(te._context)+".Provider";case l:return L(T,T.render,"ForwardRef");case f:var ye=T.displayName||null;return ye!==null?ye:H(T.type)||"Memo";case h:{var We=T,Ve=We._payload,ze=We._init;try{return H(ze(Ve))}catch{return null}}}return null}var M=Object.assign,q=0,V,Y,B,j,G,Z,ge;function de(){}de.__reactDisabledLog=!0;function ee(){{if(q===0){V=console.log,Y=console.info,B=console.warn,j=console.error,G=console.group,Z=console.groupCollapsed,ge=console.groupEnd;var T={configurable:!0,enumerable:!0,value:de,writable:!0};Object.defineProperties(console,{info:T,log:T,warn:T,error:T,group:T,groupCollapsed:T,groupEnd:T})}q++}}function Ae(){{if(q--,q===0){var T={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},T,{value:V}),info:M({},T,{value:Y}),warn:M({},T,{value:B}),error:M({},T,{value:j}),group:M({},T,{value:G}),groupCollapsed:M({},T,{value:Z}),groupEnd:M({},T,{value:ge})})}q<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=x.ReactCurrentDispatcher,K;function D(T,F,te){{if(K===void 0)try{throw Error()}catch(We){var ye=We.stack.trim().match(/\n( *(at )?)/);K=ye&&ye[1]||""}return`
18
- `+K+T}}var J=!1,U;{var fe=typeof WeakMap=="function"?WeakMap:Map;U=new fe}function ue(T,F){if(!T||J)return"";{var te=U.get(T);if(te!==void 0)return te}var ye;J=!0;var We=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ve;Ve=Te.current,Te.current=null,ee();try{if(F){var ze=function(){throw Error()};if(Object.defineProperty(ze.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ze,[])}catch(pn){ye=pn}Reflect.construct(T,[],ze)}else{try{ze.call()}catch(pn){ye=pn}T.call(ze.prototype)}}else{try{throw Error()}catch(pn){ye=pn}T()}}catch(pn){if(pn&&ye&&typeof pn.stack=="string"){for(var De=pn.stack.split(`
19
- `),Ct=ye.stack.split(`
20
- `),ct=De.length-1,dt=Ct.length-1;ct>=1&&dt>=0&&De[ct]!==Ct[dt];)dt--;for(;ct>=1&&dt>=0;ct--,dt--)if(De[ct]!==Ct[dt]){if(ct!==1||dt!==1)do if(ct--,dt--,dt<0||De[ct]!==Ct[dt]){var zt=`
21
- `+De[ct].replace(" at new "," at ");return T.displayName&&zt.includes("<anonymous>")&&(zt=zt.replace("<anonymous>",T.displayName)),typeof T=="function"&&U.set(T,zt),zt}while(ct>=1&&dt>=0);break}}}finally{J=!1,Te.current=Ve,Ae(),Error.prepareStackTrace=We}var yr=T?T.displayName||T.name:"",kp=yr?D(yr):"";return typeof T=="function"&&U.set(T,kp),kp}function $e(T,F,te){return ue(T,!1)}function Ge(T){var F=T.prototype;return!!(F&&F.isReactComponent)}function qe(T,F,te){if(T==null)return"";if(typeof T=="function")return ue(T,Ge(T));if(typeof T=="string")return D(T);switch(T){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case l:return $e(T.render);case f:return qe(T.type,F,te);case h:{var ye=T,We=ye._payload,Ve=ye._init;try{return qe(Ve(We),F,te)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,Oe={},Be=x.ReactDebugCurrentFrame;function Ue(T){if(T){var F=T._owner,te=qe(T.type,T._source,F?F.type:null);Be.setExtraStackFrame(te)}else Be.setExtraStackFrame(null)}function st(T,F,te,ye,We){{var Ve=Function.call.bind(ke);for(var ze in T)if(Ve(T,ze)){var De=void 0;try{if(typeof T[ze]!="function"){var Ct=Error((ye||"React class")+": "+te+" type `"+ze+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof T[ze]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ct.name="Invariant Violation",Ct}De=T[ze](F,ze,ye,te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ct){De=ct}De&&!(De instanceof Error)&&(Ue(We),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ye||"React class",te,ze,typeof De),Ue(null)),De instanceof Error&&!(De.message in Oe)&&(Oe[De.message]=!0,Ue(We),b("Failed %s type: %s",te,De.message),Ue(null))}}}var ot=Array.isArray;function ne(T){return ot(T)}function le(T){{var F=typeof Symbol=="function"&&Symbol.toStringTag,te=F&&T[Symbol.toStringTag]||T.constructor.name||"Object";return te}}function xe(T){try{return Se(T),!1}catch{return!0}}function Se(T){return""+T}function be(T){if(xe(T))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",le(T)),Se(T)}var je=x.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Ye,it;function gt(T){if(ke.call(T,"ref")){var F=Object.getOwnPropertyDescriptor(T,"ref").get;if(F&&F.isReactWarning)return!1}return T.ref!==void 0}function hn(T){if(ke.call(T,"key")){var F=Object.getOwnPropertyDescriptor(T,"key").get;if(F&&F.isReactWarning)return!1}return T.key!==void 0}function Jn(T,F){typeof T.ref=="string"&&je.current}function vr(T,F){{var te=function(){Ye||(Ye=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};te.isReactWarning=!0,Object.defineProperty(T,"key",{get:te,configurable:!0})}}function Zn(T,F){{var te=function(){it||(it=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};te.isReactWarning=!0,Object.defineProperty(T,"ref",{get:te,configurable:!0})}}var Nn=function(T,F,te,ye,We,Ve,ze){var De={$$typeof:t,type:T,key:F,ref:te,props:ze,_owner:Ve};return De._store={},Object.defineProperty(De._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(De,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ye}),Object.defineProperty(De,"_source",{configurable:!1,enumerable:!1,writable:!1,value:We}),Object.freeze&&(Object.freeze(De.props),Object.freeze(De)),De};function Bt(T,F,te,ye,We){{var Ve,ze={},De=null,Ct=null;te!==void 0&&(be(te),De=""+te),hn(F)&&(be(F.key),De=""+F.key),gt(F)&&(Ct=F.ref,Jn(F,We));for(Ve in F)ke.call(F,Ve)&&!Qe.hasOwnProperty(Ve)&&(ze[Ve]=F[Ve]);if(T&&T.defaultProps){var ct=T.defaultProps;for(Ve in ct)ze[Ve]===void 0&&(ze[Ve]=ct[Ve])}if(De||Ct){var dt=typeof T=="function"?T.displayName||T.name||"Unknown":T;De&&vr(ze,dt),Ct&&Zn(ze,dt)}return Nn(T,De,Ct,We,ye,je.current,ze)}}var An=x.ReactCurrentOwner,Qn=x.ReactDebugCurrentFrame;function Yt(T){if(T){var F=T._owner,te=qe(T.type,T._source,F?F.type:null);Qn.setExtraStackFrame(te)}else Qn.setExtraStackFrame(null)}var _n;_n=!1;function jn(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function er(){{if(An.current){var T=H(An.current.type);if(T)return`
17
+ */var Ba;function Rp(){return Ba||(Ba=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"),w=Symbol.iterator,v="@@iterator";function g(T){if(T===null||typeof T!="object")return null;var F=w&&T[w]||T[v];return typeof F=="function"?F:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(T){{for(var F=arguments.length,X=new Array(F>1?F-1:0),he=1;he<F;he++)X[he-1]=arguments[he];S("error",T,X)}}function S(T,F,X){{var he=x.ReactDebugCurrentFrame,Ue=he.getStackAddendum();Ue!==""&&(F+="%s",X=X.concat([Ue]));var Ke=X.map(function(Fe){return String(Fe)});Ke.unshift("Warning: "+F),Function.prototype.apply.call(console[T],console,Ke)}}var E=!1,C=!1,k=!1,I=!1,A=!1,j;j=Symbol.for("react.module.reference");function P(T){return!!(typeof T=="string"||typeof T=="function"||T===r||T===s||A||T===o||T===u||T===d||I||T===p||E||C||k||typeof T=="object"&&T!==null&&(T.$$typeof===h||T.$$typeof===f||T.$$typeof===i||T.$$typeof===a||T.$$typeof===l||T.$$typeof===j||T.getModuleId!==void 0))}function L(T,F,X){var he=T.displayName;if(he)return he;var Ue=F.displayName||F.name||"";return Ue!==""?X+"("+Ue+")":X}function $(T){return T.displayName||"Context"}function H(T){if(T==null)return null;if(typeof T.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof T=="function")return T.displayName||T.name||null;if(typeof T=="string")return T;switch(T){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 T=="object")switch(T.$$typeof){case a:var F=T;return $(F)+".Consumer";case i:var X=T;return $(X._context)+".Provider";case l:return L(T,T.render,"ForwardRef");case f:var he=T.displayName||null;return he!==null?he:H(T.type)||"Memo";case h:{var Ue=T,Ke=Ue._payload,Fe=Ue._init;try{return H(Fe(Ke))}catch{return null}}}return null}var M=Object.assign,K=0,W,G,B,_,q,Q,xe;function ue(){}ue.__reactDisabledLog=!0;function te(){{if(K===0){W=console.log,G=console.info,B=console.warn,_=console.error,q=console.group,Q=console.groupCollapsed,xe=console.groupEnd;var T={configurable:!0,enumerable:!0,value:ue,writable:!0};Object.defineProperties(console,{info:T,log:T,warn:T,error:T,group:T,groupCollapsed:T,groupEnd:T})}K++}}function je(){{if(K--,K===0){var T={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},T,{value:W}),info:M({},T,{value:G}),warn:M({},T,{value:B}),error:M({},T,{value:_}),group:M({},T,{value:q}),groupCollapsed:M({},T,{value:Q}),groupEnd:M({},T,{value:xe})})}K<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=x.ReactCurrentDispatcher,V;function D(T,F,X){{if(V===void 0)try{throw Error()}catch(Ue){var he=Ue.stack.trim().match(/\n( *(at )?)/);V=he&&he[1]||""}return`
18
+ `+V+T}}var J=!1,U;{var de=typeof WeakMap=="function"?WeakMap:Map;U=new de}function ce(T,F){if(!T||J)return"";{var X=U.get(T);if(X!==void 0)return X}var he;J=!0;var Ue=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ke;Ke=Te.current,Te.current=null,te();try{if(F){var Fe=function(){throw Error()};if(Object.defineProperty(Fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Fe,[])}catch(pn){he=pn}Reflect.construct(T,[],Fe)}else{try{Fe.call()}catch(pn){he=pn}T.call(Fe.prototype)}}else{try{throw Error()}catch(pn){he=pn}T()}}catch(pn){if(pn&&he&&typeof pn.stack=="string"){for(var Oe=pn.stack.split(`
19
+ `),bt=he.stack.split(`
20
+ `),it=Oe.length-1,ft=bt.length-1;it>=1&&ft>=0&&Oe[it]!==bt[ft];)ft--;for(;it>=1&&ft>=0;it--,ft--)if(Oe[it]!==bt[ft]){if(it!==1||ft!==1)do if(it--,ft--,ft<0||Oe[it]!==bt[ft]){var zt=`
21
+ `+Oe[it].replace(" at new "," at ");return T.displayName&&zt.includes("<anonymous>")&&(zt=zt.replace("<anonymous>",T.displayName)),typeof T=="function"&&U.set(T,zt),zt}while(it>=1&&ft>=0);break}}}finally{J=!1,Te.current=Ke,je(),Error.prepareStackTrace=Ue}var Sr=T?T.displayName||T.name:"",Ep=Sr?D(Sr):"";return typeof T=="function"&&U.set(T,Ep),Ep}function ze(T,F,X){return ce(T,!1)}function Xe(T){var F=T.prototype;return!!(F&&F.isReactComponent)}function Ge(T,F,X){if(T==null)return"";if(typeof T=="function")return ce(T,Xe(T));if(typeof T=="string")return D(T);switch(T){case u:return D("Suspense");case d:return D("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case l:return ze(T.render);case f:return Ge(T.type,F,X);case h:{var he=T,Ue=he._payload,Ke=he._init;try{return Ge(Ke(Ue),F,X)}catch{}}}return""}var ke=Object.prototype.hasOwnProperty,De={},nt=x.ReactDebugCurrentFrame;function He(T){if(T){var F=T._owner,X=Ge(T.type,T._source,F?F.type:null);nt.setExtraStackFrame(X)}else nt.setExtraStackFrame(null)}function Je(T,F,X,he,Ue){{var Ke=Function.call.bind(ke);for(var Fe in T)if(Ke(T,Fe)){var Oe=void 0;try{if(typeof T[Fe]!="function"){var bt=Error((he||"React class")+": "+X+" type `"+Fe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof T[Fe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw bt.name="Invariant Violation",bt}Oe=T[Fe](F,Fe,he,X,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(it){Oe=it}Oe&&!(Oe instanceof Error)&&(He(Ue),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",he||"React class",X,Fe,typeof Oe),He(null)),Oe instanceof Error&&!(Oe.message in De)&&(De[Oe.message]=!0,He(Ue),b("Failed %s type: %s",X,Oe.message),He(null))}}}var dt=Array.isArray;function ne(T){return dt(T)}function re(T){{var F=typeof Symbol=="function"&&Symbol.toStringTag,X=F&&T[Symbol.toStringTag]||T.constructor.name||"Object";return X}}function ve(T){try{return Ee(T),!1}catch{return!0}}function Ee(T){return""+T}function Se(T){if(ve(T))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",re(T)),Ee(T)}var Ae=x.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Ye,ct;function Ct(T){if(ke.call(T,"ref")){var F=Object.getOwnPropertyDescriptor(T,"ref").get;if(F&&F.isReactWarning)return!1}return T.ref!==void 0}function hn(T){if(ke.call(T,"key")){var F=Object.getOwnPropertyDescriptor(T,"key").get;if(F&&F.isReactWarning)return!1}return T.key!==void 0}function Nn(T,F){typeof T.ref=="string"&&Ae.current}function vr(T,F){{var X=function(){Ye||(Ye=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};X.isReactWarning=!0,Object.defineProperty(T,"key",{get:X,configurable:!0})}}function An(T,F){{var X=function(){ct||(ct=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};X.isReactWarning=!0,Object.defineProperty(T,"ref",{get:X,configurable:!0})}}var _n=function(T,F,X,he,Ue,Ke,Fe){var Oe={$$typeof:t,type:T,key:F,ref:X,props:Fe,_owner:Ke};return Oe._store={},Object.defineProperty(Oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.defineProperty(Oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ue}),Object.freeze&&(Object.freeze(Oe.props),Object.freeze(Oe)),Oe};function wr(T,F,X,he,Ue){{var Ke,Fe={},Oe=null,bt=null;X!==void 0&&(Se(X),Oe=""+X),hn(F)&&(Se(F.key),Oe=""+F.key),Ct(F)&&(bt=F.ref,Nn(F,Ue));for(Ke in F)ke.call(F,Ke)&&!Ze.hasOwnProperty(Ke)&&(Fe[Ke]=F[Ke]);if(T&&T.defaultProps){var it=T.defaultProps;for(Ke in it)Fe[Ke]===void 0&&(Fe[Ke]=it[Ke])}if(Oe||bt){var ft=typeof T=="function"?T.displayName||T.name||"Unknown":T;Oe&&vr(Fe,ft),bt&&An(Fe,ft)}return _n(T,Oe,bt,Ue,he,Ae.current,Fe)}}var jn=x.ReactCurrentOwner,Ot=x.ReactDebugCurrentFrame;function Yt(T){if(T){var F=T._owner,X=Ge(T.type,T._source,F?F.type:null);Ot.setExtraStackFrame(X)}else Ot.setExtraStackFrame(null)}var Rn;Rn=!1;function Pn(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function Qn(){{if(jn.current){var T=H(jn.current.type);if(T)return`
22
22
 
23
- Check the render method of \``+T+"`."}return""}}function wr(T){return""}var br={};function to(T){{var F=er();if(!F){var te=typeof T=="string"?T:T.displayName||T.name;te&&(F=`
23
+ Check the render method of \``+T+"`."}return""}}function br(T){return""}var er={};function yr(T){{var F=Qn();if(!F){var X=typeof T=="string"?T:T.displayName||T.name;X&&(F=`
24
24
 
25
- Check the top-level render call using <`+te+">.")}return F}}function se(T,F){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var te=to(F);if(br[te])return;br[te]=!0;var ye="";T&&T._owner&&T._owner!==An.current&&(ye=" It was passed a child from "+H(T._owner.type)+"."),Yt(T),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,ye),Yt(null)}}function E(T,F){{if(typeof T!="object")return;if(ne(T))for(var te=0;te<T.length;te++){var ye=T[te];jn(ye)&&se(ye,F)}else if(jn(T))T._store&&(T._store.validated=!0);else if(T){var We=g(T);if(typeof We=="function"&&We!==T.entries)for(var Ve=We.call(T),ze;!(ze=Ve.next()).done;)jn(ze.value)&&se(ze.value,F)}}}function _(T){{var F=T.type;if(F==null||typeof F=="string")return;var te;if(typeof F=="function")te=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===l||F.$$typeof===f))te=F.propTypes;else return;if(te){var ye=H(F);st(te,T.props,"prop",ye,T)}else if(F.PropTypes!==void 0&&!_n){_n=!0;var We=H(F);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",We||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function W(T){{for(var F=Object.keys(T.props),te=0;te<F.length;te++){var ye=F[te];if(ye!=="children"&&ye!=="key"){Yt(T),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ye),Yt(null);break}}T.ref!==null&&(Yt(T),b("Invalid attribute `ref` supplied to `React.Fragment`."),Yt(null))}}function ie(T,F,te,ye,We,Ve){{var ze=P(T);if(!ze){var De="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(De+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ct=wr();Ct?De+=Ct:De+=er();var ct;T===null?ct="null":ne(T)?ct="array":T!==void 0&&T.$$typeof===t?(ct="<"+(H(T.type)||"Unknown")+" />",De=" Did you accidentally export a JSX literal instead of a component?"):ct=typeof T,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ct,De)}var dt=Bt(T,F,te,We,Ve);if(dt==null)return dt;if(ze){var zt=F.children;if(zt!==void 0)if(ye)if(ne(zt)){for(var yr=0;yr<zt.length;yr++)E(zt[yr],T);Object.freeze&&Object.freeze(zt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else E(zt,T)}return T===r?W(dt):_(dt),dt}}function pe(T,F,te){return ie(T,F,te,!0)}function he(T,F,te){return ie(T,F,te,!1)}var et=he,ht=pe;Cr.Fragment=r,Cr.jsx=et,Cr.jsxs=ht}()),Cr}process.env.NODE_ENV==="production"?Ps.exports=_p():Ps.exports=jp();var c=Ps.exports;function za(e,t){return function(){return e.apply(t,arguments)}}const{toString:Rp}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:oo,toStringTag:Ha}=Symbol,so=(e=>t=>{const n=Rp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=e=>(e=e.toLowerCase(),t=>so(t)===e),io=e=>t=>typeof t===e,{isArray:tr}=Array,nr=io("undefined");function Tr(e){return e!==null&&!nr(e)&&e.constructor!==null&&!nr(e.constructor)&&Tt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ua=Ht("ArrayBuffer");function Pp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ua(e.buffer),t}const Op=io("string"),Tt=io("function"),Wa=io("number"),kr=e=>e!==null&&typeof e=="object",Mp=e=>e===!0||e===!1,ao=e=>{if(so(e)!=="object")return!1;const t=Os(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ha in e)&&!(oo in e)},Dp=e=>{if(!kr(e)||Tr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Lp=Ht("Date"),$p=Ht("File"),Fp=Ht("Blob"),Bp=Ht("FileList"),zp=e=>kr(e)&&Tt(e.pipe),Hp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Tt(e.append)&&((t=so(e))==="formdata"||t==="object"&&Tt(e.toString)&&e.toString()==="[object FormData]"))},Up=Ht("URLSearchParams"),[Wp,Vp,Kp,qp]=["ReadableStream","Request","Response","Headers"].map(Ht),Gp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Er(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(Tr(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 Va(e,t){if(Tr(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 Pn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ka=e=>!nr(e)&&e!==Pn;function Ms(){const{caseless:e,skipUndefined:t}=Ka(this)&&this||{},n={},r=(o,s)=>{const i=e&&Va(n,s)||s;ao(n[i])&&ao(o)?n[i]=Ms(n[i],o):ao(o)?n[i]=Ms({},o):tr(o)?n[i]=o.slice():(!t||!nr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Er(arguments[o],r);return n}const Yp=(e,t,n,{allOwnKeys:r}={})=>(Er(t,(o,s)=>{n&&Tt(o)?e[s]=za(o,n):e[s]=o},{allOwnKeys:r}),e),Xp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Jp=(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)},Zp=(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&&Os(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Qp=(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},em=e=>{if(!e)return null;if(tr(e))return e;let t=e.length;if(!Wa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},tm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Os(Uint8Array)),nm=(e,t)=>{const r=(e&&e[oo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},rm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},om=Ht("HTMLFormElement"),sm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),qa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),im=Ht("RegExp"),Ga=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Er(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},am=e=>{Ga(e,(t,n)=>{if(Tt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Tt(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+"'")})}})},lm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return tr(e)?r(e):r(String(e).split(t)),n},cm=()=>{},um=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function dm(e){return!!(e&&Tt(e.append)&&e[Ha]==="FormData"&&e[oo])}const fm=e=>{const t=new Array(10),n=(r,o)=>{if(kr(r)){if(t.indexOf(r)>=0)return;if(Tr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=tr(r)?[]:{};return Er(r,(i,a)=>{const l=n(i,o+1);!nr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},hm=Ht("AsyncFunction"),pm=e=>e&&(kr(e)||Tt(e))&&Tt(e.then)&&Tt(e.catch),Ya=((e,t)=>e?setImmediate:t?((n,r)=>(Pn.addEventListener("message",({source:o,data:s})=>{o===Pn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Pn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Tt(Pn.postMessage)),mm=typeof queueMicrotask<"u"?queueMicrotask.bind(Pn):typeof process<"u"&&process.nextTick||Ya,O={isArray:tr,isArrayBuffer:Ua,isBuffer:Tr,isFormData:Hp,isArrayBufferView:Pp,isString:Op,isNumber:Wa,isBoolean:Mp,isObject:kr,isPlainObject:ao,isEmptyObject:Dp,isReadableStream:Wp,isRequest:Vp,isResponse:Kp,isHeaders:qp,isUndefined:nr,isDate:Lp,isFile:$p,isBlob:Fp,isRegExp:im,isFunction:Tt,isStream:zp,isURLSearchParams:Up,isTypedArray:tm,isFileList:Bp,forEach:Er,merge:Ms,extend:Yp,trim:Gp,stripBOM:Xp,inherits:Jp,toFlatObject:Zp,kindOf:so,kindOfTest:Ht,endsWith:Qp,toArray:em,forEachEntry:nm,matchAll:rm,isHTMLForm:om,hasOwnProperty:qa,hasOwnProp:qa,reduceDescriptors:Ga,freezeMethods:am,toObjectSet:lm,toCamelCase:sm,noop:cm,toFiniteNumber:um,findKey:Va,global:Pn,isContextDefined:Ka,isSpecCompliantForm:dm,toJSONObject:fm,isAsyncFn:hm,isThenable:pm,setImmediate:Ya,asap:mm,isIterable:e=>e!=null&&Tt(e[oo])};function Re(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const Xa=Re.prototype,Ja={};["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=>{Ja[e]={value:e}}),Object.defineProperties(Re,Ja),Object.defineProperty(Xa,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(Xa);O.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 Re.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const gm=null;function Ds(e){return O.isPlainObject(e)||O.isArray(e)}function Za(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Qa(e,t,n){return e?e.concat(t).map(function(o,s){return o=Za(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function xm(e){return O.isArray(e)&&!e.some(Ds)}const vm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function lo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!O.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(O.isDate(w))return w.toISOString();if(O.isBoolean(w))return w.toString();if(!l&&O.isBlob(w))throw new Re("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(w)||O.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(O.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(O.isArray(w)&&xm(w)||(O.isFileList(w)||O.endsWith(v,"[]"))&&(x=O.toArray(w)))return v=Za(v),x.forEach(function(S,N){!(O.isUndefined(S)||S===null)&&t.append(i===!0?Qa([v],N,s):i===null?v:v+"[]",u(S))}),!1}return Ds(w)?!0:(t.append(Qa(g,v,s),u(w)),!1)}const f=[],h=Object.assign(vm,{defaultVisitor:d,convertValue:u,isVisitable:Ds});function p(w,v){if(!O.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),O.forEach(w,function(x,b){(!(O.isUndefined(x)||x===null)&&o.call(t,x,O.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function el(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ls(e,t){this._pairs=[],e&&lo(e,this,t)}const tl=Ls.prototype;tl.append=function(t,n){this._pairs.push([t,n])},tl.toString=function(t){const n=t?function(r){return t.call(this,r,el)}:el;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function wm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function nl(e,t,n){if(!t)return e;const r=n&&n.encode||wm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new Ls(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class rl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ol={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ls,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},$s=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,ym=$s&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),Sm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Cm=$s&&window.location.href||"http://localhost",xt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:$s,hasStandardBrowserEnv:ym,hasStandardBrowserWebWorkerEnv:Sm,navigator:Fs,origin:Cm},Symbol.toStringTag,{value:"Module"})),...bm};function Tm(e,t){return lo(e,new xt.classes.URLSearchParams,{visitor:function(n,r,o,s){return xt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function km(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Em(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 sl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Em(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(km(r),o,n,0)}),n}return null}function Im(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ir={transitional:ol,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(sl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Tm(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Im(t)):t}],transformResponse:[function(t){const n=this.transitional||Ir.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Re.from(a,Re.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:xt.classes.FormData,Blob:xt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Ir.headers[e]={}});const Nm=O.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Am=e=>{const t={};let n,r,o;return e&&e.split(`
26
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Nm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},il=Symbol("internals");function Nr(e){return e&&String(e).trim().toLowerCase()}function co(e){return e===!1||e==null?e:O.isArray(e)?e.map(co):String(e)}function _m(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const jm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Bs(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Rm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Pm(e,t){const n=O.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let kt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Nr(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=co(a))}const i=(a,l)=>O.forEach(a,(u,d)=>s(u,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!jm(t))i(Am(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,u;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Nr(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return _m(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Nr(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Bs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Nr(i),i){const a=O.findKey(r,i);a&&(!n||Bs(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Bs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=co(o),delete n[s];return}const a=t?Rm(s):String(s).trim();a!==s&&delete n[s],n[a]=co(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
27
- `)}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[il]=this[il]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Nr(i);r[a]||(Pm(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};kt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(kt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(kt);function zs(e,t){const n=this||Ir,r=t||n,o=kt.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function al(e){return!!(e&&e.__CANCEL__)}function rr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(rr,Re,{__CANCEL__:!0});function ll(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Om(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Mm(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 Dm(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 uo=(e,t,n=3)=>{let r=0;const o=Mm(50,250);return Dm(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)},cl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ul=e=>(...t)=>O.asap(()=>e(...t)),Lm=xt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,xt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(xt.origin),xt.navigator&&/(msie|trident)/i.test(xt.navigator.userAgent)):()=>!0,$m=xt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Fm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Bm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function dl(e,t,n){let r=!Fm(t);return e&&(r||n==!1)?Bm(e,t):t}const fl=e=>e instanceof kt?{...e}:e;function On(e,t){t=t||{};const n={};function r(u,d,f,h){return O.isPlainObject(u)&&O.isPlainObject(d)?O.merge.call({caseless:h},u,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(u,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!O.isUndefined(d))return r(void 0,d)}function i(u,d){if(O.isUndefined(d)){if(!O.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(fl(u),fl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const hl=e=>{const t=On({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=kt.from(i),t.url=nl(dl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(xt.hasStandardBrowserEnv||xt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.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(xt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&Lm(t.url))){const l=o&&s&&$m.read(s);l&&i.set(o,l)}return t},zm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=hl(e);let s=o.data;const i=kt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),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 x(){if(!g)return;const S=kt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};ll(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Re("Request aborted",Re.ECONNABORTED,e,g)),g=null)},g.onerror=function(N){const C=N&&N.message?N.message:"Network Error",k=new Re(C,Re.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 C=o.transitional||ol;o.timeoutErrorMessage&&(N=o.timeoutErrorMessage),r(new Re(N,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&O.forEach(i.toJSON(),function(N,C){g.setRequestHeader(C,N)}),O.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=uo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=uo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new rr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Om(o.url);if(b&&xt.protocols.indexOf(b)===-1){r(new Re("Unsupported protocol "+b+":",Re.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Hm=(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 Re?d:new rr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(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=()=>O.asap(a),l}},Um=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},Wm=async function*(e,t){for await(const n of Vm(e))yield*Um(n,t)},Vm=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()}},pl=(e,t,n,r)=>{const o=Wm(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})},ml=64*1024,{isFunction:fo}=O,Km=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:gl,TextEncoder:xl}=O.global,vl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},qm=e=>{e=O.merge.call({skipUndefined:!0},Km,e);const{fetch:t,Request:n,Response:r}=e,o=t?fo(t):typeof fetch=="function",s=fo(n),i=fo(r);if(!o)return!1;const a=o&&fo(gl),l=o&&(typeof xl=="function"?(w=>v=>w.encode(v))(new xl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&vl(()=>{let w=!1;const v=new n(xt.origin,{body:new gl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&vl(()=>O.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Re(`Response type '${w}' is not supported`,Re.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(O.isBlob(w))return w.size;if(O.isSpecCompliantForm(w))return(await new n(xt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(O.isArrayBufferView(w)||O.isArrayBuffer(w))return w.byteLength;if(O.isURLSearchParams(w)&&(w=w+""),O.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=O.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:N,onDownloadProgress:C,onUploadProgress:k,responseType:I,headers:A,withCredentials:R="same-origin",fetchOptions:P}=hl(w),L=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Hm([b,S&&S.toAbortSignal()],N),H=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let q;try{if(k&&u&&g!=="get"&&g!=="head"&&(q=await p(A,x))!==0){let Z=new n(v,{method:"POST",body:x,duplex:"half"}),ge;if(O.isFormData(x)&&(ge=Z.headers.get("content-type"))&&A.setContentType(ge),Z.body){const[de,ee]=cl(q,uo(ul(k)));x=pl(Z.body,ml,de,ee)}}O.isString(R)||(R=R?"include":"omit");const V=s&&"credentials"in n.prototype,Y={...P,signal:$,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:V?R:void 0};H=s&&new n(v,Y);let B=await(s?L(H,P):L(v,Y));const j=d&&(I==="stream"||I==="response");if(d&&(C||j&&M)){const Z={};["status","statusText","headers"].forEach(Ae=>{Z[Ae]=B[Ae]});const ge=O.toFiniteNumber(B.headers.get("content-length")),[de,ee]=C&&cl(ge,uo(ul(C),!0))||[];B=new r(pl(B.body,ml,de,()=>{ee&&ee(),M&&M()}),Z)}I=I||"text";let G=await f[O.findKey(f,I)||"text"](B,w);return!j&&M&&M(),await new Promise((Z,ge)=>{ll(Z,ge,{data:G,headers:kt.from(B.headers),status:B.status,statusText:B.statusText,config:w,request:H})})}catch(V){throw M&&M(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,w,H),{cause:V.cause||V}):Re.from(V,V&&V.code,w,H)}}},Gm=new Map,wl=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=Gm;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:qm(t)),d=u;return u};wl();const Hs={http:gm,xhr:zm,fetch:{get:wl}};O.forEach(Hs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bl=e=>`- ${e}`,Ym=e=>O.isFunction(e)||e===null||e===!1,yl={getAdapter:(e,t)=>{e=O.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Ym(r)&&(o=Hs[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
25
+ Check the top-level render call using <`+X+">.")}return F}}function ie(T,F){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var X=yr(F);if(er[X])return;er[X]=!0;var he="";T&&T._owner&&T._owner!==jn.current&&(he=" It was passed a child from "+H(T._owner.type)+"."),Yt(T),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',X,he),Yt(null)}}function ye(T,F){{if(typeof T!="object")return;if(ne(T))for(var X=0;X<T.length;X++){var he=T[X];Pn(he)&&ie(he,F)}else if(Pn(T))T._store&&(T._store.validated=!0);else if(T){var Ue=g(T);if(typeof Ue=="function"&&Ue!==T.entries)for(var Ke=Ue.call(T),Fe;!(Fe=Ke.next()).done;)Pn(Fe.value)&&ie(Fe.value,F)}}}function $e(T){{var F=T.type;if(F==null||typeof F=="string")return;var X;if(typeof F=="function")X=F.propTypes;else if(typeof F=="object"&&(F.$$typeof===l||F.$$typeof===f))X=F.propTypes;else return;if(X){var he=H(F);Je(X,T.props,"prop",he,T)}else if(F.PropTypes!==void 0&&!Rn){Rn=!0;var Ue=H(F);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ue||"Unknown")}typeof F.getDefaultProps=="function"&&!F.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function N(T){{for(var F=Object.keys(T.props),X=0;X<F.length;X++){var he=F[X];if(he!=="children"&&he!=="key"){Yt(T),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",he),Yt(null);break}}T.ref!==null&&(Yt(T),b("Invalid attribute `ref` supplied to `React.Fragment`."),Yt(null))}}function R(T,F,X,he,Ue,Ke){{var Fe=P(T);if(!Fe){var Oe="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(Oe+=" 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 bt=br();bt?Oe+=bt:Oe+=Qn();var it;T===null?it="null":ne(T)?it="array":T!==void 0&&T.$$typeof===t?(it="<"+(H(T.type)||"Unknown")+" />",Oe=" Did you accidentally export a JSX literal instead of a component?"):it=typeof T,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",it,Oe)}var ft=wr(T,F,X,Ue,Ke);if(ft==null)return ft;if(Fe){var zt=F.children;if(zt!==void 0)if(he)if(ne(zt)){for(var Sr=0;Sr<zt.length;Sr++)ye(zt[Sr],T);Object.freeze&&Object.freeze(zt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ye(zt,T)}return T===r?N(ft):$e(ft),ft}}function Z(T,F,X){return R(T,F,X,!0)}function pe(T,F,X){return R(T,F,X,!1)}var ge=pe,fe=Z;Tr.Fragment=r,Tr.jsx=ge,Tr.jsxs=fe}()),Tr}process.env.NODE_ENV==="production"?Ps.exports=jp():Ps.exports=Rp();var c=Ps.exports;function za(e,t){return function(){return e.apply(t,arguments)}}const{toString:Pp}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:oo,toStringTag:Ha}=Symbol,so=(e=>t=>{const n=Pp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ht=e=>(e=e.toLowerCase(),t=>so(t)===e),io=e=>t=>typeof t===e,{isArray:tr}=Array,nr=io("undefined");function kr(e){return e!==null&&!nr(e)&&e.constructor!==null&&!nr(e.constructor)&&Tt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ua=Ht("ArrayBuffer");function Op(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ua(e.buffer),t}const Mp=io("string"),Tt=io("function"),Wa=io("number"),Er=e=>e!==null&&typeof e=="object",Dp=e=>e===!0||e===!1,ao=e=>{if(so(e)!=="object")return!1;const t=Os(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ha in e)&&!(oo in e)},Lp=e=>{if(!Er(e)||kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},$p=Ht("Date"),Fp=Ht("File"),Bp=Ht("Blob"),zp=Ht("FileList"),Hp=e=>Er(e)&&Tt(e.pipe),Up=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Tt(e.append)&&((t=so(e))==="formdata"||t==="object"&&Tt(e.toString)&&e.toString()==="[object FormData]"))},Wp=Ht("URLSearchParams"),[Vp,Kp,qp,Gp]=["ReadableStream","Request","Response","Headers"].map(Ht),Yp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ir(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 Va(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 Mn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ka=e=>!nr(e)&&e!==Mn;function Ms(){const{caseless:e,skipUndefined:t}=Ka(this)&&this||{},n={},r=(o,s)=>{const i=e&&Va(n,s)||s;ao(n[i])&&ao(o)?n[i]=Ms(n[i],o):ao(o)?n[i]=Ms({},o):tr(o)?n[i]=o.slice():(!t||!nr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Ir(arguments[o],r);return n}const Xp=(e,t,n,{allOwnKeys:r}={})=>(Ir(t,(o,s)=>{n&&Tt(o)?e[s]=za(o,n):e[s]=o},{allOwnKeys:r}),e),Jp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zp=(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)},Qp=(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&&Os(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},em=(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},tm=e=>{if(!e)return null;if(tr(e))return e;let t=e.length;if(!Wa(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},nm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Os(Uint8Array)),rm=(e,t)=>{const r=(e&&e[oo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},om=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sm=Ht("HTMLFormElement"),im=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),qa=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),am=Ht("RegExp"),Ga=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Ir(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},lm=e=>{Ga(e,(t,n)=>{if(Tt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Tt(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+"'")})}})},cm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return tr(e)?r(e):r(String(e).split(t)),n},um=()=>{},dm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fm(e){return!!(e&&Tt(e.append)&&e[Ha]==="FormData"&&e[oo])}const hm=e=>{const t=new Array(10),n=(r,o)=>{if(Er(r)){if(t.indexOf(r)>=0)return;if(kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=tr(r)?[]:{};return Ir(r,(i,a)=>{const l=n(i,o+1);!nr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},pm=Ht("AsyncFunction"),mm=e=>e&&(Er(e)||Tt(e))&&Tt(e.then)&&Tt(e.catch),Ya=((e,t)=>e?setImmediate:t?((n,r)=>(Mn.addEventListener("message",({source:o,data:s})=>{o===Mn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Mn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Tt(Mn.postMessage)),gm=typeof queueMicrotask<"u"?queueMicrotask.bind(Mn):typeof process<"u"&&process.nextTick||Ya,O={isArray:tr,isArrayBuffer:Ua,isBuffer:kr,isFormData:Up,isArrayBufferView:Op,isString:Mp,isNumber:Wa,isBoolean:Dp,isObject:Er,isPlainObject:ao,isEmptyObject:Lp,isReadableStream:Vp,isRequest:Kp,isResponse:qp,isHeaders:Gp,isUndefined:nr,isDate:$p,isFile:Fp,isBlob:Bp,isRegExp:am,isFunction:Tt,isStream:Hp,isURLSearchParams:Wp,isTypedArray:nm,isFileList:zp,forEach:Ir,merge:Ms,extend:Xp,trim:Yp,stripBOM:Jp,inherits:Zp,toFlatObject:Qp,kindOf:so,kindOfTest:Ht,endsWith:em,toArray:tm,forEachEntry:rm,matchAll:om,isHTMLForm:sm,hasOwnProperty:qa,hasOwnProp:qa,reduceDescriptors:Ga,freezeMethods:lm,toObjectSet:cm,toCamelCase:im,noop:um,toFiniteNumber:dm,findKey:Va,global:Mn,isContextDefined:Ka,isSpecCompliantForm:fm,toJSONObject:hm,isAsyncFn:pm,isThenable:mm,setImmediate:Ya,asap:gm,isIterable:e=>e!=null&&Tt(e[oo])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}O.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:O.toJSONObject(this.config),code:this.code,status:this.status}}});const Xa=Pe.prototype,Ja={};["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=>{Ja[e]={value:e}}),Object.defineProperties(Pe,Ja),Object.defineProperty(Xa,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(Xa);O.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 Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const xm=null;function Ds(e){return O.isPlainObject(e)||O.isArray(e)}function Za(e){return O.endsWith(e,"[]")?e.slice(0,-2):e}function Qa(e,t,n){return e?e.concat(t).map(function(o,s){return o=Za(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function vm(e){return O.isArray(e)&&!e.some(Ds)}const wm=O.toFlatObject(O,{},null,function(t){return/^is[A-Z]/.test(t)});function lo(e,t,n){if(!O.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=O.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!O.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&O.isSpecCompliantForm(t);if(!O.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(O.isDate(w))return w.toISOString();if(O.isBoolean(w))return w.toString();if(!l&&O.isBlob(w))throw new Pe("Blob is not supported. Use a Buffer instead.");return O.isArrayBuffer(w)||O.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(O.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(O.isArray(w)&&vm(w)||(O.isFileList(w)||O.endsWith(v,"[]"))&&(x=O.toArray(w)))return v=Za(v),x.forEach(function(S,E){!(O.isUndefined(S)||S===null)&&t.append(i===!0?Qa([v],E,s):i===null?v:v+"[]",u(S))}),!1}return Ds(w)?!0:(t.append(Qa(g,v,s),u(w)),!1)}const f=[],h=Object.assign(wm,{defaultVisitor:d,convertValue:u,isVisitable:Ds});function p(w,v){if(!O.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),O.forEach(w,function(x,b){(!(O.isUndefined(x)||x===null)&&o.call(t,x,O.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!O.isObject(e))throw new TypeError("data must be an object");return p(e),t}function el(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ls(e,t){this._pairs=[],e&&lo(e,this,t)}const tl=Ls.prototype;tl.append=function(t,n){this._pairs.push([t,n])},tl.toString=function(t){const n=t?function(r){return t.call(this,r,el)}:el;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function bm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function nl(e,t,n){if(!t)return e;const r=n&&n.encode||bm;O.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=O.isURLSearchParams(t)?t.toString():new Ls(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class rl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){O.forEach(this.handlers,function(r){r!==null&&t(r)})}}const ol={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ym={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ls,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},$s=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,Sm=$s&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),Cm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tm=$s&&window.location.href||"http://localhost",gt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:$s,hasStandardBrowserEnv:Sm,hasStandardBrowserWebWorkerEnv:Cm,navigator:Fs,origin:Tm},Symbol.toStringTag,{value:"Module"})),...ym};function km(e,t){return lo(e,new gt.classes.URLSearchParams,{visitor:function(n,r,o,s){return gt.isNode&&O.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Em(e){return O.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Im(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 sl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&O.isArray(o)?o.length:i,l?(O.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!O.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&O.isArray(o[i])&&(o[i]=Im(o[i])),!a)}if(O.isFormData(e)&&O.isFunction(e.entries)){const n={};return O.forEachEntry(e,(r,o)=>{t(Em(r),o,n,0)}),n}return null}function Nm(e,t,n){if(O.isString(e))try{return(t||JSON.parse)(e),O.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Nr={transitional:ol,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=O.isObject(t);if(s&&O.isHTMLForm(t)&&(t=new FormData(t)),O.isFormData(t))return o?JSON.stringify(sl(t)):t;if(O.isArrayBuffer(t)||O.isBuffer(t)||O.isStream(t)||O.isFile(t)||O.isBlob(t)||O.isReadableStream(t))return t;if(O.isArrayBufferView(t))return t.buffer;if(O.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return km(t,this.formSerializer).toString();if((a=O.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Nm(t)):t}],transformResponse:[function(t){const n=this.transitional||Nr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(O.isResponse(t)||O.isReadableStream(t))return t;if(t&&O.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};O.forEach(["delete","get","head","post","put","patch"],e=>{Nr.headers[e]={}});const Am=O.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_m=e=>{const t={};let n,r,o;return e&&e.split(`
26
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Am[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},il=Symbol("internals");function Ar(e){return e&&String(e).trim().toLowerCase()}function co(e){return e===!1||e==null?e:O.isArray(e)?e.map(co):String(e)}function jm(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 Rm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Bs(e,t,n,r,o){if(O.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!O.isString(t)){if(O.isString(r))return t.indexOf(r)!==-1;if(O.isRegExp(r))return r.test(t)}}function Pm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Om(e,t){const n=O.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let kt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Ar(l);if(!d)throw new Error("header name must be a non-empty string");const f=O.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=co(a))}const i=(a,l)=>O.forEach(a,(u,d)=>s(u,d,l));if(O.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(O.isString(t)&&(t=t.trim())&&!Rm(t))i(_m(t),n);else if(O.isObject(t)&&O.isIterable(t)){let a={},l,u;for(const d of t){if(!O.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?O.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Ar(t),t){const r=O.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return jm(o);if(O.isFunction(n))return n.call(this,o,r);if(O.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ar(t),t){const r=O.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Bs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Ar(i),i){const a=O.findKey(r,i);a&&(!n||Bs(r,r[a],a,n))&&(delete r[a],o=!0)}}return O.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Bs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return O.forEach(this,(o,s)=>{const i=O.findKey(r,s);if(i){n[i]=co(o),delete n[s];return}const a=t?Pm(s):String(s).trim();a!==s&&delete n[s],n[a]=co(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return O.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&O.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
27
+ `)}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[il]=this[il]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ar(i);r[a]||(Om(o,i),r[a]=!0)}return O.isArray(t)?t.forEach(s):s(t),this}};kt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),O.reduceDescriptors(kt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),O.freezeMethods(kt);function zs(e,t){const n=this||Nr,r=t||n,o=kt.from(r.headers);let s=r.data;return O.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function al(e){return!!(e&&e.__CANCEL__)}function rr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}O.inherits(rr,Pe,{__CANCEL__:!0});function ll(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Mm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dm(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 Lm(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 uo=(e,t,n=3)=>{let r=0;const o=Dm(50,250);return Lm(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)},cl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ul=e=>(...t)=>O.asap(()=>e(...t)),$m=gt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,gt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(gt.origin),gt.navigator&&/(msie|trident)/i.test(gt.navigator.userAgent)):()=>!0,Fm=gt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];O.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),O.isString(r)&&i.push("path="+r),O.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Bm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function dl(e,t,n){let r=!Bm(t);return e&&(r||n==!1)?zm(e,t):t}const fl=e=>e instanceof kt?{...e}:e;function Dn(e,t){t=t||{};const n={};function r(u,d,f,h){return O.isPlainObject(u)&&O.isPlainObject(d)?O.merge.call({caseless:h},u,d):O.isPlainObject(d)?O.merge({},d):O.isArray(d)?d.slice():d}function o(u,d,f,h){if(O.isUndefined(d)){if(!O.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!O.isUndefined(d))return r(void 0,d)}function i(u,d){if(O.isUndefined(d)){if(!O.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(fl(u),fl(d),f,!0)};return O.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);O.isUndefined(h)&&f!==a||(n[d]=h)}),n}const hl=e=>{const t=Dn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=kt.from(i),t.url=nl(dl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),O.isFormData(n)){if(gt.hasStandardBrowserEnv||gt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(O.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(gt.hasStandardBrowserEnv&&(r&&O.isFunction(r)&&(r=r(t)),r||r!==!1&&$m(t.url))){const l=o&&s&&Fm.read(s);l&&i.set(o,l)}return t},Hm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=hl(e);let s=o.data;const i=kt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),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 x(){if(!g)return;const S=kt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};ll(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",k=new Pe(C,Pe.ERR_NETWORK,e,g);k.event=E||null,r(k),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||ol;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Pe(E,C.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&O.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),O.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=uo(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=uo(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new rr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Mm(o.url);if(b&&gt.protocols.indexOf(b)===-1){r(new Pe("Unsupported protocol "+b+":",Pe.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Um=(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 Pe?d:new rr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(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=()=>O.asap(a),l}},Wm=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},Vm=async function*(e,t){for await(const n of Km(e))yield*Wm(n,t)},Km=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()}},pl=(e,t,n,r)=>{const o=Vm(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})},ml=64*1024,{isFunction:fo}=O,qm=(({Request:e,Response:t})=>({Request:e,Response:t}))(O.global),{ReadableStream:gl,TextEncoder:xl}=O.global,vl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gm=e=>{e=O.merge.call({skipUndefined:!0},qm,e);const{fetch:t,Request:n,Response:r}=e,o=t?fo(t):typeof fetch=="function",s=fo(n),i=fo(r);if(!o)return!1;const a=o&&fo(gl),l=o&&(typeof xl=="function"?(w=>v=>w.encode(v))(new xl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&vl(()=>{let w=!1;const v=new n(gt.origin,{body:new gl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&vl(()=>O.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Pe(`Response type '${w}' is not supported`,Pe.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(O.isBlob(w))return w.size;if(O.isSpecCompliantForm(w))return(await new n(gt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(O.isArrayBufferView(w)||O.isArrayBuffer(w))return w.byteLength;if(O.isURLSearchParams(w)&&(w=w+""),O.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=O.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:k,responseType:I,headers:A,withCredentials:j="same-origin",fetchOptions:P}=hl(w),L=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Um([b,S&&S.toAbortSignal()],E),H=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let K;try{if(k&&u&&g!=="get"&&g!=="head"&&(K=await p(A,x))!==0){let Q=new n(v,{method:"POST",body:x,duplex:"half"}),xe;if(O.isFormData(x)&&(xe=Q.headers.get("content-type"))&&A.setContentType(xe),Q.body){const[ue,te]=cl(K,uo(ul(k)));x=pl(Q.body,ml,ue,te)}}O.isString(j)||(j=j?"include":"omit");const W=s&&"credentials"in n.prototype,G={...P,signal:$,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:W?j:void 0};H=s&&new n(v,G);let B=await(s?L(H,P):L(v,G));const _=d&&(I==="stream"||I==="response");if(d&&(C||_&&M)){const Q={};["status","statusText","headers"].forEach(je=>{Q[je]=B[je]});const xe=O.toFiniteNumber(B.headers.get("content-length")),[ue,te]=C&&cl(xe,uo(ul(C),!0))||[];B=new r(pl(B.body,ml,ue,()=>{te&&te(),M&&M()}),Q)}I=I||"text";let q=await f[O.findKey(f,I)||"text"](B,w);return!_&&M&&M(),await new Promise((Q,xe)=>{ll(Q,xe,{data:q,headers:kt.from(B.headers),status:B.status,statusText:B.statusText,config:w,request:H})})}catch(W){throw M&&M(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,w,H),{cause:W.cause||W}):Pe.from(W,W&&W.code,w,H)}}},Ym=new Map,wl=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=Ym;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Gm(t)),d=u;return u};wl();const Hs={http:xm,xhr:Hm,fetch:{get:wl}};O.forEach(Hs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const bl=e=>`- ${e}`,Xm=e=>O.isFunction(e)||e===null||e===!1,yl={getAdapter:(e,t)=>{e=O.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Xm(r)&&(o=Hs[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(O.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
28
28
  `+i.map(bl).join(`
29
- `):" "+bl(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Hs};function Us(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rr(null,e)}function Sl(e){return Us(e),e.headers=kt.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yl.getAdapter(e.adapter||Ir.adapter,e)(e).then(function(r){return Us(e),r.data=zs.call(e,e.transformResponse,r),r.headers=kt.from(r.headers),r},function(r){return al(r)||(Us(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=kt.from(r.response.headers))),Promise.reject(r)})}const Cl="1.12.2",ho={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ho[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Tl={};ho.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Cl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!Tl[i]&&(Tl[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}},ho.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xm(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const po={assertOptions:Xm,validators:ho},Xt=po.validators;let Mn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new rl,response:new rl}}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+=`
30
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=On(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&po.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:po.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),po.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=kt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[Sl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=Sl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=On(this.defaults,t);const n=dl(t.baseURL,t.url,t.allowAbsoluteUrls);return nl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Mn.prototype[t]=function(n,r){return this.request(On(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(On(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Mn.prototype[t]=n(),Mn.prototype[t+"Form"]=n(!0)});let Jm=class Ip{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 rr(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 Ip(function(o){t=o}),cancel:t}}};function Zm(e){return function(n){return e.apply(null,n)}}function Qm(e){return O.isObject(e)&&e.isAxiosError===!0}const Ws={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(Ws).forEach(([e,t])=>{Ws[t]=e});function kl(e){const t=new Mn(e),n=za(Mn.prototype.request,t);return O.extend(n,Mn.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return kl(On(e,o))},n}const at=kl(Ir);at.Axios=Mn,at.CanceledError=rr,at.CancelToken=Jm,at.isCancel=al,at.VERSION=Cl,at.toFormData=lo,at.AxiosError=Re,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Zm,at.isAxiosError=Qm,at.mergeConfig=On,at.AxiosHeaders=kt,at.formToJSON=e=>sl(O.isHTMLForm(e)?new FormData(e):e),at.getAdapter=yl.getAdapter,at.HttpStatusCode=Ws,at.default=at;const{Axios:jC,AxiosError:RC,CanceledError:PC,isCancel:OC,CancelToken:MC,VERSION:DC,all:LC,Cancel:$C,isAxiosError:FC,spread:BC,toFormData:zC,AxiosHeaders:HC,HttpStatusCode:UC,formToJSON:WC,getAdapter:VC,mergeConfig:KC}=at,El=typeof window<"u"?window.__API_BASE_URL__:void 0,Il=El?cn(El):void 0;function cn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let mo=null;const Vs=new Set;function Nl(){return mo}function Ks(e){mo=e,Vs.forEach(t=>t(e))}function Al(e){return Vs.add(e),()=>Vs.delete(e)}const Ot=at.create({...Il?{baseURL:Il}:{},timeout:3e4,withCredentials:!0});Ot.interceptors.request.use(e=>(mo&&(e.headers.Authorization=`Bearer ${mo}`),e)),Ot.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Ot.defaults.baseURL?(await Ot.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qs(e,t,n){return Ot.defaults.baseURL?(await Ot.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function _l(e,t,n){return Ot.defaults.baseURL?(await Ot.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function jl(e,t){return Ot.defaults.baseURL?(await Ot.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Rl{get baseUrl(){const t=Ot.defaults.baseURL;return t?cn(String(t)):""}updateConfig(t){t.baseUrl&&(Ot.defaults.baseURL=cn(String(t.baseUrl))),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return Nl()}setAuthToken(t){Ks(t)}onTokenChange(t){return Al(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qs("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await _l(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await jl(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/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 Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await qs("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const mn=new Rl,Pl=y.createContext(null);function eg({children:e,apiConfig:t}){const n=mn;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(Pl.Provider,{value:r,children:e})}function Gs(){const e=y.useContext(Pl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function tg(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function ng(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 rg(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await ng(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function og(e){return e.type!=="thread_info"&&e.type!=="token"}const sg={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function ig(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:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId: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=Ys(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 Ml(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ml(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 Ol(e=[]){const[t,n]=y.useReducer(ig,{...sg,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 Ml(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=fg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Xs(e.messages);return o?{...e,messages:Js(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Xs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Js(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=dg(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Xs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Js(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ys(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 ag(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lg(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 Js(e,t,n){return lg(e,t,r=>({...r,content:cg(r.content,n)}))}function cg(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"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.includes(s))continue;const l=ug(a,s);l?i.text=a+l:i.text=a+s}else n.push({type:"text",text:s})}else n.push(r);return n}function ug(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function dg(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 ag(e,r,s)}return e}function fg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Dl(e={}){const t=y.useMemo(()=>cn(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,w]=y.useState(null),[v,g]=y.useState(0),[x,b]=y.useState(!1),S=y.useRef(null),N=y.useRef(!0),C=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),I=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),w(null),d(null)},[]),R=y.useCallback((P,L,$)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const H=new AbortController;return S.current=H,(async()=>{var q,V,Y,B,j,G,Z,ge;const M=de=>{var ee;try{const Ae=JSON.parse(JSON.stringify(de));return(ee=Ae==null?void 0:Ae.payload)!=null&&ee.files_info&&Array.isArray(Ae.payload.files_info)&&(Ae.payload.files_info=Ae.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),Ae}catch{return de}};try{let de={};try{if(r)de={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,Be=((q=window.localStorage)==null?void 0:q.getItem("authToken"))||null;let Ue=null;try{const ot=(V=window.localStorage)==null?void 0:V.getItem("chat-settings");ot&&(Ue=((Y=JSON.parse(ot))==null?void 0:Y.apiKey)||null)}catch{}const st=Oe||Be||Ue||null;st&&(de={Authorization:`Bearer ${st}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const ee=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...de,...s.current},body:JSON.stringify(P),signal:H.signal,credentials:i});if(!ee.ok||!ee.body){const ke=await ee.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",ee.status,ke==null?void 0:ke.slice(0,500)),new Error(`stream ${ee.status}${ke?": "+ke:""}`)}b(!0);const Ae=ee.body.getReader(),Te=new TextDecoder;let K="",D=[];C.current=0,g(0);let J=0,U=null;const fe=()=>{if(D.length){const ke=D.join("");D=[],N.current&&h(Oe=>Oe+ke)}U=null},ue=()=>{typeof window<"u"&&U==null&&(U=requestAnimationFrame(fe))};let $e=Date.now();const Ge=setInterval(()=>{var ke;if(Date.now()-$e>6e4){const Oe="Stream idle timeout";d(Oe),H.abort(),(ke=$==null?void 0:$.onError)==null||ke.call($,Oe)}},5e3),qe=1024*1024;try{const ke=ee.headers.get("X-Thread-Id")||ee.headers.get("x-thread-id"),Oe=ee.headers.get("X-Thread-Created")||ee.headers.get("x-thread-created"),Be=ke??null,Ue=String(Oe??"").toLowerCase()==="true";for((B=$==null?void 0:$.onOpen)==null||B.call($,{threadId:Be,created:Ue});;){const{value:st,done:ot}=await Ae.read();if(ot)break;K+=Te.decode(st,{stream:!0}),K.length>qe&&(K="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=K.indexOf(`
29
+ `):" "+bl(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Hs};function Us(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new rr(null,e)}function Sl(e){return Us(e),e.headers=kt.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yl.getAdapter(e.adapter||Nr.adapter,e)(e).then(function(r){return Us(e),r.data=zs.call(e,e.transformResponse,r),r.headers=kt.from(r.headers),r},function(r){return al(r)||(Us(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=kt.from(r.response.headers))),Promise.reject(r)})}const Cl="1.12.2",ho={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ho[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Tl={};ho.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Cl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Tl[i]&&(Tl[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}},ho.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Jm(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const po={assertOptions:Jm,validators:ho},Xt=po.validators;let Ln=class{constructor(t){this.defaults=t||{},this.interceptors={request:new rl,response:new rl}}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+=`
30
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Dn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&po.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(O.isFunction(o)?n.paramsSerializer={serialize:o}:po.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),po.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&O.merge(s.common,s[n.method]);s&&O.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=kt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[Sl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=Sl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Dn(this.defaults,t);const n=dl(t.baseURL,t.url,t.allowAbsoluteUrls);return nl(n,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){Ln.prototype[t]=function(n,r){return this.request(Dn(r||{},{method:t,url:n,data:(r||{}).data}))}}),O.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Dn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Ln.prototype[t]=n(),Ln.prototype[t+"Form"]=n(!0)});let Zm=class Np{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 rr(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 Np(function(o){t=o}),cancel:t}}};function Qm(e){return function(n){return e.apply(null,n)}}function eg(e){return O.isObject(e)&&e.isAxiosError===!0}const Ws={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(Ws).forEach(([e,t])=>{Ws[t]=e});function kl(e){const t=new Ln(e),n=za(Ln.prototype.request,t);return O.extend(n,Ln.prototype,t,{allOwnKeys:!0}),O.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return kl(Dn(e,o))},n}const at=kl(Nr);at.Axios=Ln,at.CanceledError=rr,at.CancelToken=Zm,at.isCancel=al,at.VERSION=Cl,at.toFormData=lo,at.AxiosError=Pe,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Qm,at.isAxiosError=eg,at.mergeConfig=Dn,at.AxiosHeaders=kt,at.formToJSON=e=>sl(O.isHTMLForm(e)?new FormData(e):e),at.getAdapter=yl.getAdapter,at.HttpStatusCode=Ws,at.default=at;const{Axios:jC,AxiosError:RC,CanceledError:PC,isCancel:OC,CancelToken:MC,VERSION:DC,all:LC,Cancel:$C,isAxiosError:FC,spread:BC,toFormData:zC,AxiosHeaders:HC,HttpStatusCode:UC,formToJSON:WC,getAdapter:VC,mergeConfig:KC}=at,El=typeof window<"u"?window.__API_BASE_URL__:void 0,Il=El?cn(El):void 0;function cn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let mo=null;const Vs=new Set;function Nl(){return mo}function Ks(e){mo=e,Vs.forEach(t=>t(e))}function Al(e){return Vs.add(e),()=>Vs.delete(e)}const Mt=at.create({...Il?{baseURL:Il}:{},timeout:3e4,withCredentials:!0});Mt.interceptors.request.use(e=>(mo&&(e.headers.Authorization=`Bearer ${mo}`),e)),Mt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Mt.defaults.baseURL?(await Mt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qs(e,t,n){return Mt.defaults.baseURL?(await Mt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function _l(e,t,n){return Mt.defaults.baseURL?(await Mt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function jl(e,t){return Mt.defaults.baseURL?(await Mt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Rl{get baseUrl(){const t=Mt.defaults.baseURL;return t?cn(String(t)):""}updateConfig(t){t.baseUrl&&(Mt.defaults.baseURL=cn(String(t.baseUrl))),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return Nl()}setAuthToken(t){Ks(t)}onTokenChange(t){return Al(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qs("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await _l(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await jl(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/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 Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await qs("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const mn=new Rl,Pl=y.createContext(null);function tg({children:e,apiConfig:t}){const n=mn;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(Pl.Provider,{value:r,children:e})}function Gs(){const e=y.useContext(Pl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ng(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function rg(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 og(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await rg(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function sg(e){return e.type!=="thread_info"&&e.type!=="token"}const ig={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function ag(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:Ys(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Ys(t.payload.messages),o={...e,messages:r,assemblingId: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=Ys(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 Ml(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ml(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 Ol(e=[]){const[t,n]=y.useReducer(ag,{...ig,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 Ml(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=hg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Xs(e.messages);return o?{...e,messages:Js(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Xs(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Js(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=fg(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Xs(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Js(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Ys(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 lg(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Xs(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function cg(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 Js(e,t,n){return cg(e,t,r=>({...r,content:ug(r.content,n)}))}function ug(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"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.includes(s))continue;const l=dg(a,s);l?i.text=a+l:i.text=a+s}else n.push({type:"text",text:s})}else n.push(r);return n}function dg(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function fg(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 lg(e,r,s)}return e}function hg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Dl(e={}){const t=y.useMemo(()=>cn(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,w]=y.useState(null),[v,g]=y.useState(0),[x,b]=y.useState(!1),S=y.useRef(null),E=y.useRef(!0),C=y.useRef(0),k=y.useCallback(P=>{o(P)},[]),I=y.useCallback(()=>{var P;(P=S.current)==null||P.abort(),S.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=y.useCallback(()=>{h(""),w(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 H=new AbortController;return S.current=H,(async()=>{var K,W,G,B,_,q,Q,xe;const M=ue=>{var te;try{const je=JSON.parse(JSON.stringify(ue));return(te=je==null?void 0:je.payload)!=null&&te.files_info&&Array.isArray(je.payload.files_info)&&(je.payload.files_info=je.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),je}catch{return ue}};try{let ue={};try{if(r)ue={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const De=window.__AUTH_TOKEN__,nt=((K=window.localStorage)==null?void 0:K.getItem("authToken"))||null;let He=null;try{const dt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");dt&&(He=((G=JSON.parse(dt))==null?void 0:G.apiKey)||null)}catch{}const Je=De||nt||He||null;Je&&(ue={Authorization:`Bearer ${Je}`})}}catch{}console.debug("[use-chat] POST",t+n,M(P));const te=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...ue,...s.current},body:JSON.stringify(P),signal:H.signal,credentials:i});if(!te.ok||!te.body){const ke=await te.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",te.status,ke==null?void 0:ke.slice(0,500)),new Error(`stream ${te.status}${ke?": "+ke:""}`)}b(!0);const je=te.body.getReader(),Te=new TextDecoder;let V="",D=[];C.current=0,g(0);let J=0,U=null;const de=()=>{if(D.length){const ke=D.join("");D=[],E.current&&h(De=>De+ke)}U=null},ce=()=>{typeof window<"u"&&U==null&&(U=requestAnimationFrame(de))};let ze=Date.now();const Xe=setInterval(()=>{var ke;if(Date.now()-ze>6e4){const De="Stream idle timeout";d(De),H.abort(),(ke=$==null?void 0:$.onError)==null||ke.call($,De)}},5e3),Ge=1024*1024;try{const ke=te.headers.get("X-Thread-Id")||te.headers.get("x-thread-id"),De=te.headers.get("X-Thread-Created")||te.headers.get("x-thread-created"),nt=ke??null,He=String(De??"").toLowerCase()==="true";for((B=$==null?void 0:$.onOpen)==null||B.call($,{threadId:nt,created:He});;){const{value:Je,done:dt}=await je.read();if(dt)break;V+=Te.decode(Je,{stream:!0}),V.length>Ge&&(V="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=V.indexOf(`
31
31
 
32
- `))>=0;){const le=K.slice(0,ne);K=K.slice(ne+2);const xe=pg(le);if(!xe)continue;let Se;try{Se=JSON.parse(xe)}catch{console.debug("[use-chat] malformed SSE:",xe.slice(0,200));continue}const be=hg(Se)?Se.data:Se;$e=Date.now();const je=be.seq;if(je!==void 0){if(je<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:je,lastProcessedSeq:J,type:be.type});continue}J>0&&je>J+1&&((j=$==null?void 0:$.onGap)==null||j.call($,{from:J,to:je})),J=je,C.current=je,g(je)}if(L==null||L(be),be.type==="token"&&e.autoAppendAssistant!==!1)D.push(be.content),ue();else if(be.type==="message_delta"){const Qe=be.delta.filter(Ye=>Ye.type==="text").map(Ye=>Ye.text).join("");Qe&&e.autoAppendAssistant!==!1&&(D.push(Qe),ue())}else be.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(U!==null&&cancelAnimationFrame(U),fe(),be.type==="checkpoint"?w(be.checkpointId):be.type==="error"&&d(be.message))}}fe()}catch(ke){if(ke.name!=="AbortError"){const Oe=ke.message||String(ke);d(Oe),(G=$==null?void 0:$.onError)==null||G.call($,Oe)}}finally{try{await Ae.cancel()}catch{}finally{(Z=Ae.releaseLock)==null||Z.call(Ae)}U!==null&&typeof window<"u"&&window.cancelAnimationFrame(U),clearInterval(Ge),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(de){if(de.name!=="AbortError"){const ee=de.message||String(de);d(ee),(ge=$==null?void 0:$.onError)==null||ge.call($,ee)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>H.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:v,connected:x,stream:R,stop:I,clear:A,setToken:k}}function hg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function pg(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(`
33
- `)}function mg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(og(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Dl({baseUrl:e,token:null}),h=y.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ll=y.createContext(null),$l=y.createContext(null),Fl=y.createContext(null),gg=y.createContext(!1),xg=20,vg="cachedThreads",wg="v1",Zs=300,Bl=200;function bg(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,Zs)}function Ar(){return typeof window<"u"&&typeof window.localStorage<"u"}function Qs(e){if(!Ar())return null;try{return window.localStorage.getItem(e)}catch{return null}}function zl(e,t){if(Ar())try{window.localStorage.setItem(e,t)}catch{}}function Hl(e){if(Ar())try{window.localStorage.removeItem(e)}catch{}}function yg(){const e=Qs(vg);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 Sg(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 ei(e,t){return`cachedThreads:v1:${e}:${Sg(t||"anon")}`}function Cg(e){const t=Qs(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 Ul(e,t){try{zl(e,JSON.stringify(t))}catch{}}function Wl(e){const t=Cg(e);if(t.length>0)return t;const n=yg();if(n.length>0)try{Ul(e,n.slice(0,Bl))}catch{}return n}function ti(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 Tg(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function kg({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}=Gs(),d=y.useMemo(()=>cn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${wg}:${f}:`,[f]),p=y.useCallback(E=>`${h}${E}`,[h]),w=y.useCallback(E=>{if(!E||typeof E!="object")return null;const _=E;return typeof _.threadId!="string"||!Array.isArray(_.messages)?null:{threadId:_.threadId,messages:_.messages,hasMore:!!_.hasMore,nextCursor:_.nextCursor??null,checkpointId:_.checkpointId??null,checkpointNs:_.checkpointNs??null}},[]),v=y.useCallback(E=>{const _=Qs(p(E));if(!_)return null;try{const W=JSON.parse(_);return w(W)}catch{return null}},[p,w]),g=y.useCallback((E,_=100)=>{const W={...E,messages:Array.isArray(E.messages)?E.messages.slice(-_):[]};try{zl(p(E.threadId),JSON.stringify(W))}catch{}},[p]),x=y.useCallback(E=>{Hl(p(E))},[p]),b=y.useCallback(()=>{if(Ar())try{const E=h;for(let _=0;_<window.localStorage.length;_++){const W=window.localStorage.key(_);W&&W.startsWith(E)&&window.localStorage.removeItem(W)}}catch{}},[h]),[S,N]=y.useState(()=>{var E;return ei(f,(E=l.getAuthToken)==null?void 0:E.call(l))}),[C,k]=y.useState(()=>{var _;const E=Wl(ei(f,(_=l.getAuthToken)==null?void 0:_.call(l)));return ti(E)}),I=y.useMemo(()=>Tg(C),[C]),[A,R]=y.useState(t),[P,L]=y.useState(!1),[$,H]=y.useState(!1),[M,q]=y.useState(!1),[V,Y]=y.useState(!1),[B,j]=y.useState(null),[G,Z]=y.useState(void 0),[ge,de]=y.useState(void 0),{state:ee,seed:Ae,prepend:Te,pushUser:K,onEvent:D,reset:J}=Ol(),U=y.useRef(A);y.useEffect(()=>{U.current=A},[A]);const fe=y.useRef(!1),ue=y.useRef([]),$e=y.useRef(null),Ge=y.useRef(null),qe=y.useRef(new Map),ke=y.useRef(A),Oe=y.useCallback((E,_)=>new Promise((W,ie)=>{const pe=async()=>{fe.current=!0;try{await E(),W()}catch(he){ie(he)}finally{fe.current=!1;const he=ue.current.shift();he&&he().catch(()=>{})}};fe.current?ue.current.push(pe):pe().catch(he=>{ie(he)})}),[]),Be=y.useCallback(async()=>{const E=I.length>0;E||L(!0);try{const _=await l.listThreads();y.startTransition(()=>{k(W=>{if(_.length===0&&I.length>0)return W;const ie=he=>he.map(et=>`${et.threadId}:${et.updatedAt??""}:${et.messageCount??""}`).join("|");return ie(I)===ie(_)?W:ti(_)})})}catch(_){i==null||i(String(_)),console.error("[ChatSessionProvider] Failed to refresh threads:",_)}finally{E||L(!1)}},[l,i,I.length]),Ue=y.useRef(!1),st=y.useRef(null),ot=y.useRef(null),ne=y.useRef(""),le=y.useCallback((E,_,W)=>{const ie=Array.isArray(E==null?void 0:E.messages)?E.messages:[],pe=W??(E==null?void 0:E.threadId)??U.current;if(_==="replace"){if(pe){const he={threadId:pe,messages:ie.slice(),hasMore:!!(E!=null&&E.hasMore),nextCursor:(E==null?void 0:E.nextCursor)??null,checkpointId:(E==null?void 0:E.checkpointId)??null,checkpointNs:(E==null?void 0:E.checkpointNs)??null};qe.current.set(pe,he),ke.current=pe}Ae(ie,{checkpointId:(E==null?void 0:E.checkpointId)??null,checkpointNs:(E==null?void 0:E.checkpointNs)??null})}else if(_==="prepend"&&ie.length&&pe){const he=qe.current.get(pe),et=(he==null?void 0:he.messages)??[],ht=new Set,T=[...ie,...et].filter(te=>{const ye=te==null?void 0:te.id;return ye?ht.has(ye)?!1:(ht.add(ye),!0):!0}),F={threadId:pe,messages:T,hasMore:(E==null?void 0:E.hasMore)??(he==null?void 0:he.hasMore)??!1,nextCursor:(E==null?void 0:E.nextCursor)??(he==null?void 0:he.nextCursor)??null,checkpointId:(he==null?void 0:he.checkpointId)??(E==null?void 0:E.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??(E==null?void 0:E.checkpointNs)??null};qe.current.set(pe,F),Te(ie)}else _==="prepend"&&ie.length&&Te(ie);_==="replace"?(j((E==null?void 0:E.nextCursor)??null),q(!!(E!=null&&E.hasMore)),Z((E==null?void 0:E.checkpointId)??void 0),de((E==null?void 0:E.checkpointNs)??void 0)):(j(he=>(E==null?void 0:E.nextCursor)??he??null),q(he=>(E==null?void 0:E.hasMore)!==void 0?!!(E!=null&&E.hasMore):he),Z(he=>(E==null?void 0:E.checkpointId)??he??void 0),de(he=>(E==null?void 0:E.checkpointNs)??he??void 0))},[Te,Ae]),xe=y.useCallback(E=>{Ae(E.messages,{checkpointId:E.checkpointId,checkpointNs:E.checkpointNs}),j(E.nextCursor),q(E.hasMore),Z(E.checkpointId??void 0),de(E.checkpointNs??void 0),ke.current=E.threadId},[Ae]),Se=y.useCallback(E=>{E&&(qe.current.delete(E),x(E),ke.current===E&&(ke.current=null))},[x]),be=y.useCallback(()=>{const E=U.current;E&&Se(E),J([]),q(!1),Y(!1),j(null),Z(void 0),de(void 0)},[Se,J]),je=y.useCallback(({from:E,to:_})=>{const W=U.current;W&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${E} -> ${_}) for thread ${W}`)},[]),Qe=y.useCallback(E=>{const _=E.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:_,title:E.title,created:E.created,currentThreads:I.length});const W={threadId:_,title:E.title||`Thread ${_.slice(0,8)}`,createdAt:E.createdAt||new Date().toISOString(),updatedAt:E.updatedAt||new Date().toISOString(),messageCount:E.messageCount||0};U.current!==_&&(!U.current&&ee.messages.length<=1&&(Ge.current=_),R(_)),y.startTransition(()=>{k(ie=>{const pe=ie.byId[_];return pe?pe.title===W.title&&pe.updatedAt===W.updatedAt&&pe.messageCount===W.messageCount?ie:{byId:{...ie.byId,[_]:W},order:ie.order}:{byId:{...ie.byId,[_]:W},order:[_,...ie.order]}})})},[ee.messages.length]),{startStream:Ye,stop:it,isStreaming:gt,error:hn,setAuthToken:Jn}=mg({baseUrl:d,onThreadInfo:Qe,onMessageEvent:D,onUnhandledEvent:E=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${E.type}`,E)},onSequenceGap:je});y.useEffect(()=>{Ue.current=gt},[gt]),y.useEffect(()=>{if(!Ar())return;ot.current&&window.clearTimeout(ot.current);const E=I.map(_=>`${_.threadId}:${_.updatedAt??""}:${_.messageCount??""}`).join("|");if(I.length===0){try{Hl(S)}catch{}ne.current="";return}if(E!==ne.current)return ne.current=E,ot.current=window.setTimeout(()=>{bg(()=>{try{const W=I.slice(0,Bl);Ul(S,W)}catch{}})},Zs),()=>{ot.current&&window.clearTimeout(ot.current)}},[I,S]),y.useEffect(()=>{var ie;const E=l.getAuthToken();Jn(E);const _=pe=>{const he=ei(f,pe);N(he);const et=Wl(he);y.startTransition(()=>{k(ti(et))}),Be().catch(()=>{})};_(E);const W=(ie=l.onTokenChange)==null?void 0:ie.call(l,pe=>{Jn(pe),b(),_(pe)});return()=>{W==null||W()}},[l,f,Jn,b,Be]);const vr=y.useCallback(async E=>{const _=`temp-${Date.now()}`,W={threadId:_,title:E||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(ie=>({byId:{...ie.byId,[_]:W},order:[_,...ie.order]})),R(_);try{const ie=await l.createThread(E),pe=typeof ie=="string"?ie:ie.threadId;return k(he=>{const et=he.byId[_];if(!et)return he;const ht={...he.byId};delete ht[_],ht[pe]={...et,threadId:pe};const T=he.order.map(F=>F===_?pe:F);return{byId:ht,order:T}}),R(pe),setTimeout(()=>Be(),10),pe}catch(ie){throw k(pe=>{if(!pe.byId[_])return pe;const he={...pe.byId};delete he[_];const et=pe.order.filter(ht=>ht!==_);return{byId:he,order:et}}),R(null),ie}},[l,Be]),Zn=y.useCallback(async E=>{await l.deleteThread(E),k(_=>{if(!_.byId[E])return _;const W={..._.byId};delete W[E];const ie=_.order.filter(pe=>pe!==E);return{byId:W,order:ie}}),Se(E),U.current===E&&(Ge.current=E,R(null),U.current=null,ke.current=null,be()),await Be()},[l,be,Se,Be]),Nn=y.useCallback(async(E,_)=>{try{await l.updateThread(E,_),k(W=>{const ie=W.byId[E];return ie?{byId:{...W.byId,[E]:{...ie,title:_}},order:W.order}:W})}catch(W){throw await Be(),W}},[l,Be]),Bt=y.useCallback(async(E,_,W,ie=!1)=>{await Oe(async()=>{if(Ge.current===E&&!ie){Ge.current=null;return}if($e.current===E&&!ie)return;R(T=>T===E?T:E),U.current=E;const pe=!ie&&!_&&!W;let he=!1;if(pe){const T=qe.current.get(E);if(T)xe(T),he=!0;else{const F=v(E);F&&(qe.current.set(E,F),xe(F),he=!0)}}const et=ie||!he||!!_||!!W,ht=async T=>{T&&H(!0),$e.current=E;try{const F=await l.getMessages({threadId:E,checkpointId:_,checkpointNs:W});le(F,"replace",E)}catch(F){throw(!he||ie||T)&&(i==null||i(String(F))),F}finally{$e.current=null,T&&H(!1)}};et?await ht(!0):pe&&he&&ht(!1).catch(T=>{console.warn("[ChatSessionProvider] Background refresh failed:",T)})},`loadThread-${E}`)},[l,xe,le,Oe,i]),An=y.useCallback(async()=>{await Oe(async()=>{const E=U.current;E&&Se(E),Ge.current=null,R(null),U.current=null,ke.current=null,be(),Z(void 0),de(void 0);try{localStorage.removeItem("lastThreadId")}catch(_){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",_)}},"clearCurrentThread")},[be,Se,Oe]),Qn=y.useCallback(async E=>{const _=await l.listCheckpoints(E);return tg(_,E)},[l]),Yt=y.useCallback(async(E,_)=>{if(!U.current)throw new Error("No active thread");await Bt(U.current,E,_??void 0,!0)},[Bt]),_n=y.useCallback(async()=>{if(!U.current)throw new Error("No active thread");await Bt(U.current,void 0,void 0,!0)},[Bt]),jn=y.useCallback(async E=>{if(!U.current)throw new Error("No active thread");if(V||!M)return;const _=B;if(_){Y(!0);try{const W=U.current,ie=await l.getMessages({threadId:W,checkpointId:G,checkpointNs:ge,limit:(E==null?void 0:E.limit)??xg,beforeId:_});le(ie,"prepend",W??void 0)}finally{Y(!1)}}},[l,le,M,G,ge,B,V]),er=y.useCallback(async(E,_)=>{var We;const W=U.current;!W&&!(_!=null&&_.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const ie=(_==null?void 0:_.attachments)||[],{contentParts:pe,filesInfo:he}=await rg(l,ie),et=[...pe];E&&E.trim()&&et.push({type:"text",text:E.trim()});const ht={id:((We=crypto.randomUUID)==null?void 0:We.call(crypto))||`user-${Date.now()}`,role:"user",content:et,createdAt:new Date().toISOString(),checkpointId:(_==null?void 0:_.checkpointId)??ee.lastCheckpointId??void 0,checkpointNs:(_==null?void 0:_.checkpointNs)??ee.lastCheckpointNs??void 0};K(ht);const T={...ht,content:et},F={...(_==null?void 0:_.payloadExtras)??{}},te=ie.length>0,ye={...W?{threadId:W}:{},payload:{messages:[T],files_info:he,...o&&te&&s?{active_agent:s}:{},...F},checkpointId:(_==null?void 0:_.checkpointId)??ee.lastCheckpointId??void 0,checkpointNs:(_==null?void 0:_.checkpointNs)??ee.lastCheckpointNs??void 0,nodeFilter:_==null?void 0:_.nodeFilter,config:_==null?void 0:_.config};Ye(ye,{onError:Ve=>{console.warn("[ChatSessionProvider] Stream error:",Ve)},onOpen:({threadId:Ve,created:ze})=>{!U.current&&Ve&&(ee.messages.length<=1&&(Ge.current=Ve),R(Ve))},onGap:je})},[l,o,s,je,ee.lastCheckpointId,ee.lastCheckpointNs,ee.messages.length,K,Ye]),wr=y.useCallback(async(E,_,W)=>{const ie=U.current;if(!ie)throw new Error("No active thread to handle interrupt");try{const pe=_?W??!0:!1;await l.resume({threadId:ie,value:pe})}catch(pe){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${E}:`,pe),pe}},[l]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(E){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",E)}},[A,a]),y.useEffect(()=>((async()=>{try{if(Be().catch(_=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",_),i==null||i(String(_))}),!r&&!t)try{const _=localStorage.getItem("lastThreadId");_&&(R(_),n&&await Bt(_))}catch(_){console.warn("[ChatSessionProvider] Failed to restore last thread:",_)}else t&&n&&await Bt(t)}catch(_){console.error("[ChatSessionProvider] Initialization failed:",_),i==null||i(String(_))}})(),()=>{}),[]),y.useEffect(()=>{const E=U.current;if(!E||ke.current!==E)return;const _={threadId:E,messages:ee.messages.slice(),hasMore:M,nextCursor:B,checkpointId:ee.lastCheckpointId??null,checkpointNs:ee.lastCheckpointNs??null},W=qe.current.get(E);(!W||W.messages.length!==_.messages.length||W.messages.some((pe,he)=>{var et;return(pe==null?void 0:pe.id)!==((et=_.messages[he])==null?void 0:et.id)})||(W==null?void 0:W.hasMore)!==_.hasMore||(W==null?void 0:W.nextCursor)!==_.nextCursor||(W==null?void 0:W.checkpointId)!==_.checkpointId||(W==null?void 0:W.checkpointNs)!==_.checkpointNs)&&(qe.current.set(E,_),st.current&&window.clearTimeout(st.current),st.current=window.setTimeout(()=>{try{g(_,100)}catch(pe){console.warn("[ChatSessionProvider] Failed to persist thread payload:",pe)}},Zs))},[M,B,ee.lastCheckpointId,ee.lastCheckpointNs,ee.messages]);const br=y.useMemo(()=>({threads:I,currentThreadId:A,isLoadingThreads:P,isLoadingThread:$,setCurrentThreadId:R,createThread:vr,deleteThread:Zn,renameThread:Nn,refreshThreads:Be,loadThread:Bt,clearCurrentThread:An,listCheckpoints:Qn,navigateToCheckpoint:Yt,returnToLatest:_n}),[An,vr,A,Zn,$,P,Qn,Bt,Yt,Be,Nn,_n,I]),to=y.useMemo(()=>({messages:ee.messages,assemblingId:ee.assemblingId,lastUserMessage:null,hasMoreHistory:M,isLoadingHistory:V,send:er,stop:it,loadOlderMessages:jn,clearMessages:be,handleInterrupt:wr}),[be,wr,M,V,jn,ee.assemblingId,ee.messages,er,it]),se=y.useMemo(()=>({isStreaming:gt,error:hn,streamingAssistantId:ee.assemblingId,lastCheckpointId:ee.lastCheckpointId??null,lastCheckpointNs:ee.lastCheckpointNs??null}),[gt,ee.assemblingId,ee.lastCheckpointId,ee.lastCheckpointNs,hn]);return c.jsx(gg.Provider,{value:!0,children:c.jsx(Fl.Provider,{value:se,children:c.jsx(Ll.Provider,{value:br,children:c.jsx($l.Provider,{value:to,children:e})})})})}function go(){const e=y.useContext(Ll);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function ni(){const e=y.useContext($l);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Vl(){const e=y.useContext(Fl);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function xo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(eg,{apiConfig:t,children:c.jsx(kg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function Q(...e){return Ap.twMerge(Np.clsx(e))}const Eg=no.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"}}),He=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Rn.Slot:"button";return c.jsx(i,{className:Q(Eg({variant:t,size:n,className:e})),ref:s,...o})});He.displayName="Button";const Kl=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:Q("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Kl.displayName="Textarea";function Ig({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),[w,v]=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 x=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async A=>{A&&A.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const P=i(R);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(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`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 b(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(Kl,{ref:g,value:h,onChange:S,onKeyDown:N,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(He,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(re.Square,{size:16})}):c.jsx(He,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(re.Send,{size:16})})})]})})}const Ng=y.memo(Ig),vo=0,gn=1,or=2,ql=4;function Gl(e){return()=>e}function Ag(e){e()}function Yl(e,t){return n=>e(t(n))}function Xl(e,t){return()=>e(t)}function _g(e,t){return n=>e(t,n)}function ri(e){return e!==void 0}function jg(...e){return()=>{e.map(Ag)}}function sr(){}function wo(e,t){return t(e),e}function Rg(e,t){return t(e)}function tt(...e){return e}function Xe(e,t){return e(gn,t)}function Pe(e,t){e(vo,t)}function oi(e){e(or)}function lt(e){return e(ql)}function me(e,t){return Xe(e,_g(t,vo))}function Ut(e,t){const n=e(gn,r=>{n(),t(r)});return n}function Jl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Zl(e,t){return e===t}function nt(e=Zl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function oe(e){return t=>Yl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=Pg(...t);return(r,o)=>{switch(r){case or:oi(e);return;case gn:return Xe(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function Dn(e){return t=>n=>{e>0?e--:t(n)}}function un(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Me(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(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 Pg(...e){return t=>e.reduceRight(Rg,t)}function Og(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),sr);case or:r(),n=null;return}}}function X(e){let t=e;const n=Fe();return(r,o)=>{switch(r){case vo:t=o;break;case gn:{o(t);break}case ql:return t}return n(r,o)}}function vt(e,t){return wo(X(t),n=>me(e,n))}function Fe(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case or:e.splice(0,e.length);return;case gn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return wo(Fe(),t=>me(e,t))}function Ke(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Mg(),singleton:n}}const Mg=()=>Symbol();function Dg(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 ut(...e){const t=Fe(),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);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case or:{oi(t);return}case gn:return r===o&&i(n),Xe(t,i)}}}function Ce(e,t=Zl){return z(e,nt(t))}function si(...e){return function(t,n){switch(t){case or:return;case gn:return jg(...e.map(r=>Xe(r,n)))}}}var Et=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Et||{});const Lg={0:"debug",3:"error",1:"log",2:"warn"},$g=()=>typeof globalThis>"u"?window:globalThis,xn=Ke(()=>{const e=X(3);return{log:X((t,n,r=1)=>{var o;const s=(o=$g().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[Lg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Ln(e,t,n){return ii(e,t,n).callbackRef}function ii(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 Fg(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Bg(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 w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Ql("column-gap",getComputedStyle(d).columnGap,o):Ql("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ii(u,n,l)}function Bg(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},Et.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 Ql(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}function ec(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(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+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}=ii(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 yt=Ke(()=>{const e=Fe(),t=Fe(),n=X(0),r=Fe(),o=X(0),s=Fe(),i=Fe(),a=X(0),l=X(0),u=X(0),d=X(0),f=Fe(),h=Fe(),p=X(!1),w=X(!1),v=X(!1);return me(z(e,oe(({scrollTop:g})=>g)),t),me(z(e,oe(({scrollHeight:g})=>g)),i),me(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),_r={lvl:0};function tc(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 Je(e){return e===_r}function jr(e,t){if(!Je(e))return t===e.k?e.v:t<e.k?jr(e.l,t):jr(e.r,t)}function Wt(e,t,n="k"){if(Je(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Wt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Wt(e.l,t,n)}function _t(e,t,n){return Je(e)?oc(t,n,1):t===e.k?ft(e,{k:t,v:n}):t<e.k?sc(ft(e,{l:_t(e.l,t,n)})):sc(ft(e,{r:_t(e.r,t,n)}))}function ir(){return _r}function bo(e,t,n){if(Je(e))return[];const r=Wt(e,t)[0];return zg(li(e,r,n))}function ai(e,t){if(Je(e))return _r;const{k:n,l:r,r:o}=e;if(t===n){if(Je(r))return o;if(Je(o))return r;{const[s,i]=rc(r);return yo(ft(e,{k:s,l:nc(r),v:i}))}}else return t<n?yo(ft(e,{l:ai(r,t)})):yo(ft(e,{r:ai(o,t)}))}function $n(e){return Je(e)?[]:[...$n(e.l),{k:e.k,v:e.v},...$n(e.r)]}function li(e,t,n){if(Je(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(li(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(li(s,t,n))),a}function yo(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(ci(t))return ic(ft(e,{lvl:n-1}));if(!Je(t)&&!Je(t.r))return ft(t.r,{l:ft(t,{r:t.r.l}),lvl:n,r:ft(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ci(e))return ui(ft(e,{lvl:n-1}));if(!Je(r)&&!Je(r.l)){const o=r.l,s=ci(o)?r.lvl-1:r.lvl;return ft(o,{l:ft(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ui(ft(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ft(e,t){return oc(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 nc(e){return Je(e.r)?e.l:yo(ft(e,{r:nc(e.r)}))}function ci(e){return Je(e)||e.lvl>e.r.lvl}function rc(e){return Je(e.r)?[e.k,e.v]:rc(e.r)}function oc(e,t,n,r=_r,o=_r){return{k:e,l:r,lvl:n,r:o,v:t}}function sc(e){return ui(ic(e))}function ic(e){const{l:t}=e;return!Je(t)&&t.lvl===e.lvl?ft(t,{r:ft(e,{l:t.r})}):e}function ui(e){const{lvl:t,r:n}=e;return!Je(n)&&!Je(n.r)&&n.lvl===t&&n.r.lvl===t?ft(n,{l:ft(e,{r:n.l}),lvl:t+1}):e}function zg(e){return tc(e,({k:t,v:n})=>({index:t,value:n}))}function ac(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Rr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const di=Ke(()=>({recalcInProgress:X(!1)}),[],{singleton:!0});function lc(e,t,n){return e[So(e,t,n)]}function So(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 Hg(e,t,n,r){const o=So(e,t,r),s=So(e,n,r,o);return e.slice(o,s+1)}function vn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!Je(e.groupOffsetTree)}function fi({index:e},t){return t===e?0:t<e?-1:1}function Ug(){return{groupIndices:[],groupOffsetTree:ir(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:ir()}}function Wg(e,t){let n=Je(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Je(e)){e=_t(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(Jg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ai(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=_t(e,o+1,h));u&&(e=_t(e,i,s))}return[e,n]}function Vg(e){return typeof e.groupIndex<"u"}function Kg({offset:e},t){return t===e?0:t<e?-1:1}function Pr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=lc(t,e,fi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function cc(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function uc(e,t,n){if(Vg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=cc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function qg(e,t,n,r=0){return r>0&&(t=Math.max(t,lc(e,r,fi).offset)),tc(Hg(e,t,n,Kg),Xg)}function Gg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Et.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Je(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>_t(_t(w,v,h),v+1,p),i)}else[i,a]=Wg(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=hi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>_t(h,p,Pr(p,f,o)),ir()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Yg(e){return $n(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 dc(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 hi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=So(o,t-1,fi),a=o[l].offset;const u=Wt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Wt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of bo(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 Xg(e){return{index:e.index,value:e}}function Jg(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 Zg={offsetHeight:"height",offsetWidth:"width"},Qt=Ke(([{log:e},{recalcInProgress:t}])=>{const n=Fe(),r=Fe(),o=vt(r,0),s=Fe(),i=Fe(),a=X(0),l=X([]),u=X(void 0),d=X(void 0),f=X((C,k)=>vn(C,Zg[k])),h=X(void 0),p=X(0),w=Ug(),v=vt(z(n,Me(l,e,p),Zt(Gg,w),nt()),w),g=vt(z(l,nt(),Zt((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),oe(({prev:C})=>C)),[]);me(z(l,Ee(C=>C.length>0),Me(v,p),oe(([C,k,I])=>{const A=C.reduce((R,P,L)=>_t(R,P,Pr(P,k.offsetTree,I)||L),ir());return{...k,groupIndices:C,groupOffsetTree:A}})),v),me(z(r,Me(v),Ee(([C,{lastIndex:k}])=>C<k),oe(([C,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:C}])),n),me(u,d);const x=vt(z(u,oe(C=>C===void 0)),!0);me(z(d,Ee(C=>C!==void 0&&Je(lt(v).sizeTree)),oe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Me(v),Zt(({sizes:C},[k,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),oe(C=>C.changed)));Xe(z(a,Zt((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),oe(C=>C.diff)),C=>{const{groupIndices:k}=lt(v);if(C>0)Pe(t,!0),Pe(s,C+dc(C,k));else if(C<0){const I=lt(g);I.length>0&&(C-=dc(-C,I)),Pe(i,C)}}),Xe(z(a,Me(e)),([C,k])=>{C<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},Et.ERROR)});const S=At(s);me(z(s,Me(v),oe(([C,k])=>{const I=k.groupIndices.length>0,A=[],R=k.lastSize;if(I){const P=jr(k.sizeTree,0);let L=0,$=0;for(;L<C;){const M=k.groupIndices[$],q=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+q-1,size:R,startIndex:M+1}),$++,L+=q+1}const H=$n(k.sizeTree);return L!==C&&H.shift(),H.reduce((M,{k:q,v:V})=>{let Y=M.ranges;return M.prevSize!==0&&(Y=[...M.ranges,{endIndex:q+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:q+C,prevSize:V,ranges:Y}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return $n(k.sizeTree).reduce((P,{k:L,v:$})=>({prevIndex:L+C,prevSize:$,ranges:[...P.ranges,{endIndex:L+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const N=At(z(i,Me(v,p),oe(([C,{offsetTree:k},I])=>{const A=-C;return Pr(A,k,I)})));return me(z(i,Me(v,p),oe(([C,k,I])=>{if(k.groupIndices.length>0){if(Je(k.sizeTree))return k;let A=ir();const R=lt(g);let P=0,L=0,$=0;for(;P<-C;){$=R[L];const H=R[L+1]-$-1;L++,P+=H+1}if(A=$n(k.sizeTree).reduce((H,{k:M,v:q})=>_t(H,Math.max(0,M+C),q),A),P!==-C){const H=jr(k.sizeTree,$);A=_t(A,0,H);const M=Wt(k.sizeTree,-C+1)[1];A=_t(A,1,M)}return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}else{const A=$n(k.sizeTree).reduce((R,{k:P,v:L})=>_t(R,Math.max(0,P+C),L),ir());return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:N,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(xn,di),{singleton:!0});function Qg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const fc=Ke(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Fe(),i=Fe(),a=At(z(s,oe(Qg)));return me(z(a,oe(l=>l.totalCount)),n),me(z(a,oe(l=>l.groupIndices)),e),me(z(ut(o,t,r),Ee(([l,u])=>Co(u)),oe(([l,u,d])=>Wt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),oe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(Qt,yt)),wn=Ke(([{log:e}])=>{const t=X(!1),n=At(z(t,Ee(r=>r),nt()));return Xe(t,r=>{r&&lt(e)("props updated",{},Et.DEBUG)}),{didMount:n,propsReady:t}},tt(xn),{singleton:!0}),ex=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function hc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ex)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Or=Ke(([{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=Fe(),w=Fe(),v=X(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Pe(l,!1)}return me(z(p,Me(n,f,r,v,a,i,h),Me(e,s,o),oe(([[N,C,k,I,A,R,P,L],$,H,M])=>{const q=hc(N),{align:V,behavior:Y,offset:B}=q,j=I-1,G=uc(q,C,j);let Z=Pr(G,C.offsetTree,$)+R;V==="end"?(Z+=H+Wt(C.sizeTree,G)[1]-k+M,G===j&&(Z+=P)):V==="center"?Z+=(H+Wt(C.sizeTree,G)[1]-k+M)/2:Z-=A,B&&(Z+=B);const ge=de=>{S(),de?(L("retrying to scroll to",{location:N},Et.DEBUG),Pe(p,N)):(Pe(w,!0),L("list did not change, scroll successful",{},Et.DEBUG))};if(S(),Y==="smooth"){let de=!1;b=Xe(t,ee=>{de=de||ee}),g=Ut(d,()=>{ge(de)})}else g=Ut(z(t,tx(150)),ge);return x=setTimeout(()=>{S()},1200),Pe(l,!0),L("scrolling from index to",{behavior:Y,index:G,top:Z},Et.DEBUG),{behavior:Y,top:Z}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},tt(Qt,yt,xn),{singleton:!0});function tx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pi(e,t){e==0?t():requestAnimationFrame(()=>{pi(e-1,t)})}function mi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Mr=Ke(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=X(!0),l=X(0),u=X(!0);return me(z(i,Me(l),Ee(([d,f])=>!!f),Jt(!1)),a),me(z(i,Me(l),Ee(([d,f])=>!!f),Jt(!1)),u),Xe(z(ut(t,i),Me(a,n,e,u),Ee(([[,d],f,{sizeTree:h},p,w])=>d&&(!Je(h)||ri(p))&&!f&&!w),Me(l)),([,d])=>{Ut(o,()=>{Pe(u,!0)}),pi(4,()=>{Ut(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(Qt,yt,Or,wn),{singleton:!0});function pc(e,t){return Math.abs(e-t)<1.01}const Dr="up",Lr="down",nx="none",rx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ox=0,$r=Ke(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=X(!1),a=X(!0),l=Fe(),u=Fe(),d=X(4),f=X(ox),h=vt(z(si(z(Ce(o),Dn(1),Jt(!0)),z(Ce(o),Dn(1),Jt(!1),Jl(100))),nt()),!1),p=vt(z(si(z(n,Jt(!0)),z(n,Jt(!1),Jl(200))),nt()),!1);me(z(ut(Ce(o),Ce(f)),oe(([b,S])=>b<=S),nt()),a),me(z(a,un(50)),u);const w=At(z(ut(r,Ce(s),Ce(t),Ce(e),Ce(d)),Zt((b,[{scrollHeight:S,scrollTop:N},C,k,I,A])=>{const R=N+C-S>-A,P={scrollHeight:S,scrollTop:N,viewportHeight:C};if(R){let $,H;return N>b.state.scrollTop?($="SCROLLED_DOWN",H=b.state.scrollTop-N):($="SIZE_DECREASED",H=b.state.scrollTop-N||b.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:H,state:P}}let L;return P.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":C<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":N<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},rx),nt((b,S)=>b&&b.atBottom===S.atBottom))),v=vt(z(r,Zt((b,{scrollHeight:S,scrollTop:N,viewportHeight:C})=>{if(pc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:N};{const k=S-(N+C)<1;return b.scrollTop!==N&&k?{changed:!0,jump:b.scrollTop-N,scrollHeight:S,scrollTop:N}:{changed:!0,jump:0,scrollHeight:S,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(b=>b.changed),oe(b=>b.jump)),0);me(z(w,oe(b=>b.atBottom)),i),me(z(i,un(50)),l);const g=X(Lr);me(z(r,oe(({scrollTop:b})=>b),nt(),Zt((b,S)=>lt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Dr:Lr,prevScrollTop:S},{direction:Lr,prevScrollTop:0}),oe(b=>b.direction)),g),me(z(r,un(50),Jt(nx)),g);const x=X(0);return me(z(h,Ee(b=>!b),Jt(0)),x),me(z(o,un(100),Me(h),Ee(([b,S])=>!!S),Zt(([b,S],[N])=>[S,N],[0,0]),oe(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},tt(yt)),To="top",ko="bottom",mc="none";function gc(e,t,n){return typeof e=="number"?n===Dr&&t===To||n===Lr&&t===ko?e:0:n===Dr?t===To?e.main:e.reverse:t===ko?e.main:e.reverse}function xc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const gi=Ke(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Fe(),i=X(0),a=X(0),l=X(0),u=vt(z(ut(Ce(r),Ce(o),Ce(n),Ce(s,Rr),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),oe(([d,f,h,[p,w],v,g,x,b,S])=>{const N=d-b,C=g+x,k=Math.max(h-N,0);let I=mc;const A=xc(S,To),R=xc(S,ko);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Dr),w<d-k+f+R&&(I=Lr),I!==mc?[Math.max(N-h-gc(v,To,I)-A,0),N-k-x+f+gc(v,ko,I)+R]:null}),Ee(d=>d!=null),nt(Rr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(yt),{singleton:!0});function sx(e,t,n){if(Co(t)){const r=cc(e,t);return[{index:Wt(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 xi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Eo(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 v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:wc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:wc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function vc(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=mi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function wc(e,t,n){if(e.length===0)return[];if(!Co(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=bo(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 Fn=Ke(([{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:w}])=>{const v=X([]),g=X(0),x=Fe();me(s.topItemsIndexes,v);const b=vt(z(ut(p,w,Ce(l,Rr),Ce(o),Ce(r),Ce(u),d,Ce(v),Ce(t),Ce(n),e),Ee(([k,I,,A,,,,,,,R])=>{const P=R&&R.length!==A;return k&&!I&&!P}),oe(([,,[k,I],A,R,P,L,$,H,M,q])=>{const V=R,{offsetTree:Y,sizeTree:B}=V,j=lt(g);if(A===0)return{...xi,totalCount:A};if(k===0&&I===0)return j===0?{...xi,totalCount:A}:vc(j,P,R,H,M,q||[]);if(Je(B))return j>0?null:Eo(sx(mi(P,A),V,q),[],A,M,V,H);const G=[];if($.length>0){const Ae=$[0],Te=$[$.length-1];let K=0;for(const D of bo(B,Ae,Te)){const J=D.value,U=Math.max(D.start,Ae),fe=Math.min(D.end,Te);for(let ue=U;ue<=fe;ue++)G.push({data:q==null?void 0:q[ue],index:ue,offset:K,size:J}),K+=J}}if(!L)return Eo([],G,A,M,V,H);const Z=$.length>0?$[$.length-1]+1:0,ge=qg(Y,k,I,Z);if(ge.length===0)return null;const de=A-1,ee=wo([],Ae=>{for(const Te of ge){const K=Te.value;let D=K.offset,J=Te.start;const U=K.size;if(K.offset<k){J+=Math.floor((k-K.offset+M)/(U+M));const ue=J-Te.start;D+=ue*U+ue*M}J<Z&&(D+=(Z-J)*U,J=Z);const fe=Math.min(Te.end,de);for(let ue=J;ue<=fe&&!(D>=I);ue++)Ae.push({data:q==null?void 0:q[ue],index:ue,offset:D,size:U}),D+=U+M}});return Eo(ee,G,A,M,V,H)}),Ee(k=>k!==null),nt()),xi);me(z(e,Ee(ri),oe(k=>k==null?void 0:k.length)),o),me(z(b,oe(k=>k.topListHeight)),f),me(f,a),me(z(b,oe(k=>[k.top,k.bottom])),i),me(z(b,oe(k=>k.items)),x);const S=At(z(b,Ee(({items:k})=>k.length>0),Me(o,e),Ee(([{items:k},I])=>k[k.length-1].originalIndex===I-1),oe(([,k,I])=>[k-1,I]),nt(Rr),oe(([k])=>k))),N=At(z(b,un(200),Ee(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),oe(({items:k})=>k[0].index),nt())),C=At(z(b,Ee(({items:k})=>k.length>0),oe(({items:k})=>{let I=0,A=k.length-1;for(;k[I].type==="group"&&I<A;)I++;for(;k[A].type==="group"&&A>I;)A--;return{endIndex:k[A].index,startIndex:k[I].index}}),nt(ac)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:N,topItemsIndexes:v,...h}},tt(Qt,fc,gi,Mr,Or,$r,wn,di),{singleton:!0}),bc=Ke(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Fe(),i=vt(z(ut(n,e,r,t,o),oe(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return me(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(yt,Fn),{singleton:!0}),ix=Ke(([{viewportHeight:e},{totalListHeight:t}])=>{const n=X(!1),r=vt(z(ut(n,e,t),Ee(([o])=>o),oe(([,o,s])=>Math.max(0,o-s)),un(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(yt,bc),{singleton:!0}),yc=Ke(()=>({context:X(null)})),ax=({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,Sc=Ke(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Fe();return me(z(d,Me(t,l,n,s,o,r,a),Me(e),oe(([[f,h,p,w,v,g,x,b],S])=>{const{align:N,behavior:C,calculateViewLocation:k=ax,done:I,...A}=f,R=uc(f,h,w-1),P=Pr(R,h.offsetTree,S)+v+g,L=P+Wt(h.sizeTree,R)[1],$=b+g,H=b+p-x,M=k({itemBottom:L,itemTop:P,locationParams:{align:N,behavior:C,...A},viewportBottom:H,viewportTop:$});return M?I&&Ut(z(i,Ee(q=>!q),Dn(lt(i)?1:2)),I):I&&I(),M}),Ee(f=>f!==null)),u),{scrollIntoView:d}},tt(Qt,yt,Or,Fn,xn),{singleton:!0});function Cc(e){return e?e==="smooth"?"smooth":"auto":!1}const lx=(e,t)=>typeof e=="function"?Cc(e(t)):t&&Cc(e),cx=Ke(([{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 w=X(!1),v=Fe();let g=null;function x(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}Xe(z(ut(z(Ce(t),Dn(1)),l),Me(Ce(w),s,a,f),oe(([[C,k],I,A,R,P])=>{let L=k&&R,$="auto";return L&&($=lx(I,A||P),L=L&&!!$),{followOutputBehavior:$,shouldFollow:L,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C)}):g=Ut(e,()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C),g=null})});function b(C){const k=Ut(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},Et.DEBUG),x("auto"))});setTimeout(k,100)}Xe(z(ut(Ce(w),t,u),Ee(([C,,k])=>C&&k),Zt(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),Me(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Xe(v,()=>{b(lt(w)!==!1)}),Xe(ut(Ce(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=X(null),N=Fe();return me(si(z(Ce(r),oe(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),z(Ce(t))),N),Xe(z(ut(z(N,Dn(1)),l),Me(Ce(S),a,f,h),oe(([[C,k],I,A,R,P])=>k&&A&&(I==null?void 0:I({context:P,totalCount:C,scrollingInProgress:R}))),Ee(C=>!!C),un(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),Pe(p,C)}):g=Ut(e,()=>{lt(d)("scrolling into view",{}),Pe(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},tt(Qt,$r,Or,Mr,wn,xn,yt,yc,Sc)),ux=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(z(a,Me(s),Ee(([,l])=>l!==0),Me(o,r,t,n,e),oe(([[,l],u,d,f,h,p=[]])=>vc(l,u,d,f,h,p))),i),{}),tt(Qt,Mr,Fn,wn),{singleton:!0}),dx=Ke(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=X(0);return Xe(z(e,Me(r),Ee(([,o])=>o!==0),oe(([,o])=>({top:o}))),o=>{Ut(z(n,Dn(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},tt(wn,yt,Fn),{singleton:!0}),Tc=Ke(([{scrollVelocity:e}])=>{const t=X(!1),n=Fe(),r=X(!1);return me(z(e,Me(r,t,n),Ee(([o,s])=>!!s),oe(([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}),nt()),t),Xe(z(ut(t,e,n),Me(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},tt($r),{singleton:!0}),vi=Ke(([{scrollContainerState:e,scrollTo:t}])=>{const n=Fe(),r=Fe(),o=Fe(),s=X(!1),i=X(void 0);return me(z(ut(n,r),oe(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),me(z(t,Me(r),oe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(yt)),fx=Ke(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Fe(),d=X(void 0),f=X(null),h=X(null);return me(a,f),me(l,h),Xe(z(u,Me(t,r,i,f,h,n)),([p,w,v,g,x,b,S])=>{const N=Yg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,p({ranges:N,scrollTop:v})}),me(z(d,Ee(ri),oe(hx)),o),me(z(s,Me(d),Ee(([,p])=>p!==void 0),nt(),oe(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(Qt,yt,Mr,wn,vi));function hx(e){return{align:"start",index:0,offset:e.scrollTop}}const px=Ke(([{topItemsIndexes:e}])=>{const t=X(0);return me(z(t,Ee(n=>n>=0),oe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(Fn));function kc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const mx=kc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),gx=Ke(([{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:w}])=>{const v=At(z(l,Me(i),Zt(([,x,b,S],[{bottom:N,items:C,offsetBottom:k,totalCount:I},A])=>{const R=N+k;let P=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(P=R-S,P!==0&&(P+=A))),[P,C,I,R]},[0,[],0,0]),Ee(([x])=>x!==0),Me(r,a,n,o,p,w),Ee(([,x,b,S,,,N])=>!N&&!S&&x!==0&&b===Dr),oe(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Et.DEBUG),x))));function g(x){x>0?(Pe(t,{behavior:"auto",top:-x}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-x}))}return Xe(z(v,Me(e,s)),([x,b,S])=>{S&&mx()?Pe(e,b-x):g(-x)}),Xe(z(ut(vt(s,!1),e,w),Ee(([x,b,S])=>!x&&!S&&b!==0),oe(([x,b])=>b),un(1)),g),me(z(f,oe(x=>({top:-x}))),t),Xe(z(u,Me(h,d),oe(([x,{groupIndices:b,lastSize:S,sizeTree:N},C])=>{function k(I){return I*(S+C)}if(b.length===0)return k(x);{let I=0;const A=jr(N,0);let R=0,P=0;for(;R<x;){R++,I+=A;let L=b.length===P+1?1/0:b[P+1]-b[P]-1;R+L>x&&(I-=A,L=x-R+1),R+=L,I+=k(L),P++}return I}})),x=>{Pe(e,x),requestAnimationFrame(()=>{Pe(t,{top:x}),requestAnimationFrame(()=>{Pe(e,0),Pe(w,!1)})})}),{deviation:e}},tt(yt,$r,Fn,Qt,xn,di)),xx=Ke(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(gi,ux,wn,Tc,bc,dx,ix,vi,Sc,xn,yc)),Ec=Ke(([{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:w},v,g,x,{listState:b,topItemsIndexes:S,...N},{scrollToIndex:C},k,{topItemCount:I},{groupCounts:A},R])=>(me(N.rangeChanged,R.scrollSeekRangeChanged),me(z(R.windowViewportRect,oe(P=>P.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...N,...R,...v,sizes:l,...g}),tt(Qt,Mr,yt,fx,cx,Fn,Or,gx,px,fc,xx));function vx(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 Io=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Ic(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,x){g.propsReady&&Pe(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Pe(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Pe(S,x[b])}g.propsReady&&Pe(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const N=g[t.methods[b]];Pe(N,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Og(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[N]=y.useState(()=>wo(Dg(e),I=>{l(I,S)})),[C]=y.useState(Xl(d,N));Io(()=>{for(const I of i)I in S&&Xe(C[I],S[I]);return()=>{Object.values(C).map(oi)}},[S,C,N]),Io(()=>{l(N,S)}),y.useImperativeHandle(x,Gl(u(N)));const k=n;return c.jsx(a.Provider,{value:N,children:n?c.jsx(k,{...vx([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Pe(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>Xe(x,S),[x]);return y.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Xl(lt,x));return Io(()=>Xe(x,N=>{N!==b&&S(Gl(N))}),[x,b]),b},v=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Io(()=>Xe(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Nc=y.createContext(void 0),Ac=y.createContext(void 0),_c=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wi(e){return"self"in e}function wx(e){return"body"in e}function jc(e,t,n,r=sr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,w,v;const g=h.target;if(wx(g)||wi(g)){const b=wi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(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 w=h.behavior==="smooth";let v,g,x;wi(p)?(g=Math.max(vn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],v=vn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),pc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(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 bi="-webkit-sticky",Rc="sticky",yi=kc(()=>{if(typeof document>"u")return Rc;const e=document.createElement("div");return e.style.position=bi,e.style.position===bi?bi:Rc});function Si(e){return e}const bx=Ke(()=>{const e=X(a=>`Item ${a}`),t=X(a=>`Group ${a}`),n=X({}),r=X(Si),o=X("div"),s=X(sr),i=(a,l=null)=>vt(z(n,oe(u=>u[a]),nt()),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")}}),yx=Ke(([e,t])=>({...e,...t}),tt(Ec,bx)),Sx=({height:e})=>c.jsx("div",{style:{height:e}}),Cx={overflowAnchor:"none",position:yi(),zIndex:1},Pc={overflowAnchor:"none"},Tx={...Pc,display:"inline-block",height:"100%"},Oc=y.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Mt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Mt("windowScrollContainerState"),i=Mt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),u=_e("context"),d=_e("groupContent"),f=_e("trackItemSizes"),h=_e("itemSize"),p=_e("log"),w=Mt("gap"),v=_e("horizontalDirection"),{callbackRef:g}=Fg(n,h,f,e?sr:a,p,w,o,v,_e("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);Ci("deviation",M=>{x!==M&&b(M)});const S=_e("EmptyPlaceholder"),N=_e("ScrollSeekPlaceholder")||Sx,C=_e("ListComponent"),k=_e("ItemComponent"),I=_e("GroupComponent"),A=_e("computeItemKey"),R=_e("isSeeking"),P=_e("groupIndices").length>0,L=_e("alignToBottom"),$=_e("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...wt(S,u)}):c.jsx(C,{...wt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(M=>{const q=M.originalIndex,V=A(q+t.firstItemIndex,M.data,u);return R?y.createElement(N,{...wt(N,u),height:M.size,index:M.index,key:V,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(I,{...wt(I,u),"data-index":q,"data-item-index":M.index,"data-known-size":M.size,key:V,style:Cx},d(M.index,u)):y.createElement(k,{...wt(k,u),...Nx(k,M.data),"data-index":q,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:V,style:v?Tx:Pc},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),kx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ex={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ix={position:yi(),top:0,width:"100%",zIndex:1};function wt(e,t){if(typeof e!="string")return{context:t}}function Nx(e,t){return{item:typeof e=="string"?void 0:t}}const Ax=y.memo(function(){const e=_e("HeaderComponent"),t=Mt("headerHeight"),n=_e("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),_x=y.memo(function(){const e=_e("FooterComponent"),t=Mt("footerHeight"),n=_e("HeaderFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null});function Mc({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:w}=jc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Ex:kx,...o},tabIndex:0,...i,...wt(l,s),children:r})})}function Dc({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),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=jc(a,u,l,w,h);return _c(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...wt(l,s),children:r})})}const jx=({children:e})=>{const t=y.useContext(Nc),n=Mt("viewportHeight"),r=Mt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=y.useMemo(()=>Yl(n,l=>vn(l,s?"width":"height")),[n,s]),a=Ln(i,!0,_e("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:No(o),children:e})},Rx=({children:e})=>{const t=y.useContext(Nc),n=Mt("windowViewportRect"),r=Mt("fixedItemHeight"),o=_e("customScrollParent"),s=ec(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("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:No(i),children:e})},Px=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...Ix,marginTop:`${n}px`},o=_e("context");return c.jsx(t,{style:r,...wt(t,o),children:e})},Ox=y.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return c.jsxs(r||t?Lx:Dx,{...e,context:o,children:[n&&c.jsx(Px,{children:c.jsx(Oc,{showTopList:!0})}),c.jsxs(r||t?Rx:jx,{children:[c.jsx(Ax,{}),c.jsx(Oc,{}),c.jsx(_x,{})]})]})}),{Component:Mx,useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}=Ic(yx,{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"}},Ox),Dx=Mc({useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}),Lx=Dc({useEmitter:Ci,useEmitterValue:_e,usePublisher:Mt}),$x=Mx;tt(Ec,Ke(()=>{const e=X(u=>c.jsxs("td",{children:["Item $",u]})),t=X(null),n=X(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=X(null),o=X(null),s=X({}),i=X(Si),a=X(sr),l=(u,d=null)=>vt(z(s,oe(f=>f[u]),nt()),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")}})),yi();const Lc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Fx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$c,floor:Ao,max:Fr,min:Ti,round:Fc}=Math;function Bc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Bx(e){return{...Fx,items:e}}function _o(e,t){return e&&e.width===t.width&&e.height===t.height}function zx(e,t){return e&&e.column===t.column&&e.row===t.row}const Hx=Ke(([{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:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N},C])=>{const k=X(0),I=X(0),A=X(Lc),R=X({height:0,width:0}),P=X({height:0,width:0}),L=Fe(),$=Fe(),H=X(0),M=X(null),q=X({column:0,row:0}),V=Fe(),Y=Fe(),B=X(!1),j=X(0),G=X(!0),Z=X(!1),ge=X(!1);Xe(z(w,Me(j),Ee(([D,J])=>!!J)),()=>{Pe(G,!1)}),Xe(z(ut(w,G,P,R,j,Z),Ee(([D,J,U,fe,,ue])=>D&&!J&&U.height!==0&&fe.height!==0&&!ue)),([,,,,D])=>{Pe(Z,!0),pi(1,()=>{Pe(L,D)}),Ut(z(u),()=>{Pe(t,[0,0]),Pe(G,!0)})}),me(z(Y,Ee(D=>D!=null&&D.scrollTop>0),Jt(0)),I),Xe(z(w,Me(Y),Ee(([,D])=>D!=null)),([,D])=>{D&&(Pe(R,D.viewport),Pe(P,D.item),Pe(q,D.gap),D.scrollTop>0&&(Pe(B,!0),Ut(z(u,Dn(1)),J=>{Pe(B,!1)}),Pe(l,{top:D.scrollTop})))}),me(z(R,oe(({height:D})=>D)),f),me(z(ut(Ce(R,_o),Ce(P,_o),Ce(q,(D,J)=>D&&D.column===J.column&&D.row===J.row),Ce(u)),oe(([D,J,U,fe])=>({gap:U,item:J,scrollTop:fe,viewport:D}))),V),me(z(ut(Ce(k),r,Ce(q,zx),Ce(P,_o),Ce(R,_o),Ce(M),Ce(I),Ce(B),Ce(G),Ce(j)),Ee(([,,,,,,,D])=>!D),oe(([D,[J,U],fe,ue,$e,Ge,qe,,ke,Oe])=>{const{column:Be,row:Ue}=fe,{height:st,width:ot}=ue,{width:ne}=$e;if(qe===0&&(D===0||ne===0))return Lc;if(ot===0){const gt=mi(Oe,D),hn=gt+Math.max(qe-1,0);return Bx(Bc(gt,hn,Ge))}const le=zc(ne,ot,Be);let xe,Se;ke?J===0&&U===0&&qe>0?(xe=0,Se=qe-1):(xe=le*Ao((J+Ue)/(st+Ue)),Se=le*$c((U+Ue)/(st+Ue))-1,Se=Ti(D-1,Fr(Se,le-1)),xe=Ti(Se,Fr(0,xe))):(xe=0,Se=-1);const be=Bc(xe,Se,Ge),{bottom:je,top:Qe}=Hc($e,fe,ue,be),Ye=$c(D/le),it=Ye*st+(Ye-1)*Ue-je;return{bottom:je,itemHeight:st,items:be,itemWidth:ot,offsetBottom:it,offsetTop:Qe,top:Qe}})),A),me(z(M,Ee(D=>D!==null),oe(D=>D.length)),k),me(z(ut(R,P,A,q),Ee(([D,J,{items:U}])=>U.length>0&&J.height!==0&&D.height!==0),oe(([D,J,{items:U},fe])=>{const{bottom:ue,top:$e}=Hc(D,fe,J,U);return[$e,ue]}),nt(Rr)),t);const de=X(!1);me(z(u,Me(de),oe(([D,J])=>J||D!==0)),de);const ee=At(z(ut(A,k),Ee(([{items:D}])=>D.length>0),Me(de),Ee(([[D,J],U])=>{const fe=D.items[D.items.length-1].index===J-1;return(U||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===J)&&fe}),oe(([[,D]])=>D-1),nt())),Ae=At(z(Ce(A),Ee(({items:D})=>D.length>0&&D[0].index===0),Jt(0),nt())),Te=At(z(Ce(A),Me(B),Ee(([{items:D},J])=>D.length>0&&!J),oe(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),nt(ac),un(0)));me(Te,p.scrollSeekRangeChanged),me(z(L,Me(R,P,k,q),oe(([D,J,U,fe,ue])=>{const $e=hc(D),{align:Ge,behavior:qe,offset:ke}=$e;let Oe=$e.index;Oe==="LAST"&&(Oe=fe-1),Oe=Fr(0,Oe,Ti(fe-1,Oe));let Be=ki(J,ue,U,Oe);return Ge==="end"?Be=Fc(Be-J.height+U.height):Ge==="center"&&(Be=Fc(Be-J.height/2+U.height/2)),ke&&(Be+=ke),{behavior:qe,top:Be}})),l);const K=vt(z(A,oe(D=>D.offsetBottom+D.bottom)),0);return me(z(N,oe(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:g,data:M,deviation:H,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:P,overscan:n,restoreStateFrom:Y,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:N,...p,gridState:A,horizontalDirection:ge,initialTopMostItemIndex:j,totalListHeight:K,...h,endReached:ee,propsReady:v,rangeChanged:Te,startReached:Ae,stateChanged:V,stateRestoreInProgress:B,...C}},tt(gi,yt,$r,Tc,wn,vi,xn));function zc(e,t,n){return Fr(1,Ao((e+n)/(Ao(t)+n)))}function Hc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ki(e,t,n,r[0].index);return{bottom:ki(e,t,n,r[r.length-1].index)+o,top:s}}function ki(e,t,n,r){const o=zc(e.width,n.width,t.column),s=Ao(r/o),i=s*n.height+Fr(0,s-1)*t.row;return i>0?i+t.row:i}const Ux=Ke(()=>{const e=X(f=>`Item ${f}`),t=X({}),n=X(null),r=X("virtuoso-grid-item"),o=X("virtuoso-grid-list"),s=X(Si),i=X("div"),a=X(sr),l=(f,h=null)=>vt(z(t,oe(p=>p[f]),nt()),h),u=X(!1),d=X(!1);return me(Ce(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")}}),Wx=Ke(([e,t])=>({...e,...t}),tt(Hx,Ux)),Vx=y.memo(function(){const e=rt("gridState"),t=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),o=rt("computeItemKey"),s=rt("isSeeking"),i=Dt("scrollHeight"),a=rt("ItemComponent"),l=rt("ListComponent"),u=rt("ScrollSeekPlaceholder"),d=rt("context"),f=Dt("itemDimensions"),h=Dt("gap"),p=rt("log"),w=rt("stateRestoreInProgress"),v=Dt("reportReadyState"),g=Ln(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:N,width:C}=S.getBoundingClientRect();f({height:N,width:C})}h({column:Wc("column-gap",getComputedStyle(x).columnGap,p),row:Wc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return _c(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...wt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...wt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...wt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Kx=y.memo(function(){const e=rt("HeaderComponent"),t=Dt("headerHeight"),n=rt("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),qx=y.memo(function(){const e=rt("FooterComponent"),t=Dt("footerHeight"),n=rt("headerFooterTag"),r=Ln(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...wt(e,o)})}):null}),Gx=({children:e})=>{const t=y.useContext(Ac),n=Dt("itemDimensions"),r=Dt("viewportDimensions"),o=Ln(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:No(!1),children:e})},Yx=({children:e})=>{const t=y.useContext(Ac),n=Dt("windowViewportRect"),r=Dt("itemDimensions"),o=rt("customScrollParent"),s=ec(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:No(!1),children:e})},Xx=y.memo(function({...e}){const t=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||t?Zx:Jx,o=n||t?Yx:Gx,s=rt("context");return c.jsx(r,{...e,...wt(r,s),children:c.jsxs(o,{children:[c.jsx(Kx,{}),c.jsx(Vx,{}),c.jsx(qx,{})]})})}),{useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt}=Ic(Wx,{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"}},Xx),Jx=Mc({useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt}),Zx=Dc({useEmitter:Uc,useEmitterValue:rt,usePublisher:Dt});function Wc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}const Qx=no.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 Ei({className:e,variant:t,...n}){return c.jsx("div",{className:Q(Qx({variant:t}),e),...n})}function ce(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 ev(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 en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=m.useContext(p);if(w)return w;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,tv(o,...t)]}function tv(...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 pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},nv=m[" useInsertionEffect ".trim().toString()]||pt;function Bn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=rv({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=ov(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 rv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return nv(()=>{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 ov(e){return typeof e=="function"}function Vc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ii(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Vc(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():Vc(e[o],null)}}}}function Le(...e){return m.useCallback(Ii(...e),e)}var sv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=sv.reduce((e,t)=>{const n=Rn.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 Kc(e,t){e&&ro.flushSync(()=>e.dispatchEvent(t))}function iv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var jt=e=>{const{present:t,children:n}=e,r=av(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Le(r.ref,lv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};jt.displayName="Presence";function av(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=iv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=jo(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=jo(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]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(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=jo(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 jo(e){return(e==null?void 0:e.animationName)||"none"}function lv(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 cv=m[" useId ".trim().toString()]||(()=>{}),uv=0;function tn(e){const[t,n]=m.useState(cv());return pt(()=>{n(r=>r??String(uv++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[dv,GC]=en(Ro),[fv,Ni]=dv(Ro),qc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Bn({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return c.jsx(fv,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ie.div,{"data-state":_i(l),"data-disabled":s?"":void 0,...a,ref:t})})});qc.displayName=Ro;var Gc="CollapsibleTrigger",Yc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ni(Gc,n);return c.jsx(Ie.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":_i(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ce(e.onClick,o.onOpenToggle)})});Yc.displayName=Gc;var Ai="CollapsibleContent",hv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ni(Ai,e.__scopeCollapsible);return c.jsx(jt,{present:n||o.open,children:({present:s})=>c.jsx(pv,{...r,ref:t,present:s})})});hv.displayName=Ai;var pv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ni(Ai,n),[a,l]=m.useState(r),u=m.useRef(null),d=Le(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(Ie.div,{"data-state":_i(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function _i(e){return e?"open":"closed"}var mv=qc;const Xc=mv,Jc=Yc,Br=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Br.displayName="Card";const zr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));zr.displayName="CardHeader";const Hr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));Hr.displayName="CardTitle";const Zc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Zc.displayName="CardDescription";const Po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Po.displayName="CardContent";const Qc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Qc.displayName="CardFooter";function eu(){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 zn=eu();function gv(e){zn=e}const tu=/[&<>"']/,xv=new RegExp(tu.source,"g"),nu=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vv=new RegExp(nu.source,"g"),wv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ru=e=>wv[e];function bt(e,t){if(t){if(tu.test(e))return e.replace(xv,ru)}else if(nu.test(e))return e.replace(vv,ru);return e}const bv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ou(e){return e.replace(bv,(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 yv=/(^|[^\[])\^/g;function Ze(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Sv=/[^\w:]/g,Cv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function su(e,t,n){if(e){let r;try{r=decodeURIComponent(ou(n)).replace(Sv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Cv.test(n)&&(n=Iv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},Tv=/^[^:]+:\/*[^/]*$/,kv=/^([^:]+:)[\s\S]*$/,Ev=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Iv(e,t){Oo[" "+e]||(Tv.test(e)?Oo[" "+e]=e+"/":Oo[" "+e]=Do(e,"/",!0)),e=Oo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Ev,"$1")+t:e+t}const Mo={exec:function(){}};function iu(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 Do(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 Nv(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 Av(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 au(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function lu(e,t,n,r){const o=t.href,s=t.title?bt(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:bt(i)}}function _v(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
32
+ `))>=0;){const re=V.slice(0,ne);V=V.slice(ne+2);const ve=mg(re);if(!ve)continue;let Ee;try{Ee=JSON.parse(ve)}catch{console.debug("[use-chat] malformed SSE:",ve.slice(0,200));continue}const Se=pg(Ee)?Ee.data:Ee;ze=Date.now();const Ae=Se.seq;if(Ae!==void 0){if(Ae<=J){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ae,lastProcessedSeq:J,type:Se.type});continue}J>0&&Ae>J+1&&((_=$==null?void 0:$.onGap)==null||_.call($,{from:J,to:Ae})),J=Ae,C.current=Ae,g(Ae)}if(L==null||L(Se),Se.type==="token"&&e.autoAppendAssistant!==!1)D.push(Se.content),ce();else if(Se.type==="message_delta"){const Ze=Se.delta.filter(Ye=>Ye.type==="text").map(Ye=>Ye.text).join("");Ze&&e.autoAppendAssistant!==!1&&(D.push(Ze),ce())}else Se.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(U!==null&&cancelAnimationFrame(U),de(),Se.type==="checkpoint"?w(Se.checkpointId):Se.type==="error"&&d(Se.message))}}de()}catch(ke){if(ke.name!=="AbortError"){const De=ke.message||String(ke);d(De),(q=$==null?void 0:$.onError)==null||q.call($,De)}}finally{try{await je.cancel()}catch{}finally{(Q=je.releaseLock)==null||Q.call(je)}U!==null&&typeof window<"u"&&window.cancelAnimationFrame(U),clearInterval(Xe),l(!1),b(!1),S.current=null,C.current=0,g(0)}}catch(ue){if(ue.name!=="AbortError"){const te=ue.message||String(ue);d(te),(xe=$==null?void 0:$.onError)==null||xe.call($,te)}}finally{l(!1),b(!1),S.current=null,C.current=0,g(0)}})(),{close:()=>H.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;E.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:j,stop:I,clear:A,setToken:k}}function pg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function mg(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(`
33
+ `)}function gg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=y.useRef(null),i=y.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(sg(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Dl({baseUrl:e,token:null}),h=y.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return y.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ll=y.createContext(null),$l=y.createContext(null),Fl=y.createContext(null),xg=y.createContext(!1),vg=20,wg="cachedThreads",bg="v1",Zs=300,Bl=200;function yg(e){if(typeof window<"u"&&"requestIdleCallback"in window)try{window.requestIdleCallback(e,{timeout:1e3});return}catch{}window.setTimeout(e,Zs)}function _r(){return typeof window<"u"&&typeof window.localStorage<"u"}function Qs(e){if(!_r())return null;try{return window.localStorage.getItem(e)}catch{return null}}function zl(e,t){if(_r())try{window.localStorage.setItem(e,t)}catch{}}function Hl(e){if(_r())try{window.localStorage.removeItem(e)}catch{}}function Sg(){const e=Qs(wg);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 Cg(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 ei(e,t){return`cachedThreads:v1:${e}:${Cg(t||"anon")}`}function Tg(e){const t=Qs(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 Ul(e,t){try{zl(e,JSON.stringify(t))}catch{}}function Wl(e){const t=Tg(e);if(t.length>0)return t;const n=Sg();if(n.length>0)try{Ul(e,n.slice(0,Bl))}catch{}return n}function ti(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 Vl(e){return e.order.map(t=>e.byId[t]).filter(Boolean)}function kg({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}=Gs(),d=y.useMemo(()=>cn(u),[u]),f=y.useMemo(()=>{try{return new URL(u).host}catch{return"unknown"}},[u]),h=y.useMemo(()=>`threadPayload:${bg}:${f}:`,[f]),p=y.useCallback(N=>`${h}${N}`,[h]),w=y.useCallback(N=>{if(!N||typeof N!="object")return null;const R=N;return typeof R.threadId!="string"||!Array.isArray(R.messages)?null:{threadId:R.threadId,messages:R.messages,hasMore:!!R.hasMore,nextCursor:R.nextCursor??null,checkpointId:R.checkpointId??null,checkpointNs:R.checkpointNs??null}},[]),v=y.useCallback(N=>{const R=Qs(p(N));if(!R)return null;try{const Z=JSON.parse(R);return w(Z)}catch{return null}},[p,w]),g=y.useCallback((N,R=100)=>{const Z={...N,messages:Array.isArray(N.messages)?N.messages.slice(-R):[]};try{zl(p(N.threadId),JSON.stringify(Z))}catch{}},[p]),x=y.useCallback(N=>{Hl(p(N))},[p]),b=y.useCallback(()=>{if(_r())try{const N=h;for(let R=0;R<window.localStorage.length;R++){const Z=window.localStorage.key(R);Z&&Z.startsWith(N)&&window.localStorage.removeItem(Z)}}catch{}},[h]),[S,E]=y.useState(()=>{var N;return ei(f,(N=l.getAuthToken)==null?void 0:N.call(l))}),[C,k]=y.useState(()=>{var R;const N=Wl(ei(f,(R=l.getAuthToken)==null?void 0:R.call(l)));return ti(N)}),I=y.useMemo(()=>Vl(C),[C]),[A,j]=y.useState(t),[P,L]=y.useState(!1),[$,H]=y.useState(!1),[M,K]=y.useState(!1),[W,G]=y.useState(!1),[B,_]=y.useState(null),[q,Q]=y.useState(void 0),[xe,ue]=y.useState(void 0),{state:te,seed:je,prepend:Te,pushUser:V,onEvent:D,reset:J}=Ol(),U=y.useRef(A);y.useEffect(()=>{U.current=A},[A]);const de=y.useRef(!1),ce=y.useRef([]),ze=y.useRef(null),Xe=y.useRef(null),Ge=y.useRef(new Map),ke=y.useRef(A),De=y.useRef(!1),nt=y.useRef(null),He=y.useCallback((N,R)=>new Promise((Z,pe)=>{const ge=async()=>{de.current=!0;try{await N(),Z()}catch(fe){pe(fe)}finally{de.current=!1;const fe=ce.current.shift();fe&&fe().catch(()=>{})}};de.current?ce.current.push(ge):ge().catch(fe=>{pe(fe)})}),[]),Je=y.useCallback(async()=>{const N=I.length>0;N||L(!0);try{const R=await l.listThreads();y.startTransition(()=>{k(Z=>{const pe=T=>T.map(F=>`${F.threadId}:${F.updatedAt??""}:${F.messageCount??""}`).join("|"),ge=Vl(Z);return pe(ge)===pe(R)?Z:ti(R)})})}catch(R){i==null||i(String(R)),console.error("[ChatSessionProvider] Failed to refresh threads:",R)}finally{N||L(!1)}},[l,i,I.length]),dt=y.useRef(!1),ne=y.useRef(null),re=y.useRef(null),ve=y.useRef(""),Ee=y.useCallback((N,R,Z)=>{const pe=Array.isArray(N==null?void 0:N.messages)?N.messages:[],ge=Z??(N==null?void 0:N.threadId)??U.current;if(R==="replace"){if(ge){const fe={threadId:ge,messages:pe.slice(),hasMore:!!(N!=null&&N.hasMore),nextCursor:(N==null?void 0:N.nextCursor)??null,checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null};Ge.current.set(ge,fe),ke.current=ge}je(pe,{checkpointId:(N==null?void 0:N.checkpointId)??null,checkpointNs:(N==null?void 0:N.checkpointNs)??null})}else if(R==="prepend"&&pe.length&&ge){const fe=Ge.current.get(ge),T=(fe==null?void 0:fe.messages)??[],F=new Set,X=[...pe,...T].filter(Ue=>{const Ke=Ue==null?void 0:Ue.id;return Ke?F.has(Ke)?!1:(F.add(Ke),!0):!0}),he={threadId:ge,messages:X,hasMore:(N==null?void 0:N.hasMore)??(fe==null?void 0:fe.hasMore)??!1,nextCursor:(N==null?void 0:N.nextCursor)??(fe==null?void 0:fe.nextCursor)??null,checkpointId:(fe==null?void 0:fe.checkpointId)??(N==null?void 0:N.checkpointId)??null,checkpointNs:(fe==null?void 0:fe.checkpointNs)??(N==null?void 0:N.checkpointNs)??null};Ge.current.set(ge,he),Te(pe)}else R==="prepend"&&pe.length&&Te(pe);R==="replace"?(_((N==null?void 0:N.nextCursor)??null),K(!!(N!=null&&N.hasMore)),Q((N==null?void 0:N.checkpointId)??void 0),ue((N==null?void 0:N.checkpointNs)??void 0)):(_(fe=>(N==null?void 0:N.nextCursor)??fe??null),K(fe=>(N==null?void 0:N.hasMore)!==void 0?!!(N!=null&&N.hasMore):fe),Q(fe=>(N==null?void 0:N.checkpointId)??fe??void 0),ue(fe=>(N==null?void 0:N.checkpointNs)??fe??void 0))},[Te,je]),Se=y.useCallback(N=>{je(N.messages,{checkpointId:N.checkpointId,checkpointNs:N.checkpointNs}),_(N.nextCursor),K(N.hasMore),Q(N.checkpointId??void 0),ue(N.checkpointNs??void 0),ke.current=N.threadId},[je]),Ae=y.useCallback(N=>{N&&(Ge.current.delete(N),x(N),ke.current===N&&(ke.current=null))},[x]),Ze=y.useCallback(()=>{const N=U.current;N&&Ae(N),J([]),K(!1),G(!1),_(null),Q(void 0),ue(void 0)},[Ae,J]),Ye=y.useCallback(({from:N,to:R})=>{const Z=U.current;Z&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${N} -> ${R}) for thread ${Z}`)},[]),ct=y.useCallback(N=>{const R=N.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:R,title:N.title,created:N.created,currentThreads:I.length});const Z={threadId:R,title:N.title||`Thread ${R.slice(0,8)}`,createdAt:N.createdAt||new Date().toISOString(),updatedAt:N.updatedAt||new Date().toISOString(),messageCount:N.messageCount||0};U.current!==R&&(!U.current&&te.messages.length<=1&&(Xe.current=R),j(R)),y.startTransition(()=>{k(pe=>{const ge=pe.byId[R];return ge?ge.title===Z.title&&ge.updatedAt===Z.updatedAt&&ge.messageCount===Z.messageCount?pe:{byId:{...pe.byId,[R]:Z},order:pe.order}:{byId:{...pe.byId,[R]:Z},order:[R,...pe.order]}})})},[te.messages.length]),{startStream:Ct,stop:hn,isStreaming:Nn,error:vr,setAuthToken:An}=gg({baseUrl:d,onThreadInfo:ct,onMessageEvent:D,onUnhandledEvent:N=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${N.type}`,N)},onSequenceGap:Ye});y.useEffect(()=>{dt.current=Nn},[Nn]),y.useEffect(()=>{if(!_r())return;re.current!==null&&(window.clearTimeout(re.current),re.current=null);const N=I.map(Z=>`${Z.threadId}:${Z.updatedAt??""}:${Z.messageCount??""}`).join("|");if(I.length===0){try{Hl(S)}catch{}ve.current="";return}if(N===ve.current)return;const R=()=>{try{const Z=I.slice(0,Bl);Ul(S,Z),ve.current=N}catch{}finally{re.current=null}};return re.current=window.setTimeout(()=>{yg(R)},Zs),()=>{re.current!==null&&(window.clearTimeout(re.current),re.current=null)}},[I,S]),y.useEffect(()=>{var pe;const N=l.getAuthToken();An(N);const R=ge=>{const fe=ei(f,ge);nt.current!==fe&&(nt.current=fe,De.current=!1),E(fe);const T=Wl(fe);y.startTransition(()=>{k(ti(T))}),De.current||(De.current=!0,Je().catch(()=>{}))};R(N);const Z=(pe=l.onTokenChange)==null?void 0:pe.call(l,ge=>{An(ge),b(),R(ge)});return()=>{Z==null||Z()}},[l,f,An,b,Je]);const _n=y.useCallback(async N=>{const R=`temp-${Date.now()}`,Z={threadId:R,title:N||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};k(pe=>({byId:{...pe.byId,[R]:Z},order:[R,...pe.order]})),j(R);try{const pe=await l.createThread(N),ge=typeof pe=="string"?pe:pe.threadId;return k(fe=>{const T=fe.byId[R];if(!T)return fe;const F={...fe.byId};delete F[R],F[ge]={...T,threadId:ge};const X=fe.order.map(he=>he===R?ge:he);return{byId:F,order:X}}),j(ge),setTimeout(()=>Je(),10),ge}catch(pe){throw k(ge=>{if(!ge.byId[R])return ge;const fe={...ge.byId};delete fe[R];const T=ge.order.filter(F=>F!==R);return{byId:fe,order:T}}),j(null),pe}},[l,Je]),wr=y.useCallback(async N=>{await l.deleteThread(N),k(R=>{if(!R.byId[N])return R;const Z={...R.byId};delete Z[N];const pe=R.order.filter(ge=>ge!==N);return{byId:Z,order:pe}}),Ae(N),U.current===N&&(Xe.current=N,j(null),U.current=null,ke.current=null,Ze()),await Je()},[l,Ze,Ae,Je]),jn=y.useCallback(async(N,R)=>{try{await l.updateThread(N,R),k(Z=>{const pe=Z.byId[N];return pe?{byId:{...Z.byId,[N]:{...pe,title:R}},order:Z.order}:Z})}catch(Z){throw await Je(),Z}},[l,Je]),Ot=y.useCallback(async(N,R,Z,pe=!1)=>{await He(async()=>{if(Xe.current===N&&!pe){Xe.current=null;return}if(ze.current===N&&!pe)return;j(X=>X===N?X:N),U.current=N;const ge=!pe&&!R&&!Z;let fe=!1;if(ge){const X=Ge.current.get(N);if(X)Se(X),fe=!0;else{const he=v(N);he&&(Ge.current.set(N,he),Se(he),fe=!0)}}const T=pe||!fe||!!R||!!Z,F=async X=>{X&&H(!0),ze.current=N;try{const he=await l.getMessages({threadId:N,checkpointId:R,checkpointNs:Z});Ee(he,"replace",N)}catch(he){throw(!fe||pe||X)&&(i==null||i(String(he))),he}finally{ze.current=null,X&&H(!1)}};T?await F(!0):ge&&fe&&F(!1).catch(X=>{console.warn("[ChatSessionProvider] Background refresh failed:",X)})},`loadThread-${N}`)},[l,Se,Ee,He,i]),Yt=y.useCallback(async()=>{await He(async()=>{const N=U.current;N&&Ae(N),Xe.current=null,j(null),U.current=null,ke.current=null,Ze(),Q(void 0),ue(void 0);try{localStorage.removeItem("lastThreadId")}catch(R){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",R)}},"clearCurrentThread")},[Ze,Ae,He]),Rn=y.useCallback(async N=>{const R=await l.listCheckpoints(N);return ng(R,N)},[l]),Pn=y.useCallback(async(N,R)=>{if(!U.current)throw new Error("No active thread");await Ot(U.current,N,R??void 0,!0)},[Ot]),Qn=y.useCallback(async()=>{if(!U.current)throw new Error("No active thread");await Ot(U.current,void 0,void 0,!0)},[Ot]),br=y.useCallback(async N=>{if(!U.current)throw new Error("No active thread");if(W||!M)return;const R=B;if(R){G(!0);try{const Z=U.current,pe=await l.getMessages({threadId:Z,checkpointId:q,checkpointNs:xe,limit:(N==null?void 0:N.limit)??vg,beforeId:R});Ee(pe,"prepend",Z??void 0)}finally{G(!1)}}},[l,Ee,M,q,xe,B,W]),er=y.useCallback(async(N,R)=>{var Fe;const Z=U.current;!Z&&!(R!=null&&R.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const pe=(R==null?void 0:R.attachments)||[],{contentParts:ge,filesInfo:fe}=await og(l,pe),T=[...ge];N&&N.trim()&&T.push({type:"text",text:N.trim()});const F={id:((Fe=crypto.randomUUID)==null?void 0:Fe.call(crypto))||`user-${Date.now()}`,role:"user",content:T,createdAt:new Date().toISOString(),checkpointId:(R==null?void 0:R.checkpointId)??te.lastCheckpointId??void 0,checkpointNs:(R==null?void 0:R.checkpointNs)??te.lastCheckpointNs??void 0};V(F);const X={...F,content:T},he={...(R==null?void 0:R.payloadExtras)??{}},Ue=pe.length>0,Ke={...Z?{threadId:Z}:{},payload:{messages:[X],files_info:fe,...o&&Ue&&s?{active_agent:s}:{},...he},checkpointId:(R==null?void 0:R.checkpointId)??te.lastCheckpointId??void 0,checkpointNs:(R==null?void 0:R.checkpointNs)??te.lastCheckpointNs??void 0,nodeFilter:R==null?void 0:R.nodeFilter,config:R==null?void 0:R.config};Ct(Ke,{onError:Oe=>{console.warn("[ChatSessionProvider] Stream error:",Oe)},onOpen:({threadId:Oe,created:bt})=>{!U.current&&Oe&&(te.messages.length<=1&&(Xe.current=Oe),j(Oe))},onGap:Ye})},[l,o,s,Ye,te.lastCheckpointId,te.lastCheckpointNs,te.messages.length,V,Ct]),yr=y.useCallback(async(N,R,Z)=>{const pe=U.current;if(!pe)throw new Error("No active thread to handle interrupt");try{const ge=R?Z??!0:!1;await l.resume({threadId:pe,value:ge})}catch(ge){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${N}:`,ge),ge}},[l]);y.useEffect(()=>{if(a==null||a(A),A)try{localStorage.setItem("lastThreadId",A)}catch(N){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",N)}},[A,a]),y.useEffect(()=>((async()=>{try{if(Je().catch(R=>{console.error("[ChatSessionProvider] Failed to refresh threads (background):",R),i==null||i(String(R))}),!r&&!t)try{const R=localStorage.getItem("lastThreadId");R&&(j(R),n&&await Ot(R))}catch(R){console.warn("[ChatSessionProvider] Failed to restore last thread:",R)}else t&&n&&await Ot(t)}catch(R){console.error("[ChatSessionProvider] Initialization failed:",R),i==null||i(String(R))}})(),()=>{}),[]),y.useEffect(()=>{const N=U.current;if(!N||ke.current!==N)return;const R={threadId:N,messages:te.messages.slice(),hasMore:M,nextCursor:B,checkpointId:te.lastCheckpointId??null,checkpointNs:te.lastCheckpointNs??null},Z=Ge.current.get(N);(!Z||Z.messages.length!==R.messages.length||Z.messages.some((ge,fe)=>{var T;return(ge==null?void 0:ge.id)!==((T=R.messages[fe])==null?void 0:T.id)})||(Z==null?void 0:Z.hasMore)!==R.hasMore||(Z==null?void 0:Z.nextCursor)!==R.nextCursor||(Z==null?void 0:Z.checkpointId)!==R.checkpointId||(Z==null?void 0:Z.checkpointNs)!==R.checkpointNs)&&(Ge.current.set(N,R),ne.current&&window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{try{g(R,100)}catch(ge){console.warn("[ChatSessionProvider] Failed to persist thread payload:",ge)}},Zs))},[M,B,te.lastCheckpointId,te.lastCheckpointNs,te.messages]);const ie=y.useMemo(()=>({threads:I,currentThreadId:A,isLoadingThreads:P,isLoadingThread:$,setCurrentThreadId:j,createThread:_n,deleteThread:wr,renameThread:jn,refreshThreads:Je,loadThread:Ot,clearCurrentThread:Yt,listCheckpoints:Rn,navigateToCheckpoint:Pn,returnToLatest:Qn}),[Yt,_n,A,wr,$,P,Rn,Ot,Pn,Je,jn,Qn,I]),ye=y.useMemo(()=>({messages:te.messages,assemblingId:te.assemblingId,lastUserMessage:null,hasMoreHistory:M,isLoadingHistory:W,send:er,stop:hn,loadOlderMessages:br,clearMessages:Ze,handleInterrupt:yr}),[Ze,yr,M,W,br,te.assemblingId,te.messages,er,hn]),$e=y.useMemo(()=>({isStreaming:Nn,error:vr,streamingAssistantId:te.assemblingId,lastCheckpointId:te.lastCheckpointId??null,lastCheckpointNs:te.lastCheckpointNs??null}),[Nn,te.assemblingId,te.lastCheckpointId,te.lastCheckpointNs,vr]);return c.jsx(xg.Provider,{value:!0,children:c.jsx(Fl.Provider,{value:$e,children:c.jsx(Ll.Provider,{value:ie,children:c.jsx($l.Provider,{value:ye,children:e})})})})}function go(){const e=y.useContext(Ll);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function ni(){const e=y.useContext($l);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Kl(){const e=y.useContext(Fl);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function xo({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(tg,{apiConfig:t,children:c.jsx(kg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function ee(...e){return _p.twMerge(Ap.clsx(e))}const Eg=no.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"}}),Ve=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?On.Slot:"button";return c.jsx(i,{className:ee(Eg({variant:t,size:n,className:e})),ref:s,...o})});Ve.displayName="Button";const ql=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}));ql.displayName="Textarea";function Ig({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),[w,v]=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 x=y.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const b=y.useCallback(async A=>{A&&A.preventDefault();const j=(h??"").trim();!j&&!f||v(()=>{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`)},[]),E=y.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`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 b(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(ql,{ref:g,value:h,onChange:S,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ve,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(oe.Square,{size:16})}):c.jsx(Ve,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(oe.Send,{size:16})})})]})})}const Ng=y.memo(Ig),vo=0,gn=1,or=2,Gl=4;function Yl(e){return()=>e}function Ag(e){e()}function Xl(e,t){return n=>e(t(n))}function Jl(e,t){return()=>e(t)}function _g(e,t){return n=>e(t,n)}function ri(e){return e!==void 0}function jg(...e){return()=>{e.map(Ag)}}function sr(){}function wo(e,t){return t(e),e}function Rg(e,t){return t(e)}function rt(...e){return e}function Qe(e,t){return e(gn,t)}function Me(e,t){e(vo,t)}function oi(e){e(or)}function lt(e){return e(Gl)}function me(e,t){return Qe(e,_g(t,vo))}function Ut(e,t){const n=e(gn,r=>{n(),t(r)});return n}function Zl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ql(e,t){return e===t}function ot(e=Ql){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function se(e){return t=>Xl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=Pg(...t);return(r,o)=>{switch(r){case or:oi(e);return;case gn:return Qe(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function $n(e){return t=>n=>{e>0?e--:t(n)}}function un(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);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 Pg(...e){return t=>e.reduceRight(Rg,t)}function Og(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case gn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),sr);case or:r(),n=null;return}}}function Y(e){let t=e;const n=We();return(r,o)=>{switch(r){case vo:t=o;break;case gn:{o(t);break}case Gl:return t}return n(r,o)}}function xt(e,t){return wo(Y(t),n=>me(e,n))}function We(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case or:e.splice(0,e.length);return;case gn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return wo(We(),t=>me(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Mg(),singleton:n}}const Mg=()=>Symbol();function Dg(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 ut(...e){const t=We(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case or:{oi(t);return}case gn:return r===o&&i(n),Qe(t,i)}}}function Ce(e,t=Ql){return z(e,ot(t))}function si(...e){return function(t,n){switch(t){case or:return;case gn:return jg(...e.map(r=>Qe(r,n)))}}}var Et=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Et||{});const Lg={0:"debug",3:"error",1:"log",2:"warn"},$g=()=>typeof globalThis>"u"?window:globalThis,xn=qe(()=>{const e=Y(3);return{log:Y((t,n,r=1)=>{var o;const s=(o=$g().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[Lg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Fn(e,t,n){return ii(e,t,n).callbackRef}function ii(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 Fg(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=Bg(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 w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?ec("column-gap",getComputedStyle(d).columnGap,o):ec("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ii(u,n,l)}function Bg(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},Et.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 ec(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}function tc(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(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+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}=ii(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 yt=qe(()=>{const e=We(),t=We(),n=Y(0),r=We(),o=Y(0),s=We(),i=We(),a=Y(0),l=Y(0),u=Y(0),d=Y(0),f=We(),h=We(),p=Y(!1),w=Y(!1),v=Y(!1);return me(z(e,se(({scrollTop:g})=>g)),t),me(z(e,se(({scrollHeight:g})=>g)),i),me(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),jr={lvl:0};function nc(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 et(e){return e===jr}function Rr(e,t){if(!et(e))return t===e.k?e.v:t<e.k?Rr(e.l,t):Rr(e.r,t)}function Wt(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Wt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Wt(e.l,t,n)}function _t(e,t,n){return et(e)?sc(t,n,1):t===e.k?ht(e,{k:t,v:n}):t<e.k?ic(ht(e,{l:_t(e.l,t,n)})):ic(ht(e,{r:_t(e.r,t,n)}))}function ir(){return jr}function bo(e,t,n){if(et(e))return[];const r=Wt(e,t)[0];return zg(li(e,r,n))}function ai(e,t){if(et(e))return jr;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=oc(r);return yo(ht(e,{k:s,l:rc(r),v:i}))}}else return t<n?yo(ht(e,{l:ai(r,t)})):yo(ht(e,{r:ai(o,t)}))}function Bn(e){return et(e)?[]:[...Bn(e.l),{k:e.k,v:e.v},...Bn(e.r)]}function li(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(li(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(li(s,t,n))),a}function yo(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(ci(t))return ac(ht(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return ht(t.r,{l:ht(t,{r:t.r.l}),lvl:n,r:ht(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ci(e))return ui(ht(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=ci(o)?r.lvl-1:r.lvl;return ht(o,{l:ht(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ui(ht(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ht(e,t){return sc(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 rc(e){return et(e.r)?e.l:yo(ht(e,{r:rc(e.r)}))}function ci(e){return et(e)||e.lvl>e.r.lvl}function oc(e){return et(e.r)?[e.k,e.v]:oc(e.r)}function sc(e,t,n,r=jr,o=jr){return{k:e,l:r,lvl:n,r:o,v:t}}function ic(e){return ui(ac(e))}function ac(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?ht(t,{r:ht(e,{l:t.r})}):e}function ui(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?ht(n,{l:ht(e,{r:n.l}),lvl:t+1}):e}function zg(e){return nc(e,({k:t,v:n})=>({index:t,value:n}))}function lc(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Pr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const di=qe(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function cc(e,t,n){return e[So(e,t,n)]}function So(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 Hg(e,t,n,r){const o=So(e,t,r),s=So(e,n,r,o);return e.slice(o,s+1)}function vn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!et(e.groupOffsetTree)}function fi({index:e},t){return t===e?0:t<e?-1:1}function Ug(){return{groupIndices:[],groupOffsetTree:ir(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:ir()}}function Wg(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=_t(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(Jg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ai(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=_t(e,o+1,h));u&&(e=_t(e,i,s))}return[e,n]}function Vg(e){return typeof e.groupIndex<"u"}function Kg({offset:e},t){return t===e?0:t<e?-1:1}function Or(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=cc(t,e,fi),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function uc(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function dc(e,t,n){if(Vg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=uc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function qg(e,t,n,r=0){return r>0&&(t=Math.max(t,cc(e,r,fi).offset)),nc(Hg(e,t,n,Kg),Xg)}function Gg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Et.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>_t(_t(w,v,h),v+1,p),i)}else[i,a]=Wg(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=hi(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>_t(h,p,Or(p,f,o)),ir()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Yg(e){return Bn(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 fc(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 hi(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=So(o,t-1,fi),a=o[l].offset;const u=Wt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Wt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of bo(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 Xg(e){return{index:e.index,value:e}}function Jg(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 Zg={offsetHeight:"height",offsetWidth:"width"},Qt=qe(([{log:e},{recalcInProgress:t}])=>{const n=We(),r=We(),o=xt(r,0),s=We(),i=We(),a=Y(0),l=Y([]),u=Y(void 0),d=Y(void 0),f=Y((C,k)=>vn(C,Zg[k])),h=Y(void 0),p=Y(0),w=Ug(),v=xt(z(n,Le(l,e,p),Zt(Gg,w),ot()),w),g=xt(z(l,ot(),Zt((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),se(({prev:C})=>C)),[]);me(z(l,Ie(C=>C.length>0),Le(v,p),se(([C,k,I])=>{const A=C.reduce((j,P,L)=>_t(j,P,Or(P,k.offsetTree,I)||L),ir());return{...k,groupIndices:C,groupOffsetTree:A}})),v),me(z(r,Le(v),Ie(([C,{lastIndex:k}])=>C<k),se(([C,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:C}])),n),me(u,d);const x=xt(z(u,se(C=>C===void 0)),!0);me(z(d,Ie(C=>C!==void 0&&et(lt(v).sizeTree)),se(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Le(v),Zt(({sizes:C},[k,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),se(C=>C.changed)));Qe(z(a,Zt((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),se(C=>C.diff)),C=>{const{groupIndices:k}=lt(v);if(C>0)Me(t,!0),Me(s,C+fc(C,k));else if(C<0){const I=lt(g);I.length>0&&(C-=fc(-C,I)),Me(i,C)}}),Qe(z(a,Le(e)),([C,k])=>{C<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},Et.ERROR)});const S=At(s);me(z(s,Le(v),se(([C,k])=>{const I=k.groupIndices.length>0,A=[],j=k.lastSize;if(I){const P=Rr(k.sizeTree,0);let L=0,$=0;for(;L<C;){const M=k.groupIndices[$],K=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;A.push({endIndex:M,size:P,startIndex:M}),A.push({endIndex:M+1+K-1,size:j,startIndex:M+1}),$++,L+=K+1}const H=Bn(k.sizeTree);return L!==C&&H.shift(),H.reduce((M,{k:K,v:W})=>{let G=M.ranges;return M.prevSize!==0&&(G=[...M.ranges,{endIndex:K+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:K+C,prevSize:W,ranges:G}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Bn(k.sizeTree).reduce((P,{k:L,v:$})=>({prevIndex:L+C,prevSize:$,ranges:[...P.ranges,{endIndex:L+C-1,size:P.prevSize,startIndex:P.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=At(z(i,Le(v,p),se(([C,{offsetTree:k},I])=>{const A=-C;return Or(A,k,I)})));return me(z(i,Le(v,p),se(([C,k,I])=>{if(k.groupIndices.length>0){if(et(k.sizeTree))return k;let A=ir();const j=lt(g);let P=0,L=0,$=0;for(;P<-C;){$=j[L];const H=j[L+1]-$-1;L++,P+=H+1}if(A=Bn(k.sizeTree).reduce((H,{k:M,v:K})=>_t(H,Math.max(0,M+C),K),A),P!==-C){const H=Rr(k.sizeTree,$);A=_t(A,0,H);const M=Wt(k.sizeTree,-C+1)[1];A=_t(A,1,M)}return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}else{const A=Bn(k.sizeTree).reduce((j,{k:P,v:L})=>_t(j,Math.max(0,P+C),L),ir());return{...k,sizeTree:A,...hi(k.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},rt(xn,di),{singleton:!0});function Qg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const hc=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=We(),i=We(),a=At(z(s,se(Qg)));return me(z(a,se(l=>l.totalCount)),n),me(z(a,se(l=>l.groupIndices)),e),me(z(ut(o,t,r),Ie(([l,u])=>Co(u)),se(([l,u,d])=>Wt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),se(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(Qt,yt)),wn=qe(([{log:e}])=>{const t=Y(!1),n=At(z(t,Ie(r=>r),ot()));return Qe(t,r=>{r&&lt(e)("props updated",{},Et.DEBUG)}),{didMount:n,propsReady:t}},rt(xn),{singleton:!0}),ex=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function pc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!ex)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Mr=qe(([{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=We(),w=We(),v=Y(0);let g=null,x=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Me(l,!1)}return me(z(p,Le(n,f,r,v,a,i,h),Le(e,s,o),se(([[E,C,k,I,A,j,P,L],$,H,M])=>{const K=pc(E),{align:W,behavior:G,offset:B}=K,_=I-1,q=dc(K,C,_);let Q=Or(q,C.offsetTree,$)+j;W==="end"?(Q+=H+Wt(C.sizeTree,q)[1]-k+M,q===_&&(Q+=P)):W==="center"?Q+=(H+Wt(C.sizeTree,q)[1]-k+M)/2:Q-=A,B&&(Q+=B);const xe=ue=>{S(),ue?(L("retrying to scroll to",{location:E},Et.DEBUG),Me(p,E)):(Me(w,!0),L("list did not change, scroll successful",{},Et.DEBUG))};if(S(),G==="smooth"){let ue=!1;b=Qe(t,te=>{ue=ue||te}),g=Ut(d,()=>{xe(ue)})}else g=Ut(z(t,tx(150)),xe);return x=setTimeout(()=>{S()},1200),Me(l,!0),L("scrolling from index to",{behavior:G,index:q,top:Q},Et.DEBUG),{behavior:G,top:Q}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},rt(Qt,yt,xn),{singleton:!0});function tx(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pi(e,t){e==0?t():requestAnimationFrame(()=>{pi(e-1,t)})}function mi(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Dr=qe(([{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 me(z(i,Le(l),Ie(([d,f])=>!!f),Jt(!1)),a),me(z(i,Le(l),Ie(([d,f])=>!!f),Jt(!1)),u),Qe(z(ut(t,i),Le(a,n,e,u),Ie(([[,d],f,{sizeTree:h},p,w])=>d&&(!et(h)||ri(p))&&!f&&!w),Le(l)),([,d])=>{Ut(o,()=>{Me(u,!0)}),pi(4,()=>{Ut(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(Qt,yt,Mr,wn),{singleton:!0});function mc(e,t){return Math.abs(e-t)<1.01}const Lr="up",$r="down",nx="none",rx={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ox=0,Fr=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=Y(!1),a=Y(!0),l=We(),u=We(),d=Y(4),f=Y(ox),h=xt(z(si(z(Ce(o),$n(1),Jt(!0)),z(Ce(o),$n(1),Jt(!1),Zl(100))),ot()),!1),p=xt(z(si(z(n,Jt(!0)),z(n,Jt(!1),Zl(200))),ot()),!1);me(z(ut(Ce(o),Ce(f)),se(([b,S])=>b<=S),ot()),a),me(z(a,un(50)),u);const w=At(z(ut(r,Ce(s),Ce(t),Ce(e),Ce(d)),Zt((b,[{scrollHeight:S,scrollTop:E},C,k,I,A])=>{const j=E+C-S>-A,P={scrollHeight:S,scrollTop:E,viewportHeight:C};if(j){let $,H;return E>b.state.scrollTop?($="SCROLLED_DOWN",H=b.state.scrollTop-E):($="SIZE_DECREASED",H=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:H,state:P}}let L;return P.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":C<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:P}},rx),ot((b,S)=>b&&b.atBottom===S.atBottom))),v=xt(z(r,Zt((b,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(mc(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const k=S-(E+C)<1;return b.scrollTop!==E&&k?{changed:!0,jump:b.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(b=>b.changed),se(b=>b.jump)),0);me(z(w,se(b=>b.atBottom)),i),me(z(i,un(50)),l);const g=Y($r);me(z(r,se(({scrollTop:b})=>b),ot(),Zt((b,S)=>lt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?Lr:$r,prevScrollTop:S},{direction:$r,prevScrollTop:0}),se(b=>b.direction)),g),me(z(r,un(50),Jt(nx)),g);const x=Y(0);return me(z(h,Ie(b=>!b),Jt(0)),x),me(z(o,un(100),Le(h),Ie(([b,S])=>!!S),Zt(([b,S],[E])=>[S,E],[0,0]),se(([b,S])=>S-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},rt(yt)),To="top",ko="bottom",gc="none";function xc(e,t,n){return typeof e=="number"?n===Lr&&t===To||n===$r&&t===ko?e:0:n===Lr?t===To?e.main:e.reverse:t===ko?e.main:e.reverse}function vc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const gi=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=We(),i=Y(0),a=Y(0),l=Y(0),u=xt(z(ut(Ce(r),Ce(o),Ce(n),Ce(s,Pr),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),se(([d,f,h,[p,w],v,g,x,b,S])=>{const E=d-b,C=g+x,k=Math.max(h-E,0);let I=gc;const A=vc(S,To),j=vc(S,ko);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Lr),w<d-k+f+j&&(I=$r),I!==gc?[Math.max(E-h-xc(v,To,I)-A,0),E-k-x+f+xc(v,ko,I)+j]:null}),Ie(d=>d!=null),ot(Pr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},rt(yt),{singleton:!0});function sx(e,t,n){if(Co(t)){const r=uc(e,t);return[{index:Wt(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 xi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Eo(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 v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:bc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:bc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function wc(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=mi(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function bc(e,t,n){if(e.length===0)return[];if(!Co(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=bo(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 zn=qe(([{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:w}])=>{const v=Y([]),g=Y(0),x=We();me(s.topItemsIndexes,v);const b=xt(z(ut(p,w,Ce(l,Pr),Ce(o),Ce(r),Ce(u),d,Ce(v),Ce(t),Ce(n),e),Ie(([k,I,,A,,,,,,,j])=>{const P=j&&j.length!==A;return k&&!I&&!P}),se(([,,[k,I],A,j,P,L,$,H,M,K])=>{const W=j,{offsetTree:G,sizeTree:B}=W,_=lt(g);if(A===0)return{...xi,totalCount:A};if(k===0&&I===0)return _===0?{...xi,totalCount:A}:wc(_,P,j,H,M,K||[]);if(et(B))return _>0?null:Eo(sx(mi(P,A),W,K),[],A,M,W,H);const q=[];if($.length>0){const je=$[0],Te=$[$.length-1];let V=0;for(const D of bo(B,je,Te)){const J=D.value,U=Math.max(D.start,je),de=Math.min(D.end,Te);for(let ce=U;ce<=de;ce++)q.push({data:K==null?void 0:K[ce],index:ce,offset:V,size:J}),V+=J}}if(!L)return Eo([],q,A,M,W,H);const Q=$.length>0?$[$.length-1]+1:0,xe=qg(G,k,I,Q);if(xe.length===0)return null;const ue=A-1,te=wo([],je=>{for(const Te of xe){const V=Te.value;let D=V.offset,J=Te.start;const U=V.size;if(V.offset<k){J+=Math.floor((k-V.offset+M)/(U+M));const ce=J-Te.start;D+=ce*U+ce*M}J<Q&&(D+=(Q-J)*U,J=Q);const de=Math.min(Te.end,ue);for(let ce=J;ce<=de&&!(D>=I);ce++)je.push({data:K==null?void 0:K[ce],index:ce,offset:D,size:U}),D+=U+M}});return Eo(te,q,A,M,W,H)}),Ie(k=>k!==null),ot()),xi);me(z(e,Ie(ri),se(k=>k==null?void 0:k.length)),o),me(z(b,se(k=>k.topListHeight)),f),me(f,a),me(z(b,se(k=>[k.top,k.bottom])),i),me(z(b,se(k=>k.items)),x);const S=At(z(b,Ie(({items:k})=>k.length>0),Le(o,e),Ie(([{items:k},I])=>k[k.length-1].originalIndex===I-1),se(([,k,I])=>[k-1,I]),ot(Pr),se(([k])=>k))),E=At(z(b,un(200),Ie(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),se(({items:k})=>k[0].index),ot())),C=At(z(b,Ie(({items:k})=>k.length>0),se(({items:k})=>{let I=0,A=k.length-1;for(;k[I].type==="group"&&I<A;)I++;for(;k[A].type==="group"&&A>I;)A--;return{endIndex:k[A].index,startIndex:k[I].index}}),ot(lc)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:v,...h}},rt(Qt,hc,gi,Dr,Mr,Fr,wn,di),{singleton:!0}),yc=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=We(),i=xt(z(ut(n,e,r,t,o),se(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return me(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(yt,zn),{singleton:!0}),ix=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=Y(!1),r=xt(z(ut(n,e,t),Ie(([o])=>o),se(([,o,s])=>Math.max(0,o-s)),un(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(yt,yc),{singleton:!0}),Sc=qe(()=>({context:Y(null)})),ax=({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,Cc=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=We();return me(z(d,Le(t,l,n,s,o,r,a),Le(e),se(([[f,h,p,w,v,g,x,b],S])=>{const{align:E,behavior:C,calculateViewLocation:k=ax,done:I,...A}=f,j=dc(f,h,w-1),P=Or(j,h.offsetTree,S)+v+g,L=P+Wt(h.sizeTree,j)[1],$=b+g,H=b+p-x,M=k({itemBottom:L,itemTop:P,locationParams:{align:E,behavior:C,...A},viewportBottom:H,viewportTop:$});return M?I&&Ut(z(i,Ie(K=>!K),$n(lt(i)?1:2)),I):I&&I(),M}),Ie(f=>f!==null)),u),{scrollIntoView:d}},rt(Qt,yt,Mr,zn,xn),{singleton:!0});function Tc(e){return e?e==="smooth"?"smooth":"auto":!1}const lx=(e,t)=>typeof e=="function"?Tc(e(t)):t&&Tc(e),cx=qe(([{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 w=Y(!1),v=We();let g=null;function x(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Qe(z(ut(z(Ce(t),$n(1)),l),Le(Ce(w),s,a,f),se(([[C,k],I,A,j,P])=>{let L=k&&j,$="auto";return L&&($=lx(I,A||P),L=L&&!!$),{followOutputBehavior:$,shouldFollow:L,totalCount:C}}),Ie(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C)}):g=Ut(e,()=>{lt(d)("following output to ",{totalCount:k},Et.DEBUG),x(C),g=null})});function b(C){const k=Ut(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},Et.DEBUG),x("auto"))});setTimeout(k,100)}Qe(z(ut(Ce(w),t,u),Ie(([C,,k])=>C&&k),Zt(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:C})=>C),Le(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Qe(v,()=>{b(lt(w)!==!1)}),Qe(ut(Ce(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=Y(null),E=We();return me(si(z(Ce(r),se(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),z(Ce(t))),E),Qe(z(ut(z(E,$n(1)),l),Le(Ce(S),a,f,h),se(([[C,k],I,A,j,P])=>k&&A&&(I==null?void 0:I({context:P,totalCount:C,scrollingInProgress:j}))),Ie(C=>!!C),un(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),Me(p,C)}):g=Ut(e,()=>{lt(d)("scrolling into view",{}),Me(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:S}},rt(Qt,Fr,Mr,Dr,wn,xn,yt,Sc,Cc)),ux=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(z(a,Le(s),Ie(([,l])=>l!==0),Le(o,r,t,n,e),se(([[,l],u,d,f,h,p=[]])=>wc(l,u,d,f,h,p))),i),{}),rt(Qt,Dr,zn,wn),{singleton:!0}),dx=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=Y(0);return Qe(z(e,Le(r),Ie(([,o])=>o!==0),se(([,o])=>({top:o}))),o=>{Ut(z(n,$n(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},rt(wn,yt,zn),{singleton:!0}),kc=qe(([{scrollVelocity:e}])=>{const t=Y(!1),n=We(),r=Y(!1);return me(z(e,Le(r,t,n),Ie(([o,s])=>!!s),se(([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}),ot()),t),Qe(z(ut(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(Fr),{singleton:!0}),vi=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=We(),r=We(),o=We(),s=Y(!1),i=Y(void 0);return me(z(ut(n,r),se(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),me(z(t,Le(r),se(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(yt)),fx=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=We(),d=Y(void 0),f=Y(null),h=Y(null);return me(a,f),me(l,h),Qe(z(u,Le(t,r,i,f,h,n)),([p,w,v,g,x,b,S])=>{const E=Yg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=S,p({ranges:E,scrollTop:v})}),me(z(d,Ie(ri),se(hx)),o),me(z(s,Le(d),Ie(([,p])=>p!==void 0),ot(),se(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},rt(Qt,yt,Dr,wn,vi));function hx(e){return{align:"start",index:0,offset:e.scrollTop}}const px=qe(([{topItemsIndexes:e}])=>{const t=Y(0);return me(z(t,Ie(n=>n>=0),se(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(zn));function Ec(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const mx=Ec(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),gx=qe(([{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:w}])=>{const v=At(z(l,Le(i),Zt(([,x,b,S],[{bottom:E,items:C,offsetBottom:k,totalCount:I},A])=>{const j=E+k;let P=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(P=j-S,P!==0&&(P+=A))),[P,C,I,j]},[0,[],0,0]),Ie(([x])=>x!==0),Le(r,a,n,o,p,w),Ie(([,x,b,S,,,E])=>!E&&!S&&x!==0&&b===Lr),se(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Et.DEBUG),x))));function g(x){x>0?(Me(t,{behavior:"auto",top:-x}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-x}))}return Qe(z(v,Le(e,s)),([x,b,S])=>{S&&mx()?Me(e,b-x):g(-x)}),Qe(z(ut(xt(s,!1),e,w),Ie(([x,b,S])=>!x&&!S&&b!==0),se(([x,b])=>b),un(1)),g),me(z(f,se(x=>({top:-x}))),t),Qe(z(u,Le(h,d),se(([x,{groupIndices:b,lastSize:S,sizeTree:E},C])=>{function k(I){return I*(S+C)}if(b.length===0)return k(x);{let I=0;const A=Rr(E,0);let j=0,P=0;for(;j<x;){j++,I+=A;let L=b.length===P+1?1/0:b[P+1]-b[P]-1;j+L>x&&(I-=A,L=x-j+1),j+=L,I+=k(L),P++}return I}})),x=>{Me(e,x),requestAnimationFrame(()=>{Me(t,{top:x}),requestAnimationFrame(()=>{Me(e,0),Me(w,!1)})})}),{deviation:e}},rt(yt,Fr,zn,Qt,xn,di)),xx=qe(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),rt(gi,ux,wn,kc,yc,dx,ix,vi,Cc,xn,Sc)),Ic=qe(([{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:w},v,g,x,{listState:b,topItemsIndexes:S,...E},{scrollToIndex:C},k,{topItemCount:I},{groupCounts:A},j])=>(me(E.rangeChanged,j.scrollSeekRangeChanged),me(z(j.windowViewportRect,se(P=>P.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...j,...v,sizes:l,...g}),rt(Qt,Dr,yt,fx,cx,zn,Mr,gx,px,hc,xx));function vx(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 Io=typeof document<"u"?y.useLayoutEffect:y.useEffect;function Nc(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,x){g.propsReady&&Me(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Me(S,x[b])}for(const b of o)if(b in x){const S=g[t.optional[b]];Me(S,x[b])}g.propsReady&&Me(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=S=>{const E=g[t.methods[b]];Me(E,S)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=Og(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...S}=g,[E]=y.useState(()=>wo(Dg(e),I=>{l(I,S)})),[C]=y.useState(Jl(d,E));Io(()=>{for(const I of i)I in S&&Qe(C[I],S[I]);return()=>{Object.values(C).map(oi)}},[S,C,E]),Io(()=>{l(E,S)}),y.useImperativeHandle(x,Yl(u(E)));const k=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(k,{...vx([...r,...o,...i],S),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Me(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(S=>Qe(x,S),[x]);return y.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=y.useContext(a)[g],[b,S]=y.useState(Jl(lt,x));return Io(()=>Qe(x,E=>{E!==b&&S(Yl(E))}),[x,b]),b},v=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Io(()=>Qe(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const Ac=y.createContext(void 0),_c=y.createContext(void 0),jc=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wi(e){return"self"in e}function wx(e){return"body"in e}function Rc(e,t,n,r=sr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,w,v;const g=h.target;if(wx(g)||wi(g)){const b=wi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(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 w=h.behavior==="smooth";let v,g,x;wi(p)?(g=Math.max(vn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],v=vn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),mc(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(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 bi="-webkit-sticky",Pc="sticky",yi=Ec(()=>{if(typeof document>"u")return Pc;const e=document.createElement("div");return e.style.position=bi,e.style.position===bi?bi:Pc});function Si(e){return e}const bx=qe(()=>{const e=Y(a=>`Item ${a}`),t=Y(a=>`Group ${a}`),n=Y({}),r=Y(Si),o=Y("div"),s=Y(sr),i=(a,l=null)=>xt(z(n,se(u=>u[a]),ot()),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")}}),yx=qe(([e,t])=>({...e,...t}),rt(Ic,bx)),Sx=({height:e})=>c.jsx("div",{style:{height:e}}),Cx={overflowAnchor:"none",position:yi(),zIndex:1},Oc={overflowAnchor:"none"},Tx={...Oc,display:"inline-block",height:"100%"},Mc=y.memo(function({showTopList:e=!1}){const t=Re("listState"),n=Dt("sizeRanges"),r=Re("useWindowScroll"),o=Re("customScrollParent"),s=Dt("windowScrollContainerState"),i=Dt("scrollContainerState"),a=o||r?s:i,l=Re("itemContent"),u=Re("context"),d=Re("groupContent"),f=Re("trackItemSizes"),h=Re("itemSize"),p=Re("log"),w=Dt("gap"),v=Re("horizontalDirection"),{callbackRef:g}=Fg(n,h,f,e?sr:a,p,w,o,v,Re("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);Ci("deviation",M=>{x!==M&&b(M)});const S=Re("EmptyPlaceholder"),E=Re("ScrollSeekPlaceholder")||Sx,C=Re("ListComponent"),k=Re("ItemComponent"),I=Re("GroupComponent"),A=Re("computeItemKey"),j=Re("isSeeking"),P=Re("groupIndices").length>0,L=Re("alignToBottom"),$=Re("initialItemFinalLocationReached"),H=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...vt(S,u)}):c.jsx(C,{...vt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:H,children:(e?t.topItems:t.items).map(M=>{const K=M.originalIndex,W=A(K+t.firstItemIndex,M.data,u);return j?y.createElement(E,{...vt(E,u),height:M.size,index:M.index,key:W,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(I,{...vt(I,u),"data-index":K,"data-item-index":M.index,"data-known-size":M.size,key:W,style:Cx},d(M.index,u)):y.createElement(k,{...vt(k,u),...Nx(k,M.data),"data-index":K,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:W,style:v?Tx:Oc},P?l(M.index,M.groupIndex,M.data,u):l(M.index,M.data,u))})})}),kx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ex={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ix={position:yi(),top:0,width:"100%",zIndex:1};function vt(e,t){if(typeof e!="string")return{context:t}}function Nx(e,t){return{item:typeof e=="string"?void 0:t}}const Ax=y.memo(function(){const e=Re("HeaderComponent"),t=Dt("headerHeight"),n=Re("HeaderFooterTag"),r=Fn(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),_x=y.memo(function(){const e=Re("FooterComponent"),t=Dt("footerHeight"),n=Re("HeaderFooterTag"),r=Fn(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,Re("skipAnimationFrameInResizeObserver")),o=Re("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null});function Dc({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:w}=Rc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?Ex:kx,...o},tabIndex:0,...i,...vt(l,s),children:r})})}function Lc({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),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Rc(a,u,l,w,h);return jc(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...vt(l,s),children:r})})}const jx=({children:e})=>{const t=y.useContext(Ac),n=Dt("viewportHeight"),r=Dt("fixedItemHeight"),o=Re("alignToBottom"),s=Re("horizontalDirection"),i=y.useMemo(()=>Xl(n,l=>vn(l,s?"width":"height")),[n,s]),a=Fn(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:No(o),children:e})},Rx=({children:e})=>{const t=y.useContext(Ac),n=Dt("windowViewportRect"),r=Dt("fixedItemHeight"),o=Re("customScrollParent"),s=tc(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:No(i),children:e})},Px=({children:e})=>{const t=Re("TopItemListComponent")||"div",n=Re("headerHeight"),r={...Ix,marginTop:`${n}px`},o=Re("context");return c.jsx(t,{style:r,...vt(t,o),children:e})},Ox=y.memo(function(e){const t=Re("useWindowScroll"),n=Re("topItemsIndexes").length>0,r=Re("customScrollParent"),o=Re("context");return c.jsxs(r||t?Lx:Dx,{...e,context:o,children:[n&&c.jsx(Px,{children:c.jsx(Mc,{showTopList:!0})}),c.jsxs(r||t?Rx:jx,{children:[c.jsx(Ax,{}),c.jsx(Mc,{}),c.jsx(_x,{})]})]})}),{Component:Mx,useEmitter:Ci,useEmitterValue:Re,usePublisher:Dt}=Nc(yx,{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"}},Ox),Dx=Dc({useEmitter:Ci,useEmitterValue:Re,usePublisher:Dt}),Lx=Lc({useEmitter:Ci,useEmitterValue:Re,usePublisher:Dt}),$x=Mx;rt(Ic,qe(()=>{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(Si),a=Y(sr),l=(u,d=null)=>xt(z(s,se(f=>f[u]),ot()),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")}})),yi();const $c={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Fx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Fc,floor:Ao,max:Br,min:Ti,round:Bc}=Math;function zc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Bx(e){return{...Fx,items:e}}function _o(e,t){return e&&e.width===t.width&&e.height===t.height}function zx(e,t){return e&&e.column===t.column&&e.row===t.row}const Hx=qe(([{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:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E},C])=>{const k=Y(0),I=Y(0),A=Y($c),j=Y({height:0,width:0}),P=Y({height:0,width:0}),L=We(),$=We(),H=Y(0),M=Y(null),K=Y({column:0,row:0}),W=We(),G=We(),B=Y(!1),_=Y(0),q=Y(!0),Q=Y(!1),xe=Y(!1);Qe(z(w,Le(_),Ie(([D,J])=>!!J)),()=>{Me(q,!1)}),Qe(z(ut(w,q,P,j,_,Q),Ie(([D,J,U,de,,ce])=>D&&!J&&U.height!==0&&de.height!==0&&!ce)),([,,,,D])=>{Me(Q,!0),pi(1,()=>{Me(L,D)}),Ut(z(u),()=>{Me(t,[0,0]),Me(q,!0)})}),me(z(G,Ie(D=>D!=null&&D.scrollTop>0),Jt(0)),I),Qe(z(w,Le(G),Ie(([,D])=>D!=null)),([,D])=>{D&&(Me(j,D.viewport),Me(P,D.item),Me(K,D.gap),D.scrollTop>0&&(Me(B,!0),Ut(z(u,$n(1)),J=>{Me(B,!1)}),Me(l,{top:D.scrollTop})))}),me(z(j,se(({height:D})=>D)),f),me(z(ut(Ce(j,_o),Ce(P,_o),Ce(K,(D,J)=>D&&D.column===J.column&&D.row===J.row),Ce(u)),se(([D,J,U,de])=>({gap:U,item:J,scrollTop:de,viewport:D}))),W),me(z(ut(Ce(k),r,Ce(K,zx),Ce(P,_o),Ce(j,_o),Ce(M),Ce(I),Ce(B),Ce(q),Ce(_)),Ie(([,,,,,,,D])=>!D),se(([D,[J,U],de,ce,ze,Xe,Ge,,ke,De])=>{const{column:nt,row:He}=de,{height:Je,width:dt}=ce,{width:ne}=ze;if(Ge===0&&(D===0||ne===0))return $c;if(dt===0){const Ct=mi(De,D),hn=Ct+Math.max(Ge-1,0);return Bx(zc(Ct,hn,Xe))}const re=Hc(ne,dt,nt);let ve,Ee;ke?J===0&&U===0&&Ge>0?(ve=0,Ee=Ge-1):(ve=re*Ao((J+He)/(Je+He)),Ee=re*Fc((U+He)/(Je+He))-1,Ee=Ti(D-1,Br(Ee,re-1)),ve=Ti(Ee,Br(0,ve))):(ve=0,Ee=-1);const Se=zc(ve,Ee,Xe),{bottom:Ae,top:Ze}=Uc(ze,de,ce,Se),Ye=Fc(D/re),ct=Ye*Je+(Ye-1)*He-Ae;return{bottom:Ae,itemHeight:Je,items:Se,itemWidth:dt,offsetBottom:ct,offsetTop:Ze,top:Ze}})),A),me(z(M,Ie(D=>D!==null),se(D=>D.length)),k),me(z(ut(j,P,A,K),Ie(([D,J,{items:U}])=>U.length>0&&J.height!==0&&D.height!==0),se(([D,J,{items:U},de])=>{const{bottom:ce,top:ze}=Uc(D,de,J,U);return[ze,ce]}),ot(Pr)),t);const ue=Y(!1);me(z(u,Le(ue),se(([D,J])=>J||D!==0)),ue);const te=At(z(ut(A,k),Ie(([{items:D}])=>D.length>0),Le(ue),Ie(([[D,J],U])=>{const de=D.items[D.items.length-1].index===J-1;return(U||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===J)&&de}),se(([[,D]])=>D-1),ot())),je=At(z(Ce(A),Ie(({items:D})=>D.length>0&&D[0].index===0),Jt(0),ot())),Te=At(z(Ce(A),Le(B),Ie(([{items:D},J])=>D.length>0&&!J),se(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ot(lc),un(0)));me(Te,p.scrollSeekRangeChanged),me(z(L,Le(j,P,k,K),se(([D,J,U,de,ce])=>{const ze=pc(D),{align:Xe,behavior:Ge,offset:ke}=ze;let De=ze.index;De==="LAST"&&(De=de-1),De=Br(0,De,Ti(de-1,De));let nt=ki(J,ce,U,De);return Xe==="end"?nt=Bc(nt-J.height+U.height):Xe==="center"&&(nt=Bc(nt-J.height/2+U.height/2)),ke&&(nt+=ke),{behavior:Ge,top:nt}})),l);const V=xt(z(A,se(D=>D.offsetBottom+D.bottom)),0);return me(z(E,se(D=>({height:D.visibleHeight,width:D.visibleWidth}))),j),{customScrollParent:g,data:M,deviation:H,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:P,overscan:n,restoreStateFrom:G,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:l,scrollToIndex:L,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:E,...p,gridState:A,horizontalDirection:xe,initialTopMostItemIndex:_,totalListHeight:V,...h,endReached:te,propsReady:v,rangeChanged:Te,startReached:je,stateChanged:W,stateRestoreInProgress:B,...C}},rt(gi,yt,Fr,kc,wn,vi,xn));function Hc(e,t,n){return Br(1,Ao((e+n)/(Ao(t)+n)))}function Uc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ki(e,t,n,r[0].index);return{bottom:ki(e,t,n,r[r.length-1].index)+o,top:s}}function ki(e,t,n,r){const o=Hc(e.width,n.width,t.column),s=Ao(r/o),i=s*n.height+Br(0,s-1)*t.row;return i>0?i+t.row:i}const Ux=qe(()=>{const e=Y(f=>`Item ${f}`),t=Y({}),n=Y(null),r=Y("virtuoso-grid-item"),o=Y("virtuoso-grid-list"),s=Y(Si),i=Y("div"),a=Y(sr),l=(f,h=null)=>xt(z(t,se(p=>p[f]),ot()),h),u=Y(!1),d=Y(!1);return me(Ce(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")}}),Wx=qe(([e,t])=>({...e,...t}),rt(Hx,Ux)),Vx=y.memo(function(){const e=st("gridState"),t=st("listClassName"),n=st("itemClassName"),r=st("itemContent"),o=st("computeItemKey"),s=st("isSeeking"),i=Lt("scrollHeight"),a=st("ItemComponent"),l=st("ListComponent"),u=st("ScrollSeekPlaceholder"),d=st("context"),f=Lt("itemDimensions"),h=Lt("gap"),p=st("log"),w=st("stateRestoreInProgress"),v=Lt("reportReadyState"),g=Fn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const S=x.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();f({height:E,width:C})}h({column:Vc("column-gap",getComputedStyle(x).columnGap,p),row:Vc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return jc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...vt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...vt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...vt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Kx=y.memo(function(){const e=st("HeaderComponent"),t=Lt("headerHeight"),n=st("headerFooterTag"),r=Fn(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=st("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),qx=y.memo(function(){const e=st("FooterComponent"),t=Lt("footerHeight"),n=st("headerFooterTag"),r=Fn(y.useMemo(()=>s=>{t(vn(s,"height"))},[t]),!0,!1),o=st("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),Gx=({children:e})=>{const t=y.useContext(_c),n=Lt("itemDimensions"),r=Lt("viewportDimensions"),o=Fn(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:No(!1),children:e})},Yx=({children:e})=>{const t=y.useContext(_c),n=Lt("windowViewportRect"),r=Lt("itemDimensions"),o=st("customScrollParent"),s=tc(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:No(!1),children:e})},Xx=y.memo(function({...e}){const t=st("useWindowScroll"),n=st("customScrollParent"),r=n||t?Zx:Jx,o=n||t?Yx:Gx,s=st("context");return c.jsx(r,{...e,...vt(r,s),children:c.jsxs(o,{children:[c.jsx(Kx,{}),c.jsx(Vx,{}),c.jsx(qx,{})]})})}),{useEmitter:Wc,useEmitterValue:st,usePublisher:Lt}=Nc(Wx,{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"}},Xx),Jx=Dc({useEmitter:Wc,useEmitterValue:st,usePublisher:Lt}),Zx=Lc({useEmitter:Wc,useEmitterValue:st,usePublisher:Lt});function Vc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}const Qx=no.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 Ei({className:e,variant:t,...n}){return c.jsx("div",{className:ee(Qx({variant:t}),e),...n})}function le(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 ev(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 en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=m.useContext(p);if(w)return w;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,tv(o,...t)]}function tv(...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 pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},nv=m[" useInsertionEffect ".trim().toString()]||pt;function Hn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=rv({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=ov(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 rv({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return nv(()=>{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 ov(e){return typeof e=="function"}function Kc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ii(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Kc(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():Kc(e[o],null)}}}}function Be(...e){return m.useCallback(Ii(...e),e)}var sv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ne=sv.reduce((e,t)=>{const n=On.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 qc(e,t){e&&ro.flushSync(()=>e.dispatchEvent(t))}function iv(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var jt=e=>{const{present:t,children:n}=e,r=av(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Be(r.ref,lv(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};jt.displayName="Presence";function av(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=iv(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=jo(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=jo(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]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(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=jo(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 jo(e){return(e==null?void 0:e.animationName)||"none"}function lv(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 cv=m[" useId ".trim().toString()]||(()=>{}),uv=0;function tn(e){const[t,n]=m.useState(cv());return pt(()=>{n(r=>r??String(uv++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[dv,GC]=en(Ro),[fv,Ni]=dv(Ro),Gc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Hn({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return c.jsx(fv,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(Ne.div,{"data-state":_i(l),"data-disabled":s?"":void 0,...a,ref:t})})});Gc.displayName=Ro;var Yc="CollapsibleTrigger",Xc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ni(Yc,n);return c.jsx(Ne.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":_i(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});Xc.displayName=Yc;var Ai="CollapsibleContent",hv=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ni(Ai,e.__scopeCollapsible);return c.jsx(jt,{present:n||o.open,children:({present:s})=>c.jsx(pv,{...r,ref:t,present:s})})});hv.displayName=Ai;var pv=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ni(Ai,n),[a,l]=m.useState(r),u=m.useRef(null),d=Be(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const S=b.getBoundingClientRect();f.current=S.height,p.current=S.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(Ne.div,{"data-state":_i(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function _i(e){return e?"open":"closed"}var mv=Gc;const Jc=mv,Zc=Xc,zr=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}));zr.displayName="Card";const Hr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex flex-col space-y-1.5 p-6",e),...t}));Hr.displayName="CardHeader";const Ur=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ee("text-2xl font-semibold leading-none tracking-tight",e),...t}));Ur.displayName="CardTitle";const Qc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Qc.displayName="CardDescription";const Po=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("p-6 pt-0",e),...t}));Po.displayName="CardContent";const eu=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ee("flex items-center p-6 pt-0",e),...t}));eu.displayName="CardFooter";function tu(){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 Un=tu();function gv(e){Un=e}const nu=/[&<>"']/,xv=new RegExp(nu.source,"g"),ru=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vv=new RegExp(ru.source,"g"),wv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ou=e=>wv[e];function wt(e,t){if(t){if(nu.test(e))return e.replace(xv,ou)}else if(ru.test(e))return e.replace(vv,ou);return e}const bv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function su(e){return e.replace(bv,(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 yv=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(yv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const Sv=/[^\w:]/g,Cv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function iu(e,t,n){if(e){let r;try{r=decodeURIComponent(su(n)).replace(Sv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Cv.test(n)&&(n=Iv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},Tv=/^[^:]+:\/*[^/]*$/,kv=/^([^:]+:)[\s\S]*$/,Ev=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Iv(e,t){Oo[" "+e]||(Tv.test(e)?Oo[" "+e]=e+"/":Oo[" "+e]=Do(e,"/",!0)),e=Oo[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(kv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Ev,"$1")+t:e+t}const Mo={exec:function(){}};function au(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 Do(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 Nv(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 Av(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 lu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function cu(e,t,n,r){const o=t.href,s=t.title?wt(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:wt(i)}}function _v(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
34
34
  `).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(`
35
- `)}class ji{constructor(t){this.options=t||zn}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:Do(r,`
35
+ `)}class ji{constructor(t){this.options=t||Un}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:Do(r,`
36
36
  `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=_v(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=Do(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,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
37
- `,1)[0].replace(/^\t+/,N=>" ".repeat(3*N.length)),f=t.split(`
37
+ `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
38
38
  `,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+`
39
- `,t=t.substring(f.length+1),w=!0),!w){const N=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
40
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||I.test(f)||N.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
39
+ `,t=t.substring(f.length+1),w=!0),!w){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
40
+ `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||I.test(f)||E.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
41
41
  `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||I.test(d)||C.test(d))break;p+=`
42
42
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
43
- `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const N=x.items[a].tokens.filter(k=>k.type==="space"),C=N.length>0&&N.some(k=>/\n.*\n/.test(k.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}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]):bt(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:iu(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
44
- `):[]};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]=iu(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)===`
45
- `?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:bt(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]):bt(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=Do(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Nv(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)),lu(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 lu(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 w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}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=bt(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=bt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=bt(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=bt(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=bt(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]):bt(r[0]):r[0]:o=bt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={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:Mo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=Ze(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=Ze(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=Ze(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=Ze(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=Ze(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=Ze(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=Ze(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.paragraph=Ze(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.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",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:Ze(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:Mo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ze(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
46
- ]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ae={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Mo,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:Mo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ae._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ae.punctuation=Ze(ae.punctuation).replace(/punctuation/g,ae._punctuation).getRegex(),ae.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ae.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ae._comment=Ze(ve._comment).replace("(?:-->|$)","-->").getRegex(),ae.emStrong.lDelim=Ze(ae.emStrong.lDelim).replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimAst=Ze(ae.emStrong.rDelimAst,"g").replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimUnd=Ze(ae.emStrong.rDelimUnd,"g").replace(/punct/g,ae._punctuation).getRegex(),ae._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ae._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ae._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])?)+(?![-_])/,ae.autolink=Ze(ae.autolink).replace("scheme",ae._scheme).replace("email",ae._email).getRegex(),ae._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ae.tag=Ze(ae.tag).replace("comment",ae._comment).replace("attribute",ae._attribute).getRegex(),ae._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ae._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ae.link=Ze(ae.link).replace("label",ae._label).replace("href",ae._href).replace("title",ae._title).getRegex(),ae.reflink=Ze(ae.reflink).replace("label",ae._label).replace("ref",ve._label).getRegex(),ae.nolink=Ze(ae.nolink).replace("ref",ve._label).getRegex(),ae.reflinkSearch=Ze(ae.reflinkSearch,"g").replace("reflink",ae.reflink).replace("nolink",ae.nolink).getRegex(),ae.normal={...ae},ae.pedantic={...ae.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:Ze(/^!?\[(label)\]\((.*?)\)/).replace("label",ae._label).getRegex(),reflink:Ze(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ae._label).getRegex()},ae.gfm={...ae.normal,escape:Ze(ae.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ae.gfm.url=Ze(ae.gfm.url,"i").replace("email",ae.gfm._extended_email).getRegex(),ae.breaks={...ae.gfm,br:Ze(ae.br).replace("{2,}","*").getRegex(),text:Ze(ae.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function jv(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 cu(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||zn,this.options.tokenizer=this.options.tokenizer||new ji,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:ve.normal,inline:ae.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ae}}static lex(t,n){return new bn(n).lex(t)}static lexInline(t,n){return new bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
43
+ `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const S=x.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const E=x.items[a].tokens.filter(k=>k.type==="space"),C=E.length>0&&E.some(k=>/\n.*\n/.test(k.raw));x.loose=C}if(x.loose)for(a=0;a<S;a++)x.items[a].loose=!0;return x}}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]):wt(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:au(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
44
+ `):[]};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]=au(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)===`
45
+ `?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:wt(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]):wt(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=Do(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=Nv(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)),cu(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 cu(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 w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}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=wt(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=wt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=wt(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=wt(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=wt(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]):wt(r[0]):r[0]:o=wt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Mo,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=tt(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=tt(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=tt(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=tt(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=tt(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.blockquote=tt(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=tt(we.gfm.table).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.gfm.paragraph=tt(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.pedantic={...we.normal,html:tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Mo,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tt(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
46
+ ]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ae={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Mo,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:Mo,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ae._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ae.punctuation=tt(ae.punctuation).replace(/punctuation/g,ae._punctuation).getRegex(),ae.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ae.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ae._comment=tt(we._comment).replace("(?:-->|$)","-->").getRegex(),ae.emStrong.lDelim=tt(ae.emStrong.lDelim).replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimAst=tt(ae.emStrong.rDelimAst,"g").replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimUnd=tt(ae.emStrong.rDelimUnd,"g").replace(/punct/g,ae._punctuation).getRegex(),ae._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ae._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ae._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])?)+(?![-_])/,ae.autolink=tt(ae.autolink).replace("scheme",ae._scheme).replace("email",ae._email).getRegex(),ae._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ae.tag=tt(ae.tag).replace("comment",ae._comment).replace("attribute",ae._attribute).getRegex(),ae._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ae._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ae.link=tt(ae.link).replace("label",ae._label).replace("href",ae._href).replace("title",ae._title).getRegex(),ae.reflink=tt(ae.reflink).replace("label",ae._label).replace("ref",we._label).getRegex(),ae.nolink=tt(ae.nolink).replace("ref",we._label).getRegex(),ae.reflinkSearch=tt(ae.reflinkSearch,"g").replace("reflink",ae.reflink).replace("nolink",ae.nolink).getRegex(),ae.normal={...ae},ae.pedantic={...ae.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:tt(/^!?\[(label)\]\((.*?)\)/).replace("label",ae._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ae._label).getRegex()},ae.gfm={...ae.normal,escape:tt(ae.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ae.gfm.url=tt(ae.gfm.url,"i").replace("email",ae.gfm._extended_email).getRegex(),ae.breaks={...ae.gfm,br:tt(ae.br).replace("{2,}","*").getRegex(),text:tt(ae.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function jv(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 uu(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Un,this.options.tokenizer=this.options.tokenizer||new ji,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:we.normal,inline:ae.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:ae}}static lex(t,n){return new bn(n).lex(t)}static lexInline(t,n){return new bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
47
47
  `),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+=`
48
48
  `: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+=`
49
49
  `+r.raw,o.text+=`
@@ -53,9 +53,9 @@ Check the top-level render call using <`+te+">.")}return F}}function se(T,F){{if
53
53
  `+r.raw,o.text+=`
54
54
  `+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+=`
55
55
  `+r.raw,o.text+=`
56
- `+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)+"["+au("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)+"["+au("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,cu)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,cu))){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,jv)){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 Ri{constructor(t){this.options=t||zn}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$/,"")+`
57
- `,o?'<pre><code class="'+this.options.langPrefix+bt(o)+'">'+(r?t:bt(t,!0))+`</code></pre>
58
- `:"<pre><code>"+(r?t:bt(t,!0))+`</code></pre>
56
+ `+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)+"["+lu("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)+"["+lu("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,uu)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,uu))){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,jv)){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 Ri{constructor(t){this.options=t||Un}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$/,"")+`
57
+ `,o?'<pre><code class="'+this.options.langPrefix+wt(o)+'">'+(r?t:wt(t,!0))+`</code></pre>
58
+ `:"<pre><code>"+(r?t:wt(t,!0))+`</code></pre>
59
59
  `}blockquote(t){return`<blockquote>
60
60
  ${t}</blockquote>
61
61
  `}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}>
@@ -73,9 +73,9 @@ ${t}</blockquote>
73
73
  `}tablerow(t){return`<tr>
74
74
  ${t}</tr>
75
75
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
76
- `}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=su(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=su(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 uu{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 du{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 yn{constructor(t){this.options=t||zn,this.options.renderer=this.options.renderer||new Ri,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uu,this.slugger=new du}static parse(t,n){return new yn(n).parse(t)}static parseInline(t,n){return new yn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,S,N,C,k;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(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,ou(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(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,N=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,N,S);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
77
- `+(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 Lo{constructor(t){this.options=t||zn}preprocess(t){return t}postprocess(t){return t}}Ep(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function Rv(e,t,n){return r=>{if(r.message+=`
78
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+bt(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 fu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...we.defaults,...s};const i=Rv(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(Av(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&&we.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;we.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(we.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&&we.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function we(e,t,n){return fu(bn.lex,yn.parse)(e,t,n)}we.options=we.setOptions=function(e){return we.defaults={...we.defaults,...e},gv(we.defaults),we},we.getDefaults=eu,we.defaults=zn,we.use=function(...e){const t=we.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=we.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=we.defaults.renderer||new Ri;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=we.defaults.tokenizer||new ji;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=we.defaults.hooks||new Lo;for(const s in n.hooks){const i=o[s];Lo.passThroughHooks.has(s)?o[s]=a=>{if(we.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=we.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}}we.setOptions(r)})},we.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(we,r)),r.type){case"table":{for(const o of r.header)n=n.concat(we.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(we.walkTokens(s.tokens,t));break}case"list":{n=n.concat(we.walkTokens(r.items,t));break}default:we.defaults.extensions&&we.defaults.extensions.childTokens&&we.defaults.extensions.childTokens[r.type]?we.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(we.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(we.walkTokens(r.tokens,t)))}return n},we.parseInline=fu(bn.lexInline,yn.parseInline),we.Parser=yn,we.parser=yn.parse,we.Renderer=Ri,we.TextRenderer=uu,we.Lexer=bn,we.lexer=bn.lex,we.Tokenizer=ji,we.Slugger=du,we.Hooks=Lo,we.parse=we,we.options,we.setOptions,we.use,we.walkTokens,we.parseInline,yn.parse,bn.lex;function Pi({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return we.parse(o)}return we.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function hu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function pu(e,t){return await(await hu(`/files/${e}/view`,t)).text()}async function Pv(e,t){const n=await hu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ov(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const Mv=1,Dv=1e6;let Oi=0;function Lv(){return Oi=(Oi+1)%Number.MAX_SAFE_INTEGER,Oi.toString()}const Mi=new Map,mu=e=>{if(Mi.has(e))return;const t=setTimeout(()=>{Mi.delete(e),Ur({type:"REMOVE_TOAST",toastId:e})},Dv);Mi.set(e,t)},$v=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Mv)};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?mu(n):e.toasts.forEach(r=>{mu(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)}}},$o=[];let Fo={toasts:[]};function Ur(e){Fo=$v(Fo,e),$o.forEach(t=>{t(Fo)})}function Fv({...e}){const t=Lv(),n=o=>Ur({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Ur({type:"DISMISS_TOAST",toastId:t});return Ur({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Di(){const[e,t]=m.useState(Fo);return m.useEffect(()=>($o.push(t),()=>{const n=$o.indexOf(t);n>-1&&$o.splice(n,1)}),[e]),{...e,toast:Fv,dismiss:n=>Ur({type:"DISMISS_TOAST",toastId:n})}}function mt(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 Bv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(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 zv="DismissableLayer",Li="dismissableLayer.update",Hv="dismissableLayer.pointerDownOutside",Uv="dismissableLayer.focusOutside",gu,xu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(xu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Le(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=b>=x,C=Kv(I=>{const A=I.target,R=[...u.branches].some(P=>P.contains(A));!N||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=qv(I=>{const A=I.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Bv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(gu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),vu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=gu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),vu())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Li,I),()=>document.removeEventListener(Li,I)},[]),c.jsx(Ie.div,{...l,ref:w,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,k.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=zv;var Wv="DismissableLayerBranch",Vv=m.forwardRef((e,t)=>{const n=m.useContext(xu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ie.div,{...e,ref:o})});Vv.displayName=Wv;function Kv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){wu(Hv,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 qv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&wu(Uv,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 vu(){const e=new CustomEvent(Li);document.dispatchEvent(e)}function wu(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?Kc(o,s):o.dispatchEvent(s)}var $i="focusScope.autoFocusOnMount",Fi="focusScope.autoFocusOnUnmount",bu={bubbles:!1,cancelable:!0},Gv="FocusScope",zo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Le(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const N=S.target;a.contains(N)?f.current=N:Sn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const N=S.relatedTarget;N!==null&&(a.contains(N)||Sn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Sn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Cu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent($i,bu);a.addEventListener($i,u),a.dispatchEvent(x),x.defaultPrevented||(Yv(ew(yu(a)),{select:!0}),document.activeElement===v&&Sn(a))}return()=>{a.removeEventListener($i,u),setTimeout(()=>{const x=new CustomEvent(Fi,bu);a.addEventListener(Fi,d),a.dispatchEvent(x),x.defaultPrevented||Sn(v??document.body,{select:!0}),a.removeEventListener(Fi,d),Cu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,N]=Xv(b);S&&N?!v.shiftKey&&x===N?(v.preventDefault(),n&&Sn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&Sn(N,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=Gv;function Yv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Sn(r,{select:t}),document.activeElement!==n)return}function Xv(e){const t=yu(e),n=Su(t,e),r=Su(t.reverse(),e);return[n,r]}function yu(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 Su(e,t){for(const n of e)if(!Jv(n,{upTo:t}))return n}function Jv(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 Zv(e){return e instanceof HTMLInputElement&&"select"in e}function Sn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zv(e)&&t&&e.select()}}var Cu=Qv();function Qv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Tu(e,t),e.unshift(t)},remove(t){var n;e=Tu(e,t),(n=e[0])==null||n.resume()}}}function Tu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ew(e){return e.filter(t=>t.tagName!=="A")}var tw="Portal",Ho=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(c.jsx(Ie.div,{...r,ref:t}),i):null});Ho.displayName=tw;var Bi=0;function zi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ku()),document.body.insertAdjacentElement("beforeend",e[1]??ku()),Bi++,()=>{Bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Bi--}},[])}function ku(){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 nn=function(){return nn=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},nn.apply(this,arguments)};function Eu(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 nw(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 Uo="right-scroll-bar-position",Wo="width-before-scroll-bar",rw="with-scroll-bars-hidden",ow="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sw(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 iw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Iu=new WeakMap;function aw(e,t){var n=sw(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return iw(function(){var r=Iu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}Iu.set(n,e)},[e]),n}function lw(e){return e}function cw(e,t){t===void 0&&(t=lw);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 uw(e){e===void 0&&(e={});var t=cw(null);return t.options=nn({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Eu(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,nn({},n))};Nu.isSideCarExport=!0;function dw(e,t){return e.useMedium(t),Nu}var Au=uw(),Ui=function(){},Vo=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),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,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,N=Eu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=aw([n,t]),I=nn(nn({},N),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Au,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:k})):m.createElement(b,nn({},I,{className:l,ref:k}),a))});Vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vo.classNames={fullWidth:Wo,zeroRight:Uo};var fw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fw();return t&&e.setAttribute("nonce",t),e}function pw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hw())&&(pw(t,n),mw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xw=function(){var e=gw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_u=function(){var e=xw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vw={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},ww=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Wi(n),Wi(r),Wi(o)]},bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vw;var t=ww(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])}},yw=_u(),ar="data-scroll-locked",Sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
76
+ `}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=iu(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=iu(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 du{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 fu{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 yn{constructor(t){this.options=t||Un,this.options.renderer=this.options.renderer||new Ri,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new du,this.slugger=new fu}static parse(t,n){return new yn(n).parse(t)}static parseInline(t,n){return new yn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,S,E,C,k;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(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,su(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(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,E=b.task,x="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,E,S);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
77
+ `+(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 Lo{constructor(t){this.options=t||Un}preprocess(t){return t}postprocess(t){return t}}Ip(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function Rv(e,t,n){return r=>{if(r.message+=`
78
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+wt(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 hu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=Rv(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(Av(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&&be.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;be.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(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return hu(bn.lex,yn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},gv(be.defaults),be},be.getDefaults=tu,be.defaults=Un,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new Ri;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=be.defaults.tokenizer||new ji;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=be.defaults.hooks||new Lo;for(const s in n.hooks){const i=o[s];Lo.passThroughHooks.has(s)?o[s]=a=>{if(be.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=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=hu(bn.lexInline,yn.parseInline),be.Parser=yn,be.parser=yn.parse,be.Renderer=Ri,be.TextRenderer=du,be.Lexer=bn,be.lexer=bn.lex,be.Tokenizer=ji,be.Slugger=fu,be.Hooks=Lo,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,yn.parse,bn.lex;function Pi({content:e,className:t="",allowHtml:n=!1}){const r=y.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return be.parse(o)}return be.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:ee("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function pu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function mu(e,t){return await(await pu(`/files/${e}/view`,t)).text()}async function Pv(e,t){const n=await pu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ov(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const Mv=1,Dv=1e6;let Oi=0;function Lv(){return Oi=(Oi+1)%Number.MAX_SAFE_INTEGER,Oi.toString()}const Mi=new Map,gu=e=>{if(Mi.has(e))return;const t=setTimeout(()=>{Mi.delete(e),Wr({type:"REMOVE_TOAST",toastId:e})},Dv);Mi.set(e,t)},$v=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Mv)};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?gu(n):e.toasts.forEach(r=>{gu(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)}}},$o=[];let Fo={toasts:[]};function Wr(e){Fo=$v(Fo,e),$o.forEach(t=>{t(Fo)})}function Fv({...e}){const t=Lv(),n=o=>Wr({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Wr({type:"DISMISS_TOAST",toastId:t});return Wr({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Di(){const[e,t]=m.useState(Fo);return m.useEffect(()=>($o.push(t),()=>{const n=$o.indexOf(t);n>-1&&$o.splice(n,1)}),[e]),{...e,toast:Fv,dismiss:n=>Wr({type:"DISMISS_TOAST",toastId:n})}}function mt(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 Bv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(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 zv="DismissableLayer",Li="dismissableLayer.update",Hv="dismissableLayer.pointerDownOutside",Uv="dismissableLayer.focusOutside",xu,vu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(vu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Be(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,C=Kv(I=>{const A=I.target,j=[...u.branches].some(P=>P.contains(A));!E||j||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=qv(I=>{const A=I.target;[...u.branches].some(P=>P.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Bv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),wu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=xu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),wu())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Li,I),()=>document.removeEventListener(Li,I)},[]),c.jsx(Ne.div,{...l,ref:w,style:{pointerEvents:S?E?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,k.onFocusCapture),onBlurCapture:le(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=zv;var Wv="DismissableLayerBranch",Vv=m.forwardRef((e,t)=>{const n=m.useContext(vu),r=m.useRef(null),o=Be(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Ne.div,{...e,ref:o})});Vv.displayName=Wv;function Kv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){bu(Hv,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 qv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&bu(Uv,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 wu(){const e=new CustomEvent(Li);document.dispatchEvent(e)}function bu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?qc(o,s):o.dispatchEvent(s)}var $i="focusScope.autoFocusOnMount",Fi="focusScope.autoFocusOnUnmount",yu={bubbles:!1,cancelable:!0},Gv="FocusScope",zo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Be(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(S){if(p.paused||!a)return;const E=S.target;a.contains(E)?f.current=E:Sn(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Sn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Sn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Tu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent($i,yu);a.addEventListener($i,u),a.dispatchEvent(x),x.defaultPrevented||(Yv(ew(Su(a)),{select:!0}),document.activeElement===v&&Sn(a))}return()=>{a.removeEventListener($i,u),setTimeout(()=>{const x=new CustomEvent(Fi,yu);a.addEventListener(Fi,d),a.dispatchEvent(x),x.defaultPrevented||Sn(v??document.body,{select:!0}),a.removeEventListener(Fi,d),Tu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[S,E]=Xv(b);S&&E?!v.shiftKey&&x===E?(v.preventDefault(),n&&Sn(S,{select:!0})):v.shiftKey&&x===S&&(v.preventDefault(),n&&Sn(E,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(Ne.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=Gv;function Yv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Sn(r,{select:t}),document.activeElement!==n)return}function Xv(e){const t=Su(e),n=Cu(t,e),r=Cu(t.reverse(),e);return[n,r]}function Su(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 Cu(e,t){for(const n of e)if(!Jv(n,{upTo:t}))return n}function Jv(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 Zv(e){return e instanceof HTMLInputElement&&"select"in e}function Sn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zv(e)&&t&&e.select()}}var Tu=Qv();function Qv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ku(e,t),e.unshift(t)},remove(t){var n;e=ku(e,t),(n=e[0])==null||n.resume()}}}function ku(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ew(e){return e.filter(t=>t.tagName!=="A")}var tw="Portal",Ho=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(c.jsx(Ne.div,{...r,ref:t}),i):null});Ho.displayName=tw;var Bi=0;function zi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Eu()),document.body.insertAdjacentElement("beforeend",e[1]??Eu()),Bi++,()=>{Bi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Bi--}},[])}function Eu(){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 nn=function(){return nn=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},nn.apply(this,arguments)};function Iu(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 nw(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 Uo="right-scroll-bar-position",Wo="width-before-scroll-bar",rw="with-scroll-bars-hidden",ow="--removed-body-scroll-bar-size";function Hi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sw(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 iw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Nu=new WeakMap;function aw(e,t){var n=sw(null,function(r){return e.forEach(function(o){return Hi(o,r)})});return iw(function(){var r=Nu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Hi(a,null)}),s.forEach(function(a){o.has(a)||Hi(a,i)})}Nu.set(n,e)},[e]),n}function lw(e){return e}function cw(e,t){t===void 0&&(t=lw);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 uw(e){e===void 0&&(e={});var t=cw(null);return t.options=nn({async:!0,ssr:!1},e),t}var Au=function(e){var t=e.sideCar,n=Iu(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,nn({},n))};Au.isSideCarExport=!0;function dw(e,t){return e.useMedium(t),Au}var _u=uw(),Ui=function(){},Vo=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Ui,onWheelCapture:Ui,onTouchMoveCapture:Ui}),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,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,S=e.gapMode,E=Iu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=aw([n,t]),I=nn(nn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:_u,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:k})):m.createElement(b,nn({},I,{className:l,ref:k}),a))});Vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Vo.classNames={fullWidth:Wo,zeroRight:Uo};var fw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fw();return t&&e.setAttribute("nonce",t),e}function pw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hw())&&(pw(t,n),mw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xw=function(){var e=gw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ju=function(){var e=xw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vw={left:0,top:0,right:0,gap:0},Wi=function(e){return parseInt(e||"",10)||0},ww=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Wi(n),Wi(r),Wi(o)]},bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vw;var t=ww(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])}},yw=ju(),ar="data-scroll-locked",Sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
79
79
  .`.concat(rw,` {
80
80
  overflow: hidden `).concat(r,`;
81
81
  padding-right: `).concat(a,"px ").concat(r,`;
@@ -112,18 +112,18 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
112
112
  body[`).concat(ar,`] {
113
113
  `).concat(ow,": ").concat(a,`px;
114
114
  }
115
- `)},ju=function(){var e=parseInt(document.body.getAttribute(ar)||"0",10);return isFinite(e)?e:0},Cw=function(){m.useEffect(function(){return document.body.setAttribute(ar,(ju()+1).toString()),function(){var e=ju()-1;e<=0?document.body.removeAttribute(ar):document.body.setAttribute(ar,e.toString())}},[])},Tw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Cw();var s=m.useMemo(function(){return bw(o)},[o]);return m.createElement(yw,{styles:Sw(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var Ko=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",Ko,Ko),window.removeEventListener("test",Ko,Ko)}catch{Vi=!1}var lr=Vi?{passive:!1}:!1,kw=function(e){return e.tagName==="TEXTAREA"},Ru=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")},Ew=function(e){return Ru(e,"overflowY")},Iw=function(e){return Ru(e,"overflowX")},Pu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ou(e,r);if(o){var s=Mu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Nw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Aw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ou=function(e,t){return e==="v"?Ew(t):Iw(t)},Mu=function(e,t){return e==="v"?Nw(t):Aw(t)},_w=function(e,t){return e==="h"&&t==="rtl"?-1:1},jw=function(e,t,n,r,o){var s=_w(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=Mu(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&Ou(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},qo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Du=function(e){return[e.deltaX,e.deltaY]},Lu=function(e){return e&&"current"in e?e.current:e},Rw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pw=function(e){return`
115
+ `)},Ru=function(){var e=parseInt(document.body.getAttribute(ar)||"0",10);return isFinite(e)?e:0},Cw=function(){m.useEffect(function(){return document.body.setAttribute(ar,(Ru()+1).toString()),function(){var e=Ru()-1;e<=0?document.body.removeAttribute(ar):document.body.setAttribute(ar,e.toString())}},[])},Tw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Cw();var s=m.useMemo(function(){return bw(o)},[o]);return m.createElement(yw,{styles:Sw(s,!t,o,n?"":"!important")})},Vi=!1;if(typeof window<"u")try{var Ko=Object.defineProperty({},"passive",{get:function(){return Vi=!0,!0}});window.addEventListener("test",Ko,Ko),window.removeEventListener("test",Ko,Ko)}catch{Vi=!1}var lr=Vi?{passive:!1}:!1,kw=function(e){return e.tagName==="TEXTAREA"},Pu=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")},Ew=function(e){return Pu(e,"overflowY")},Iw=function(e){return Pu(e,"overflowX")},Ou=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Mu(e,r);if(o){var s=Du(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Nw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Aw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Mu=function(e,t){return e==="v"?Ew(t):Iw(t)},Du=function(e,t){return e==="v"?Nw(t):Aw(t)},_w=function(e,t){return e==="h"&&t==="rtl"?-1:1},jw=function(e,t,n,r,o){var s=_w(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=Du(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&Mu(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},qo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Lu=function(e){return[e.deltaX,e.deltaY]},$u=function(e){return e&&"current"in e?e.current:e},Rw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Pw=function(e){return`
116
116
  .block-interactivity-`.concat(e,` {pointer-events: none;}
117
117
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
118
- `)},Ow=0,cr=[];function Mw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ow++)[0],s=m.useState(_u)[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 v=nw([e.lockRef.current],(e.shards||[]).map(Lu),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=qo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],N="deltaY"in v?v.deltaY:b[1]-x[1],C,k=v.target,I=Math.abs(S)>Math.abs(N)?"h":"v";if("touches"in v&&I==="h"&&k.type==="range")return!1;var A=Pu(I,k);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Pu(I,k)),!A)return!1;if(!r.current&&"changedTouches"in v&&(S||N)&&(r.current=C),!C)return!0;var R=r.current||C;return jw(R,g,v,R==="h"?S:N)},[]),l=m.useCallback(function(v){var g=v;if(!(!cr.length||cr[cr.length-1]!==s)){var x="deltaY"in g?Du(g):qo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Rw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Lu).filter(Boolean).filter(function(C){return C.contains(g.target)}),N=S.length>0?a(g,S[0]):!i.current.noIsolation;N&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Dw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(N){return N!==S})},1)},[]),d=m.useCallback(function(v){n.current=qo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Du(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,qo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return cr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,lr),document.addEventListener("touchmove",l,lr),document.addEventListener("touchstart",d,lr),function(){cr=cr.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,lr),document.removeEventListener("touchmove",l,lr),document.removeEventListener("touchstart",d,lr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:Pw(o)}):null,p?m.createElement(Tw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lw=dw(Au,Mw);var Go=m.forwardRef(function(e,t){return m.createElement(Vo,nn({},e,{ref:t,sideCar:Lw}))});Go.classNames=Vo.classNames;var $w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ur=new WeakMap,Yo=new WeakMap,Xo={},Ki=0,$u=function(e){return e&&(e.host||$u(e.parentNode))},Fw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=$u(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})},Bw=function(e,t,n,r){var o=Fw(t,Array.isArray(e)?e:[e]);Xo[n]||(Xo[n]=new WeakMap);var s=Xo[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),w=p!==null&&p!=="false",v=(ur.get(h)||0)+1,g=(s.get(h)||0)+1;ur.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Yo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Ki++,function(){i.forEach(function(f){var h=ur.get(f)-1,p=s.get(f)-1;ur.set(f,h),s.set(f,p),h||(Yo.has(f)||f.removeAttribute(r),Yo.delete(f)),p||f.removeAttribute(n)}),Ki--,Ki||(ur=new WeakMap,ur=new WeakMap,Yo=new WeakMap,Xo={})}},qi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Bw(r,o,n,"aria-hidden")):function(){return null}},Jo="Dialog",[Fu,YC]=en(Jo),[zw,Vt]=Fu(Jo),Bu=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]=Bn({prop:r,defaultProp:o??!1,onChange:s,caller:Jo});return c.jsx(zw,{scope:t,triggerRef:a,contentRef:l,contentId:tn(),titleId:tn(),descriptionId:tn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Bu.displayName=Jo;var zu="DialogTrigger",Hu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(zu,n),s=Le(t,o.triggerRef);return c.jsx(Ie.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xi(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Hu.displayName=zu;var Gi="DialogPortal",[Hw,Uu]=Fu(Gi,{forceMount:void 0}),Wu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Vt(Gi,t);return c.jsx(Hw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:i})}))})};Wu.displayName=Gi;var Zo="DialogOverlay",Vu=m.forwardRef((e,t)=>{const n=Uu(Zo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Zo,e.__scopeDialog);return s.modal?c.jsx(jt,{present:r||s.open,children:c.jsx(Ww,{...o,ref:t})}):null});Vu.displayName=Zo;var Uw=Rn.createSlot("DialogOverlay.RemoveScroll"),Ww=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Zo,n);return c.jsx(Go,{as:Uw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ie.div,{"data-state":Xi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Hn="DialogContent",Ku=m.forwardRef((e,t)=>{const n=Uu(Hn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Hn,e.__scopeDialog);return c.jsx(jt,{present:r||s.open,children:s.modal?c.jsx(Vw,{...o,ref:t}):c.jsx(Kw,{...o,ref:t})})});Ku.displayName=Hn;var Vw=m.forwardRef((e,t)=>{const n=Vt(Hn,e.__scopeDialog),r=m.useRef(null),o=Le(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(qu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),Kw=m.forwardRef((e,t)=>{const n=Vt(Hn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(qu,{...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()}})}),qu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Vt(Hn,n),l=m.useRef(null),u=Le(t,l);return zi(),c.jsxs(c.Fragment,{children:[c.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(qw,{titleId:a.titleId}),c.jsx(Yw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Yi="DialogTitle",Gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Yi,n);return c.jsx(Ie.h2,{id:o.titleId,...r,ref:t})});Gu.displayName=Yi;var Yu="DialogDescription",Xu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Yu,n);return c.jsx(Ie.p,{id:o.descriptionId,...r,ref:t})});Xu.displayName=Yu;var Ju="DialogClose",Zu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Ju,n);return c.jsx(Ie.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});Zu.displayName=Ju;function Xi(e){return e?"open":"closed"}var Qu="DialogTitleWarning",[XC,ed]=ev(Qu,{contentName:Hn,titleName:Yi,docsSlug:"dialog"}),qw=({titleId:e})=>{const t=ed(Qu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
118
+ `)},Ow=0,cr=[];function Mw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Ow++)[0],s=m.useState(ju)[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 v=nw([e.lockRef.current],(e.shards||[]).map($u),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=qo(v),b=n.current,S="deltaX"in v?v.deltaX:b[0]-x[0],E="deltaY"in v?v.deltaY:b[1]-x[1],C,k=v.target,I=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in v&&I==="h"&&k.type==="range")return!1;var A=Ou(I,k);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Ou(I,k)),!A)return!1;if(!r.current&&"changedTouches"in v&&(S||E)&&(r.current=C),!C)return!0;var j=r.current||C;return jw(j,g,v,j==="h"?S:E)},[]),l=m.useCallback(function(v){var g=v;if(!(!cr.length||cr[cr.length-1]!==s)){var x="deltaY"in g?Lu(g):qo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&Rw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map($u).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=S.length>0?a(g,S[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var S={name:v,delta:g,target:x,should:b,shadowParent:Dw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=m.useCallback(function(v){n.current=qo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Lu(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,qo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return cr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,lr),document.addEventListener("touchmove",l,lr),document.addEventListener("touchstart",d,lr),function(){cr=cr.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,lr),document.removeEventListener("touchmove",l,lr),document.removeEventListener("touchstart",d,lr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:Pw(o)}):null,p?m.createElement(Tw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lw=dw(_u,Mw);var Go=m.forwardRef(function(e,t){return m.createElement(Vo,nn({},e,{ref:t,sideCar:Lw}))});Go.classNames=Vo.classNames;var $w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},ur=new WeakMap,Yo=new WeakMap,Xo={},Ki=0,Fu=function(e){return e&&(e.host||Fu(e.parentNode))},Fw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Fu(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})},Bw=function(e,t,n,r){var o=Fw(t,Array.isArray(e)?e:[e]);Xo[n]||(Xo[n]=new WeakMap);var s=Xo[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),w=p!==null&&p!=="false",v=(ur.get(h)||0)+1,g=(s.get(h)||0)+1;ur.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Yo.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Ki++,function(){i.forEach(function(f){var h=ur.get(f)-1,p=s.get(f)-1;ur.set(f,h),s.set(f,p),h||(Yo.has(f)||f.removeAttribute(r),Yo.delete(f)),p||f.removeAttribute(n)}),Ki--,Ki||(ur=new WeakMap,ur=new WeakMap,Yo=new WeakMap,Xo={})}},qi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Bw(r,o,n,"aria-hidden")):function(){return null}},Jo="Dialog",[Bu,YC]=en(Jo),[zw,Vt]=Bu(Jo),zu=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]=Hn({prop:r,defaultProp:o??!1,onChange:s,caller:Jo});return c.jsx(zw,{scope:t,triggerRef:a,contentRef:l,contentId:tn(),titleId:tn(),descriptionId:tn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};zu.displayName=Jo;var Hu="DialogTrigger",Uu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Hu,n),s=Be(t,o.triggerRef);return c.jsx(Ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xi(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});Uu.displayName=Hu;var Gi="DialogPortal",[Hw,Wu]=Bu(Gi,{forceMount:void 0}),Vu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Vt(Gi,t);return c.jsx(Hw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:i})}))})};Vu.displayName=Gi;var Zo="DialogOverlay",Ku=m.forwardRef((e,t)=>{const n=Wu(Zo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Zo,e.__scopeDialog);return s.modal?c.jsx(jt,{present:r||s.open,children:c.jsx(Ww,{...o,ref:t})}):null});Ku.displayName=Zo;var Uw=On.createSlot("DialogOverlay.RemoveScroll"),Ww=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Zo,n);return c.jsx(Go,{as:Uw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(Ne.div,{"data-state":Xi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Wn="DialogContent",qu=m.forwardRef((e,t)=>{const n=Wu(Wn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Vt(Wn,e.__scopeDialog);return c.jsx(jt,{present:r||s.open,children:s.modal?c.jsx(Vw,{...o,ref:t}):c.jsx(Kw,{...o,ref:t})})});qu.displayName=Wn;var Vw=m.forwardRef((e,t)=>{const n=Vt(Wn,e.__scopeDialog),r=m.useRef(null),o=Be(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(Gu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:le(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault())})}),Kw=m.forwardRef((e,t)=>{const n=Vt(Wn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Gu,{...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()}})}),Gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Vt(Wn,n),l=m.useRef(null),u=Be(t,l);return zi(),c.jsxs(c.Fragment,{children:[c.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(qw,{titleId:a.titleId}),c.jsx(Yw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Yi="DialogTitle",Yu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Yi,n);return c.jsx(Ne.h2,{id:o.titleId,...r,ref:t})});Yu.displayName=Yi;var Xu="DialogDescription",Ju=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Xu,n);return c.jsx(Ne.p,{id:o.descriptionId,...r,ref:t})});Ju.displayName=Xu;var Zu="DialogClose",Qu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Vt(Zu,n);return c.jsx(Ne.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});Qu.displayName=Zu;function Xi(e){return e?"open":"closed"}var ed="DialogTitleWarning",[XC,td]=ev(ed,{contentName:Wn,titleName:Yi,docsSlug:"dialog"}),qw=({titleId:e})=>{const t=td(ed),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
119
119
 
120
120
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
121
121
 
122
- 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},Gw="DialogDescriptionWarning",Yw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ed(Gw).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},td=Bu,Xw=Hu,nd=Wu,Qo=Vu,es=Ku,Un=Gu,ts=Xu,rd=Zu;const Jw=td,Zw=nd,od=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{ref:n,className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));od.displayName=Qo.displayName;const sd=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===Un||(u==null?void 0:u.displayName)===Un.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(Zw,{children:[c.jsx(od,{}),c.jsxs(es,{ref:r,className:Q("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(Un,{className:"sr-only",children:"Dialog"}),t,c.jsxs(rd,{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(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});sd.displayName=es.displayName;const id=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});id.displayName="DialogHeader";const ad=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));ad.displayName=Un.displayName;const Qw=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Qw.displayName=ts.displayName;function eb({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}=Di(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await pu(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Pv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await pu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(re.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(He,{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(re.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(re.Image,{className:"h-5 w-5"}):c.jsx(re.FileText,{className:"h-5 w-5"});return c.jsx(Jw,{open:e,onOpenChange:t,children:c.jsxs(sd,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(id,{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(ad,{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(He,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(re.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(He,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(re.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function ld(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 cd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(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(Wr).filter(r=>r!==void 0);return n.length?n:void 0}if(cd(e))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=Wr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Ji(e){if(typeof e=="string")return e;if(cd(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ud(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 ud(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),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,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",Wn=1e5;function tb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function nb(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 rb(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 ob(e){const t=(r,o=Wn)=>{try{const s=Wr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
123
- … [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 sb(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 ib(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function dd(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 ab({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:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const fd=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:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[N,C]=y.useState("collapsed"),[k,I]=y.useState(!1),{currentThreadId:A}=go(),{handleInterrupt:R}=ni(),{toast:P}=Di(),[L,$]=y.useState({}),[H,M]=y.useState(!1),[q,V]=y.useState(null),Y=l==="phone"||l==="half-screen",B=t.role,j=B==="tool",G=!(r&&B!=="user"),Z=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]),ge=y.useMemo(()=>tb(t.content),[t.content]),de=y.useMemo(()=>nb(t.content),[t.content]),ee=y.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),Ae=y.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),Te=y.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),K=y.useMemo(()=>ob(t.content),[t.content]);y.useMemo(()=>sb(t.content),[t.content]);const D=y.useMemo(()=>K.length<=Wn?K:`${K.slice(0,Wn)}
124
- … [truncated ${K.length-Wn} chars]`,[K]),J=y.useCallback(async(ne="all")=>{const xe=ne==="visible"&&j?D:j?K:ge;async function Se(be){try{await navigator.clipboard.writeText(be)}catch{try{const je=document.createElement("textarea");je.value=be,je.setAttribute("readonly",""),je.style.position="absolute",je.style.left="-9999px",document.body.appendChild(je),je.select(),document.execCommand("copy"),document.body.removeChild(je)}catch(je){throw console.error("Failed to copy:",je),je}}}try{await Se(xe),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(xe)}catch(be){console.error("Failed to copy:",be)}},[j,K,ge,D,x]),U=y.useCallback(()=>{if(!w)return;const ne=j?K:ge;w(t.id,ne)},[w,t.id,j,K,ge]),fe=y.useCallback(()=>{v==null||v(n)},[v,n]),ue=y.useCallback(async(ne,le,xe)=>{if(!G){ne.preventDefault();return}if(L[xe]){ne.preventDefault();return}try{const Se=String(le.url??""),be=Se.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(be){ne.preventDefault();const je=be[1],Qe=le.name||`file_${je}`,Ye=le.mimeType||"application/octet-stream";V({id:je,name:Qe,mimeType:Ye}),M(!0);return}if(Se.startsWith("data:")){ne.preventDefault(),$(Ye=>({...Ye,[xe]:!0}));const je=`${le.name}_${le.size}_${Date.now()}`,Qe=P({title:"Fetching file...",description:"",open:!0});try{const Ye=await Ov(A??void 0);if(!Ye||!Array.isArray(Ye))throw new Error("Invalid file list response");const it=Ye.find(gt=>!gt||typeof gt!="object"||!((gt.filename??"")===(le.name??""))?!1:typeof le.size=="number"&&typeof gt.size=="number"?gt.size===le.size:!0);if(!(it!=null&&it.id))throw new Error(`File "${le.name}" is not yet available on the server`);if(!it.id||!it.filename)throw new Error("Invalid file data received from server");V({id:it.id,name:le.name||it.filename||`file_${it.id}`,mimeType:le.mimeType||it.mime_type||"application/octet-stream"}),M(!0),Qe.update({id:Qe.id,title:"Success",description:`Opened ${le.name}`,open:!0})}catch(Ye){console.error("Failed to fetch server file:",Ye);const it=Ye instanceof Error?Ye.message:"Unknown error occurred";Qe.update({id:Qe.id,title:"Failed",description:it}),P({title:"Failed to fetch file",description:it,open:!0})}finally{$(Ye=>({...Ye,[xe]:!1}))}}}catch(Se){console.error("File click error:",Se),$(be=>({...be,[xe]:!1}))}},[G,L,P,A]),$e=y.useCallback(()=>{const le=Q(Y?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(B){case"user":return c.jsx(re.User,{className:le});case"assistant":return c.jsx(re.Bot,{className:le});case"tool":return c.jsx(re.Wrench,{className:le});default:return c.jsx(re.Bot,{className:le})}},[Y,Z,B]),Ge=y.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch(B){case"user":return Q(ne,"justify-end");case"assistant":case"tool":case"system":return Q(ne,"justify-start");default:return ne}},[B]),qe=y.useCallback(()=>{const ne=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",Y&&"px-3 py-2 text-sm");switch(B){case"user":return Q(ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return Q(ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return Q(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(ne,"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")}},[Y,B]),ke=y.useCallback(async ne=>{try{const le=ne.id||`interrupt-${Date.now()}`;await R(le,!0)}catch(le){console.error("Failed to approve interrupt:",le)}},[R]),Oe=y.useCallback(async ne=>{try{const le=ne.id||`interrupt-${Date.now()}`;await R(le,!1)}catch(le){console.error("Failed to reject interrupt:",le)}},[R]),Be=y.useCallback(({part:ne,i:le})=>{if(ne.type==="text"){const xe=ne.text??"",Se=xe.trim(),be=ld(Se);return be&&B!=="tool"?c.jsx(lb,{data:be},le):B==="user"&&f&&Se.length>h?c.jsxs(Xc,{open:k,onOpenChange:I,children:[c.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",Y&&"text-xs"),children:k?c.jsx(Pi,{content:Se,allowHtml:!1}):c.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",Y&&"text-xs"),children:[Se.substring(0,h),"..."]})}),c.jsx(Jc,{asChild:!0,children:c.jsx(He,{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(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Se.length-h," chars)"]})})})]},le):c.jsx(Pi,{content:xe,allowHtml:!1},le)}if(ne.type==="image_url"){const xe=ne;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"})},le)}if(ne.type==="file"){const xe=ne,Se=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:be=>ue(be,xe,le),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
125
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[le]?c.jsx(re.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Se,L[le]?" (processing)":""]})]},le)}return ne.type==="interrupt"?c.jsx(ub,{interruptPart:ne,onApprove:ke,onReject:Oe},le):null},[ue,L,ke,Oe,B,f,h,k,Y]),Ue=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),st=y.useCallback(()=>{const ne=ge.trim().length>0||ee.length>0||Ae.length>0||Te.length>0;if(!j&&!ne&&!r)return Ue();if(t.model==="reflection"){const le=ge.trim(),xe=ld(le);if(xe&&typeof xe=="object")return c.jsx(db,{data:xe})}if(j&&de.name==="get_issues"){const le=t.content.find(be=>be.type==="tool_end"),xe=(le==null?void 0:le.output)??K,Se=ud(xe);if(Se)return c.jsx(fb,{issues:Se})}if(j){const le=rb(t.content);if(le.length>0)return c.jsx("div",{className:"space-y-2",children:le.map((xe,Se)=>{const be=typeof xe.output=="string"?xe.output:Ji(xe.output),je=be.length>Wn?`${be.slice(0,Wn)}
126
- … [truncated ${be.length-Wn} chars]`:be,Qe=N==="expanded";return c.jsxs(Xc,{open:Qe,onOpenChange:Ye=>C(Ye?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Ei,{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:Qe?je:je.slice(0,d)+(je.length>d?"...":"")})}),c.jsx(Jc,{asChild:!0,children:c.jsx(He,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Qe?c.jsxs(c.Fragment,{children:[" ",c.jsx(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Se)})})}if(!j){const le=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Se)=>c.jsx(Be,{part:xe,i:Se},Se))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[le,c.jsx(ab,{className:Z})]}):le}},[ge,ee.length,Ae.length,Te.length,r,t.model,j,de.name,K,N,u,Ue,Z]),ot=y.useMemo(()=>ib(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:Q(Ge(),p.container),children:c.jsxs("div",{className:Q(qe(),p.content),children:[(i||a||j)&&c.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",Y&&"mb-1 pb-1",Z,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[$e(),a&&ot&&c.jsx("span",{className:Q("font-medium",Y?"text-xs":"text-sm"),children:ot}),j&&de.name&&c.jsxs(Ei,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",Z,"border border-current/40",Y&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":N!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(le=>le==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:de.name}),c.jsx("span",{className:"inline-flex items-center",children:N!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})})]}),j&&!de.name&&c.jsx(He,{variant:"ghost",size:"sm",className:Q("h-6 px-1",Z,"hover:bg-foreground/10"),onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:Q("text-xs opacity-60",Z,Y&&"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:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J(j?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":j?"Copy visible":"Copy message",title:j?"Copy visible portion":"Copy message",children:c.jsx(re.Copy,{className:Q(b?"text-success":Z,Y?"h-3 w-3":"h-4 w-4")})}),j&&c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",Z),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),B==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:U,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(re.Edit,{className:Q(Z,Y?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:fe,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",Z,Y&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(re.RotateCcw,{className:Q(Z,Y?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:st()}),j&&N==="expanded"&&(de.toolCallId||de.name)&&c.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",Y&&"text-xs"),children:[de.name&&c.jsxs("div",{children:["Function: ",de.name]}),de.toolCallId&&c.jsxs("div",{children:["Call ID: ",de.toolCallId]})]}),!(i||a||j)&&s&&!o&&c.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>J(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.Copy,{className:Q(b?"text-success":"text-current",Y?"h-3 w-3":"h-4 w-4")})}),B==="user"&&w&&c.jsx(He,{variant:"ghost",size:"sm",onClick:U,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.Edit,{className:Q("text-current",Y?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(He,{variant:"ghost",size:"sm",onClick:fe,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",Y&&"h-5 w-5"),children:c.jsx(re.RotateCcw,{className:Q("text-current",Y?"h-3 w-3":"h-4 w-4")})})]})]})}),q&&c.jsx(eb,{isOpen:H,onClose:()=>{M(!1),V(null)},fileId:q.id,fileName:q.name,mimeType:q.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&dd(e.message)===dd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),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 lb({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:Ji(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:cb(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ji(e)})}function cb(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(Wr(e))})}catch{return String(e)}}function ub({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Br,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(zr,{className:"pb-3",children:[c.jsx(Hr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Zc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Qc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(He,{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(He,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function db({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 fb({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 hd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Zi=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:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),N=y.useRef(null),C=y.useRef(!1),[k,I]=y.useState(!0),A=y.useCallback(L=>{I(L),g&&g(!L),x&&x(L)},[g,x]),R=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=y.useMemo(()=>!w||v?!1:k?"auto":!1,[k,w,v]);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($x,{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:()=>{R&&R()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,$)=>hd($,L),itemContent:(L,$)=>{const H=hd($,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(fd,{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})})}})})});Zi.displayName="MessageList";const rs=1e4;function hb(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,`
122
+ 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},Gw="DialogDescriptionWarning",Yw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${td(Gw).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},nd=zu,Xw=Uu,rd=Vu,Qo=Ku,es=qu,Vn=Yu,ts=Ju,od=Qu;const Jw=nd,Zw=rd,sd=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{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}));sd.displayName=Qo.displayName;const id=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===Vn||(u==null?void 0:u.displayName)===Vn.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(Zw,{children:[c.jsx(sd,{}),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(Vn,{className:"sr-only",children:"Dialog"}),t,c.jsxs(od,{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(oe.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});id.displayName=es.displayName;const ad=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ad.displayName="DialogHeader";const ld=m.forwardRef(({className:e,...t},n)=>c.jsx(Vn,{ref:n,className:ee("text-lg font-semibold leading-none tracking-tight",e),...t}));ld.displayName=Vn.displayName;const Qw=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));Qw.displayName=ts.displayName;function eb({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}=Di(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await mu(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await Pv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await mu(n),b=new Blob([x],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(oe.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(Ve,{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(oe.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(oe.Image,{className:"h-5 w-5"}):c.jsx(oe.FileText,{className:"h-5 w-5"});return c.jsx(Jw,{open:e,onOpenChange:t,children:c.jsxs(id,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(ad,{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(ld,{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(Ve,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(oe.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ve,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(oe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function cd(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 ud(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Vr(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(Vr).filter(r=>r!==void 0);return n.length?n:void 0}if(ud(e))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=Vr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Ji(e){if(typeof e=="string")return e;if(ud(e))return"";try{const t=Vr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function dd(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 dd(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),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,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",Kn=1e5;function tb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function nb(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 rb(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 ob(e){const t=(r,o=Kn)=>{try{const s=Vr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
123
+ … [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 sb(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 ib(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function fd(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 ab({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 hd=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:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,S]=y.useState(!1),[E,C]=y.useState("collapsed"),[k,I]=y.useState(!1),{currentThreadId:A}=go(),{handleInterrupt:j}=ni(),{toast:P}=Di(),[L,$]=y.useState({}),[H,M]=y.useState(!1),[K,W]=y.useState(null),G=l==="phone"||l==="half-screen",B=t.role,_=B==="tool",q=!(r&&B!=="user"),Q=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]),xe=y.useMemo(()=>tb(t.content),[t.content]),ue=y.useMemo(()=>nb(t.content),[t.content]),te=y.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),je=y.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),Te=y.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),V=y.useMemo(()=>ob(t.content),[t.content]);y.useMemo(()=>sb(t.content),[t.content]);const D=y.useMemo(()=>V.length<=Kn?V:`${V.slice(0,Kn)}
124
+ … [truncated ${V.length-Kn} chars]`,[V]),J=y.useCallback(async(ne="all")=>{const ve=ne==="visible"&&_?D:_?V:xe;async function Ee(Se){try{await navigator.clipboard.writeText(Se)}catch{try{const Ae=document.createElement("textarea");Ae.value=Se,Ae.setAttribute("readonly",""),Ae.style.position="absolute",Ae.style.left="-9999px",document.body.appendChild(Ae),Ae.select(),document.execCommand("copy"),document.body.removeChild(Ae)}catch(Ae){throw console.error("Failed to copy:",Ae),Ae}}}try{await Ee(ve),S(!0),setTimeout(()=>S(!1),2e3),x==null||x(ve)}catch(Se){console.error("Failed to copy:",Se)}},[_,V,xe,D,x]),U=y.useCallback(()=>{if(!w)return;const ne=_?V:xe;w(t.id,ne)},[w,t.id,_,V,xe]),de=y.useCallback(()=>{v==null||v(n)},[v,n]),ce=y.useCallback(async(ne,re,ve)=>{if(!q){ne.preventDefault();return}if(L[ve]){ne.preventDefault();return}try{const Ee=String(re.url??""),Se=Ee.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Se){ne.preventDefault();const Ae=Se[1],Ze=re.name||`file_${Ae}`,Ye=re.mimeType||"application/octet-stream";W({id:Ae,name:Ze,mimeType:Ye}),M(!0);return}if(Ee.startsWith("data:")){ne.preventDefault(),$(Ye=>({...Ye,[ve]:!0}));const Ae=`${re.name}_${re.size}_${Date.now()}`,Ze=P({title:"Fetching file...",description:"",open:!0});try{const Ye=await Ov(A??void 0);if(!Ye||!Array.isArray(Ye))throw new Error("Invalid file list response");const ct=Ye.find(Ct=>!Ct||typeof Ct!="object"||!((Ct.filename??"")===(re.name??""))?!1:typeof re.size=="number"&&typeof Ct.size=="number"?Ct.size===re.size:!0);if(!(ct!=null&&ct.id))throw new Error(`File "${re.name}" is not yet available on the server`);if(!ct.id||!ct.filename)throw new Error("Invalid file data received from server");W({id:ct.id,name:re.name||ct.filename||`file_${ct.id}`,mimeType:re.mimeType||ct.mime_type||"application/octet-stream"}),M(!0),Ze.update({id:Ze.id,title:"Success",description:`Opened ${re.name}`,open:!0})}catch(Ye){console.error("Failed to fetch server file:",Ye);const ct=Ye instanceof Error?Ye.message:"Unknown error occurred";Ze.update({id:Ze.id,title:"Failed",description:ct}),P({title:"Failed to fetch file",description:ct,open:!0})}finally{$(Ye=>({...Ye,[ve]:!1}))}}}catch(Ee){console.error("File click error:",Ee),$(Se=>({...Se,[ve]:!1}))}},[q,L,P,A]),ze=y.useCallback(()=>{const re=ee(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(B){case"user":return c.jsx(oe.User,{className:re});case"assistant":return c.jsx(oe.Bot,{className:re});case"tool":return c.jsx(oe.Wrench,{className:re});default:return c.jsx(oe.Bot,{className:re})}},[G,Q,B]),Xe=y.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch(B){case"user":return ee(ne,"justify-end");case"assistant":case"tool":case"system":return ee(ne,"justify-start");default:return ne}},[B]),Ge=y.useCallback(()=>{const ne=ee("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");switch(B){case"user":return ee(ne,"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(ne,"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(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ee(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ee(ne,"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")}},[G,B]),ke=y.useCallback(async ne=>{try{const re=ne.id||`interrupt-${Date.now()}`;await j(re,!0)}catch(re){console.error("Failed to approve interrupt:",re)}},[j]),De=y.useCallback(async ne=>{try{const re=ne.id||`interrupt-${Date.now()}`;await j(re,!1)}catch(re){console.error("Failed to reject interrupt:",re)}},[j]),nt=y.useCallback(({part:ne,i:re})=>{if(ne.type==="text"){const ve=ne.text??"",Ee=ve.trim(),Se=cd(Ee);return Se&&B!=="tool"?c.jsx(lb,{data:Se},re):B==="user"&&f&&Ee.length>h?c.jsxs(Jc,{open:k,onOpenChange:I,children:[c.jsx("div",{className:ee("text-sm text-[hsl(var(--chat-bubble-user-text))]",G&&"text-xs"),children:k?c.jsx(Pi,{content:Ee,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))]",G&&"text-xs"),children:[Ee.substring(0,h),"..."]})}),c.jsx(Zc,{asChild:!0,children:c.jsx(Ve,{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(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ee.length-h," chars)"]})})})]},re):c.jsx(Pi,{content:ve,allowHtml:!1},re)}if(ne.type==="image_url"){const ve=ne;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},re)}if(ne.type==="file"){const ve=ne,Ee=ve.name||"file";return c.jsxs("a",{href:ve.url,onClick:Se=>ce(Se,ve,re),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
125
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[L[re]?c.jsx(oe.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ee,L[re]?" (processing)":""]})]},re)}return ne.type==="interrupt"?c.jsx(ub,{interruptPart:ne,onApprove:ke,onReject:De},re):null},[ce,L,ke,De,B,f,h,k,G]),He=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(oe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Je=y.useCallback(()=>{const ne=xe.trim().length>0||te.length>0||je.length>0||Te.length>0;if(!_&&!ne&&!r)return He();if(t.model==="reflection"){const re=xe.trim(),ve=cd(re);if(ve&&typeof ve=="object")return c.jsx(db,{data:ve})}if(_&&ue.name==="get_issues"){const re=t.content.find(Se=>Se.type==="tool_end"),ve=(re==null?void 0:re.output)??V,Ee=dd(ve);if(Ee)return c.jsx(fb,{issues:Ee})}if(_){const re=rb(t.content);if(re.length>0)return c.jsx("div",{className:"space-y-2",children:re.map((ve,Ee)=>{const Se=typeof ve.output=="string"?ve.output:Ji(ve.output),Ae=Se.length>Kn?`${Se.slice(0,Kn)}
126
+ … [truncated ${Se.length-Kn} chars]`:Se,Ze=E==="expanded";return c.jsxs(Jc,{open:Ze,onOpenChange:Ye=>C(Ye?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(Ei,{variant:"outline",children:(ve.name??"tool")+(ve.toolCallId?` • ${ve.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:Ze?Ae:Ae.slice(0,d)+(Ae.length>d?"...":"")})}),c.jsx(Zc,{asChild:!0,children:c.jsx(Ve,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Ze?c.jsxs(c.Fragment,{children:[" ",c.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ve.toolCallId??Ee)})})}if(!_){const re=c.jsx("div",{className:"space-y-2",children:t.content.map((ve,Ee)=>c.jsx(nt,{part:ve,i:Ee},Ee))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[re,c.jsx(ab,{className:Q})]}):re}},[xe,te.length,je.length,Te.length,r,t.model,_,ue.name,V,E,u,He,Q]),dt=y.useMemo(()=>ib(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ee(Xe(),p.container),children:c.jsxs("div",{className:ee(Ge(),p.content),children:[(i||a||_)&&c.jsxs("div",{className:ee("flex items-center justify-between mb-2 pb-2 border-b border-current/10",G&&"mb-1 pb-1",Q,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[ze(),a&&dt&&c.jsx("span",{className:ee("font-medium",G?"text-xs":"text-sm"),children:dt}),_&&ue.name&&c.jsxs(Ei,{variant:"outline",className:ee("text-xs flex items-center gap-1 cursor-pointer",Q,"border border-current/40",G&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(re=>re==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:ue.name}),c.jsx("span",{className:"inline-flex items-center",children:E!=="collapsed"?c.jsx(oe.ChevronUp,{className:"h-3 w-3"}):c.jsx(oe.ChevronDown,{className:"h-3 w-3"})})]}),_&&!ue.name&&c.jsx(Ve,{variant:"ghost",size:"sm",className:ee("h-6 px-1",Q,"hover:bg-foreground/10"),onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E!=="collapsed"?c.jsx(oe.ChevronUp,{className:"h-3 w-3"}):c.jsx(oe.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",Q,G&&"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(Ve,{variant:"ghost",size:"sm",onClick:()=>J(_?"visible":"all"),className:ee("h-6 w-6 p-0 hover:bg-foreground/10",Q,G&&"h-5 w-5"),"aria-label":_?"Copy visible":"Copy message",title:_?"Copy visible portion":"Copy message",children:c.jsx(oe.Copy,{className:ee(b?"text-success":Q,G?"h-3 w-3":"h-4 w-4")})}),_&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:()=>J("all"),className:ee("h-6 px-1 text-xs hover:bg-foreground/10",Q),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),B==="user"&&w&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:U,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",Q,G&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(oe.Edit,{className:ee(Q,G?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-foreground/10",Q,G&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(oe.RotateCcw,{className:ee(Q,G?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:Je()}),_&&E==="expanded"&&(ue.toolCallId||ue.name)&&c.jsxs("div",{className:ee("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[ue.name&&c.jsxs("div",{children:["Function: ",ue.name]}),ue.toolCallId&&c.jsxs("div",{children:["Call ID: ",ue.toolCallId]})]}),!(i||a||_)&&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(Ve,{variant:"ghost",size:"sm",onClick:()=>J(),className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(oe.Copy,{className:ee(b?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),B==="user"&&w&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:U,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(oe.Edit,{className:ee("text-current",G?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&v&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:de,className:ee("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(oe.RotateCcw,{className:ee("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),K&&c.jsx(eb,{isOpen:H,onClose:()=>{M(!1),W(null)},fileId:K.id,fileName:K.name,mimeType:K.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&fd(e.message)===fd(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),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 lb({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:Ji(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:cb(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ji(e)})}function cb(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(Vr(e))})}catch{return String(e)}}function ub({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(zr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Hr,{className:"pb-3",children:[c.jsx(Ur,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Qc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(eu,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ve,{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(Ve,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function db({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 fb({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 pd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Zi=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:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const S=y.useRef(null),E=y.useRef(null),C=y.useRef(!1),[k,I]=y.useState(!0),A=y.useCallback(L=>{I(L),g&&g(!L),x&&x(L)},[g,x]),j=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),P=y.useMemo(()=>!w||v?!1:k?"auto":!1,[k,w,v]);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($x,{ref:L=>{S.current=L},scrollerRef:L=>{E.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,$)=>pd($,L),itemContent:(L,$)=>{const H=pd($,L);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":H,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(hd,{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})})}})})});Zi.displayName="MessageList";const rs=1e4;function hb(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
127
127
  `).replace(/<p>(.*?)<\/p>/gi,`$1
128
128
 
129
129
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -131,4 +131,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
131
131
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
132
132
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
133
133
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
134
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function pb(e,t=rs){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 mb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),pb(t),hb(t)}function Qi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Rn.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),N=Le(g,S.collectionRef);return c.jsx(l,{ref:N,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Rn.createSlot(d),p=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,N=y.useRef(null),C=Le(g,N),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(N,{ref:N,...S}),()=>void k.itemMap.delete(N))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,I)=>S.indexOf(k.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var gb=m.createContext(void 0);function os(e){const t=m.useContext(gb);return e||t||"ltr"}const xb=["top","right","bottom","left"],Cn=Math.min,Rt=Math.max,ss=Math.round,is=Math.floor,rn=e=>({x:e,y:e}),vb={left:"right",right:"left",bottom:"top",top:"bottom"},wb={start:"end",end:"start"};function ea(e,t,n){return Rt(e,Cn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function ta(e){return e==="x"?"y":"x"}function na(e){return e==="y"?"height":"width"}const bb=new Set(["top","bottom"]);function on(e){return bb.has(fn(e))?"y":"x"}function ra(e){return ta(on(e))}function yb(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=ra(e),s=na(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=as(i)),[i,as(i)]}function Sb(e){const t=as(e);return[oa(e),t,oa(t)]}function oa(e){return e.replace(/start|end/g,t=>wb[t])}const pd=["left","right"],md=["right","left"],Cb=["top","bottom"],Tb=["bottom","top"];function kb(e,t,n){switch(e){case"top":case"bottom":return n?t?md:pd:t?pd:md;case"left":case"right":return t?Cb:Tb;default:return[]}}function Eb(e,t,n,r){const o=dr(e);let s=kb(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(oa)))),s}function as(e){return e.replace(/left|right|bottom|top/g,t=>vb[t])}function Ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function gd(e){return typeof e!="number"?Ib(e):{top:e,right:e,bottom:e,left:e}}function ls(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 xd(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=ra(t),a=na(i),l=fn(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 Nb=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}=xd(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:N,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...N}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=xd(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Vr(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),w=gd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ls(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),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},C=ls(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+w.top)/N.y,bottom:(C.bottom-x.bottom+w.bottom)/N.y,left:(x.left-C.left+w.left)/N.x,right:(C.right-x.right+w.right)/N.x}}const Ab=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=gd(d),h={x:n,y:r},p=ra(o),w=na(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",N=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=k?k[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(k)))&&(I=a.floating[S]||s.floating[w]);const A=N/2-C/2,R=I/2-v[w]/2-1,P=Cn(f[x],R),L=Cn(f[b],R),$=P,H=I-v[w]-L,M=I/2-v[w]/2+A,q=ea($,M,H),V=!l.arrow&&dr(o)!=null&&M!==q&&s.reference[w]/2-(M<$?P:L)-v[w]/2<0,Y=V?M<$?M-$:M-H:0;return{[p]:h[p]+Y,data:{[p]:q,centerOffset:M-q-Y,...V&&{alignmentOffset:Y}},reset:V}}}),_b=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:w="none",flipAlignment:v=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),b=on(a),S=fn(a)===a,N=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[as(a)]:Sb(a)),k=w!=="none";!h&&k&&C.push(...Eb(a,v,w,N));const I=[a,...C],A=await Vr(t,g),R=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[x]),f){const M=yb(o,i,N);R.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:R}],!R.every(M=>M<=0)){var L,$;const M=(((L=s.flip)==null?void 0:L.index)||0)+1,q=I[M];if(q&&(!(f==="alignment"?b!==on(q):!1)||P.every(B=>on(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:q}};let V=($=P.filter(Y=>Y.overflows[0]<=0).sort((Y,B)=>Y.overflows[1]-B.overflows[1])[0])==null?void 0:$.placement;if(!V)switch(p){case"bestFit":{var H;const Y=(H=P.filter(B=>{if(k){const j=on(B.placement);return j===b||j==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(j=>j>0).reduce((j,G)=>j+G,0)]).sort((B,j)=>B[1]-j[1])[0])==null?void 0:H[0];Y&&(V=Y);break}case"initialPlacement":V=a;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function vd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function wd(e){return xb.some(t=>e[t]>=0)}const jb=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 Vr(t,{...o,elementContext:"reference"}),i=vd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:wd(i)}}}case"escaped":{const s=await Vr(t,{...o,altBoundary:!0}),i=vd(s,n.floating);return{data:{escapedOffsets:i,escaped:wd(i)}}}default:return{}}}}},bd=new Set(["left","top"]);async function Rb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=dr(n),l=on(n)==="y",u=bd.has(i)?-1:1,d=s&&l?-1:1,f=dn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Pb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Rb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Ob=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=dn(e,t),u={x:n,y:r},d=await Vr(t,l),f=on(fn(o)),h=ta(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],S=p-d[x];p=ea(b,p,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=ea(b,w,S)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},Mb=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=on(o),h=ta(f);let p=d[h],w=d[f];const v=dn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",N=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<N?p=N:p>C&&(p=C)}if(u){var x,b;const S=h==="y"?"width":"height",N=bd.has(fn(o)),C=s.reference[f]-s.floating[S]+(N&&((x=i.offset)==null?void 0:x[f])||0)+(N?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(N?0:((b=i.offset)==null?void 0:b[f])||0)-(N?g.crossAxis:0);w<C?w=C:w>k&&(w=k)}return{[h]:p,[f]:w}}}},Db=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 Vr(t,u),f=fn(o),h=dr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,N=Cn(v-d[g],b),C=Cn(w-d[x],S),k=!t.middlewareData.shift;let I=N,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),k&&!h){const P=Rt(d.left,0),L=Rt(d.right,0),$=Rt(d.top,0),H=Rt(d.bottom,0);p?A=w-2*(P!==0||L!==0?P+L:Rt(d.left,d.right)):I=v-2*($!==0||H!==0?$+H:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const R=await i.getDimensions(a.floating);return w!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function cs(){return typeof window<"u"}function fr(e){return yd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(yd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function yd(e){return cs()?e instanceof Node||e instanceof Pt(e).Node:!1}function Kt(e){return cs()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return cs()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function Sd(e){return!cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const Lb=new Set(["inline","contents"]);function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Lb.has(o)}const $b=new Set(["table","td","th"]);function Fb(e){return $b.has(fr(e))}const Bb=[":popover-open",":modal"];function us(e){return Bb.some(t=>{try{return e.matches(t)}catch{return!1}})}const zb=["transform","translate","scale","rotate","perspective"],Hb=["transform","translate","scale","rotate","perspective","filter"],Ub=["paint","layout","strict","content"];function sa(e){const t=ia(),n=Kt(e)?qt(e):e;return zb.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)||Hb.some(r=>(n.willChange||"").includes(r))||Ub.some(r=>(n.contain||"").includes(r))}function Wb(e){let t=Tn(e);for(;an(t)&&!hr(t);){if(sa(t))return t;if(us(t))return null;t=Tn(t)}return null}function ia(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Vb=new Set(["html","body","#document"]);function hr(e){return Vb.has(fr(e))}function qt(e){return Pt(e).getComputedStyle(e)}function ds(e){return Kt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Sd(e)&&e.host||sn(e);return Sd(t)?t.host:t}function Cd(e){const t=Tn(e);return hr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&Kr(t)?t:Cd(t)}function qr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Cd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=aa(i);return t.concat(i,i.visualViewport||[],Kr(o)?o:[],a&&n?qr(a):[])}return t.concat(o,qr(o,[],n))}function aa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Td(e){const t=qt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ss(n)!==s||ss(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function la(e){return Kt(e)?e:e.contextElement}function pr(e){const t=la(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Td(t);let i=(s?ss(n.width):n.width)/r,a=(s?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Kb=rn(0);function kd(e){const t=Pt(e);return!ia()||!t.visualViewport?Kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=la(e);let i=rn(1);t&&(r?Kt(r)&&(i=pr(r)):i=pr(e));const a=qb(s,n,r)?kd(s):rn(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=Pt(s),p=r&&Kt(r)?Pt(r):r;let w=h,v=aa(w);for(;v&&r&&p!==w;){const g=pr(v),x=v.getBoundingClientRect(),b=qt(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,N=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=N,w=Pt(v),v=aa(w)}}return ls({width:d,height:f,x:l,y:u})}function fs(e,t){const n=ds(e).scrollLeft;return t?t.left+n:Vn(sn(e)).left+n}function Ed(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 Gb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((fr(r)!=="body"||Kr(i))&&(l=ds(r)),an(r))){const p=Vn(r);u=pr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Ed(i,l):rn(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 Yb(e){return Array.from(e.getClientRects())}function Xb(e){const t=sn(e),n=ds(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+fs(e);const a=-n.scrollTop;return qt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Id=25;function Jb(e,t){const n=Pt(e),r=sn(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=ia();(!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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Id&&(s-=w)}else u<=Id&&(s+=u);return{width:s,height:i,x:a,y:l}}const Zb=new Set(["absolute","fixed"]);function Qb(e,t){const n=Vn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?pr(e):rn(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 Nd(e,t,n){let r;if(t==="viewport")r=Jb(e,n);else if(t==="document")r=Xb(sn(e));else if(Kt(t))r=Qb(t,n);else{const o=kd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(r)}function Ad(e,t){const n=Tn(e);return n===t||!Kt(n)||hr(n)?!1:qt(n).position==="fixed"||Ad(n,t)}function ey(e,t){const n=t.get(e);if(n)return n;let r=qr(e,[],!1).filter(a=>Kt(a)&&fr(a)!=="body"),o=null;const s=qt(e).position==="fixed";let i=s?Tn(e):e;for(;Kt(i)&&!hr(i);){const a=qt(i),l=sa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Zb.has(o.position)||Kr(i)&&!l&&Ad(e,i))?r=r.filter(d=>d!==i):o=a,i=Tn(i)}return t.set(e,r),r}function ty(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?us(t)?[]:ey(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Nd(t,d,o);return u.top=Rt(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},Nd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ny(e){const{width:t,height:n}=Td(e);return{width:t,height:n}}function ry(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=Vn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=fs(o)}if(r||!r&&!s)if((fr(t)!=="body"||Kr(o))&&(a=ds(t)),r){const p=Vn(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?Ed(o,a):rn(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 ca(e){return qt(e).position==="static"}function _d(e,t){if(!an(e)||qt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function jd(e,t){const n=Pt(e);if(us(e))return n;if(!an(e)){let o=Tn(e);for(;o&&!hr(o);){if(Kt(o)&&!ca(o))return o;o=Tn(o)}return n}let r=_d(e,t);for(;r&&Fb(r)&&ca(r);)r=_d(r,t);return r&&hr(r)&&ca(r)&&!sa(r)?n:r||Wb(e)||n}const oy=async function(e){const t=this.getOffsetParent||jd,n=this.getDimensions,r=await n(e.floating);return{reference:ry(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sy(e){return qt(e).direction==="rtl"}const iy={convertOffsetParentRelativeRectToViewportRelativeRect:Gb,getDocumentElement:sn,getClippingRect:ty,getOffsetParent:jd,getElementRects:oy,getClientRects:Yb,getDimensions:ny,getScale:pr,isElement:Kt,isRTL:sy};function Rd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ay(e,t){let n=null,r;const o=sn(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 w=is(f),v=is(o.clientWidth-(d+h)),g=is(o.clientHeight-(f+p)),x=is(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,Cn(1,l))||1};let N=!0;function C(k){const I=k[0].intersectionRatio;if(I!==l){if(!N)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Rd(u,e.getBoundingClientRect())&&i(),N=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function ly(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=la(e),d=o||s?[...u?qr(u):[],...qr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?ay(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,v=l?Vn(e):null;l&&g();function g(){const x=Vn(e);v&&!Rd(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const cy=Pb,uy=Ob,dy=_b,fy=Db,hy=jb,Pd=Ab,py=Mb,my=(e,t,n)=>{const r=new Map,o={platform:iy,...n},s={...o.platform,_c:r};return Nb(e,t,{...o,platform:s})};var gy=typeof document<"u",xy=function(){},hs=gy?y.useLayoutEffect:xy;function ps(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(!ps(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)&&!ps(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Od(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Md(e,t){const n=Od(e);return Math.round(t*n)/n}function ua(e){const t=m.useRef(e);return hs(()=>{t.current=e}),t}function vy(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);ps(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(B=>{B!==k.current&&(k.current=B,v(B))},[]),S=m.useCallback(B=>{B!==I.current&&(I.current=B,x(B))},[]),N=s||w,C=i||g,k=m.useRef(null),I=m.useRef(null),A=m.useRef(d),R=l!=null,P=ua(l),L=ua(o),$=ua(u),H=m.useCallback(()=>{if(!k.current||!I.current)return;const B={placement:t,strategy:n,middleware:h};L.current&&(B.platform=L.current),my(k.current,I.current,B).then(j=>{const G={...j,isPositioned:$.current!==!1};M.current&&!ps(A.current,G)&&(A.current=G,ro.flushSync(()=>{f(G)}))})},[h,t,n,L,$]);hs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[u]);const M=m.useRef(!1);hs(()=>(M.current=!0,()=>{M.current=!1}),[]),hs(()=>{if(N&&(k.current=N),C&&(I.current=C),N&&C){if(P.current)return P.current(N,C,H);H()}},[N,C,H,P,R]);const q=m.useMemo(()=>({reference:k,floating:I,setReference:b,setFloating:S}),[b,S]),V=m.useMemo(()=>({reference:N,floating:C}),[N,C]),Y=m.useMemo(()=>{const B={position:n,left:0,top:0};if(!V.floating)return B;const j=Md(V.floating,d.x),G=Md(V.floating,d.y);return a?{...B,transform:"translate("+j+"px, "+G+"px)",...Od(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:G}},[n,a,V.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:H,refs:q,elements:V,floatingStyles:Y}),[d,H,q,V,Y])}const wy=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?Pd({element:r.current,padding:o}).fn(n):{}:r?Pd({element:r,padding:o}).fn(n):{}}}},by=(e,t)=>({...cy(e),options:[e,t]}),yy=(e,t)=>({...uy(e),options:[e,t]}),Sy=(e,t)=>({...py(e),options:[e,t]}),Cy=(e,t)=>({...dy(e),options:[e,t]}),Ty=(e,t)=>({...fy(e),options:[e,t]}),ky=(e,t)=>({...hy(e),options:[e,t]}),Ey=(e,t)=>({...wy(e),options:[e,t]});var Iy="Arrow",Dd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ie.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"})})});Dd.displayName=Iy;var Ny=Dd;function Ld(e){const[t,n]=m.useState(void 0);return pt(()=>{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 da="Popper",[$d,ms]=en(da),[Ay,Fd]=$d(da),Bd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};Bd.displayName=da;var zd="PopperAnchor",Hd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Fd(zd,n),i=m.useRef(null),a=Le(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(Ie.div,{...o,ref:a})});Hd.displayName=zd;var fa="PopperContent",[_y,jy]=$d(fa),Ud=m.forwardRef((e,t)=>{var K,D,J,U,fe,ue;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:w,...v}=e,g=Fd(fa,n),[x,b]=m.useState(null),S=Le(t,$e=>b($e)),[N,C]=m.useState(null),k=Ld(N),I=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,R=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,H={padding:P,boundary:L.filter(Py),altBoundary:$},{refs:M,floatingStyles:q,placement:V,isPositioned:Y,middlewareData:B}=vy({strategy:"fixed",placement:R,whileElementsMounted:(...$e)=>ly(...$e,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[by({mainAxis:o+A,alignmentAxis:i}),l&&yy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Sy():void 0,...H}),l&&Cy({...H}),Ty({...H,apply:({elements:$e,rects:Ge,availableWidth:qe,availableHeight:ke})=>{const{width:Oe,height:Be}=Ge.reference,Ue=$e.floating.style;Ue.setProperty("--radix-popper-available-width",`${qe}px`),Ue.setProperty("--radix-popper-available-height",`${ke}px`),Ue.setProperty("--radix-popper-anchor-width",`${Oe}px`),Ue.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),N&&Ey({element:N,padding:a}),Oy({arrowWidth:I,arrowHeight:A}),h&&ky({strategy:"referenceHidden",...H})]}),[j,G]=Kd(V),Z=mt(w);pt(()=>{Y&&(Z==null||Z())},[Y,Z]);const ge=(K=B.arrow)==null?void 0:K.x,de=(D=B.arrow)==null?void 0:D.y,ee=((J=B.arrow)==null?void 0:J.centerOffset)!==0,[Ae,Te]=m.useState();return pt(()=>{x&&Te(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:Y?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(U=B.transformOrigin)==null?void 0:U.x,(fe=B.transformOrigin)==null?void 0:fe.y].join(" "),...((ue=B.hide)==null?void 0:ue.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(_y,{scope:n,placedSide:j,onArrowChange:C,arrowX:ge,arrowY:de,shouldHideArrow:ee,children:c.jsx(Ie.div,{"data-side":j,"data-align":G,...v,ref:S,style:{...v.style,animation:Y?void 0:"none"}})})})});Ud.displayName=fa;var Wd="PopperArrow",Ry={top:"bottom",right:"left",bottom:"top",left:"right"},Vd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=jy(Wd,r),i=Ry[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(Ny,{...o,ref:n,style:{...o.style,display:"block"}})})});Vd.displayName=Wd;function Py(e){return e!==null}var Oy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Kd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Kd(e){const[t,n="center"]=e.split("-");return[t,n]}var qd=Bd,Gd=Hd,Yd=Ud,Xd=Vd,ha="rovingFocusGroup.onEntryFocus",My={bubbles:!1,cancelable:!0},Gr="RovingFocusGroup",[pa,Jd,Dy]=Qi(Gr),[Ly,Zd]=en(Gr,[Dy]),[$y,Fy]=Ly(Gr),Qd=m.forwardRef((e,t)=>c.jsx(pa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(pa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(By,{...e,ref:t})})}));Qd.displayName=Gr;var By=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=Le(t,h),w=os(s),[v,g]=Bn({prop:i,defaultProp:a??null,onChange:l,caller:Gr}),[x,b]=m.useState(!1),S=mt(u),N=Jd(n),C=m.useRef(!1),[k,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ha,S),()=>A.removeEventListener(ha,S)},[S]),c.jsx($y,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(Ie.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!x){const P=new CustomEvent(ha,My);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=N().filter(V=>V.focusable),$=L.find(V=>V.active),H=L.find(V=>V.id===v),q=[$,H,...L].filter(Boolean).map(V=>V.ref.current);nf(q,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>b(!1))})})}),ef="RovingFocusGroupItem",tf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Fy(ef,n),f=d.currentTabStopId===u,h=Jd(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(pa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ce(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Uy(g,d.orientation,d.dir);if(x!==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(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const N=S.indexOf(g.currentTarget);S=d.loop?Wy(S,N+1):S.slice(N+1)}setTimeout(()=>nf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});tf.displayName=ef;var zy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uy(e,t,n){const r=Hy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zy[r]}function nf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vy=Qd,Ky=tf,ma=["Enter"," "],qy=["ArrowDown","PageUp","Home"],rf=["ArrowUp","PageDown","End"],Gy=[...qy,...rf],Yy={ltr:[...ma,"ArrowRight"],rtl:[...ma,"ArrowLeft"]},Xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Yr="Menu",[Xr,Jy,Zy]=Qi(Yr),[Kn,of]=en(Yr,[Zy,ms,Zd]),gs=ms(),sf=Zd(),[Qy,qn]=Kn(Yr),[e0,Jr]=Kn(Yr),af=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=os(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(qd,{...a,children:c.jsx(Qy,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(e0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};af.displayName=Yr;var t0="MenuAnchor",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Gd,{...o,...r,ref:t})});ga.displayName=t0;var xa="MenuPortal",[n0,lf]=Kn(xa,{forceMount:void 0}),cf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(xa,t);return c.jsx(n0,{scope:t,forceMount:n,children:c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:r})})})};cf.displayName=xa;var Lt="MenuContent",[r0,va]=Kn(Lt),uf=m.forwardRef((e,t)=>{const n=lf(Lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Lt,e.__scopeMenu),i=Jr(Lt,e.__scopeMenu);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(o0,{...o,ref:t}):c.jsx(s0,{...o,ref:t})})})})}),o0=m.forwardRef((e,t)=>{const n=qn(Lt,e.__scopeMenu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),s0=m.forwardRef((e,t)=>{const n=qn(Lt,e.__scopeMenu);return c.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),i0=Rn.createSlot("MenuContent.ScrollLock"),wa=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:w,...v}=e,g=qn(Lt,n),x=Jr(Lt,n),b=gs(n),S=sf(n),N=Jy(n),[C,k]=m.useState(null),I=m.useRef(null),A=Le(t,I,g.onContentChange),R=m.useRef(0),P=m.useRef(""),L=m.useRef(0),$=m.useRef(null),H=m.useRef("right"),M=m.useRef(0),q=w?Go:m.Fragment,V=w?{as:i0,allowPinchZoom:!0}:void 0,Y=j=>{var K,D;const G=P.current+j,Z=N().filter(J=>!J.disabled),ge=document.activeElement,de=(K=Z.find(J=>J.ref.current===ge))==null?void 0:K.textValue,ee=Z.map(J=>J.textValue),Ae=v0(ee,G,de),Te=(D=Z.find(J=>J.textValue===Ae))==null?void 0:D.ref.current;(function J(U){P.current=U,window.clearTimeout(R.current),U!==""&&(R.current=window.setTimeout(()=>J(""),1e3))})(G),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),zi();const B=m.useCallback(j=>{var Z,ge;return H.current===((Z=$.current)==null?void 0:Z.side)&&b0(j,(ge=$.current)==null?void 0:ge.area)},[]);return c.jsx(r0,{scope:n,searchRef:P,onItemEnter:m.useCallback(j=>{B(j)&&j.preventDefault()},[B]),onItemLeave:m.useCallback(j=>{var G;B(j)||((G=I.current)==null||G.focus(),k(null))},[B]),onTriggerLeave:m.useCallback(j=>{B(j)&&j.preventDefault()},[B]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback(j=>{$.current=j},[]),children:c.jsx(q,{...V,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,j=>{var G;j.preventDefault(),(G=I.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Vy,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:ce(l,j=>{x.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Yd,{role:"menu","aria-orientation":"vertical","data-state":If(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:ce(v.onKeyDown,j=>{const Z=j.target.closest("[data-radix-menu-content]")===j.currentTarget,ge=j.ctrlKey||j.altKey||j.metaKey,de=j.key.length===1;Z&&(j.key==="Tab"&&j.preventDefault(),!ge&&de&&Y(j.key));const ee=I.current;if(j.target!==ee||!Gy.includes(j.key))return;j.preventDefault();const Te=N().filter(K=>!K.disabled).map(K=>K.ref.current);rf.includes(j.key)&&Te.reverse(),g0(Te)}),onBlur:ce(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(R.current),P.current="")}),onPointerMove:ce(e.onPointerMove,Qr(j=>{const G=j.target,Z=M.current!==j.clientX;if(j.currentTarget.contains(G)&&Z){const ge=j.clientX>M.current?"right":"left";H.current=ge,M.current=j.clientX}}))})})})})})})});uf.displayName=Lt;var a0="MenuGroup",ba=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"group",...r,ref:t})});ba.displayName=a0;var l0="MenuLabel",df=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{...r,ref:t})});df.displayName=l0;var xs="MenuItem",ff="menu.itemSelect",vs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Jr(xs,e.__scopeMenu),a=va(xs,e.__scopeMenu),l=Le(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ff,{bubbles:!0,cancelable:!0});f.addEventListener(ff,p=>r==null?void 0:r(p),{once:!0}),Kc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(hf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ce(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ce(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ma.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=va(xs,n),a=sf(n),l=m.useRef(null),u=Le(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Xr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Ky,{asChild:!0,...a,focusable:!r,children:c.jsx(Ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ce(e.onPointerMove,Qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,Qr(w=>i.onItemLeave(w))),onFocus:ce(e.onFocus,()=>f(!0)),onBlur:ce(e.onBlur,()=>f(!1))})})})}),c0="MenuCheckboxItem",pf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(wf,{scope:e.__scopeMenu,checked:n,children:c.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Sa(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pf.displayName=c0;var mf="MenuRadioGroup",[u0,d0]=Kn(mf,{value:void 0,onValueChange:()=>{}}),gf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(u0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ba,{...o,ref:t})})});gf.displayName=mf;var xf="MenuRadioItem",vf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=d0(xf,e.__scopeMenu),s=n===o.value;return c.jsx(wf,{scope:e.__scopeMenu,checked:s,children:c.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sa(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});vf.displayName=xf;var ya="MenuItemIndicator",[wf,f0]=Kn(ya,{checked:!1}),bf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=f0(ya,n);return c.jsx(jt,{present:r||ws(s.checked)||s.checked===!0,children:c.jsx(Ie.span,{...o,ref:t,"data-state":Sa(s.checked)})})});bf.displayName=ya;var h0="MenuSeparator",yf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yf.displayName=h0;var p0="MenuArrow",Sf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Xd,{...o,...r,ref:t})});Sf.displayName=p0;var m0="MenuSub",[JC,Cf]=Kn(m0),Zr="MenuSubTrigger",Tf=m.forwardRef((e,t)=>{const n=qn(Zr,e.__scopeMenu),r=Jr(Zr,e.__scopeMenu),o=Cf(Zr,e.__scopeMenu),s=va(Zr,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(hf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":If(n.open),...e,ref:Ii(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:ce(e.onPointerMove,Qr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,Qr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Yy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Tf.displayName=Zr;var kf="MenuSubContent",Ef=m.forwardRef((e,t)=>{const n=lf(Lt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Lt,e.__scopeMenu),i=Jr(Lt,e.__scopeMenu),a=Cf(kf,e.__scopeMenu),l=m.useRef(null),u=Le(t,l);return c.jsx(Xr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Xr.Slot,{scope:e.__scopeMenu,children:c.jsx(wa,{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:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Xy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Ef.displayName=kf;function If(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Sa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function g0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function x0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function v0(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=x0(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 w0(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 b0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return w0(n,t)}function Qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var y0=af,S0=ga,C0=cf,T0=uf,k0=ba,E0=df,I0=vs,N0=pf,A0=gf,_0=vf,j0=bf,R0=yf,P0=Sf,O0=Tf,M0=Ef,bs="DropdownMenu",[D0,ZC]=en(bs,[of]),St=of(),[L0,Nf]=D0(bs),Af=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=St(t),u=m.useRef(null),[d,f]=Bn({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return c.jsx(L0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(y0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Af.displayName=bs;var _f="DropdownMenuTrigger",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Nf(_f,n),i=St(n);return c.jsx(S0,{asChild:!0,...i,children:c.jsx(Ie.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:Ii(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});jf.displayName=_f;var $0="DropdownMenuPortal",Rf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=St(t);return c.jsx(C0,{...r,...n})};Rf.displayName=$0;var Pf="DropdownMenuContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nf(Pf,n),s=St(n),i=m.useRef(!1);return c.jsx(T0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Of.displayName=Pf;var F0="DropdownMenuGroup",B0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(k0,{...o,...r,ref:t})});B0.displayName=F0;var z0="DropdownMenuLabel",Mf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(E0,{...o,...r,ref:t})});Mf.displayName=z0;var H0="DropdownMenuItem",Df=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(I0,{...o,...r,ref:t})});Df.displayName=H0;var U0="DropdownMenuCheckboxItem",Lf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(N0,{...o,...r,ref:t})});Lf.displayName=U0;var W0="DropdownMenuRadioGroup",V0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(A0,{...o,...r,ref:t})});V0.displayName=W0;var K0="DropdownMenuRadioItem",$f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(_0,{...o,...r,ref:t})});$f.displayName=K0;var q0="DropdownMenuItemIndicator",Ff=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(j0,{...o,...r,ref:t})});Ff.displayName=q0;var G0="DropdownMenuSeparator",Bf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(R0,{...o,...r,ref:t})});Bf.displayName=G0;var Y0="DropdownMenuArrow",X0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(P0,{...o,...r,ref:t})});X0.displayName=Y0;var J0="DropdownMenuSubTrigger",zf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(O0,{...o,...r,ref:t})});zf.displayName=J0;var Z0="DropdownMenuSubContent",Hf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(M0,{...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)"}})});Hf.displayName=Z0;var Q0=Af,eS=jf,tS=Rf,Uf=Of,Wf=Mf,Vf=Df,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf;const nS=Q0,rS=eS,oS=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Xf,{ref:o,className:Q("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(re.ChevronRight,{className:"ml-auto h-4 w-4"})]}));oS.displayName=Xf.displayName;const sS=m.forwardRef(({className:e,...t},n)=>c.jsx(Jf,{ref:n,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));sS.displayName=Jf.displayName;const Zf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(tS,{children:c.jsx(Uf,{ref:r,sideOffset:t,className:Q("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Zf.displayName=Uf.displayName;const Ca=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Vf,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Ca.displayName=Vf.displayName;const iS=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Kf,{ref:o,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gf,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),t]}));iS.displayName=Kf.displayName;const aS=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(qf,{ref:r,className:Q("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Gf,{children:c.jsx(re.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));aS.displayName=qf.displayName;const lS=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Wf,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));lS.displayName=Wf.displayName;const cS=m.forwardRef(({className:e,...t},n)=>c.jsx(Yf,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));cS.displayName=Yf.displayName;function ys({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:w}=Gs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=go(),{messages:N,hasMoreHistory:C,isLoadingHistory:k,send:I,stop:A,loadOlderMessages:R}=ni(),{isStreaming:P,error:L,streamingAssistantId:$,lastCheckpointId:H,lastCheckpointNs:M}=Vl(),[q,V]=y.useState(null),[Y,B]=y.useState(""),[j,G]=y.useState(null),[Z,ge]=y.useState([]),[de,ee]=y.useState(0),[Ae,Te]=y.useState(0),[K,D]=y.useState(!1),[J,U]=y.useState(null),[fe,ue]=y.useState(null),[$e,Ge]=y.useState(!1),[qe,ke]=y.useState(null),[Oe,Be]=y.useState([]),[Ue,st]=y.useState(null),[ot,ne]=y.useState(null),[le,xe]=y.useState(!1),Se=y.useRef(null),be=y.useRef(null),je=y.useRef(null),Qe=y.useCallback(()=>{Se.current&&(Se.current.value=""),be.current&&(be.current.value=""),ee(se=>se+1),Te(se=>se+1)},[]),Ye=y.useRef(!1);y.useEffect(()=>{Ye.current&&!P&&(ge([]),Qe()),Ye.current=P},[P,Qe]);const[it,gt]=y.useState("desktop");y.useEffect(()=>{const se=()=>{const E=window.innerWidth;gt(E<640?"phone":E<1024?"tablet":"desktop")};return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]),y.useEffect(()=>{let se=!1;if(!v){Be([]),st(null),ne(null),je.current=null;return}const E={threadId:v,checkpointId:H??null,checkpointNs:M??null},_=je.current;if(!(_&&_.threadId===E.threadId&&_.checkpointId===E.checkpointId&&_.checkpointNs===E.checkpointNs))return x(v).then(W=>{var ht;if(se)return;const ie=((W==null?void 0:W.checkpoints)??[]).slice().sort((T,F)=>new Date(F.createdAt).getTime()-new Date(T.createdAt).getTime());Be(ie);const pe=Ue,he=pe&&ie.some(T=>T.checkpointId===pe)?pe:((ht=ie[0])==null?void 0:ht.checkpointId)??null;let et=null;if(he){const T=ie.find(F=>F.checkpointId===he);et=(T==null?void 0:T.checkpointNs)??null}st(he),ne(et),je.current=E}).catch(W=>{console.error("ChatInterface - listCheckpoints error:",W),se||(Be([]),je.current=null)}),()=>{se=!0}},[v,H,M,Ue,x]),y.useEffect(()=>{H&&(st(H),ne(M??null))},[H,M]);const hn=y.useCallback(async()=>{if(!(!C||k))try{await R()}catch(se){console.warn("loadOlderMessages failed",se)}},[C,k,R]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){ke(null);return}try{const E=await w.getAgent("default");ke(E.uiDefaultMessage||null)}catch(E){console.warn("Failed to fetch default message:",E),ke(null)}})()},[w]),y.useEffect(()=>{L&&!$e&&(p==null||p(L))},[L,$e,p]);const Jn=se=>{if(se.length>rs)return`Message too long (${se.length}/${rs} characters)`;try{return mb(se),null}catch(E){return(E==null?void 0:E.message)||"Invalid message"}},vr=async se=>{const E=se.trim();if(!(!E&&Z.length===0)){if(E){const _=Jn(E);if(_){G(_);return}}try{await I(E||"",{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0,payloadExtras:q?{edit:!0,originalMessageId:q}:void 0,attachments:Z}),f==null||f(E),G(null),ge([]),Qe(),V(null),B("")}catch(_){const W=(_==null?void 0:_.message)||"Failed to send message";G(W),p==null||p(W)}}},Zn=y.useCallback((se,E)=>{u&&(V(se),B(E),G(null))},[u]),Nn=y.useCallback(()=>{V(null),B(""),G(null)},[]),Bt=y.useCallback((se,E)=>{Zn(se,E)},[Zn]),An=y.useCallback(se=>{const E=_=>{const W=_.content||[],ie=W.filter(pe=>pe.type==="text").map(pe=>pe.text).join("");if(ie)return ie;try{return JSON.stringify(W,null,2)}catch{return String(W)}};for(let _=se-1;_>=0;_--)if(N[_].role==="user"){const W=E(N[_]);W&&I(W,{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0});break}},[N,I,Ue,ot,H,M]),Qn=se=>{const E=Array.from(se.target.files||[]);ge(_=>[..._,...E]),se.target.value=""},Yt=se=>{ge(E=>{const _=E.filter((W,ie)=>se!==ie);return _.length===0&&Qe(),_})},_n=async se=>{const E=(se.target.files||[])[0];if(E){U(null),ue(null),D(!0);try{await I("",{checkpointId:Ue??H??void 0,checkpointNs:ot??M??void 0,attachments:[E]});const _=`Uploaded ${E.name} - processing through chat stream`;ue(_)}catch(_){const W=_ instanceof Error?_.message:"Failed to upload Excel file";console.error("Excel upload failed",_),U(W),p==null||p(W)}finally{D(!1),se.target.value="",Qe()}}},jn=se=>{if(!se)return"Unknown";const E=Date.parse(se);return Number.isNaN(E)?se:new Date(E).toLocaleString()},er=async se=>{if(v){xe(!0);try{if(!se){await S(),st(null),ne(null);return}const E=Oe.find(W=>W.checkpointId===se),_=(E==null?void 0:E.checkpointNs)??null;await b(se,_),st(se),ne(_)}finally{xe(!1)}}},wr=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,br=`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||""}`,to=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:wr,children:[!!L&&!$e&&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:L}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Ge(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(re.X,{size:16})})]}),v&&Oe.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:Ue??"",onChange:se=>{const E=se.target.value||null;er(E)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(se=>c.jsxs("option",{value:se.checkpointId,children:[jn(se.createdAt),se.preview?` — ${se.preview.slice(0,40)}`:""]},se.checkpointId))]})]}),c.jsxs("div",{className:`relative ${br}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Zi,{className:"h-full",style:{height:"100%"},messages:N,isStreaming:P,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:it,enableMessageEditing:u,editingMessageId:q,onStartReached:()=>{hn()},onEdit:Bt,onRegenerate:An,onCancelEdit:Nn,emptyMessage:qe??void 0,isNavigatingCheckpoint:le}),g&&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(re.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:to,children:[q&&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(re.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(He,{variant:"ghost",size:"sm",onClick:Nn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(re.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:Se,type:"file",multiple:!0,onChange:se=>Qn(se),className:"hidden"},de),Z.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Z.map((se,E)=>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(re.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:se.name}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>Yt(E),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 ${se.name}`,children:c.jsx(re.X,{size:12})})]},E))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:be,type:"file",accept:".xls,.xlsx,.xlsm",onChange:_n,className:"hidden"},Ae),K&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(re.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),fe&&!K&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:fe}),J&&!K&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:J})]})]}),j&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:j}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(nS,{children:[c.jsx(rS,{asChild:!0,children:c.jsx(He,{type:"button",size:"icon",variant:"outline",disabled:P,title:"More input actions",className:d.moreButton||"",children:c.jsx(re.Plus,{size:16})})}),c.jsxs(Zf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Ca,{onClick:()=>{var se;return(se=Se.current)==null?void 0:se.click()},className:"cursor-pointer",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Ca,{onClick:()=>{var se;K||(se=be.current)==null||se.click()},className:`cursor-pointer ${K?"opacity-60 pointer-events-none":""}`,children:[c.jsx(re.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Ng,{initialValue:Y,editingMessageId:q,placeholder:q?"Edit your message...":t,isStreaming:P,disabled:!1,maxLength:rs,onSend:vr,onCancelEdit:Nn,onStop:A,allowEmptySend:Z.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${q?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${j?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:Q("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Ss.displayName="Input";function Ta(e,[t,n]){return Math.min(n,Math.max(t,e))}function uS(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ka="ScrollArea",[Qf,QC]=en(ka),[dS,$t]=Qf(ka),eh=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,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[S,N]=m.useState(0),[C,k]=m.useState(!1),[I,A]=m.useState(!1),R=Le(t,L=>l(L)),P=os(o);return c.jsx(dS,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:N,children:c.jsx(Ie.div,{dir:P,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});eh.displayName=ka;var th="ScrollAreaViewport",nh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=$t(th,n),a=m.useRef(null),l=Le(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(Ie.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})})]})});nh.displayName=th;var ln="ScrollAreaScrollbar",Ea=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,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(fS,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(hS,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(rh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ia,{...r,ref:t}):null});Ea.displayName=ln;var fS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,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(jt,{present:n||s,children:c.jsx(rh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),hS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=$t(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>l("SCROLL_END"),100),[a,l]=uS("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(jt,{present:n||a!=="hidden",children:c.jsx(Ia,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),rh=m.forwardRef((e,t)=>{const n=$t(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Es(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return mr(n.viewport,l),mr(n.content,l),c.jsx(jt,{present:r||s,children:c.jsx(Ia,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ia=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=$t(ln,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=lh(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 wS(h,i.current,a,p)}return n==="horizontal"?c.jsx(pS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=ch(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(mS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=ch(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}),pS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=$t(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(sh,{"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":ks(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),dh(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:Ts(i.paddingLeft),paddingEnd:Ts(i.paddingRight)}})}})}),mS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=$t(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(sh,{"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":ks(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),dh(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:Ts(i.paddingTop),paddingEnd:Ts(i.paddingBottom)}})}})}),[gS,oh]=Qf(ln),sh=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=$t(ln,n),[w,v]=m.useState(null),g=Le(t,R=>v(R)),x=m.useRef(null),b=m.useRef(""),S=p.viewport,N=r.content-r.viewport,C=mt(d),k=mt(l),I=Es(f,10);function A(R){if(x.current){const P=R.clientX-x.current.left,L=R.clientY-x.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const R=P=>{const L=P.target;(w==null?void 0:w.contains(L))&&C(P,N)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,w,N,C]),m.useEffect(k,[r,k]),mr(w,I),mr(p.content,I),c.jsx(gS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:k,onThumbPointerDown:mt(a),children:c.jsx(Ie.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:ce(e.onPointerMove,A),onPointerUp:ce(e.onPointerUp,R=>{const P=R.target;P.hasPointerCapture(R.pointerId)&&P.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Cs="ScrollAreaThumb",ih=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=oh(Cs,e.__scopeScrollArea);return c.jsx(jt,{present:n||o.hasThumb,children:c.jsx(xS,{ref:t,...r})})}),xS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=$t(Cs,n),i=oh(Cs,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Es(()=>{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=bS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ie.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:ce(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});ih.displayName=Cs;var Na="ScrollAreaCorner",ah=m.forwardRef((e,t)=>{const n=$t(Na,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(vS,{...e,ref:t}):null});ah.displayName=Na;var vS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=$t(Na,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return mr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),mr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ie.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 Ts(e){return e?parseInt(e,10):0}function lh(e,t){const n=e/t;return isNaN(n)?0:n}function ks(e){const t=lh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wS(e,t,n,r="ltr"){const o=ks(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 uh([l,u],f)(e)}function ch(e,t,n="ltr"){const r=ks(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=Ta(e,l);return uh([0,i],[0,a])(u)}function uh(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 dh(e,t){return e>0&&e<t}var bS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Es(e,t){const n=mt(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 mr(e,t){const n=mt(t);pt(()=>{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 fh=eh,yS=nh,SS=ah;const hh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(fh,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[c.jsx(yS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ph,{}),c.jsx(SS,{})]}));hh.displayName=fh.displayName;const ph=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ea,{ref:r,orientation:t,className:Q("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(ih,{className:"relative flex-1 rounded-full bg-border"})}));ph.displayName=Ea.displayName;function Aa({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{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=go(),[b,S]=y.useState(h??[]),[N,C]=y.useState(null),[k,I]=y.useState(""),[A,R]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const P=async j=>{try{await f(j),a==null||a(j),l==null||l(j)}catch(G){console.error("Failed to select thread:",G)}},L=async()=>{try{R(!0);const j=await w();u==null||u(j),a==null||a(j)}catch(j){console.error("Failed to create thread:",j)}finally{R(!1)}},$=async(j,G)=>{if(G.stopPropagation(),!!confirm("Delete this thread?"))try{await v(j),d==null||d(j)}catch(Z){console.error("Failed to delete thread:",Z)}},H=(j,G)=>{G.stopPropagation(),C(j.threadId),I(j.title||`Thread ${j.threadId.slice(0,8)}`)},M=async j=>{if(k.trim())try{await g(j,k.trim()),C(null),I("")}catch(G){console.error("Failed to update title:",G)}},q=()=>{C(null),I("")},V=(j,G)=>{j.key==="Enter"?M(G):j.key==="Escape"&&q()},Y=j=>{if(!j)return"";try{const G=new Date(j),ge=new Date().getTime()-G.getTime(),de=Math.floor(ge/(1e3*60*60*24));return de===0?G.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):de===1?"Yesterday":de<7?`${de} days ago`:G.toLocaleDateString()}catch{return""}},B=j=>j.title||`Thread ${j.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(He,{onClick:L,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(re.MessageSquarePlus,{size:20})})}),c.jsx(hh,{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:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(re.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(re.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"})]}):b.slice().sort((j,G)=>new Date(G.updatedAt||G.createdAt||"").getTime()-new Date(j.updatedAt||j.createdAt||"").getTime()).map(j=>c.jsxs("div",{onClick:()=>P(j.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===j.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:N===j.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:G=>G.stopPropagation(),children:[c.jsx(Ss,{value:k,onChange:G=>I(G.target.value),onKeyDown:G=>V(G,j.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(He,{variant:"ghost",size:"sm",onClick:()=>M(j.threadId),className:"h-6 w-6 p-0",children:c.jsx(re.Check,{size:12})}),c.jsx(He,{variant:"ghost",size:"sm",onClick:q,className:"h-6 w-6 p-0",children:c.jsx(re.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:B(j)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(re.Calendar,{size:10}),c.jsx("span",{children:Y(j.updatedAt||j.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&N!==j.threadId&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>H(j,G),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(re.Edit3,{size:12})}),n&&c.jsx(He,{variant:"ghost",size:"sm",onClick:G=>$(j.threadId,G),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(re.Trash2,{size:12})})]})]}),i===j.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},j.threadId))})})]})}function gr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function CS(e){if(typeof e!="string")return;const t=e.trim();if(t)return cn(t)}function mh(){const e=[gr("__API_BASE_URL__"),gr("__CHAT_API_BASE_URL__"),gr("__CHAT_API_URL__")];for(const t of e){const n=CS(t);if(n)return n}}function gh(){const e=[gr("__API_AUTH_TOKEN__"),gr("__CHAT_API_KEY__"),gr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function xh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return cn(t);return cn()}function vh(){const e={},t=mh(),n=gh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function wh(){const e=vh(),t=mn.getAuthToken(),n=mh();return{apiBaseUrl:xh(e.baseUrl,mn.baseUrl,n),apiKey:t||e.apiKey||gh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const bh="chat-settings";function TS(){try{const e=localStorage.getItem(bh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function kS(e){try{const t={...e,apiBaseUrl:cn(e.apiBaseUrl)};localStorage.setItem(bh,JSON.stringify(t)),t.apiKey&&mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ES(){const e=wh(),t=TS(),n=mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:xh(mn.baseUrl,r,e.apiBaseUrl)}}function IS(e){mn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),kS(e)}var NS="Label",yh=m.forwardRef((e,t)=>c.jsx(Ie.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())}}));yh.displayName=NS;var Sh=yh;const AS=no.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ft=m.forwardRef(({className:e,...t},n)=>c.jsx(Sh,{ref:n,className:Q(AS(),e),...t}));Ft.displayName=Sh.displayName;function Ch(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 Is="Switch",[_S,eT]=en(Is),[jS,RS]=_S(Is),Th=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),w=Le(t,S=>p(S)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=Bn({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return c.jsxs(jS,{scope:n,checked:x,disabled:a,children:[c.jsx(Ie.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Nh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:ce(e.onClick,S=>{b(N=>!N),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&c.jsx(Ih,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Th.displayName=Is;var kh="SwitchThumb",Eh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=RS(kh,n);return c.jsx(Ie.span,{"data-state":Nh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Eh.displayName=kh;var PS="SwitchBubbleInput",Ih=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Le(i,s),l=Ch(n),u=Ld(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 w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[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}})});Ih.displayName=PS;function Nh(e){return e?"checked":"unchecked"}var Ah=Th,OS=Eh;const kn=m.forwardRef(({className:e,...t},n)=>c.jsx(Ah,{className:Q("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(OS,{className:Q("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));kn.displayName=Ah.displayName;var _h=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"}),MS="VisuallyHidden",DS=m.forwardRef((e,t)=>c.jsx(Ie.span,{...e,ref:t,style:{..._h,...e.style}}));DS.displayName=MS;var LS=[" ","Enter","ArrowUp","ArrowDown"],$S=[" ","Enter"],Gn="Select",[Ns,As,FS]=Qi(Gn),[xr,tT]=en(Gn,[FS,ms]),_s=ms(),[BS,En]=xr(Gn),[zS,HS]=xr(Gn),jh=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:w}=e,v=_s(t),[g,x]=m.useState(null),[b,S]=m.useState(null),[N,C]=m.useState(!1),k=os(u),[I,A]=Bn({prop:r,defaultProp:o??!1,onChange:s,caller:Gn}),[R,P]=Bn({prop:i,defaultProp:a,onChange:l,caller:Gn}),L=m.useRef(null),$=g?w||!!g.closest("form"):!0,[H,M]=m.useState(new Set),q=Array.from(H).map(V=>V.props.value).join(";");return c.jsx(qd,{...v,children:c.jsxs(BS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:tn(),value:R,onValueChange:P,open:I,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(Ns.Provider,{scope:t,children:c.jsx(zS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(V=>{M(Y=>new Set(Y).add(V))},[]),onNativeOptionRemove:m.useCallback(V=>{M(Y=>{const B=new Set(Y);return B.delete(V),B})},[]),children:n})}),$?c.jsxs(tp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:V=>P(V.target.value),disabled:h,form:w,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(H)]},q):null]})})};jh.displayName=Gn;var Rh="SelectTrigger",Ph=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=_s(n),i=En(Rh,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),u=As(n),d=m.useRef("touch"),[f,h,p]=rp(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=op(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(Gd,{asChild:!0,...s,children:c.jsx(Ie.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":np(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:ce(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:ce(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&LS.includes(v.key)&&(w(),v.preventDefault())})})})});Ph.displayName=Rh;var Oh="SelectValue",Mh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=En(Oh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(Ie.span,{...a,ref:f,style:{pointerEvents:"none"},children:np(l.value)?c.jsx(c.Fragment,{children:i}):s})});Mh.displayName=Oh;var US="SelectIcon",Dh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ie.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Dh.displayName=US;var WS="SelectPortal",Lh=e=>c.jsx(Ho,{asChild:!0,...e});Lh.displayName=WS;var Yn="SelectContent",$h=m.forwardRef((e,t)=>{const n=En(Yn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ro.createPortal(c.jsx(Fh,{scope:e.__scopeSelect,children:c.jsx(Ns.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Bh,{...e,ref:t})});$h.displayName=Yn;var Gt=10,[Fh,In]=xr(Yn),VS="SelectContentImpl",KS=Rn.createSlot("SelectContent.RemoveScroll"),Bh=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:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=En(Yn,n),[S,N]=m.useState(null),[C,k]=m.useState(null),I=Le(t,K=>N(K)),[A,R]=m.useState(null),[P,L]=m.useState(null),$=As(n),[H,M]=m.useState(!1),q=m.useRef(!1);m.useEffect(()=>{if(S)return qi(S)},[S]),zi();const V=m.useCallback(K=>{const[D,...J]=$().map(ue=>ue.ref.current),[U]=J.slice(-1),fe=document.activeElement;for(const ue of K)if(ue===fe||(ue==null||ue.scrollIntoView({block:"nearest"}),ue===D&&C&&(C.scrollTop=0),ue===U&&C&&(C.scrollTop=C.scrollHeight),ue==null||ue.focus(),document.activeElement!==fe))return},[$,C]),Y=m.useCallback(()=>V([A,S]),[V,A,S]);m.useEffect(()=>{H&&Y()},[H,Y]);const{onOpenChange:B,triggerPointerDownPosRef:j}=b;m.useEffect(()=>{if(S){let K={x:0,y:0};const D=U=>{var fe,ue;K={x:Math.abs(Math.round(U.pageX)-(((fe=j.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(U.pageY)-(((ue=j.current)==null?void 0:ue.y)??0))}},J=U=>{K.x<=10&&K.y<=10?U.preventDefault():S.contains(U.target)||B(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,B,j]),m.useEffect(()=>{const K=()=>B(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[B]);const[G,Z]=rp(K=>{const D=$().filter(fe=>!fe.disabled),J=D.find(fe=>fe.ref.current===document.activeElement),U=op(D,K,J);U&&setTimeout(()=>U.ref.current.focus())}),ge=m.useCallback((K,D,J)=>{const U=!q.current&&!J;(b.value!==void 0&&b.value===D||U)&&(R(K),U&&(q.current=!0))},[b.value]),de=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ee=m.useCallback((K,D,J)=>{const U=!q.current&&!J;(b.value!==void 0&&b.value===D||U)&&L(K)},[b.value]),Ae=r==="popper"?_a:zh,Te=Ae===_a?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(Fh,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:ge,selectedItem:A,onItemLeave:de,itemTextRefCallback:ee,focusSelectedItem:Y,selectedItemText:P,position:r,isPositioned:H,searchRef:G,children:c.jsx(Go,{as:KS,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ce(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(Ae,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...x,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ce(x.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&Z(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let U=$().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(K.key)&&(U=U.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const fe=K.target,ue=U.indexOf(fe);U=U.slice(ue+1)}setTimeout(()=>V(U)),K.preventDefault()}})})})})})})});Bh.displayName=VS;var qS="SelectItemAlignedPosition",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=En(Yn,n),i=In(Yn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Le(t,I=>d(I)),h=As(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),P=x.getBoundingClientRect();if(s.dir!=="rtl"){const fe=P.left-A.left,ue=R.left-fe,$e=I.left-ue,Ge=I.width+$e,qe=Math.max(Ge,A.width),ke=window.innerWidth-Gt,Oe=Ta(ue,[Gt,Math.max(Gt,ke-qe)]);a.style.minWidth=Ge+"px",a.style.left=Oe+"px"}else{const fe=A.right-P.right,ue=window.innerWidth-R.right-fe,$e=window.innerWidth-I.right-ue,Ge=I.width+$e,qe=Math.max(Ge,A.width),ke=window.innerWidth-Gt,Oe=Ta(ue,[Gt,Math.max(Gt,ke-qe)]);a.style.minWidth=Ge+"px",a.style.right=Oe+"px"}const L=h(),$=window.innerHeight-Gt*2,H=v.scrollHeight,M=window.getComputedStyle(u),q=parseInt(M.borderTopWidth,10),V=parseInt(M.paddingTop,10),Y=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),j=q+V+H+B+Y,G=Math.min(g.offsetHeight*5,j),Z=window.getComputedStyle(v),ge=parseInt(Z.paddingTop,10),de=parseInt(Z.paddingBottom,10),ee=I.top+I.height/2-Gt,Ae=$-ee,Te=g.offsetHeight/2,K=g.offsetTop+Te,D=q+V+K,J=j-D;if(D<=ee){const fe=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const ue=u.clientHeight-v.offsetTop-v.offsetHeight,$e=Math.max(Ae,Te+(fe?de:0)+ue+Y),Ge=D+$e;a.style.height=Ge+"px"}else{const fe=L.length>0&&g===L[0].ref.current;a.style.top="0px";const $e=Math.max(ee,q+v.offsetTop+(fe?ge:0)+Te)+J;a.style.height=$e+"px",v.scrollTop=D-ee+v.offsetTop}a.style.margin=`${Gt}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>S(),[S]);const[N,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(YS,{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(Ie.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});zh.displayName=qS;var GS="SelectPopperPosition",_a=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Gt,...s}=e,i=_s(n);return c.jsx(Yd,{...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)"}})});_a.displayName=GS;var[YS,ja]=xr(Yn,{}),Ra="SelectViewport",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=In(Ra,n),i=ja(Ra,n),a=Le(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(Ns.Slot,{scope:n,children:c.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(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 w=window.innerHeight-Gt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,S=Math.min(w,b),N=b-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})})})]})});Hh.displayName=Ra;var Uh="SelectGroup",[XS,JS]=xr(Uh),ZS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(XS,{scope:n,id:o,children:c.jsx(Ie.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ZS.displayName=Uh;var Wh="SelectLabel",Vh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=JS(Wh,n);return c.jsx(Ie.div,{id:o.id,...r,ref:t})});Vh.displayName=Wh;var js="SelectItem",[QS,Kh]=xr(js),qh=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=En(js,n),l=In(js,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Le(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=tn(),g=m.useRef("touch"),x=()=>{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(QS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ie.div,{role:"option","aria-labelledby":v,"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:w,onFocus:ce(i.onFocus,()=>p(!0)),onBlur:ce(i.onBlur,()=>p(!1)),onClick:ce(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ce(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ce(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:ce(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,b=>{var N;((N=l.searchRef)==null?void 0:N.current)!==""&&b.key===" "||($S.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});qh.displayName=js;var eo="SelectItemText",Gh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=En(eo,n),a=In(eo,n),l=Kh(eo,n),u=HS(eo,n),[d,f]=m.useState(null),h=Le(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(Ie.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ro.createPortal(s.children,i.valueNode):null]})});Gh.displayName=eo;var Yh="SelectItemIndicator",Xh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Kh(Yh,n).isSelected?c.jsx(Ie.span,{"aria-hidden":!0,...r,ref:t}):null});Xh.displayName=Yh;var Pa="SelectScrollUpButton",Jh=m.forwardRef((e,t)=>{const n=In(Pa,e.__scopeSelect),r=ja(Pa,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return pt(()=>{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(Qh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Jh.displayName=Pa;var Oa="SelectScrollDownButton",Zh=m.forwardRef((e,t)=>{const n=In(Oa,e.__scopeSelect),r=ja(Oa,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return pt(()=>{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(Qh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Zh.displayName=Oa;var Qh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=In("SelectScrollButton",n),i=m.useRef(null),a=As(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{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(Ie.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),eC="SelectSeparator",ep=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ie.div,{"aria-hidden":!0,...r,ref:t})});ep.displayName=eC;var Ma="SelectArrow",tC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_s(n),s=En(Ma,n),i=In(Ma,n);return s.open&&i.position==="popper"?c.jsx(Xd,{...o,...r,ref:t}):null});tC.displayName=Ma;var nC="SelectBubbleInput",tp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Le(r,o),i=Ch(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(Ie.select,{...n,style:{..._h,...n.style},ref:s,defaultValue:t})});tp.displayName=nC;function np(e){return e===""||e===void 0}function rp(e){const t=mt(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 op(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=rC(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 rC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oC=jh,sp=Ph,sC=Mh,iC=Dh,aC=Lh,ip=$h,lC=Hh,ap=Vh,lp=qh,cC=Gh,uC=Xh,cp=Jh,up=Zh,dp=ep;const fp=oC,hp=sC,Da=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(sp,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(iC,{asChild:!0,children:c.jsx(re.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Da.displayName=sp.displayName;const pp=m.forwardRef(({className:e,...t},n)=>c.jsx(cp,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronUp,{className:"h-4 w-4"})}));pp.displayName=cp.displayName;const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronDown,{className:"h-4 w-4"})}));mp.displayName=up.displayName;const La=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(aC,{children:c.jsxs(ip,{ref:o,className:Q("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(pp,{}),c.jsx(lC,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(mp,{})]})}));La.displayName=ip.displayName;const dC=m.forwardRef(({className:e,...t},n)=>c.jsx(ap,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));dC.displayName=ap.displayName;const Xn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(lp,{ref:r,className:Q("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(uC,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),c.jsx(cC,{children:t})]}));Xn.displayName=lp.displayName;const fC=m.forwardRef(({className:e,...t},n)=>c.jsx(dp,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));fC.displayName=dp.displayName;var hC="Separator",gp="horizontal",pC=["horizontal","vertical"],xp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=gp,...o}=e,s=mC(r)?r:gp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ie.div,{"data-orientation":s,...a,...o,ref:t})});xp.displayName=hC;function mC(e){return pC.includes(e)}var vp=xp;const wp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(vp,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));wp.displayName=vp.displayName;const gC=td,xC=Xw,vC=nd,bp=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{className:Q("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));bp.displayName=Qo.displayName;const wC=no.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"}}),yp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(vC,{children:[c.jsx(bp,{}),c.jsxs(es,{ref:o,className:Q(wC({side:e}),t),...r,children:[n,c.jsxs(rd,{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(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));yp.displayName=es.displayName;const Sp=({className:e,...t})=>c.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});Sp.displayName="SheetHeader";const Cp=m.forwardRef(({className:e,...t},n)=>c.jsx(Un,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));Cp.displayName=Un.displayName;const Tp=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Tp.displayName=ts.displayName;const bC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function yC({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}=Di();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(bC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(gC,{open:r,onOpenChange:o,children:[c.jsx(xC,{asChild:!0,children:c.jsxs(He,{variant:"outline",size:"sm",className:n,children:[c.jsx(re.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Ei,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(yp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Sp,{children:[c.jsx(Cp,{children:"Chat Settings"}),c.jsx(Tp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(He,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(He,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(re.EyeOff,{className:"h-4 w-4"}):c.jsx(re.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(fp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Da,{children:c.jsx(hp,{})}),c.jsxs(La,{children:[c.jsx(Xn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Xn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Xn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ft,{htmlFor:"theme",children:"Theme"}),c.jsxs(fp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Da,{children:c.jsx(hp,{})}),c.jsxs(La,{children:[c.jsx(Xn,{value:"light",children:"Light"}),c.jsx(Xn,{value:"dark",children:"Dark"}),c.jsx(Xn,{value:"system",children:"System"})]})]})]}),c.jsx(wp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ft,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Br,{children:[c.jsx(zr,{className:"pb-3",children:c.jsxs(Hr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Ft,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Ft,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(kn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Ft,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(He,{variant:"outline",onClick:p,children:[c.jsx(re.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(He,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(He,{onClick:h,disabled:!u,children:[c.jsx(re.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function SC({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(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(xo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Rl,Ne.ChatInterface=ys,Ne.ChatProviders=xo,Ne.ChatSettings=yC,Ne.MarkdownContent=Pi,Ne.MessageComponent=fd,Ne.MessageList=Zi,Ne.ThreadManager=Aa,Ne.applySettings=IS,Ne.chatApiClient=mn,Ne.default=SC,Ne.del=jl,Ne.get=It,Ne.getChatToken=Nl,Ne.getCurrentSettings=ES,Ne.getDefaultApiConfig=vh,Ne.getDefaultChatSettings=wh,Ne.onChatTokenChanged=Al,Ne.post=qs,Ne.put=_l,Ne.setChatToken=Ks,Ne.useApi=Gs,Ne.useChatStream=Dl,Ne.useMessages=ni,Ne.useMessagesReducer=Ol,Ne.useStream=Vl,Ne.useThreads=go,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
134
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function pb(e,t=rs){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 mb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),pb(t),hb(t)}function Qi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=On.createSlot(a),u=y.forwardRef((v,g)=>{const{scope:x,children:b}=v,S=s(a,x),E=Be(g,S.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=On.createSlot(d),p=y.forwardRef((v,g)=>{const{scope:x,children:b,...S}=v,E=y.useRef(null),C=Be(g,E),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(E,{ref:E,...S}),()=>void k.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,I)=>S.indexOf(k.ref.current)-S.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var gb=m.createContext(void 0);function os(e){const t=m.useContext(gb);return e||t||"ltr"}const xb=["top","right","bottom","left"],Cn=Math.min,Rt=Math.max,ss=Math.round,is=Math.floor,rn=e=>({x:e,y:e}),vb={left:"right",right:"left",bottom:"top",top:"bottom"},wb={start:"end",end:"start"};function ea(e,t,n){return Rt(e,Cn(t,n))}function dn(e,t){return typeof e=="function"?e(t):e}function fn(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function ta(e){return e==="x"?"y":"x"}function na(e){return e==="y"?"height":"width"}const bb=new Set(["top","bottom"]);function on(e){return bb.has(fn(e))?"y":"x"}function ra(e){return ta(on(e))}function yb(e,t,n){n===void 0&&(n=!1);const r=dr(e),o=ra(e),s=na(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=as(i)),[i,as(i)]}function Sb(e){const t=as(e);return[oa(e),t,oa(t)]}function oa(e){return e.replace(/start|end/g,t=>wb[t])}const md=["left","right"],gd=["right","left"],Cb=["top","bottom"],Tb=["bottom","top"];function kb(e,t,n){switch(e){case"top":case"bottom":return n?t?gd:md:t?md:gd;case"left":case"right":return t?Cb:Tb;default:return[]}}function Eb(e,t,n,r){const o=dr(e);let s=kb(fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(oa)))),s}function as(e){return e.replace(/left|right|bottom|top/g,t=>vb[t])}function Ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function xd(e){return typeof e!="number"?Ib(e):{top:e,right:e,bottom:e,left:e}}function ls(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 vd(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=ra(t),a=na(i),l=fn(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 Nb=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}=vd(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y:S,data:E,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...E}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=vd(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Kr(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),w=xd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ls(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ls(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(x.top-C.top+w.top)/E.y,bottom:(C.bottom-x.bottom+w.bottom)/E.y,left:(x.left-C.left+w.left)/E.x,right:(C.right-x.right+w.right)/E.x}}const Ab=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=xd(d),h={x:n,y:r},p=ra(o),w=na(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=k?k[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(k)))&&(I=a.floating[S]||s.floating[w]);const A=E/2-C/2,j=I/2-v[w]/2-1,P=Cn(f[x],j),L=Cn(f[b],j),$=P,H=I-v[w]-L,M=I/2-v[w]/2+A,K=ea($,M,H),W=!l.arrow&&dr(o)!=null&&M!==K&&s.reference[w]/2-(M<$?P:L)-v[w]/2<0,G=W?M<$?M-$:M-H:0;return{[p]:h[p]+G,data:{[p]:K,centerOffset:M-K-G,...W&&{alignmentOffset:G}},reset:W}}}),_b=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:w="none",flipAlignment:v=!0,...g}=dn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=fn(o),b=on(a),S=fn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!v?[as(a)]:Sb(a)),k=w!=="none";!h&&k&&C.push(...Eb(a,v,w,E));const I=[a,...C],A=await Kr(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[x]),f){const M=yb(o,i,E);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,K=I[M];if(K&&(!(f==="alignment"?b!==on(K):!1)||P.every(B=>on(B.placement)===b?B.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:K}};let W=($=P.filter(G=>G.overflows[0]<=0).sort((G,B)=>G.overflows[1]-B.overflows[1])[0])==null?void 0:$.placement;if(!W)switch(p){case"bestFit":{var H;const G=(H=P.filter(B=>{if(k){const _=on(B.placement);return _===b||_==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(_=>_>0).reduce((_,q)=>_+q,0)]).sort((B,_)=>B[1]-_[1])[0])==null?void 0:H[0];G&&(W=G);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function wd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bd(e){return xb.some(t=>e[t]>=0)}const jb=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 Kr(t,{...o,elementContext:"reference"}),i=wd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:bd(i)}}}case"escaped":{const s=await Kr(t,{...o,altBoundary:!0}),i=wd(s,n.floating);return{data:{escapedOffsets:i,escaped:bd(i)}}}default:return{}}}}},yd=new Set(["left","top"]);async function Rb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=fn(n),a=dr(n),l=on(n)==="y",u=yd.has(i)?-1:1,d=s&&l?-1:1,f=dn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Pb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Rb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Ob=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=dn(e,t),u={x:n,y:r},d=await Kr(t,l),f=on(fn(o)),h=ta(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],S=p-d[x];p=ea(b,p,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],S=w-d[x];w=ea(b,w,S)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},Mb=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=on(o),h=ta(f);let p=d[h],w=d[f];const v=dn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const S=h==="y"?"height":"width",E=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var x,b;const S=h==="y"?"width":"height",E=yd.has(fn(o)),C=s.reference[f]-s.floating[S]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);w<C?w=C:w>k&&(w=k)}return{[h]:p,[f]:w}}}},Db=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 Kr(t,u),f=fn(o),h=dr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,S=w-d.left-d.right,E=Cn(v-d[g],b),C=Cn(w-d[x],S),k=!t.middlewareData.shift;let I=E,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),k&&!h){const P=Rt(d.left,0),L=Rt(d.right,0),$=Rt(d.top,0),H=Rt(d.bottom,0);p?A=w-2*(P!==0||L!==0?P+L:Rt(d.left,d.right)):I=v-2*($!==0||H!==0?$+H:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const j=await i.getDimensions(a.floating);return w!==j.width||v!==j.height?{reset:{rects:!0}}:{}}}};function cs(){return typeof window<"u"}function fr(e){return Sd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(Sd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Sd(e){return cs()?e instanceof Node||e instanceof Pt(e).Node:!1}function Kt(e){return cs()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return cs()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function Cd(e){return!cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const Lb=new Set(["inline","contents"]);function qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Lb.has(o)}const $b=new Set(["table","td","th"]);function Fb(e){return $b.has(fr(e))}const Bb=[":popover-open",":modal"];function us(e){return Bb.some(t=>{try{return e.matches(t)}catch{return!1}})}const zb=["transform","translate","scale","rotate","perspective"],Hb=["transform","translate","scale","rotate","perspective","filter"],Ub=["paint","layout","strict","content"];function sa(e){const t=ia(),n=Kt(e)?qt(e):e;return zb.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)||Hb.some(r=>(n.willChange||"").includes(r))||Ub.some(r=>(n.contain||"").includes(r))}function Wb(e){let t=Tn(e);for(;an(t)&&!hr(t);){if(sa(t))return t;if(us(t))return null;t=Tn(t)}return null}function ia(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Vb=new Set(["html","body","#document"]);function hr(e){return Vb.has(fr(e))}function qt(e){return Pt(e).getComputedStyle(e)}function ds(e){return Kt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tn(e){if(fr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Cd(e)&&e.host||sn(e);return Cd(t)?t.host:t}function Td(e){const t=Tn(e);return hr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&qr(t)?t:Td(t)}function Gr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Td(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=aa(i);return t.concat(i,i.visualViewport||[],qr(o)?o:[],a&&n?Gr(a):[])}return t.concat(o,Gr(o,[],n))}function aa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kd(e){const t=qt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ss(n)!==s||ss(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function la(e){return Kt(e)?e:e.contextElement}function pr(e){const t=la(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=kd(t);let i=(s?ss(n.width):n.width)/r,a=(s?ss(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Kb=rn(0);function Ed(e){const t=Pt(e);return!ia()||!t.visualViewport?Kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function qb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=la(e);let i=rn(1);t&&(r?Kt(r)&&(i=pr(r)):i=pr(e));const a=qb(s,n,r)?Ed(s):rn(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=Pt(s),p=r&&Kt(r)?Pt(r):r;let w=h,v=aa(w);for(;v&&r&&p!==w;){const g=pr(v),x=v.getBoundingClientRect(),b=qt(v),S=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=E,w=Pt(v),v=aa(w)}}return ls({width:d,height:f,x:l,y:u})}function fs(e,t){const n=ds(e).scrollLeft;return t?t.left+n:qn(sn(e)).left+n}function Id(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 Gb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?us(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((fr(r)!=="body"||qr(i))&&(l=ds(r)),an(r))){const p=qn(r);u=pr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Id(i,l):rn(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 Yb(e){return Array.from(e.getClientRects())}function Xb(e){const t=sn(e),n=ds(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+fs(e);const a=-n.scrollTop;return qt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Nd=25;function Jb(e,t){const n=Pt(e),r=sn(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=ia();(!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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Nd&&(s-=w)}else u<=Nd&&(s+=u);return{width:s,height:i,x:a,y:l}}const Zb=new Set(["absolute","fixed"]);function Qb(e,t){const n=qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?pr(e):rn(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 Ad(e,t,n){let r;if(t==="viewport")r=Jb(e,n);else if(t==="document")r=Xb(sn(e));else if(Kt(t))r=Qb(t,n);else{const o=Ed(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(r)}function _d(e,t){const n=Tn(e);return n===t||!Kt(n)||hr(n)?!1:qt(n).position==="fixed"||_d(n,t)}function ey(e,t){const n=t.get(e);if(n)return n;let r=Gr(e,[],!1).filter(a=>Kt(a)&&fr(a)!=="body"),o=null;const s=qt(e).position==="fixed";let i=s?Tn(e):e;for(;Kt(i)&&!hr(i);){const a=qt(i),l=sa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Zb.has(o.position)||qr(i)&&!l&&_d(e,i))?r=r.filter(d=>d!==i):o=a,i=Tn(i)}return t.set(e,r),r}function ty(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?us(t)?[]:ey(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Ad(t,d,o);return u.top=Rt(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},Ad(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ny(e){const{width:t,height:n}=kd(e);return{width:t,height:n}}function ry(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=fs(o)}if(r||!r&&!s)if((fr(t)!=="body"||qr(o))&&(a=ds(t)),r){const p=qn(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?Id(o,a):rn(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 ca(e){return qt(e).position==="static"}function jd(e,t){if(!an(e)||qt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Rd(e,t){const n=Pt(e);if(us(e))return n;if(!an(e)){let o=Tn(e);for(;o&&!hr(o);){if(Kt(o)&&!ca(o))return o;o=Tn(o)}return n}let r=jd(e,t);for(;r&&Fb(r)&&ca(r);)r=jd(r,t);return r&&hr(r)&&ca(r)&&!sa(r)?n:r||Wb(e)||n}const oy=async function(e){const t=this.getOffsetParent||Rd,n=this.getDimensions,r=await n(e.floating);return{reference:ry(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function sy(e){return qt(e).direction==="rtl"}const iy={convertOffsetParentRelativeRectToViewportRelativeRect:Gb,getDocumentElement:sn,getClippingRect:ty,getOffsetParent:Rd,getElementRects:oy,getClientRects:Yb,getDimensions:ny,getScale:pr,isElement:Kt,isRTL:sy};function Pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ay(e,t){let n=null,r;const o=sn(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 w=is(f),v=is(o.clientWidth-(d+h)),g=is(o.clientHeight-(f+p)),x=is(d),S={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,Cn(1,l))||1};let E=!0;function C(k){const I=k[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Pd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function ly(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=la(e),d=o||s?[...u?Gr(u):[],...Gr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?ay(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,v=l?qn(e):null;l&&g();function g(){const x=qn(e);v&&!Pd(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const cy=Pb,uy=Ob,dy=_b,fy=Db,hy=jb,Od=Ab,py=Mb,my=(e,t,n)=>{const r=new Map,o={platform:iy,...n},s={...o.platform,_c:r};return Nb(e,t,{...o,platform:s})};var gy=typeof document<"u",xy=function(){},hs=gy?y.useLayoutEffect:xy;function ps(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(!ps(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)&&!ps(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Dd(e,t){const n=Md(e);return Math.round(t*n)/n}function ua(e){const t=m.useRef(e);return hs(()=>{t.current=e}),t}function vy(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);ps(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(B=>{B!==k.current&&(k.current=B,v(B))},[]),S=m.useCallback(B=>{B!==I.current&&(I.current=B,x(B))},[]),E=s||w,C=i||g,k=m.useRef(null),I=m.useRef(null),A=m.useRef(d),j=l!=null,P=ua(l),L=ua(o),$=ua(u),H=m.useCallback(()=>{if(!k.current||!I.current)return;const B={placement:t,strategy:n,middleware:h};L.current&&(B.platform=L.current),my(k.current,I.current,B).then(_=>{const q={..._,isPositioned:$.current!==!1};M.current&&!ps(A.current,q)&&(A.current=q,ro.flushSync(()=>{f(q)}))})},[h,t,n,L,$]);hs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(B=>({...B,isPositioned:!1})))},[u]);const M=m.useRef(!1);hs(()=>(M.current=!0,()=>{M.current=!1}),[]),hs(()=>{if(E&&(k.current=E),C&&(I.current=C),E&&C){if(P.current)return P.current(E,C,H);H()}},[E,C,H,P,j]);const K=m.useMemo(()=>({reference:k,floating:I,setReference:b,setFloating:S}),[b,S]),W=m.useMemo(()=>({reference:E,floating:C}),[E,C]),G=m.useMemo(()=>{const B={position:n,left:0,top:0};if(!W.floating)return B;const _=Dd(W.floating,d.x),q=Dd(W.floating,d.y);return a?{...B,transform:"translate("+_+"px, "+q+"px)",...Md(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:q}},[n,a,W.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:H,refs:K,elements:W,floatingStyles:G}),[d,H,K,W,G])}const wy=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?Od({element:r.current,padding:o}).fn(n):{}:r?Od({element:r,padding:o}).fn(n):{}}}},by=(e,t)=>({...cy(e),options:[e,t]}),yy=(e,t)=>({...uy(e),options:[e,t]}),Sy=(e,t)=>({...py(e),options:[e,t]}),Cy=(e,t)=>({...dy(e),options:[e,t]}),Ty=(e,t)=>({...fy(e),options:[e,t]}),ky=(e,t)=>({...hy(e),options:[e,t]}),Ey=(e,t)=>({...wy(e),options:[e,t]});var Iy="Arrow",Ld=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Ne.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"})})});Ld.displayName=Iy;var Ny=Ld;function $d(e){const[t,n]=m.useState(void 0);return pt(()=>{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 da="Popper",[Fd,ms]=en(da),[Ay,Bd]=Fd(da),zd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(Ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};zd.displayName=da;var Hd="PopperAnchor",Ud=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Bd(Hd,n),i=m.useRef(null),a=Be(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(Ne.div,{...o,ref:a})});Ud.displayName=Hd;var fa="PopperContent",[_y,jy]=Fd(fa),Wd=m.forwardRef((e,t)=>{var V,D,J,U,de,ce;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:w,...v}=e,g=Bd(fa,n),[x,b]=m.useState(null),S=Be(t,ze=>b(ze)),[E,C]=m.useState(null),k=$d(E),I=(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,H={padding:P,boundary:L.filter(Py),altBoundary:$},{refs:M,floatingStyles:K,placement:W,isPositioned:G,middlewareData:B}=vy({strategy:"fixed",placement:j,whileElementsMounted:(...ze)=>ly(...ze,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[by({mainAxis:o+A,alignmentAxis:i}),l&&yy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Sy():void 0,...H}),l&&Cy({...H}),Ty({...H,apply:({elements:ze,rects:Xe,availableWidth:Ge,availableHeight:ke})=>{const{width:De,height:nt}=Xe.reference,He=ze.floating.style;He.setProperty("--radix-popper-available-width",`${Ge}px`),He.setProperty("--radix-popper-available-height",`${ke}px`),He.setProperty("--radix-popper-anchor-width",`${De}px`),He.setProperty("--radix-popper-anchor-height",`${nt}px`)}}),E&&Ey({element:E,padding:a}),Oy({arrowWidth:I,arrowHeight:A}),h&&ky({strategy:"referenceHidden",...H})]}),[_,q]=qd(W),Q=mt(w);pt(()=>{G&&(Q==null||Q())},[G,Q]);const xe=(V=B.arrow)==null?void 0:V.x,ue=(D=B.arrow)==null?void 0:D.y,te=((J=B.arrow)==null?void 0:J.centerOffset)!==0,[je,Te]=m.useState();return pt(()=>{x&&Te(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:G?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[(U=B.transformOrigin)==null?void 0:U.x,(de=B.transformOrigin)==null?void 0:de.y].join(" "),...((ce=B.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(_y,{scope:n,placedSide:_,onArrowChange:C,arrowX:xe,arrowY:ue,shouldHideArrow:te,children:c.jsx(Ne.div,{"data-side":_,"data-align":q,...v,ref:S,style:{...v.style,animation:G?void 0:"none"}})})})});Wd.displayName=fa;var Vd="PopperArrow",Ry={top:"bottom",right:"left",bottom:"top",left:"right"},Kd=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=jy(Vd,r),i=Ry[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(Ny,{...o,ref:n,style:{...o.style,display:"block"}})})});Kd.displayName=Vd;function Py(e){return e!==null}var Oy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=qd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function qd(e){const[t,n="center"]=e.split("-");return[t,n]}var Gd=zd,Yd=Ud,Xd=Wd,Jd=Kd,ha="rovingFocusGroup.onEntryFocus",My={bubbles:!1,cancelable:!0},Yr="RovingFocusGroup",[pa,Zd,Dy]=Qi(Yr),[Ly,Qd]=en(Yr,[Dy]),[$y,Fy]=Ly(Yr),ef=m.forwardRef((e,t)=>c.jsx(pa.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(pa.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(By,{...e,ref:t})})}));ef.displayName=Yr;var By=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=Be(t,h),w=os(s),[v,g]=Hn({prop:i,defaultProp:a??null,onChange:l,caller:Yr}),[x,b]=m.useState(!1),S=mt(u),E=Zd(n),C=m.useRef(!1),[k,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ha,S),()=>A.removeEventListener(ha,S)},[S]),c.jsx($y,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(Ne.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!x){const P=new CustomEvent(ha,My);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const L=E().filter(W=>W.focusable),$=L.find(W=>W.active),H=L.find(W=>W.id===v),K=[$,H,...L].filter(Boolean).map(W=>W.ref.current);rf(K,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>b(!1))})})}),tf="RovingFocusGroupItem",nf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Fy(tf,n),f=d.currentTabStopId===u,h=Zd(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(pa.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(Ne.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:le(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Uy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")S.reverse();else if(x==="prev"||x==="next"){x==="prev"&&S.reverse();const E=S.indexOf(g.currentTarget);S=d.loop?Wy(S,E+1):S.slice(E+1)}setTimeout(()=>rf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});nf.displayName=tf;var zy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Hy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uy(e,t,n){const r=Hy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return zy[r]}function rf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Vy=ef,Ky=nf,ma=["Enter"," "],qy=["ArrowDown","PageUp","Home"],of=["ArrowUp","PageDown","End"],Gy=[...qy,...of],Yy={ltr:[...ma,"ArrowRight"],rtl:[...ma,"ArrowLeft"]},Xy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Xr="Menu",[Jr,Jy,Zy]=Qi(Xr),[Gn,sf]=en(Xr,[Zy,ms,Qd]),gs=ms(),af=Qd(),[Qy,Yn]=Gn(Xr),[e0,Zr]=Gn(Xr),lf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=os(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(Gd,{...a,children:c.jsx(Qy,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(e0,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};lf.displayName=Xr;var t0="MenuAnchor",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Yd,{...o,...r,ref:t})});ga.displayName=t0;var xa="MenuPortal",[n0,cf]=Gn(xa,{forceMount:void 0}),uf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Yn(xa,t);return c.jsx(n0,{scope:t,forceMount:n,children:c.jsx(jt,{present:n||s.open,children:c.jsx(Ho,{asChild:!0,container:o,children:r})})})};uf.displayName=xa;var $t="MenuContent",[r0,va]=Gn($t),df=m.forwardRef((e,t)=>{const n=cf($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Yn($t,e.__scopeMenu),i=Zr($t,e.__scopeMenu);return c.jsx(Jr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Jr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(o0,{...o,ref:t}):c.jsx(s0,{...o,ref:t})})})})}),o0=m.forwardRef((e,t)=>{const n=Yn($t,e.__scopeMenu),r=m.useRef(null),o=Be(t,r);return m.useEffect(()=>{const s=r.current;if(s)return qi(s)},[]),c.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),s0=m.forwardRef((e,t)=>{const n=Yn($t,e.__scopeMenu);return c.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),i0=On.createSlot("MenuContent.ScrollLock"),wa=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:w,...v}=e,g=Yn($t,n),x=Zr($t,n),b=gs(n),S=af(n),E=Jy(n),[C,k]=m.useState(null),I=m.useRef(null),A=Be(t,I,g.onContentChange),j=m.useRef(0),P=m.useRef(""),L=m.useRef(0),$=m.useRef(null),H=m.useRef("right"),M=m.useRef(0),K=w?Go:m.Fragment,W=w?{as:i0,allowPinchZoom:!0}:void 0,G=_=>{var V,D;const q=P.current+_,Q=E().filter(J=>!J.disabled),xe=document.activeElement,ue=(V=Q.find(J=>J.ref.current===xe))==null?void 0:V.textValue,te=Q.map(J=>J.textValue),je=v0(te,q,ue),Te=(D=Q.find(J=>J.textValue===je))==null?void 0:D.ref.current;(function J(U){P.current=U,window.clearTimeout(j.current),U!==""&&(j.current=window.setTimeout(()=>J(""),1e3))})(q),Te&&setTimeout(()=>Te.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),zi();const B=m.useCallback(_=>{var Q,xe;return H.current===((Q=$.current)==null?void 0:Q.side)&&b0(_,(xe=$.current)==null?void 0:xe.area)},[]);return c.jsx(r0,{scope:n,searchRef:P,onItemEnter:m.useCallback(_=>{B(_)&&_.preventDefault()},[B]),onItemLeave:m.useCallback(_=>{var q;B(_)||((q=I.current)==null||q.focus(),k(null))},[B]),onTriggerLeave:m.useCallback(_=>{B(_)&&_.preventDefault()},[B]),pointerGraceTimerRef:L,onPointerGraceIntentChange:m.useCallback(_=>{$.current=_},[]),children:c.jsx(K,{...W,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,_=>{var q;_.preventDefault(),(q=I.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Vy,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:le(l,_=>{x.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Xd,{role:"menu","aria-orientation":"vertical","data-state":Nf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:le(v.onKeyDown,_=>{const Q=_.target.closest("[data-radix-menu-content]")===_.currentTarget,xe=_.ctrlKey||_.altKey||_.metaKey,ue=_.key.length===1;Q&&(_.key==="Tab"&&_.preventDefault(),!xe&&ue&&G(_.key));const te=I.current;if(_.target!==te||!Gy.includes(_.key))return;_.preventDefault();const Te=E().filter(V=>!V.disabled).map(V=>V.ref.current);of.includes(_.key)&&Te.reverse(),g0(Te)}),onBlur:le(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:le(e.onPointerMove,eo(_=>{const q=_.target,Q=M.current!==_.clientX;if(_.currentTarget.contains(q)&&Q){const xe=_.clientX>M.current?"right":"left";H.current=xe,M.current=_.clientX}}))})})})})})})});df.displayName=$t;var a0="MenuGroup",ba=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ne.div,{role:"group",...r,ref:t})});ba.displayName=a0;var l0="MenuLabel",ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ne.div,{...r,ref:t})});ff.displayName=l0;var xs="MenuItem",hf="menu.itemSelect",vs=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Zr(xs,e.__scopeMenu),a=va(xs,e.__scopeMenu),l=Be(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(hf,{bubbles:!0,cancelable:!0});f.addEventListener(hf,p=>r==null?void 0:r(p),{once:!0}),qc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(pf,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:le(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:le(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ma.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var pf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=va(xs,n),a=af(n),l=m.useRef(null),u=Be(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Jr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Ky,{asChild:!0,...a,focusable:!r,children:c.jsx(Ne.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:le(e.onPointerMove,eo(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,eo(w=>i.onItemLeave(w))),onFocus:le(e.onFocus,()=>f(!0)),onBlur:le(e.onBlur,()=>f(!1))})})})}),c0="MenuCheckboxItem",mf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(bf,{scope:e.__scopeMenu,checked:n,children:c.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Sa(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mf.displayName=c0;var gf="MenuRadioGroup",[u0,d0]=Gn(gf,{value:void 0,onValueChange:()=>{}}),xf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(u0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ba,{...o,ref:t})})});xf.displayName=gf;var vf="MenuRadioItem",wf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=d0(vf,e.__scopeMenu),s=n===o.value;return c.jsx(bf,{scope:e.__scopeMenu,checked:s,children:c.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Sa(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});wf.displayName=vf;var ya="MenuItemIndicator",[bf,f0]=Gn(ya,{checked:!1}),yf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=f0(ya,n);return c.jsx(jt,{present:r||ws(s.checked)||s.checked===!0,children:c.jsx(Ne.span,{...o,ref:t,"data-state":Sa(s.checked)})})});yf.displayName=ya;var h0="MenuSeparator",Sf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(Ne.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Sf.displayName=h0;var p0="MenuArrow",Cf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return c.jsx(Jd,{...o,...r,ref:t})});Cf.displayName=p0;var m0="MenuSub",[JC,Tf]=Gn(m0),Qr="MenuSubTrigger",kf=m.forwardRef((e,t)=>{const n=Yn(Qr,e.__scopeMenu),r=Zr(Qr,e.__scopeMenu),o=Tf(Qr,e.__scopeMenu),s=va(Qr,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(pf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Nf(n.open),...e,ref:Ii(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:le(e.onPointerMove,eo(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:le(e.onPointerLeave,eo(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:le(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Yy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});kf.displayName=Qr;var Ef="MenuSubContent",If=m.forwardRef((e,t)=>{const n=cf($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Yn($t,e.__scopeMenu),i=Zr($t,e.__scopeMenu),a=Tf(Ef,e.__scopeMenu),l=m.useRef(null),u=Be(t,l);return c.jsx(Jr.Provider,{scope:e.__scopeMenu,children:c.jsx(jt,{present:r||s.open,children:c.jsx(Jr.Slot,{scope:e.__scopeMenu,children:c.jsx(wa,{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:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Xy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});If.displayName=Ef;function Nf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Sa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function g0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function x0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function v0(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=x0(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 w0(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 b0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return w0(n,t)}function eo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var y0=lf,S0=ga,C0=uf,T0=df,k0=ba,E0=ff,I0=vs,N0=mf,A0=xf,_0=wf,j0=yf,R0=Sf,P0=Cf,O0=kf,M0=If,bs="DropdownMenu",[D0,ZC]=en(bs,[sf]),St=sf(),[L0,Af]=D0(bs),_f=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=St(t),u=m.useRef(null),[d,f]=Hn({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return c.jsx(L0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(y0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};_f.displayName=bs;var jf="DropdownMenuTrigger",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Af(jf,n),i=St(n);return c.jsx(S0,{asChild:!0,...i,children:c.jsx(Ne.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:Ii(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Rf.displayName=jf;var $0="DropdownMenuPortal",Pf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=St(t);return c.jsx(C0,{...r,...n})};Pf.displayName=$0;var Of="DropdownMenuContent",Mf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Af(Of,n),s=St(n),i=m.useRef(!1);return c.jsx(T0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(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)"}})});Mf.displayName=Of;var F0="DropdownMenuGroup",B0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(k0,{...o,...r,ref:t})});B0.displayName=F0;var z0="DropdownMenuLabel",Df=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(E0,{...o,...r,ref:t})});Df.displayName=z0;var H0="DropdownMenuItem",Lf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(I0,{...o,...r,ref:t})});Lf.displayName=H0;var U0="DropdownMenuCheckboxItem",$f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(N0,{...o,...r,ref:t})});$f.displayName=U0;var W0="DropdownMenuRadioGroup",V0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(A0,{...o,...r,ref:t})});V0.displayName=W0;var K0="DropdownMenuRadioItem",Ff=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(_0,{...o,...r,ref:t})});Ff.displayName=K0;var q0="DropdownMenuItemIndicator",Bf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(j0,{...o,...r,ref:t})});Bf.displayName=q0;var G0="DropdownMenuSeparator",zf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(R0,{...o,...r,ref:t})});zf.displayName=G0;var Y0="DropdownMenuArrow",X0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(P0,{...o,...r,ref:t})});X0.displayName=Y0;var J0="DropdownMenuSubTrigger",Hf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(O0,{...o,...r,ref:t})});Hf.displayName=J0;var Z0="DropdownMenuSubContent",Uf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=St(n);return c.jsx(M0,{...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)"}})});Uf.displayName=Z0;var Q0=_f,eS=Rf,tS=Pf,Wf=Mf,Vf=Df,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf;const nS=Q0,rS=eS,oS=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Jf,{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(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));oS.displayName=Jf.displayName;const sS=m.forwardRef(({className:e,...t},n)=>c.jsx(Zf,{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}));sS.displayName=Zf.displayName;const Qf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(tS,{children:c.jsx(Wf,{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})}));Qf.displayName=Wf.displayName;const Ca=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Kf,{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}));Ca.displayName=Kf.displayName;const iS=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(qf,{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(Yf,{children:c.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));iS.displayName=qf.displayName;const aS=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Gf,{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(Yf,{children:c.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));aS.displayName=Gf.displayName;const lS=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Vf,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));lS.displayName=Vf.displayName;const cS=m.forwardRef(({className:e,...t},n)=>c.jsx(Xf,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));cS.displayName=Xf.displayName;function ys({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:w}=Gs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:S}=go(),{messages:E,hasMoreHistory:C,isLoadingHistory:k,send:I,stop:A,loadOlderMessages:j}=ni(),{isStreaming:P,error:L,streamingAssistantId:$,lastCheckpointId:H,lastCheckpointNs:M}=Kl(),[K,W]=y.useState(null),[G,B]=y.useState(""),[_,q]=y.useState(null),[Q,xe]=y.useState([]),[ue,te]=y.useState(0),[je,Te]=y.useState(0),[V,D]=y.useState(!1),[J,U]=y.useState(null),[de,ce]=y.useState(null),[ze,Xe]=y.useState(!1),[Ge,ke]=y.useState(null),[De,nt]=y.useState([]),[He,Je]=y.useState(null),[dt,ne]=y.useState(null),[re,ve]=y.useState(!1),Ee=y.useRef(null),Se=y.useRef(null),Ae=y.useRef(null),Ze=y.useCallback(()=>{Ee.current&&(Ee.current.value=""),Se.current&&(Se.current.value=""),te(ie=>ie+1),Te(ie=>ie+1)},[]),Ye=y.useRef(!1);y.useEffect(()=>{Ye.current&&!P&&(xe([]),Ze()),Ye.current=P},[P,Ze]);const[ct,Ct]=y.useState("desktop");y.useEffect(()=>{const ie=()=>{const ye=window.innerWidth;Ct(ye<640?"phone":ye<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),y.useEffect(()=>{let ie=!1;if(!v){nt([]),Je(null),ne(null),Ae.current=null;return}const ye={threadId:v,checkpointId:H??null,checkpointNs:M??null},$e=Ae.current;if(!($e&&$e.threadId===ye.threadId&&$e.checkpointId===ye.checkpointId&&$e.checkpointNs===ye.checkpointNs))return x(v).then(N=>{var fe;if(ie)return;const R=((N==null?void 0:N.checkpoints)??[]).slice().sort((T,F)=>new Date(F.createdAt).getTime()-new Date(T.createdAt).getTime());nt(R);const Z=He,pe=Z&&R.some(T=>T.checkpointId===Z)?Z:((fe=R[0])==null?void 0:fe.checkpointId)??null;let ge=null;if(pe){const T=R.find(F=>F.checkpointId===pe);ge=(T==null?void 0:T.checkpointNs)??null}Je(pe),ne(ge),Ae.current=ye}).catch(N=>{console.error("ChatInterface - listCheckpoints error:",N),ie||(nt([]),Ae.current=null)}),()=>{ie=!0}},[v,H,M,He,x]),y.useEffect(()=>{H&&(Je(H),ne(M??null))},[H,M]);const hn=y.useCallback(async()=>{if(!(!C||k))try{await j()}catch(ie){console.warn("loadOlderMessages failed",ie)}},[C,k,j]);y.useEffect(()=>{(async()=>{if(!w.baseUrl){ke(null);return}try{const ye=await w.getAgent("default");ke(ye.uiDefaultMessage||null)}catch(ye){console.warn("Failed to fetch default message:",ye),ke(null)}})()},[w]),y.useEffect(()=>{L&&!ze&&(p==null||p(L))},[L,ze,p]);const Nn=ie=>{if(ie.length>rs)return`Message too long (${ie.length}/${rs} characters)`;try{return mb(ie),null}catch(ye){return(ye==null?void 0:ye.message)||"Invalid message"}},vr=async ie=>{const ye=ie.trim();if(!(!ye&&Q.length===0)){if(ye){const $e=Nn(ye);if($e){q($e);return}}try{await I(ye||"",{checkpointId:He??H??void 0,checkpointNs:dt??M??void 0,payloadExtras:K?{edit:!0,originalMessageId:K}:void 0,attachments:Q}),f==null||f(ye),q(null),xe([]),Ze(),W(null),B("")}catch($e){const N=($e==null?void 0:$e.message)||"Failed to send message";q(N),p==null||p(N)}}},An=y.useCallback((ie,ye)=>{u&&(W(ie),B(ye),q(null))},[u]),_n=y.useCallback(()=>{W(null),B(""),q(null)},[]),wr=y.useCallback((ie,ye)=>{An(ie,ye)},[An]),jn=y.useCallback(ie=>{const ye=$e=>{const N=$e.content||[],R=N.filter(Z=>Z.type==="text").map(Z=>Z.text).join("");if(R)return R;try{return JSON.stringify(N,null,2)}catch{return String(N)}};for(let $e=ie-1;$e>=0;$e--)if(E[$e].role==="user"){const N=ye(E[$e]);N&&I(N,{checkpointId:He??H??void 0,checkpointNs:dt??M??void 0});break}},[E,I,He,dt,H,M]),Ot=ie=>{const ye=Array.from(ie.target.files||[]);xe($e=>[...$e,...ye]),ie.target.value=""},Yt=ie=>{xe(ye=>{const $e=ye.filter((N,R)=>ie!==R);return $e.length===0&&Ze(),$e})},Rn=async ie=>{const ye=(ie.target.files||[])[0];if(ye){U(null),ce(null),D(!0);try{await I("",{checkpointId:He??H??void 0,checkpointNs:dt??M??void 0,attachments:[ye]});const $e=`Uploaded ${ye.name} - processing through chat stream`;ce($e)}catch($e){const N=$e instanceof Error?$e.message:"Failed to upload Excel file";console.error("Excel upload failed",$e),U(N),p==null||p(N)}finally{D(!1),ie.target.value="",Ze()}}},Pn=ie=>{if(!ie)return"Unknown";const ye=Date.parse(ie);return Number.isNaN(ye)?ie:new Date(ye).toLocaleString()},Qn=async ie=>{if(v){ve(!0);try{if(!ie){await S(),Je(null),ne(null);return}const ye=De.find(N=>N.checkpointId===ie),$e=(ye==null?void 0:ye.checkpointNs)??null;await b(ie,$e),Je(ie),ne($e)}finally{ve(!1)}}},br=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,er=`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||""}`,yr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:br,children:[!!L&&!ze&&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:L}),c.jsx(Ve,{variant:"ghost",size:"sm",onClick:()=>Xe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(oe.X,{size:16})})]}),v&&De.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:He??"",onChange:ie=>{const ye=ie.target.value||null;Qn(ye)},children:[c.jsx("option",{value:"",children:"Latest"}),De.map(ie=>c.jsxs("option",{value:ie.checkpointId,children:[Pn(ie.createdAt),ie.preview?` — ${ie.preview.slice(0,40)}`:""]},ie.checkpointId))]})]}),c.jsxs("div",{className:`relative ${er}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Zi,{className:"h-full",style:{height:"100%"},messages:E,isStreaming:P,streamingAssistantId:$,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ct,enableMessageEditing:u,editingMessageId:K,onStartReached:()=>{hn()},onEdit:wr,onRegenerate:jn,onCancelEdit:_n,emptyMessage:Ge??void 0,isNavigatingCheckpoint:re}),g&&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(oe.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:yr,children:[K&&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(oe.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ve,{variant:"ghost",size:"sm",onClick:_n,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(oe.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:Ee,type:"file",multiple:!0,onChange:ie=>Ot(ie),className:"hidden"},ue),Q.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Q.map((ie,ye)=>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(oe.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ie.name}),c.jsx(Ve,{variant:"ghost",size:"sm",onClick:()=>Yt(ye),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ie.name}`,children:c.jsx(oe.X,{size:12})})]},ye))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Se,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Rn,className:"hidden"},je),V&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),de&&!V&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:de}),J&&!V&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:J})]})]}),_&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:_}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(nS,{children:[c.jsx(rS,{asChild:!0,children:c.jsx(Ve,{type:"button",size:"icon",variant:"outline",disabled:P,title:"More input actions",className:d.moreButton||"",children:c.jsx(oe.Plus,{size:16})})}),c.jsxs(Qf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Ca,{onClick:()=>{var ie;return(ie=Ee.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[c.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Ca,{onClick:()=>{var ie;V||(ie=Se.current)==null||ie.click()},className:`cursor-pointer ${V?"opacity-60 pointer-events-none":""}`,children:[c.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Ng,{initialValue:G,editingMessageId:K,placeholder:K?"Edit your message...":t,isStreaming:P,disabled:!1,maxLength:rs,onSend:vr,onCancelEdit:_n,onStop:A,allowEmptySend:Q.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${_?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=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}));Ss.displayName="Input";function Ta(e,[t,n]){return Math.min(n,Math.max(t,e))}function uS(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ka="ScrollArea",[eh,QC]=en(ka),[dS,Ft]=eh(ka),th=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,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[S,E]=m.useState(0),[C,k]=m.useState(!1),[I,A]=m.useState(!1),j=Be(t,L=>l(L)),P=os(o);return c.jsx(dS,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(Ne.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});th.displayName=ka;var nh="ScrollAreaViewport",rh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Ft(nh,n),a=m.useRef(null),l=Be(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(Ne.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})})]})});rh.displayName=nh;var ln="ScrollAreaScrollbar",Ea=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(ln,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(fS,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(hS,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(oh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ia,{...r,ref:t}):null});Ea.displayName=ln;var fS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(ln,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(jt,{present:n||s,children:c.jsx(oh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),hS=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ft(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>l("SCROLL_END"),100),[a,l]=uS("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(jt,{present:n||a!=="hidden",children:c.jsx(Ia,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),oh=m.forwardRef((e,t)=>{const n=Ft(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Es(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return mr(n.viewport,l),mr(n.content,l),c.jsx(jt,{present:r||s,children:c.jsx(Ia,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ia=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Ft(ln,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=ch(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 wS(h,i.current,a,p)}return n==="horizontal"?c.jsx(pS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=uh(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(mS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=uh(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}),pS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Be(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(ih,{"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":ks(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),fh(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:Ts(i.paddingLeft),paddingEnd:Ts(i.paddingRight)}})}})}),mS=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Ft(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Be(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(ih,{"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":ks(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),fh(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:Ts(i.paddingTop),paddingEnd:Ts(i.paddingBottom)}})}})}),[gS,sh]=eh(ln),ih=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=Ft(ln,n),[w,v]=m.useState(null),g=Be(t,j=>v(j)),x=m.useRef(null),b=m.useRef(""),S=p.viewport,E=r.content-r.viewport,C=mt(d),k=mt(l),I=Es(f,10);function A(j){if(x.current){const P=j.clientX-x.current.left,L=j.clientY-x.current.top;u({x:P,y:L})}}return m.useEffect(()=>{const j=P=>{const L=P.target;(w==null?void 0:w.contains(L))&&C(P,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,w,E,C]),m.useEffect(k,[r,k]),mr(w,I),mr(p.content,I),c.jsx(gS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:k,onThumbPointerDown:mt(a),children:c.jsx(Ne.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:le(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Cs="ScrollAreaThumb",ah=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sh(Cs,e.__scopeScrollArea);return c.jsx(jt,{present:n||o.hasThumb,children:c.jsx(xS,{ref:t,...r})})}),xS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Ft(Cs,n),i=sh(Cs,n),{onThumbPositionChange:a}=i,l=Be(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Es(()=>{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=bS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(Ne.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:le(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});ah.displayName=Cs;var Na="ScrollAreaCorner",lh=m.forwardRef((e,t)=>{const n=Ft(Na,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(vS,{...e,ref:t}):null});lh.displayName=Na;var vS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Ft(Na,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return mr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),mr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(Ne.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 Ts(e){return e?parseInt(e,10):0}function ch(e,t){const n=e/t;return isNaN(n)?0:n}function ks(e){const t=ch(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wS(e,t,n,r="ltr"){const o=ks(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 dh([l,u],f)(e)}function uh(e,t,n="ltr"){const r=ks(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=Ta(e,l);return dh([0,i],[0,a])(u)}function dh(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 fh(e,t){return e>0&&e<t}var bS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Es(e,t){const n=mt(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 mr(e,t){const n=mt(t);pt(()=>{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 hh=th,yS=rh,SS=lh;const ph=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(hh,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(yS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(mh,{}),c.jsx(SS,{})]}));ph.displayName=hh.displayName;const mh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ea,{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(ah,{className:"relative flex-1 rounded-full bg-border"})}));mh.displayName=Ea.displayName;function Aa({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{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=go(),[b,S]=y.useState(h??[]),[E,C]=y.useState(null),[k,I]=y.useState(""),[A,j]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const P=async _=>{try{await f(_),a==null||a(_),l==null||l(_)}catch(q){console.error("Failed to select thread:",q)}},L=async()=>{try{j(!0);const _=await w();u==null||u(_),a==null||a(_)}catch(_){console.error("Failed to create thread:",_)}finally{j(!1)}},$=async(_,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?"))try{await v(_),d==null||d(_)}catch(Q){console.error("Failed to delete thread:",Q)}},H=(_,q)=>{q.stopPropagation(),C(_.threadId),I(_.title||`Thread ${_.threadId.slice(0,8)}`)},M=async _=>{if(k.trim())try{await g(_,k.trim()),C(null),I("")}catch(q){console.error("Failed to update title:",q)}},K=()=>{C(null),I("")},W=(_,q)=>{_.key==="Enter"?M(q):_.key==="Escape"&&K()},G=_=>{if(!_)return"";try{const q=new Date(_),xe=new Date().getTime()-q.getTime(),ue=Math.floor(xe/(1e3*60*60*24));return ue===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ue===1?"Yesterday":ue<7?`${ue} days ago`:q.toLocaleDateString()}catch{return""}},B=_=>_.title||`Thread ${_.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(Ve,{onClick:L,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(oe.MessageSquarePlus,{size:20})})}),c.jsx(ph,{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:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(oe.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(oe.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"})]}):b.slice().sort((_,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>c.jsxs("div",{onClick:()=>P(_.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===_.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:E===_.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[c.jsx(Ss,{value:k,onChange:q=>I(q.target.value),onKeyDown:q=>W(q,_.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ve,{variant:"ghost",size:"sm",onClick:()=>M(_.threadId),className:"h-6 w-6 p-0",children:c.jsx(oe.Check,{size:12})}),c.jsx(Ve,{variant:"ghost",size:"sm",onClick:K,className:"h-6 w-6 p-0",children:c.jsx(oe.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:B(_)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(oe.Calendar,{size:10}),c.jsx("span",{children:G(_.updatedAt||_.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==_.threadId&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:q=>H(_,q),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(oe.Edit3,{size:12})}),n&&c.jsx(Ve,{variant:"ghost",size:"sm",onClick:q=>$(_.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(oe.Trash2,{size:12})})]})]}),i===_.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},_.threadId))})})]})}function gr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function CS(e){if(typeof e!="string")return;const t=e.trim();if(t)return cn(t)}function gh(){const e=[gr("__API_BASE_URL__"),gr("__CHAT_API_BASE_URL__"),gr("__CHAT_API_URL__")];for(const t of e){const n=CS(t);if(n)return n}}function xh(){const e=[gr("__API_AUTH_TOKEN__"),gr("__CHAT_API_KEY__"),gr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function vh(...e){for(const t of e)if(typeof t=="string"&&t.trim())return cn(t);return cn()}function wh(){const e={},t=gh(),n=xh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function bh(){const e=wh(),t=mn.getAuthToken(),n=gh();return{apiBaseUrl:vh(e.baseUrl,mn.baseUrl,n),apiKey:t||e.apiKey||xh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const yh="chat-settings";function TS(){try{const e=localStorage.getItem(yh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function kS(e){try{const t={...e,apiBaseUrl:cn(e.apiBaseUrl)};localStorage.setItem(yh,JSON.stringify(t)),t.apiKey&&mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ES(){const e=bh(),t=TS(),n=mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:vh(mn.baseUrl,r,e.apiBaseUrl)}}function IS(e){mn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),kS(e)}var NS="Label",Sh=m.forwardRef((e,t)=>c.jsx(Ne.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())}}));Sh.displayName=NS;var Ch=Sh;const AS=no.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=m.forwardRef(({className:e,...t},n)=>c.jsx(Ch,{ref:n,className:ee(AS(),e),...t}));Bt.displayName=Ch.displayName;function Th(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 Is="Switch",[_S,eT]=en(Is),[jS,RS]=_S(Is),kh=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),w=Be(t,S=>p(S)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=Hn({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return c.jsxs(jS,{scope:n,checked:x,disabled:a,children:[c.jsx(Ne.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":Ah(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:le(e.onClick,S=>{b(E=>!E),g&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})}),g&&c.jsx(Nh,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});kh.displayName=Is;var Eh="SwitchThumb",Ih=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=RS(Eh,n);return c.jsx(Ne.span,{"data-state":Ah(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Ih.displayName=Eh;var PS="SwitchBubbleInput",Nh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Be(i,s),l=Th(n),u=$d(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 w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[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}})});Nh.displayName=PS;function Ah(e){return e?"checked":"unchecked"}var _h=kh,OS=Ih;const kn=m.forwardRef(({className:e,...t},n)=>c.jsx(_h,{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(OS,{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")})}));kn.displayName=_h.displayName;var jh=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"}),MS="VisuallyHidden",DS=m.forwardRef((e,t)=>c.jsx(Ne.span,{...e,ref:t,style:{...jh,...e.style}}));DS.displayName=MS;var LS=[" ","Enter","ArrowUp","ArrowDown"],$S=[" ","Enter"],Xn="Select",[Ns,As,FS]=Qi(Xn),[xr,tT]=en(Xn,[FS,ms]),_s=ms(),[BS,En]=xr(Xn),[zS,HS]=xr(Xn),Rh=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:w}=e,v=_s(t),[g,x]=m.useState(null),[b,S]=m.useState(null),[E,C]=m.useState(!1),k=os(u),[I,A]=Hn({prop:r,defaultProp:o??!1,onChange:s,caller:Xn}),[j,P]=Hn({prop:i,defaultProp:a,onChange:l,caller:Xn}),L=m.useRef(null),$=g?w||!!g.closest("form"):!0,[H,M]=m.useState(new Set),K=Array.from(H).map(W=>W.props.value).join(";");return c.jsx(Gd,{...v,children:c.jsxs(BS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:tn(),value:j,onValueChange:P,open:I,onOpenChange:A,dir:k,triggerPointerDownPosRef:L,disabled:h,children:[c.jsx(Ns.Provider,{scope:t,children:c.jsx(zS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(W=>{M(G=>new Set(G).add(W))},[]),onNativeOptionRemove:m.useCallback(W=>{M(G=>{const B=new Set(G);return B.delete(W),B})},[]),children:n})}),$?c.jsxs(np,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:W=>P(W.target.value),disabled:h,form:w,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(H)]},K):null]})})};Rh.displayName=Xn;var Ph="SelectTrigger",Oh=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=_s(n),i=En(Ph,n),a=i.disabled||r,l=Be(t,i.onTriggerChange),u=As(n),d=m.useRef("touch"),[f,h,p]=op(v=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),b=sp(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(Yd,{asChild:!0,...s,children:c.jsx(Ne.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":rp(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:le(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:le(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&LS.includes(v.key)&&(w(),v.preventDefault())})})})});Oh.displayName=Ph;var Mh="SelectValue",Dh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=En(Mh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Be(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(Ne.span,{...a,ref:f,style:{pointerEvents:"none"},children:rp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Dh.displayName=Mh;var US="SelectIcon",Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(Ne.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Lh.displayName=US;var WS="SelectPortal",$h=e=>c.jsx(Ho,{asChild:!0,...e});$h.displayName=WS;var Jn="SelectContent",Fh=m.forwardRef((e,t)=>{const n=En(Jn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?ro.createPortal(c.jsx(Bh,{scope:e.__scopeSelect,children:c.jsx(Ns.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(zh,{...e,ref:t})});Fh.displayName=Jn;var Gt=10,[Bh,In]=xr(Jn),VS="SelectContentImpl",KS=On.createSlot("SelectContent.RemoveScroll"),zh=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:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=En(Jn,n),[S,E]=m.useState(null),[C,k]=m.useState(null),I=Be(t,V=>E(V)),[A,j]=m.useState(null),[P,L]=m.useState(null),$=As(n),[H,M]=m.useState(!1),K=m.useRef(!1);m.useEffect(()=>{if(S)return qi(S)},[S]),zi();const W=m.useCallback(V=>{const[D,...J]=$().map(ce=>ce.ref.current),[U]=J.slice(-1),de=document.activeElement;for(const ce of V)if(ce===de||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===D&&C&&(C.scrollTop=0),ce===U&&C&&(C.scrollTop=C.scrollHeight),ce==null||ce.focus(),document.activeElement!==de))return},[$,C]),G=m.useCallback(()=>W([A,S]),[W,A,S]);m.useEffect(()=>{H&&G()},[H,G]);const{onOpenChange:B,triggerPointerDownPosRef:_}=b;m.useEffect(()=>{if(S){let V={x:0,y:0};const D=U=>{var de,ce;V={x:Math.abs(Math.round(U.pageX)-(((de=_.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(U.pageY)-(((ce=_.current)==null?void 0:ce.y)??0))}},J=U=>{V.x<=10&&V.y<=10?U.preventDefault():S.contains(U.target)||B(!1),document.removeEventListener("pointermove",D),_.current=null};return _.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,B,_]),m.useEffect(()=>{const V=()=>B(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[B]);const[q,Q]=op(V=>{const D=$().filter(de=>!de.disabled),J=D.find(de=>de.ref.current===document.activeElement),U=sp(D,V,J);U&&setTimeout(()=>U.ref.current.focus())}),xe=m.useCallback((V,D,J)=>{const U=!K.current&&!J;(b.value!==void 0&&b.value===D||U)&&(j(V),U&&(K.current=!0))},[b.value]),ue=m.useCallback(()=>S==null?void 0:S.focus(),[S]),te=m.useCallback((V,D,J)=>{const U=!K.current&&!J;(b.value!==void 0&&b.value===D||U)&&L(V)},[b.value]),je=r==="popper"?_a:Hh,Te=je===_a?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(Bh,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:xe,selectedItem:A,onItemLeave:ue,itemTextRefCallback:te,focusSelectedItem:G,selectedItemText:P,position:r,isPositioned:H,searchRef:q,children:c.jsx(Go,{as:KS,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:le(o,V=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(je,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:V=>V.preventDefault(),...x,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:le(x.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&Q(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let U=$().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(V.key)&&(U=U.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const de=V.target,ce=U.indexOf(de);U=U.slice(ce+1)}setTimeout(()=>W(U)),V.preventDefault()}})})})})})})});zh.displayName=VS;var qS="SelectItemAlignedPosition",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=En(Jn,n),i=In(Jn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Be(t,I=>d(I)),h=As(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=x.getBoundingClientRect();if(s.dir!=="rtl"){const de=P.left-A.left,ce=j.left-de,ze=I.left-ce,Xe=I.width+ze,Ge=Math.max(Xe,A.width),ke=window.innerWidth-Gt,De=Ta(ce,[Gt,Math.max(Gt,ke-Ge)]);a.style.minWidth=Xe+"px",a.style.left=De+"px"}else{const de=A.right-P.right,ce=window.innerWidth-j.right-de,ze=window.innerWidth-I.right-ce,Xe=I.width+ze,Ge=Math.max(Xe,A.width),ke=window.innerWidth-Gt,De=Ta(ce,[Gt,Math.max(Gt,ke-Ge)]);a.style.minWidth=Xe+"px",a.style.right=De+"px"}const L=h(),$=window.innerHeight-Gt*2,H=v.scrollHeight,M=window.getComputedStyle(u),K=parseInt(M.borderTopWidth,10),W=parseInt(M.paddingTop,10),G=parseInt(M.borderBottomWidth,10),B=parseInt(M.paddingBottom,10),_=K+W+H+B+G,q=Math.min(g.offsetHeight*5,_),Q=window.getComputedStyle(v),xe=parseInt(Q.paddingTop,10),ue=parseInt(Q.paddingBottom,10),te=I.top+I.height/2-Gt,je=$-te,Te=g.offsetHeight/2,V=g.offsetTop+Te,D=K+W+V,J=_-D;if(D<=te){const de=L.length>0&&g===L[L.length-1].ref.current;a.style.bottom="0px";const ce=u.clientHeight-v.offsetTop-v.offsetHeight,ze=Math.max(je,Te+(de?ue:0)+ce+G),Xe=D+ze;a.style.height=Xe+"px"}else{const de=L.length>0&&g===L[0].ref.current;a.style.top="0px";const ze=Math.max(te,K+v.offsetTop+(de?xe:0)+Te)+J;a.style.height=ze+"px",v.scrollTop=D-te+v.offsetTop}a.style.margin=`${Gt}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>S(),[S]);const[E,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(I=>{I&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(YS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(Ne.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hh.displayName=qS;var GS="SelectPopperPosition",_a=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Gt,...s}=e,i=_s(n);return c.jsx(Xd,{...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)"}})});_a.displayName=GS;var[YS,ja]=xr(Jn,{}),Ra="SelectViewport",Uh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=In(Ra,n),i=ja(Ra,n),a=Be(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(Ns.Slot,{scope:n,children:c.jsx(Ne.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(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 w=window.innerHeight-Gt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,S=Math.min(w,b),E=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Uh.displayName=Ra;var Wh="SelectGroup",[XS,JS]=xr(Wh),ZS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(XS,{scope:n,id:o,children:c.jsx(Ne.div,{role:"group","aria-labelledby":o,...r,ref:t})})});ZS.displayName=Wh;var Vh="SelectLabel",Kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=JS(Vh,n);return c.jsx(Ne.div,{id:o.id,...r,ref:t})});Kh.displayName=Vh;var js="SelectItem",[QS,qh]=xr(js),Gh=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=En(js,n),l=In(js,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Be(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),v=tn(),g=m.useRef("touch"),x=()=>{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(QS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(Ne.div,{role:"option","aria-labelledby":v,"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:w,onFocus:le(i.onFocus,()=>p(!0)),onBlur:le(i.onBlur,()=>p(!1)),onClick:le(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:le(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:le(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:le(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:le(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||($S.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Gh.displayName=js;var to="SelectItemText",Yh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=En(to,n),a=In(to,n),l=qh(to,n),u=HS(to,n),[d,f]=m.useState(null),h=Be(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(Ne.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ro.createPortal(s.children,i.valueNode):null]})});Yh.displayName=to;var Xh="SelectItemIndicator",Jh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qh(Xh,n).isSelected?c.jsx(Ne.span,{"aria-hidden":!0,...r,ref:t}):null});Jh.displayName=Xh;var Pa="SelectScrollUpButton",Zh=m.forwardRef((e,t)=>{const n=In(Pa,e.__scopeSelect),r=ja(Pa,e.__scopeSelect),[o,s]=m.useState(!1),i=Be(t,r.onScrollButtonChange);return pt(()=>{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(ep,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Zh.displayName=Pa;var Oa="SelectScrollDownButton",Qh=m.forwardRef((e,t)=>{const n=In(Oa,e.__scopeSelect),r=ja(Oa,e.__scopeSelect),[o,s]=m.useState(!1),i=Be(t,r.onScrollButtonChange);return pt(()=>{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(ep,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Qh.displayName=Oa;var ep=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=In("SelectScrollButton",n),i=m.useRef(null),a=As(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{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(Ne.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),eC="SelectSeparator",tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ne.div,{"aria-hidden":!0,...r,ref:t})});tp.displayName=eC;var Ma="SelectArrow",tC=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_s(n),s=En(Ma,n),i=In(Ma,n);return s.open&&i.position==="popper"?c.jsx(Jd,{...o,...r,ref:t}):null});tC.displayName=Ma;var nC="SelectBubbleInput",np=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Be(r,o),i=Th(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(Ne.select,{...n,style:{...jh,...n.style},ref:s,defaultValue:t})});np.displayName=nC;function rp(e){return e===""||e===void 0}function op(e){const t=mt(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 sp(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=rC(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 rC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var oC=Rh,ip=Oh,sC=Dh,iC=Lh,aC=$h,ap=Fh,lC=Uh,lp=Kh,cp=Gh,cC=Yh,uC=Jh,up=Zh,dp=Qh,fp=tp;const hp=oC,pp=sC,Da=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ip,{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(iC,{asChild:!0,children:c.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Da.displayName=ip.displayName;const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));mp.displayName=up.displayName;const gp=m.forwardRef(({className:e,...t},n)=>c.jsx(dp,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));gp.displayName=dp.displayName;const La=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(aC,{children:c.jsxs(ap,{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(mp,{}),c.jsx(lC,{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(gp,{})]})}));La.displayName=ap.displayName;const dC=m.forwardRef(({className:e,...t},n)=>c.jsx(lp,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));dC.displayName=lp.displayName;const Zn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(cp,{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(uC,{children:c.jsx(oe.Check,{className:"h-4 w-4"})})}),c.jsx(cC,{children:t})]}));Zn.displayName=cp.displayName;const fC=m.forwardRef(({className:e,...t},n)=>c.jsx(fp,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));fC.displayName=fp.displayName;var hC="Separator",xp="horizontal",pC=["horizontal","vertical"],vp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=xp,...o}=e,s=mC(r)?r:xp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(Ne.div,{"data-orientation":s,...a,...o,ref:t})});vp.displayName=hC;function mC(e){return pC.includes(e)}var wp=vp;const bp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(wp,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));bp.displayName=wp.displayName;const gC=nd,xC=Xw,vC=rd,yp=m.forwardRef(({className:e,...t},n)=>c.jsx(Qo,{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}));yp.displayName=Qo.displayName;const wC=no.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"}}),Sp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(vC,{children:[c.jsx(yp,{}),c.jsxs(es,{ref:o,className:ee(wC({side:e}),t),...r,children:[n,c.jsxs(od,{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(oe.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Sp.displayName=es.displayName;const Cp=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});Cp.displayName="SheetHeader";const Tp=m.forwardRef(({className:e,...t},n)=>c.jsx(Vn,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));Tp.displayName=Vn.displayName;const kp=m.forwardRef(({className:e,...t},n)=>c.jsx(ts,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));kp.displayName=ts.displayName;const bC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function yC({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}=Di();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(bC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(gC,{open:r,onOpenChange:o,children:[c.jsx(xC,{asChild:!0,children:c.jsxs(Ve,{variant:"outline",size:"sm",className:n,children:[c.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Ei,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(Sp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(Cp,{children:[c.jsx(Tp,{children:"Chat Settings"}),c.jsx(kp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(zr,{children:[c.jsx(Hr,{className:"pb-3",children:c.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[c.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ve,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(kn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ve,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(oe.EyeOff,{className:"h-4 w-4"}):c.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(zr,{children:[c.jsx(Hr,{className:"pb-3",children:c.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[c.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(hp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Da,{children:c.jsx(pp,{})}),c.jsxs(La,{children:[c.jsx(Zn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Zn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Zn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"theme",children:"Theme"}),c.jsxs(hp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Da,{children:c.jsx(pp,{})}),c.jsxs(La,{children:[c.jsx(Zn,{value:"light",children:"Light"}),c.jsx(Zn,{value:"dark",children:"Dark"}),c.jsx(Zn,{value:"system",children:"System"})]})]})]}),c.jsx(bp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(kn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(kn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(kn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(zr,{children:[c.jsx(Hr,{className:"pb-3",children:c.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[c.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(Po,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(kn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(kn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(kn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ve,{variant:"outline",onClick:p,children:[c.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ve,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Ve,{onClick:h,disabled:!u,children:[c.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function SC({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(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(xo,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(xo,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Aa,{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(ys,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=Rl,_e.ChatInterface=ys,_e.ChatProviders=xo,_e.ChatSettings=yC,_e.MarkdownContent=Pi,_e.MessageComponent=hd,_e.MessageList=Zi,_e.ThreadManager=Aa,_e.applySettings=IS,_e.chatApiClient=mn,_e.default=SC,_e.del=jl,_e.get=It,_e.getChatToken=Nl,_e.getCurrentSettings=ES,_e.getDefaultApiConfig=wh,_e.getDefaultChatSettings=bh,_e.onChatTokenChanged=Al,_e.post=qs,_e.put=_l,_e.setChatToken=Ks,_e.useApi=Gs,_e.useChatStream=Dl,_e.useMessages=ni,_e.useMessagesReducer=Ol,_e.useStream=Kl,_e.useThreads=go,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});