teodor-new-chat-ui 4.0.0 → 4.0.2

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(Ce,S){typeof exports=="object"&&typeof module<"u"?S(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"],S):(Ce=typeof globalThis<"u"?globalThis:Ce||self,S(Ce.NewChatUI={},Ce.React,Ce.LucideReact,Ce.reactSlot,Ce.classVarianceAuthority,Ce.clsx,Ce.tailwindMerge,Ce.ReactDOM))})(this,function(Ce,S,ne,$n,ro,hp,pp,Rs){"use strict";var ZS=Object.defineProperty;var QS=(Ce,S,ne)=>S in Ce?ZS(Ce,S,{enumerable:!0,configurable:!0,writable:!0,value:ne}):Ce[S]=ne;var dp=(Ce,S,ne)=>QS(Ce,typeof S!="symbol"?S+"":S,ne);function Oa(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 p=Oa(S),oo=Oa(Rs);var Ps={exports:{}},kr={};/**
1
+ (function(Te,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):(Te=typeof globalThis<"u"?globalThis:Te||self,y(Te.NewChatUI={},Te.React,Te.LucideReact,Te.reactSlot,Te.classVarianceAuthority,Te.clsx,Te.tailwindMerge,Te.ReactDOM))})(this,function(Te,y,oe,Mn,ro,mp,gp,Rs){"use strict";var iC=Object.defineProperty;var aC=(Te,y,oe)=>y in Te?iC(Te,y,{enumerable:!0,configurable:!0,writable:!0,value:oe}):Te[y]=oe;var hp=(Te,y,oe)=>aC(Te,typeof y!="symbol"?y+"":y,oe);var Ps=typeof document<"u"?document.currentScript:null;function Da(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 p=Da(y),oo=Da(Rs);var Os={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 Ma;function mp(){if(Ma)return kr;Ma=1;var e=S,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,c,u){var d,f={},h=null,m=null;u!==void 0&&(h=""+u),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:h,ref:m,props:f,_owner:o.current}}return kr.Fragment=n,kr.jsx=i,kr.jsxs=i,kr}var Tr={};/**
9
+ */var La;function xp(){if(La)return Cr;La=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,c,u){var d,f={},h=null,m=null;u!==void 0&&(h=""+u),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:h,ref:m,props:f,_owner:o.current}}return Cr.Fragment=n,Cr.jsx=i,Cr.jsxs=i,Cr}var kr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,41 +14,41 @@
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 Da;function gp(){return Da||(Da=1,process.env.NODE_ENV!=="production"&&function(){var e=S,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"),c=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"),m=Symbol.for("react.offscreen"),b=Symbol.iterator,w="@@iterator";function g(T){if(T===null||typeof T!="object")return null;var z=b&&T[b]||T[w];return typeof z=="function"?z:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(T){{for(var z=arguments.length,se=new Array(z>1?z-1:0),be=1;be<z;be++)se[be-1]=arguments[be];y("error",T,se)}}function y(T,z,se){{var be=x.ReactDebugCurrentFrame,Ke=be.getStackAddendum();Ke!==""&&(z+="%s",se=se.concat([Ke]));var et=se.map(function(Fe){return String(Fe)});et.unshift("Warning: "+z),Function.prototype.apply.call(console[T],console,et)}}var E=!1,C=!1,k=!1,I=!1,N=!1,_;_=Symbol.for("react.module.reference");function O(T){return!!(typeof T=="string"||typeof T=="function"||T===r||T===s||N||T===o||T===u||T===d||I||T===m||E||C||k||typeof T=="object"&&T!==null&&(T.$$typeof===h||T.$$typeof===f||T.$$typeof===i||T.$$typeof===a||T.$$typeof===c||T.$$typeof===_||T.getModuleId!==void 0))}function R(T,z,se){var be=T.displayName;if(be)return be;var Ke=z.displayName||z.name||"";return Ke!==""?se+"("+Ke+")":se}function $(T){return T.displayName||"Context"}function q(T){if(T==null)return null;if(typeof T.tag=="number"&&v("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 z=T;return $(z)+".Consumer";case i:var se=T;return $(se._context)+".Provider";case c:return R(T,T.render,"ForwardRef");case f:var be=T.displayName||null;return be!==null?be:q(T.type)||"Memo";case h:{var Ke=T,et=Ke._payload,Fe=Ke._init;try{return q(Fe(et))}catch{return null}}}return null}var M=Object.assign,W=0,U,V,D,A,K,Y,re;function te(){}te.__reactDisabledLog=!0;function pe(){{if(W===0){U=console.log,V=console.info,D=console.warn,A=console.error,K=console.group,Y=console.groupCollapsed,re=console.groupEnd;var T={configurable:!0,enumerable:!0,value:te,writable:!0};Object.defineProperties(console,{info:T,log:T,warn:T,error:T,group:T,groupCollapsed:T,groupEnd:T})}W++}}function Se(){{if(W--,W===0){var T={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},T,{value:U}),info:M({},T,{value:V}),warn:M({},T,{value:D}),error:M({},T,{value:A}),group:M({},T,{value:K}),groupCollapsed:M({},T,{value:Y}),groupEnd:M({},T,{value:re})})}W<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Te=x.ReactCurrentDispatcher,B;function j(T,z,se){{if(B===void 0)try{throw Error()}catch(Ke){var be=Ke.stack.trim().match(/\n( *(at )?)/);B=be&&be[1]||""}return`
18
- `+B+T}}var H=!1,ee;{var ue=typeof WeakMap=="function"?WeakMap:Map;ee=new ue}function ce(T,z){if(!T||H)return"";{var se=ee.get(T);if(se!==void 0)return se}var be;H=!0;var Ke=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var et;et=Te.current,Te.current=null,pe();try{if(z){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(Dt){be=Dt}Reflect.construct(T,[],Fe)}else{try{Fe.call()}catch(Dt){be=Dt}T.call(Fe.prototype)}}else{try{throw Error()}catch(Dt){be=Dt}T()}}catch(Dt){if(Dt&&be&&typeof Dt.stack=="string"){for(var Le=Dt.stack.split(`
19
- `),Rt=be.stack.split(`
20
- `),ht=Le.length-1,vt=Rt.length-1;ht>=1&&vt>=0&&Le[ht]!==Rt[vt];)vt--;for(;ht>=1&&vt>=0;ht--,vt--)if(Le[ht]!==Rt[vt]){if(ht!==1||vt!==1)do if(ht--,vt--,vt<0||Le[ht]!==Rt[vt]){var Zt=`
21
- `+Le[ht].replace(" at new "," at ");return T.displayName&&Zt.includes("<anonymous>")&&(Zt=Zt.replace("<anonymous>",T.displayName)),typeof T=="function"&&ee.set(T,Zt),Zt}while(ht>=1&&vt>=0);break}}}finally{H=!1,Te.current=et,Se(),Error.prepareStackTrace=Ke}var Cr=T?T.displayName||T.name:"",sr=Cr?j(Cr):"";return typeof T=="function"&&ee.set(T,sr),sr}function _e(T,z,se){return ce(T,!1)}function Ne(T){var z=T.prototype;return!!(z&&z.isReactComponent)}function Ee(T,z,se){if(T==null)return"";if(typeof T=="function")return ce(T,Ne(T));if(typeof T=="string")return j(T);switch(T){case u:return j("Suspense");case d:return j("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case c:return _e(T.render);case f:return Ee(T.type,z,se);case h:{var be=T,Ke=be._payload,et=be._init;try{return Ee(et(Ke),z,se)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Be={},Ge=x.ReactDebugCurrentFrame;function De(T){if(T){var z=T._owner,se=Ee(T.type,T._source,z?z.type:null);Ge.setExtraStackFrame(se)}else Ge.setExtraStackFrame(null)}function tt(T,z,se,be,Ke){{var et=Function.call.bind(je);for(var Fe in T)if(et(T,Fe)){var Le=void 0;try{if(typeof T[Fe]!="function"){var Rt=Error((be||"React class")+": "+se+" 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 Rt.name="Invariant Violation",Rt}Le=T[Fe](z,Fe,be,se,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ht){Le=ht}Le&&!(Le instanceof Error)&&(De(Ke),v("%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).",be||"React class",se,Fe,typeof Le),De(null)),Le instanceof Error&&!(Le.message in Be)&&(Be[Le.message]=!0,De(Ke),v("Failed %s type: %s",se,Le.message),De(null))}}}var mt=Array.isArray;function at(T){return mt(T)}function lt(T){{var z=typeof Symbol=="function"&&Symbol.toStringTag,se=z&&T[Symbol.toStringTag]||T.constructor.name||"Object";return se}}function gt(T){try{return Ue(T),!1}catch{return!0}}function Ue(T){return""+T}function Q(T){if(gt(T))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",lt(T)),Ue(T)}var oe=x.ReactCurrentOwner,fe={key:!0,ref:!0,__self:!0,__source:!0},We,Ye;function Ze(T){if(je.call(T,"ref")){var z=Object.getOwnPropertyDescriptor(T,"ref").get;if(z&&z.isReactWarning)return!1}return T.ref!==void 0}function yt(T){if(je.call(T,"key")){var z=Object.getOwnPropertyDescriptor(T,"key").get;if(z&&z.isReactWarning)return!1}return T.key!==void 0}function dt(T,z){typeof T.ref=="string"&&oe.current}function St(T,z){{var se=function(){We||(We=!0,v("%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)",z))};se.isReactWarning=!0,Object.defineProperty(T,"key",{get:se,configurable:!0})}}function Xt(T,z){{var se=function(){Ye||(Ye=!0,v("%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)",z))};se.isReactWarning=!0,Object.defineProperty(T,"ref",{get:se,configurable:!0})}}var L=function(T,z,se,be,Ke,et,Fe){var Le={$$typeof:t,type:T,key:z,ref:se,props:Fe,_owner:et};return Le._store={},Object.defineProperty(Le._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Le,"_self",{configurable:!1,enumerable:!1,writable:!1,value:be}),Object.defineProperty(Le,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ke}),Object.freeze&&(Object.freeze(Le.props),Object.freeze(Le)),Le};function Z(T,z,se,be,Ke){{var et,Fe={},Le=null,Rt=null;se!==void 0&&(Q(se),Le=""+se),yt(z)&&(Q(z.key),Le=""+z.key),Ze(z)&&(Rt=z.ref,dt(z,Ke));for(et in z)je.call(z,et)&&!fe.hasOwnProperty(et)&&(Fe[et]=z[et]);if(T&&T.defaultProps){var ht=T.defaultProps;for(et in ht)Fe[et]===void 0&&(Fe[et]=ht[et])}if(Le||Rt){var vt=typeof T=="function"?T.displayName||T.name||"Unknown":T;Le&&St(Fe,vt),Rt&&Xt(Fe,vt)}return L(T,Le,Rt,Ke,be,oe.current,Fe)}}var Re=x.ReactCurrentOwner,qe=x.ReactDebugCurrentFrame;function it(T){if(T){var z=T._owner,se=Ee(T.type,T._source,z?z.type:null);qe.setExtraStackFrame(se)}else qe.setExtraStackFrame(null)}var ft;ft=!1;function Jt(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function bn(){{if(Re.current){var T=q(Re.current.type);if(T)return`
17
+ */var $a;function vp(){return $a||($a=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"),c=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"),m=Symbol.for("react.offscreen"),b=Symbol.iterator,w="@@iterator";function g(T){if(T===null||typeof T!="object")return null;var z=b&&T[b]||T[w];return typeof z=="function"?z:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(T){{for(var z=arguments.length,ne=new Array(z>1?z-1:0),Se=1;Se<z;Se++)ne[Se-1]=arguments[Se];S("error",T,ne)}}function S(T,z,ne){{var Se=x.ReactDebugCurrentFrame,qe=Se.getStackAddendum();qe!==""&&(z+="%s",ne=ne.concat([qe]));var tt=ne.map(function(ze){return String(ze)});tt.unshift("Warning: "+z),Function.prototype.apply.call(console[T],console,tt)}}var E=!1,C=!1,k=!1,I=!1,N=!1,_;_=Symbol.for("react.module.reference");function O(T){return!!(typeof T=="string"||typeof T=="function"||T===r||T===s||N||T===o||T===u||T===d||I||T===m||E||C||k||typeof T=="object"&&T!==null&&(T.$$typeof===h||T.$$typeof===f||T.$$typeof===i||T.$$typeof===a||T.$$typeof===c||T.$$typeof===_||T.getModuleId!==void 0))}function R(T,z,ne){var Se=T.displayName;if(Se)return Se;var qe=z.displayName||z.name||"";return qe!==""?ne+"("+qe+")":ne}function $(T){return T.displayName||"Context"}function K(T){if(T==null)return null;if(typeof T.tag=="number"&&v("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 z=T;return $(z)+".Consumer";case i:var ne=T;return $(ne._context)+".Provider";case c:return R(T,T.render,"ForwardRef");case f:var Se=T.displayName||null;return Se!==null?Se:K(T.type)||"Memo";case h:{var qe=T,tt=qe._payload,ze=qe._init;try{return K(ze(tt))}catch{return null}}}return null}var M=Object.assign,W=0,U,V,L,A,q,J,se;function te(){}te.__reactDisabledLog=!0;function pe(){{if(W===0){U=console.log,V=console.info,L=console.warn,A=console.error,q=console.group,J=console.groupCollapsed,se=console.groupEnd;var T={configurable:!0,enumerable:!0,value:te,writable:!0};Object.defineProperties(console,{info:T,log:T,warn:T,error:T,group:T,groupCollapsed:T,groupEnd:T})}W++}}function Ie(){{if(W--,W===0){var T={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},T,{value:U}),info:M({},T,{value:V}),warn:M({},T,{value:L}),error:M({},T,{value:A}),group:M({},T,{value:q}),groupCollapsed:M({},T,{value:J}),groupEnd:M({},T,{value:se})})}W<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ne=x.ReactCurrentDispatcher,B;function j(T,z,ne){{if(B===void 0)try{throw Error()}catch(qe){var Se=qe.stack.trim().match(/\n( *(at )?)/);B=Se&&Se[1]||""}return`
18
+ `+B+T}}var H=!1,ee;{var ue=typeof WeakMap=="function"?WeakMap:Map;ee=new ue}function ce(T,z){if(!T||H)return"";{var ne=ee.get(T);if(ne!==void 0)return ne}var Se;H=!0;var qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=Ne.current,Ne.current=null,pe();try{if(z){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(Pt){Se=Pt}Reflect.construct(T,[],ze)}else{try{ze.call()}catch(Pt){Se=Pt}T.call(ze.prototype)}}else{try{throw Error()}catch(Pt){Se=Pt}T()}}catch(Pt){if(Pt&&Se&&typeof Pt.stack=="string"){for(var De=Pt.stack.split(`
19
+ `),At=Se.stack.split(`
20
+ `),ft=De.length-1,gt=At.length-1;ft>=1&&gt>=0&&De[ft]!==At[gt];)gt--;for(;ft>=1&&gt>=0;ft--,gt--)if(De[ft]!==At[gt]){if(ft!==1||gt!==1)do if(ft--,gt--,gt<0||De[ft]!==At[gt]){var Yt=`
21
+ `+De[ft].replace(" at new "," at ");return T.displayName&&Yt.includes("<anonymous>")&&(Yt=Yt.replace("<anonymous>",T.displayName)),typeof T=="function"&&ee.set(T,Yt),Yt}while(ft>=1&&gt>=0);break}}}finally{H=!1,Ne.current=tt,Ie(),Error.prepareStackTrace=qe}var Sr=T?T.displayName||T.name:"",nr=Sr?j(Sr):"";return typeof T=="function"&&ee.set(T,nr),nr}function Oe(T,z,ne){return ce(T,!1)}function Ge(T){var z=T.prototype;return!!(z&&z.isReactComponent)}function ke(T,z,ne){if(T==null)return"";if(typeof T=="function")return ce(T,Ge(T));if(typeof T=="string")return j(T);switch(T){case u:return j("Suspense");case d:return j("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case c:return Oe(T.render);case f:return ke(T.type,z,ne);case h:{var Se=T,qe=Se._payload,tt=Se._init;try{return ke(tt(qe),z,ne)}catch{}}}return""}var be=Object.prototype.hasOwnProperty,Ue={},Ye=x.ReactDebugCurrentFrame;function $e(T){if(T){var z=T._owner,ne=ke(T.type,T._source,z?z.type:null);Ye.setExtraStackFrame(ne)}else Ye.setExtraStackFrame(null)}function st(T,z,ne,Se,qe){{var tt=Function.call.bind(be);for(var ze in T)if(tt(T,ze)){var De=void 0;try{if(typeof T[ze]!="function"){var At=Error((Se||"React class")+": "+ne+" 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 At.name="Invariant Violation",At}De=T[ze](z,ze,Se,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ft){De=ft}De&&!(De instanceof Error)&&($e(qe),v("%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).",Se||"React class",ne,ze,typeof De),$e(null)),De instanceof Error&&!(De.message in Ue)&&(Ue[De.message]=!0,$e(qe),v("Failed %s type: %s",ne,De.message),$e(null))}}}var pt=Array.isArray;function it(T){return pt(T)}function dt(T){{var z=typeof Symbol=="function"&&Symbol.toStringTag,ne=z&&T[Symbol.toStringTag]||T.constructor.name||"Object";return ne}}function at(T){try{return Fe(T),!1}catch{return!0}}function Fe(T){return""+T}function Y(T){if(at(T))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",dt(T)),Fe(T)}var re=x.ReactCurrentOwner,he={key:!0,ref:!0,__self:!0,__source:!0},We,Xe;function Qe(T){if(be.call(T,"ref")){var z=Object.getOwnPropertyDescriptor(T,"ref").get;if(z&&z.isReactWarning)return!1}return T.ref!==void 0}function yt(T){if(be.call(T,"key")){var z=Object.getOwnPropertyDescriptor(T,"key").get;if(z&&z.isReactWarning)return!1}return T.key!==void 0}function lt(T,z){typeof T.ref=="string"&&re.current}function mt(T,z){{var ne=function(){We||(We=!0,v("%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)",z))};ne.isReactWarning=!0,Object.defineProperty(T,"key",{get:ne,configurable:!0})}}function Kt(T,z){{var ne=function(){Xe||(Xe=!0,v("%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)",z))};ne.isReactWarning=!0,Object.defineProperty(T,"ref",{get:ne,configurable:!0})}}var On=function(T,z,ne,Se,qe,tt,ze){var De={$$typeof:t,type:T,key:z,ref:ne,props:ze,_owner:tt};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:Se}),Object.defineProperty(De,"_source",{configurable:!1,enumerable:!1,writable:!1,value:qe}),Object.freeze&&(Object.freeze(De.props),Object.freeze(De)),De};function no(T,z,ne,Se,qe){{var tt,ze={},De=null,At=null;ne!==void 0&&(Y(ne),De=""+ne),yt(z)&&(Y(z.key),De=""+z.key),Qe(z)&&(At=z.ref,lt(z,qe));for(tt in z)be.call(z,tt)&&!he.hasOwnProperty(tt)&&(ze[tt]=z[tt]);if(T&&T.defaultProps){var ft=T.defaultProps;for(tt in ft)ze[tt]===void 0&&(ze[tt]=ft[tt])}if(De||At){var gt=typeof T=="function"?T.displayName||T.name||"Unknown":T;De&&mt(ze,gt),At&&Kt(ze,gt)}return On(T,De,At,qe,Se,re.current,ze)}}var er=x.ReactCurrentOwner,br=x.ReactDebugCurrentFrame;function gn(T){if(T){var z=T._owner,ne=ke(T.type,T._source,z?z.type:null);br.setExtraStackFrame(ne)}else br.setExtraStackFrame(null)}var tr;tr=!1;function D(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function Z(){{if(er.current){var T=K(er.current.type);if(T)return`
22
22
 
23
- Check the render method of \``+T+"`."}return""}}function Ct(T){return""}var Pe={};function xt(T){{var z=bn();if(!z){var se=typeof T=="string"?T:T.displayName||T.name;se&&(z=`
23
+ Check the render method of \``+T+"`."}return""}}function Re(T){return""}var Ke={};function vt(T){{var z=Z();if(!z){var ne=typeof T=="string"?T:T.displayName||T.name;ne&&(z=`
24
24
 
25
- Check the top-level render call using <`+se+">.")}return z}}function J(T,z){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var se=xt(z);if(Pe[se])return;Pe[se]=!0;var be="";T&&T._owner&&T._owner!==Re.current&&(be=" It was passed a child from "+q(T._owner.type)+"."),it(T),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',se,be),it(null)}}function he(T,z){{if(typeof T!="object")return;if(at(T))for(var se=0;se<T.length;se++){var be=T[se];Jt(be)&&J(be,z)}else if(Jt(T))T._store&&(T._store.validated=!0);else if(T){var Ke=g(T);if(typeof Ke=="function"&&Ke!==T.entries)for(var et=Ke.call(T),Fe;!(Fe=et.next()).done;)Jt(Fe.value)&&J(Fe.value,z)}}}function Oe(T){{var z=T.type;if(z==null||typeof z=="string")return;var se;if(typeof z=="function")se=z.propTypes;else if(typeof z=="object"&&(z.$$typeof===c||z.$$typeof===f))se=z.propTypes;else return;if(se){var be=q(z);tt(se,T.props,"prop",be,T)}else if(z.PropTypes!==void 0&&!ft){ft=!0;var Ke=q(z);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ke||"Unknown")}typeof z.getDefaultProps=="function"&&!z.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Qe(T){{for(var z=Object.keys(T.props),se=0;se<z.length;se++){var be=z[se];if(be!=="children"&&be!=="key"){it(T),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",be),it(null);break}}T.ref!==null&&(it(T),v("Invalid attribute `ref` supplied to `React.Fragment`."),it(null))}}var nt={};function At(T,z,se,be,Ke,et){{var Fe=O(T);if(!Fe){var Le="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(Le+=" 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 Rt=Ct();Rt?Le+=Rt:Le+=bn();var ht;T===null?ht="null":at(T)?ht="array":T!==void 0&&T.$$typeof===t?(ht="<"+(q(T.type)||"Unknown")+" />",Le=" Did you accidentally export a JSX literal instead of a component?"):ht=typeof T,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ht,Le)}var vt=Z(T,z,se,Ke,et);if(vt==null)return vt;if(Fe){var Zt=z.children;if(Zt!==void 0)if(be)if(at(Zt)){for(var Cr=0;Cr<Zt.length;Cr++)he(Zt[Cr],T);Object.freeze&&Object.freeze(Zt)}else v("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 he(Zt,T)}if(je.call(z,"key")){var sr=q(T),Dt=Object.keys(z).filter(function(JS){return JS!=="key"}),Pa=Dt.length>0?"{key: someKey, "+Dt.join(": ..., ")+": ...}":"{key: someKey}";if(!nt[sr+Pa]){var XS=Dt.length>0?"{"+Dt.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+ne+">.")}return z}}function X(T,z){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var ne=vt(z);if(Ke[ne])return;Ke[ne]=!0;var Se="";T&&T._owner&&T._owner!==er.current&&(Se=" It was passed a child from "+K(T._owner.type)+"."),gn(T),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,Se),gn(null)}}function fe(T,z){{if(typeof T!="object")return;if(it(T))for(var ne=0;ne<T.length;ne++){var Se=T[ne];D(Se)&&X(Se,z)}else if(D(T))T._store&&(T._store.validated=!0);else if(T){var qe=g(T);if(typeof qe=="function"&&qe!==T.entries)for(var tt=qe.call(T),ze;!(ze=tt.next()).done;)D(ze.value)&&X(ze.value,z)}}}function je(T){{var z=T.type;if(z==null||typeof z=="string")return;var ne;if(typeof z=="function")ne=z.propTypes;else if(typeof z=="object"&&(z.$$typeof===c||z.$$typeof===f))ne=z.propTypes;else return;if(ne){var Se=K(z);st(ne,T.props,"prop",Se,T)}else if(z.PropTypes!==void 0&&!tr){tr=!0;var qe=K(z);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof z.getDefaultProps=="function"&&!z.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pe(T){{for(var z=Object.keys(T.props),ne=0;ne<z.length;ne++){var Se=z[ne];if(Se!=="children"&&Se!=="key"){gn(T),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Se),gn(null);break}}T.ref!==null&&(gn(T),v("Invalid attribute `ref` supplied to `React.Fragment`."),gn(null))}}var ye={};function et(T,z,ne,Se,qe,tt){{var ze=O(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 At=Re();At?De+=At:De+=Z();var ft;T===null?ft="null":it(T)?ft="array":T!==void 0&&T.$$typeof===t?(ft="<"+(K(T.type)||"Unknown")+" />",De=" Did you accidentally export a JSX literal instead of a component?"):ft=typeof T,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ft,De)}var gt=no(T,z,ne,qe,tt);if(gt==null)return gt;if(ze){var Yt=z.children;if(Yt!==void 0)if(Se)if(it(Yt)){for(var Sr=0;Sr<Yt.length;Sr++)fe(Yt[Sr],T);Object.freeze&&Object.freeze(Yt)}else v("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 fe(Yt,T)}if(be.call(z,"key")){var nr=K(T),Pt=Object.keys(z).filter(function(sC){return sC!=="key"}),Ma=Pt.length>0?"{key: someKey, "+Pt.join(": ..., ")+": ...}":"{key: someKey}";if(!ye[nr+Ma]){var oC=Pt.length>0?"{"+Pt.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Pa,sr,XS,sr),nt[sr+Pa]=!0}}return T===r?Qe(vt):Oe(vt),vt}}function an(T,z,se){return At(T,z,se,!0)}function rr(T,z,se){return At(T,z,se,!1)}var or=rr,kn=an;Tr.Fragment=r,Tr.jsx=or,Tr.jsxs=kn}()),Tr}process.env.NODE_ENV==="production"?Ps.exports=mp():Ps.exports=gp();var l=Ps.exports;function La(e,t){return function(){return e.apply(t,arguments)}}const{toString:xp}=Object.prototype,{getPrototypeOf:Os}=Object,{iterator:so,toStringTag:$a}=Symbol,io=(e=>t=>{const n=xp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Qt=e=>(e=e.toLowerCase(),t=>io(t)===e),ao=e=>t=>typeof t===e,{isArray:ir}=Array,ar=ao("undefined");function Er(e){return e!==null&&!ar(e)&&e.constructor!==null&&!ar(e.constructor)&&Pt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Fa=Qt("ArrayBuffer");function vp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fa(e.buffer),t}const wp=ao("string"),Pt=ao("function"),za=ao("number"),Ir=e=>e!==null&&typeof e=="object",bp=e=>e===!0||e===!1,lo=e=>{if(io(e)!=="object")return!1;const t=Os(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($a in e)&&!(so in e)},yp=e=>{if(!Ir(e)||Er(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Sp=Qt("Date"),Cp=Qt("File"),kp=Qt("Blob"),Tp=Qt("FileList"),Ep=e=>Ir(e)&&Pt(e.pipe),Ip=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Pt(e.append)&&((t=io(e))==="formdata"||t==="object"&&Pt(e.toString)&&e.toString()==="[object FormData]"))},Np=Qt("URLSearchParams"),[Ap,jp,_p,Rp]=["ReadableStream","Request","Response","Headers"].map(Qt),Pp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ir(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Er(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 Ba(e,t){if(Er(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 Fn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ha=e=>!ar(e)&&e!==Fn;function Ms(){const{caseless:e,skipUndefined:t}=Ha(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ba(n,s)||s;lo(n[i])&&lo(o)?n[i]=Ms(n[i],o):lo(o)?n[i]=Ms({},o):ir(o)?n[i]=o.slice():(!t||!ar(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Nr(arguments[o],r);return n}const Op=(e,t,n,{allOwnKeys:r}={})=>(Nr(t,(o,s)=>{n&&Pt(o)?e[s]=La(o,n):e[s]=o},{allOwnKeys:r}),e),Mp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Dp=(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)},Lp=(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},$p=(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},Fp=e=>{if(!e)return null;if(ir(e))return e;let t=e.length;if(!za(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},zp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Os(Uint8Array)),Bp=(e,t)=>{const r=(e&&e[so]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Hp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Up=Qt("HTMLFormElement"),Wp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Ua=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vp=Qt("RegExp"),Wa=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Nr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Kp=e=>{Wa(e,(t,n)=>{if(Pt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Pt(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+"'")})}})},qp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ir(e)?r(e):r(String(e).split(t)),n},Gp=()=>{},Yp=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Xp(e){return!!(e&&Pt(e.append)&&e[$a]==="FormData"&&e[so])}const Jp=e=>{const t=new Array(10),n=(r,o)=>{if(Ir(r)){if(t.indexOf(r)>=0)return;if(Er(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ir(r)?[]:{};return Nr(r,(i,a)=>{const c=n(i,o+1);!ar(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},Zp=Qt("AsyncFunction"),Qp=e=>e&&(Ir(e)||Pt(e))&&Pt(e.then)&&Pt(e.catch),Va=((e,t)=>e?setImmediate:t?((n,r)=>(Fn.addEventListener("message",({source:o,data:s})=>{o===Fn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Fn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Pt(Fn.postMessage)),em=typeof queueMicrotask<"u"?queueMicrotask.bind(Fn):typeof process<"u"&&process.nextTick||Va,P={isArray:ir,isArrayBuffer:Fa,isBuffer:Er,isFormData:Ip,isArrayBufferView:vp,isString:wp,isNumber:za,isBoolean:bp,isObject:Ir,isPlainObject:lo,isEmptyObject:yp,isReadableStream:Ap,isRequest:jp,isResponse:_p,isHeaders:Rp,isUndefined:ar,isDate:Sp,isFile:Cp,isBlob:kp,isRegExp:Vp,isFunction:Pt,isStream:Ep,isURLSearchParams:Np,isTypedArray:zp,isFileList:Tp,forEach:Nr,merge:Ms,extend:Op,trim:Pp,stripBOM:Mp,inherits:Dp,toFlatObject:Lp,kindOf:io,kindOfTest:Qt,endsWith:$p,toArray:Fp,forEachEntry:Bp,matchAll:Hp,isHTMLForm:Up,hasOwnProperty:Ua,hasOwnProp:Ua,reduceDescriptors:Wa,freezeMethods:Kp,toObjectSet:qp,toCamelCase:Wp,noop:Gp,toFiniteNumber:Yp,findKey:Ba,global:Fn,isContextDefined:Ha,isSpecCompliantForm:Xp,toJSONObject:Jp,isAsyncFn:Zp,isThenable:Qp,setImmediate:Va,asap:em,isIterable:e=>e!=null&&Pt(e[so])};function ke(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(ke,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ka=ke.prototype,qa={};["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=>{qa[e]={value:e}}),Object.defineProperties(ke,qa),Object.defineProperty(Ka,"isAxiosError",{value:!0}),ke.from=(e,t,n,r,o,s)=>{const i=Object.create(Ka);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return ke.call(i,a,c,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 tm=null;function Ds(e){return P.isPlainObject(e)||P.isArray(e)}function Ga(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function Ya(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ga(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function nm(e){return P.isArray(e)&&!e.some(Ds)}const rm=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function co(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,g){return!P.isUndefined(g[w])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(b){if(b===null)return"";if(P.isDate(b))return b.toISOString();if(P.isBoolean(b))return b.toString();if(!c&&P.isBlob(b))throw new ke("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(b)||P.isTypedArray(b)?c&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,w,g){let x=b;if(b&&!g&&typeof b=="object"){if(P.endsWith(w,"{}"))w=r?w:w.slice(0,-2),b=JSON.stringify(b);else if(P.isArray(b)&&nm(b)||(P.isFileList(b)||P.endsWith(w,"[]"))&&(x=P.toArray(b)))return w=Ga(w),x.forEach(function(y,E){!(P.isUndefined(y)||y===null)&&t.append(i===!0?Ya([w],E,s):i===null?w:w+"[]",u(y))}),!1}return Ds(b)?!0:(t.append(Ya(g,w,s),u(b)),!1)}const f=[],h=Object.assign(rm,{defaultVisitor:d,convertValue:u,isVisitable:Ds});function m(b,w){if(!P.isUndefined(b)){if(f.indexOf(b)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(b),P.forEach(b,function(x,v){(!(P.isUndefined(x)||x===null)&&o.call(t,x,P.isString(v)?v.trim():v,w,h))===!0&&m(x,w?w.concat(v):[v])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Xa(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&&co(e,this,t)}const Ja=Ls.prototype;Ja.append=function(t,n){this._pairs.push([t,n])},Ja.toString=function(t){const n=t?function(r){return t.call(this,r,Xa)}:Xa;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function om(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Za(e,t,n){if(!t)return e;const r=n&&n.encode||om;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.isURLSearchParams(t)?t.toString():new 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 Qa{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const el={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sm={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,im=$s&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),am=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lm=$s&&window.location.href||"http://localhost",Tt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:$s,hasStandardBrowserEnv:im,hasStandardBrowserWebWorkerEnv:am,navigator:Fs,origin:lm},Symbol.toStringTag,{value:"Module"})),...sm};function cm(e,t){return co(e,new Tt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Tt.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function um(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dm(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 tl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&P.isArray(o)?o.length:i,c?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=dm(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(um(r),o,n,0)}),n}return null}function fm(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ar={transitional:el,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(tl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return cm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return co(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),fm(t)):t}],transformResponse:[function(t){const n=this.transitional||Ar.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?ke.from(a,ke.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:Tt.classes.FormData,Blob:Tt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{Ar.headers[e]={}});const hm=P.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),pm=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&hm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},nl=Symbol("internals");function jr(e){return e&&String(e).trim().toLowerCase()}function uo(e){return e===!1||e==null?e:P.isArray(e)?e.map(uo):String(e)}function mm(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 gm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function zs(e,t,n,r,o){if(P.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!P.isString(t)){if(P.isString(r))return t.indexOf(r)!==-1;if(P.isRegExp(r))return r.test(t)}}function xm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function vm(e,t){const n=P.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Ot=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=jr(c);if(!d)throw new Error("header name must be a non-empty string");const f=P.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=uo(a))}const i=(a,c)=>P.forEach(a,(u,d)=>s(u,d,c));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!gm(t))i(pm(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},c,u;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?P.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=jr(t),t){const r=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return mm(o);if(P.isFunction(n))return n.call(this,o,r);if(P.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=jr(t),t){const r=P.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||zs(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=jr(i),i){const a=P.findKey(r,i);a&&(!n||zs(r,r[a],a,n))&&(delete r[a],o=!0)}}return P.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||zs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return P.forEach(this,(o,s)=>{const i=P.findKey(r,s);if(i){n[i]=uo(o),delete n[s];return}const a=t?xm(s):String(s).trim();a!==s&&delete n[s],n[a]=uo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return P.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&P.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[nl]=this[nl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=jr(i);r[a]||(vm(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};Ot.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(Ot.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(Ot);function Bs(e,t){const n=this||Ar,r=t||n,o=Ot.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function rl(e){return!!(e&&e.__CANCEL__)}function lr(e,t,n){ke.call(this,e??"canceled",ke.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(lr,ke,{__CANCEL__:!0});function ol(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ke("Request failed with status code "+n.status,[ke.ERR_BAD_REQUEST,ke.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function wm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function bm(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(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,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 m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function ym(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 fo=(e,t,n=3)=>{let r=0;const o=bm(50,250);return ym(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,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)},sl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},il=e=>(...t)=>P.asap(()=>e(...t)),Sm=Tt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Tt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Tt.origin),Tt.navigator&&/(msie|trident)/i.test(Tt.navigator.userAgent)):()=>!0,Cm=Tt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function km(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function al(e,t,n){let r=!km(t);return e&&(r||n==!1)?Tm(e,t):t}const ll=e=>e instanceof Ot?{...e}:e;function zn(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={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(ll(u),ll(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const cl=e=>{const t=zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ot.from(i),t.url=Za(al(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(Tt.hasStandardBrowserEnv||Tt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Tt.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&Sm(t.url))){const c=o&&s&&Cm.read(s);c&&i.set(o,c)}return t},Em=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=cl(e);let s=o.data;const i=Ot.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,m,b;function w(){m&&m(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=Ot.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:y,config:e,request:g};ol(function(I){n(I),w()},function(I){r(I),w()},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 ke("Request aborted",ke.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",k=new ke(C,ke.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||el;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new ke(E,C.clarifyTimeoutError?ke.ETIMEDOUT:ke.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,b]=fo(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,m]=fo(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new lr(null,e,g):y),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const v=wm(o.url);if(v&&Tt.protocols.indexOf(v)===-1){r(new ke("Unsupported protocol "+v+":",ke.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Im=(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 ke?d:new lr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new ke(`timeout ${t} of ms exceeded`,ke.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:c}=r;return c.unsubscribe=()=>P.asap(a),c}},Nm=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},Am=async function*(e,t){for await(const n of jm(e))yield*Nm(n,t)},jm=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()}},ul=(e,t,n,r)=>{const o=Am(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},dl=64*1024,{isFunction:ho}=P,_m=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:fl,TextEncoder:hl}=P.global,pl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Rm=e=>{e=P.merge.call({skipUndefined:!0},_m,e);const{fetch:t,Request:n,Response:r}=e,o=t?ho(t):typeof fetch=="function",s=ho(n),i=ho(r);if(!o)return!1;const a=o&&ho(fl),c=o&&(typeof hl=="function"?(b=>w=>b.encode(w))(new hl):async b=>new Uint8Array(await new n(b).arrayBuffer())),u=s&&a&&pl(()=>{let b=!1;const w=new n(Tt.origin,{body:new fl,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!w}),d=i&&a&&pl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!f[b]&&(f[b]=(w,g)=>{let x=w&&w[b];if(x)return x.call(w);throw new ke(`Response type '${b}' is not supported`,ke.ERR_NOT_SUPPORT,g)})});const h=async b=>{if(b==null)return 0;if(P.isBlob(b))return b.size;if(P.isSpecCompliantForm(b))return(await new n(Tt.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(P.isArrayBufferView(b)||P.isArrayBuffer(b))return b.byteLength;if(P.isURLSearchParams(b)&&(b=b+""),P.isString(b))return(await c(b)).byteLength},m=async(b,w)=>{const g=P.toFiniteNumber(b.getContentLength());return g??h(w)};return async b=>{let{url:w,method:g,data:x,signal:v,cancelToken:y,timeout:E,onDownloadProgress:C,onUploadProgress:k,responseType:I,headers:N,withCredentials:_="same-origin",fetchOptions:O}=cl(b),R=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Im([v,y&&y.toAbortSignal()],E),q=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let W;try{if(k&&u&&g!=="get"&&g!=="head"&&(W=await m(N,x))!==0){let Y=new n(w,{method:"POST",body:x,duplex:"half"}),re;if(P.isFormData(x)&&(re=Y.headers.get("content-type"))&&N.setContentType(re),Y.body){const[te,pe]=sl(W,fo(il(k)));x=ul(Y.body,dl,te,pe)}}P.isString(_)||(_=_?"include":"omit");const U=s&&"credentials"in n.prototype,V={...O,signal:$,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:U?_:void 0};q=s&&new n(w,V);let D=await(s?R(q,O):R(w,V));const A=d&&(I==="stream"||I==="response");if(d&&(C||A&&M)){const Y={};["status","statusText","headers"].forEach(Se=>{Y[Se]=D[Se]});const re=P.toFiniteNumber(D.headers.get("content-length")),[te,pe]=C&&sl(re,fo(il(C),!0))||[];D=new r(ul(D.body,dl,te,()=>{pe&&pe(),M&&M()}),Y)}I=I||"text";let K=await f[P.findKey(f,I)||"text"](D,b);return!A&&M&&M(),await new Promise((Y,re)=>{ol(Y,re,{data:K,headers:Ot.from(D.headers),status:D.status,statusText:D.statusText,config:b,request:q})})}catch(U){throw M&&M(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new ke("Network Error",ke.ERR_NETWORK,b,q),{cause:U.cause||U}):ke.from(U,U&&U.code,b,q)}}},Pm=new Map,ml=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=Pm;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:Rm(t)),d=u;return u};ml();const Hs={http:tm,xhr:Em,fetch:{get:ml}};P.forEach(Hs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const gl=e=>`- ${e}`,Om=e=>P.isFunction(e)||e===null||e===!1,xl={getAdapter:(e,t)=>{e=P.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Om(r)&&(o=Hs[(a=String(r)).toLowerCase()],o===void 0))throw new ke(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
- `+i.map(gl).join(`
34
- `):" "+gl(i[0]):"as no adapter specified";throw new ke("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 lr(null,e)}function vl(e){return Us(e),e.headers=Ot.from(e.headers),e.data=Bs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),xl.getAdapter(e.adapter||Ar.adapter,e)(e).then(function(r){return Us(e),r.data=Bs.call(e,e.transformResponse,r),r.headers=Ot.from(r.headers),r},function(r){return rl(r)||(Us(e),r&&r.response&&(r.response.data=Bs.call(e,e.transformResponse,r.response),r.response.headers=Ot.from(r.response.headers))),Promise.reject(r)})}const wl="1.12.2",po={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{po[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bl={};po.transitional=function(t,n,r){function o(s,i){return"[Axios v"+wl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new ke(o(i," has been removed"+(n?" in "+n:"")),ke.ERR_DEPRECATED);return n&&!bl[i]&&(bl[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}},po.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Mm(e,t,n){if(typeof e!="object")throw new ke("options must be an object",ke.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],c=a===void 0||i(a,s,e);if(c!==!0)throw new ke("option "+s+" must be "+c,ke.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ke("Unknown option "+s,ke.ERR_BAD_OPTION)}}const mo={assertOptions:Mm,validators:po},ln=mo.validators;let Bn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Qa,response:new Qa}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&mo.assertOptions(r,{silentJSONParsing:ln.transitional(ln.boolean),forcedJSONParsing:ln.transitional(ln.boolean),clarifyTimeoutError:ln.transitional(ln.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:mo.assertOptions(o,{encode:ln.function,serialize:ln.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),mo.assertOptions(n,{baseUrl:ln.spelling("baseURL"),withXsrfToken:ln.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=Ot.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let d,f=0,h;if(!c){const b=[vl.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,d=Promise.resolve(n);f<h;)d=d.then(b[f++],b[f++]);return d}h=a.length;let m=n;for(;f<h;){const b=a[f++],w=a[f++];try{m=b(m)}catch(g){w.call(this,g);break}}try{d=vl.call(this,m)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=zn(this.defaults,t);const n=al(t.baseURL,t.url,t.allowAbsoluteUrls);return Za(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){Bn.prototype[t]=function(n,r){return this.request(zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Bn.prototype[t]=n(),Bn.prototype[t+"Form"]=n(!0)});let Dm=class fp{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 lr(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 fp(function(o){t=o}),cancel:t}}};function Lm(e){return function(n){return e.apply(null,n)}}function $m(e){return P.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 yl(e){const t=new Bn(e),n=La(Bn.prototype.request,t);return P.extend(n,Bn.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return yl(zn(e,o))},n}const ct=yl(Ar);ct.Axios=Bn,ct.CanceledError=lr,ct.CancelToken=Dm,ct.isCancel=rl,ct.VERSION=wl,ct.toFormData=co,ct.AxiosError=ke,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=Lm,ct.isAxiosError=$m,ct.mergeConfig=zn,ct.AxiosHeaders=Ot,ct.formToJSON=e=>tl(P.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=xl.getAdapter,ct.HttpStatusCode=Ws,ct.default=ct;const{Axios:iC,AxiosError:aC,CanceledError:lC,isCancel:cC,CancelToken:uC,VERSION:dC,all:fC,Cancel:hC,isAxiosError:pC,spread:mC,toFormData:gC,AxiosHeaders:xC,HttpStatusCode:vC,formToJSON:wC,getAdapter:bC,mergeConfig:yC}=ct,Sl=typeof window<"u"?window.__API_BASE_URL__:void 0,Cl=Sl?Sl.replace(/\/+$/,""):void 0;let go=null;const Vs=new Set;function kl(){return go}function Ks(e){go=e,Vs.forEach(t=>t(e))}function Tl(e){return Vs.add(e),()=>Vs.delete(e)}const Wt=ct.create({...Cl?{baseURL:Cl}:{},timeout:3e4,withCredentials:!0});Wt.interceptors.request.use(e=>(go&&(e.headers.Authorization=`Bearer ${go}`),e)),Wt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Lt(e,t){return Wt.defaults.baseURL?(await Wt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qs(e,t,n){return Wt.defaults.baseURL?(await Wt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function El(e,t,n){return Wt.defaults.baseURL?(await Wt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Il(e,t){return Wt.defaults.baseURL?(await Wt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Nl{get baseUrl(){const t=Wt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Wt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Ks(t)}onTokenChange(t){return Tl(t)}async listThreads(){const t=await Lt("/chat/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qs("/chat/threads",t?{title:t}:void 0);return $t(r)}async updateThread(t,n){const r=await El(`/chat/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Il(`/chat/threads/${t}`);return $t(n)}async threadInfo(t){const n=await Lt(`/chat/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Lt("/chat/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Lt(`/chat/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Lt(`/chat/agents/${t}/schema`);return $t(n)}async getMessages(t){const n=await Lt(`/chat/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 $t(n)}async getState(t){const n=await Lt(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Lt(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async listCheckpoints(t){const n=await Lt(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return $t(n)}async resume(t){const n=await qs("/chat/runs/resume",{thread_id:t.threadId,value:t.value});return $t(n)}}const Tn=new Nl;function Al(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/runs/stream",[r,o]=S.useState(e.token??null),s=S.useRef(e.headers??{}),[i,a]=S.useState(!1),[c,u]=S.useState(null),[d,f]=S.useState(""),[h,m]=S.useState(null),[b,w]=S.useState(0),[g,x]=S.useState(!1),v=S.useRef(null),y=S.useRef(!0),E=S.useRef(0),C=S.useCallback(_=>{o(_)},[]),k=S.useCallback(()=>{var _;(_=v.current)==null||_.abort(),v.current=null,a(!1),x(!1)},[]),I=S.useCallback(()=>{f(""),m(null),u(null)},[]),N=S.useCallback((_,O,R)=>{v.current&&(v.current.abort(),v.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const $=new AbortController;return v.current=$,(async()=>{var M,W,U,V,D,A,K,Y;const q=re=>{var te;try{const pe=JSON.parse(JSON.stringify(re));return(te=pe==null?void 0:pe.payload)!=null&&te.files_info&&Array.isArray(pe.payload.files_info)&&(pe.payload.files_info=pe.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),pe}catch{return re}};try{let re={};try{if(r)re={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const je=window.__AUTH_TOKEN__,Be=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let Ge=null;try{const tt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");tt&&(Ge=((U=JSON.parse(tt))==null?void 0:U.apiKey)||null)}catch{}const De=je||Be||Ge||null;De&&(re={Authorization:`Bearer ${De}`})}}catch{}console.debug("[use-chat] POST",t+n,q(_));const te=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...re,...s.current},body:JSON.stringify(_),signal:$.signal});if(!te.ok||!te.body){const Ee=await te.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",te.status,Ee==null?void 0:Ee.slice(0,500)),new Error(`stream ${te.status}${Ee?": "+Ee:""}`)}x(!0);const pe=te.body.getReader(),Se=new TextDecoder;let Te="",B=[],j=E.current,H=null;const ee=()=>{if(B.length){const Ee=B.join("");B=[],y.current&&f(je=>je+Ee)}H=null},ue=()=>{typeof window<"u"&&H==null&&(H=requestAnimationFrame(ee))};let ce=Date.now();const _e=setInterval(()=>{var Ee;if(Date.now()-ce>2e4){const je="Stream idle timeout";u(je),$.abort(),(Ee=R==null?void 0:R.onError)==null||Ee.call(R,je)}},5e3),Ne=1024*1024;try{const Ee=te.headers.get("X-Thread-Id")||te.headers.get("x-thread-id"),je=te.headers.get("X-Thread-Created")||te.headers.get("x-thread-created"),Be=Ee??null,Ge=String(je??"").toLowerCase()==="true";for((V=R==null?void 0:R.onOpen)==null||V.call(R,{threadId:Be,created:Ge});;){const{value:De,done:tt}=await pe.read();if(tt)break;Te+=Se.decode(De,{stream:!0}),Te.length>Ne&&(Te="",console.warn("Stream buffer reset: exceeded 1MB"));let mt;for(;(mt=Te.indexOf(`
30
+ <%s key={someKey} {...props} />`,Ma,nr,oC,nr),ye[nr+Ma]=!0}}return T===r?Pe(gt):je(gt),gt}}function wt(T,z,ne){return et(T,z,ne,!0)}function bn(T,z,ne){return et(T,z,ne,!1)}var yr=bn,Gt=wt;kr.Fragment=r,kr.jsx=yr,kr.jsxs=Gt}()),kr}process.env.NODE_ENV==="production"?Os.exports=xp():Os.exports=vp();var l=Os.exports;function Fa(e,t){return function(){return e.apply(t,arguments)}}const{toString:wp}=Object.prototype,{getPrototypeOf:Ms}=Object,{iterator:so,toStringTag:za}=Symbol,io=(e=>t=>{const n=wp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Xt=e=>(e=e.toLowerCase(),t=>io(t)===e),ao=e=>t=>typeof t===e,{isArray:rr}=Array,or=ao("undefined");function Tr(e){return e!==null&&!or(e)&&e.constructor!==null&&!or(e.constructor)&&jt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=Xt("ArrayBuffer");function bp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const yp=ao("string"),jt=ao("function"),Ha=ao("number"),Er=e=>e!==null&&typeof e=="object",Sp=e=>e===!0||e===!1,lo=e=>{if(io(e)!=="object")return!1;const t=Ms(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(so in e)},Cp=e=>{if(!Er(e)||Tr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},kp=Xt("Date"),Tp=Xt("File"),Ep=Xt("Blob"),Ip=Xt("FileList"),Np=e=>Er(e)&&jt(e.pipe),Ap=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||jt(e.append)&&((t=io(e))==="formdata"||t==="object"&&jt(e.toString)&&e.toString()==="[object FormData]"))},jp=Xt("URLSearchParams"),[_p,Rp,Pp,Op]=["ReadableStream","Request","Response","Headers"].map(Xt),Mp=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]),rr(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 Ua(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 Dn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!or(e)&&e!==Dn;function Ds(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;lo(n[i])&&lo(o)?n[i]=Ds(n[i],o):lo(o)?n[i]=Ds({},o):rr(o)?n[i]=o.slice():(!t||!or(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Ir(arguments[o],r);return n}const Dp=(e,t,n,{allOwnKeys:r}={})=>(Ir(t,(o,s)=>{n&&jt(o)?e[s]=Fa(o,n):e[s]=o},{allOwnKeys:r}),e),Lp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$p=(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)},Fp=(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&&Ms(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},zp=(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},Bp=e=>{if(!e)return null;if(rr(e))return e;let t=e.length;if(!Ha(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ms(Uint8Array)),Up=(e,t)=>{const r=(e&&e[so]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vp=Xt("HTMLFormElement"),qp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Kp=Xt("RegExp"),qa=(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)},Gp=e=>{qa(e,(t,n)=>{if(jt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(jt(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+"'")})}})},Yp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return rr(e)?r(e):r(String(e).split(t)),n},Xp=()=>{},Jp=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zp(e){return!!(e&&jt(e.append)&&e[za]==="FormData"&&e[so])}const Qp=e=>{const t=new Array(10),n=(r,o)=>{if(Er(r)){if(t.indexOf(r)>=0)return;if(Tr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=rr(r)?[]:{};return Ir(r,(i,a)=>{const c=n(i,o+1);!or(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},em=Xt("AsyncFunction"),tm=e=>e&&(Er(e)||jt(e))&&jt(e.then)&&jt(e.catch),Ka=((e,t)=>e?setImmediate:t?((n,r)=>(Dn.addEventListener("message",({source:o,data:s})=>{o===Dn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Dn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",jt(Dn.postMessage)),nm=typeof queueMicrotask<"u"?queueMicrotask.bind(Dn):typeof process<"u"&&process.nextTick||Ka,P={isArray:rr,isArrayBuffer:Ba,isBuffer:Tr,isFormData:Ap,isArrayBufferView:bp,isString:yp,isNumber:Ha,isBoolean:Sp,isObject:Er,isPlainObject:lo,isEmptyObject:Cp,isReadableStream:_p,isRequest:Rp,isResponse:Pp,isHeaders:Op,isUndefined:or,isDate:kp,isFile:Tp,isBlob:Ep,isRegExp:Kp,isFunction:jt,isStream:Np,isURLSearchParams:jp,isTypedArray:Hp,isFileList:Ip,forEach:Ir,merge:Ds,extend:Dp,trim:Mp,stripBOM:Lp,inherits:$p,toFlatObject:Fp,kindOf:io,kindOfTest:Xt,endsWith:zp,toArray:Bp,forEachEntry:Up,matchAll:Wp,isHTMLForm:Vp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:qa,freezeMethods:Gp,toObjectSet:Yp,toCamelCase:qp,noop:Xp,toFiniteNumber:Jp,findKey:Ua,global:Dn,isContextDefined:Wa,isSpecCompliantForm:Zp,toJSONObject:Qp,isAsyncFn:em,isThenable:tm,setImmediate:Ka,asap:nm,isIterable:e=>e!=null&&jt(e[so])};function Ee(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}P.inherits(Ee,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:P.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ee.prototype,Ya={};["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=>{Ya[e]={value:e}}),Object.defineProperties(Ee,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);P.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ee.call(i,a,c,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 rm=null;function Ls(e){return P.isPlainObject(e)||P.isArray(e)}function Xa(e){return P.endsWith(e,"[]")?e.slice(0,-2):e}function Ja(e,t,n){return e?e.concat(t).map(function(o,s){return o=Xa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function om(e){return P.isArray(e)&&!e.some(Ls)}const sm=P.toFlatObject(P,{},null,function(t){return/^is[A-Z]/.test(t)});function co(e,t,n){if(!P.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=P.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,g){return!P.isUndefined(g[w])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&P.isSpecCompliantForm(t);if(!P.isFunction(o))throw new TypeError("visitor must be a function");function u(b){if(b===null)return"";if(P.isDate(b))return b.toISOString();if(P.isBoolean(b))return b.toString();if(!c&&P.isBlob(b))throw new Ee("Blob is not supported. Use a Buffer instead.");return P.isArrayBuffer(b)||P.isTypedArray(b)?c&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,w,g){let x=b;if(b&&!g&&typeof b=="object"){if(P.endsWith(w,"{}"))w=r?w:w.slice(0,-2),b=JSON.stringify(b);else if(P.isArray(b)&&om(b)||(P.isFileList(b)||P.endsWith(w,"[]"))&&(x=P.toArray(b)))return w=Xa(w),x.forEach(function(S,E){!(P.isUndefined(S)||S===null)&&t.append(i===!0?Ja([w],E,s):i===null?w:w+"[]",u(S))}),!1}return Ls(b)?!0:(t.append(Ja(g,w,s),u(b)),!1)}const f=[],h=Object.assign(sm,{defaultVisitor:d,convertValue:u,isVisitable:Ls});function m(b,w){if(!P.isUndefined(b)){if(f.indexOf(b)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(b),P.forEach(b,function(x,v){(!(P.isUndefined(x)||x===null)&&o.call(t,x,P.isString(v)?v.trim():v,w,h))===!0&&m(x,w?w.concat(v):[v])}),f.pop()}}if(!P.isObject(e))throw new TypeError("data must be an object");return m(e),t}function Za(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function $s(e,t){this._pairs=[],e&&co(e,this,t)}const Qa=$s.prototype;Qa.append=function(t,n){this._pairs.push([t,n])},Qa.toString=function(t){const n=t?function(r){return t.call(this,r,Za)}:Za;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function im(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function el(e,t,n){if(!t)return e;const r=n&&n.encode||im;P.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=P.isURLSearchParams(t)?t.toString():new $s(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class tl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){P.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},am={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:$s,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Fs=typeof window<"u"&&typeof document<"u",zs=typeof navigator=="object"&&navigator||void 0,lm=Fs&&(!zs||["ReactNative","NativeScript","NS"].indexOf(zs.product)<0),cm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",um=Fs&&window.location.href||"http://localhost",Ct={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Fs,hasStandardBrowserEnv:lm,hasStandardBrowserWebWorkerEnv:cm,navigator:zs,origin:um},Symbol.toStringTag,{value:"Module"})),...am};function dm(e,t){return co(e,new Ct.classes.URLSearchParams,{visitor:function(n,r,o,s){return Ct.isNode&&P.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fm(e){return P.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hm(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 rl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&P.isArray(o)?o.length:i,c?(P.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!P.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&P.isArray(o[i])&&(o[i]=hm(o[i])),!a)}if(P.isFormData(e)&&P.isFunction(e.entries)){const n={};return P.forEachEntry(e,(r,o)=>{t(fm(r),o,n,0)}),n}return null}function pm(e,t,n){if(P.isString(e))try{return(t||JSON.parse)(e),P.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Nr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=P.isObject(t);if(s&&P.isHTMLForm(t)&&(t=new FormData(t)),P.isFormData(t))return o?JSON.stringify(rl(t)):t;if(P.isArrayBuffer(t)||P.isBuffer(t)||P.isStream(t)||P.isFile(t)||P.isBlob(t)||P.isReadableStream(t))return t;if(P.isArrayBufferView(t))return t.buffer;if(P.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return dm(t,this.formSerializer).toString();if((a=P.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return co(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pm(t)):t}],transformResponse:[function(t){const n=this.transitional||Nr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(P.isResponse(t)||P.isReadableStream(t))return t;if(t&&P.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ee.from(a,Ee.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:Ct.classes.FormData,Blob:Ct.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};P.forEach(["delete","get","head","post","put","patch"],e=>{Nr.headers[e]={}});const mm=P.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gm=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&mm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ol=Symbol("internals");function Ar(e){return e&&String(e).trim().toLowerCase()}function uo(e){return e===!1||e==null?e:P.isArray(e)?e.map(uo):String(e)}function xm(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const vm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Bs(e,t,n,r,o){if(P.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!P.isString(t)){if(P.isString(r))return t.indexOf(r)!==-1;if(P.isRegExp(r))return r.test(t)}}function wm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function bm(e,t){const n=P.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let _t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=Ar(c);if(!d)throw new Error("header name must be a non-empty string");const f=P.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=uo(a))}const i=(a,c)=>P.forEach(a,(u,d)=>s(u,d,c));if(P.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(P.isString(t)&&(t=t.trim())&&!vm(t))i(gm(t),n);else if(P.isObject(t)&&P.isIterable(t)){let a={},c,u;for(const d of t){if(!P.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?P.isArray(c)?[...c,d[1]]:[c,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=P.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xm(o);if(P.isFunction(n))return n.call(this,o,r);if(P.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ar(t),t){const r=P.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=P.findKey(r,i);a&&(!n||Bs(r,r[a],a,n))&&(delete r[a],o=!0)}}return P.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Bs(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return P.forEach(this,(o,s)=>{const i=P.findKey(r,s);if(i){n[i]=uo(o),delete n[s];return}const a=t?wm(s):String(s).trim();a!==s&&delete n[s],n[a]=uo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return P.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&P.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ol]=this[ol]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ar(i);r[a]||(bm(o,i),r[a]=!0)}return P.isArray(t)?t.forEach(s):s(t),this}};_t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),P.reduceDescriptors(_t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),P.freezeMethods(_t);function Hs(e,t){const n=this||Nr,r=t||n,o=_t.from(r.headers);let s=r.data;return P.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sl(e){return!!(e&&e.__CANCEL__)}function sr(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}P.inherits(sr,Ee,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ee("Request failed with status code "+n.status,[Ee.ERR_BAD_REQUEST,Ee.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function ym(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sm(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(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,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 m=d&&u-d;return m?Math.round(h*1e3/m):void 0}}function Cm(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 fo=(e,t,n=3)=>{let r=0;const o=Sm(50,250);return Cm(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,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)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>P.asap(()=>e(...t)),km=Ct.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Ct.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Ct.origin),Ct.navigator&&/(msie|trident)/i.test(Ct.navigator.userAgent)):()=>!0,Tm=Ct.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];P.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),P.isString(r)&&i.push("path="+r),P.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Em(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Im(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!Em(t);return e&&(r||n==!1)?Im(e,t):t}const ul=e=>e instanceof _t?{...e}:e;function Ln(e,t){t=t||{};const n={};function r(u,d,f,h){return P.isPlainObject(u)&&P.isPlainObject(d)?P.merge.call({caseless:h},u,d):P.isPlainObject(d)?P.merge({},d):P.isArray(d)?d.slice():d}function o(u,d,f,h){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!P.isUndefined(d))return r(void 0,d)}function i(u,d){if(P.isUndefined(d)){if(!P.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const c={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(ul(u),ul(d),f,!0)};return P.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);P.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=Ln({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=_t.from(i),t.url=el(cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),P.isFormData(n)){if(Ct.hasStandardBrowserEnv||Ct.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(P.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(Ct.hasStandardBrowserEnv&&(r&&P.isFunction(r)&&(r=r(t)),r||r!==!1&&km(t.url))){const c=o&&s&&Tm.read(s);c&&i.set(o,c)}return t},Nm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=_t.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,m,b;function w(){m&&m(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const S=_t.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};il(function(I){n(I),w()},function(I){r(I),w()},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 Ee("Request aborted",Ee.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",k=new Ee(C,Ee.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||nl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ee(E,C.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&P.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),P.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,b]=fo(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,m]=fo(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new sr(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 v=ym(o.url);if(v&&Ct.protocols.indexOf(v)===-1){r(new Ee("Unsupported protocol "+v+":",Ee.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Am=(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 Ee?d:new sr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ee(`timeout ${t} of ms exceeded`,Ee.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:c}=r;return c.unsubscribe=()=>P.asap(a),c}},jm=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},_m=async function*(e,t){for await(const n of Rm(e))yield*jm(n,t)},Rm=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()}},fl=(e,t,n,r)=>{const o=_m(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:ho}=P,Pm=(({Request:e,Response:t})=>({Request:e,Response:t}))(P.global),{ReadableStream:pl,TextEncoder:ml}=P.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Om=e=>{e=P.merge.call({skipUndefined:!0},Pm,e);const{fetch:t,Request:n,Response:r}=e,o=t?ho(t):typeof fetch=="function",s=ho(n),i=ho(r);if(!o)return!1;const a=o&&ho(pl),c=o&&(typeof ml=="function"?(b=>w=>b.encode(w))(new ml):async b=>new Uint8Array(await new n(b).arrayBuffer())),u=s&&a&&gl(()=>{let b=!1;const w=new n(Ct.origin,{body:new pl,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!w}),d=i&&a&&gl(()=>P.isReadableStream(new r("").body)),f={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!f[b]&&(f[b]=(w,g)=>{let x=w&&w[b];if(x)return x.call(w);throw new Ee(`Response type '${b}' is not supported`,Ee.ERR_NOT_SUPPORT,g)})});const h=async b=>{if(b==null)return 0;if(P.isBlob(b))return b.size;if(P.isSpecCompliantForm(b))return(await new n(Ct.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(P.isArrayBufferView(b)||P.isArrayBuffer(b))return b.byteLength;if(P.isURLSearchParams(b)&&(b=b+""),P.isString(b))return(await c(b)).byteLength},m=async(b,w)=>{const g=P.toFiniteNumber(b.getContentLength());return g??h(w)};return async b=>{let{url:w,method:g,data:x,signal:v,cancelToken:S,timeout:E,onDownloadProgress:C,onUploadProgress:k,responseType:I,headers:N,withCredentials:_="same-origin",fetchOptions:O}=dl(b),R=t||fetch;I=I?(I+"").toLowerCase():"text";let $=Am([v,S&&S.toAbortSignal()],E),K=null;const M=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let W;try{if(k&&u&&g!=="get"&&g!=="head"&&(W=await m(N,x))!==0){let J=new n(w,{method:"POST",body:x,duplex:"half"}),se;if(P.isFormData(x)&&(se=J.headers.get("content-type"))&&N.setContentType(se),J.body){const[te,pe]=al(W,fo(ll(k)));x=fl(J.body,hl,te,pe)}}P.isString(_)||(_=_?"include":"omit");const U=s&&"credentials"in n.prototype,V={...O,signal:$,method:g.toUpperCase(),headers:N.normalize().toJSON(),body:x,duplex:"half",credentials:U?_:void 0};K=s&&new n(w,V);let L=await(s?R(K,O):R(w,V));const A=d&&(I==="stream"||I==="response");if(d&&(C||A&&M)){const J={};["status","statusText","headers"].forEach(Ie=>{J[Ie]=L[Ie]});const se=P.toFiniteNumber(L.headers.get("content-length")),[te,pe]=C&&al(se,fo(ll(C),!0))||[];L=new r(fl(L.body,hl,te,()=>{pe&&pe(),M&&M()}),J)}I=I||"text";let q=await f[P.findKey(f,I)||"text"](L,b);return!A&&M&&M(),await new Promise((J,se)=>{il(J,se,{data:q,headers:_t.from(L.headers),status:L.status,statusText:L.statusText,config:b,request:K})})}catch(U){throw M&&M(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,b,K),{cause:U.cause||U}):Ee.from(U,U&&U.code,b,K)}}},Mm=new Map,xl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=Mm;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:Om(t)),d=u;return u};xl();const Us={http:rm,xhr:Nm,fetch:{get:xl}};P.forEach(Us,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,Dm=e=>P.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=P.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Dm(r)&&(o=Us[(a=String(r)).toLowerCase()],o===void 0))throw new Ee(`Unknown adapter '${a}'`);if(o&&(P.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
+ `+i.map(vl).join(`
34
+ `):" "+vl(i[0]):"as no adapter specified";throw new Ee("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Us};function Ws(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new sr(null,e)}function bl(e){return Ws(e),e.headers=_t.from(e.headers),e.data=Hs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),wl.getAdapter(e.adapter||Nr.adapter,e)(e).then(function(r){return Ws(e),r.data=Hs.call(e,e.transformResponse,r),r.headers=_t.from(r.headers),r},function(r){return sl(r)||(Ws(e),r&&r.response&&(r.response.data=Hs.call(e,e.transformResponse,r.response),r.response.headers=_t.from(r.response.headers))),Promise.reject(r)})}const yl="1.12.2",po={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{po[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Sl={};po.transitional=function(t,n,r){function o(s,i){return"[Axios v"+yl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ee(o(i," has been removed"+(n?" in "+n:"")),Ee.ERR_DEPRECATED);return n&&!Sl[i]&&(Sl[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}},po.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lm(e,t,n){if(typeof e!="object")throw new Ee("options must be an object",Ee.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],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ee("option "+s+" must be "+c,Ee.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ee("Unknown option "+s,Ee.ERR_BAD_OPTION)}}const mo={assertOptions:Lm,validators:po},rn=mo.validators;let $n=class{constructor(t){this.defaults=t||{},this.interceptors={request:new tl,response:new tl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ln(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&mo.assertOptions(r,{silentJSONParsing:rn.transitional(rn.boolean),forcedJSONParsing:rn.transitional(rn.boolean),clarifyTimeoutError:rn.transitional(rn.boolean)},!1),o!=null&&(P.isFunction(o)?n.paramsSerializer={serialize:o}:mo.assertOptions(o,{encode:rn.function,serialize:rn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),mo.assertOptions(n,{baseUrl:rn.spelling("baseURL"),withXsrfToken:rn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&P.merge(s.common,s[n.method]);s&&P.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),n.headers=_t.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let d,f=0,h;if(!c){const b=[bl.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,d=Promise.resolve(n);f<h;)d=d.then(b[f++],b[f++]);return d}h=a.length;let m=n;for(;f<h;){const b=a[f++],w=a[f++];try{m=b(m)}catch(g){w.call(this,g);break}}try{d=bl.call(this,m)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Ln(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};P.forEach(["delete","get","head","options"],function(t){$n.prototype[t]=function(n,r){return this.request(Ln(r||{},{method:t,url:n,data:(r||{}).data}))}}),P.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Ln(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}$n.prototype[t]=n(),$n.prototype[t+"Form"]=n(!0)});let $m=class pp{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 sr(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 pp(function(o){t=o}),cancel:t}}};function Fm(e){return function(n){return e.apply(null,n)}}function zm(e){return P.isObject(e)&&e.isAxiosError===!0}const Vs={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(Vs).forEach(([e,t])=>{Vs[t]=e});function Cl(e){const t=new $n(e),n=Fa($n.prototype.request,t);return P.extend(n,$n.prototype,t,{allOwnKeys:!0}),P.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(Ln(e,o))},n}const ct=Cl(Nr);ct.Axios=$n,ct.CanceledError=sr,ct.CancelToken=$m,ct.isCancel=sl,ct.VERSION=yl,ct.toFormData=co,ct.AxiosError=Ee,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=Fm,ct.isAxiosError=zm,ct.mergeConfig=Ln,ct.AxiosHeaders=_t,ct.formToJSON=e=>rl(P.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=wl.getAdapter,ct.HttpStatusCode=Vs,ct.default=ct;const{Axios:pC,AxiosError:mC,CanceledError:gC,isCancel:xC,CancelToken:vC,VERSION:wC,all:bC,Cancel:yC,isAxiosError:SC,spread:CC,toFormData:kC,AxiosHeaders:TC,HttpStatusCode:EC,formToJSON:IC,getAdapter:NC,mergeConfig:AC}=ct,kl=typeof window<"u"?window.__API_BASE_URL__:void 0,Tl=kl?kl.replace(/\/+$/,""):void 0;let go=null;const qs=new Set;function El(){return go}function Ks(e){go=e,qs.forEach(t=>t(e))}function Il(e){return qs.add(e),()=>qs.delete(e)}const Bt=ct.create({...Tl?{baseURL:Tl}:{},timeout:3e4,withCredentials:!0});Bt.interceptors.request.use(e=>(go&&(e.headers.Authorization=`Bearer ${go}`),e)),Bt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function Ot(e,t){return Bt.defaults.baseURL?(await Bt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Gs(e,t,n){return Bt.defaults.baseURL?(await Bt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return Bt.defaults.baseURL?(await Bt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return Bt.defaults.baseURL?(await Bt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class jl{get baseUrl(){const t=Bt.defaults.baseURL||"";return String(t).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(t){t.baseUrl&&(Bt.defaults.baseURL=String(t.baseUrl).replace(/\/+$/g,"")),t.authToken!==void 0&&Ks(t.authToken)}getAuthToken(){return El()}setAuthToken(t){Ks(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await Ot("/chat/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Gs("/chat/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Nl(`/chat/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await Al(`/chat/threads/${t}`);return Mt(n)}async threadInfo(t){const n=await Ot(`/chat/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await Ot("/chat/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Ot(`/chat/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await Ot(`/chat/agents/${t}/schema`);return Mt(n)}async getMessages(t){const n=await Ot(`/chat/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 Mt(n)}async getState(t){const n=await Ot(`/chat/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await Ot(`/chat/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async listCheckpoints(t){const n=await Ot(`/chat/threads/${t}/checkpoints`,{params:{thread_id:t}});return Mt(n)}async resume(t){const n=await Gs("/chat/runs/resume",{thread_id:t.threadId,value:t.value});return Mt(n)}}const yn=new jl;function _l(e={}){const t=e.baseUrl??"/api/chat",n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),[i,a]=y.useState(!1),[c,u]=y.useState(null),[d,f]=y.useState(""),[h,m]=y.useState(null),[b,w]=y.useState(0),[g,x]=y.useState(!1),v=y.useRef(null),S=y.useRef(!0),E=y.useRef(0),C=y.useCallback(_=>{o(_)},[]),k=y.useCallback(()=>{var _;(_=v.current)==null||_.abort(),v.current=null,a(!1),x(!1)},[]),I=y.useCallback(()=>{f(""),m(null),u(null)},[]),N=y.useCallback((_,O,R)=>{v.current&&(v.current.abort(),v.current=null),a(!0),u(null),e.autoAppendAssistant!==!1&&f("");const $=new AbortController;return v.current=$,(async()=>{var M,W,U,V,L,A,q,J;const K=se=>{var te;try{const pe=JSON.parse(JSON.stringify(se));return(te=pe==null?void 0:pe.payload)!=null&&te.files_info&&Array.isArray(pe.payload.files_info)&&(pe.payload.files_info=pe.payload.files_info.map(Ie=>({...Ie,data:Ie!=null&&Ie.data?`<base64 ${String(Ie.data).length} chars>`:Ie==null?void 0:Ie.data}))),pe}catch{return se}};try{let se={};try{if(r)se={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const be=window.__AUTH_TOKEN__,Ue=((M=window.localStorage)==null?void 0:M.getItem("authToken"))||null;let Ye=null;try{const st=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");st&&(Ye=((U=JSON.parse(st))==null?void 0:U.apiKey)||null)}catch{}const $e=be||Ue||Ye||null;$e&&(se={Authorization:`Bearer ${$e}`})}}catch{}console.debug("[use-chat] POST",t+n,K(_));const te=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...se,...s.current},body:JSON.stringify(_),signal:$.signal});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:""}`)}x(!0);const pe=te.body.getReader(),Ie=new TextDecoder;let Ne="",B=[],j=E.current,H=null;const ee=()=>{if(B.length){const ke=B.join("");B=[],S.current&&f(be=>be+ke)}H=null},ue=()=>{typeof window<"u"&&H==null&&(H=requestAnimationFrame(ee))};let ce=Date.now();const Oe=setInterval(()=>{var ke;if(Date.now()-ce>2e4){const be="Stream idle timeout";u(be),$.abort(),(ke=R==null?void 0:R.onError)==null||ke.call(R,be)}},5e3),Ge=1024*1024;try{const ke=te.headers.get("X-Thread-Id")||te.headers.get("x-thread-id"),be=te.headers.get("X-Thread-Created")||te.headers.get("x-thread-created"),Ue=ke??null,Ye=String(be??"").toLowerCase()==="true";for((V=R==null?void 0:R.onOpen)==null||V.call(R,{threadId:Ue,created:Ye});;){const{value:$e,done:st}=await pe.read();if(st)break;Ne+=Ie.decode($e,{stream:!0}),Ne.length>Ge&&(Ne="",console.warn("Stream buffer reset: exceeded 1MB"));let pt;for(;(pt=Ne.indexOf(`
36
36
 
37
- `))>=0;){const at=Te.slice(0,mt);Te=Te.slice(mt+2);const lt=zm(at);if(!lt)continue;let gt;try{gt=JSON.parse(lt)}catch{console.debug("[use-chat] malformed SSE:",lt.slice(0,200));continue}const Ue=Fm(gt)?gt.data:gt;ce=Date.now(),O==null||O(Ue);const Q=Ue.seq;if(Q!==void 0){if(Q<=j)continue;j>0&&Q>j+1&&((D=R==null?void 0:R.onGap)==null||D.call(R,{from:j,to:Q})),j=Q,E.current=Q,w(Q)}if(Ue.type==="token"&&e.autoAppendAssistant!==!1)B.push(Ue.content),ue();else if(Ue.type==="message_delta"){const oe=Ue.delta.filter(fe=>fe.type==="text").map(fe=>fe.text).join("");oe&&e.autoAppendAssistant!==!1&&(B.push(oe),ue())}else H!==null&&cancelAnimationFrame(H),ee(),Ue.type==="checkpoint"?m(Ue.checkpointId):Ue.type==="error"&&u(Ue.message)}}ee()}catch(Ee){if(Ee.name!=="AbortError"){const je=Ee.message||String(Ee);u(je),(A=R==null?void 0:R.onError)==null||A.call(R,je)}}finally{try{await pe.cancel()}catch{}finally{(K=pe.releaseLock)==null||K.call(pe)}H!==null&&typeof window<"u"&&window.cancelAnimationFrame(H),clearInterval(_e),a(!1),x(!1),v.current=null}}catch(re){if(re.name!=="AbortError"){const te=re.message||String(re);u(te),(Y=R==null?void 0:R.onError)==null||Y.call(R,te)}}finally{a(!1),x(!1),v.current=null}})(),{close:()=>$.abort()}},[t,n,r,e.autoAppendAssistant]);return S.useEffect(()=>()=>{var _;y.current=!1,(_=v.current)==null||_.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:h,lastSeq:b,connected:g,stream:N,stop:k,clear:I,setToken:C}}function Fm(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function zm(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
- `)}const Bm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Hm(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:Gs(((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 o=Gs(t.payload.messages),s={...e,messages:o,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(s.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(s.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:o.length,previousCount:e.messages.length,checkpointId:s.lastCheckpointId}),s}case"prepend":{const o=Gs(t.payload.messages);if(!o.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const s=new Set(e.messages.map(a=>a.id)),i=o.filter(a=>!s.has(a.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:i.length,duplicates:o.length-i.length,finalTotal:i.length+e.messages.length}),i.length?{...e,messages:[...i,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const o=t.payload.message;return e.messages.some(s=>s.id===o.id)?e:{...e,messages:[...e.messages,o]}}case"event":return _l(e,t.payload.ev);case"batch":{const{events:o}=t.payload;return o.length?o.reduce((s,i)=>_l(s,i),e):e}case"interrupt_response":{const{interruptId:o}=t.payload,s=e.messages.map(i=>({...i,content:i.content.filter(a=>a.type!=="interrupt")}));return{...e,messages:s,pendingInterrupt:null}}default:return e}}function jl(e=[]){const[t,n]=S.useReducer(Hm,{...Bm,messages:e}),r=S.useRef([]),o=S.useRef(null),s=S.useRef(null),i=S.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=S.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]),c=S.useCallback(d=>{r.current.push(d),a()},[a]);S.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=S.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:c}),[c]);return{state:t,dispatch:n,...u}}function _l(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=qm(t.model);if(e.messages.some(a=>a.id===r))return{...e,assemblingId:r};const i={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,i]}}if(t.type==="message_delta"){const r=e.assemblingId??Ys(e.messages);return r?{...e,messages:Xs(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Ys(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args};if(e.messages.find(a=>a.id===r))return{...e,toolIndex:{...e.toolIndex,[t.id]:r}};const i={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,i],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?Xs(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Km(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}if(t.type==="interrupt"){const r=e.assemblingId??Ys(e.messages),o={type:"interrupt",value:t.value};if(r)return{...e,assemblingId:null,messages:Xs(e.messages,r,[o]),pendingInterrupt:{id:t.id,value:t.value}};const s={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Gs(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 Um(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ys(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Wm(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 Xs(e,t,n){return Wm(e,t,r=>({...r,content:Vm(r.content,n)}))}function Vm(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Km(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 Um(e,r,s)}return e}function qm(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gm(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 Ym(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Xm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Ym(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const Rl=S.createContext(null);function xo({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,disableAutoRestore:i=!1,enableFileAgentRouting:a=!1,fileAgentId:c="invoice_reader"}){const u=Tn;S.useEffect(()=>{t&&u.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[u,t]);const{isStreaming:d,error:f,stream:h,stop:m,setToken:b}=Al({baseUrl:u.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[w,g]=S.useState(()=>typeof u.getAuthToken=="function"?u.getAuthToken():null);S.useEffect(()=>{b(typeof u.getAuthToken=="function"?u.getAuthToken():null);const L=u.onTokenChange(Z=>{g(Z),b(Z)});return()=>{L()}},[u,b]);const x=S.useCallback(L=>{u.setAuthToken(L)},[u]),{state:v,dispatch:y,seed:E,prepend:C,pushUser:k,onEvent:I,reset:N}=jl(),_=20,[O,R]=S.useState(!1),[$,q]=S.useState(!1),[M,W]=S.useState(null),[U,V]=S.useState(void 0),[D,A]=S.useState(void 0),K=S.useRef(!1),Y=S.useRef([]),re=S.useRef(null),te=S.useCallback(L=>{L.cursor!==void 0&&W(L.cursor),L.hasMore!==void 0&&R(L.hasMore),L.checkpointId!==void 0&&V(L.checkpointId),L.checkpointNs!==void 0&&A(L.checkpointNs)},[]),pe=S.useCallback((L,Z)=>new Promise((Re,qe)=>{const it=async()=>{if(K.current){console.warn(`[ChatProvider] Operation "${Z}" queued - another operation in progress`),Y.current.push(it);return}K.current=!0;try{console.log(`[ChatProvider] Executing operation: ${Z}`),await L(),Re()}catch(ft){console.error(`[ChatProvider] Operation "${Z}" failed:`,ft),qe(ft)}finally{K.current=!1;const ft=Y.current.shift();ft&&ft().catch(()=>{})}};K.current?(Y.current.push(it),console.log(`[ChatProvider] Queued operation: ${Z}`)):it().catch(ft=>{qe(ft)})}),[]),Se=S.useCallback((L,Z)=>{const Re=Array.isArray(L==null?void 0:L.messages)?L.messages:[];Z==="replace"?(console.log("[ChatProvider] Replacing messages, count:",Re.length),E(Re,{checkpointId:(L==null?void 0:L.checkpointId)??null,checkpointNs:(L==null?void 0:L.checkpointNs)??null})):Z==="prepend"&&Re.length?(console.log("[ChatProvider] Calling prepend with",Re.length,"messages"),C(Re)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),W((L==null?void 0:L.nextCursor)??null),R(!!(L!=null&&L.hasMore)),V(qe=>(L==null?void 0:L.checkpointId)??qe??void 0),A(qe=>(L==null?void 0:L.checkpointNs)??qe??void 0)},[E,C]),[Te,B]=S.useState([]),[j,H]=S.useState(null),[ee,ue]=S.useState(!1),[ce,_e]=S.useState(!1),Ne=S.useCallback(async()=>{ue(!0);try{const L=await u.listThreads();B(L)}finally{ue(!1)}},[u]),[Ee,je]=S.useState(!1),Be=S.useCallback(async L=>{const Z=(L==null?void 0:L.maxAttempts)??5,Re=(L==null?void 0:L.baseDelayMs)??500,qe=(L==null?void 0:L.timeoutMs)??2e3;if(!u.baseUrl)return!1;const it=u.baseUrl.replace(/\/+$/,""),ft=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],Jt=async Ct=>{try{const Pe=new AbortController,xt=setTimeout(()=>Pe.abort(),qe),J=await fetch(Ct,{method:"GET",signal:Pe.signal});return clearTimeout(xt),J.ok}catch{return!1}},bn=async Ct=>{try{const Pe=new AbortController,xt=setTimeout(()=>Pe.abort(),qe),J=await fetch(Ct,{method:"HEAD",signal:Pe.signal});return clearTimeout(xt),J.ok}catch{return!1}};for(let Ct=0;Ct<Z;Ct++){console.debug(`[ChatProvider] health-check attempt ${Ct+1}/${Z}`);for(const xt of ft){let J=xt;it.endsWith("/api")&&xt.startsWith("/api")&&(J=xt.replace(/^\/api/,"")||"/");const he=J==="/"?it+"/":it+J;if(console.debug(`[ChatProvider] checking ${he}`),await Jt(he)||xt==="/"&&await bn(it+"/"))return je(!0),!0}const Pe=Re*Math.pow(2,Ct);await new Promise(xt=>setTimeout(xt,Pe))}return je(!1),!1},[u.baseUrl]);S.useEffect(()=>{let L=!0;if(!u.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const Z=await Be();if(!L)return;Z?Ne().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{L=!1}},[Ne,u.baseUrl,Be]),S.useEffect(()=>{r==null||r(j)},[j,r]);const Ge=S.useRef(null);S.useEffect(()=>{if(o&&s){if(!u.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!Ee){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}Ge.current!==o&&(Ge.current=o,lt(o).catch(()=>{}))}},[o,s,u.baseUrl,Ee]);const De=S.useRef(null),tt=S.useRef(null),mt=S.useRef(null),at=S.useRef({count:0,checkpointId:null,checkpointNs:null});S.useEffect(()=>{mt.current=j},[j]),S.useEffect(()=>{at.current={count:v.messages.length,checkpointId:v.lastCheckpointId,checkpointNs:v.lastCheckpointNs}},[v.messages.length,v.lastCheckpointId,v.lastCheckpointNs]);const lt=S.useCallback(async(L,Z,Re,qe=!1)=>{await pe(async()=>{if(re.current===L){console.log(`[ChatProvider] Skipping auto-load for thread ${L} - suppressed after clear`),re.current=null;return}if(!u.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(De.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${De.current}) is loading`);return}const it=tt.current!==null&&tt.current!==L,ft=tt.current===L||mt.current===L,Jt=Z!==void 0||Re!==void 0,bn=at.current.count>0,Ct=at.current.checkpointId!==null||at.current.checkpointNs!==null;if(!qe&&!it&&ft&&!Jt&&!Ct&&bn){console.debug("[ChatProvider] Fast-return loadThread - reusing existing messages for thread",L),H(L),tt.current=L;return}it&&(console.log(`[ChatProvider] Thread switch detected: ${tt.current} -> ${L}`),N([])),De.current=L,tt.current=L;try{_e(!0),te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),H(L);const Pe=await u.getMessages({threadId:L,checkpointId:Z,checkpointNs:Re,limit:_}),xt=Array.isArray(Pe==null?void 0:Pe.messages)?Pe.messages:[];console.log("[ChatProvider] Loading thread with",xt.length,"messages"),E(xt,{checkpointId:(Pe==null?void 0:Pe.checkpointId)??null,checkpointNs:(Pe==null?void 0:Pe.checkpointNs)??null}),W((Pe==null?void 0:Pe.nextCursor)??null),R(!!(Pe!=null&&Pe.hasMore)),V(J=>(Pe==null?void 0:Pe.checkpointId)??J??void 0),A(J=>(Pe==null?void 0:Pe.checkpointNs)??J??void 0)}finally{De.current=null,_e(!1)}},`loadThread-${L}`)},[u,pe,te,E]),gt=S.useCallback(async L=>{const Z=await u.listCheckpoints(L);return Gm(Z,L)},[u]),Ue=S.useCallback(async(L,Z)=>{await pe(async()=>{if(!j)throw new Error("No active thread");te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),_e(!0);try{const Re=await u.getMessages({threadId:j,checkpointId:L,checkpointNs:Z??void 0,limit:_});Se(Re,"replace")}finally{_e(!1)}},`navigateToCheckpoint-${L}`)},[u,j,Se,pe,te,_]),Q=S.useCallback(async()=>{if(!j)throw new Error("No active thread");await lt(j,void 0,void 0,!0)},[j,lt]),oe=S.useRef(!1);S.useEffect(()=>{const L=oe.current;oe.current=d,L&&!d&&j&&pe(async()=>{try{await Ne()}catch(Z){console.warn("[ChatProvider] Post-streaming thread refresh failed:",Z)}},"postStreamingRefresh")},[d,j,u,Se,Ne,pe]);const fe=S.useCallback(async()=>{console.log("[ChatProvider] 🔄 clearCurrentThread called"),console.log("[ChatProvider] 📊 Before clear - currentThreadId:",j),console.log("[ChatProvider] 📊 Before clear - messages count:",v.messages.length),j&&(re.current=j,console.log(`[ChatProvider] 🚫 Suppressing next auto-load for thread: ${j}`)),await pe(()=>(console.log("[ChatProvider] 🚀 Executing atomic clear operation"),H(null),N([]),te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),typeof window<"u"&&localStorage.removeItem("currentThreadId"),console.log("[ChatProvider] ✅ Atomic clear operation completed"),Promise.resolve()),"clearCurrentThread"),console.log("[ChatProvider] 📊 After clear - currentThreadId should be null")},[N,te,j,v.messages.length,pe]),We=S.useCallback(async L=>{fe();let Z=null;try{return Z=await u.createThread(L),B(Re=>[...Re.filter(it=>it.threadId!==Z.threadId),Z]),await lt(Z.threadId),Z.threadId}catch(Re){if(await Ne(),Z!=null&&Z.threadId)try{return await lt(Z.threadId),Z.threadId}catch(qe){console.error("[ChatProvider] Failed to load thread after refresh",qe)}throw Re}},[u,Ne,lt,fe]),Ye=S.useCallback(async L=>{try{await u.deleteThread(L),B(Z=>Z.filter(Re=>Re.threadId!==L)),j===L&&(H(null),N([]),R(!1),W(null),V(void 0),A(void 0))}catch(Z){throw await Ne(),Z}},[u,Ne,j,N]),Ze=S.useCallback(async(L,Z)=>{try{await u.updateThread(L,Z),B(Re=>Re.map(qe=>qe.threadId===L?{...qe,title:Z}:qe))}catch(Re){throw await Ne(),Re}},[u,Ne]),yt=S.useCallback(async(L,Z)=>{var Qe;const Re=(Z==null?void 0:Z.attachments)||[],{contentParts:qe,filesInfo:it}=await Xm(u,Re,t==null?void 0:t.uploadPath),ft=[];L&&L.trim()&&ft.push({type:"text",text:L.trim()});const Jt={id:((Qe=crypto.randomUUID)==null?void 0:Qe.call(crypto))||`user-${Date.now()}`,role:"user",content:ft,createdAt:new Date().toISOString(),checkpointId:(Z==null?void 0:Z.checkpointId)??v.lastCheckpointId??void 0,checkpointNs:(Z==null?void 0:Z.checkpointNs)??v.lastCheckpointNs??void 0};k(Jt);const bn={...Jt,content:ft},Ct={...(Z==null?void 0:Z.payloadExtras)??{}},Pe=!!Ct.edit,xt=Ct.originalMessageId,J=typeof xt=="string"?xt:void 0,he=Re&&Re.length>0,Oe={...j?{threadId:j}:{},payload:{messages:[bn],files_info:it,...a&&he&&c?{active_agent:c}:{},...Ct},checkpointId:(Z==null?void 0:Z.checkpointId)??v.lastCheckpointId??void 0,checkpointNs:(Z==null?void 0:Z.checkpointNs)??v.lastCheckpointNs??void 0,nodeFilter:Z==null?void 0:Z.nodeFilter,config:Z==null?void 0:Z.config,edit:Pe,originalMessageId:J};h(Oe,nt=>{if(nt.type==="thread_info"&&nt.threadId){const At=nt.threadId,an=!!nt.created,rr=!!nt.ready;if(j!==At){const or=!j&&v.messages.length<=1;or&&(re.current=At),H(At),(rr||an||or)&&Ne().catch(()=>{})}else(rr||an)&&Ne().catch(()=>{})}I(nt)},{onError:nt=>console.warn("stream error",nt),onOpen:({threadId:nt,created:At})=>{if(!j&&nt){const an=v.messages.length<=1;an&&(re.current=nt),H(nt),(At||an)&&Ne().catch(()=>{})}}})},[j,k,h,I,v.lastCheckpointId,v.lastCheckpointNs,u,t==null?void 0:t.uploadPath,Ne,H,a,c,v.messages.length]),dt=S.useCallback(async L=>{if(!j)throw new Error("No active thread");if($||!O)return;const Z=M;if(Z){q(!0);try{const Re=await u.getMessages({threadId:j,checkpointId:U,checkpointNs:D,limit:(L==null?void 0:L.limit)??_,beforeId:Z});Se(Re,"prepend")}finally{q(!1)}}},[u,j,U,D,M,O,$,Se,_]),St=S.useCallback(async(L,Z,Re)=>{if(!j)throw new Error("No active thread to handle interrupt");try{console.log(`[ChatProvider] Handling interrupt ${L}: ${Z?"approved":"rejected"}`);const qe=!!Z;await u.resume({threadId:j,value:qe}),console.log(`[ChatProvider] Interrupt ${L} handled successfully`),y({type:"interrupt_response",payload:{interruptId:L}})}catch(qe){throw console.error(`[ChatProvider] Failed to handle interrupt ${L}:`,qe),qe}},[u,j]),Xt={baseUrl:u.baseUrl,token:w,setToken:x,api:u,threads:Te,currentThreadId:j,setCurrentThreadId:H,isLoadingThreads:ee,isLoadingThread:ce,messages:v.messages,isStreaming:d,error:f,lastCheckpointId:v.lastCheckpointId,lastCheckpointNs:v.lastCheckpointNs,streamingAssistantId:v.assemblingId,hasMoreHistory:O,isLoadingHistory:$,loadOlderMessages:dt,historyPageSize:_,listCheckpoints:gt,navigateToCheckpoint:Ue,returnToLatest:Q,refreshThreads:Ne,createThread:We,deleteThread:Ye,renameThread:Ze,loadThread:lt,clearCurrentThread:fe,send:yt,stop:m,handleInterrupt:St};return l.jsx(Rl.Provider,{value:Xt,children:e})}function _r(){const e=S.useContext(Rl);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function X(...e){return pp.twMerge(hp.clsx(e))}const Jm=ro.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"}}),ze=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?$n.Slot:"button";return l.jsx(i,{className:X(Jm({variant:t,size:n,className:e})),ref:s,...o})});ze.displayName="Button";const Pl=p.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:X("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}));Pl.displayName="Textarea";function Zm({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=S.useState(e),[b,w]=S.useTransition(),g=S.useRef(null);S.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=S.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);S.useEffect(()=>{x()},[x]);const v=S.useCallback(async N=>{N&&N.preventDefault();const _=(h??"").trim();!_&&!f||w(()=>{try{const O=i(_);O&&typeof O.then=="function"?O.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=S.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=S.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),v()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[v,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 l.jsx("form",{onSubmit:N=>void v(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Pl,{ref:g,value:h,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(ze,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(ne.Square,{size:16})}):l.jsx(ze,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:l.jsx(ne.Send,{size:16})})})]})})}const Qm=S.memo(Zm),vo=0,En=1,cr=2,Ol=4;function Ml(e){return()=>e}function eg(e){e()}function Dl(e,t){return n=>e(t(n))}function Ll(e,t){return()=>e(t)}function tg(e,t){return n=>e(t,n)}function Js(e){return e!==void 0}function ng(...e){return()=>{e.map(eg)}}function ur(){}function wo(e,t){return t(e),e}function rg(e,t){return t(e)}function rt(...e){return e}function Ve(e,t){return e(En,t)}function Ie(e,t){e(vo,t)}function Zs(e){e(cr)}function ut(e){return e(Ol)}function de(e,t){return Ve(e,tg(t,vo))}function en(e,t){const n=e(En,r=>{n(),t(r)});return n}function $l(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Fl(e,t){return e===t}function ot(e=Fl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ve(e){return t=>n=>{e(n)&&t(n)}}function ie(e){return t=>Dl(t,e)}function cn(e){return t=>()=>{t(e)}}function F(e,...t){const n=og(...t);return(r,o)=>{switch(r){case cr:Zs(e);return;case En:return Ve(e,n(o))}}}function un(e,t){return n=>r=>{n(t=e(t,r))}}function Hn(e){return t=>n=>{e>0?e--:t(n)}}function yn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Ae(...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);Ve(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function og(...e){return t=>e.reduceRight(rg,t)}function sg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case En:return s?n===s?void 0:(r(),n=s,t=Ve(e,s),t):(r(),ur);case cr:r(),n=null;return}}}function G(e){let t=e;const n=$e();return(r,o)=>{switch(r){case vo:t=o;break;case En:{o(t);break}case Ol:return t}return n(r,o)}}function Et(e,t){return wo(G(t),n=>de(e,n))}function $e(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case cr:e.splice(0,e.length);return;case En:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Ft(e){return wo($e(),t=>de(e,t))}function He(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:ig(),singleton:n}}const ig=()=>Symbol();function ag(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function pt(...e){const t=$e(),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);Ve(s,c=>{n[i]=c,r=r|a,r===o&&Ie(t,n)})}),function(s,i){switch(s){case cr:{Zs(t);return}case En:return r===o&&i(n),Ve(t,i)}}}function xe(e,t=Fl){return F(e,ot(t))}function Qs(...e){return function(t,n){switch(t){case cr:return;case En:return ng(...e.map(r=>Ve(r,n)))}}}var Mt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Mt||{});const lg={0:"debug",3:"error",1:"log",2:"warn"},cg=()=>typeof globalThis>"u"?window:globalThis,In=He(()=>{const e=G(3);return{log:G((t,n,r=1)=>{var o;const s=(o=cg().VIRTUOSO_LOG_LEVEL)!=null?o:ut(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 Un(e,t,n){return ei(e,t,n).callbackRef}function ei(e,t,n){const r=S.useRef(null);let o=i=>{};const s=S.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 ug(e,t,n,r,o,s,i,a,c){const u=S.useCallback(d=>{const f=dg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let b;m&&(b=h.ownerDocument.defaultView);const w=i?a?i.scrollLeft:i.scrollTop:m?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:x}),s==null||s(a?zl("column-gap",getComputedStyle(d).columnGap,o):zl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ei(u,n,c)}function dg(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 c=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},Mt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function zl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Mt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Bl(e,t,n){const r=S.useRef(null),o=S.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),b=u.top-m.top;h=m.height-Math.max(0,b),f=b+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ei(o,!0,n),a=S.useCallback(()=>{o(i.current)},[o,i]);return S.useEffect(()=>{var c;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=(c=i.current)==null?void 0:c.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 jt=He(()=>{const e=$e(),t=$e(),n=G(0),r=$e(),o=G(0),s=$e(),i=$e(),a=G(0),c=G(0),u=G(0),d=G(0),f=$e(),h=$e(),m=G(!1),b=G(!1),w=G(!1);return de(F(e,ie(({scrollTop:g})=>g)),t),de(F(e,ie(({scrollHeight:g})=>g)),i),de(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Rr={lvl:0};function Hl(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Xe(e){return e===Rr}function Pr(e,t){if(!Xe(e))return t===e.k?e.v:t<e.k?Pr(e.l,t):Pr(e.r,t)}function tn(e,t,n="k"){if(Xe(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=tn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return tn(e.l,t,n)}function zt(e,t,n){return Xe(e)?Vl(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?Kl(wt(e,{l:zt(e.l,t,n)})):Kl(wt(e,{r:zt(e.r,t,n)}))}function dr(){return Rr}function bo(e,t,n){if(Xe(e))return[];const r=tn(e,t)[0];return fg(ni(e,r,n))}function ti(e,t){if(Xe(e))return Rr;const{k:n,l:r,r:o}=e;if(t===n){if(Xe(r))return o;if(Xe(o))return r;{const[s,i]=Wl(r);return yo(wt(e,{k:s,l:Ul(r),v:i}))}}else return t<n?yo(wt(e,{l:ti(r,t)})):yo(wt(e,{r:ti(o,t)}))}function Wn(e){return Xe(e)?[]:[...Wn(e.l),{k:e.k,v:e.v},...Wn(e.r)]}function ni(e,t,n){if(Xe(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ni(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ni(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(ri(t))return ql(wt(e,{lvl:n-1}));if(!Xe(t)&&!Xe(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ri(e))return oi(wt(e,{lvl:n-1}));if(!Xe(r)&&!Xe(r.l)){const o=r.l,s=ri(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:oi(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return Vl(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 Ul(e){return Xe(e.r)?e.l:yo(wt(e,{r:Ul(e.r)}))}function ri(e){return Xe(e)||e.lvl>e.r.lvl}function Wl(e){return Xe(e.r)?[e.k,e.v]:Wl(e.r)}function Vl(e,t,n,r=Rr,o=Rr){return{k:e,l:r,lvl:n,r:o,v:t}}function Kl(e){return oi(ql(e))}function ql(e){const{l:t}=e;return!Xe(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function oi(e){const{lvl:t,r:n}=e;return!Xe(n)&&!Xe(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function fg(e){return Hl(e,({k:t,v:n})=>({index:t,value:n}))}function Gl(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Or(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const si=He(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function Yl(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 Nn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!Xe(e.groupOffsetTree)}function ii({index:e},t){return t===e?0:t<e?-1:1}function pg(){return{groupIndices:[],groupOffsetTree:dr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:dr()}}function mg(e,t){let n=Xe(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Xe(e)){e=zt(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(Sg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=ti(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=zt(e,o+1,h));u&&(e=zt(e,i,s))}return[e,n]}function gg(e){return typeof e.groupIndex<"u"}function xg({offset:e},t){return t===e?0:t<e?-1:1}function Mr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Yl(t,e,ii),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Xl(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Jl(e,t,n){if(gg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Xl(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function vg(e,t,n,r=0){return r>0&&(t=Math.max(t,Yl(e,r,ii).offset)),Hl(hg(e,t,n,xg),yg)}function wg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Mt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Xe(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((b,w)=>zt(zt(b,w,h),w+1,m),i)}else[i,a]=mg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ai(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>zt(h,m,Mr(m,f,o)),dr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function bg(e){return Wn(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 Zl(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 ai(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=So(o,t-1,ii),a=o[c].offset;const u=tn(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===tn(n,t)[1]&&(c-=1),o=o.slice(0,c+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 yg(e){return{index:e.index,value:e}}function Sg(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 Cg={offsetHeight:"height",offsetWidth:"width"},dn=He(([{log:e},{recalcInProgress:t}])=>{const n=$e(),r=$e(),o=Et(r,0),s=$e(),i=$e(),a=G(0),c=G([]),u=G(void 0),d=G(void 0),f=G((C,k)=>Nn(C,Cg[k])),h=G(void 0),m=G(0),b=pg(),w=Et(F(n,Ae(c,e,m),un(wg,b),ot()),b),g=Et(F(c,ot(),un((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ie(({prev:C})=>C)),[]);de(F(c,ve(C=>C.length>0),Ae(w,m),ie(([C,k,I])=>{const N=C.reduce((_,O,R)=>zt(_,O,Mr(O,k.offsetTree,I)||R),dr());return{...k,groupIndices:C,groupOffsetTree:N}})),w),de(F(r,Ae(w),ve(([C,{lastIndex:k}])=>C<k),ie(([C,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:C}])),n),de(u,d);const x=Et(F(u,ie(C=>C===void 0)),!0);de(F(d,ve(C=>C!==void 0&&Xe(ut(w).sizeTree)),ie(C=>[{endIndex:0,size:C,startIndex:0}])),n);const v=Ft(F(n,Ae(w),un(({sizes:C},[k,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:b}),ie(C=>C.changed)));Ve(F(a,un((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ie(C=>C.diff)),C=>{const{groupIndices:k}=ut(w);if(C>0)Ie(t,!0),Ie(s,C+Zl(C,k));else if(C<0){const I=ut(g);I.length>0&&(C-=Zl(-C,I)),Ie(i,C)}}),Ve(F(a,Ae(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},Mt.ERROR)});const y=Ft(s);de(F(s,Ae(w),ie(([C,k])=>{const I=k.groupIndices.length>0,N=[],_=k.lastSize;if(I){const O=Pr(k.sizeTree,0);let R=0,$=0;for(;R<C;){const M=k.groupIndices[$],W=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;N.push({endIndex:M,size:O,startIndex:M}),N.push({endIndex:M+1+W-1,size:_,startIndex:M+1}),$++,R+=W+1}const q=Wn(k.sizeTree);return R!==C&&q.shift(),q.reduce((M,{k:W,v:U})=>{let V=M.ranges;return M.prevSize!==0&&(V=[...M.ranges,{endIndex:W+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+C,prevSize:U,ranges:V}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return Wn(k.sizeTree).reduce((O,{k:R,v:$})=>({prevIndex:R+C,prevSize:$,ranges:[...O.ranges,{endIndex:R+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const E=Ft(F(i,Ae(w,m),ie(([C,{offsetTree:k},I])=>{const N=-C;return Mr(N,k,I)})));return de(F(i,Ae(w,m),ie(([C,k,I])=>{if(k.groupIndices.length>0){if(Xe(k.sizeTree))return k;let N=dr();const _=ut(g);let O=0,R=0,$=0;for(;O<-C;){$=_[R];const q=_[R+1]-$-1;R++,O+=q+1}if(N=Wn(k.sizeTree).reduce((q,{k:M,v:W})=>zt(q,Math.max(0,M+C),W),N),O!==-C){const q=Pr(k.sizeTree,$);N=zt(N,0,q);const M=tn(k.sizeTree,-C+1)[1];N=zt(N,1,M)}return{...k,sizeTree:N,...ai(k.offsetTree,0,N,I)}}else{const N=Wn(k.sizeTree).reduce((_,{k:O,v:R})=>zt(_,Math.max(0,O+C),R),dr());return{...k,sizeTree:N,...ai(k.offsetTree,0,N,I)}}})),w),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:v,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},rt(In,si),{singleton:!0});function kg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Ql=He(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=$e(),i=$e(),a=Ft(F(s,ie(kg)));return de(F(a,ie(c=>c.totalCount)),n),de(F(a,ie(c=>c.groupIndices)),e),de(F(pt(o,t,r),ve(([c,u])=>Co(u)),ie(([c,u,d])=>tn(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),ot(),ie(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},rt(dn,jt)),An=He(([{log:e}])=>{const t=G(!1),n=Ft(F(t,ve(r=>r),ot()));return Ve(t,r=>{r&&ut(e)("props updated",{},Mt.DEBUG)}),{didMount:n,propsReady:t}},rt(In),{singleton:!0}),Tg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ec(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Tg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Dr=He(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=$e(),b=$e(),w=G(0);let g=null,x=null,v=null;function y(){g&&(g(),g=null),v&&(v(),v=null),x&&(clearTimeout(x),x=null),Ie(c,!1)}return de(F(m,Ae(n,f,r,w,a,i,h),Ae(e,s,o),ie(([[E,C,k,I,N,_,O,R],$,q,M])=>{const W=ec(E),{align:U,behavior:V,offset:D}=W,A=I-1,K=Jl(W,C,A);let Y=Mr(K,C.offsetTree,$)+_;U==="end"?(Y+=q+tn(C.sizeTree,K)[1]-k+M,K===A&&(Y+=O)):U==="center"?Y+=(q+tn(C.sizeTree,K)[1]-k+M)/2:Y-=N,D&&(Y+=D);const re=te=>{y(),te?(R("retrying to scroll to",{location:E},Mt.DEBUG),Ie(m,E)):(Ie(b,!0),R("list did not change, scroll successful",{},Mt.DEBUG))};if(y(),V==="smooth"){let te=!1;v=Ve(t,pe=>{te=te||pe}),g=en(d,()=>{re(te)})}else g=en(F(t,Eg(150)),re);return x=setTimeout(()=>{y()},1200),Ie(c,!0),R("scrolling from index to",{behavior:V,index:K,top:Y},Mt.DEBUG),{behavior:V,top:Y}})),u),{scrollTargetReached:b,scrollToIndex:m,topListHeight:w}},rt(dn,jt,In),{singleton:!0});function Eg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function li(e,t){e==0?t():requestAnimationFrame(()=>{li(e-1,t)})}function ci(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Lr=He(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=G(!0),c=G(0),u=G(!0);return de(F(i,Ae(c),ve(([d,f])=>!!f),cn(!1)),a),de(F(i,Ae(c),ve(([d,f])=>!!f),cn(!1)),u),Ve(F(pt(t,i),Ae(a,n,e,u),ve(([[,d],f,{sizeTree:h},m,b])=>d&&(!Xe(h)||Js(m))&&!f&&!b),Ae(c)),([,d])=>{en(o,()=>{Ie(u,!0)}),li(4,()=>{en(r,()=>{Ie(a,!0)}),Ie(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},rt(dn,jt,Dr,An),{singleton:!0});function tc(e,t){return Math.abs(e-t)<1.01}const $r="up",Fr="down",Ig="none",Ng={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ag=0,zr=He(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=G(!1),a=G(!0),c=$e(),u=$e(),d=G(4),f=G(Ag),h=Et(F(Qs(F(xe(o),Hn(1),cn(!0)),F(xe(o),Hn(1),cn(!1),$l(100))),ot()),!1),m=Et(F(Qs(F(n,cn(!0)),F(n,cn(!1),$l(200))),ot()),!1);de(F(pt(xe(o),xe(f)),ie(([v,y])=>v<=y),ot()),a),de(F(a,yn(50)),u);const b=Ft(F(pt(r,xe(s),xe(t),xe(e),xe(d)),un((v,[{scrollHeight:y,scrollTop:E},C,k,I,N])=>{const _=E+C-y>-N,O={scrollHeight:y,scrollTop:E,viewportHeight:C};if(_){let $,q;return E>v.state.scrollTop?($="SCROLLED_DOWN",q=v.state.scrollTop-E):($="SIZE_DECREASED",q=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:q,state:O}}let R;return O.scrollHeight>v.state.scrollHeight?R="SIZE_INCREASED":C<v.state.viewportHeight?R="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?R="SCROLLING_UPWARDS":R="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:O}},Ng),ot((v,y)=>v&&v.atBottom===y.atBottom))),w=Et(F(r,un((v,{scrollHeight:y,scrollTop:E,viewportHeight:C})=>{if(tc(v.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const k=y-(E+C)<1;return v.scrollTop!==E&&k?{changed:!0,jump:v.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ve(v=>v.changed),ie(v=>v.jump)),0);de(F(b,ie(v=>v.atBottom)),i),de(F(i,yn(50)),c);const g=G(Fr);de(F(r,ie(({scrollTop:v})=>v),ot(),un((v,y)=>ut(m)?{direction:v.direction,prevScrollTop:y}:{direction:y<v.prevScrollTop?$r:Fr,prevScrollTop:y},{direction:Fr,prevScrollTop:0}),ie(v=>v.direction)),g),de(F(r,yn(50),cn(Ig)),g);const x=G(0);return de(F(h,ve(v=>!v),cn(0)),x),de(F(o,yn(100),Ae(h),ve(([v,y])=>!!y),un(([v,y],[E])=>[y,E],[0,0]),ie(([v,y])=>y-v)),x),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:x}},rt(jt)),ko="top",To="bottom",nc="none";function rc(e,t,n){return typeof e=="number"?n===$r&&t===ko||n===Fr&&t===To?e:0:n===$r?t===ko?e.main:e.reverse:t===To?e.main:e.reverse}function oc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ui=He(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=$e(),i=G(0),a=G(0),c=G(0),u=Et(F(pt(xe(r),xe(o),xe(n),xe(s,Or),xe(c),xe(i),xe(t),xe(e),xe(a)),ie(([d,f,h,[m,b],w,g,x,v,y])=>{const E=d-v,C=g+x,k=Math.max(h-E,0);let I=nc;const N=oc(y,ko),_=oc(y,To);return m-=v,m+=h+x,b+=h+x,b-=v,m>d+C-N&&(I=$r),b<d-k+f+_&&(I=Fr),I!==nc?[Math.max(E-h-rc(w,ko,I)-N,0),E-k-x+f+rc(w,To,I)+_]:null}),ve(d=>d!=null),ot(Or)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},rt(jt),{singleton:!0});function jg(e,t,n){if(Co(t)){const r=Xl(e,t);return[{index:tn(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 di={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:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,b=h-d;return{bottom:d,firstItemIndex:s,items:ic(e,o,s),offsetBottom:b,offsetTop:u,top:m,topItems:ic(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function sc(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,c=ci(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function ic(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,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Vn=He(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:b}])=>{const w=G([]),g=G(0),x=$e();de(s.topItemsIndexes,w);const v=Et(F(pt(m,b,xe(c,Or),xe(o),xe(r),xe(u),d,xe(w),xe(t),xe(n),e),ve(([k,I,,N,,,,,,,_])=>{const O=_&&_.length!==N;return k&&!I&&!O}),ie(([,,[k,I],N,_,O,R,$,q,M,W])=>{const U=_,{offsetTree:V,sizeTree:D}=U,A=ut(g);if(N===0)return{...di,totalCount:N};if(k===0&&I===0)return A===0?{...di,totalCount:N}:sc(A,O,_,q,M,W||[]);if(Xe(D))return A>0?null:Eo(jg(ci(O,N),U,W),[],N,M,U,q);const K=[];if($.length>0){const Se=$[0],Te=$[$.length-1];let B=0;for(const j of bo(D,Se,Te)){const H=j.value,ee=Math.max(j.start,Se),ue=Math.min(j.end,Te);for(let ce=ee;ce<=ue;ce++)K.push({data:W==null?void 0:W[ce],index:ce,offset:B,size:H}),B+=H}}if(!R)return Eo([],K,N,M,U,q);const Y=$.length>0?$[$.length-1]+1:0,re=vg(V,k,I,Y);if(re.length===0)return null;const te=N-1,pe=wo([],Se=>{for(const Te of re){const B=Te.value;let j=B.offset,H=Te.start;const ee=B.size;if(B.offset<k){H+=Math.floor((k-B.offset+M)/(ee+M));const ce=H-Te.start;j+=ce*ee+ce*M}H<Y&&(j+=(Y-H)*ee,H=Y);const ue=Math.min(Te.end,te);for(let ce=H;ce<=ue&&!(j>=I);ce++)Se.push({data:W==null?void 0:W[ce],index:ce,offset:j,size:ee}),j+=ee+M}});return Eo(pe,K,N,M,U,q)}),ve(k=>k!==null),ot()),di);de(F(e,ve(Js),ie(k=>k==null?void 0:k.length)),o),de(F(v,ie(k=>k.topListHeight)),f),de(f,a),de(F(v,ie(k=>[k.top,k.bottom])),i),de(F(v,ie(k=>k.items)),x);const y=Ft(F(v,ve(({items:k})=>k.length>0),Ae(o,e),ve(([{items:k},I])=>k[k.length-1].originalIndex===I-1),ie(([,k,I])=>[k-1,I]),ot(Or),ie(([k])=>k))),E=Ft(F(v,yn(200),ve(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),ie(({items:k})=>k[0].index),ot())),C=Ft(F(v,ve(({items:k})=>k.length>0),ie(({items:k})=>{let I=0,N=k.length-1;for(;k[I].type==="group"&&I<N;)I++;for(;k[N].type==="group"&&N>I;)N--;return{endIndex:k[N].index,startIndex:k[I].index}}),ot(Gl)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:v,rangeChanged:C,startReached:E,topItemsIndexes:w,...h}},rt(dn,Ql,ui,Lr,Dr,zr,An,si),{singleton:!0}),ac=He(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=$e(),i=Et(F(pt(n,e,r,t,o),ie(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return de(xe(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(jt,Vn),{singleton:!0}),_g=He(([{viewportHeight:e},{totalListHeight:t}])=>{const n=G(!1),r=Et(F(pt(n,e,t),ve(([o])=>o),ie(([,o,s])=>Math.max(0,o-s)),yn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(jt,ac),{singleton:!0}),lc=He(()=>({context:G(null)})),Rg=({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=He(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=$e();return de(F(d,Ae(t,c,n,s,o,r,a),Ae(e),ie(([[f,h,m,b,w,g,x,v],y])=>{const{align:E,behavior:C,calculateViewLocation:k=Rg,done:I,...N}=f,_=Jl(f,h,b-1),O=Mr(_,h.offsetTree,y)+w+g,R=O+tn(h.sizeTree,_)[1],$=v+g,q=v+m-x,M=k({itemBottom:R,itemTop:O,locationParams:{align:E,behavior:C,...N},viewportBottom:q,viewportTop:$});return M?I&&en(F(i,ve(W=>!W),Hn(ut(i)?1:2)),I):I&&I(),M}),ve(f=>f!==null)),u),{scrollIntoView:d}},rt(dn,jt,Dr,Vn,In),{singleton:!0});function uc(e){return e?e==="smooth"?"smooth":"auto":!1}const Pg=(e,t)=>typeof e=="function"?uc(e(t)):t&&uc(e),Og=He(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const b=G(!1),w=$e();let g=null;function x(C){Ie(i,{align:"end",behavior:C,index:"LAST"})}Ve(F(pt(F(xe(t),Hn(1)),c),Ae(xe(b),s,a,f),ie(([[C,k],I,N,_,O])=>{let R=k&&_,$="auto";return R&&($=Pg(I,N||O),R=R&&!!$),{followOutputBehavior:$,shouldFollow:R,totalCount:C}}),ve(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:k},Mt.DEBUG),x(C)}):g=en(e,()=>{ut(d)("following output to ",{totalCount:k},Mt.DEBUG),x(C),g=null})});function v(C){const k=en(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ut(d)("scrolling to bottom due to increased size",{},Mt.DEBUG),x("auto"))});setTimeout(k,100)}Ve(F(pt(xe(b),t,u),ve(([C,,k])=>C&&k),un(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),ve(({refreshed:C})=>C),Ae(b,t)),([,C])=>{ut(a)&&v(C!==!1)}),Ve(w,()=>{v(ut(b)!==!1)}),Ve(pt(xe(b),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=G(null),E=$e();return de(Qs(F(xe(r),ie(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),F(xe(t))),E),Ve(F(pt(F(E,Hn(1)),c),Ae(xe(y),a,f,h),ie(([[C,k],I,N,_,O])=>k&&N&&(I==null?void 0:I({context:O,totalCount:C,scrollingInProgress:_}))),ve(C=>!!C),yn(0)),C=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Ie(m,C)}):g=en(e,()=>{ut(d)("scrolling into view",{}),Ie(m,C),g=null})}),{autoscrollToBottom:w,followOutput:b,scrollIntoViewOnChange:y}},rt(dn,zr,Dr,Lr,An,In,jt,lc,cc)),Mg=He(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(de(F(a,Ae(s),ve(([,c])=>c!==0),Ae(o,r,t,n,e),ie(([[,c],u,d,f,h,m=[]])=>sc(c,u,d,f,h,m))),i),{}),rt(dn,Lr,Vn,An),{singleton:!0}),Dg=He(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=G(0);return Ve(F(e,Ae(r),ve(([,o])=>o!==0),ie(([,o])=>({top:o}))),o=>{en(F(n,Hn(1),ve(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ie(t,o)})})}),{initialScrollTop:r}},rt(An,jt,Vn),{singleton:!0}),dc=He(([{scrollVelocity:e}])=>{const t=G(!1),n=$e(),r=G(!1);return de(F(e,Ae(r,t,n),ve(([o,s])=>!!s),ie(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),ot()),t),Ve(F(pt(t,e,n),Ae(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(zr),{singleton:!0}),fi=He(([{scrollContainerState:e,scrollTo:t}])=>{const n=$e(),r=$e(),o=$e(),s=G(!1),i=G(void 0);return de(F(pt(n,r),ie(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),de(F(t,Ae(r),ie(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(jt)),Lg=He(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=$e(),d=G(void 0),f=G(null),h=G(null);return de(a,f),de(c,h),Ve(F(u,Ae(t,r,i,f,h,n)),([m,b,w,g,x,v,y])=>{const E=bg(b.sizeTree);g&&x!==null&&v!==null&&(w=x.scrollTop-v.offsetTop),w-=y,m({ranges:E,scrollTop:w})}),de(F(d,ve(Js),ie($g)),o),de(F(s,Ae(d),ve(([,m])=>m!==void 0),ot(),ie(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},rt(dn,jt,Lr,An,fi));function $g(e){return{align:"start",index:0,offset:e.scrollTop}}const Fg=He(([{topItemsIndexes:e}])=>{const t=G(0);return de(F(t,ve(n=>n>=0),ie(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(Vn));function fc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const zg=fc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Bg=He(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:b}])=>{const w=Ft(F(c,Ae(i),un(([,x,v,y],[{bottom:E,items:C,offsetBottom:k,totalCount:I},N])=>{const _=E+k;let O=0;return v===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(O=_-y,O!==0&&(O+=N))),[O,C,I,_]},[0,[],0,0]),ve(([x])=>x!==0),Ae(r,a,n,o,m,b),ve(([,x,v,y,,,E])=>!E&&!y&&x!==0&&v===$r),ie(([[x],,,,,v])=>(v("Upward scrolling compensation",{amount:x},Mt.DEBUG),x))));function g(x){x>0?(Ie(t,{behavior:"auto",top:-x}),Ie(e,0)):(Ie(e,0),Ie(t,{behavior:"auto",top:-x}))}return Ve(F(w,Ae(e,s)),([x,v,y])=>{y&&zg()?Ie(e,v-x):g(-x)}),Ve(F(pt(Et(s,!1),e,b),ve(([x,v,y])=>!x&&!y&&v!==0),ie(([x,v])=>v),yn(1)),g),de(F(f,ie(x=>({top:-x}))),t),Ve(F(u,Ae(h,d),ie(([x,{groupIndices:v,lastSize:y,sizeTree:E},C])=>{function k(I){return I*(y+C)}if(v.length===0)return k(x);{let I=0;const N=Pr(E,0);let _=0,O=0;for(;_<x;){_++,I+=N;let R=v.length===O+1?1/0:v[O+1]-v[O]-1;_+R>x&&(I-=N,R=x-_+1),_+=R,I+=k(R),O++}return I}})),x=>{Ie(e,x),requestAnimationFrame(()=>{Ie(t,{top:x}),requestAnimationFrame(()=>{Ie(e,0),Ie(b,!1)})})}),{deviation:e}},rt(jt,zr,Vn,dn,In,si)),Hg=He(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),rt(ui,Mg,An,dc,ac,Dg,_g,fi,cc,In,lc)),hc=He(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b},w,g,x,{listState:v,topItemsIndexes:y,...E},{scrollToIndex:C},k,{topItemCount:I},{groupCounts:N},_])=>(de(E.rangeChanged,_.scrollSeekRangeChanged),de(F(_.windowViewportRect,ie(O=>O.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:v,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,..._,...w,sizes:c,...g}),rt(dn,Lr,jt,Lg,Og,Vn,Dr,Bg,Fg,Ql,Hg));function Ug(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"?S.useLayoutEffect:S.useEffect;function pc(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=S.createContext({});function c(g,x){g.propsReady&&Ie(g.propsReady,!1);for(const v of r){const y=g[t.required[v]];Ie(y,x[v])}for(const v of o)if(v in x){const y=g[t.optional[v]];Ie(y,x[v])}g.propsReady&&Ie(g.propsReady,!0)}function u(g){return s.reduce((x,v)=>(x[v]=y=>{const E=g[t.methods[v]];Ie(E,y)},x),{})}function d(g){return i.reduce((x,v)=>(x[v]=sg(g[t.events[v]]),x),{})}const f=S.forwardRef((g,x)=>{const{children:v,...y}=g,[E]=S.useState(()=>wo(ag(e),I=>{c(I,y)})),[C]=S.useState(Ll(d,E));Io(()=>{for(const I of i)I in y&&Ve(C[I],y[I]);return()=>{Object.values(C).map(Zs)}},[y,C,E]),Io(()=>{c(E,y)}),S.useImperativeHandle(x,Ml(u(E)));const k=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(k,{...Ug([...r,...o,...i],y),children:v}):v})}),h=g=>{const x=S.useContext(a);return S.useCallback(v=>{Ie(x[g],v)},[x,g])},m=g=>{const x=S.useContext(a)[g],v=S.useCallback(y=>Ve(x,y),[x]);return S.useSyncExternalStore(v,()=>ut(x),()=>ut(x))},b=g=>{const x=S.useContext(a)[g],[v,y]=S.useState(Ll(ut,x));return Io(()=>Ve(x,E=>{E!==v&&y(Ml(E))}),[x,v]),v},w=S.version.startsWith("18")?m:b;return{Component:f,useEmitter:(g,x)=>{const v=S.useContext(a)[g];Io(()=>Ve(v,x),[x,v])},useEmitterValue:w,usePublisher:h}}const mc=S.createContext(void 0),gc=S.createContext(void 0),xc=typeof document<"u"?S.useLayoutEffect:S.useEffect;function hi(e){return"self"in e}function Wg(e){return"body"in e}function vc(e,t,n,r=ur,o,s){const i=S.useRef(null),a=S.useRef(null),c=S.useRef(null),u=S.useCallback(h=>{let m,b,w;const g=h.target;if(Wg(g)||hi(g)){const v=hi(g)?g:g.defaultView;w=s?v.scrollX:v.scrollY,m=s?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,b=s?v.innerWidth:v.innerHeight}else w=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(w,0),viewportHeight:b})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(w===a.current||w<=0||w===m-b)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);S.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 m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=h.behavior==="smooth";let w,g,x;hi(m)?(g=Math.max(Nn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),w=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],w=Nn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const v=g-w;if(h.top=Math.ceil(Math.max(Math.min(v,h.top),0)),tc(w,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:w}),b&&t(!0);return}b?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),m.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 pi="-webkit-sticky",wc="sticky",mi=fc(()=>{if(typeof document>"u")return wc;const e=document.createElement("div");return e.style.position=pi,e.style.position===pi?pi:wc});function gi(e){return e}const Vg=He(()=>{const e=G(a=>`Item ${a}`),t=G(a=>`Group ${a}`),n=G({}),r=G(gi),o=G("div"),s=G(ur),i=(a,c=null)=>Et(F(n,ie(u=>u[a]),ot()),c);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")}}),Kg=He(([e,t])=>({...e,...t}),rt(hc,Vg)),qg=({height:e})=>l.jsx("div",{style:{height:e}}),Gg={overflowAnchor:"none",position:mi(),zIndex:1},bc={overflowAnchor:"none"},Yg={...bc,display:"inline-block",height:"100%"},yc=S.memo(function({showTopList:e=!1}){const t=ye("listState"),n=Vt("sizeRanges"),r=ye("useWindowScroll"),o=ye("customScrollParent"),s=Vt("windowScrollContainerState"),i=Vt("scrollContainerState"),a=o||r?s:i,c=ye("itemContent"),u=ye("context"),d=ye("groupContent"),f=ye("trackItemSizes"),h=ye("itemSize"),m=ye("log"),b=Vt("gap"),w=ye("horizontalDirection"),{callbackRef:g}=ug(n,h,f,e?ur:a,m,b,o,w,ye("skipAnimationFrameInResizeObserver")),[x,v]=S.useState(0);xi("deviation",M=>{x!==M&&v(M)});const y=ye("EmptyPlaceholder"),E=ye("ScrollSeekPlaceholder")||qg,C=ye("ListComponent"),k=ye("ItemComponent"),I=ye("GroupComponent"),N=ye("computeItemKey"),_=ye("isSeeking"),O=ye("groupIndices").length>0,R=ye("alignToBottom"),$=ye("initialItemFinalLocationReached"),q=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:x!==0?x:R?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:R?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?l.jsx(y,{...It(y,u)}):l.jsx(C,{...It(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:q,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,U=N(W+t.firstItemIndex,M.data,u);return _?S.createElement(E,{...It(E,u),height:M.size,index:M.index,key:U,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?S.createElement(I,{...It(I,u),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:U,style:Gg},d(M.index,u)):S.createElement(k,{...It(k,u),...Qg(k,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:U,style:w?Yg:bc},O?c(M.index,M.groupIndex,M.data,u):c(M.index,M.data,u))})})}),Xg={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Jg={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Zg={position:mi(),top:0,width:"100%",zIndex:1};function It(e,t){if(typeof e!="string")return{context:t}}function Qg(e,t){return{item:typeof e=="string"?void 0:t}}const ex=S.memo(function(){const e=ye("HeaderComponent"),t=Vt("headerHeight"),n=ye("HeaderFooterTag"),r=Un(S.useMemo(()=>s=>{t(Nn(s,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...It(e,o)})}):null}),tx=S.memo(function(){const e=ye("FooterComponent"),t=Vt("footerHeight"),n=ye("HeaderFooterTag"),r=Un(S.useMemo(()=>s=>{t(Nn(s,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),o=ye("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...It(e,o)})}):null});function Sc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:b}=vc(a,u,c,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?Jg:Xg,...o},tabIndex:0,...i,...It(c,s),children:r})})}function Cc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=S.useRef(null),b=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:x}=vc(a,u,c,b,h);return xc(()=>{var v;return g.current=h||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",w),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...It(c,s),children:r})})}const nx=({children:e})=>{const t=S.useContext(mc),n=Vt("viewportHeight"),r=Vt("fixedItemHeight"),o=ye("alignToBottom"),s=ye("horizontalDirection"),i=S.useMemo(()=>Dl(n,c=>Nn(c,s?"width":"height")),[n,s]),a=Un(i,!0,ye("skipAnimationFrameInResizeObserver"));return S.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:No(o),children:e})},rx=({children:e})=>{const t=S.useContext(mc),n=Vt("windowViewportRect"),r=Vt("fixedItemHeight"),o=ye("customScrollParent"),s=Bl(n,o,ye("skipAnimationFrameInResizeObserver")),i=ye("alignToBottom");return S.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:No(i),children:e})},ox=({children:e})=>{const t=ye("TopItemListComponent")||"div",n=ye("headerHeight"),r={...Zg,marginTop:`${n}px`},o=ye("context");return l.jsx(t,{style:r,...It(t,o),children:e})},sx=S.memo(function(e){const t=ye("useWindowScroll"),n=ye("topItemsIndexes").length>0,r=ye("customScrollParent"),o=ye("context");return l.jsxs(r||t?lx:ax,{...e,context:o,children:[n&&l.jsx(ox,{children:l.jsx(yc,{showTopList:!0})}),l.jsxs(r||t?rx:nx,{children:[l.jsx(ex,{}),l.jsx(yc,{}),l.jsx(tx,{})]})]})}),{Component:ix,useEmitter:xi,useEmitterValue:ye,usePublisher:Vt}=pc(Kg,{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"}},sx),ax=Sc({useEmitter:xi,useEmitterValue:ye,usePublisher:Vt}),lx=Cc({useEmitter:xi,useEmitterValue:ye,usePublisher:Vt}),cx=ix;rt(hc,He(()=>{const e=G(u=>l.jsxs("td",{children:["Item $",u]})),t=G(null),n=G(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=G(null),o=G(null),s=G({}),i=G(gi),a=G(ur),c=(u,d=null)=>Et(F(s,ie(f=>f[u]),ot()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),mi();const kc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},ux={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Tc,floor:Ao,max:Br,min:vi,round:Ec}=Math;function Ic(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function dx(e){return{...ux,items:e}}function jo(e,t){return e&&e.width===t.width&&e.height===t.height}function fx(e,t){return e&&e.column===t.column&&e.row===t.row}const hx=He(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:b,propsReady:w},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E},C])=>{const k=G(0),I=G(0),N=G(kc),_=G({height:0,width:0}),O=G({height:0,width:0}),R=$e(),$=$e(),q=G(0),M=G(null),W=G({column:0,row:0}),U=$e(),V=$e(),D=G(!1),A=G(0),K=G(!0),Y=G(!1),re=G(!1);Ve(F(b,Ae(A),ve(([j,H])=>!!H)),()=>{Ie(K,!1)}),Ve(F(pt(b,K,O,_,A,Y),ve(([j,H,ee,ue,,ce])=>j&&!H&&ee.height!==0&&ue.height!==0&&!ce)),([,,,,j])=>{Ie(Y,!0),li(1,()=>{Ie(R,j)}),en(F(u),()=>{Ie(t,[0,0]),Ie(K,!0)})}),de(F(V,ve(j=>j!=null&&j.scrollTop>0),cn(0)),I),Ve(F(b,Ae(V),ve(([,j])=>j!=null)),([,j])=>{j&&(Ie(_,j.viewport),Ie(O,j.item),Ie(W,j.gap),j.scrollTop>0&&(Ie(D,!0),en(F(u,Hn(1)),H=>{Ie(D,!1)}),Ie(c,{top:j.scrollTop})))}),de(F(_,ie(({height:j})=>j)),f),de(F(pt(xe(_,jo),xe(O,jo),xe(W,(j,H)=>j&&j.column===H.column&&j.row===H.row),xe(u)),ie(([j,H,ee,ue])=>({gap:ee,item:H,scrollTop:ue,viewport:j}))),U),de(F(pt(xe(k),r,xe(W,fx),xe(O,jo),xe(_,jo),xe(M),xe(I),xe(D),xe(K),xe(A)),ve(([,,,,,,,j])=>!j),ie(([j,[H,ee],ue,ce,_e,Ne,Ee,,je,Be])=>{const{column:Ge,row:De}=ue,{height:tt,width:mt}=ce,{width:at}=_e;if(Ee===0&&(j===0||at===0))return kc;if(mt===0){const Ze=ci(Be,j),yt=Ze+Math.max(Ee-1,0);return dx(Ic(Ze,yt,Ne))}const lt=Nc(at,mt,Ge);let gt,Ue;je?H===0&&ee===0&&Ee>0?(gt=0,Ue=Ee-1):(gt=lt*Ao((H+De)/(tt+De)),Ue=lt*Tc((ee+De)/(tt+De))-1,Ue=vi(j-1,Br(Ue,lt-1)),gt=vi(Ue,Br(0,gt))):(gt=0,Ue=-1);const Q=Ic(gt,Ue,Ne),{bottom:oe,top:fe}=Ac(_e,ue,ce,Q),We=Tc(j/lt),Ye=We*tt+(We-1)*De-oe;return{bottom:oe,itemHeight:tt,items:Q,itemWidth:mt,offsetBottom:Ye,offsetTop:fe,top:fe}})),N),de(F(M,ve(j=>j!==null),ie(j=>j.length)),k),de(F(pt(_,O,N,W),ve(([j,H,{items:ee}])=>ee.length>0&&H.height!==0&&j.height!==0),ie(([j,H,{items:ee},ue])=>{const{bottom:ce,top:_e}=Ac(j,ue,H,ee);return[_e,ce]}),ot(Or)),t);const te=G(!1);de(F(u,Ae(te),ie(([j,H])=>H||j!==0)),te);const pe=Ft(F(pt(N,k),ve(([{items:j}])=>j.length>0),Ae(te),ve(([[j,H],ee])=>{const ue=j.items[j.items.length-1].index===H-1;return(ee||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===H)&&ue}),ie(([[,j]])=>j-1),ot())),Se=Ft(F(xe(N),ve(({items:j})=>j.length>0&&j[0].index===0),cn(0),ot())),Te=Ft(F(xe(N),Ae(D),ve(([{items:j},H])=>j.length>0&&!H),ie(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),ot(Gl),yn(0)));de(Te,m.scrollSeekRangeChanged),de(F(R,Ae(_,O,k,W),ie(([j,H,ee,ue,ce])=>{const _e=ec(j),{align:Ne,behavior:Ee,offset:je}=_e;let Be=_e.index;Be==="LAST"&&(Be=ue-1),Be=Br(0,Be,vi(ue-1,Be));let Ge=wi(H,ce,ee,Be);return Ne==="end"?Ge=Ec(Ge-H.height+ee.height):Ne==="center"&&(Ge=Ec(Ge-H.height/2+ee.height/2)),je&&(Ge+=je),{behavior:Ee,top:Ge}})),c);const B=Et(F(N,ie(j=>j.offsetBottom+j.bottom)),0);return de(F(E,ie(j=>({height:j.visibleHeight,width:j.visibleWidth}))),_),{customScrollParent:g,data:M,deviation:q,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:V,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:c,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:E,...m,gridState:N,horizontalDirection:re,initialTopMostItemIndex:A,totalListHeight:B,...h,endReached:pe,propsReady:w,rangeChanged:Te,startReached:Se,stateChanged:U,stateRestoreInProgress:D,...C}},rt(ui,jt,zr,dc,An,fi,In));function Nc(e,t,n){return Br(1,Ao((e+n)/(Ao(t)+n)))}function Ac(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=wi(e,t,n,r[0].index);return{bottom:wi(e,t,n,r[r.length-1].index)+o,top:s}}function wi(e,t,n,r){const o=Nc(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 px=He(()=>{const e=G(f=>`Item ${f}`),t=G({}),n=G(null),r=G("virtuoso-grid-item"),o=G("virtuoso-grid-list"),s=G(gi),i=G("div"),a=G(ur),c=(f,h=null)=>Et(F(t,ie(m=>m[f]),ot()),h),u=G(!1),d=G(!1);return de(xe(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),mx=He(([e,t])=>({...e,...t}),rt(hx,px)),gx=S.memo(function(){const e=st("gridState"),t=st("listClassName"),n=st("itemClassName"),r=st("itemContent"),o=st("computeItemKey"),s=st("isSeeking"),i=Kt("scrollHeight"),a=st("ItemComponent"),c=st("ListComponent"),u=st("ScrollSeekPlaceholder"),d=st("context"),f=Kt("itemDimensions"),h=Kt("gap"),m=st("log"),b=st("stateRestoreInProgress"),w=Kt("reportReadyState"),g=Un(S.useMemo(()=>x=>{const v=x.parentElement.parentElement.scrollHeight;i(v);const y=x.firstChild;if(y){const{height:E,width:C}=y.getBoundingClientRect();f({height:E,width:C})}h({column:_c("column-gap",getComputedStyle(x).columnGap,m),row:_c("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return xc(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),b?null:l.jsx(c,{className:t,ref:g,...It(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const v=o(x.index,x.data,d);return s?l.jsx(u,{...It(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},v):S.createElement(a,{...It(a,d),className:n,"data-index":x.index,key:v},r(x.index,x.data,d))})})}),xx=S.memo(function(){const e=st("HeaderComponent"),t=Kt("headerHeight"),n=st("headerFooterTag"),r=Un(S.useMemo(()=>s=>{t(Nn(s,"height"))},[t]),!0,!1),o=st("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...It(e,o)})}):null}),vx=S.memo(function(){const e=st("FooterComponent"),t=Kt("footerHeight"),n=st("headerFooterTag"),r=Un(S.useMemo(()=>s=>{t(Nn(s,"height"))},[t]),!0,!1),o=st("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...It(e,o)})}):null}),wx=({children:e})=>{const t=S.useContext(gc),n=Kt("itemDimensions"),r=Kt("viewportDimensions"),o=Un(S.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return S.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:No(!1),children:e})},bx=({children:e})=>{const t=S.useContext(gc),n=Kt("windowViewportRect"),r=Kt("itemDimensions"),o=st("customScrollParent"),s=Bl(n,o,!1);return S.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:No(!1),children:e})},yx=S.memo(function({...e}){const t=st("useWindowScroll"),n=st("customScrollParent"),r=n||t?Cx:Sx,o=n||t?bx:wx,s=st("context");return l.jsx(r,{...e,...It(r,s),children:l.jsxs(o,{children:[l.jsx(xx,{}),l.jsx(gx,{}),l.jsx(vx,{})]})})}),{useEmitter:jc,useEmitterValue:st,usePublisher:Kt}=pc(mx,{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"}},yx),Sx=Sc({useEmitter:jc,useEmitterValue:st,usePublisher:Kt}),Cx=Cc({useEmitter:jc,useEmitterValue:st,usePublisher:Kt});function _c(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Mt.WARN),t==="normal"?0:parseInt(t??"0",10)}const kx=ro.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 bi({className:e,variant:t,...n}){return l.jsx("div",{className:X(kx({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 Tx(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.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 fn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...b}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>b,Object.values(b));return l.jsx(w.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var w;const m=((w=h==null?void 0:h[e])==null?void 0:w[c])||a,b=p.useContext(m);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Ex(o,...t)]}function Ex(...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:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var bt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Ix=p[" useInsertionEffect ".trim().toString()]||bt;function Kn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.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=p.useCallback(d=>{var f;if(a){const h=Ax(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Nx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Ix(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Ax(e){return typeof e=="function"}function Rc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function yi(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Rc(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():Rc(e[o],null)}}}}function Me(...e){return p.useCallback(yi(...e),e)}var jx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],we=jx.reduce((e,t)=>{const n=$n.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Pc(e,t){e&&oo.flushSync(()=>e.dispatchEvent(t))}function _x(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Bt=e=>{const{present:t,children:n}=e,r=Rx(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Me(r.ref,Px(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Bt.displayName="Presence";function Rx(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=_x(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=_o(r.current);s.current=a==="mounted"?u:"none"},[a]),bt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=_o(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),bt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const w=_o(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&w&&(c("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=m=>{m.target===t&&(s.current=_o(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 c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function _o(e){return(e==null?void 0:e.animationName)||"none"}function Px(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 Ox=p[" useId ".trim().toString()]||(()=>{}),Mx=0;function hn(e){const[t,n]=p.useState(Ox());return bt(()=>{n(r=>r??String(Mx++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[Dx,CC]=fn(Ro),[Lx,Si]=Dx(Ro),Oc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=Kn({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return l.jsx(Lx,{scope:n,disabled:s,contentId:hn(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(we.div,{"data-state":ki(c),"data-disabled":s?"":void 0,...a,ref:t})})});Oc.displayName=Ro;var Mc="CollapsibleTrigger",Dc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Si(Mc,n);return l.jsx(we.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ki(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});Dc.displayName=Mc;var Ci="CollapsibleContent",$x=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Si(Ci,e.__scopeCollapsible);return l.jsx(Bt,{present:n||o.open,children:({present:s})=>l.jsx(Fx,{...r,ref:t,present:s})})});$x.displayName=Ci;var Fx=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Si(Ci,n),[a,c]=p.useState(r),u=p.useRef(null),d=Me(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),b=m.current,w=i.open||a,g=p.useRef(w),x=p.useRef(void 0);return p.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),bt(()=>{const v=u.current;if(v){x.current=x.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const y=v.getBoundingClientRect();f.current=y.height,m.current=y.width,g.current||(v.style.transitionDuration=x.current.transitionDuration,v.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(we.div,{"data-state":ki(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!w,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:w&&o})});function ki(e){return e?"open":"closed"}var zx=Oc;const Lc=zx,$c=Dc,Hr=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Hr.displayName="Card";const Ur=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Ur.displayName="CardHeader";const Wr=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Wr.displayName="CardTitle";const Fc=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Fc.displayName="CardDescription";const Po=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));Po.displayName="CardContent";const zc=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));zc.displayName="CardFooter";function Bc(){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 qn=Bc();function Bx(e){qn=e}const Hc=/[&<>"']/,Hx=new RegExp(Hc.source,"g"),Uc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Ux=new RegExp(Uc.source,"g"),Wx={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Wc=e=>Wx[e];function Nt(e,t){if(t){if(Hc.test(e))return e.replace(Hx,Wc)}else if(Uc.test(e))return e.replace(Ux,Wc);return e}const Vx=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Vc(e){return e.replace(Vx,(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 Kx=/(^|[^\[])\^/g;function Je(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(Kx,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const qx=/[^\w:]/g,Gx=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Kc(e,t,n){if(e){let r;try{r=decodeURIComponent(Vc(n)).replace(qx,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!Gx.test(n)&&(n=Zx(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},Yx=/^[^:]+:\/*[^/]*$/,Xx=/^([^:]+:)[\s\S]*$/,Jx=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Zx(e,t){Oo[" "+e]||(Yx.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(Xx,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(Jx,"$1")+t:e+t}const Mo={exec:function(){}};function qc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),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 Qx(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 ev(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 Gc(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Yc(e,t,n,r){const o=t.href,s=t.title?Nt(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:Nt(i)}}function tv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const it=Ne.slice(0,pt);Ne=Ne.slice(pt+2);const dt=Hm(it);if(!dt)continue;let at;try{at=JSON.parse(dt)}catch{console.debug("[use-chat] malformed SSE:",dt.slice(0,200));continue}const Fe=Bm(at)?at.data:at;ce=Date.now(),O==null||O(Fe);const Y=Fe.seq;if(Y!==void 0){if(Y<=j)continue;j>0&&Y>j+1&&((L=R==null?void 0:R.onGap)==null||L.call(R,{from:j,to:Y})),j=Y,E.current=Y,w(Y)}if(Fe.type==="token"&&e.autoAppendAssistant!==!1)B.push(Fe.content),ue();else if(Fe.type==="message_delta"){const re=Fe.delta.filter(he=>he.type==="text").map(he=>he.text).join("");re&&e.autoAppendAssistant!==!1&&(B.push(re),ue())}else H!==null&&cancelAnimationFrame(H),ee(),Fe.type==="checkpoint"?m(Fe.checkpointId):Fe.type==="error"&&u(Fe.message)}}ee()}catch(ke){if(ke.name!=="AbortError"){const be=ke.message||String(ke);u(be),(A=R==null?void 0:R.onError)==null||A.call(R,be)}}finally{try{await pe.cancel()}catch{}finally{(q=pe.releaseLock)==null||q.call(pe)}H!==null&&typeof window<"u"&&window.cancelAnimationFrame(H),clearInterval(Oe),a(!1),x(!1),v.current=null}}catch(se){if(se.name!=="AbortError"){const te=se.message||String(se);u(te),(J=R==null?void 0:R.onError)==null||J.call(R,te)}}finally{a(!1),x(!1),v.current=null}})(),{close:()=>$.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var _;S.current=!1,(_=v.current)==null||_.abort()},[]),{isStreaming:i,error:c,assistantText:d,lastCheckpointId:h,lastSeq:b,connected:g,stream:N,stop:k,clear:I,setToken:C}}function Bm(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Hm(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
+ `)}function Um(e){return e.type!=="thread_info"&&e.type!=="token"}const Wm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Vm(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 Pl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Pl(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 Rl(e=[]){const[t,n]=y.useReducer(Vm,{...Wm,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]),c=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:c}),[c]);return{state:t,dispatch:n,...u}}function Pl(e,t){var n;if(t.type==="message_start"&&t.role==="assistant"){const r=t.id,o=Xm(t.model);if(e.messages.some(a=>a.id===r))return{...e,assemblingId:r};const i={id:r,role:"assistant",name:o||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:r,messages:[...e.messages,i]}}if(t.type==="message_delta"){const r=e.assemblingId??Xs(e.messages);return r?{...e,messages:Js(e.messages,r,t.delta)}:e}if(t.type==="message_end"){const r=e.assemblingId??Xs(e.messages);if(!r)return{...e,assemblingId:null};const o=e.messages,s=o.findIndex(i=>i.id===r&&i.role==="assistant");if(s>=0&&!((n=o[s].content)==null?void 0:n.some(c=>{var u;return(c==null?void 0:c.type)==="text"&&((u=c.text)==null?void 0:u.trim())}))){const c=[...o.slice(0,s),...o.slice(s+1)];return{...e,assemblingId:null,messages:c}}return e}if(t.type==="tool_start"){const r=`tool-${t.id}`,o={type:"tool_call",id:t.id,name:t.name,args:t.args};if(e.messages.find(a=>a.id===r))return{...e,toolIndex:{...e.toolIndex,[t.id]:r}};const i={id:r,role:"tool",name:t.name,createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,i],toolIndex:{...e.toolIndex,[t.id]:r}}}if(t.type==="tool_result"){const r=e.toolIndex[t.id]??`tool-${t.id}`,o={type:"tool_result",toolCallId:t.id,output:t.output,error:t.error},s=e.messages.find(c=>c.id===r),i={id:r,role:"tool",content:[o],createdAt:new Date().toISOString()},a=s?Js(e.messages,r,[o]):[...e.messages,i];return{...e,messages:a}}if(t.type==="checkpoint"){const r=t.checkpointNs??e.lastCheckpointNs??null,o=Ym(e.messages,t.checkpointId,r);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:r,messages:o}}if(t.type==="branch"){const r=t.checkpointId??e.lastCheckpointId,o=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:r??null,lastCheckpointNs:o??null}}if(t.type==="error"){const r={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,r]}}if(t.type==="interrupt"){const r=e.assemblingId??Xs(e.messages),o={type:"interrupt",value:t.value};if(r)return{...e,assemblingId:null,messages:Js(e.messages,r,[o]),pendingInterrupt:{id:t.id,value:t.value}};const s={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[o]};return{...e,messages:[...e.messages,s],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 qm(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 Km(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 Km(e,t,r=>({...r,content:Gm(r.content,n)}))}function Gm(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1];(o==null?void 0:o.type)==="text"?o.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Ym(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 qm(e,r,s)}return e}function Xm(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Jm(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 Zm(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Qm(e,t=[],n,r,o,s){const i=[],a=[];for(const c of t)try{const u=await Zm(c);a.push({filename:c.name,data:u,mime_type:c.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}const eg={MODE:"library"};function tg(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Ps&&Ps.tagName.toUpperCase()==="SCRIPT"&&Ps.src||new URL("index.umd.js",document.baseURI).href}<"u"?eg:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function Zs(){return!tg()}function ng({currentThreadId:e,messageCount:t,setCurrentThreadId:n,markThreadRefreshPending:r,skipNextLoadRef:o}){return y.useCallback(s=>{const i=s.threadId,a=!!s.created,c=!!s.ready;if(e!==i){const u=!e&&t<=1;u&&(o.current=i),n(i),(c||a||u)&&r();return}(c||a)&&r()},[e,r,t,n,o])}function rg(e){const t=e.seq;return typeof t=="number"&&Number.isFinite(t)?t:null}function og({onThreadInfo:e,onMessageEvent:t,onUnhandledEvent:n,onSequenceGap:r}){const o=y.useRef(null),s=y.useCallback(a=>{const c=rg(a);if(c!==null){const u=o.current;if(u!==null){if(c<=u){Zs()&&console.debug("[StreamEventCoordinator] drop out-of-order seq",{prev:u,seq:c,type:a.type});return}c>u+1&&(r==null||r({from:u,to:c}))}o.current=c}if(a.type==="thread_info"){e==null||e(a);return}if(Um(a)){t(a);return}n==null||n(a)},[t,r,e,n]),i=y.useCallback(()=>{o.current=null},[]);return{handleEvent:s,reset:i}}const Ol=y.createContext(null);function xo({children:e,apiConfig:t,onError:n,onThreadChange:r,initialThreadId:o=null,autoLoadInitial:s=!0,disableAutoRestore:i=!1,enableFileAgentRouting:a=!1,fileAgentId:c="invoice_reader"}){const u=yn;y.useEffect(()=>{t&&u.updateConfig({baseUrl:t.baseUrl,authToken:t.apiKey})},[u,t]);const{isStreaming:d,error:f,stream:h,stop:m,setToken:b}=_l({baseUrl:u.baseUrl,token:null,headers:t==null?void 0:t.headers,streamPath:"/chat/runs/stream"}),[w,g]=y.useState(()=>typeof u.getAuthToken=="function"?u.getAuthToken():null);y.useEffect(()=>{b(typeof u.getAuthToken=="function"?u.getAuthToken():null);const D=u.onTokenChange(Z=>{g(Z),b(Z)});return()=>{D()}},[u,b]);const x=y.useCallback(D=>{u.setAuthToken(D)},[u]),{state:v,dispatch:S,seed:E,prepend:C,pushUser:k,onEvent:I,reset:N}=Rl(),_=20,[O,R]=y.useState(!1),[$,K]=y.useState(!1),[M,W]=y.useState(null),[U,V]=y.useState(void 0),[L,A]=y.useState(void 0),q=y.useRef(!1),J=y.useRef([]),se=y.useRef(null),te=y.useCallback(D=>{D.cursor!==void 0&&W(D.cursor),D.hasMore!==void 0&&R(D.hasMore),D.checkpointId!==void 0&&V(D.checkpointId),D.checkpointNs!==void 0&&A(D.checkpointNs)},[]),pe=y.useCallback((D,Z)=>new Promise((Re,Ke)=>{const vt=async()=>{if(q.current){console.warn(`[ChatProvider] Operation "${Z}" queued - another operation in progress`),J.current.push(vt);return}q.current=!0;try{console.log(`[ChatProvider] Executing operation: ${Z}`),await D(),Re()}catch(X){console.error(`[ChatProvider] Operation "${Z}" failed:`,X),Ke(X)}finally{q.current=!1;const X=J.current.shift();X&&X().catch(()=>{})}};q.current?(J.current.push(vt),console.log(`[ChatProvider] Queued operation: ${Z}`)):vt().catch(X=>{Ke(X)})}),[]),Ie=y.useCallback((D,Z)=>{const Re=Array.isArray(D==null?void 0:D.messages)?D.messages:[];Z==="replace"?(console.log("[ChatProvider] Replacing messages, count:",Re.length),E(Re,{checkpointId:(D==null?void 0:D.checkpointId)??null,checkpointNs:(D==null?void 0:D.checkpointNs)??null})):Z==="prepend"&&Re.length?(console.log("[ChatProvider] Calling prepend with",Re.length,"messages"),C(Re)):console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"),W((D==null?void 0:D.nextCursor)??null),R(!!(D!=null&&D.hasMore)),V(Ke=>(D==null?void 0:D.checkpointId)??Ke??void 0),A(Ke=>(D==null?void 0:D.checkpointNs)??Ke??void 0)},[E,C]),[Ne,B]=y.useState([]),[j,H]=y.useState(null),[ee,ue]=y.useState(!1),[ce,Oe]=y.useState(!1),Ge=y.useRef(!1),ke=y.useCallback(()=>{Ge.current=!0},[]),be=y.useCallback(async()=>{ue(!0);try{const D=await u.listThreads();B(D)}finally{ue(!1)}},[u]),Ue=ng({currentThreadId:j,messageCount:v.messages.length,setCurrentThreadId:H,markThreadRefreshPending:ke,skipNextLoadRef:se}),[Ye,$e]=y.useState(!1),st=y.useCallback(async D=>{const Z=(D==null?void 0:D.maxAttempts)??5,Re=(D==null?void 0:D.baseDelayMs)??500,Ke=(D==null?void 0:D.timeoutMs)??2e3;if(!u.baseUrl)return!1;const vt=u.baseUrl.replace(/\/+$/,""),X=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],fe=async Pe=>{try{const ye=new AbortController,et=setTimeout(()=>ye.abort(),Ke),wt=await fetch(Pe,{method:"GET",signal:ye.signal});return clearTimeout(et),wt.ok}catch{return!1}},je=async Pe=>{try{const ye=new AbortController,et=setTimeout(()=>ye.abort(),Ke),wt=await fetch(Pe,{method:"HEAD",signal:ye.signal});return clearTimeout(et),wt.ok}catch{return!1}};for(let Pe=0;Pe<Z;Pe++){console.debug(`[ChatProvider] health-check attempt ${Pe+1}/${Z}`);for(const et of X){let wt=et;vt.endsWith("/api")&&et.startsWith("/api")&&(wt=et.replace(/^\/api/,"")||"/");const bn=wt==="/"?vt+"/":vt+wt;if(console.debug(`[ChatProvider] checking ${bn}`),await fe(bn)||et==="/"&&await je(vt+"/"))return $e(!0),!0}const ye=Re*Math.pow(2,Pe);await new Promise(et=>setTimeout(et,ye))}return $e(!1),!1},[u.baseUrl]);y.useEffect(()=>{let D=!0;if(!u.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const Z=await st();if(!D)return;Z?be().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{D=!1}},[be,u.baseUrl,st]),y.useEffect(()=>{r==null||r(j)},[j,r]);const pt=y.useRef(null);y.useEffect(()=>{if(o&&s){if(!u.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!Ye){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}pt.current!==o&&(pt.current=o,Y(o).catch(()=>{}))}},[o,s,u.baseUrl,Ye]);const it=y.useRef(null),dt=y.useRef(null),at=y.useRef(null),Fe=y.useRef({count:0,checkpointId:null,checkpointNs:null});y.useEffect(()=>{at.current=j},[j]),y.useEffect(()=>{Fe.current={count:v.messages.length,checkpointId:v.lastCheckpointId,checkpointNs:v.lastCheckpointNs}},[v.messages.length,v.lastCheckpointId,v.lastCheckpointNs]);const Y=y.useCallback(async(D,Z,Re,Ke=!1)=>{await pe(async()=>{if(se.current===D){console.log(`[ChatProvider] Skipping auto-load for thread ${D} - suppressed after clear`),se.current=null;return}if(!u.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(it.current){console.warn(`[ChatProvider] Thread load cancelled - another thread (${it.current}) is loading`);return}const vt=dt.current!==null&&dt.current!==D,X=dt.current===D||at.current===D,fe=Z!==void 0||Re!==void 0,je=Fe.current.count>0,Pe=Fe.current.checkpointId!==null||Fe.current.checkpointNs!==null;if(!Ke&&!vt&&X&&!fe&&!Pe&&je){console.debug("[ChatProvider] Fast-return loadThread - reusing existing messages for thread",D),H(D),dt.current=D;return}vt&&(console.log(`[ChatProvider] Thread switch detected: ${dt.current} -> ${D}`),N([])),it.current=D,dt.current=D;try{Oe(!0),te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),H(D);const ye=await u.getMessages({threadId:D,checkpointId:Z,checkpointNs:Re,limit:_}),et=Array.isArray(ye==null?void 0:ye.messages)?ye.messages:[];console.log("[ChatProvider] Loading thread with",et.length,"messages"),E(et,{checkpointId:(ye==null?void 0:ye.checkpointId)??null,checkpointNs:(ye==null?void 0:ye.checkpointNs)??null}),W((ye==null?void 0:ye.nextCursor)??null),R(!!(ye!=null&&ye.hasMore)),V(wt=>(ye==null?void 0:ye.checkpointId)??wt??void 0),A(wt=>(ye==null?void 0:ye.checkpointNs)??wt??void 0)}finally{it.current=null,Oe(!1)}},`loadThread-${D}`)},[u,pe,te,E]),re=y.useCallback(({from:D,to:Z})=>{const Re=at.current;Re&&(Zs()&&console.warn(`[ChatProvider] Stream sequence gap detected (${D} -> ${Z}) for thread ${Re}`),Y(Re,void 0,void 0,!0).catch(()=>{}))},[Y]),{handleEvent:he,reset:We}=og({onThreadInfo:Ue,onMessageEvent:I,onUnhandledEvent:D=>{Zs()&&console.warn(`[ChatProvider] Unhandled stream event type: ${D.type}`,D)},onSequenceGap:re}),Xe=y.useCallback(async D=>{const Z=await u.listCheckpoints(D);return Jm(Z,D)},[u]),Qe=y.useCallback(async(D,Z)=>{await pe(async()=>{if(!j)throw new Error("No active thread");te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),Oe(!0);try{const Re=await u.getMessages({threadId:j,checkpointId:D,checkpointNs:Z??void 0,limit:_});Ie(Re,"replace")}finally{Oe(!1)}},`navigateToCheckpoint-${D}`)},[u,j,Ie,pe,te,_]),yt=y.useCallback(async()=>{if(!j)throw new Error("No active thread");await Y(j,void 0,void 0,!0)},[j,Y]),lt=y.useRef(!1);y.useEffect(()=>{const D=lt.current;lt.current=d,D&&!d&&j&&Ge.current&&pe(async()=>{try{await be()}catch(Z){console.warn("[ChatProvider] Post-streaming thread refresh failed:",Z)}finally{Ge.current=!1}},"postStreamingRefresh")},[d,j,be,pe]);const mt=y.useCallback(async()=>{console.log("[ChatProvider] 🔄 clearCurrentThread called"),console.log("[ChatProvider] 📊 Before clear - currentThreadId:",j),console.log("[ChatProvider] 📊 Before clear - messages count:",v.messages.length),j&&(se.current=j,console.log(`[ChatProvider] 🚫 Suppressing next auto-load for thread: ${j}`)),await pe(()=>(console.log("[ChatProvider] 🚀 Executing atomic clear operation"),H(null),N([]),te({cursor:null,hasMore:!1,checkpointId:void 0,checkpointNs:void 0}),typeof window<"u"&&localStorage.removeItem("currentThreadId"),console.log("[ChatProvider] ✅ Atomic clear operation completed"),Promise.resolve()),"clearCurrentThread"),console.log("[ChatProvider] 📊 After clear - currentThreadId should be null")},[N,te,j,v.messages.length,pe]),Kt=y.useCallback(async D=>{mt();let Z=null;try{return Z=await u.createThread(D),B(Re=>[...Re.filter(vt=>vt.threadId!==Z.threadId),Z]),await Y(Z.threadId),Z.threadId}catch(Re){if(await be(),Z!=null&&Z.threadId)try{return await Y(Z.threadId),Z.threadId}catch(Ke){console.error("[ChatProvider] Failed to load thread after refresh",Ke)}throw Re}},[u,be,Y,mt]),On=y.useCallback(async D=>{try{await u.deleteThread(D),B(Z=>Z.filter(Re=>Re.threadId!==D)),j===D&&(H(null),N([]),R(!1),W(null),V(void 0),A(void 0))}catch(Z){throw await be(),Z}},[u,be,j,N]),no=y.useCallback(async(D,Z)=>{try{await u.updateThread(D,Z),B(Re=>Re.map(Ke=>Ke.threadId===D?{...Ke,title:Z}:Ke))}catch(Re){throw await be(),Re}},[u,be]),er=y.useCallback(async(D,Z)=>{var Gt;const Re=(Z==null?void 0:Z.attachments)||[],{contentParts:Ke,filesInfo:vt}=await Qm(u,Re,t==null?void 0:t.uploadPath),X=[];D&&D.trim()&&X.push({type:"text",text:D.trim()});const fe={id:((Gt=crypto.randomUUID)==null?void 0:Gt.call(crypto))||`user-${Date.now()}`,role:"user",content:X,createdAt:new Date().toISOString(),checkpointId:(Z==null?void 0:Z.checkpointId)??v.lastCheckpointId??void 0,checkpointNs:(Z==null?void 0:Z.checkpointNs)??v.lastCheckpointNs??void 0};k(fe);const je={...fe,content:X},Pe={...(Z==null?void 0:Z.payloadExtras)??{}},ye=!!Pe.edit,et=Pe.originalMessageId,wt=typeof et=="string"?et:void 0,bn=Re&&Re.length>0,yr={...j?{threadId:j}:{},payload:{messages:[je],files_info:vt,...a&&bn&&c?{active_agent:c}:{},...Pe},checkpointId:(Z==null?void 0:Z.checkpointId)??v.lastCheckpointId??void 0,checkpointNs:(Z==null?void 0:Z.checkpointNs)??v.lastCheckpointNs??void 0,nodeFilter:Z==null?void 0:Z.nodeFilter,config:Z==null?void 0:Z.config,edit:ye,originalMessageId:wt};We(),ke(),h(yr,T=>{he(T)},{onError:T=>console.warn("stream error",T),onOpen:({threadId:T,created:z})=>{if(!j&&T){const ne=v.messages.length<=1;ne&&(se.current=T),H(T),(z||ne)&&ke()}},onGap:re})},[j,k,h,he,We,re,v.lastCheckpointId,v.lastCheckpointNs,u,t==null?void 0:t.uploadPath,ke,H,a,c,v.messages.length]),br=y.useCallback(async D=>{if(!j)throw new Error("No active thread");if($||!O)return;const Z=M;if(Z){K(!0);try{const Re=await u.getMessages({threadId:j,checkpointId:U,checkpointNs:L,limit:(D==null?void 0:D.limit)??_,beforeId:Z});Ie(Re,"prepend")}finally{K(!1)}}},[u,j,U,L,M,O,$,Ie,_]),gn=y.useCallback(async(D,Z,Re)=>{if(!j)throw new Error("No active thread to handle interrupt");try{console.log(`[ChatProvider] Handling interrupt ${D}: ${Z?"approved":"rejected"}`);const Ke=!!Z;await u.resume({threadId:j,value:Ke}),console.log(`[ChatProvider] Interrupt ${D} handled successfully`),S({type:"interrupt_response",payload:{interruptId:D}})}catch(Ke){throw console.error(`[ChatProvider] Failed to handle interrupt ${D}:`,Ke),Ke}},[u,j]),tr={baseUrl:u.baseUrl,token:w,setToken:x,api:u,threads:Ne,currentThreadId:j,setCurrentThreadId:H,isLoadingThreads:ee,isLoadingThread:ce,messages:v.messages,isStreaming:d,error:f,lastCheckpointId:v.lastCheckpointId,lastCheckpointNs:v.lastCheckpointNs,streamingAssistantId:v.assemblingId,hasMoreHistory:O,isLoadingHistory:$,loadOlderMessages:br,historyPageSize:_,listCheckpoints:Xe,navigateToCheckpoint:Qe,returnToLatest:yt,refreshThreads:be,createThread:Kt,deleteThread:On,renameThread:no,loadThread:Y,clearCurrentThread:mt,send:er,stop:m,handleInterrupt:gn};return l.jsx(Ol.Provider,{value:tr,children:e})}function jr(){const e=y.useContext(Ol);if(!e)throw new Error("useChat must be used within ChatProvider");return e}function Q(...e){return gp.twMerge(mp.clsx(e))}const sg=ro.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"}}),Be=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Mn.Slot:"button";return l.jsx(i,{className:Q(sg({variant:t,size:n,className:e})),ref:s,...o})});Be.displayName="Button";const Ml=p.forwardRef(({className:e,...t},n)=>l.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}));Ml.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:c,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,m]=y.useState(e),[b,w]=y.useTransition(),g=y.useRef(null);y.useEffect(()=>{m(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=y.useCallback(()=>{const N=g.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);y.useEffect(()=>{x()},[x]);const v=y.useCallback(async N=>{N&&N.preventDefault();const _=(h??"").trim();!_&&!f||w(()=>{try{const O=i(_);O&&typeof O.then=="function"?O.then(()=>{m(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(m(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),S=y.useCallback(N=>{m(N.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=y.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),v()):N.key==="Escape"&&t&&(N.preventDefault(),a==null||a())},[v,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 l.jsx("form",{onSubmit:N=>void v(N),className:`w-full ${u}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(Ml,{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"})}),l.jsx("div",{children:r?l.jsx(Be,{type:"button",onClick:()=>{c==null||c()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!c,children:l.jsx(oe.Square,{size:16})}):l.jsx(Be,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||b,children:l.jsx(oe.Send,{size:16})})})]})})}const ag=y.memo(ig),vo=0,Sn=1,ir=2,Dl=4;function Ll(e){return()=>e}function lg(e){e()}function $l(e,t){return n=>e(t(n))}function Fl(e,t){return()=>e(t)}function cg(e,t){return n=>e(t,n)}function Qs(e){return e!==void 0}function ug(...e){return()=>{e.map(lg)}}function ar(){}function wo(e,t){return t(e),e}function dg(e,t){return t(e)}function nt(...e){return e}function Ve(e,t){return e(Sn,t)}function Ae(e,t){e(vo,t)}function ei(e){e(ir)}function ut(e){return e(Dl)}function de(e,t){return Ve(e,cg(t,vo))}function Jt(e,t){const n=e(Sn,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 Bl(e,t){return e===t}function rt(e=Bl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ve(e){return t=>n=>{e(n)&&t(n)}}function ie(e){return t=>$l(t,e)}function on(e){return t=>()=>{t(e)}}function F(e,...t){const n=fg(...t);return(r,o)=>{switch(r){case ir:ei(e);return;case Sn:return Ve(e,n(o))}}}function sn(e,t){return n=>r=>{n(t=e(t,r))}}function Fn(e){return t=>n=>{e>0?e--:t(n)}}function xn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...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);Ve(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function fg(...e){return t=>e.reduceRight(dg,t)}function hg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Sn:return s?n===s?void 0:(r(),n=s,t=Ve(e,s),t):(r(),ar);case ir:r(),n=null;return}}}function G(e){let t=e;const n=Le();return(r,o)=>{switch(r){case vo:t=o;break;case Sn:{o(t);break}case Dl:return t}return n(r,o)}}function kt(e,t){return wo(G(t),n=>de(e,n))}function Le(){const e=[];return(t,n)=>{switch(t){case vo:e.slice().forEach(r=>{r(n)});return;case ir:e.splice(0,e.length);return;case Sn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Dt(e){return wo(Le(),t=>de(e,t))}function He(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:pg(),singleton:n}}const pg=()=>Symbol();function mg(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function ht(...e){const t=Le(),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);Ve(s,c=>{n[i]=c,r=r|a,r===o&&Ae(t,n)})}),function(s,i){switch(s){case ir:{ei(t);return}case Sn:return r===o&&i(n),Ve(t,i)}}}function xe(e,t=Bl){return F(e,rt(t))}function ti(...e){return function(t,n){switch(t){case ir:return;case Sn:return ug(...e.map(r=>Ve(r,n)))}}}var Rt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Rt||{});const gg={0:"debug",3:"error",1:"log",2:"warn"},xg=()=>typeof globalThis>"u"?window:globalThis,Cn=He(()=>{const e=G(3);return{log:G((t,n,r=1)=>{var o;const s=(o=xg().VIRTUOSO_LOG_LEVEL)!=null?o:ut(e);r>=s&&console[gg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function zn(e,t,n){return ni(e,t,n).callbackRef}function ni(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 vg(e,t,n,r,o,s,i,a,c){const u=y.useCallback(d=>{const f=wg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const m=h.lastElementChild.dataset.viewportType==="window";let b;m&&(b=h.ownerDocument.defaultView);const w=i?a?i.scrollLeft:i.scrollTop:m?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:m?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:m?a?b.innerWidth:b.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:x}),s==null||s(a?Hl("column-gap",getComputedStyle(d).columnGap,o):Hl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ni(u,n,c)}function wg(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 c=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},Rt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Hl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Rt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Ul(e,t,n){const r=y.useRef(null),o=y.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const m=t.getBoundingClientRect(),b=u.top-m.top;h=m.height-Math.max(0,b),f=b+t.scrollTop}else{const m=i.current.ownerDocument.defaultView;h=m.innerHeight-Math.max(0,u.top),f=u.top+m.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ni(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var c;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=(c=i.current)==null?void 0:c.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 It=He(()=>{const e=Le(),t=Le(),n=G(0),r=Le(),o=G(0),s=Le(),i=Le(),a=G(0),c=G(0),u=G(0),d=G(0),f=Le(),h=Le(),m=G(!1),b=G(!1),w=G(!1);return de(F(e,ie(({scrollTop:g})=>g)),t),de(F(e,ie(({scrollHeight:g})=>g)),i),de(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:m,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),_r={lvl:0};function Wl(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Je(e){return e===_r}function Rr(e,t){if(!Je(e))return t===e.k?e.v:t<e.k?Rr(e.l,t):Rr(e.r,t)}function Zt(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=Zt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Zt(e.l,t,n)}function Lt(e,t,n){return Je(e)?Kl(t,n,1):t===e.k?xt(e,{k:t,v:n}):t<e.k?Gl(xt(e,{l:Lt(e.l,t,n)})):Gl(xt(e,{r:Lt(e.r,t,n)}))}function lr(){return _r}function bo(e,t,n){if(Je(e))return[];const r=Zt(e,t)[0];return bg(oi(e,r,n))}function ri(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]=ql(r);return yo(xt(e,{k:s,l:Vl(r),v:i}))}}else return t<n?yo(xt(e,{l:ri(r,t)})):yo(xt(e,{r:ri(o,t)}))}function Bn(e){return Je(e)?[]:[...Bn(e.l),{k:e.k,v:e.v},...Bn(e.r)]}function oi(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(oi(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(oi(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(si(t))return Yl(xt(e,{lvl:n-1}));if(!Je(t)&&!Je(t.r))return xt(t.r,{l:xt(t,{r:t.r.l}),lvl:n,r:xt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(si(e))return ii(xt(e,{lvl:n-1}));if(!Je(r)&&!Je(r.l)){const o=r.l,s=si(o)?r.lvl-1:r.lvl;return xt(o,{l:xt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ii(xt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function xt(e,t){return Kl(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 Vl(e){return Je(e.r)?e.l:yo(xt(e,{r:Vl(e.r)}))}function si(e){return Je(e)||e.lvl>e.r.lvl}function ql(e){return Je(e.r)?[e.k,e.v]:ql(e.r)}function Kl(e,t,n,r=_r,o=_r){return{k:e,l:r,lvl:n,r:o,v:t}}function Gl(e){return ii(Yl(e))}function Yl(e){const{l:t}=e;return!Je(t)&&t.lvl===e.lvl?xt(t,{r:xt(e,{l:t.r})}):e}function ii(e){const{lvl:t,r:n}=e;return!Je(n)&&!Je(n.r)&&n.lvl===t&&n.r.lvl===t?xt(n,{l:xt(e,{r:n.l}),lvl:t+1}):e}function bg(e){return Wl(e,({k:t,v:n})=>({index:t,value:n}))}function Xl(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 ai=He(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function Jl(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 yg(e,t,n,r){const o=So(e,t,r),s=So(e,n,r,o);return e.slice(o,s+1)}function kn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Co(e){return!Je(e.groupOffsetTree)}function li({index:e},t){return t===e?0:t<e?-1:1}function Sg(){return{groupIndices:[],groupOffsetTree:lr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:lr()}}function Cg(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=Lt(e,0,s);continue}const a=bo(e,i-1,o+1);if(a.some(jg(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=ri(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=Lt(e,o+1,h));u&&(e=Lt(e,i,s))}return[e,n]}function kg(e){return typeof e.groupIndex<"u"}function Tg({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}=Jl(t,e,li),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Zl(e,t){if(!Co(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Ql(e,t,n){if(kg(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Zl(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Eg(e,t,n,r=0){return r>0&&(t=Math.max(t,Jl(e,r,li).offset)),Wl(yg(e,t,n,Tg),Ag)}function Ig(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Rt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Je(s)&&t.length===2){const h=t[0].size,m=t[1].size;i=n.reduce((b,w)=>Lt(Lt(b,w,h),w+1,m),i)}else[i,a]=Cg(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ci(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,m)=>Lt(h,m,Or(m,f,o)),lr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Ng(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 ec(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 ci(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=So(o,t-1,li),a=o[c].offset;const u=Zt(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===Zt(n,t)[1]&&(c-=1),o=o.slice(0,c+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 Ag(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 _g={offsetHeight:"height",offsetWidth:"width"},an=He(([{log:e},{recalcInProgress:t}])=>{const n=Le(),r=Le(),o=kt(r,0),s=Le(),i=Le(),a=G(0),c=G([]),u=G(void 0),d=G(void 0),f=G((C,k)=>kn(C,_g[k])),h=G(void 0),m=G(0),b=Sg(),w=kt(F(n,_e(c,e,m),sn(Ig,b),rt()),b),g=kt(F(c,rt(),sn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ie(({prev:C})=>C)),[]);de(F(c,ve(C=>C.length>0),_e(w,m),ie(([C,k,I])=>{const N=C.reduce((_,O,R)=>Lt(_,O,Or(O,k.offsetTree,I)||R),lr());return{...k,groupIndices:C,groupOffsetTree:N}})),w),de(F(r,_e(w),ve(([C,{lastIndex:k}])=>C<k),ie(([C,{lastIndex:k,lastSize:I}])=>[{endIndex:k,size:I,startIndex:C}])),n),de(u,d);const x=kt(F(u,ie(C=>C===void 0)),!0);de(F(d,ve(C=>C!==void 0&&Je(ut(w).sizeTree)),ie(C=>[{endIndex:0,size:C,startIndex:0}])),n);const v=Dt(F(n,_e(w),sn(({sizes:C},[k,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:b}),ie(C=>C.changed)));Ve(F(a,sn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ie(C=>C.diff)),C=>{const{groupIndices:k}=ut(w);if(C>0)Ae(t,!0),Ae(s,C+ec(C,k));else if(C<0){const I=ut(g);I.length>0&&(C-=ec(-C,I)),Ae(i,C)}}),Ve(F(a,_e(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},Rt.ERROR)});const S=Dt(s);de(F(s,_e(w),ie(([C,k])=>{const I=k.groupIndices.length>0,N=[],_=k.lastSize;if(I){const O=Rr(k.sizeTree,0);let R=0,$=0;for(;R<C;){const M=k.groupIndices[$],W=k.groupIndices.length===$+1?1/0:k.groupIndices[$+1]-M-1;N.push({endIndex:M,size:O,startIndex:M}),N.push({endIndex:M+1+W-1,size:_,startIndex:M+1}),$++,R+=W+1}const K=Bn(k.sizeTree);return R!==C&&K.shift(),K.reduce((M,{k:W,v:U})=>{let V=M.ranges;return M.prevSize!==0&&(V=[...M.ranges,{endIndex:W+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+C,prevSize:U,ranges:V}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return Bn(k.sizeTree).reduce((O,{k:R,v:$})=>({prevIndex:R+C,prevSize:$,ranges:[...O.ranges,{endIndex:R+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const E=Dt(F(i,_e(w,m),ie(([C,{offsetTree:k},I])=>{const N=-C;return Or(N,k,I)})));return de(F(i,_e(w,m),ie(([C,k,I])=>{if(k.groupIndices.length>0){if(Je(k.sizeTree))return k;let N=lr();const _=ut(g);let O=0,R=0,$=0;for(;O<-C;){$=_[R];const K=_[R+1]-$-1;R++,O+=K+1}if(N=Bn(k.sizeTree).reduce((K,{k:M,v:W})=>Lt(K,Math.max(0,M+C),W),N),O!==-C){const K=Rr(k.sizeTree,$);N=Lt(N,0,K);const M=Zt(k.sizeTree,-C+1)[1];N=Lt(N,1,M)}return{...k,sizeTree:N,...ci(k.offsetTree,0,N,I)}}else{const N=Bn(k.sizeTree).reduce((_,{k:O,v:R})=>Lt(_,Math.max(0,O+C),R),lr());return{...k,sizeTree:N,...ci(k.offsetTree,0,N,I)}}})),w),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:m,groupIndices:c,itemSize:f,listRefresh:v,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},nt(Cn,ai),{singleton:!0});function Rg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const tc=He(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Le(),i=Le(),a=Dt(F(s,ie(Rg)));return de(F(a,ie(c=>c.totalCount)),n),de(F(a,ie(c=>c.groupIndices)),e),de(F(ht(o,t,r),ve(([c,u])=>Co(u)),ie(([c,u,d])=>Zt(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),rt(),ie(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},nt(an,It)),Tn=He(([{log:e}])=>{const t=G(!1),n=Dt(F(t,ve(r=>r),rt()));return Ve(t,r=>{r&&ut(e)("props updated",{},Rt.DEBUG)}),{didMount:n,propsReady:t}},nt(Cn),{singleton:!0}),Pg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function nc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Pg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Mr=He(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const m=Le(),b=Le(),w=G(0);let g=null,x=null,v=null;function S(){g&&(g(),g=null),v&&(v(),v=null),x&&(clearTimeout(x),x=null),Ae(c,!1)}return de(F(m,_e(n,f,r,w,a,i,h),_e(e,s,o),ie(([[E,C,k,I,N,_,O,R],$,K,M])=>{const W=nc(E),{align:U,behavior:V,offset:L}=W,A=I-1,q=Ql(W,C,A);let J=Or(q,C.offsetTree,$)+_;U==="end"?(J+=K+Zt(C.sizeTree,q)[1]-k+M,q===A&&(J+=O)):U==="center"?J+=(K+Zt(C.sizeTree,q)[1]-k+M)/2:J-=N,L&&(J+=L);const se=te=>{S(),te?(R("retrying to scroll to",{location:E},Rt.DEBUG),Ae(m,E)):(Ae(b,!0),R("list did not change, scroll successful",{},Rt.DEBUG))};if(S(),V==="smooth"){let te=!1;v=Ve(t,pe=>{te=te||pe}),g=Jt(d,()=>{se(te)})}else g=Jt(F(t,Og(150)),se);return x=setTimeout(()=>{S()},1200),Ae(c,!0),R("scrolling from index to",{behavior:V,index:q,top:J},Rt.DEBUG),{behavior:V,top:J}})),u),{scrollTargetReached:b,scrollToIndex:m,topListHeight:w}},nt(an,It,Cn),{singleton:!0});function Og(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ui(e,t){e==0?t():requestAnimationFrame(()=>{ui(e-1,t)})}function di(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Dr=He(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=G(!0),c=G(0),u=G(!0);return de(F(i,_e(c),ve(([d,f])=>!!f),on(!1)),a),de(F(i,_e(c),ve(([d,f])=>!!f),on(!1)),u),Ve(F(ht(t,i),_e(a,n,e,u),ve(([[,d],f,{sizeTree:h},m,b])=>d&&(!Je(h)||Qs(m))&&!f&&!b),_e(c)),([,d])=>{Jt(o,()=>{Ae(u,!0)}),ui(4,()=>{Jt(r,()=>{Ae(a,!0)}),Ae(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},nt(an,It,Mr,Tn),{singleton:!0});function rc(e,t){return Math.abs(e-t)<1.01}const Lr="up",$r="down",Mg="none",Dg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Lg=0,Fr=He(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=G(!1),a=G(!0),c=Le(),u=Le(),d=G(4),f=G(Lg),h=kt(F(ti(F(xe(o),Fn(1),on(!0)),F(xe(o),Fn(1),on(!1),zl(100))),rt()),!1),m=kt(F(ti(F(n,on(!0)),F(n,on(!1),zl(200))),rt()),!1);de(F(ht(xe(o),xe(f)),ie(([v,S])=>v<=S),rt()),a),de(F(a,xn(50)),u);const b=Dt(F(ht(r,xe(s),xe(t),xe(e),xe(d)),sn((v,[{scrollHeight:S,scrollTop:E},C,k,I,N])=>{const _=E+C-S>-N,O={scrollHeight:S,scrollTop:E,viewportHeight:C};if(_){let $,K;return E>v.state.scrollTop?($="SCROLLED_DOWN",K=v.state.scrollTop-E):($="SIZE_DECREASED",K=v.state.scrollTop-E||v.scrollTopDelta),{atBottom:!0,atBottomBecause:$,scrollTopDelta:K,state:O}}let R;return O.scrollHeight>v.state.scrollHeight?R="SIZE_INCREASED":C<v.state.viewportHeight?R="VIEWPORT_HEIGHT_DECREASING":E<v.state.scrollTop?R="SCROLLING_UPWARDS":R="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:O}},Dg),rt((v,S)=>v&&v.atBottom===S.atBottom))),w=kt(F(r,sn((v,{scrollHeight:S,scrollTop:E,viewportHeight:C})=>{if(rc(v.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:E};{const k=S-(E+C)<1;return v.scrollTop!==E&&k?{changed:!0,jump:v.scrollTop-E,scrollHeight:S,scrollTop:E}:{changed:!0,jump:0,scrollHeight:S,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ve(v=>v.changed),ie(v=>v.jump)),0);de(F(b,ie(v=>v.atBottom)),i),de(F(i,xn(50)),c);const g=G($r);de(F(r,ie(({scrollTop:v})=>v),rt(),sn((v,S)=>ut(m)?{direction:v.direction,prevScrollTop:S}:{direction:S<v.prevScrollTop?Lr:$r,prevScrollTop:S},{direction:$r,prevScrollTop:0}),ie(v=>v.direction)),g),de(F(r,xn(50),on(Mg)),g);const x=G(0);return de(F(h,ve(v=>!v),on(0)),x),de(F(o,xn(100),_e(h),ve(([v,S])=>!!S),sn(([v,S],[E])=>[S,E],[0,0]),ie(([v,S])=>S-v)),x),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:x}},nt(It)),ko="top",To="bottom",oc="none";function sc(e,t,n){return typeof e=="number"?n===Lr&&t===ko||n===$r&&t===To?e:0:n===Lr?t===ko?e.main:e.reverse:t===To?e.main:e.reverse}function ic(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const fi=He(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Le(),i=G(0),a=G(0),c=G(0),u=kt(F(ht(xe(r),xe(o),xe(n),xe(s,Pr),xe(c),xe(i),xe(t),xe(e),xe(a)),ie(([d,f,h,[m,b],w,g,x,v,S])=>{const E=d-v,C=g+x,k=Math.max(h-E,0);let I=oc;const N=ic(S,ko),_=ic(S,To);return m-=v,m+=h+x,b+=h+x,b-=v,m>d+C-N&&(I=Lr),b<d-k+f+_&&(I=$r),I!==oc?[Math.max(E-h-sc(w,ko,I)-N,0),E-k-x+f+sc(w,To,I)+_]:null}),ve(d=>d!=null),rt(Pr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},nt(It),{singleton:!0});function $g(e,t,n){if(Co(t)){const r=Zl(e,t);return[{index:Zt(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 hi={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:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const f=n-i,h=a+f*c+(f-1)*r,m=u,b=h-d;return{bottom:d,firstItemIndex:s,items:lc(e,o,s),offsetBottom:b,offsetTop:u,top:m,topItems:lc(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function ac(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,c=di(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Eo(u,[],a,o,n,r)}function lc(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,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Hn=He(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:m},{recalcInProgress:b}])=>{const w=G([]),g=G(0),x=Le();de(s.topItemsIndexes,w);const v=kt(F(ht(m,b,xe(c,Pr),xe(o),xe(r),xe(u),d,xe(w),xe(t),xe(n),e),ve(([k,I,,N,,,,,,,_])=>{const O=_&&_.length!==N;return k&&!I&&!O}),ie(([,,[k,I],N,_,O,R,$,K,M,W])=>{const U=_,{offsetTree:V,sizeTree:L}=U,A=ut(g);if(N===0)return{...hi,totalCount:N};if(k===0&&I===0)return A===0?{...hi,totalCount:N}:ac(A,O,_,K,M,W||[]);if(Je(L))return A>0?null:Eo($g(di(O,N),U,W),[],N,M,U,K);const q=[];if($.length>0){const Ie=$[0],Ne=$[$.length-1];let B=0;for(const j of bo(L,Ie,Ne)){const H=j.value,ee=Math.max(j.start,Ie),ue=Math.min(j.end,Ne);for(let ce=ee;ce<=ue;ce++)q.push({data:W==null?void 0:W[ce],index:ce,offset:B,size:H}),B+=H}}if(!R)return Eo([],q,N,M,U,K);const J=$.length>0?$[$.length-1]+1:0,se=Eg(V,k,I,J);if(se.length===0)return null;const te=N-1,pe=wo([],Ie=>{for(const Ne of se){const B=Ne.value;let j=B.offset,H=Ne.start;const ee=B.size;if(B.offset<k){H+=Math.floor((k-B.offset+M)/(ee+M));const ce=H-Ne.start;j+=ce*ee+ce*M}H<J&&(j+=(J-H)*ee,H=J);const ue=Math.min(Ne.end,te);for(let ce=H;ce<=ue&&!(j>=I);ce++)Ie.push({data:W==null?void 0:W[ce],index:ce,offset:j,size:ee}),j+=ee+M}});return Eo(pe,q,N,M,U,K)}),ve(k=>k!==null),rt()),hi);de(F(e,ve(Qs),ie(k=>k==null?void 0:k.length)),o),de(F(v,ie(k=>k.topListHeight)),f),de(f,a),de(F(v,ie(k=>[k.top,k.bottom])),i),de(F(v,ie(k=>k.items)),x);const S=Dt(F(v,ve(({items:k})=>k.length>0),_e(o,e),ve(([{items:k},I])=>k[k.length-1].originalIndex===I-1),ie(([,k,I])=>[k-1,I]),rt(Pr),ie(([k])=>k))),E=Dt(F(v,xn(200),ve(({items:k,topItems:I})=>k.length>0&&k[0].originalIndex===I.length),ie(({items:k})=>k[0].index),rt())),C=Dt(F(v,ve(({items:k})=>k.length>0),ie(({items:k})=>{let I=0,N=k.length-1;for(;k[I].type==="group"&&I<N;)I++;for(;k[N].type==="group"&&N>I;)N--;return{endIndex:k[N].index,startIndex:k[I].index}}),rt(Xl)));return{endReached:S,initialItemCount:g,itemsRendered:x,listState:v,rangeChanged:C,startReached:E,topItemsIndexes:w,...h}},nt(an,tc,fi,Dr,Mr,Fr,Tn,ai),{singleton:!0}),cc=He(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Le(),i=kt(F(ht(n,e,r,t,o),ie(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return de(xe(i),s),{totalListHeight:i,totalListHeightChanged:s}},nt(It,Hn),{singleton:!0}),Fg=He(([{viewportHeight:e},{totalListHeight:t}])=>{const n=G(!1),r=kt(F(ht(n,e,t),ve(([o])=>o),ie(([,o,s])=>Math.max(0,o-s)),xn(0),rt()),0);return{alignToBottom:n,paddingTopAddition:r}},nt(It,cc),{singleton:!0}),uc=He(()=>({context:G(null)})),zg=({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,dc=He(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=Le();return de(F(d,_e(t,c,n,s,o,r,a),_e(e),ie(([[f,h,m,b,w,g,x,v],S])=>{const{align:E,behavior:C,calculateViewLocation:k=zg,done:I,...N}=f,_=Ql(f,h,b-1),O=Or(_,h.offsetTree,S)+w+g,R=O+Zt(h.sizeTree,_)[1],$=v+g,K=v+m-x,M=k({itemBottom:R,itemTop:O,locationParams:{align:E,behavior:C,...N},viewportBottom:K,viewportTop:$});return M?I&&Jt(F(i,ve(W=>!W),Fn(ut(i)?1:2)),I):I&&I(),M}),ve(f=>f!==null)),u),{scrollIntoView:d}},nt(an,It,Mr,Hn,Cn),{singleton:!0});function fc(e){return e?e==="smooth"?"smooth":"auto":!1}const Bg=(e,t)=>typeof e=="function"?fc(e(t)):t&&fc(e),Hg=He(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:m}])=>{const b=G(!1),w=Le();let g=null;function x(C){Ae(i,{align:"end",behavior:C,index:"LAST"})}Ve(F(ht(F(xe(t),Fn(1)),c),_e(xe(b),s,a,f),ie(([[C,k],I,N,_,O])=>{let R=k&&_,$="auto";return R&&($=Bg(I,N||O),R=R&&!!$),{followOutputBehavior:$,shouldFollow:R,totalCount:C}}),ve(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:k},Rt.DEBUG),x(C)}):g=Jt(e,()=>{ut(d)("following output to ",{totalCount:k},Rt.DEBUG),x(C),g=null})});function v(C){const k=Jt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ut(d)("scrolling to bottom due to increased size",{},Rt.DEBUG),x("auto"))});setTimeout(k,100)}Ve(F(ht(xe(b),t,u),ve(([C,,k])=>C&&k),sn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),ve(({refreshed:C})=>C),_e(b,t)),([,C])=>{ut(a)&&v(C!==!1)}),Ve(w,()=>{v(ut(b)!==!1)}),Ve(ht(xe(b),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const S=G(null),E=Le();return de(ti(F(xe(r),ie(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),F(xe(t))),E),Ve(F(ht(F(E,Fn(1)),c),_e(xe(S),a,f,h),ie(([[C,k],I,N,_,O])=>k&&N&&(I==null?void 0:I({context:O,totalCount:C,scrollingInProgress:_}))),ve(C=>!!C),xn(0)),C=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Ae(m,C)}):g=Jt(e,()=>{ut(d)("scrolling into view",{}),Ae(m,C),g=null})}),{autoscrollToBottom:w,followOutput:b,scrollIntoViewOnChange:S}},nt(an,Fr,Mr,Dr,Tn,Cn,It,uc,dc)),Ug=He(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(de(F(a,_e(s),ve(([,c])=>c!==0),_e(o,r,t,n,e),ie(([[,c],u,d,f,h,m=[]])=>ac(c,u,d,f,h,m))),i),{}),nt(an,Dr,Hn,Tn),{singleton:!0}),Wg=He(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=G(0);return Ve(F(e,_e(r),ve(([,o])=>o!==0),ie(([,o])=>({top:o}))),o=>{Jt(F(n,Fn(1),ve(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ae(t,o)})})}),{initialScrollTop:r}},nt(Tn,It,Hn),{singleton:!0}),hc=He(([{scrollVelocity:e}])=>{const t=G(!1),n=Le(),r=G(!1);return de(F(e,_e(r,t,n),ve(([o,s])=>!!s),ie(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),rt()),t),Ve(F(ht(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},nt(Fr),{singleton:!0}),pi=He(([{scrollContainerState:e,scrollTo:t}])=>{const n=Le(),r=Le(),o=Le(),s=G(!1),i=G(void 0);return de(F(ht(n,r),ie(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),de(F(t,_e(r),ie(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},nt(It)),Vg=He(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=Le(),d=G(void 0),f=G(null),h=G(null);return de(a,f),de(c,h),Ve(F(u,_e(t,r,i,f,h,n)),([m,b,w,g,x,v,S])=>{const E=Ng(b.sizeTree);g&&x!==null&&v!==null&&(w=x.scrollTop-v.offsetTop),w-=S,m({ranges:E,scrollTop:w})}),de(F(d,ve(Qs),ie(qg)),o),de(F(s,_e(d),ve(([,m])=>m!==void 0),rt(),ie(([,m])=>m.ranges)),e),{getState:u,restoreStateFrom:d}},nt(an,It,Dr,Tn,pi));function qg(e){return{align:"start",index:0,offset:e.scrollTop}}const Kg=He(([{topItemsIndexes:e}])=>{const t=G(0);return de(F(t,ve(n=>n>=0),ie(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},nt(Hn));function pc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Gg=pc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Yg=He(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:m},{recalcInProgress:b}])=>{const w=Dt(F(c,_e(i),sn(([,x,v,S],[{bottom:E,items:C,offsetBottom:k,totalCount:I},N])=>{const _=E+k;let O=0;return v===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(O=_-S,O!==0&&(O+=N))),[O,C,I,_]},[0,[],0,0]),ve(([x])=>x!==0),_e(r,a,n,o,m,b),ve(([,x,v,S,,,E])=>!E&&!S&&x!==0&&v===Lr),ie(([[x],,,,,v])=>(v("Upward scrolling compensation",{amount:x},Rt.DEBUG),x))));function g(x){x>0?(Ae(t,{behavior:"auto",top:-x}),Ae(e,0)):(Ae(e,0),Ae(t,{behavior:"auto",top:-x}))}return Ve(F(w,_e(e,s)),([x,v,S])=>{S&&Gg()?Ae(e,v-x):g(-x)}),Ve(F(ht(kt(s,!1),e,b),ve(([x,v,S])=>!x&&!S&&v!==0),ie(([x,v])=>v),xn(1)),g),de(F(f,ie(x=>({top:-x}))),t),Ve(F(u,_e(h,d),ie(([x,{groupIndices:v,lastSize:S,sizeTree:E},C])=>{function k(I){return I*(S+C)}if(v.length===0)return k(x);{let I=0;const N=Rr(E,0);let _=0,O=0;for(;_<x;){_++,I+=N;let R=v.length===O+1?1/0:v[O+1]-v[O]-1;_+R>x&&(I-=N,R=x-_+1),_+=R,I+=k(R),O++}return I}})),x=>{Ae(e,x),requestAnimationFrame(()=>{Ae(t,{top:x}),requestAnimationFrame(()=>{Ae(e,0),Ae(b,!1)})})}),{deviation:e}},nt(It,Fr,Hn,an,Cn,ai)),Xg=He(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),nt(fi,Ug,Tn,hc,cc,Wg,Fg,pi,dc,Cn,uc)),mc=He(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b},w,g,x,{listState:v,topItemsIndexes:S,...E},{scrollToIndex:C},k,{topItemCount:I},{groupCounts:N},_])=>(de(E.rangeChanged,_.scrollSeekRangeChanged),de(F(_.windowViewportRect,ie(O=>O.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:h,initialTopMostItemIndex:m,scrolledToInitialItem:b,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...x,groupIndices:s,itemSize:i,listState:v,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,..._,...w,sizes:c,...g}),nt(an,Dr,It,Vg,Hg,Hn,Mr,Yg,Kg,tc,Xg));function Jg(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 gc(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 c(g,x){g.propsReady&&Ae(g.propsReady,!1);for(const v of r){const S=g[t.required[v]];Ae(S,x[v])}for(const v of o)if(v in x){const S=g[t.optional[v]];Ae(S,x[v])}g.propsReady&&Ae(g.propsReady,!0)}function u(g){return s.reduce((x,v)=>(x[v]=S=>{const E=g[t.methods[v]];Ae(E,S)},x),{})}function d(g){return i.reduce((x,v)=>(x[v]=hg(g[t.events[v]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:v,...S}=g,[E]=y.useState(()=>wo(mg(e),I=>{c(I,S)})),[C]=y.useState(Fl(d,E));Io(()=>{for(const I of i)I in S&&Ve(C[I],S[I]);return()=>{Object.values(C).map(ei)}},[S,C,E]),Io(()=>{c(E,S)}),y.useImperativeHandle(x,Ll(u(E)));const k=n;return l.jsx(a.Provider,{value:E,children:n?l.jsx(k,{...Jg([...r,...o,...i],S),children:v}):v})}),h=g=>{const x=y.useContext(a);return y.useCallback(v=>{Ae(x[g],v)},[x,g])},m=g=>{const x=y.useContext(a)[g],v=y.useCallback(S=>Ve(x,S),[x]);return y.useSyncExternalStore(v,()=>ut(x),()=>ut(x))},b=g=>{const x=y.useContext(a)[g],[v,S]=y.useState(Fl(ut,x));return Io(()=>Ve(x,E=>{E!==v&&S(Ll(E))}),[x,v]),v},w=y.version.startsWith("18")?m:b;return{Component:f,useEmitter:(g,x)=>{const v=y.useContext(a)[g];Io(()=>Ve(v,x),[x,v])},useEmitterValue:w,usePublisher:h}}const xc=y.createContext(void 0),vc=y.createContext(void 0),wc=typeof document<"u"?y.useLayoutEffect:y.useEffect;function mi(e){return"self"in e}function Zg(e){return"body"in e}function bc(e,t,n,r=ar,o,s){const i=y.useRef(null),a=y.useRef(null),c=y.useRef(null),u=y.useCallback(h=>{let m,b,w;const g=h.target;if(Zg(g)||mi(g)){const v=mi(g)?g:g.defaultView;w=s?v.scrollX:v.scrollY,m=s?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,b=s?v.innerWidth:v.innerHeight}else w=s?g.scrollLeft:g.scrollTop,m=s?g.scrollWidth:g.scrollHeight,b=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:m,scrollTop:Math.max(w,0),viewportHeight:b})};h.suppressFlushSync?x():Rs.flushSync(x),a.current!==null&&(w===a.current||w<=0||w===m-b)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.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 m=i.current;if(!m||(s?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=h.behavior==="smooth";let w,g,x;mi(m)?(g=Math.max(kn(m.document.documentElement,s?"width":"height"),s?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),w=s?m.innerWidth:m.innerHeight,x=s?window.scrollX:window.scrollY):(g=m[s?"scrollWidth":"scrollHeight"],w=kn(m,s?"width":"height"),x=m[s?"scrollLeft":"scrollTop"]);const v=g-w;if(h.top=Math.ceil(Math.max(Math.min(v,h.top),0)),rc(w,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:w}),b&&t(!0);return}b?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),m.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 gi="-webkit-sticky",yc="sticky",xi=pc(()=>{if(typeof document>"u")return yc;const e=document.createElement("div");return e.style.position=gi,e.style.position===gi?gi:yc});function vi(e){return e}const Qg=He(()=>{const e=G(a=>`Item ${a}`),t=G(a=>`Group ${a}`),n=G({}),r=G(vi),o=G("div"),s=G(ar),i=(a,c=null)=>kt(F(n,ie(u=>u[a]),rt()),c);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")}}),ex=He(([e,t])=>({...e,...t}),nt(mc,Qg)),tx=({height:e})=>l.jsx("div",{style:{height:e}}),nx={overflowAnchor:"none",position:xi(),zIndex:1},Sc={overflowAnchor:"none"},rx={...Sc,display:"inline-block",height:"100%"},Cc=y.memo(function({showTopList:e=!1}){const t=Ce("listState"),n=Ht("sizeRanges"),r=Ce("useWindowScroll"),o=Ce("customScrollParent"),s=Ht("windowScrollContainerState"),i=Ht("scrollContainerState"),a=o||r?s:i,c=Ce("itemContent"),u=Ce("context"),d=Ce("groupContent"),f=Ce("trackItemSizes"),h=Ce("itemSize"),m=Ce("log"),b=Ht("gap"),w=Ce("horizontalDirection"),{callbackRef:g}=vg(n,h,f,e?ar:a,m,b,o,w,Ce("skipAnimationFrameInResizeObserver")),[x,v]=y.useState(0);wi("deviation",M=>{x!==M&&v(M)});const S=Ce("EmptyPlaceholder"),E=Ce("ScrollSeekPlaceholder")||tx,C=Ce("ListComponent"),k=Ce("ItemComponent"),I=Ce("GroupComponent"),N=Ce("computeItemKey"),_=Ce("isSeeking"),O=Ce("groupIndices").length>0,R=Ce("alignToBottom"),$=Ce("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:x!==0?x:R?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:R?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...$?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?l.jsx(S,{...Tt(S,u)}):l.jsx(C,{...Tt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:K,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,U=N(W+t.firstItemIndex,M.data,u);return _?y.createElement(E,{...Tt(E,u),height:M.size,index:M.index,key:U,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?y.createElement(I,{...Tt(I,u),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:U,style:nx},d(M.index,u)):y.createElement(k,{...Tt(k,u),...ax(k,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:U,style:w?rx:Sc},O?c(M.index,M.groupIndex,M.data,u):c(M.index,M.data,u))})})}),ox={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},sx={outline:"none",overflowX:"auto",position:"relative"},No=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ix={position:xi(),top:0,width:"100%",zIndex:1};function Tt(e,t){if(typeof e!="string")return{context:t}}function ax(e,t){return{item:typeof e=="string"?void 0:t}}const lx=y.memo(function(){const e=Ce("HeaderComponent"),t=Ht("headerHeight"),n=Ce("HeaderFooterTag"),r=zn(y.useMemo(()=>s=>{t(kn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Tt(e,o)})}):null}),cx=y.memo(function(){const e=Ce("FooterComponent"),t=Ht("footerHeight"),n=Ce("HeaderFooterTag"),r=zn(y.useMemo(()=>s=>{t(kn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Tt(e,o)})}):null});function kc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:m,scrollToCallback:b}=bc(a,u,c,d,void 0,f);return e("scrollTo",b),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...f?sx:ox,...o},tabIndex:0,...i,...Tt(c,s),children:r})})}function Tc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),m=y.useRef(null),b=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:x}=bc(a,u,c,b,h);return wc(()=>{var v;return g.current=h||((v=m.current)==null?void 0:v.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",w),l.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Tt(c,s),children:r})})}const ux=({children:e})=>{const t=y.useContext(xc),n=Ht("viewportHeight"),r=Ht("fixedItemHeight"),o=Ce("alignToBottom"),s=Ce("horizontalDirection"),i=y.useMemo(()=>$l(n,c=>kn(c,s?"width":"height")),[n,s]),a=zn(i,!0,Ce("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:No(o),children:e})},dx=({children:e})=>{const t=y.useContext(xc),n=Ht("windowViewportRect"),r=Ht("fixedItemHeight"),o=Ce("customScrollParent"),s=Ul(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:No(i),children:e})},fx=({children:e})=>{const t=Ce("TopItemListComponent")||"div",n=Ce("headerHeight"),r={...ix,marginTop:`${n}px`},o=Ce("context");return l.jsx(t,{style:r,...Tt(t,o),children:e})},hx=y.memo(function(e){const t=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,r=Ce("customScrollParent"),o=Ce("context");return l.jsxs(r||t?gx:mx,{...e,context:o,children:[n&&l.jsx(fx,{children:l.jsx(Cc,{showTopList:!0})}),l.jsxs(r||t?dx:ux,{children:[l.jsx(lx,{}),l.jsx(Cc,{}),l.jsx(cx,{})]})]})}),{Component:px,useEmitter:wi,useEmitterValue:Ce,usePublisher:Ht}=gc(ex,{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"}},hx),mx=kc({useEmitter:wi,useEmitterValue:Ce,usePublisher:Ht}),gx=Tc({useEmitter:wi,useEmitterValue:Ce,usePublisher:Ht}),xx=px;nt(mc,He(()=>{const e=G(u=>l.jsxs("td",{children:["Item $",u]})),t=G(null),n=G(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=G(null),o=G(null),s=G({}),i=G(vi),a=G(ar),c=(u,d=null)=>kt(F(s,ie(f=>f[u]),rt()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),xi();const Ec={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},vx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ic,floor:Ao,max:zr,min:bi,round:Nc}=Math;function Ac(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function wx(e){return{...vx,items:e}}function jo(e,t){return e&&e.width===t.width&&e.height===t.height}function bx(e,t){return e&&e.column===t.column&&e.row===t.row}const yx=He(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,m,{didMount:b,propsReady:w},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:v,windowScrollTo:S,windowViewportRect:E},C])=>{const k=G(0),I=G(0),N=G(Ec),_=G({height:0,width:0}),O=G({height:0,width:0}),R=Le(),$=Le(),K=G(0),M=G(null),W=G({column:0,row:0}),U=Le(),V=Le(),L=G(!1),A=G(0),q=G(!0),J=G(!1),se=G(!1);Ve(F(b,_e(A),ve(([j,H])=>!!H)),()=>{Ae(q,!1)}),Ve(F(ht(b,q,O,_,A,J),ve(([j,H,ee,ue,,ce])=>j&&!H&&ee.height!==0&&ue.height!==0&&!ce)),([,,,,j])=>{Ae(J,!0),ui(1,()=>{Ae(R,j)}),Jt(F(u),()=>{Ae(t,[0,0]),Ae(q,!0)})}),de(F(V,ve(j=>j!=null&&j.scrollTop>0),on(0)),I),Ve(F(b,_e(V),ve(([,j])=>j!=null)),([,j])=>{j&&(Ae(_,j.viewport),Ae(O,j.item),Ae(W,j.gap),j.scrollTop>0&&(Ae(L,!0),Jt(F(u,Fn(1)),H=>{Ae(L,!1)}),Ae(c,{top:j.scrollTop})))}),de(F(_,ie(({height:j})=>j)),f),de(F(ht(xe(_,jo),xe(O,jo),xe(W,(j,H)=>j&&j.column===H.column&&j.row===H.row),xe(u)),ie(([j,H,ee,ue])=>({gap:ee,item:H,scrollTop:ue,viewport:j}))),U),de(F(ht(xe(k),r,xe(W,bx),xe(O,jo),xe(_,jo),xe(M),xe(I),xe(L),xe(q),xe(A)),ve(([,,,,,,,j])=>!j),ie(([j,[H,ee],ue,ce,Oe,Ge,ke,,be,Ue])=>{const{column:Ye,row:$e}=ue,{height:st,width:pt}=ce,{width:it}=Oe;if(ke===0&&(j===0||it===0))return Ec;if(pt===0){const Qe=di(Ue,j),yt=Qe+Math.max(ke-1,0);return wx(Ac(Qe,yt,Ge))}const dt=jc(it,pt,Ye);let at,Fe;be?H===0&&ee===0&&ke>0?(at=0,Fe=ke-1):(at=dt*Ao((H+$e)/(st+$e)),Fe=dt*Ic((ee+$e)/(st+$e))-1,Fe=bi(j-1,zr(Fe,dt-1)),at=bi(Fe,zr(0,at))):(at=0,Fe=-1);const Y=Ac(at,Fe,Ge),{bottom:re,top:he}=_c(Oe,ue,ce,Y),We=Ic(j/dt),Xe=We*st+(We-1)*$e-re;return{bottom:re,itemHeight:st,items:Y,itemWidth:pt,offsetBottom:Xe,offsetTop:he,top:he}})),N),de(F(M,ve(j=>j!==null),ie(j=>j.length)),k),de(F(ht(_,O,N,W),ve(([j,H,{items:ee}])=>ee.length>0&&H.height!==0&&j.height!==0),ie(([j,H,{items:ee},ue])=>{const{bottom:ce,top:Oe}=_c(j,ue,H,ee);return[Oe,ce]}),rt(Pr)),t);const te=G(!1);de(F(u,_e(te),ie(([j,H])=>H||j!==0)),te);const pe=Dt(F(ht(N,k),ve(([{items:j}])=>j.length>0),_e(te),ve(([[j,H],ee])=>{const ue=j.items[j.items.length-1].index===H-1;return(ee||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===H)&&ue}),ie(([[,j]])=>j-1),rt())),Ie=Dt(F(xe(N),ve(({items:j})=>j.length>0&&j[0].index===0),on(0),rt())),Ne=Dt(F(xe(N),_e(L),ve(([{items:j},H])=>j.length>0&&!H),ie(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),rt(Xl),xn(0)));de(Ne,m.scrollSeekRangeChanged),de(F(R,_e(_,O,k,W),ie(([j,H,ee,ue,ce])=>{const Oe=nc(j),{align:Ge,behavior:ke,offset:be}=Oe;let Ue=Oe.index;Ue==="LAST"&&(Ue=ue-1),Ue=zr(0,Ue,bi(ue-1,Ue));let Ye=yi(H,ce,ee,Ue);return Ge==="end"?Ye=Nc(Ye-H.height+ee.height):Ge==="center"&&(Ye=Nc(Ye-H.height/2+ee.height/2)),be&&(Ye+=be),{behavior:ke,top:Ye}})),c);const B=kt(F(N,ie(j=>j.offsetBottom+j.bottom)),0);return de(F(E,ie(j=>({height:j.visibleHeight,width:j.visibleWidth}))),_),{customScrollParent:g,data:M,deviation:K,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:V,scrollBy:i,scrollContainerState:a,scrollHeight:$,scrollTo:c,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:_,windowScrollContainerState:v,windowScrollTo:S,windowViewportRect:E,...m,gridState:N,horizontalDirection:se,initialTopMostItemIndex:A,totalListHeight:B,...h,endReached:pe,propsReady:w,rangeChanged:Ne,startReached:Ie,stateChanged:U,stateRestoreInProgress:L,...C}},nt(fi,It,Fr,hc,Tn,pi,Cn));function jc(e,t,n){return zr(1,Ao((e+n)/(Ao(t)+n)))}function _c(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=yi(e,t,n,r[0].index);return{bottom:yi(e,t,n,r[r.length-1].index)+o,top:s}}function yi(e,t,n,r){const o=jc(e.width,n.width,t.column),s=Ao(r/o),i=s*n.height+zr(0,s-1)*t.row;return i>0?i+t.row:i}const Sx=He(()=>{const e=G(f=>`Item ${f}`),t=G({}),n=G(null),r=G("virtuoso-grid-item"),o=G("virtuoso-grid-list"),s=G(vi),i=G("div"),a=G(ar),c=(f,h=null)=>kt(F(t,ie(m=>m[f]),rt()),h),u=G(!1),d=G(!1);return de(xe(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),Cx=He(([e,t])=>({...e,...t}),nt(yx,Sx)),kx=y.memo(function(){const e=ot("gridState"),t=ot("listClassName"),n=ot("itemClassName"),r=ot("itemContent"),o=ot("computeItemKey"),s=ot("isSeeking"),i=Ut("scrollHeight"),a=ot("ItemComponent"),c=ot("ListComponent"),u=ot("ScrollSeekPlaceholder"),d=ot("context"),f=Ut("itemDimensions"),h=Ut("gap"),m=ot("log"),b=ot("stateRestoreInProgress"),w=Ut("reportReadyState"),g=zn(y.useMemo(()=>x=>{const v=x.parentElement.parentElement.scrollHeight;i(v);const S=x.firstChild;if(S){const{height:E,width:C}=S.getBoundingClientRect();f({height:E,width:C})}h({column:Pc("column-gap",getComputedStyle(x).columnGap,m),row:Pc("row-gap",getComputedStyle(x).rowGap,m)})},[i,f,h,m]),!0,!1);return wc(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),b?null:l.jsx(c,{className:t,ref:g,...Tt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const v=o(x.index,x.data,d);return s?l.jsx(u,{...Tt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},v):y.createElement(a,{...Tt(a,d),className:n,"data-index":x.index,key:v},r(x.index,x.data,d))})})}),Tx=y.memo(function(){const e=ot("HeaderComponent"),t=Ut("headerHeight"),n=ot("headerFooterTag"),r=zn(y.useMemo(()=>s=>{t(kn(s,"height"))},[t]),!0,!1),o=ot("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Tt(e,o)})}):null}),Ex=y.memo(function(){const e=ot("FooterComponent"),t=Ut("footerHeight"),n=ot("headerFooterTag"),r=zn(y.useMemo(()=>s=>{t(kn(s,"height"))},[t]),!0,!1),o=ot("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Tt(e,o)})}):null}),Ix=({children:e})=>{const t=y.useContext(vc),n=Ut("itemDimensions"),r=Ut("viewportDimensions"),o=zn(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]),l.jsx("div",{ref:o,style:No(!1),children:e})},Nx=({children:e})=>{const t=y.useContext(vc),n=Ut("windowViewportRect"),r=Ut("itemDimensions"),o=ot("customScrollParent"),s=Ul(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]),l.jsx("div",{ref:s,style:No(!1),children:e})},Ax=y.memo(function({...e}){const t=ot("useWindowScroll"),n=ot("customScrollParent"),r=n||t?_x:jx,o=n||t?Nx:Ix,s=ot("context");return l.jsx(r,{...e,...Tt(r,s),children:l.jsxs(o,{children:[l.jsx(Tx,{}),l.jsx(kx,{}),l.jsx(Ex,{})]})})}),{useEmitter:Rc,useEmitterValue:ot,usePublisher:Ut}=gc(Cx,{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"}},Ax),jx=kc({useEmitter:Rc,useEmitterValue:ot,usePublisher:Ut}),_x=Tc({useEmitter:Rc,useEmitterValue:ot,usePublisher:Ut});function Pc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Rt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Rx=ro.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 Si({className:e,variant:t,...n}){return l.jsx("div",{className:Q(Rx({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 Px(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,c=p.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=p.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 ln(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:m,...b}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=p.useMemo(()=>b,Object.values(b));return l.jsx(w.Provider,{value:g,children:m})};u.displayName=s+"Provider";function d(f,h){var w;const m=((w=h==null?void 0:h[e])==null?void 0:w[c])||a,b=p.useContext(m);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Ox(o,...t)]}function Ox(...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:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var bt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Mx=p[" useInsertionEffect ".trim().toString()]||bt;function Un({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Dx({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=p.useRef(e!==void 0);p.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=p.useCallback(d=>{var f;if(a){const h=Lx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Dx({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Mx(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Lx(e){return typeof e=="function"}function Oc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ci(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Oc(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():Oc(e[o],null)}}}}function Me(...e){return p.useCallback(Ci(...e),e)}var $x=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],we=$x.reduce((e,t)=>{const n=Mn.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Mc(e,t){e&&oo.flushSync(()=>e.dispatchEvent(t))}function Fx(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var $t=e=>{const{present:t,children:n}=e,r=zx(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Me(r.ref,Bx(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};$t.displayName="Presence";function zx(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Fx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const u=_o(r.current);s.current=a==="mounted"?u:"none"},[a]),bt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,m=_o(u);e?c("MOUNT"):m==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==m?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),bt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=m=>{const w=_o(r.current).includes(CSS.escape(m.animationName));if(m.target===t&&w&&(c("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=m=>{m.target===t&&(s.current=_o(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 c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function _o(e){return(e==null?void 0:e.animationName)||"none"}function Bx(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 Hx=p[" useId ".trim().toString()]||(()=>{}),Ux=0;function cn(e){const[t,n]=p.useState(Hx());return bt(()=>{n(r=>r??String(Ux++))},[e]),e||(t?`radix-${t}`:"")}var Ro="Collapsible",[Wx,_C]=ln(Ro),[Vx,ki]=Wx(Ro),Dc=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=Un({prop:r,defaultProp:o??!1,onChange:i,caller:Ro});return l.jsx(Vx,{scope:n,disabled:s,contentId:cn(),open:c,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),children:l.jsx(we.div,{"data-state":Ei(c),"data-disabled":s?"":void 0,...a,ref:t})})});Dc.displayName=Ro;var Lc="CollapsibleTrigger",$c=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ki(Lc,n);return l.jsx(we.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ei(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:le(e.onClick,o.onOpenToggle)})});$c.displayName=Lc;var Ti="CollapsibleContent",qx=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ki(Ti,e.__scopeCollapsible);return l.jsx($t,{present:n||o.open,children:({present:s})=>l.jsx(Kx,{...r,ref:t,present:s})})});qx.displayName=Ti;var Kx=p.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=ki(Ti,n),[a,c]=p.useState(r),u=p.useRef(null),d=Me(t,u),f=p.useRef(0),h=f.current,m=p.useRef(0),b=m.current,w=i.open||a,g=p.useRef(w),x=p.useRef(void 0);return p.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),bt(()=>{const v=u.current;if(v){x.current=x.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const S=v.getBoundingClientRect();f.current=S.height,m.current=S.width,g.current||(v.style.transitionDuration=x.current.transitionDuration,v.style.animationName=x.current.animationName),c(r)}},[i.open,r]),l.jsx(we.div,{"data-state":Ei(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!w,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:w&&o})});function Ei(e){return e?"open":"closed"}var Gx=Dc;const Fc=Gx,zc=$c,Br=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Q("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Br.displayName="Card";const Hr=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Q("flex flex-col space-y-1.5 p-6",e),...t}));Hr.displayName="CardHeader";const Ur=p.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:Q("text-2xl font-semibold leading-none tracking-tight",e),...t}));Ur.displayName="CardTitle";const Bc=p.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Bc.displayName="CardDescription";const Po=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Q("p-6 pt-0",e),...t}));Po.displayName="CardContent";const Hc=p.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:Q("flex items-center p-6 pt-0",e),...t}));Hc.displayName="CardFooter";function Uc(){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 Wn=Uc();function Yx(e){Wn=e}const Wc=/[&<>"']/,Xx=new RegExp(Wc.source,"g"),Vc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Jx=new RegExp(Vc.source,"g"),Zx={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},qc=e=>Zx[e];function Et(e,t){if(t){if(Wc.test(e))return e.replace(Xx,qc)}else if(Vc.test(e))return e.replace(Jx,qc);return e}const Qx=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Kc(e){return e.replace(Qx,(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 ev=/(^|[^\[])\^/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(ev,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const tv=/[^\w:]/g,nv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Gc(e,t,n){if(e){let r;try{r=decodeURIComponent(Kc(n)).replace(tv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!nv.test(n)&&(n=iv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Oo={},rv=/^[^:]+:\/*[^/]*$/,ov=/^([^:]+:)[\s\S]*$/,sv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function iv(e,t){Oo[" "+e]||(rv.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(ov,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(sv,"$1")+t:e+t}const Mo={exec:function(){}};function Yc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),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 av(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 lv(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 Xc(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Jc(e,t,n,r){const o=t.href,s=t.title?Et(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:Et(i)}}function cv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
39
39
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
40
- `)}class Ti{constructor(t){this.options=t||qn}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,`
41
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=tv(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,c,u,d,f,h,m,b,w=n[1].trim();const g=w.length>1,x={type:"list",raw:"",ordered:g,start:g?+w.slice(0,-1):"",loose:!1,items:[]};w=g?`\\d{1,9}\\${w.slice(-1)}`:`\\${w}`,this.options.pedantic&&(w=g?w:"[*+-]");const v=new RegExp(`^( {0,3}${w})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(b=!1,!(!(n=v.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
40
+ `)}class Ii{constructor(t){this.options=t||Wn}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,`
41
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=cv(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,c,u,d,f,h,m,b,w=n[1].trim();const g=w.length>1,x={type:"list",raw:"",ordered:g,start:g?+w.slice(0,-1):"",loose:!1,items:[]};w=g?`\\d{1,9}\\${w.slice(-1)}`:`\\${w}`,this.options.pedantic&&(w=g?w:"[*+-]");const v=new RegExp(`^( {0,3}${w})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(b=!1,!(!(n=v.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
42
42
  `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
43
43
  `,1)[0],this.options.pedantic?(i=2,m=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,m=d.slice(i),i+=n[1].length),c=!1,!d&&/^ *$/.test(f)&&(r+=f+`
44
44
  `,t=t.substring(f.length+1),b=!0),!b){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(`
45
45
  `,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())m+=`
46
46
  `+f.slice(i);else{if(c||d.search(/[^ ]/)>=4||k.test(d)||I.test(d)||C.test(d))break;m+=`
47
47
  `+f}!c&&!f.trim()&&(c=!0),r+=h+`
48
- `,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(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.trimRight(),x.raw=x.raw.trimRight();const y=x.items.length;for(a=0;a<y;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<y;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]):Nt(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:qc(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
- `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;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]=qc(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(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
- `?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:Nt(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]):Nt(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=Qx(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).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)),Yc(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 Yc(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,c,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(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}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=Nt(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=Nt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Nt(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=Nt(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=Nt(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]):Nt(r[0]):r[0]:o=Nt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const me={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]+/};me._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Je(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.listItemStart=Je(/^( *)(bull) */).replace("bull",me.bullet).getRegex(),me.list=Je(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._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",me._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,me.html=Je(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Je(me._paragraph).replace("hr",me.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",me._tag).getRegex(),me.blockquote=Je(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal={...me},me.gfm={...me.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},me.gfm.table=Je(me.gfm.table).replace("hr",me.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",me._tag).getRegex(),me.gfm.paragraph=Je(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",me.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",me._tag).getRegex(),me.pedantic={...me.normal,html:Je(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._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:Je(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",me.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=Je(ae.punctuation).replace(/punctuation/g,ae._punctuation).getRegex(),ae.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ae.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ae._comment=Je(me._comment).replace("(?:-->|$)","-->").getRegex(),ae.emStrong.lDelim=Je(ae.emStrong.lDelim).replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimAst=Je(ae.emStrong.rDelimAst,"g").replace(/punct/g,ae._punctuation).getRegex(),ae.emStrong.rDelimUnd=Je(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=Je(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=Je(ae.tag).replace("comment",ae._comment).replace("attribute",ae._attribute).getRegex(),ae._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ae._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ae._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ae.link=Je(ae.link).replace("label",ae._label).replace("href",ae._href).replace("title",ae._title).getRegex(),ae.reflink=Je(ae.reflink).replace("label",ae._label).replace("ref",me._label).getRegex(),ae.nolink=Je(ae.nolink).replace("ref",me._label).getRegex(),ae.reflinkSearch=Je(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:Je(/^!?\[(label)\]\((.*?)\)/).replace("label",ae._label).getRegex(),reflink:Je(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ae._label).getRegex()},ae.gfm={...ae.normal,escape:Je(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=Je(ae.gfm.url,"i").replace("email",ae.gfm._extended_email).getRegex(),ae.breaks={...ae.gfm,br:Je(ae.br).replace("{2,}","*").getRegex(),text:Je(ae.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function nv(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 Xc(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 jn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||qn,this.options.tokenizer=this.options.tokenizer||new Ti,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:me.normal,inline:ae.normal};this.options.pedantic?(n.block=me.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=me.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:me,inline:ae}}static lex(t,n){return new jn(n).lex(t)}static lexInline(t,n){return new jn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
48
+ `,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(m),o&&(s=o[0]!=="[ ] ",m=m.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:m}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=m.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]):Et(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:Yc(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
+ `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;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]=Yc(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(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
+ `?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:Et(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]):Et(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=av(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).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)),Jc(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 Jc(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,c,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(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const b=h.slice(1,-1);return{type:"em",raw:h,text:b,tokens:this.lexer.inlineTokens(b)}}const m=h.slice(2,-2);return{type:"strong",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}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=Et(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=Et(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Et(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=Et(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=Et(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]):Et(r[0]):r[0]:o=Et(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const me={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]+/};me._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Ze(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.listItemStart=Ze(/^( *)(bull) */).replace("bull",me.bullet).getRegex(),me.list=Ze(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._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",me._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,me.html=Ze(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Ze(me._paragraph).replace("hr",me.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",me._tag).getRegex(),me.blockquote=Ze(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal={...me},me.gfm={...me.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},me.gfm.table=Ze(me.gfm.table).replace("hr",me.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",me._tag).getRegex(),me.gfm.paragraph=Ze(me._paragraph).replace("hr",me.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",me.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",me._tag).getRegex(),me.pedantic={...me.normal,html:Ze(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._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(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
51
+ ]`).replace("lheading",me.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(me._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",me._label).getRegex(),ae.nolink=Ze(ae.nolink).replace("ref",me._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 uv(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 Zc(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 En{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Wn,this.options.tokenizer=this.options.tokenizer||new Ii,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:me.normal,inline:ae.normal};this.options.pedantic?(n.block=me.pedantic,n.inline=ae.pedantic):this.options.gfm&&(n.block=me.gfm,this.options.breaks?n.inline=ae.breaks:n.inline=ae.gfm),this.tokenizer.rules=n}static get rules(){return{block:me,inline:ae}}static lex(t,n){return new En(n).lex(t)}static lexInline(t,n){return new En(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
52
52
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c,u)=>c+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
53
53
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
54
54
  `+r.raw,o.text+=`
@@ -58,9 +58,9 @@ React keys must be passed directly to JSX without using spread:
58
58
  `+r.raw,o.text+=`
59
59
  `+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+=`
60
60
  `+r.raw,o.text+=`
61
- `+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,c,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)+"["+Gc("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)+"["+Gc("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(c||(u=""),c=!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,Xc)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Xc))){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(m){h=m.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,nv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!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 Ei{constructor(t){this.options=t||qn}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$/,"")+`
62
- `,o?'<pre><code class="'+this.options.langPrefix+Nt(o)+'">'+(r?t:Nt(t,!0))+`</code></pre>
63
- `:"<pre><code>"+(r?t:Nt(t,!0))+`</code></pre>
61
+ `+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,c,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)+"["+Xc("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)+"["+Xc("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(c||(u=""),c=!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,Zc)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Zc))){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(m){h=m.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,uv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!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 Ni{constructor(t){this.options=t||Wn}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$/,"")+`
62
+ `,o?'<pre><code class="'+this.options.langPrefix+Et(o)+'">'+(r?t:Et(t,!0))+`</code></pre>
63
+ `:"<pre><code>"+(r?t:Et(t,!0))+`</code></pre>
64
64
  `}blockquote(t){return`<blockquote>
65
65
  ${t}</blockquote>
66
66
  `}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}>
@@ -78,14 +78,14 @@ ${t}</blockquote>
78
78
  `}tablerow(t){return`<tr>
79
79
  ${t}</tr>
80
80
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
81
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Kc(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=Kc(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 Jc{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 Zc{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 _n{constructor(t){this.options=t||qn,this.options.renderer=this.options.renderer||new Ei,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Jc,this.slugger=new Zc}static parse(t,n){return new _n(n).parse(t)}static parseInline(t,n){return new _n(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,u,d,f,h,m,b,w,g,x,v,y,E,C,k;const I=t.length;for(o=0;o<I;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(k=this.options.extensions.renderers[m.type].call({parser:this},m),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=k||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,Vc(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),h="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(m.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(b=m.ordered,w=m.start,g=m.loose,a=m.items.length,h="",s=0;s<a;s++)v=m.items[s],y=v.checked,E=v.task,x="",v.task&&(C=this.renderer.checkbox(y),g?v.tokens.length>0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=C+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=C+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(v.tokens,g),h+=this.renderer.listitem(x,E,y);r+=this.renderer.list(h,b,w);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(h=m.tokens?this.parseInline(m.tokens):m.text;o+1<I&&t[o+1].type==="text";)m=t[++o],h+=`
82
- `+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Lo{constructor(t){this.options=t||qn}preprocess(t){return t}postprocess(t){return t}}dp(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function rv(e,t,n){return r=>{if(r.message+=`
83
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Nt(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 Qc(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.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(ev(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&ge.walkTokens(c,r.walkTokens),h=t(c,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;ge.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,m){if(h)return u(h);m!=null&&m!==f.text&&(f.text=m,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(ge.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ge.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function ge(e,t,n){return Qc(jn.lex,_n.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},Bx(ge.defaults),ge},ge.getDefaults=Bc,ge.defaults=qn,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ge.defaults.renderer||new Ei;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=ge.defaults.tokenizer||new Ti;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=ge.defaults.hooks||new Lo;for(const s in n.hooks){const i=o[s];Lo.passThroughHooks.has(s)?o[s]=a=>{if(ge.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=ge.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=Qc(jn.lexInline,_n.parseInline),ge.Parser=_n,ge.parser=_n.parse,ge.Renderer=Ei,ge.TextRenderer=Jc,ge.Lexer=jn,ge.lexer=jn.lex,ge.Tokenizer=Ti,ge.Slugger=Zc,ge.Hooks=Lo,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,_n.parse,jn.lex;function $o({content:e,className:t="",allowHtml:n=!1}){const r=S.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 ge.parse(o)}return ge.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:X("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function eu(e,t){return await Lt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function tu(e,t){return await(await eu(`/chat/files/${e}/view`,t)).text()}async function ov(e,t){const n=await eu(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Lt(`/chat/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 sv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Lt("/chat/files",{params:r})}const iv=1,av=1e6;let Ii=0;function lv(){return Ii=(Ii+1)%Number.MAX_SAFE_INTEGER,Ii.toString()}const Ni=new Map,nu=e=>{if(Ni.has(e))return;const t=setTimeout(()=>{Ni.delete(e),Vr({type:"REMOVE_TOAST",toastId:e})},av);Ni.set(e,t)},cv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,iv)};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?nu(n):e.toasts.forEach(r=>{nu(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)}}},Fo=[];let zo={toasts:[]};function Vr(e){zo=cv(zo,e),Fo.forEach(t=>{t(zo)})}function uv({...e}){const t=lv(),n=o=>Vr({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Vr({type:"DISMISS_TOAST",toastId:t});return Vr({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ai(){const[e,t]=p.useState(zo);return p.useEffect(()=>(Fo.push(t),()=>{const n=Fo.indexOf(t);n>-1&&Fo.splice(n,1)}),[e]),{...e,toast:uv,dismiss:n=>Vr({type:"DISMISS_TOAST",toastId:n})}}function kt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function dv(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e);p.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 fv="DismissableLayer",ji="dismissableLayer.update",hv="dismissableLayer.pointerDownOutside",pv="dismissableLayer.focusOutside",ru,ou=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=p.useContext(ou),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),b=Me(t,I=>f(I)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(g),v=d?w.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=x,C=xv(I=>{const N=I.target,_=[...u.branches].some(O=>O.contains(N));!E||_||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=vv(I=>{const N=I.target;[...u.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return dv(I=>{v===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(ru=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),su(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=ru)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),su())},[d,u]),p.useEffect(()=>{const I=()=>m({});return document.addEventListener(ji,I),()=>document.removeEventListener(ji,I)},[]),l.jsx(we.div,{...c,ref:b,style:{pointerEvents:y?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=fv;var mv="DismissableLayerBranch",gv=p.forwardRef((e,t)=>{const n=p.useContext(ou),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(we.div,{...e,ref:o})});gv.displayName=mv;function xv(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){iu(hv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 vv(e,t=globalThis==null?void 0:globalThis.document){const n=kt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&iu(pv,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 su(){const e=new CustomEvent(ji);document.dispatchEvent(e)}function iu(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?Pc(o,s):o.dispatchEvent(s)}var _i="focusScope.autoFocusOnMount",Ri="focusScope.autoFocusOnUnmount",au={bubbles:!1,cancelable:!0},wv="FocusScope",Ho=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=p.useState(null),u=kt(o),d=kt(s),f=p.useRef(null),h=Me(t,w=>c(w)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let w=function(y){if(m.paused||!a)return;const E=y.target;a.contains(E)?f.current=E:Rn(f.current,{select:!0})},g=function(y){if(m.paused||!a)return;const E=y.relatedTarget;E!==null&&(a.contains(E)||Rn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const C of y)C.removedNodes.length>0&&Rn(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",g);const v=new MutationObserver(x);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",g),v.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){uu.add(m);const w=document.activeElement;if(!a.contains(w)){const x=new CustomEvent(_i,au);a.addEventListener(_i,u),a.dispatchEvent(x),x.defaultPrevented||(bv(Tv(lu(a)),{select:!0}),document.activeElement===w&&Rn(a))}return()=>{a.removeEventListener(_i,u),setTimeout(()=>{const x=new CustomEvent(Ri,au);a.addEventListener(Ri,d),a.dispatchEvent(x),x.defaultPrevented||Rn(w??document.body,{select:!0}),a.removeEventListener(Ri,d),uu.remove(m)},0)}}},[a,u,d,m]);const b=p.useCallback(w=>{if(!n&&!r||m.paused)return;const g=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,x=document.activeElement;if(g&&x){const v=w.currentTarget,[y,E]=yv(v);y&&E?!w.shiftKey&&x===E?(w.preventDefault(),n&&Rn(y,{select:!0})):w.shiftKey&&x===y&&(w.preventDefault(),n&&Rn(E,{select:!0})):x===v&&w.preventDefault()}},[n,r,m.paused]);return l.jsx(we.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});Ho.displayName=wv;function bv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Rn(r,{select:t}),document.activeElement!==n)return}function yv(e){const t=lu(e),n=cu(t,e),r=cu(t.reverse(),e);return[n,r]}function lu(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(!Sv(n,{upTo:t}))return n}function Sv(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 Cv(e){return e instanceof HTMLInputElement&&"select"in e}function Rn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Cv(e)&&t&&e.select()}}var uu=kv();function kv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=du(e,t),e.unshift(t)},remove(t){var n;e=du(e,t),(n=e[0])==null||n.resume()}}}function du(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Tv(e){return e.filter(t=>t.tagName!=="A")}var Ev="Portal",Uo=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);bt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(l.jsx(we.div,{...r,ref:t}),i):null});Uo.displayName=Ev;var Pi=0;function Oi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??fu()),document.body.insertAdjacentElement("beforeend",e[1]??fu()),Pi++,()=>{Pi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Pi--}},[])}function fu(){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 pn=function(){return pn=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},pn.apply(this,arguments)};function hu(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 Iv(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 Wo="right-scroll-bar-position",Vo="width-before-scroll-bar",Nv="with-scroll-bars-hidden",Av="--removed-body-scroll-bar-size";function Mi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jv(e,t){var n=S.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 _v=typeof window<"u"?p.useLayoutEffect:p.useEffect,pu=new WeakMap;function Rv(e,t){var n=jv(null,function(r){return e.forEach(function(o){return Mi(o,r)})});return _v(function(){var r=pu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Mi(a,null)}),s.forEach(function(a){o.has(a)||Mi(a,i)})}pu.set(n,e)},[e]),n}function Pv(e){return e}function Ov(e,t){t===void 0&&(t=Pv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Mv(e){e===void 0&&(e={});var t=Ov(null);return t.options=pn({async:!0,ssr:!1},e),t}var mu=function(e){var t=e.sideCar,n=hu(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 p.createElement(r,pn({},n))};mu.isSideCarExport=!0;function Dv(e,t){return e.useMedium(t),mu}var gu=Mv(),Di=function(){},Ko=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:Di,onWheelCapture:Di,onTouchMoveCapture:Di}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,b=e.noIsolation,w=e.inert,g=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,y=e.gapMode,E=hu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Rv([n,t]),I=pn(pn({},E),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:gu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:b,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?p.cloneElement(p.Children.only(a),pn(pn({},I),{ref:k})):p.createElement(v,pn({},I,{className:c,ref:k}),a))});Ko.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ko.classNames={fullWidth:Vo,zeroRight:Wo};var Lv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function $v(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Lv();return t&&e.setAttribute("nonce",t),e}function Fv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function zv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Bv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=$v())&&(Fv(t,n),zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Hv=function(){var e=Bv();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},xu=function(){var e=Hv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Uv={left:0,top:0,right:0,gap:0},Li=function(e){return parseInt(e||"",10)||0},Wv=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[Li(n),Li(r),Li(o)]},Vv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Uv;var t=Wv(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])}},Kv=xu(),fr="data-scroll-locked",qv=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
- .`.concat(Nv,` {
81
+ `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Gc(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=Gc(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 Qc{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 eu{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 In{constructor(t){this.options=t||Wn,this.options.renderer=this.options.renderer||new Ni,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Qc,this.slugger=new eu}static parse(t,n){return new In(n).parse(t)}static parseInline(t,n){return new In(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,u,d,f,h,m,b,w,g,x,v,S,E,C,k;const I=t.length;for(o=0;o<I;o++){if(m=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[m.type]&&(k=this.options.extensions.renderers[m.type].call({parser:this},m),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(m.type))){r+=k||"";continue}switch(m.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(m.tokens),m.depth,Kc(this.parseInline(m.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(m.text,m.lang,m.escaped);continue}case"table":{for(f="",d="",a=m.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(m.header[s].tokens),{header:!0,align:m.align[s]});for(f+=this.renderer.tablerow(d),h="",a=m.rows.length,s=0;s<a;s++){for(u=m.rows[s],d="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:m.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(m.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(b=m.ordered,w=m.start,g=m.loose,a=m.items.length,h="",s=0;s<a;s++)v=m.items[s],S=v.checked,E=v.task,x="",v.task&&(C=this.renderer.checkbox(S),g?v.tokens.length>0&&v.tokens[0].type==="paragraph"?(v.tokens[0].text=C+" "+v.tokens[0].text,v.tokens[0].tokens&&v.tokens[0].tokens.length>0&&v.tokens[0].tokens[0].type==="text"&&(v.tokens[0].tokens[0].text=C+" "+v.tokens[0].tokens[0].text)):v.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(v.tokens,g),h+=this.renderer.listitem(x,E,S);r+=this.renderer.list(h,b,w);continue}case"html":{r+=this.renderer.html(m.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(m.tokens));continue}case"text":{for(h=m.tokens?this.parseInline(m.tokens):m.text;o+1<I&&t[o+1].type==="text";)m=t[++o],h+=`
82
+ `+(m.tokens?this.parseInline(m.tokens):m.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const N='Token with "'+m.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Lo{constructor(t){this.options=t||Wn}preprocess(t){return t}postprocess(t){return t}}hp(Lo,"passThroughHooks",new Set(["preprocess","postprocess"]));function dv(e,t,n){return r=>{if(r.message+=`
83
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Et(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 tu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=dv(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(lv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&ge.walkTokens(c,r.walkTokens),h=t(c,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(m){f=m}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!c.length))return u();let d=0;ge.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,m){if(h)return u(h);m!=null&&m!==f.text&&(f.text=m,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(ge.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ge.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function ge(e,t,n){return tu(En.lex,In.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},Yx(ge.defaults),ge},ge.getDefaults=Uc,ge.defaults=Wn,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ge.defaults.renderer||new Ni;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=ge.defaults.tokenizer||new Ii;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=ge.defaults.hooks||new Lo;for(const s in n.hooks){const i=o[s];Lo.passThroughHooks.has(s)?o[s]=a=>{if(ge.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=ge.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=tu(En.lexInline,In.parseInline),ge.Parser=In,ge.parser=In.parse,ge.Renderer=Ni,ge.TextRenderer=Qc,ge.Lexer=En,ge.lexer=En.lex,ge.Tokenizer=Ii,ge.Slugger=eu,ge.Hooks=Lo,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,In.parse,En.lex;function $o({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 ge.parse(o)}return ge.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return l.jsx("div",{className:Q("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function nu(e,t){return await Ot(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function ru(e,t){return await(await nu(`/chat/files/${e}/view`,t)).text()}async function fv(e,t){const n=await nu(`/chat/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Ot(`/chat/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 hv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Ot("/chat/files",{params:r})}const pv=1,mv=1e6;let Ai=0;function gv(){return Ai=(Ai+1)%Number.MAX_SAFE_INTEGER,Ai.toString()}const ji=new Map,ou=e=>{if(ji.has(e))return;const t=setTimeout(()=>{ji.delete(e),Wr({type:"REMOVE_TOAST",toastId:e})},mv);ji.set(e,t)},xv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,pv)};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?ou(n):e.toasts.forEach(r=>{ou(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)}}},Fo=[];let zo={toasts:[]};function Wr(e){zo=xv(zo,e),Fo.forEach(t=>{t(zo)})}function vv({...e}){const t=gv(),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 _i(){const[e,t]=p.useState(zo);return p.useEffect(()=>(Fo.push(t),()=>{const n=Fo.indexOf(t);n>-1&&Fo.splice(n,1)}),[e]),{...e,toast:vv,dismiss:n=>Wr({type:"DISMISS_TOAST",toastId:n})}}function St(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function wv(e,t=globalThis==null?void 0:globalThis.document){const n=St(e);p.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 bv="DismissableLayer",Ri="dismissableLayer.update",yv="dismissableLayer.pointerDownOutside",Sv="dismissableLayer.focusOutside",su,iu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,u=p.useContext(iu),[d,f]=p.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=p.useState({}),b=Me(t,I=>f(I)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(g),v=d?w.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,E=v>=x,C=Tv(I=>{const N=I.target,_=[...u.branches].some(O=>O.contains(N));!E||_||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),k=Ev(I=>{const N=I.target;[...u.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return wv(I=>{v===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),p.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(su=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),au(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=su)}},[d,h,n,u]),p.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),au())},[d,u]),p.useEffect(()=>{const I=()=>m({});return document.addEventListener(Ri,I),()=>document.removeEventListener(Ri,I)},[]),l.jsx(we.div,{...c,ref:b,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=bv;var Cv="DismissableLayerBranch",kv=p.forwardRef((e,t)=>{const n=p.useContext(iu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(we.div,{...e,ref:o})});kv.displayName=Cv;function Tv(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){lu(yv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 Ev(e,t=globalThis==null?void 0:globalThis.document){const n=St(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&lu(Sv,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 au(){const e=new CustomEvent(Ri);document.dispatchEvent(e)}function lu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Mc(o,s):o.dispatchEvent(s)}var Pi="focusScope.autoFocusOnMount",Oi="focusScope.autoFocusOnUnmount",cu={bubbles:!1,cancelable:!0},Iv="FocusScope",Ho=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=p.useState(null),u=St(o),d=St(s),f=p.useRef(null),h=Me(t,w=>c(w)),m=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let w=function(S){if(m.paused||!a)return;const E=S.target;a.contains(E)?f.current=E:Nn(f.current,{select:!0})},g=function(S){if(m.paused||!a)return;const E=S.relatedTarget;E!==null&&(a.contains(E)||Nn(f.current,{select:!0}))},x=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Nn(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",g);const v=new MutationObserver(x);return a&&v.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",g),v.disconnect()}}},[r,a,m.paused]),p.useEffect(()=>{if(a){fu.add(m);const w=document.activeElement;if(!a.contains(w)){const x=new CustomEvent(Pi,cu);a.addEventListener(Pi,u),a.dispatchEvent(x),x.defaultPrevented||(Nv(Pv(uu(a)),{select:!0}),document.activeElement===w&&Nn(a))}return()=>{a.removeEventListener(Pi,u),setTimeout(()=>{const x=new CustomEvent(Oi,cu);a.addEventListener(Oi,d),a.dispatchEvent(x),x.defaultPrevented||Nn(w??document.body,{select:!0}),a.removeEventListener(Oi,d),fu.remove(m)},0)}}},[a,u,d,m]);const b=p.useCallback(w=>{if(!n&&!r||m.paused)return;const g=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,x=document.activeElement;if(g&&x){const v=w.currentTarget,[S,E]=Av(v);S&&E?!w.shiftKey&&x===E?(w.preventDefault(),n&&Nn(S,{select:!0})):w.shiftKey&&x===S&&(w.preventDefault(),n&&Nn(E,{select:!0})):x===v&&w.preventDefault()}},[n,r,m.paused]);return l.jsx(we.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});Ho.displayName=Iv;function Nv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Nn(r,{select:t}),document.activeElement!==n)return}function Av(e){const t=uu(e),n=du(t,e),r=du(t.reverse(),e);return[n,r]}function uu(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 du(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 _v(e){return e instanceof HTMLInputElement&&"select"in e}function Nn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&_v(e)&&t&&e.select()}}var fu=Rv();function Rv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=hu(e,t),e.unshift(t)},remove(t){var n;e=hu(e,t),(n=e[0])==null||n.resume()}}}function hu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Pv(e){return e.filter(t=>t.tagName!=="A")}var Ov="Portal",Uo=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);bt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Rs.createPortal(l.jsx(we.div,{...r,ref:t}),i):null});Uo.displayName=Ov;var Mi=0;function Di(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??pu()),document.body.insertAdjacentElement("beforeend",e[1]??pu()),Mi++,()=>{Mi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mi--}},[])}function pu(){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 un=function(){return un=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},un.apply(this,arguments)};function mu(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 Mv(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 Wo="right-scroll-bar-position",Vo="width-before-scroll-bar",Dv="with-scroll-bars-hidden",Lv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function $v(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 Fv=typeof window<"u"?p.useLayoutEffect:p.useEffect,gu=new WeakMap;function zv(e,t){var n=$v(null,function(r){return e.forEach(function(o){return Li(o,r)})});return Fv(function(){var r=gu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}gu.set(n,e)},[e]),n}function Bv(e){return e}function Hv(e,t){t===void 0&&(t=Bv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Uv(e){e===void 0&&(e={});var t=Hv(null);return t.options=un({async:!0,ssr:!1},e),t}var xu=function(e){var t=e.sideCar,n=mu(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 p.createElement(r,un({},n))};xu.isSideCarExport=!0;function Wv(e,t){return e.useMedium(t),xu}var vu=Uv(),$i=function(){},qo=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:$i,onWheelCapture:$i,onTouchMoveCapture:$i}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,m=e.noRelative,b=e.noIsolation,w=e.inert,g=e.allowPinchZoom,x=e.as,v=x===void 0?"div":x,S=e.gapMode,E=mu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=zv([n,t]),I=un(un({},E),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:vu,removeScrollBar:u,shards:f,noRelative:m,noIsolation:b,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),un(un({},I),{ref:k})):p.createElement(v,un({},I,{className:c,ref:k}),a))});qo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},qo.classNames={fullWidth:Vo,zeroRight:Wo};var Vv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function qv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Vv();return t&&e.setAttribute("nonce",t),e}function Kv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Gv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Yv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=qv())&&(Kv(t,n),Gv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Xv=function(){var e=Yv();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},wu=function(){var e=Xv(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Jv={left:0,top:0,right:0,gap:0},Fi=function(e){return parseInt(e||"",10)||0},Zv=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[Fi(n),Fi(r),Fi(o)]},Qv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Jv;var t=Zv(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])}},ew=wu(),cr="data-scroll-locked",tw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
+ .`.concat(Dv,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
87
87
  }
88
- body[`).concat(fr,`] {
88
+ body[`).concat(cr,`] {
89
89
  overflow: hidden `).concat(r,`;
90
90
  overscroll-behavior: contain;
91
91
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -114,21 +114,21 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
114
114
  margin-right: 0 `).concat(r,`;
115
115
  }
116
116
 
117
- body[`).concat(fr,`] {
118
- `).concat(Av,": ").concat(a,`px;
117
+ body[`).concat(cr,`] {
118
+ `).concat(Lv,": ").concat(a,`px;
119
119
  }
120
- `)},vu=function(){var e=parseInt(document.body.getAttribute(fr)||"0",10);return isFinite(e)?e:0},Gv=function(){p.useEffect(function(){return document.body.setAttribute(fr,(vu()+1).toString()),function(){var e=vu()-1;e<=0?document.body.removeAttribute(fr):document.body.setAttribute(fr,e.toString())}},[])},Yv=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Gv();var s=p.useMemo(function(){return Vv(o)},[o]);return p.createElement(Kv,{styles:qv(s,!t,o,n?"":"!important")})},$i=!1;if(typeof window<"u")try{var qo=Object.defineProperty({},"passive",{get:function(){return $i=!0,!0}});window.addEventListener("test",qo,qo),window.removeEventListener("test",qo,qo)}catch{$i=!1}var hr=$i?{passive:!1}:!1,Xv=function(e){return e.tagName==="TEXTAREA"},wu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Xv(e)&&n[t]==="visible")},Jv=function(e){return wu(e,"overflowY")},Zv=function(e){return wu(e,"overflowX")},bu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=yu(e,r);if(o){var s=Su(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Qv=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},ew=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},yu=function(e,t){return e==="v"?Jv(t):Zv(t)},Su=function(e,t){return e==="v"?Qv(t):ew(t)},tw=function(e,t){return e==="h"&&t==="rtl"?-1:1},nw=function(e,t,n,r,o){var s=tw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var m=Su(e,a),b=m[0],w=m[1],g=m[2],x=w-g-s*b;(b||x)&&yu(e,a)&&(f+=x,h+=b);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Go=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Cu=function(e){return[e.deltaX,e.deltaY]},ku=function(e){return e&&"current"in e?e.current:e},rw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ow=function(e){return`
120
+ `)},bu=function(){var e=parseInt(document.body.getAttribute(cr)||"0",10);return isFinite(e)?e:0},nw=function(){p.useEffect(function(){return document.body.setAttribute(cr,(bu()+1).toString()),function(){var e=bu()-1;e<=0?document.body.removeAttribute(cr):document.body.setAttribute(cr,e.toString())}},[])},rw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;nw();var s=p.useMemo(function(){return Qv(o)},[o]);return p.createElement(ew,{styles:tw(s,!t,o,n?"":"!important")})},zi=!1;if(typeof window<"u")try{var Ko=Object.defineProperty({},"passive",{get:function(){return zi=!0,!0}});window.addEventListener("test",Ko,Ko),window.removeEventListener("test",Ko,Ko)}catch{zi=!1}var ur=zi?{passive:!1}:!1,ow=function(e){return e.tagName==="TEXTAREA"},yu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!ow(e)&&n[t]==="visible")},sw=function(e){return yu(e,"overflowY")},iw=function(e){return yu(e,"overflowX")},Su=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Cu(e,r);if(o){var s=ku(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},aw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},lw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Cu=function(e,t){return e==="v"?sw(t):iw(t)},ku=function(e,t){return e==="v"?aw(t):lw(t)},cw=function(e,t){return e==="h"&&t==="rtl"?-1:1},uw=function(e,t,n,r,o){var s=cw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var m=ku(e,a),b=m[0],w=m[1],g=m[2],x=w-g-s*b;(b||x)&&Cu(e,a)&&(f+=x,h+=b);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Go=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Tu=function(e){return[e.deltaX,e.deltaY]},Eu=function(e){return e&&"current"in e?e.current:e},dw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},fw=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},sw=0,pr=[];function iw(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(sw++)[0],s=p.useState(xu)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var w=Iv([e.lockRef.current],(e.shards||[]).map(ku),!0).filter(Boolean);return w.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),w.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(w,g){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var x=Go(w),v=n.current,y="deltaX"in w?w.deltaX:v[0]-x[0],E="deltaY"in w?w.deltaY:v[1]-x[1],C,k=w.target,I=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in w&&I==="h"&&k.type==="range")return!1;var N=bu(I,k);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=bu(I,k)),!N)return!1;if(!r.current&&"changedTouches"in w&&(y||E)&&(r.current=C),!C)return!0;var _=r.current||C;return nw(_,g,w,_==="h"?y:E)},[]),c=p.useCallback(function(w){var g=w;if(!(!pr.length||pr[pr.length-1]!==s)){var x="deltaY"in g?Cu(g):Go(g),v=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&rw(C.delta,x)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var y=(i.current.shards||[]).map(ku).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=y.length>0?a(g,y[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=p.useCallback(function(w,g,x,v){var y={name:w,delta:g,target:x,should:v,shadowParent:aw(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),d=p.useCallback(function(w){n.current=Go(w),r.current=void 0},[]),f=p.useCallback(function(w){u(w.type,Cu(w),w.target,a(w,e.lockRef.current))},[]),h=p.useCallback(function(w){u(w.type,Go(w),w.target,a(w,e.lockRef.current))},[]);p.useEffect(function(){return pr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,hr),document.addEventListener("touchmove",c,hr),document.addEventListener("touchstart",d,hr),function(){pr=pr.filter(function(w){return w!==s}),document.removeEventListener("wheel",c,hr),document.removeEventListener("touchmove",c,hr),document.removeEventListener("touchstart",d,hr)}},[]);var m=e.removeScrollBar,b=e.inert;return p.createElement(p.Fragment,null,b?p.createElement(s,{styles:ow(o)}):null,m?p.createElement(Yv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const lw=Dv(gu,iw);var Yo=p.forwardRef(function(e,t){return p.createElement(Ko,pn({},e,{ref:t,sideCar:lw}))});Yo.classNames=Ko.classNames;var cw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},mr=new WeakMap,Xo=new WeakMap,Jo={},Fi=0,Tu=function(e){return e&&(e.host||Tu(e.parentNode))},uw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Tu(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})},dw=function(e,t,n,r){var o=uw(t,Array.isArray(e)?e:[e]);Jo[n]||(Jo[n]=new WeakMap);var s=Jo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var m=h.getAttribute(r),b=m!==null&&m!=="false",w=(mr.get(h)||0)+1,g=(s.get(h)||0)+1;mr.set(h,w),s.set(h,g),i.push(h),w===1&&b&&Xo.set(h,!0),g===1&&h.setAttribute(n,"true"),b||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Fi++,function(){i.forEach(function(f){var h=mr.get(f)-1,m=s.get(f)-1;mr.set(f,h),s.set(f,m),h||(Xo.has(f)||f.removeAttribute(r),Xo.delete(f)),m||f.removeAttribute(n)}),Fi--,Fi||(mr=new WeakMap,mr=new WeakMap,Xo=new WeakMap,Jo={})}},zi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=cw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),dw(r,o,n,"aria-hidden")):function(){return null}},Zo="Dialog",[Eu,kC]=fn(Zo),[fw,nn]=Eu(Zo),Iu=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),c=p.useRef(null),[u,d]=Kn({prop:r,defaultProp:o??!1,onChange:s,caller:Zo});return l.jsx(fw,{scope:t,triggerRef:a,contentRef:c,contentId:hn(),titleId:hn(),descriptionId:hn(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Iu.displayName=Zo;var Nu="DialogTrigger",Au=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(Nu,n),s=Me(t,o.triggerRef);return l.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ui(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});Au.displayName=Nu;var Bi="DialogPortal",[hw,ju]=Eu(Bi,{forceMount:void 0}),_u=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=nn(Bi,t);return l.jsx(hw,{scope:t,forceMount:n,children:p.Children.map(r,i=>l.jsx(Bt,{present:n||s.open,children:l.jsx(Uo,{asChild:!0,container:o,children:i})}))})};_u.displayName=Bi;var Qo="DialogOverlay",Ru=p.forwardRef((e,t)=>{const n=ju(Qo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=nn(Qo,e.__scopeDialog);return s.modal?l.jsx(Bt,{present:r||s.open,children:l.jsx(mw,{...o,ref:t})}):null});Ru.displayName=Qo;var pw=$n.createSlot("DialogOverlay.RemoveScroll"),mw=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(Qo,n);return l.jsx(Yo,{as:pw,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(we.div,{"data-state":Ui(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Gn="DialogContent",Pu=p.forwardRef((e,t)=>{const n=ju(Gn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=nn(Gn,e.__scopeDialog);return l.jsx(Bt,{present:r||s.open,children:s.modal?l.jsx(gw,{...o,ref:t}):l.jsx(xw,{...o,ref:t})})});Pu.displayName=Gn;var gw=p.forwardRef((e,t)=>{const n=nn(Gn,e.__scopeDialog),r=p.useRef(null),o=Me(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return zi(s)},[]),l.jsx(Ou,{...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())})}),xw=p.forwardRef((e,t)=>{const n=nn(Gn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return l.jsx(Ou,{...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 c,u;(c=e.onInteractOutside)==null||c.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()}})}),Ou=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=nn(Gn,n),c=p.useRef(null),u=Me(t,c);return Oi(),l.jsxs(l.Fragment,{children:[l.jsx(Ho,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ui(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(vw,{titleId:a.titleId}),l.jsx(bw,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Hi="DialogTitle",Mu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(Hi,n);return l.jsx(we.h2,{id:o.titleId,...r,ref:t})});Mu.displayName=Hi;var Du="DialogDescription",Lu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn(Du,n);return l.jsx(we.p,{id:o.descriptionId,...r,ref:t})});Lu.displayName=Du;var $u="DialogClose",Fu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=nn($u,n);return l.jsx(we.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});Fu.displayName=$u;function Ui(e){return e?"open":"closed"}var zu="DialogTitleWarning",[TC,Bu]=Tx(zu,{contentName:Gn,titleName:Hi,docsSlug:"dialog"}),vw=({titleId:e})=>{const t=Bu(zu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},hw=0,dr=[];function pw(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(hw++)[0],s=p.useState(wu)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var w=Mv([e.lockRef.current],(e.shards||[]).map(Eu),!0).filter(Boolean);return w.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),w.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(w,g){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var x=Go(w),v=n.current,S="deltaX"in w?w.deltaX:v[0]-x[0],E="deltaY"in w?w.deltaY:v[1]-x[1],C,k=w.target,I=Math.abs(S)>Math.abs(E)?"h":"v";if("touches"in w&&I==="h"&&k.type==="range")return!1;var N=Su(I,k);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=Su(I,k)),!N)return!1;if(!r.current&&"changedTouches"in w&&(S||E)&&(r.current=C),!C)return!0;var _=r.current||C;return uw(_,g,w,_==="h"?S:E)},[]),c=p.useCallback(function(w){var g=w;if(!(!dr.length||dr[dr.length-1]!==s)){var x="deltaY"in g?Tu(g):Go(g),v=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&dw(C.delta,x)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var S=(i.current.shards||[]).map(Eu).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=p.useCallback(function(w,g,x,v){var S={name:w,delta:g,target:x,should:v,shadowParent:mw(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(E){return E!==S})},1)},[]),d=p.useCallback(function(w){n.current=Go(w),r.current=void 0},[]),f=p.useCallback(function(w){u(w.type,Tu(w),w.target,a(w,e.lockRef.current))},[]),h=p.useCallback(function(w){u(w.type,Go(w),w.target,a(w,e.lockRef.current))},[]);p.useEffect(function(){return dr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,ur),document.addEventListener("touchmove",c,ur),document.addEventListener("touchstart",d,ur),function(){dr=dr.filter(function(w){return w!==s}),document.removeEventListener("wheel",c,ur),document.removeEventListener("touchmove",c,ur),document.removeEventListener("touchstart",d,ur)}},[]);var m=e.removeScrollBar,b=e.inert;return p.createElement(p.Fragment,null,b?p.createElement(s,{styles:fw(o)}):null,m?p.createElement(rw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function mw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const gw=Wv(vu,pw);var Yo=p.forwardRef(function(e,t){return p.createElement(qo,un({},e,{ref:t,sideCar:gw}))});Yo.classNames=qo.classNames;var xw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},fr=new WeakMap,Xo=new WeakMap,Jo={},Bi=0,Iu=function(e){return e&&(e.host||Iu(e.parentNode))},vw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Iu(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})},ww=function(e,t,n,r){var o=vw(t,Array.isArray(e)?e:[e]);Jo[n]||(Jo[n]=new WeakMap);var s=Jo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var m=h.getAttribute(r),b=m!==null&&m!=="false",w=(fr.get(h)||0)+1,g=(s.get(h)||0)+1;fr.set(h,w),s.set(h,g),i.push(h),w===1&&b&&Xo.set(h,!0),g===1&&h.setAttribute(n,"true"),b||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Bi++,function(){i.forEach(function(f){var h=fr.get(f)-1,m=s.get(f)-1;fr.set(f,h),s.set(f,m),h||(Xo.has(f)||f.removeAttribute(r),Xo.delete(f)),m||f.removeAttribute(n)}),Bi--,Bi||(fr=new WeakMap,fr=new WeakMap,Xo=new WeakMap,Jo={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=xw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),ww(r,o,n,"aria-hidden")):function(){return null}},Zo="Dialog",[Nu,RC]=ln(Zo),[bw,Qt]=Nu(Zo),Au=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),c=p.useRef(null),[u,d]=Un({prop:r,defaultProp:o??!1,onChange:s,caller:Zo});return l.jsx(bw,{scope:t,triggerRef:a,contentRef:c,contentId:cn(),titleId:cn(),descriptionId:cn(),open:u,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Au.displayName=Zo;var ju="DialogTrigger",_u=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qt(ju,n),s=Me(t,o.triggerRef);return l.jsx(we.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vi(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});_u.displayName=ju;var Ui="DialogPortal",[yw,Ru]=Nu(Ui,{forceMount:void 0}),Pu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Qt(Ui,t);return l.jsx(yw,{scope:t,forceMount:n,children:p.Children.map(r,i=>l.jsx($t,{present:n||s.open,children:l.jsx(Uo,{asChild:!0,container:o,children:i})}))})};Pu.displayName=Ui;var Qo="DialogOverlay",Ou=p.forwardRef((e,t)=>{const n=Ru(Qo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Qt(Qo,e.__scopeDialog);return s.modal?l.jsx($t,{present:r||s.open,children:l.jsx(Cw,{...o,ref:t})}):null});Ou.displayName=Qo;var Sw=Mn.createSlot("DialogOverlay.RemoveScroll"),Cw=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qt(Qo,n);return l.jsx(Yo,{as:Sw,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(we.div,{"data-state":Vi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Vn="DialogContent",Mu=p.forwardRef((e,t)=>{const n=Ru(Vn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Qt(Vn,e.__scopeDialog);return l.jsx($t,{present:r||s.open,children:s.modal?l.jsx(kw,{...o,ref:t}):l.jsx(Tw,{...o,ref:t})})});Mu.displayName=Vn;var kw=p.forwardRef((e,t)=>{const n=Qt(Vn,e.__scopeDialog),r=p.useRef(null),o=Me(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),l.jsx(Du,{...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())})}),Tw=p.forwardRef((e,t)=>{const n=Qt(Vn,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return l.jsx(Du,{...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 c,u;(c=e.onInteractOutside)==null||c.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()}})}),Du=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Qt(Vn,n),c=p.useRef(null),u=Me(t,c);return Di(),l.jsxs(l.Fragment,{children:[l.jsx(Ho,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Vi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(Ew,{titleId:a.titleId}),l.jsx(Nw,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Wi="DialogTitle",Lu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qt(Wi,n);return l.jsx(we.h2,{id:o.titleId,...r,ref:t})});Lu.displayName=Wi;var $u="DialogDescription",Fu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qt($u,n);return l.jsx(we.p,{id:o.descriptionId,...r,ref:t})});Fu.displayName=$u;var zu="DialogClose",Bu=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Qt(zu,n);return l.jsx(we.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});Bu.displayName=zu;function Vi(e){return e?"open":"closed"}var Hu="DialogTitleWarning",[PC,Uu]=Px(Hu,{contentName:Vn,titleName:Wi,docsSlug:"dialog"}),Ew=({titleId:e})=>{const t=Uu(Hu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
124
124
 
125
125
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
126
126
 
127
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ww="DialogDescriptionWarning",bw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bu(ww).contentName}}.`;return p.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},Hu=Iu,yw=Au,Uu=_u,es=Ru,ts=Pu,Yn=Mu,ns=Lu,Wu=Fu;const Sw=Hu,Cw=Uu,Vu=p.forwardRef(({className:e,...t},n)=>l.jsx(es,{ref:n,className:X("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}));Vu.displayName=es.displayName;const Ku=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,c=>{if(s||!p.isValidElement(c))return;const u=c.type;if(u===Yn||(u==null?void 0:u.displayName)===Yn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(Cw,{children:[l.jsx(Vu,{}),l.jsxs(ts,{ref:r,className:X("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&&l.jsx(Yn,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Wu,{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:[l.jsx(ne.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ku.displayName=ts.displayName;const qu=({className:e,...t})=>l.jsx("div",{className:X("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});qu.displayName="DialogHeader";const Gu=p.forwardRef(({className:e,...t},n)=>l.jsx(Yn,{ref:n,className:X("text-lg font-semibold leading-none tracking-tight",e),...t}));Gu.displayName=Yn.displayName;const kw=p.forwardRef(({className:e,...t},n)=>l.jsx(ns,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));kw.displayName=ns.displayName;function Tw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=S.useState(!1),[a,c]=S.useState(null),[u,d]=S.useState(null),{toast:f}=Ai(),h=S.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await tu(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);S.useEffect(()=>{e&&n&&h()},[e,n,h]);const m=async()=>{if(n)try{await ov(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"})}},b=async()=>{if(n)try{const x=await tu(n),v=new Blob([x],{type:o}),y=URL.createObjectURL(v);window.open(y,"_blank"),URL.revokeObjectURL(y)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},w=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(ne.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(ze,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(ne.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(ne.Image,{className:"h-5 w-5"}):l.jsx(ne.FileText,{className:"h-5 w-5"});return l.jsx(Sw,{open:e,onOpenChange:t,children:l.jsxs(Ku,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(qu,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(Gu,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(ze,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[l.jsx(ne.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(ze,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(ne.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:w()})]})})}function Wi(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 Yu(e,t){const n=t==null?void 0:t.trim();return n?!!(e==="tool"||n.startsWith("```json")||n.length<5e3&&(n.startsWith("{")||n.startsWith("["))):!1}function Ew(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function Iw(e){try{const t=[],n=[],r="\0F",o="\0I";let s=e.replace(/```[\s\S]*?```/g,i=>(t.push(i),`${r}${t.length-1}\0`));return s=s.replace(/`[^`]*`/g,i=>(n.push(i),`${o}${n.length-1}\0`)),s=s.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1"),s=s.replace(/\u0000F(\d+)\u0000/g,(i,a)=>t[+a]??""),s=s.replace(/\u0000I(\d+)\u0000/g,(i,a)=>n[+a]??""),s}catch{return e}}function Xu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Kr(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(Kr).filter(r=>r!==void 0);return n.length?n:void 0}if(Xu(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=Kr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Vi(e){if(typeof e=="string")return e;if(Xu(e))return"";try{const t=Kr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Ju(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 Ju(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 c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),b=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=m?m[2].trim():"",g=b?b[2].trim():"";n[i].push({title:w,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const rs="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",Xn=1e5;function Nw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Aw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function jw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_result").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 _w(e){const t=(r,o=Xn)=>{try{const s=Kr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");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 Rw(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Pw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Zu(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_result":return"result";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Ow(e,t,n=16){const[r,o]=S.useState(e),s=S.useRef(e),i=S.useRef(null),a=S.useRef(null);return S.useEffect(()=>{if(s.current=e,!t){i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current),o(e);return}return a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>o(s.current))},n),()=>{i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current)}},[e,t,n]),r}function Mw({className:e}){const[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:X("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const Qu=S.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:h=!0,userMessagePreviewLength:m=200,customStyles:b={},onEdit:w,onRegenerate:g,onCancelEdit:x,onCopy:v}){const[y,E]=S.useState(!1),[C,k]=S.useState("collapsed"),[I,N]=S.useState(!1),{currentThreadId:_}=_r(),{toast:O}=Ai(),[R,$]=S.useState({}),[q,M]=S.useState(!1),[W,U]=S.useState(null),V=u==="phone"||u==="half-screen",D=t.role,A=D==="tool",K=!(r&&D!=="user"),Y=S.useMemo(()=>{switch(D){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[D]),re=S.useMemo(()=>Nw(t.content),[t.content]),te=S.useMemo(()=>Aw(t.content),[t.content]),pe=S.useMemo(()=>t.content.filter(Q=>Q.type==="image_url"),[t.content]),Se=S.useMemo(()=>t.content.filter(Q=>Q.type==="file"),[t.content]),Te=S.useMemo(()=>t.content.filter(Q=>Q.type==="interrupt"),[t.content]),B=S.useMemo(()=>_w(t.content),[t.content]);S.useMemo(()=>Rw(t.content),[t.content]);const j=S.useMemo(()=>B.length<=Xn?B:`${B.slice(0,Xn)}
129
- … [truncated ${B.length-Xn} chars]`,[B]),H=Ow(re,r,o),ee=S.useCallback(async(Q="all")=>{const fe=Q==="visible"&&A?j:A?B:re;async function We(Ye){try{await navigator.clipboard.writeText(Ye)}catch{try{const Ze=document.createElement("textarea");Ze.value=Ye,Ze.setAttribute("readonly",""),Ze.style.position="absolute",Ze.style.left="-9999px",document.body.appendChild(Ze),Ze.select(),document.execCommand("copy"),document.body.removeChild(Ze)}catch(Ze){throw console.error("Failed to copy:",Ze),Ze}}}try{await We(fe),E(!0),setTimeout(()=>E(!1),2e3),v==null||v(fe)}catch(Ye){console.error("Failed to copy:",Ye)}},[A,B,re,j,v]),ue=S.useCallback(()=>{if(!w)return;const Q=A?B:re;w(t.id,Q)},[w,t.id,A,B,re]),ce=S.useCallback(()=>{g==null||g(n)},[g,n]),_e=S.useCallback(async(Q,oe,fe)=>{if(!K){Q.preventDefault();return}if(R[fe]){Q.preventDefault();return}try{const We=String(oe.url??""),Ye=We.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Ye){Q.preventDefault();const Ze=Ye[1],yt=oe.name||`file_${Ze}`,dt=oe.mimeType||"application/octet-stream";U({id:Ze,name:yt,mimeType:dt}),M(!0);return}if(We.startsWith("data:")){Q.preventDefault(),$(dt=>({...dt,[fe]:!0}));const Ze=`${oe.name}_${oe.size}_${Date.now()}`,yt=O({title:"Fetching file...",description:"",open:!0});try{const dt=await sv(_??void 0);if(!dt||!Array.isArray(dt))throw new Error("Invalid file list response");const St=dt.find(Xt=>!Xt||typeof Xt!="object"||!((Xt.filename??"")===(oe.name??""))?!1:typeof oe.size=="number"&&typeof Xt.size=="number"?Xt.size===oe.size:!0);if(!(St!=null&&St.id))throw new Error(`File "${oe.name}" is not yet available on the server`);if(!St.id||!St.filename)throw new Error("Invalid file data received from server");U({id:St.id,name:oe.name||St.filename||`file_${St.id}`,mimeType:oe.mimeType||St.mime_type||"application/octet-stream"}),M(!0),yt.update({id:yt.id,title:"Success",description:`Opened ${oe.name}`,open:!0})}catch(dt){console.error("Failed to fetch server file:",dt);const St=dt instanceof Error?dt.message:"Unknown error occurred";yt.update({id:yt.id,title:"Failed",description:St}),O({title:"Failed to fetch file",description:St,open:!0})}finally{$(dt=>({...dt,[fe]:!1}))}}}catch(We){console.error("File click error:",We),$(Ye=>({...Ye,[fe]:!1}))}},[K,R,O,_]),Ne=S.useCallback(()=>{const oe=X(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Y);switch(D){case"user":return l.jsx(ne.User,{className:oe});case"assistant":return l.jsx(ne.Bot,{className:oe});case"tool":return l.jsx(ne.Wrench,{className:oe});default:return l.jsx(ne.Bot,{className:oe})}},[V,Y,D]),Ee=S.useCallback(()=>{const Q="group relative mb-4 flex w-full";switch(D){case"user":return X(Q,"justify-end");case"assistant":case"tool":case"system":return X(Q,"justify-start");default:return Q}},[D]),je=S.useCallback(()=>{const Q=X("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");switch(D){case"user":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return X(Q,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return X(Q,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[V,D]),{handleInterrupt:Be}=_r(),Ge=S.useCallback(async Q=>{try{const oe=Q.id||`interrupt-${Date.now()}`;await Be(oe,!0)}catch(oe){console.error("Failed to approve interrupt:",oe)}},[Be]),De=S.useCallback(async Q=>{try{const oe=Q.id||`interrupt-${Date.now()}`;await Be(oe,!1)}catch(oe){console.error("Failed to reject interrupt:",oe)}},[Be]),tt=S.useCallback(({part:Q,i:oe})=>{if(Q.type==="text")return l.jsx($o,{content:Q.text,allowHtml:!1},oe);if(Q.type==="image_url"){const fe=Q;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:fe.url,alt:fe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},oe)}if(Q.type==="file"){const fe=Q,We=fe.name||"file";return l.jsxs("a",{href:fe.url,onClick:Ye=>_e(Ye,fe,oe),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[R[oe]?l.jsx(ne.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[We,R[oe]?" (processing)":""]})]},oe)}return Q.type==="interrupt"?l.jsx(Lw,{interruptPart:Q,onApprove:Ge,onReject:De},oe):null},[_e,R,Ge,De]),mt=S.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(ne.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),at=S.useCallback(()=>{const oe=Yu(D,H)?Wi(H):null;if(oe!==null)return l.jsx(ed,{data:oe});const fe=Iw(Ew(H)),We=H.trim().length===0;return l.jsx(l.Fragment,{children:We?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:X("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",V&&"text-xs"),children:fe})})},[D,H,V]),lt=S.useCallback(()=>{const Q=re.trim(),fe=Yu(D,Q)?Wi(Q):null;if(fe!==null)return l.jsx(ed,{data:fe});if(D==="user"&&h){const We=Q;if(We.length>m)return l.jsxs(Lc,{open:I,onOpenChange:N,children:[l.jsx("div",{className:X("text-sm text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:I?l.jsx($o,{content:We,allowHtml:!1}):l.jsxs("pre",{className:X("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:[We.substring(0,m),"..."]})}),l.jsx($c,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:I?l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",We.length-m," chars)"]})})})]})}return l.jsx($o,{content:re.trim(),allowHtml:!1})},[re,D,h,m,I,V]),gt=S.useCallback(()=>{if(!(re.trim().length>0||pe.length>0||Se.length>0||Te.length>0)&&!r)return mt();if(t.model==="reflection"){const oe=re.trim(),fe=Wi(oe);if(fe&&typeof fe=="object")return l.jsx($w,{data:fe})}if(A&&te.name==="get_issues"){const oe=t.content.find(Ye=>Ye.type==="tool_result"),fe=(oe==null?void 0:oe.output)??B,We=Ju(fe);if(We)return l.jsx(Fw,{issues:We})}if(A){const oe=jw(t.content);if(oe.length>0)return l.jsx("div",{className:"space-y-2",children:oe.map((fe,We)=>{const Ye=typeof fe.output=="string"?fe.output:Vi(fe.output),Ze=Ye.length>Xn?`${Ye.slice(0,Xn)}
131
- … [truncated ${Ye.length-Xn} chars]`:Ye,yt=C==="expanded";return l.jsxs(Lc,{open:yt,onOpenChange:dt=>k(dt?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(bi,{variant:"outline",children:(fe.name??"tool")+(fe.toolCallId?` • ${fe.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:yt?Ze:Ze.slice(0,f)+(Ze.length>f?"...":"")})}),l.jsx($c,{asChild:!0,children:l.jsx(ze,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:yt?l.jsxs(l.Fragment,{children:[" ",l.jsx(ne.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(ne.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},fe.toolCallId??We)})})}if(!A)return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[at(),r&&l.jsx(Mw,{className:Y})]}):l.jsx("div",{className:"space-y-2",children:t.content.map((oe,fe)=>l.jsx(tt,{part:oe,i:fe},fe))})},[re,pe.length,Se.length,r,t.model,A,te.name,B,C,d,mt,at,lt,Y]),Ue=S.useMemo(()=>Pw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:X(Ee(),b.container),children:l.jsxs("div",{className:X(je(),b.content),children:[(a||c||A)&&l.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",Y,b.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Ne(),c&&Ue&&l.jsx("span",{className:X("font-medium",V?"text-xs":"text-sm"),children:Ue}),A&&te.name&&l.jsxs(bi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",Y,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":C!=="collapsed",onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),k(oe=>oe==="collapsed"?"preview":"collapsed"))},onClick:()=>k(Q=>Q==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:te.name}),l.jsx("span",{className:"inline-flex items-center",children:C!=="collapsed"?l.jsx(ne.ChevronUp,{className:"h-3 w-3"}):l.jsx(ne.ChevronDown,{className:"h-3 w-3"})})]}),A&&!te.name&&l.jsx(ze,{variant:"ghost",size:"sm",className:X("h-6 px-1",Y,"hover:bg-foreground/10"),onClick:()=>k(Q=>Q==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",C!=="collapsed"?l.jsx(ne.ChevronUp,{className:"h-3 w-3"}):l.jsx(ne.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.createdAt&&l.jsx("time",{className:X("text-xs opacity-60",Y,V&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),i&&!s&&l.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>ee(A?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,V&&"h-5 w-5"),"aria-label":A?"Copy visible":"Copy message",title:A?"Copy visible portion":"Copy message",children:l.jsx(ne.Copy,{className:X(y?"text-success":Y,V?"h-3 w-3":"h-4 w-4")})}),A&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>ee("all"),className:X("h-6 px-1 text-xs hover:bg-foreground/10",Y),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),D==="user"&&w&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:ue,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,V&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(ne.Edit,{className:X(Y,V?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(ne.RotateCcw,{className:X(Y,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:gt()}),A&&C==="expanded"&&(te.toolCallId||te.name)&&l.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[te.name&&l.jsxs("div",{children:["Function: ",te.name]}),te.toolCallId&&l.jsxs("div",{children:["Call ID: ",te.toolCallId]})]}),!(a||c||A)&&i&&!s&&l.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>ee(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(ne.Copy,{className:X(y?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),D==="user"&&w&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:ue,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(ne.Edit,{className:X("text-current",V?"h-3 w-3":"h-4 w-4")})}),D==="assistant"&&g&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(ne.RotateCcw,{className:X("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&l.jsx(Tw,{isOpen:q,onClose:()=>{M(!1),U(null)},fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Zu(e.message)===Zu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.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)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function ed({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:rs,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Vi(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 l.jsxs("div",{className:rs,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:rs,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:Dw(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Vi(e)})}function Dw(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 l.jsx("code",{className:"text-xs",children:JSON.stringify(Kr(e))})}catch{return String(e)}}function Lw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return l.jsxs(Hr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[l.jsxs(Ur,{className:"pb-3",children:[l.jsx(Wr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),l.jsx(Fc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),l.jsx(zc,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(ze,{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"}),l.jsx(ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function $w({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Fw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:rs,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const td=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ki=S.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:b=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:x},v)=>{const y=S.useRef(null),E=S.useRef(null),C=S.useRef(!1),[k,I]=S.useState(!0),N=S.useCallback(R=>{I(R),g&&g(!R),x&&x(R)},[g,x]),_=S.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),O=S.useMemo(()=>!b||w?!1:k?"auto":!1,[k,b,w]);return e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(cx,{ref:R=>{y.current=R},scrollerRef:R=>{E.current=R instanceof HTMLDivElement?R:null},data:e,followOutput:O,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{_&&_()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,$)=>td($,R),itemContent:(R,$)=>{const q=td($,R);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":q,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(Qu,{message:$,messageIndex:R,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(R),onCancelEdit:d})})}})})});Ki.displayName="MessageList";const os=1e4;function zw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
127
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Iw="DialogDescriptionWarning",Nw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Uu(Iw).contentName}}.`;return p.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},Wu=Au,Aw=_u,Vu=Pu,es=Ou,ts=Mu,qn=Lu,ns=Fu,qu=Bu;const jw=Wu,_w=Vu,Ku=p.forwardRef(({className:e,...t},n)=>l.jsx(es,{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}));Ku.displayName=es.displayName;const Gu=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,c=>{if(s||!p.isValidElement(c))return;const u=c.type;if(u===qn||(u==null?void 0:u.displayName)===qn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(_w,{children:[l.jsx(Ku,{}),l.jsxs(ts,{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&&l.jsx(qn,{className:"sr-only",children:"Dialog"}),t,l.jsxs(qu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Gu.displayName=ts.displayName;const Yu=({className:e,...t})=>l.jsx("div",{className:Q("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Yu.displayName="DialogHeader";const Xu=p.forwardRef(({className:e,...t},n)=>l.jsx(qn,{ref:n,className:Q("text-lg font-semibold leading-none tracking-tight",e),...t}));Xu.displayName=qn.displayName;const Rw=p.forwardRef(({className:e,...t},n)=>l.jsx(ns,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));Rw.displayName=ns.displayName;function Pw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,c]=y.useState(null),[u,d]=y.useState(null),{toast:f}=_i(),h=y.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await ru(n);c(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 m=async()=>{if(n)try{await fv(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"})}},b=async()=>{if(n)try{const x=await ru(n),v=new Blob([x],{type:o}),S=URL.createObjectURL(v);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"})}},w=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(oe.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(Be,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(oe.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(oe.Image,{className:"h-5 w-5"}):l.jsx(oe.FileText,{className:"h-5 w-5"});return l.jsx(jw,{open:e,onOpenChange:t,children:l.jsxs(Gu,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(Yu,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(Xu,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Be,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[l.jsx(oe.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(Be,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[l.jsx(oe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:w()})]})})}function qi(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 Ju(e,t){const n=t==null?void 0:t.trim();return n?!!(e==="tool"||n.startsWith("```json")||n.length<5e3&&(n.startsWith("{")||n.startsWith("["))):!1}function Ow(e){let t=e;try{(t.match(/```/g)||[]).length%2===1&&(t+="\n```"),(t.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(t+="`")}catch{}return t}function Mw(e){try{const t=[],n=[],r="\0F",o="\0I";let s=e.replace(/```[\s\S]*?```/g,i=>(t.push(i),`${r}${t.length-1}\0`));return s=s.replace(/`[^`]*`/g,i=>(n.push(i),`${o}${n.length-1}\0`)),s=s.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1"),s=s.replace(/\u0000F(\d+)\u0000/g,(i,a)=>t[+a]??""),s=s.replace(/\u0000I(\d+)\u0000/g,(i,a)=>n[+a]??""),s}catch{return e}}function Zu(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(Zu(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 Ki(e){if(typeof e=="string")return e;if(Zu(e))return"";try{const t=Vr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Qu(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 Qu(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 c=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!c)continue;const u=c[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),b=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=m?m[2].trim():"",g=b?b[2].trim():"";n[i].push({title:w,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const rs="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 Dw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Lw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_result");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function $w(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_result").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 Fw(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)+`
128
+ … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_result");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 zw(e){const t=e.find(r=>r.type==="tool_result");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Bw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function ed(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_result":return"result";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Hw(e,t,n=16){const[r,o]=y.useState(e),s=y.useRef(e),i=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{if(s.current=e,!t){i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current),o(e);return}return a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(()=>o(s.current))},n),()=>{i.current&&cancelAnimationFrame(i.current),a.current&&clearTimeout(a.current)}},[e,t,n]),r}function Uw({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:Q("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const td=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:o=16,isEditing:s=!1,showActions:i=!0,showTimestamp:a=!0,showAgentName:c=!0,layoutSize:u="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:f=200,truncateUserMessages:h=!0,userMessagePreviewLength:m=200,customStyles:b={},onEdit:w,onRegenerate:g,onCancelEdit:x,onCopy:v}){const[S,E]=y.useState(!1),[C,k]=y.useState("collapsed"),[I,N]=y.useState(!1),{currentThreadId:_}=jr(),{toast:O}=_i(),[R,$]=y.useState({}),[K,M]=y.useState(!1),[W,U]=y.useState(null),V=u==="phone"||u==="half-screen",L=t.role,A=L==="tool",q=!(r&&L!=="user"),J=y.useMemo(()=>{switch(L){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))]"}},[L]),se=y.useMemo(()=>Dw(t.content),[t.content]),te=y.useMemo(()=>Lw(t.content),[t.content]),pe=y.useMemo(()=>t.content.filter(Y=>Y.type==="image_url"),[t.content]),Ie=y.useMemo(()=>t.content.filter(Y=>Y.type==="file"),[t.content]),Ne=y.useMemo(()=>t.content.filter(Y=>Y.type==="interrupt"),[t.content]),B=y.useMemo(()=>Fw(t.content),[t.content]);y.useMemo(()=>zw(t.content),[t.content]);const j=y.useMemo(()=>B.length<=Kn?B:`${B.slice(0,Kn)}
129
+ … [truncated ${B.length-Kn} chars]`,[B]),H=Hw(se,r,o),ee=y.useCallback(async(Y="all")=>{const he=Y==="visible"&&A?j:A?B:se;async function We(Xe){try{await navigator.clipboard.writeText(Xe)}catch{try{const Qe=document.createElement("textarea");Qe.value=Xe,Qe.setAttribute("readonly",""),Qe.style.position="absolute",Qe.style.left="-9999px",document.body.appendChild(Qe),Qe.select(),document.execCommand("copy"),document.body.removeChild(Qe)}catch(Qe){throw console.error("Failed to copy:",Qe),Qe}}}try{await We(he),E(!0),setTimeout(()=>E(!1),2e3),v==null||v(he)}catch(Xe){console.error("Failed to copy:",Xe)}},[A,B,se,j,v]),ue=y.useCallback(()=>{if(!w)return;const Y=A?B:se;w(t.id,Y)},[w,t.id,A,B,se]),ce=y.useCallback(()=>{g==null||g(n)},[g,n]),Oe=y.useCallback(async(Y,re,he)=>{if(!q){Y.preventDefault();return}if(R[he]){Y.preventDefault();return}try{const We=String(re.url??""),Xe=We.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Xe){Y.preventDefault();const Qe=Xe[1],yt=re.name||`file_${Qe}`,lt=re.mimeType||"application/octet-stream";U({id:Qe,name:yt,mimeType:lt}),M(!0);return}if(We.startsWith("data:")){Y.preventDefault(),$(lt=>({...lt,[he]:!0}));const Qe=`${re.name}_${re.size}_${Date.now()}`,yt=O({title:"Fetching file...",description:"",open:!0});try{const lt=await hv(_??void 0);if(!lt||!Array.isArray(lt))throw new Error("Invalid file list response");const mt=lt.find(Kt=>!Kt||typeof Kt!="object"||!((Kt.filename??"")===(re.name??""))?!1:typeof re.size=="number"&&typeof Kt.size=="number"?Kt.size===re.size:!0);if(!(mt!=null&&mt.id))throw new Error(`File "${re.name}" is not yet available on the server`);if(!mt.id||!mt.filename)throw new Error("Invalid file data received from server");U({id:mt.id,name:re.name||mt.filename||`file_${mt.id}`,mimeType:re.mimeType||mt.mime_type||"application/octet-stream"}),M(!0),yt.update({id:yt.id,title:"Success",description:`Opened ${re.name}`,open:!0})}catch(lt){console.error("Failed to fetch server file:",lt);const mt=lt instanceof Error?lt.message:"Unknown error occurred";yt.update({id:yt.id,title:"Failed",description:mt}),O({title:"Failed to fetch file",description:mt,open:!0})}finally{$(lt=>({...lt,[he]:!1}))}}}catch(We){console.error("File click error:",We),$(Xe=>({...Xe,[he]:!1}))}},[q,R,O,_]),Ge=y.useCallback(()=>{const re=Q(V?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",J);switch(L){case"user":return l.jsx(oe.User,{className:re});case"assistant":return l.jsx(oe.Bot,{className:re});case"tool":return l.jsx(oe.Wrench,{className:re});default:return l.jsx(oe.Bot,{className:re})}},[V,J,L]),ke=y.useCallback(()=>{const Y="group relative mb-4 flex w-full";switch(L){case"user":return Q(Y,"justify-end");case"assistant":case"tool":case"system":return Q(Y,"justify-start");default:return Y}},[L]),be=y.useCallback(()=>{const Y=Q("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",V&&"px-3 py-2 text-sm");switch(L){case"user":return Q(Y,"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(Y,"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(Y,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return Q(Y,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return Q(Y,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[V,L]),{handleInterrupt:Ue}=jr(),Ye=y.useCallback(async Y=>{try{const re=Y.id||`interrupt-${Date.now()}`;await Ue(re,!0)}catch(re){console.error("Failed to approve interrupt:",re)}},[Ue]),$e=y.useCallback(async Y=>{try{const re=Y.id||`interrupt-${Date.now()}`;await Ue(re,!1)}catch(re){console.error("Failed to reject interrupt:",re)}},[Ue]),st=y.useCallback(({part:Y,i:re})=>{if(Y.type==="text")return l.jsx($o,{content:Y.text,allowHtml:!1},re);if(Y.type==="image_url"){const he=Y;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:he.url,alt:he.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},re)}if(Y.type==="file"){const he=Y,We=he.name||"file";return l.jsxs("a",{href:he.url,onClick:Xe=>Oe(Xe,he,re),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[R[re]?l.jsx(oe.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[We,R[re]?" (processing)":""]})]},re)}return Y.type==="interrupt"?l.jsx(Vw,{interruptPart:Y,onApprove:Ye,onReject:$e},re):null},[Oe,R,Ye,$e]),pt=y.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),it=y.useCallback(()=>{const re=Ju(L,H)?qi(H):null;if(re!==null)return l.jsx(nd,{data:re});const he=Mw(Ow(H)),We=H.trim().length===0;return l.jsx(l.Fragment,{children:We?l.jsx("div",{className:"w-full",children:l.jsxs("div",{className:"animate-pulse space-y-2",children:[l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),l.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):l.jsx("pre",{className:Q("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",V&&"text-xs"),children:he})})},[L,H,V]),dt=y.useCallback(()=>{const Y=se.trim(),he=Ju(L,Y)?qi(Y):null;if(he!==null)return l.jsx(nd,{data:he});if(L==="user"&&h){const We=Y;if(We.length>m)return l.jsxs(Fc,{open:I,onOpenChange:N,children:[l.jsx("div",{className:Q("text-sm text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:I?l.jsx($o,{content:We,allowHtml:!1}):l.jsxs("pre",{className:Q("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",V&&"text-xs"),children:[We.substring(0,m),"..."]})}),l.jsx(zc,{asChild:!0,children:l.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:I?l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",We.length-m," chars)"]})})})]})}return l.jsx($o,{content:se.trim(),allowHtml:!1})},[se,L,h,m,I,V]),at=y.useCallback(()=>{if(!(se.trim().length>0||pe.length>0||Ie.length>0||Ne.length>0)&&!r)return pt();if(t.model==="reflection"){const re=se.trim(),he=qi(re);if(he&&typeof he=="object")return l.jsx(qw,{data:he})}if(A&&te.name==="get_issues"){const re=t.content.find(Xe=>Xe.type==="tool_result"),he=(re==null?void 0:re.output)??B,We=Qu(he);if(We)return l.jsx(Kw,{issues:We})}if(A){const re=$w(t.content);if(re.length>0)return l.jsx("div",{className:"space-y-2",children:re.map((he,We)=>{const Xe=typeof he.output=="string"?he.output:Ki(he.output),Qe=Xe.length>Kn?`${Xe.slice(0,Kn)}
131
+ … [truncated ${Xe.length-Kn} chars]`:Xe,yt=C==="expanded";return l.jsxs(Fc,{open:yt,onOpenChange:lt=>k(lt?"expanded":"preview"),children:[l.jsx("div",{className:"flex items-center gap-2 text-xs",children:l.jsx(Si,{variant:"outline",children:(he.name??"tool")+(he.toolCallId?` • ${he.toolCallId.slice(0,8)}`:"")})}),l.jsx("div",{className:"font-mono text-sm mt-1",children:l.jsx("pre",{className:"whitespace-pre-wrap break-words",children:yt?Qe:Qe.slice(0,f)+(Qe.length>f?"...":"")})}),l.jsx(zc,{asChild:!0,children:l.jsx(Be,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:yt?l.jsxs(l.Fragment,{children:[" ",l.jsx(oe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(oe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},he.toolCallId??We)})})}if(!A)return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[it(),r&&l.jsx(Uw,{className:J})]}):l.jsx("div",{className:"space-y-2",children:t.content.map((re,he)=>l.jsx(st,{part:re,i:he},he))})},[se,pe.length,Ie.length,r,t.model,A,te.name,B,C,d,pt,it,dt,J]),Fe=y.useMemo(()=>Bw(t),[t]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Q(ke(),b.container),children:l.jsxs("div",{className:Q(be(),b.content),children:[(a||c||A)&&l.jsxs("div",{className:Q("flex items-center justify-between mb-2 pb-2 border-b border-current/10",V&&"mb-1 pb-1",J,b.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[Ge(),c&&Fe&&l.jsx("span",{className:Q("font-medium",V?"text-xs":"text-sm"),children:Fe}),A&&te.name&&l.jsxs(Si,{variant:"outline",className:Q("text-xs flex items-center gap-1 cursor-pointer",J,"border border-current/40",V&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":C!=="collapsed",onKeyDown:Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),k(re=>re==="collapsed"?"preview":"collapsed"))},onClick:()=>k(Y=>Y==="collapsed"?"preview":"collapsed"),children:[l.jsx("span",{children:te.name}),l.jsx("span",{className:"inline-flex items-center",children:C!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})})]}),A&&!te.name&&l.jsx(Be,{variant:"ghost",size:"sm",className:Q("h-6 px-1",J,"hover:bg-foreground/10"),onClick:()=>k(Y=>Y==="collapsed"?"preview":"collapsed"),children:l.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",C!=="collapsed"?l.jsx(oe.ChevronUp,{className:"h-3 w-3"}):l.jsx(oe.ChevronDown,{className:"h-3 w-3"})]})})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[a&&t.createdAt&&l.jsx("time",{className:Q("text-xs opacity-60",J,V&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),i&&!s&&l.jsxs("div",{className:Q("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>ee(A?"visible":"all"),className:Q("h-6 w-6 p-0 hover:bg-foreground/10",J,V&&"h-5 w-5"),"aria-label":A?"Copy visible":"Copy message",title:A?"Copy visible portion":"Copy message",children:l.jsx(oe.Copy,{className:Q(S?"text-success":J,V?"h-3 w-3":"h-4 w-4")})}),A&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>ee("all"),className:Q("h-6 px-1 text-xs hover:bg-foreground/10",J),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),L==="user"&&w&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:ue,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",J,V&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(oe.Edit,{className:Q(J,V?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:ce,className:Q("h-6 w-6 p-0 hover:bg-foreground/10",J,V&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(oe.RotateCcw,{className:Q(J,V?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsx("div",{className:"relative",children:at()}),A&&C==="expanded"&&(te.toolCallId||te.name)&&l.jsxs("div",{className:Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",V&&"text-xs"),children:[te.name&&l.jsxs("div",{children:["Function: ",te.name]}),te.toolCallId&&l.jsxs("div",{children:["Call ID: ",te.toolCallId]})]}),!(a||c||A)&&i&&!s&&l.jsxs("div",{className:Q("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",b.actions),children:[l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>ee(),className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(oe.Copy,{className:Q(S?"text-success":"text-current",V?"h-3 w-3":"h-4 w-4")})}),L==="user"&&w&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:ue,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(oe.Edit,{className:Q("text-current",V?"h-3 w-3":"h-4 w-4")})}),L==="assistant"&&g&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:ce,className:Q("h-6 w-6 p-0 hover:bg-background/50 text-current",V&&"h-5 w-5"),children:l.jsx(oe.RotateCcw,{className:Q("text-current",V?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&l.jsx(Pw,{isOpen:K,onClose:()=>{M(!1),U(null)},fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,c,u,d,f,h,m;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&ed(e.message)===ed(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(b=>e[b]===t[b]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((c=e.customStyles)==null?void 0:c.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)===((m=t.customStyles)==null?void 0:m.header);return o&&s});function nd({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:rs,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(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 l.jsxs("div",{className:rs,children:[typeof r=="boolean"&&l.jsxs("p",{children:[l.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Follow-up queries:"})}),l.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>l.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&l.jsxs("div",{children:[l.jsx("p",{children:l.jsx("strong",{children:"Facts:"})}),l.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>l.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return l.jsx("div",{className:rs,children:l.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>l.jsxs("div",{className:"mb-1",children:[l.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),l.jsx("dd",{className:"inline",children:Ww(i)})]},s))})})}return l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)})}function Ww(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 l.jsx("code",{className:"text-xs",children:JSON.stringify(Vr(e))})}catch{return String(e)}}function Vw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return l.jsxs(Br,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[l.jsxs(Hr,{className:"pb-3",children:[l.jsx(Ur,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),l.jsx(Bc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),l.jsx(Hc,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(Be,{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"}),l.jsx(Be,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function qw({data:e}){return l.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>l.jsxs("div",{className:"flex",children:[l.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),l.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>l.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Kw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return l.jsx("div",{className:rs,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:l.jsxs("div",{className:"mb-4",children:[l.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),l.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>l.jsxs("li",{children:[l.jsx("div",{className:"font-medium",children:o.title}),l.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const rd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Gi=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:m,followNewMessages:b=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:x},v)=>{const S=y.useRef(null),E=y.useRef(null),C=y.useRef(!1),[k,I]=y.useState(!0),N=y.useCallback(R=>{I(R),g&&g(!R),x&&x(R)},[g,x]),_=y.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),O=y.useMemo(()=>!b||w?!1:k?"auto":!1,[k,b,w]);return e.length===0?l.jsx("div",{className:f,style:h,children:l.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):l.jsx("div",{className:f,style:h,children:l.jsx(xx,{ref:R=>{S.current=R},scrollerRef:R=>{E.current=R instanceof HTMLDivElement?R:null},data:e,followOutput:O,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{_&&_()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,$)=>rd($,R),itemContent:(R,$)=>{const K=rd($,R);return l.jsx("div",{className:"mb-4 last:mb-0","data-message-id":K,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(td,{message:$,messageIndex:R,isStreamingMessage:t&&n===$.id,streamingDebounceMs:r,isEditing:i===$.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:c,onRegenerate:()=>u(R),onCancelEdit:d})})}})})});Gi.displayName="MessageList";const os=1e4;function Gw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
133
 
134
134
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
136
136
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
137
137
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
138
138
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
139
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Bw(e,t=os){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function Hw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Bw(t),zw(t)}function qi(e){const t=e+"CollectionProvider",[n,r]=fn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:x}=w,v=S.useRef(null),y=S.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:y,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=$n.createSlot(a),u=S.forwardRef((w,g)=>{const{scope:x,children:v}=w,y=s(a,x),E=Me(g,y.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=$n.createSlot(d),m=S.forwardRef((w,g)=>{const{scope:x,children:v,...y}=w,E=S.useRef(null),C=Me(g,E),k=s(d,x);return S.useEffect(()=>(k.itemMap.set(E,{ref:E,...y}),()=>void k.itemMap.delete(E))),l.jsx(h,{[f]:"",ref:C,children:v})});m.displayName=d;function b(w){const g=s(e+"CollectionConsumer",w);return S.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const y=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,I)=>y.indexOf(k.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:m},b,r]}var Uw=p.createContext(void 0);function ss(e){const t=p.useContext(Uw);return e||t||"ltr"}const Ww=["top","right","bottom","left"],Pn=Math.min,Ht=Math.max,is=Math.round,as=Math.floor,mn=e=>({x:e,y:e}),Vw={left:"right",right:"left",bottom:"top",top:"bottom"},Kw={start:"end",end:"start"};function Gi(e,t,n){return Ht(e,Pn(t,n))}function Sn(e,t){return typeof e=="function"?e(t):e}function Cn(e){return e.split("-")[0]}function gr(e){return e.split("-")[1]}function Yi(e){return e==="x"?"y":"x"}function Xi(e){return e==="y"?"height":"width"}const qw=new Set(["top","bottom"]);function gn(e){return qw.has(Cn(e))?"y":"x"}function Ji(e){return Yi(gn(e))}function Gw(e,t,n){n===void 0&&(n=!1);const r=gr(e),o=Ji(e),s=Xi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ls(i)),[i,ls(i)]}function Yw(e){const t=ls(e);return[Zi(e),t,Zi(t)]}function Zi(e){return e.replace(/start|end/g,t=>Kw[t])}const nd=["left","right"],rd=["right","left"],Xw=["top","bottom"],Jw=["bottom","top"];function Zw(e,t,n){switch(e){case"top":case"bottom":return n?t?rd:nd:t?nd:rd;case"left":case"right":return t?Xw:Jw;default:return[]}}function Qw(e,t,n,r){const o=gr(e);let s=Zw(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Zi)))),s}function ls(e){return e.replace(/left|right|bottom|top/g,t=>Vw[t])}function eb(e){return{top:0,right:0,bottom:0,left:0,...e}}function od(e){return typeof e!="number"?eb(e):{top:e,right:e,bottom:e,left:e}}function cs(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 sd(e,t,n){let{reference:r,floating:o}=e;const s=gn(t),i=Ji(t),a=Xi(i),c=Cn(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 m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(gr(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const tb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=sd(u,r,c),h=r,m={},b=0;for(let w=0;w<a.length;w++){const{name:g,fn:x}=a[w],{x:v,y,data:E,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=y??f,m={...m,[g]:{...m[g],...E}},C&&b<=50&&(b++,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}=sd(u,h,c)),w=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function qr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=Sn(t,e),b=od(m),g=a[h?f==="floating"?"reference":"floating":f],x=cs(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:c})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},C=cs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:c}):v);return{top:(x.top-C.top+b.top)/E.y,bottom:(C.bottom-x.bottom+b.bottom)/E.y,left:(x.left-C.left+b.left)/E.x,right:(C.right-x.right+b.right)/E.x}}const nb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=Sn(e,t)||{};if(u==null)return{};const f=od(d),h={x:n,y:r},m=Ji(o),b=Xi(m),w=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[b]+s.reference[m]-h[m]-s.floating[b],C=h[m]-s.reference[m],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=k?k[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(k)))&&(I=a.floating[y]||s.floating[b]);const N=E/2-C/2,_=I/2-w[b]/2-1,O=Pn(f[x],_),R=Pn(f[v],_),$=O,q=I-w[b]-R,M=I/2-w[b]/2+N,W=Gi($,M,q),U=!c.arrow&&gr(o)!=null&&M!==W&&s.reference[b]/2-(M<$?O:R)-w[b]/2<0,V=U?M<$?M-$:M-q:0;return{[m]:h[m]+V,data:{[m]:W,centerOffset:M-W-V,...U&&{alignmentOffset:V}},reset:U}}}),rb=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...g}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Cn(o),v=gn(a),y=Cn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=h||(y||!w?[ls(a)]:Yw(a)),k=b!=="none";!h&&k&&C.push(...Qw(a,w,b,E));const I=[a,...C],N=await qr(t,g),_=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(N[x]),f){const M=Gw(o,i,E);_.push(N[M[0]],N[M[1]])}if(O=[...O,{placement:o,overflows:_}],!_.every(M=>M<=0)){var R,$;const M=(((R=s.flip)==null?void 0:R.index)||0)+1,W=I[M];if(W&&(!(f==="alignment"?v!==gn(W):!1)||O.every(D=>gn(D.placement)===v?D.overflows[0]>0:!0)))return{data:{index:M,overflows:O},reset:{placement:W}};let U=($=O.filter(V=>V.overflows[0]<=0).sort((V,D)=>V.overflows[1]-D.overflows[1])[0])==null?void 0:$.placement;if(!U)switch(m){case"bestFit":{var q;const V=(q=O.filter(D=>{if(k){const A=gn(D.placement);return A===v||A==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(A=>A>0).reduce((A,K)=>A+K,0)]).sort((D,A)=>D[1]-A[1])[0])==null?void 0:q[0];V&&(U=V);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function id(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ad(e){return Ww.some(t=>e[t]>=0)}const ob=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Sn(e,t);switch(r){case"referenceHidden":{const s=await qr(t,{...o,elementContext:"reference"}),i=id(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ad(i)}}}case"escaped":{const s=await qr(t,{...o,altBoundary:!0}),i=id(s,n.floating);return{data:{escapedOffsets:i,escaped:ad(i)}}}default:return{}}}}},ld=new Set(["left","top"]);async function sb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Cn(n),a=gr(n),c=gn(n)==="y",u=ld.has(i)?-1:1,d=s&&c?-1:1,f=Sn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),c?{x:m*d,y:h*u}:{x:h*u,y:m*d}}const ib=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,c=await sb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},ab=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:v}=g;return{x,y:v}}},...c}=Sn(e,t),u={x:n,y:r},d=await qr(t,c),f=gn(Cn(o)),h=Yi(f);let m=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+d[g],y=m-d[x];m=Gi(v,m,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=b+d[g],y=b-d[x];b=Gi(v,b,y)}const w=a.fn({...t,[h]:m,[f]:b});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:s,[f]:i}}}}}},lb=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:c=!0,crossAxis:u=!0}=Sn(e,t),d={x:n,y:r},f=gn(o),h=Yi(f);let m=d[h],b=d[f];const w=Sn(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const y=h==="y"?"height":"width",E=s.reference[h]-s.floating[y]+g.mainAxis,C=s.reference[h]+s.reference[y]-g.mainAxis;m<E?m=E:m>C&&(m=C)}if(u){var x,v;const y=h==="y"?"width":"height",E=ld.has(Cn(o)),C=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),k=s.reference[f]+s.reference[y]+(E?0:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);b<C?b=C:b>k&&(b=k)}return{[h]:m,[f]:b}}}},cb=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:c=()=>{},...u}=Sn(e,t),d=await qr(t,u),f=Cn(o),h=gr(o),m=gn(o)==="y",{width:b,height:w}=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 v=w-d.top-d.bottom,y=b-d.left-d.right,E=Pn(w-d[g],v),C=Pn(b-d[x],y),k=!t.middlewareData.shift;let I=E,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),k&&!h){const O=Ht(d.left,0),R=Ht(d.right,0),$=Ht(d.top,0),q=Ht(d.bottom,0);m?N=b-2*(O!==0||R!==0?O+R:Ht(d.left,d.right)):I=w-2*($!==0||q!==0?$+q:Ht(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const _=await i.getDimensions(a.floating);return b!==_.width||w!==_.height?{reset:{rects:!0}}:{}}}};function us(){return typeof window<"u"}function xr(e){return cd(e)?(e.nodeName||"").toLowerCase():"#document"}function Ut(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function xn(e){var t;return(t=(cd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function cd(e){return us()?e instanceof Node||e instanceof Ut(e).Node:!1}function rn(e){return us()?e instanceof Element||e instanceof Ut(e).Element:!1}function vn(e){return us()?e instanceof HTMLElement||e instanceof Ut(e).HTMLElement:!1}function ud(e){return!us()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ut(e).ShadowRoot}const ub=new Set(["inline","contents"]);function Gr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!ub.has(o)}const db=new Set(["table","td","th"]);function fb(e){return db.has(xr(e))}const hb=[":popover-open",":modal"];function ds(e){return hb.some(t=>{try{return e.matches(t)}catch{return!1}})}const pb=["transform","translate","scale","rotate","perspective"],mb=["transform","translate","scale","rotate","perspective","filter"],gb=["paint","layout","strict","content"];function Qi(e){const t=ea(),n=rn(e)?on(e):e;return pb.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)||mb.some(r=>(n.willChange||"").includes(r))||gb.some(r=>(n.contain||"").includes(r))}function xb(e){let t=On(e);for(;vn(t)&&!vr(t);){if(Qi(t))return t;if(ds(t))return null;t=On(t)}return null}function ea(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const vb=new Set(["html","body","#document"]);function vr(e){return vb.has(xr(e))}function on(e){return Ut(e).getComputedStyle(e)}function fs(e){return rn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(xr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ud(e)&&e.host||xn(e);return ud(t)?t.host:t}function dd(e){const t=On(e);return vr(t)?e.ownerDocument?e.ownerDocument.body:e.body:vn(t)&&Gr(t)?t:dd(t)}function Yr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=dd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Ut(o);if(s){const a=ta(i);return t.concat(i,i.visualViewport||[],Gr(o)?o:[],a&&n?Yr(a):[])}return t.concat(o,Yr(o,[],n))}function ta(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fd(e){const t=on(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=vn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=is(n)!==s||is(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function na(e){return rn(e)?e:e.contextElement}function wr(e){const t=na(e);if(!vn(t))return mn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=fd(t);let i=(s?is(n.width):n.width)/r,a=(s?is(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const wb=mn(0);function hd(e){const t=Ut(e);return!ea()||!t.visualViewport?wb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ut(e)?!1:t}function Jn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=na(e);let i=mn(1);t&&(r?rn(r)&&(i=wr(r)):i=wr(e));const a=bb(s,n,r)?hd(s):mn(0);let c=(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=Ut(s),m=r&&rn(r)?Ut(r):r;let b=h,w=ta(b);for(;w&&r&&m!==b;){const g=wr(w),x=w.getBoundingClientRect(),v=on(w),y=x.left+(w.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(w.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=E,b=Ut(w),w=ta(b)}}return cs({width:d,height:f,x:c,y:u})}function ra(e,t){const n=fs(e).scrollLeft;return t?t.left+n:Jn(xn(e)).left+n}function pd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ra(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function yb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=xn(r),a=t?ds(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=mn(1);const d=mn(0),f=vn(r);if((f||!f&&!s)&&((xr(r)!=="body"||Gr(i))&&(c=fs(r)),vn(r))){const m=Jn(r);u=wr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?pd(i,c,!0):mn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Sb(e){return Array.from(e.getClientRects())}function Cb(e){const t=xn(e),n=fs(e),r=e.ownerDocument.body,o=Ht(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ht(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ra(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Ht(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function kb(e,t){const n=Ut(e),r=xn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=ea();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const Tb=new Set(["absolute","fixed"]);function Eb(e,t){const n=Jn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=vn(e)?wr(e):mn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function md(e,t,n){let r;if(t==="viewport")r=kb(e,n);else if(t==="document")r=Cb(xn(e));else if(rn(t))r=Eb(t,n);else{const o=hd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return cs(r)}function gd(e,t){const n=On(e);return n===t||!rn(n)||vr(n)?!1:on(n).position==="fixed"||gd(n,t)}function Ib(e,t){const n=t.get(e);if(n)return n;let r=Yr(e,[],!1).filter(a=>rn(a)&&xr(a)!=="body"),o=null;const s=on(e).position==="fixed";let i=s?On(e):e;for(;rn(i)&&!vr(i);){const a=on(i),c=Qi(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Tb.has(o.position)||Gr(i)&&!c&&gd(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function Nb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ds(t)?[]:Ib(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=md(t,d,o);return u.top=Ht(f.top,u.top),u.right=Pn(f.right,u.right),u.bottom=Pn(f.bottom,u.bottom),u.left=Ht(f.left,u.left),u},md(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Ab(e){const{width:t,height:n}=fd(e);return{width:t,height:n}}function jb(e,t,n){const r=vn(t),o=xn(t),s=n==="fixed",i=Jn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=mn(0);function u(){c.x=ra(o)}if(r||!r&&!s)if((xr(t)!=="body"||Gr(o))&&(a=fs(t)),r){const m=Jn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?pd(o,a):mn(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function oa(e){return on(e).position==="static"}function xd(e,t){if(!vn(e)||on(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return xn(e)===n&&(n=n.ownerDocument.body),n}function vd(e,t){const n=Ut(e);if(ds(e))return n;if(!vn(e)){let o=On(e);for(;o&&!vr(o);){if(rn(o)&&!oa(o))return o;o=On(o)}return n}let r=xd(e,t);for(;r&&fb(r)&&oa(r);)r=xd(r,t);return r&&vr(r)&&oa(r)&&!Qi(r)?n:r||xb(e)||n}const _b=async function(e){const t=this.getOffsetParent||vd,n=this.getDimensions,r=await n(e.floating);return{reference:jb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return on(e).direction==="rtl"}const Pb={convertOffsetParentRelativeRectToViewportRelativeRect:yb,getDocumentElement:xn,getClippingRect:Nb,getOffsetParent:vd,getElementRects:_b,getClientRects:Sb,getDimensions:Ab,getScale:wr,isElement:rn,isRTL:Rb};function wd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ob(e,t){let n=null,r;const o=xn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const b=as(f),w=as(o.clientWidth-(d+h)),g=as(o.clientHeight-(f+m)),x=as(d),y={rootMargin:-b+"px "+-w+"px "+-g+"px "+-x+"px",threshold:Ht(0,Pn(1,c))||1};let E=!0;function C(k){const I=k[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!wd(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,y)}n.observe(e)}return i(!0),s}function Mb(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:c=!1}=r,u=na(e),d=o||s?[...u?Yr(u):[],...Yr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Ob(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=m)==null||y.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let b,w=c?Jn(e):null;c&&g();function g(){const x=Jn(e);w&&!wd(w,x)&&n(),w=x,b=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(b)}}const Db=ib,Lb=ab,$b=rb,Fb=cb,zb=ob,bd=nb,Bb=lb,Hb=(e,t,n)=>{const r=new Map,o={platform:Pb,...n},s={...o.platform,_c:r};return tb(e,t,{...o,platform:s})};var Ub=typeof document<"u",Wb=function(){},hs=Ub?S.useLayoutEffect:Wb;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 yd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Sd(e,t){const n=yd(e);return Math.round(t*n)/n}function sa(e){const t=p.useRef(e);return hs(()=>{t.current=e}),t}function Vb(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:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);ps(h,r)||m(r);const[b,w]=p.useState(null),[g,x]=p.useState(null),v=p.useCallback(D=>{D!==k.current&&(k.current=D,w(D))},[]),y=p.useCallback(D=>{D!==I.current&&(I.current=D,x(D))},[]),E=s||b,C=i||g,k=p.useRef(null),I=p.useRef(null),N=p.useRef(d),_=c!=null,O=sa(c),R=sa(o),$=sa(u),q=p.useCallback(()=>{if(!k.current||!I.current)return;const D={placement:t,strategy:n,middleware:h};R.current&&(D.platform=R.current),Hb(k.current,I.current,D).then(A=>{const K={...A,isPositioned:$.current!==!1};M.current&&!ps(N.current,K)&&(N.current=K,oo.flushSync(()=>{f(K)}))})},[h,t,n,R,$]);hs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[u]);const M=p.useRef(!1);hs(()=>(M.current=!0,()=>{M.current=!1}),[]),hs(()=>{if(E&&(k.current=E),C&&(I.current=C),E&&C){if(O.current)return O.current(E,C,q);q()}},[E,C,q,O,_]);const W=p.useMemo(()=>({reference:k,floating:I,setReference:v,setFloating:y}),[v,y]),U=p.useMemo(()=>({reference:E,floating:C}),[E,C]),V=p.useMemo(()=>{const D={position:n,left:0,top:0};if(!U.floating)return D;const A=Sd(U.floating,d.x),K=Sd(U.floating,d.y);return a?{...D,transform:"translate("+A+"px, "+K+"px)",...yd(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:K}},[n,a,U.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:q,refs:W,elements:U,floatingStyles:V}),[d,q,W,U,V])}const Kb=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?bd({element:r.current,padding:o}).fn(n):{}:r?bd({element:r,padding:o}).fn(n):{}}}},qb=(e,t)=>({...Db(e),options:[e,t]}),Gb=(e,t)=>({...Lb(e),options:[e,t]}),Yb=(e,t)=>({...Bb(e),options:[e,t]}),Xb=(e,t)=>({...$b(e),options:[e,t]}),Jb=(e,t)=>({...Fb(e),options:[e,t]}),Zb=(e,t)=>({...zb(e),options:[e,t]}),Qb=(e,t)=>({...Kb(e),options:[e,t]});var ey="Arrow",Cd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(we.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Cd.displayName=ey;var ty=Cd;function kd(e){const[t,n]=p.useState(void 0);return bt(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;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 ia="Popper",[Td,ms]=fn(ia),[ny,Ed]=Td(ia),Id=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(ny,{scope:t,anchor:r,onAnchorChange:o,children:n})};Id.displayName=ia;var Nd="PopperAnchor",Ad=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ed(Nd,n),i=p.useRef(null),a=Me(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(we.div,{...o,ref:a})});Ad.displayName=Nd;var aa="PopperContent",[ry,oy]=Td(aa),jd=p.forwardRef((e,t)=>{var B,j,H,ee,ue,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:b,...w}=e,g=Ed(aa,n),[x,v]=p.useState(null),y=Me(t,_e=>v(_e)),[E,C]=p.useState(null),k=kd(E),I=(k==null?void 0:k.width)??0,N=(k==null?void 0:k.height)??0,_=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],$=R.length>0,q={padding:O,boundary:R.filter(iy),altBoundary:$},{refs:M,floatingStyles:W,placement:U,isPositioned:V,middlewareData:D}=Vb({strategy:"fixed",placement:_,whileElementsMounted:(..._e)=>Mb(..._e,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[qb({mainAxis:o+N,alignmentAxis:i}),c&&Gb({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Yb():void 0,...q}),c&&Xb({...q}),Jb({...q,apply:({elements:_e,rects:Ne,availableWidth:Ee,availableHeight:je})=>{const{width:Be,height:Ge}=Ne.reference,De=_e.floating.style;De.setProperty("--radix-popper-available-width",`${Ee}px`),De.setProperty("--radix-popper-available-height",`${je}px`),De.setProperty("--radix-popper-anchor-width",`${Be}px`),De.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&Qb({element:E,padding:a}),ay({arrowWidth:I,arrowHeight:N}),h&&Zb({strategy:"referenceHidden",...q})]}),[A,K]=Pd(U),Y=kt(b);bt(()=>{V&&(Y==null||Y())},[V,Y]);const re=(B=D.arrow)==null?void 0:B.x,te=(j=D.arrow)==null?void 0:j.y,pe=((H=D.arrow)==null?void 0:H.centerOffset)!==0,[Se,Te]=p.useState();return bt(()=>{x&&Te(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:V?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(ee=D.transformOrigin)==null?void 0:ee.x,(ue=D.transformOrigin)==null?void 0:ue.y].join(" "),...((ce=D.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(ry,{scope:n,placedSide:A,onArrowChange:C,arrowX:re,arrowY:te,shouldHideArrow:pe,children:l.jsx(we.div,{"data-side":A,"data-align":K,...w,ref:y,style:{...w.style,animation:V?void 0:"none"}})})})});jd.displayName=aa;var _d="PopperArrow",sy={top:"bottom",right:"left",bottom:"top",left:"right"},Rd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=oy(_d,r),i=sy[s.placedSide];return l.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:l.jsx(ty,{...o,ref:n,style:{...o.style,display:"block"}})})});Rd.displayName=_d;function iy(e){return e!==null}var ay=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Pd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let b="",w="";return u==="bottom"?(b=i?f:`${h}px`,w=`${-c}px`):u==="top"?(b=i?f:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(b=`${-c}px`,w=i?f:`${m}px`):u==="left"&&(b=`${r.floating.width+c}px`,w=i?f:`${m}px`),{data:{x:b,y:w}}}});function Pd(e){const[t,n="center"]=e.split("-");return[t,n]}var Od=Id,Md=Ad,Dd=jd,Ld=Rd,la="rovingFocusGroup.onEntryFocus",ly={bubbles:!1,cancelable:!0},Xr="RovingFocusGroup",[ca,$d,cy]=qi(Xr),[uy,Fd]=fn(Xr,[cy]),[dy,fy]=uy(Xr),zd=p.forwardRef((e,t)=>l.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(hy,{...e,ref:t})})}));zd.displayName=Xr;var hy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Me(t,h),b=ss(s),[w,g]=Kn({prop:i,defaultProp:a??null,onChange:c,caller:Xr}),[x,v]=p.useState(!1),y=kt(u),E=$d(n),C=p.useRef(!1),[k,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(la,y),()=>N.removeEventListener(la,y)},[y]),l.jsx(dy,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:w,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>v(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(we.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,N=>{const _=!C.current;if(N.target===N.currentTarget&&_&&!x){const O=new CustomEvent(la,ly);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const R=E().filter(U=>U.focusable),$=R.find(U=>U.active),q=R.find(U=>U.id===w),W=[$,q,...R].filter(Boolean).map(U=>U.ref.current);Ud(W,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>v(!1))})})}),Bd="RovingFocusGroupItem",Hd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=hn(),u=s||c,d=fy(Bd,n),f=d.currentTabStopId===u,h=$d(n),{onFocusableItemAdd:m,onFocusableItemRemove:b,currentTabStopId:w}=d;return p.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),l.jsx(ca.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(we.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=gy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?xy(y,E+1):y.slice(E+1)}setTimeout(()=>Ud(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Hd.displayName=Bd;var py={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function my(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function gy(e,t,n){const r=my(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return py[r]}function Ud(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function xy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var vy=zd,wy=Hd,ua=["Enter"," "],by=["ArrowDown","PageUp","Home"],Wd=["ArrowUp","PageDown","End"],yy=[...by,...Wd],Sy={ltr:[...ua,"ArrowRight"],rtl:[...ua,"ArrowLeft"]},Cy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Jr="Menu",[Zr,ky,Ty]=qi(Jr),[Zn,Vd]=fn(Jr,[Ty,ms,Fd]),gs=ms(),Kd=Fd(),[Ey,Qn]=Zn(Jr),[Iy,Qr]=Zn(Jr),qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[c,u]=p.useState(null),d=p.useRef(!1),f=kt(s),h=ss(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),l.jsx(Od,{...a,children:l.jsx(Ey,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(Iy,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};qd.displayName=Jr;var Ny="MenuAnchor",da=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return l.jsx(Md,{...o,...r,ref:t})});da.displayName=Ny;var fa="MenuPortal",[Ay,Gd]=Zn(fa,{forceMount:void 0}),Yd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Qn(fa,t);return l.jsx(Ay,{scope:t,forceMount:n,children:l.jsx(Bt,{present:n||s.open,children:l.jsx(Uo,{asChild:!0,container:o,children:r})})})};Yd.displayName=fa;var qt="MenuContent",[jy,ha]=Zn(qt),Xd=p.forwardRef((e,t)=>{const n=Gd(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(qt,e.__scopeMenu),i=Qr(qt,e.__scopeMenu);return l.jsx(Zr.Provider,{scope:e.__scopeMenu,children:l.jsx(Bt,{present:r||s.open,children:l.jsx(Zr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(_y,{...o,ref:t}):l.jsx(Ry,{...o,ref:t})})})})}),_y=p.forwardRef((e,t)=>{const n=Qn(qt,e.__scopeMenu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return zi(s)},[]),l.jsx(pa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ry=p.forwardRef((e,t)=>{const n=Qn(qt,e.__scopeMenu);return l.jsx(pa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Py=$n.createSlot("MenuContent.ScrollLock"),pa=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:b,...w}=e,g=Qn(qt,n),x=Qr(qt,n),v=gs(n),y=Kd(n),E=ky(n),[C,k]=p.useState(null),I=p.useRef(null),N=Me(t,I,g.onContentChange),_=p.useRef(0),O=p.useRef(""),R=p.useRef(0),$=p.useRef(null),q=p.useRef("right"),M=p.useRef(0),W=b?Yo:p.Fragment,U=b?{as:Py,allowPinchZoom:!0}:void 0,V=A=>{var B,j;const K=O.current+A,Y=E().filter(H=>!H.disabled),re=document.activeElement,te=(B=Y.find(H=>H.ref.current===re))==null?void 0:B.textValue,pe=Y.map(H=>H.textValue),Se=Vy(pe,K,te),Te=(j=Y.find(H=>H.textValue===Se))==null?void 0:j.ref.current;(function H(ee){O.current=ee,window.clearTimeout(_.current),ee!==""&&(_.current=window.setTimeout(()=>H(""),1e3))})(K),Te&&setTimeout(()=>Te.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Oi();const D=p.useCallback(A=>{var Y,re;return q.current===((Y=$.current)==null?void 0:Y.side)&&qy(A,(re=$.current)==null?void 0:re.area)},[]);return l.jsx(jy,{scope:n,searchRef:O,onItemEnter:p.useCallback(A=>{D(A)&&A.preventDefault()},[D]),onItemLeave:p.useCallback(A=>{var K;D(A)||((K=I.current)==null||K.focus(),k(null))},[D]),onTriggerLeave:p.useCallback(A=>{D(A)&&A.preventDefault()},[D]),pointerGraceTimerRef:R,onPointerGraceIntentChange:p.useCallback(A=>{$.current=A},[]),children:l.jsx(W,{...U,children:l.jsx(Ho,{asChild:!0,trapped:o,onMountAutoFocus:le(s,A=>{var K;A.preventDefault(),(K=I.current)==null||K.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(vy,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:le(c,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(Dd,{role:"menu","aria-orientation":"vertical","data-state":pf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...w,ref:N,style:{outline:"none",...w.style},onKeyDown:le(w.onKeyDown,A=>{const Y=A.target.closest("[data-radix-menu-content]")===A.currentTarget,re=A.ctrlKey||A.altKey||A.metaKey,te=A.key.length===1;Y&&(A.key==="Tab"&&A.preventDefault(),!re&&te&&V(A.key));const pe=I.current;if(A.target!==pe||!yy.includes(A.key))return;A.preventDefault();const Te=E().filter(B=>!B.disabled).map(B=>B.ref.current);Wd.includes(A.key)&&Te.reverse(),Uy(Te)}),onBlur:le(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(_.current),O.current="")}),onPointerMove:le(e.onPointerMove,to(A=>{const K=A.target,Y=M.current!==A.clientX;if(A.currentTarget.contains(K)&&Y){const re=A.clientX>M.current?"right":"left";q.current=re,M.current=A.clientX}}))})})})})})})});Xd.displayName=qt;var Oy="MenuGroup",ma=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{role:"group",...r,ref:t})});ma.displayName=Oy;var My="MenuLabel",Jd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{...r,ref:t})});Jd.displayName=My;var xs="MenuItem",Zd="menu.itemSelect",vs=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Qr(xs,e.__scopeMenu),a=ha(xs,e.__scopeMenu),c=Me(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Zd,{bubbles:!0,cancelable:!0});f.addEventListener(Zd,m=>r==null?void 0:r(m),{once:!0}),Pc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(Qd,{...o,ref:c,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===" "||ua.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var Qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ha(xs,n),a=Kd(n),c=p.useRef(null),u=Me(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const b=c.current;b&&m((b.textContent??"").trim())},[s.children]),l.jsx(Zr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(wy,{asChild:!0,...a,focusable:!r,children:l.jsx(we.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,to(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,to(b=>i.onItemLeave(b))),onFocus:le(e.onFocus,()=>f(!0)),onBlur:le(e.onBlur,()=>f(!1))})})})}),Dy="MenuCheckboxItem",ef=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(sf,{scope:e.__scopeMenu,checked:n,children:l.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":xa(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ef.displayName=Dy;var tf="MenuRadioGroup",[Ly,$y]=Zn(tf,{value:void 0,onValueChange:()=>{}}),nf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=kt(r);return l.jsx(Ly,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(ma,{...o,ref:t})})});nf.displayName=tf;var rf="MenuRadioItem",of=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=$y(rf,e.__scopeMenu),s=n===o.value;return l.jsx(sf,{scope:e.__scopeMenu,checked:s,children:l.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":xa(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});of.displayName=rf;var ga="MenuItemIndicator",[sf,Fy]=Zn(ga,{checked:!1}),af=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Fy(ga,n);return l.jsx(Bt,{present:r||ws(s.checked)||s.checked===!0,children:l.jsx(we.span,{...o,ref:t,"data-state":xa(s.checked)})})});af.displayName=ga;var zy="MenuSeparator",lf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});lf.displayName=zy;var By="MenuArrow",cf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return l.jsx(Ld,{...o,...r,ref:t})});cf.displayName=By;var Hy="MenuSub",[EC,uf]=Zn(Hy),eo="MenuSubTrigger",df=p.forwardRef((e,t)=>{const n=Qn(eo,e.__scopeMenu),r=Qr(eo,e.__scopeMenu),o=uf(eo,e.__scopeMenu),s=ha(eo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(da,{asChild:!0,...u,children:l.jsx(Qd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pf(n.open),...e,ref:yi(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:le(e.onPointerMove,to(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,to(f=>{var m,b;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const w=(b=n.content)==null?void 0:b.dataset.side,g=w==="right",x=g?-5:5,v=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:v,y:h.bottom}],side:w}),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 m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Sy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});df.displayName=eo;var ff="MenuSubContent",hf=p.forwardRef((e,t)=>{const n=Gd(qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Qn(qt,e.__scopeMenu),i=Qr(qt,e.__scopeMenu),a=uf(ff,e.__scopeMenu),c=p.useRef(null),u=Me(t,c);return l.jsx(Zr.Provider,{scope:e.__scopeMenu,children:l.jsx(Bt,{present:r||s.open,children:l.jsx(Zr.Slot,{scope:e.__scopeMenu,children:l.jsx(pa,{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=c.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 m;const f=d.currentTarget.contains(d.target),h=Cy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});hf.displayName=ff;function pf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function xa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function Uy(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Wy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Vy(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=Wy(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function Ky(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],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function qy(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Ky(n,t)}function to(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Gy=qd,Yy=da,Xy=Yd,Jy=Xd,Zy=ma,Qy=Jd,e0=vs,t0=ef,n0=nf,r0=of,o0=af,s0=lf,i0=cf,a0=df,l0=hf,bs="DropdownMenu",[c0,IC]=fn(bs,[Vd]),_t=Vd(),[u0,mf]=c0(bs),gf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=_t(t),u=p.useRef(null),[d,f]=Kn({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return l.jsx(u0,{scope:t,triggerId:hn(),triggerRef:u,contentId:hn(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(Gy,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};gf.displayName=bs;var xf="DropdownMenuTrigger",vf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=mf(xf,n),i=_t(n);return l.jsx(Yy,{asChild:!0,...i,children:l.jsx(we.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:yi(t,s.triggerRef),onPointerDown: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())})})})});vf.displayName=xf;var d0="DropdownMenuPortal",wf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=_t(t);return l.jsx(Xy,{...r,...n})};wf.displayName=d0;var bf="DropdownMenuContent",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=mf(bf,n),s=_t(n),i=p.useRef(!1);return l.jsx(Jy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.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)"}})});yf.displayName=bf;var f0="DropdownMenuGroup",h0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(Zy,{...o,...r,ref:t})});h0.displayName=f0;var p0="DropdownMenuLabel",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(Qy,{...o,...r,ref:t})});Sf.displayName=p0;var m0="DropdownMenuItem",Cf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(e0,{...o,...r,ref:t})});Cf.displayName=m0;var g0="DropdownMenuCheckboxItem",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(t0,{...o,...r,ref:t})});kf.displayName=g0;var x0="DropdownMenuRadioGroup",v0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(n0,{...o,...r,ref:t})});v0.displayName=x0;var w0="DropdownMenuRadioItem",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(r0,{...o,...r,ref:t})});Tf.displayName=w0;var b0="DropdownMenuItemIndicator",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(o0,{...o,...r,ref:t})});Ef.displayName=b0;var y0="DropdownMenuSeparator",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(s0,{...o,...r,ref:t})});If.displayName=y0;var S0="DropdownMenuArrow",C0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(i0,{...o,...r,ref:t})});C0.displayName=S0;var k0="DropdownMenuSubTrigger",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(a0,{...o,...r,ref:t})});Nf.displayName=k0;var T0="DropdownMenuSubContent",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_t(n);return l.jsx(l0,{...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)"}})});Af.displayName=T0;var E0=gf,I0=vf,N0=wf,jf=yf,_f=Sf,Rf=Cf,Pf=kf,Of=Tf,Mf=Ef,Df=If,Lf=Nf,$f=Af;const A0=E0,j0=I0,_0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Lf,{ref:o,className:X("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,l.jsx(ne.ChevronRight,{className:"ml-auto h-4 w-4"})]}));_0.displayName=Lf.displayName;const R0=p.forwardRef(({className:e,...t},n)=>l.jsx($f,{ref:n,className:X("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}));R0.displayName=$f.displayName;const Ff=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(N0,{children:l.jsx(jf,{ref:r,sideOffset:t,className:X("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})}));Ff.displayName=jf.displayName;const va=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Rf,{ref:r,className:X("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}));va.displayName=Rf.displayName;const P0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Pf,{ref:o,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Mf,{children:l.jsx(ne.Check,{className:"h-4 w-4"})})}),t]}));P0.displayName=Pf.displayName;const O0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Of,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Mf,{children:l.jsx(ne.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));O0.displayName=Of.displayName;const M0=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(_f,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));M0.displayName=_f.displayName;const D0=p.forwardRef(({className:e,...t},n)=>l.jsx(Df,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));D0.displayName=Df.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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{currentThreadId:b,messages:w,isStreaming:g,streamingAssistantId:x,isLoadingThread:v,error:y,send:E,stop:C,lastCheckpointId:k,lastCheckpointNs:I,listCheckpoints:N,navigateToCheckpoint:_,returnToLatest:O,hasMoreHistory:R,isLoadingHistory:$,loadOlderMessages:q,api:M}=_r(),[W,U]=S.useState(null),[V,D]=S.useState(""),[A,K]=S.useState(null),[Y,re]=S.useState([]),[te,pe]=S.useState(0),[Se,Te]=S.useState(0),[B,j]=S.useState(!1),[H,ee]=S.useState(null),[ue,ce]=S.useState(null),[_e,Ne]=S.useState(!1),[Ee,je]=S.useState(null),[Be,Ge]=S.useState([]),[De,tt]=S.useState(null),[mt,at]=S.useState(null),[lt,gt]=S.useState(!1),Ue=S.useRef(null),Q=S.useRef(null),oe=S.useRef(null),fe=S.useCallback(()=>{Ue.current&&(Ue.current.value=""),Q.current&&(Q.current.value=""),pe(J=>J+1),Te(J=>J+1)},[]),We=S.useRef(!1);S.useEffect(()=>{We.current&&!g&&(re([]),fe()),We.current=g},[g,fe]);const[Ye,Ze]=S.useState("desktop");S.useEffect(()=>{const J=()=>{const he=window.innerWidth;Ze(he<640?"phone":he<1024?"tablet":"desktop")};return J(),window.addEventListener("resize",J),()=>window.removeEventListener("resize",J)},[]),S.useEffect(()=>{let J=!1;if(!b){Ge([]),tt(null),at(null),oe.current=null;return}const he={threadId:b,checkpointId:k??null,checkpointNs:I??null},Oe=oe.current;if(!(Oe&&Oe.threadId===he.threadId&&Oe.checkpointId===he.checkpointId&&Oe.checkpointNs===he.checkpointNs))return N(b).then(Qe=>{var or;if(J)return;const nt=((Qe==null?void 0:Qe.checkpoints)??[]).slice().sort((kn,T)=>new Date(T.createdAt).getTime()-new Date(kn.createdAt).getTime());Ge(nt);const At=De,an=At&&nt.some(kn=>kn.checkpointId===At)?At:((or=nt[0])==null?void 0:or.checkpointId)??null;let rr=null;if(an){const kn=nt.find(T=>T.checkpointId===an);rr=(kn==null?void 0:kn.checkpointNs)??null}tt(an),at(rr),oe.current=he}).catch(Qe=>{console.error("ChatInterface - listCheckpoints error:",Qe),J||(Ge([]),oe.current=null)}),()=>{J=!0}},[b,k,I,De,N]),S.useEffect(()=>{k&&(tt(k),at(I??null))},[k,I]);const yt=S.useCallback(async()=>{if(!(!R||$))try{await q()}catch(J){console.warn("loadOlderMessages failed",J)}},[R,$,q]);S.useEffect(()=>{(async()=>{if(!M.baseUrl){je(null);return}try{const he=await M.getAgent("default");je(he.uiDefaultMessage||null)}catch(he){console.warn("Failed to fetch default message:",he),je(null)}})()},[M]),S.useEffect(()=>{y&&!_e&&(m==null||m(y))},[y,_e,m]);const dt=J=>{if(J.length>os)return`Message too long (${J.length}/${os} characters)`;try{return Hw(J),null}catch(he){return(he==null?void 0:he.message)||"Invalid message"}},St=async J=>{const he=J.trim();if(!(!he&&Y.length===0)){if(he){const Oe=dt(he);if(Oe){K(Oe);return}}try{await E(he||"",{checkpointId:De??k??void 0,checkpointNs:mt??I??void 0,payloadExtras:W?{edit:!0,originalMessageId:W}:void 0,attachments:Y}),f==null||f(he),K(null),re([]),fe(),U(null),D("")}catch(Oe){const Qe=(Oe==null?void 0:Oe.message)||"Failed to send message";K(Qe),m==null||m(Qe)}}},Xt=S.useCallback((J,he)=>{u&&(U(J),D(he),K(null))},[u]),L=S.useCallback(()=>{U(null),D(""),K(null)},[]),Z=S.useCallback((J,he)=>{Xt(J,he)},[Xt]),Re=S.useCallback(J=>{const he=Oe=>{const Qe=Oe.content||[],nt=Qe.filter(At=>At.type==="text").map(At=>At.text).join("");if(nt)return nt;try{return JSON.stringify(Qe,null,2)}catch{return String(Qe)}};for(let Oe=J-1;Oe>=0;Oe--)if(w[Oe].role==="user"){const Qe=he(w[Oe]);Qe&&E(Qe,{checkpointId:De??k??void 0,checkpointNs:mt??I??void 0});break}},[w,E,De,mt,k,I]),qe=J=>{const he=Array.from(J.target.files||[]);re(Oe=>[...Oe,...he]),J.target.value=""},it=J=>{re(he=>{const Oe=he.filter((Qe,nt)=>J!==nt);return Oe.length===0&&fe(),Oe})},ft=async J=>{const he=(J.target.files||[])[0];if(he){ee(null),ce(null),j(!0);try{await E("",{checkpointId:De??k??void 0,checkpointNs:mt??I??void 0,attachments:[he]});const Oe=`Uploaded ${he.name} - processing through chat stream`;ce(Oe)}catch(Oe){const Qe=Oe instanceof Error?Oe.message:"Failed to upload Excel file";console.error("Excel upload failed",Oe),ee(Qe),m==null||m(Qe)}finally{j(!1),J.target.value="",fe()}}},Jt=J=>{if(!J)return"Unknown";const he=Date.parse(J);return Number.isNaN(he)?J:new Date(he).toLocaleString()},bn=async J=>{if(b){gt(!0);try{if(!J){await O(),tt(null),at(null);return}const he=Be.find(Qe=>Qe.checkpointId===J),Oe=(he==null?void 0:he.checkpointNs)??null;await _(J,Oe),tt(J),at(Oe)}finally{gt(!1)}}},Ct=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Pe=`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||""}`,xt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Ct,children:[!!y&&!_e&&l.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:[l.jsx("span",{children:y}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>Ne(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(ne.X,{size:16})})]}),b&&Be.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:De??"",onChange:J=>{const he=J.target.value||null;bn(he)},children:[l.jsx("option",{value:"",children:"Latest"}),Be.map(J=>l.jsxs("option",{value:J.checkpointId,children:[Jt(J.createdAt),J.preview?` — ${J.preview.slice(0,40)}`:""]},J.checkpointId))]})]}),l.jsxs("div",{className:`relative ${Pe}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Ki,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ye,enableMessageEditing:u,editingMessageId:W,onStartReached:()=>{yt()},onEdit:Z,onRegenerate:Re,onCancelEdit:L,emptyMessage:Ee??void 0,isNavigatingCheckpoint:lt}),v&&l.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:[l.jsx(ne.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),l.jsxs("div",{className:xt,children:[W&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ne.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:L,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(ne.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Ue,type:"file",multiple:!0,onChange:J=>qe(J),className:"hidden"},te),Y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((J,he)=>l.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:[l.jsx(ne.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:J.name}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>it(he),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 ${J.name}`,children:l.jsx(ne.X,{size:12})})]},he))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Q,type:"file",accept:".xls,.xlsx,.xlsm",onChange:ft,className:"hidden"},Se),B&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(ne.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ue&&!B&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ue}),H&&!B&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:H})]})]}),A&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:A}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(A0,{children:[l.jsx(j0,{asChild:!0,children:l.jsx(ze,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(ne.Plus,{size:16})})}),l.jsxs(Ff,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(va,{onClick:()=>{var J;return(J=Ue.current)==null?void 0:J.click()},className:"cursor-pointer",children:[l.jsx(ne.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(va,{onClick:()=>{var J;B||(J=Q.current)==null||J.click()},className:`cursor-pointer ${B?"opacity-60 pointer-events-none":""}`,children:[l.jsx(ne.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(Qm,{initialValue:V,editingMessageId:W,placeholder:W?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:os,onSend:St,onCancelEdit:L,onStop:C,allowEmptySend:Y.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${W?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${A?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=p.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:X("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 wa(e,[t,n]){return Math.min(n,Math.max(t,e))}function L0(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var ba="ScrollArea",[zf,NC]=fn(ba),[$0,Gt]=zf(ba),Bf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,b]=p.useState(null),[w,g]=p.useState(null),[x,v]=p.useState(0),[y,E]=p.useState(0),[C,k]=p.useState(!1),[I,N]=p.useState(!1),_=Me(t,R=>c(R)),O=ss(o);return l.jsx($0,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:b,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(we.div,{dir:O,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Bf.displayName=ba;var Hf="ScrollAreaViewport",Uf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Gt(Hf,n),a=p.useRef(null),c=Me(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(we.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Uf.displayName=Hf;var wn="ScrollAreaScrollbar",ya=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(wn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(F0,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(z0,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Wf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Sa,{...r,ref:t}):null});ya.displayName=wn;var F0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(wn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Bt,{present:n||s,children:l.jsx(Wf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),z0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gt(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>c("SCROLL_END"),100),[a,c]=L0("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 p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(Bt,{present:n||a!=="hidden",children:l.jsx(Sa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Wf=p.forwardRef((e,t)=>{const n=Gt(wn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=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 br(n.viewport,c),br(n.content,c),l.jsx(Bt,{present:r||s,children:l.jsx(Sa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Sa=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Gt(wn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Yf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return K0(h,i.current,a,m)}return n==="horizontal"?l.jsx(B0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=Xf(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(H0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=Xf(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),B0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Gt(wn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Kf,{"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":Ts(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),Zf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ks(i.paddingLeft),paddingEnd:ks(i.paddingRight)}})}})}),H0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Gt(wn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Kf,{"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":Ts(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),Zf(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ks(i.paddingTop),paddingEnd:ks(i.paddingBottom)}})}})}),[U0,Vf]=zf(wn),Kf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Gt(wn,n),[b,w]=p.useState(null),g=Me(t,_=>w(_)),x=p.useRef(null),v=p.useRef(""),y=m.viewport,E=r.content-r.viewport,C=kt(d),k=kt(c),I=Es(f,10);function N(_){if(x.current){const O=_.clientX-x.current.left,R=_.clientY-x.current.top;u({x:O,y:R})}}return p.useEffect(()=>{const _=O=>{const R=O.target;(b==null?void 0:b.contains(R))&&C(O,E)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[y,b,E,C]),p.useEffect(k,[r,k]),br(b,I),br(m.content,I),l.jsx(U0,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:kt(s),onThumbPointerUp:kt(i),onThumbPositionChange:k,onThumbPointerDown:kt(a),children:l.jsx(we.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:le(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),x.current=b.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(_))}),onPointerMove:le(e.onPointerMove,N),onPointerUp:le(e.onPointerUp,_=>{const O=_.target;O.hasPointerCapture(_.pointerId)&&O.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),Cs="ScrollAreaThumb",qf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Vf(Cs,e.__scopeScrollArea);return l.jsx(Bt,{present:n||o.hasThumb,children:l.jsx(W0,{ref:t,...r})})}),W0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Gt(Cs,n),i=Vf(Cs,n),{onThumbPositionChange:a}=i,c=Me(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=Es(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=q0(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(we.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:le(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),b=f.clientX-m.left,w=f.clientY-m.top;i.onThumbPointerDown({x:b,y:w})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});qf.displayName=Cs;var Ca="ScrollAreaCorner",Gf=p.forwardRef((e,t)=>{const n=Gt(Ca,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(V0,{...e,ref:t}):null});Gf.displayName=Ca;var V0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Gt(Ca,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return br(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),br(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(we.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 ks(e){return e?parseInt(e,10):0}function Yf(e,t){const n=e/t;return isNaN(n)?0:n}function Ts(e){const t=Yf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function K0(e,t,n,r="ltr"){const o=Ts(n),s=o/2,i=t||s,a=o-i,c=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 Jf([c,u],f)(e)}function Xf(e,t,n="ltr"){const r=Ts(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=wa(e,c);return Jf([0,i],[0,a])(u)}function Jf(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 Zf(e,t){return e>0&&e<t}var q0=(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=kt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function br(e,t){const n=kt(t);bt(()=>{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 Qf=Bf,G0=Uf,Y0=Gf;const eh=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Qf,{ref:r,className:X("relative overflow-hidden",e),...n,children:[l.jsx(G0,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(th,{}),l.jsx(Y0,{})]}));eh.displayName=Qf.displayName;const th=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(ya,{ref:r,orientation:t,className:X("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:l.jsx(qf,{className:"relative flex-1 rounded-full bg-border"})}));th.displayName=ya.displayName;function ka({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:m,createThread:b,deleteThread:w,renameThread:g,isLoadingThreads:x}=_r(),[v,y]=S.useState(h??[]),[E,C]=S.useState(null),[k,I]=S.useState(""),[N,_]=S.useState(!1);S.useEffect(()=>{y(h??[])},[h]);const O=async A=>{try{await f(A),a==null||a(A),c==null||c(A)}catch(K){console.error("Failed to select thread:",K)}},R=async()=>{try{_(!0);const A=await b();u==null||u(A),a==null||a(A)}catch(A){console.error("Failed to create thread:",A)}finally{_(!1)}},$=async(A,K)=>{if(K.stopPropagation(),!!confirm("Delete this thread?"))try{await w(A),d==null||d(A)}catch(Y){console.error("Failed to delete thread:",Y)}},q=(A,K)=>{K.stopPropagation(),C(A.threadId),I(A.title||`Thread ${A.threadId.slice(0,8)}`)},M=async A=>{if(k.trim())try{await g(A,k.trim()),C(null),I("")}catch(K){console.error("Failed to update title:",K)}},W=()=>{C(null),I("")},U=(A,K)=>{A.key==="Enter"?M(K):A.key==="Escape"&&W()},V=A=>{if(!A)return"";try{const K=new Date(A),re=new Date().getTime()-K.getTime(),te=Math.floor(re/(1e3*60*60*24));return te===0?K.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):te===1?"Yesterday":te<7?`${te} days ago`:K.toLocaleDateString()}catch{return""}},D=A=>A.title||`Thread ${A.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(ze,{onClick:R,disabled:N||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:N?"Creating...":"New Chat",children:l.jsx(ne.MessageSquarePlus,{size:20})})}),l.jsx(eh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[l.jsx(ne.Loader2,{className:"h-5 w-5 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(ne.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort((A,K)=>new Date(K.updatedAt||K.createdAt||"").getTime()-new Date(A.updatedAt||A.createdAt||"").getTime()).map(A=>l.jsxs("div",{onClick:()=>O(A.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??m)===A.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:E===A.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:K=>K.stopPropagation(),children:[l.jsx(Ss,{value:k,onChange:K=>I(K.target.value),onKeyDown:K=>U(K,A.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>M(A.threadId),className:"h-6 w-6 p-0",children:l.jsx(ne.Check,{size:12})}),l.jsx(ze,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:l.jsx(ne.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:D(A)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(ne.Calendar,{size:10}),l.jsx("span",{children:V(A.updatedAt||A.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==A.threadId&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:K=>q(A,K),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(ne.Edit3,{size:12})}),n&&l.jsx(ze,{variant:"ghost",size:"sm",onClick:K=>$(A.threadId,K),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:l.jsx(ne.Trash2,{size:12})})]})]}),i===A.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},A.threadId))})})]})}function yr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function X0(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function nh(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=X0(t);if(n)return n}}function rh(){const e=[yr("__API_AUTH_TOKEN__"),yr("__CHAT_API_KEY__"),yr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function oh(){const e={},t=nh(),n=rh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function sh(){const e=oh(),t=Tn.getAuthToken(),n=nh();return{apiBaseUrl:e.baseUrl||Tn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||rh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const ih="chat-settings";function J0(){try{const e=localStorage.getItem(ih);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Z0(e){try{localStorage.setItem(ih,JSON.stringify(e)),e.apiKey&&Tn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Q0(){const e=sh(),t=J0(),n=Tn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Tn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function eS(e){e.apiKey&&Tn.setAuthToken(e.apiKey),Z0(e)}var tS="Label",ah=p.forwardRef((e,t)=>l.jsx(we.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())}}));ah.displayName=tS;var lh=ah;const nS=ro.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Yt=p.forwardRef(({className:e,...t},n)=>l.jsx(lh,{ref:n,className:X(nS(),e),...t}));Yt.displayName=lh.displayName;function ch(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Is="Switch",[rS,AC]=fn(Is),[oS,sS]=rS(Is),uh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),b=Me(t,y=>m(y)),w=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,v]=Kn({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return l.jsxs(oS,{scope:n,checked:x,disabled:a,children:[l.jsx(we.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":ph(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:b,onClick:le(e.onClick,y=>{v(E=>!E),g&&(w.current=y.isPropagationStopped(),w.current||y.stopPropagation())})}),g&&l.jsx(hh,{control:h,bubbles:!w.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});uh.displayName=Is;var dh="SwitchThumb",fh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=sS(dh,n);return l.jsx(we.span,{"data-state":ph(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});fh.displayName=dh;var iS="SwitchBubbleInput",hh=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Me(i,s),c=ch(n),u=kd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const b=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(b)}},[c,n,r]),l.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}})});hh.displayName=iS;function ph(e){return e?"checked":"unchecked"}var mh=uh,aS=fh;const Mn=p.forwardRef(({className:e,...t},n)=>l.jsx(mh,{className:X("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:l.jsx(aS,{className:X("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")})}));Mn.displayName=mh.displayName;var gh=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"}),lS="VisuallyHidden",cS=p.forwardRef((e,t)=>l.jsx(we.span,{...e,ref:t,style:{...gh,...e.style}}));cS.displayName=lS;var uS=[" ","Enter","ArrowUp","ArrowDown"],dS=[" ","Enter"],er="Select",[Ns,As,fS]=qi(er),[Sr,jC]=fn(er,[fS,ms]),js=ms(),[hS,Dn]=Sr(er),[pS,mS]=Sr(er),xh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:b}=e,w=js(t),[g,x]=p.useState(null),[v,y]=p.useState(null),[E,C]=p.useState(!1),k=ss(u),[I,N]=Kn({prop:r,defaultProp:o??!1,onChange:s,caller:er}),[_,O]=Kn({prop:i,defaultProp:a,onChange:c,caller:er}),R=p.useRef(null),$=g?b||!!g.closest("form"):!0,[q,M]=p.useState(new Set),W=Array.from(q).map(U=>U.props.value).join(";");return l.jsx(Od,{...w,children:l.jsxs(hS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:hn(),value:_,onValueChange:O,open:I,onOpenChange:N,dir:k,triggerPointerDownPosRef:R,disabled:h,children:[l.jsx(Ns.Provider,{scope:t,children:l.jsx(pS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(U=>{M(V=>new Set(V).add(U))},[]),onNativeOptionRemove:p.useCallback(U=>{M(V=>{const D=new Set(V);return D.delete(U),D})},[]),children:n})}),$?l.jsxs(Bh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:U=>O(U.target.value),disabled:h,form:b,children:[_===void 0?l.jsx("option",{value:""}):null,Array.from(q)]},W):null]})})};xh.displayName=er;var vh="SelectTrigger",wh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=js(n),i=Dn(vh,n),a=i.disabled||r,c=Me(t,i.onTriggerChange),u=As(n),d=p.useRef("touch"),[f,h,m]=Uh(w=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),v=Wh(g,w,x);v!==void 0&&i.onValueChange(v.value)}),b=w=>{a||(i.onOpenChange(!0),m()),w&&(i.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return l.jsx(Md,{asChild:!0,...s,children:l.jsx(we.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Hh(i.value)?"":void 0,...o,ref:c,onClick:le(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&b(w)}),onPointerDown:le(o.onPointerDown,w=>{d.current=w.pointerType;const g=w.target;g.hasPointerCapture(w.pointerId)&&g.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(b(w),w.preventDefault())}),onKeyDown:le(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&uS.includes(w.key)&&(b(),w.preventDefault())})})})});wh.displayName=vh;var bh="SelectValue",yh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=Dn(bh,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Me(t,c.onValueNodeChange);return bt(()=>{u(d)},[u,d]),l.jsx(we.span,{...a,ref:f,style:{pointerEvents:"none"},children:Hh(c.value)?l.jsx(l.Fragment,{children:i}):s})});yh.displayName=bh;var gS="SelectIcon",Sh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(we.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Sh.displayName=gS;var xS="SelectPortal",Ch=e=>l.jsx(Uo,{asChild:!0,...e});Ch.displayName=xS;var tr="SelectContent",kh=p.forwardRef((e,t)=>{const n=Dn(tr,e.__scopeSelect),[r,o]=p.useState();if(bt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?oo.createPortal(l.jsx(Th,{scope:e.__scopeSelect,children:l.jsx(Ns.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(Eh,{...e,ref:t})});kh.displayName=tr;var sn=10,[Th,Ln]=Sr(tr),vS="SelectContentImpl",wS=$n.createSlot("SelectContent.RemoveScroll"),Eh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:w,avoidCollisions:g,...x}=e,v=Dn(tr,n),[y,E]=p.useState(null),[C,k]=p.useState(null),I=Me(t,B=>E(B)),[N,_]=p.useState(null),[O,R]=p.useState(null),$=As(n),[q,M]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(y)return zi(y)},[y]),Oi();const U=p.useCallback(B=>{const[j,...H]=$().map(ce=>ce.ref.current),[ee]=H.slice(-1),ue=document.activeElement;for(const ce of B)if(ce===ue||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===j&&C&&(C.scrollTop=0),ce===ee&&C&&(C.scrollTop=C.scrollHeight),ce==null||ce.focus(),document.activeElement!==ue))return},[$,C]),V=p.useCallback(()=>U([N,y]),[U,N,y]);p.useEffect(()=>{q&&V()},[q,V]);const{onOpenChange:D,triggerPointerDownPosRef:A}=v;p.useEffect(()=>{if(y){let B={x:0,y:0};const j=ee=>{var ue,ce;B={x:Math.abs(Math.round(ee.pageX)-(((ue=A.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((ce=A.current)==null?void 0:ce.y)??0))}},H=ee=>{B.x<=10&&B.y<=10?ee.preventDefault():y.contains(ee.target)||D(!1),document.removeEventListener("pointermove",j),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",H,{capture:!0})}}},[y,D,A]),p.useEffect(()=>{const B=()=>D(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[D]);const[K,Y]=Uh(B=>{const j=$().filter(ue=>!ue.disabled),H=j.find(ue=>ue.ref.current===document.activeElement),ee=Wh(j,B,H);ee&&setTimeout(()=>ee.ref.current.focus())}),re=p.useCallback((B,j,H)=>{const ee=!W.current&&!H;(v.value!==void 0&&v.value===j||ee)&&(_(B),ee&&(W.current=!0))},[v.value]),te=p.useCallback(()=>y==null?void 0:y.focus(),[y]),pe=p.useCallback((B,j,H)=>{const ee=!W.current&&!H;(v.value!==void 0&&v.value===j||ee)&&R(B)},[v.value]),Se=r==="popper"?Ta:Ih,Te=Se===Ta?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:w,avoidCollisions:g}:{};return l.jsx(Th,{scope:n,content:y,viewport:C,onViewportChange:k,itemRefCallback:re,selectedItem:N,onItemLeave:te,itemTextRefCallback:pe,focusSelectedItem:V,selectedItemText:O,position:r,isPositioned:q,searchRef:K,children:l.jsx(Yo,{as:wS,allowPinchZoom:!0,children:l.jsx(Ho,{asChild:!0,trapped:v.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:le(o,B=>{var j;(j=v.trigger)==null||j.focus({preventScroll:!0}),B.preventDefault()}),children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(Se,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:B=>B.preventDefault(),...x,...Te,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:le(x.onKeyDown,B=>{const j=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!j&&B.key.length===1&&Y(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let ee=$().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(B.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const ue=B.target,ce=ee.indexOf(ue);ee=ee.slice(ce+1)}setTimeout(()=>U(ee)),B.preventDefault()}})})})})})})});Eh.displayName=vS;var bS="SelectItemAlignedPosition",Ih=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Dn(tr,n),i=Ln(tr,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=Me(t,I=>d(I)),h=As(n),m=p.useRef(!1),b=p.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,y=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const ue=O.left-N.left,ce=_.left-ue,_e=I.left-ce,Ne=I.width+_e,Ee=Math.max(Ne,N.width),je=window.innerWidth-sn,Be=wa(ce,[sn,Math.max(sn,je-Ee)]);a.style.minWidth=Ne+"px",a.style.left=Be+"px"}else{const ue=N.right-O.right,ce=window.innerWidth-_.right-ue,_e=window.innerWidth-I.right-ce,Ne=I.width+_e,Ee=Math.max(Ne,N.width),je=window.innerWidth-sn,Be=wa(ce,[sn,Math.max(sn,je-Ee)]);a.style.minWidth=Ne+"px",a.style.right=Be+"px"}const R=h(),$=window.innerHeight-sn*2,q=w.scrollHeight,M=window.getComputedStyle(u),W=parseInt(M.borderTopWidth,10),U=parseInt(M.paddingTop,10),V=parseInt(M.borderBottomWidth,10),D=parseInt(M.paddingBottom,10),A=W+U+q+D+V,K=Math.min(g.offsetHeight*5,A),Y=window.getComputedStyle(w),re=parseInt(Y.paddingTop,10),te=parseInt(Y.paddingBottom,10),pe=I.top+I.height/2-sn,Se=$-pe,Te=g.offsetHeight/2,B=g.offsetTop+Te,j=W+U+B,H=A-j;if(j<=pe){const ue=R.length>0&&g===R[R.length-1].ref.current;a.style.bottom="0px";const ce=u.clientHeight-w.offsetTop-w.offsetHeight,_e=Math.max(Se,Te+(ue?te:0)+ce+V),Ne=j+_e;a.style.height=Ne+"px"}else{const ue=R.length>0&&g===R[0].ref.current;a.style.top="0px";const _e=Math.max(pe,W+w.offsetTop+(ue?re:0)+Te)+H;a.style.height=_e+"px",w.scrollTop=j-pe+w.offsetTop}a.style.margin=`${sn}px 0`,a.style.minHeight=K+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,x,s.dir,r]);bt(()=>y(),[y]);const[E,C]=p.useState();bt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=p.useCallback(I=>{I&&b.current===!0&&(y(),v==null||v(),b.current=!1)},[y,v]);return l.jsx(SS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:k,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(we.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ih.displayName=bS;var yS="SelectPopperPosition",Ta=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=sn,...s}=e,i=js(n);return l.jsx(Dd,{...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)"}})});Ta.displayName=yS;var[SS,Ea]=Sr(tr,{}),Ia="SelectViewport",Nh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Ln(Ia,n),i=Ea(Ia,n),a=Me(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Ns.Slot,{scope:n,children:l.jsx(we.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 m=Math.abs(c.current-d.scrollTop);if(m>0){const b=window.innerHeight-sn*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(w,g);if(x<b){const v=x+m,y=Math.min(b,v),E=v-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Nh.displayName=Ia;var Ah="SelectGroup",[CS,kS]=Sr(Ah),TS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=hn();return l.jsx(CS,{scope:n,id:o,children:l.jsx(we.div,{role:"group","aria-labelledby":o,...r,ref:t})})});TS.displayName=Ah;var jh="SelectLabel",_h=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kS(jh,n);return l.jsx(we.div,{id:o.id,...r,ref:t})});_h.displayName=jh;var _s="SelectItem",[ES,Rh]=Sr(_s),Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Dn(_s,n),c=Ln(_s,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),b=Me(t,v=>{var y;return(y=c.itemRefCallback)==null?void 0:y.call(c,v,r,o)}),w=hn(),g=p.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 l.jsx(ES,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:p.useCallback(v=>{f(y=>y||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(Ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(we.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:le(i.onFocus,()=>m(!0)),onBlur:le(i.onBlur,()=>m(!1)),onClick:le(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:le(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:le(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:le(i.onPointerMove,v=>{var y;g.current=v.pointerType,o?(y=c.onItemLeave)==null||y.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,v=>{var y;v.currentTarget===document.activeElement&&((y=c.onItemLeave)==null||y.call(c))}),onKeyDown:le(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(dS.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});Ph.displayName=_s;var no="SelectItemText",Oh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Dn(no,n),a=Ln(no,n),c=Rh(no,n),u=mS(no,n),[d,f]=p.useState(null),h=Me(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,b=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:w,onNativeOptionRemove:g}=u;return bt(()=>(w(b),()=>g(b)),[w,g,b]),l.jsxs(l.Fragment,{children:[l.jsx(we.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?oo.createPortal(s.children,i.valueNode):null]})});Oh.displayName=no;var Mh="SelectItemIndicator",Dh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Rh(Mh,n).isSelected?l.jsx(we.span,{"aria-hidden":!0,...r,ref:t}):null});Dh.displayName=Mh;var Na="SelectScrollUpButton",Lh=p.forwardRef((e,t)=>{const n=Ln(Na,e.__scopeSelect),r=Ea(Na,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Fh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Lh.displayName=Na;var Aa="SelectScrollDownButton",$h=p.forwardRef((e,t)=>{const n=Ln(Aa,e.__scopeSelect),r=Ea(Aa,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Fh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});$h.displayName=Aa;var Fh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Ln("SelectScrollButton",n),i=p.useRef(null),a=As(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),bt(()=>{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]),l.jsx(we.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,()=>{c()})})}),IS="SelectSeparator",zh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(we.div,{"aria-hidden":!0,...r,ref:t})});zh.displayName=IS;var ja="SelectArrow",NS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=js(n),s=Dn(ja,n),i=Ln(ja,n);return s.open&&i.position==="popper"?l.jsx(Ld,{...o,...r,ref:t}):null});NS.displayName=ja;var AS="SelectBubbleInput",Bh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Me(r,o),i=ch(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(we.select,{...n,style:{...gh,...n.style},ref:s,defaultValue:t})});Bh.displayName=AS;function Hh(e){return e===""||e===void 0}function Uh(e){const t=kt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Wh(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=jS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function jS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _S=xh,Vh=wh,RS=yh,PS=Sh,OS=Ch,Kh=kh,MS=Nh,qh=_h,Gh=Ph,DS=Oh,LS=Dh,Yh=Lh,Xh=$h,Jh=zh;const Zh=_S,Qh=RS,_a=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Vh,{ref:r,className:X("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,l.jsx(PS,{asChild:!0,children:l.jsx(ne.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));_a.displayName=Vh.displayName;const ep=p.forwardRef(({className:e,...t},n)=>l.jsx(Yh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ne.ChevronUp,{className:"h-4 w-4"})}));ep.displayName=Yh.displayName;const tp=p.forwardRef(({className:e,...t},n)=>l.jsx(Xh,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ne.ChevronDown,{className:"h-4 w-4"})}));tp.displayName=Xh.displayName;const Ra=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(OS,{children:l.jsxs(Kh,{ref:o,className:X("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:[l.jsx(ep,{}),l.jsx(MS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(tp,{})]})}));Ra.displayName=Kh.displayName;const $S=p.forwardRef(({className:e,...t},n)=>l.jsx(qh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));$S.displayName=qh.displayName;const nr=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Gh,{ref:r,className:X("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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(LS,{children:l.jsx(ne.Check,{className:"h-4 w-4"})})}),l.jsx(DS,{children:t})]}));nr.displayName=Gh.displayName;const FS=p.forwardRef(({className:e,...t},n)=>l.jsx(Jh,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));FS.displayName=Jh.displayName;var zS="Separator",np="horizontal",BS=["horizontal","vertical"],rp=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=np,...o}=e,s=HS(r)?r:np,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(we.div,{"data-orientation":s,...a,...o,ref:t})});rp.displayName=zS;function HS(e){return BS.includes(e)}var op=rp;const sp=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(op,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));sp.displayName=op.displayName;const US=Hu,WS=yw,VS=Uu,ip=p.forwardRef(({className:e,...t},n)=>l.jsx(es,{className:X("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}));ip.displayName=es.displayName;const KS=ro.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"}}),ap=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(VS,{children:[l.jsx(ip,{}),l.jsxs(ts,{ref:o,className:X(KS({side:e}),t),...r,children:[n,l.jsxs(Wu,{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:[l.jsx(ne.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ap.displayName=ts.displayName;const lp=({className:e,...t})=>l.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});lp.displayName="SheetHeader";const cp=p.forwardRef(({className:e,...t},n)=>l.jsx(Yn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));cp.displayName=Yn.displayName;const up=p.forwardRef(({className:e,...t},n)=>l.jsx(ns,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));up.displayName=ns.displayName;const qS={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 GS({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=S.useState(!1),[s,i]=S.useState(!1),[a,c]=S.useState(e),[u,d]=S.useState(!1),{toast:f}=Ai();S.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),S.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(qS),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{c(e),d(!1),o(!1)},w=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 l.jsxs(US,{open:r,onOpenChange:o,children:[l.jsx(WS,{asChild:!0,children:l.jsxs(ze,{variant:"outline",size:"sm",className:n,children:[l.jsx(ne.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(bi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(ap,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(lp,{children:[l.jsx(cp,{children:"Chat Settings"}),l.jsx(up,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(Hr,{children:[l.jsx(Ur,{className:"pb-3",children:l.jsxs(Wr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Yt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(ze,{variant:"outline",onClick:w,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Yt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(Mn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(Yt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(ze,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(ne.EyeOff,{className:"h-4 w-4"}):l.jsx(ne.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(Hr,{children:[l.jsx(Ur,{className:"pb-3",children:l.jsxs(Wr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(Yt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Zh,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(_a,{children:l.jsx(Qh,{})}),l.jsxs(Ra,{children:[l.jsx(nr,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(nr,{value:"fullscreen",children:"Fullscreen"}),l.jsx(nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(Yt,{htmlFor:"theme",children:"Theme"}),l.jsxs(Zh,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(_a,{children:l.jsx(Qh,{})}),l.jsxs(Ra,{children:[l.jsx(nr,{value:"light",children:"Light"}),l.jsx(nr,{value:"dark",children:"Dark"}),l.jsx(nr,{value:"system",children:"System"})]})]})]}),l.jsx(sp,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Yt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(Mn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Yt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(Mn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Yt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(Mn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(Hr,{children:[l.jsx(Ur,{className:"pb-3",children:l.jsxs(Wr,{className:"text-lg flex items-center gap-2",children:[l.jsx(ne.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Yt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(Mn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Yt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(Mn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(Yt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(Mn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(ze,{variant:"outline",onClick:m,children:[l.jsx(ne.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ze,{variant:"outline",onClick:b,children:"Cancel"}),l.jsxs(ze,{onClick:h,disabled:!u,children:[l.jsx(ne.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function YS({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"}),c=S.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(xo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(xo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ka,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(xo,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(ka,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ys,{onError:s.onError,enableFileUpload:!0})})]})})}Ce.ChatApi=Nl,Ce.ChatInterface=ys,Ce.ChatProvider=xo,Ce.ChatSettings=GS,Ce.MarkdownContent=$o,Ce.MessageComponent=Qu,Ce.MessageList=Ki,Ce.ThreadManager=ka,Ce.applySettings=eS,Ce.chatApiClient=Tn,Ce.default=YS,Ce.del=Il,Ce.get=Lt,Ce.getChatToken=kl,Ce.getCurrentSettings=Q0,Ce.getDefaultApiConfig=oh,Ce.getDefaultChatSettings=sh,Ce.onChatTokenChanged=Tl,Ce.post=qs,Ce.put=El,Ce.setChatToken=Ks,Ce.useChat=_r,Ce.useChatStream=Al,Ce.useMessagesReducer=jl,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
139
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Yw(e,t=os){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function Xw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Yw(t),Gw(t)}function Yi(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:x}=w,v=y.useRef(null),S=y.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:S,collectionRef:v,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=Mn.createSlot(a),u=y.forwardRef((w,g)=>{const{scope:x,children:v}=w,S=s(a,x),E=Me(g,S.collectionRef);return l.jsx(c,{ref:E,children:v})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Mn.createSlot(d),m=y.forwardRef((w,g)=>{const{scope:x,children:v,...S}=w,E=y.useRef(null),C=Me(g,E),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(E,{ref:E,...S}),()=>void k.itemMap.delete(E))),l.jsx(h,{[f]:"",ref:C,children:v})});m.displayName=d;function b(w){const g=s(e+"CollectionConsumer",w);return y.useCallback(()=>{const v=g.collectionRef.current;if(!v)return[];const S=Array.from(v.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:m},b,r]}var Jw=p.createContext(void 0);function ss(e){const t=p.useContext(Jw);return e||t||"ltr"}const Zw=["top","right","bottom","left"],An=Math.min,Ft=Math.max,is=Math.round,as=Math.floor,dn=e=>({x:e,y:e}),Qw={left:"right",right:"left",bottom:"top",top:"bottom"},eb={start:"end",end:"start"};function Xi(e,t,n){return Ft(e,An(t,n))}function vn(e,t){return typeof e=="function"?e(t):e}function wn(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function Ji(e){return e==="x"?"y":"x"}function Zi(e){return e==="y"?"height":"width"}const tb=new Set(["top","bottom"]);function fn(e){return tb.has(wn(e))?"y":"x"}function Qi(e){return Ji(fn(e))}function nb(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=Qi(e),s=Zi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ls(i)),[i,ls(i)]}function rb(e){const t=ls(e);return[ea(e),t,ea(t)]}function ea(e){return e.replace(/start|end/g,t=>eb[t])}const od=["left","right"],sd=["right","left"],ob=["top","bottom"],sb=["bottom","top"];function ib(e,t,n){switch(e){case"top":case"bottom":return n?t?sd:od:t?od:sd;case"left":case"right":return t?ob:sb;default:return[]}}function ab(e,t,n,r){const o=hr(e);let s=ib(wn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ea)))),s}function ls(e){return e.replace(/left|right|bottom|top/g,t=>Qw[t])}function lb(e){return{top:0,right:0,bottom:0,left:0,...e}}function id(e){return typeof e!="number"?lb(e):{top:e,right:e,bottom:e,left:e}}function cs(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 ad(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=Qi(t),a=Zi(i),c=wn(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 m;switch(c){case"top":m={x:d,y:r.y-o.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-o.width,y:f};break;default:m={x:r.x,y:r.y}}switch(hr(t)){case"start":m[i]-=h*(n&&u?-1:1);break;case"end":m[i]+=h*(n&&u?-1:1);break}return m}const cb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ad(u,r,c),h=r,m={},b=0;for(let w=0;w<a.length;w++){const{name:g,fn:x}=a[w],{x:v,y:S,data:E,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:m,rects:u,platform:i,elements:{reference:e,floating:t}});d=v??d,f=S??f,m={...m,[g]:{...m[g],...E}},C&&b<=50&&(b++,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}=ad(u,h,c)),w=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:m}};async function qr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:m=0}=vn(t,e),b=id(m),g=a[h?f==="floating"?"reference":"floating":f],x=cs(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:c})),v=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=cs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:S,strategy:c}):v);return{top:(x.top-C.top+b.top)/E.y,bottom:(C.bottom-x.bottom+b.bottom)/E.y,left:(x.left-C.left+b.left)/E.x,right:(C.right-x.right+b.right)/E.x}}const ub=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=vn(e,t)||{};if(u==null)return{};const f=id(d),h={x:n,y:r},m=Qi(o),b=Zi(m),w=await i.getDimensions(u),g=m==="y",x=g?"top":"left",v=g?"bottom":"right",S=g?"clientHeight":"clientWidth",E=s.reference[b]+s.reference[m]-h[m]-s.floating[b],C=h[m]-s.reference[m],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[b]);const N=E/2-C/2,_=I/2-w[b]/2-1,O=An(f[x],_),R=An(f[v],_),$=O,K=I-w[b]-R,M=I/2-w[b]/2+N,W=Xi($,M,K),U=!c.arrow&&hr(o)!=null&&M!==W&&s.reference[b]/2-(M<$?O:R)-w[b]/2<0,V=U?M<$?M-$:M-K:0;return{[m]:h[m]+V,data:{[m]:W,centerOffset:M-W-V,...U&&{alignmentOffset:V}},reset:U}}}),db=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:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...g}=vn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=wn(o),v=fn(a),S=wn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=h||(S||!w?[ls(a)]:rb(a)),k=b!=="none";!h&&k&&C.push(...ab(a,w,b,E));const I=[a,...C],N=await qr(t,g),_=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(N[x]),f){const M=nb(o,i,E);_.push(N[M[0]],N[M[1]])}if(O=[...O,{placement:o,overflows:_}],!_.every(M=>M<=0)){var R,$;const M=(((R=s.flip)==null?void 0:R.index)||0)+1,W=I[M];if(W&&(!(f==="alignment"?v!==fn(W):!1)||O.every(L=>fn(L.placement)===v?L.overflows[0]>0:!0)))return{data:{index:M,overflows:O},reset:{placement:W}};let U=($=O.filter(V=>V.overflows[0]<=0).sort((V,L)=>V.overflows[1]-L.overflows[1])[0])==null?void 0:$.placement;if(!U)switch(m){case"bestFit":{var K;const V=(K=O.filter(L=>{if(k){const A=fn(L.placement);return A===v||A==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(A=>A>0).reduce((A,q)=>A+q,0)]).sort((L,A)=>L[1]-A[1])[0])==null?void 0:K[0];V&&(U=V);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function ld(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function cd(e){return Zw.some(t=>e[t]>=0)}const fb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=vn(e,t);switch(r){case"referenceHidden":{const s=await qr(t,{...o,elementContext:"reference"}),i=ld(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:cd(i)}}}case"escaped":{const s=await qr(t,{...o,altBoundary:!0}),i=ld(s,n.floating);return{data:{escapedOffsets:i,escaped:cd(i)}}}default:return{}}}}},ud=new Set(["left","top"]);async function hb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=wn(n),a=hr(n),c=fn(n)==="y",u=ud.has(i)?-1:1,d=s&&c?-1:1,f=vn(t,e);let{mainAxis:h,crossAxis:m,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(m=a==="end"?b*-1:b),c?{x:m*d,y:h*u}:{x:h*u,y:m*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,c=await hb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},mb=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:v}=g;return{x,y:v}}},...c}=vn(e,t),u={x:n,y:r},d=await qr(t,c),f=fn(wn(o)),h=Ji(f);let m=u[h],b=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+d[g],S=m-d[x];m=Xi(v,m,S)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=b+d[g],S=b-d[x];b=Xi(v,b,S)}const w=a.fn({...t,[h]:m,[f]:b});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:s,[f]:i}}}}}},gb=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:c=!0,crossAxis:u=!0}=vn(e,t),d={x:n,y:r},f=fn(o),h=Ji(f);let m=d[h],b=d[f];const w=vn(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const S=h==="y"?"height":"width",E=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;m<E?m=E:m>C&&(m=C)}if(u){var x,v;const S=h==="y"?"width":"height",E=ud.has(wn(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:((v=i.offset)==null?void 0:v[f])||0)-(E?g.crossAxis:0);b<C?b=C:b>k&&(b=k)}return{[h]:m,[f]:b}}}},xb=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:c=()=>{},...u}=vn(e,t),d=await qr(t,u),f=wn(o),h=hr(o),m=fn(o)==="y",{width:b,height:w}=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 v=w-d.top-d.bottom,S=b-d.left-d.right,E=An(w-d[g],v),C=An(b-d[x],S),k=!t.middlewareData.shift;let I=E,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=v),k&&!h){const O=Ft(d.left,0),R=Ft(d.right,0),$=Ft(d.top,0),K=Ft(d.bottom,0);m?N=b-2*(O!==0||R!==0?O+R:Ft(d.left,d.right)):I=w-2*($!==0||K!==0?$+K:Ft(d.top,d.bottom))}await c({...t,availableWidth:N,availableHeight:I});const _=await i.getDimensions(a.floating);return b!==_.width||w!==_.height?{reset:{rects:!0}}:{}}}};function us(){return typeof window<"u"}function pr(e){return dd(e)?(e.nodeName||"").toLowerCase():"#document"}function zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=(dd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dd(e){return us()?e instanceof Node||e instanceof zt(e).Node:!1}function en(e){return us()?e instanceof Element||e instanceof zt(e).Element:!1}function pn(e){return us()?e instanceof HTMLElement||e instanceof zt(e).HTMLElement:!1}function fd(e){return!us()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof zt(e).ShadowRoot}const vb=new Set(["inline","contents"]);function Kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=tn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!vb.has(o)}const wb=new Set(["table","td","th"]);function bb(e){return wb.has(pr(e))}const yb=[":popover-open",":modal"];function ds(e){return yb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Sb=["transform","translate","scale","rotate","perspective"],Cb=["transform","translate","scale","rotate","perspective","filter"],kb=["paint","layout","strict","content"];function ta(e){const t=na(),n=en(e)?tn(e):e;return Sb.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)||Cb.some(r=>(n.willChange||"").includes(r))||kb.some(r=>(n.contain||"").includes(r))}function Tb(e){let t=jn(e);for(;pn(t)&&!mr(t);){if(ta(t))return t;if(ds(t))return null;t=jn(t)}return null}function na(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Eb=new Set(["html","body","#document"]);function mr(e){return Eb.has(pr(e))}function tn(e){return zt(e).getComputedStyle(e)}function fs(e){return en(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function jn(e){if(pr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fd(e)&&e.host||hn(e);return fd(t)?t.host:t}function hd(e){const t=jn(e);return mr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&Kr(t)?t:hd(t)}function Gr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=hd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=zt(o);if(s){const a=ra(i);return t.concat(i,i.visualViewport||[],Kr(o)?o:[],a&&n?Gr(a):[])}return t.concat(o,Gr(o,[],n))}function ra(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pd(e){const t=tn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=pn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=is(n)!==s||is(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function oa(e){return en(e)?e:e.contextElement}function gr(e){const t=oa(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=pd(t);let i=(s?is(n.width):n.width)/r,a=(s?is(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Ib=dn(0);function md(e){const t=zt(e);return!na()||!t.visualViewport?Ib:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Nb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==zt(e)?!1:t}function Gn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=oa(e);let i=dn(1);t&&(r?en(r)&&(i=gr(r)):i=gr(e));const a=Nb(s,n,r)?md(s):dn(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=zt(s),m=r&&en(r)?zt(r):r;let b=h,w=ra(b);for(;w&&r&&m!==b;){const g=gr(w),x=w.getBoundingClientRect(),v=tn(w),S=x.left+(w.clientLeft+parseFloat(v.paddingLeft))*g.x,E=x.top+(w.clientTop+parseFloat(v.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=S,u+=E,b=zt(w),w=ra(b)}}return cs({width:d,height:f,x:c,y:u})}function sa(e,t){const n=fs(e).scrollLeft;return t?t.left+n:Gn(hn(e)).left+n}function gd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:sa(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Ab(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=hn(r),a=t?ds(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=dn(1);const d=dn(0),f=pn(r);if((f||!f&&!s)&&((pr(r)!=="body"||Kr(i))&&(c=fs(r)),pn(r))){const m=Gn(r);u=gr(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=i&&!f&&!s?gd(i,c,!0):dn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function jb(e){return Array.from(e.getClientRects())}function _b(e){const t=hn(e),n=fs(e),r=e.ownerDocument.body,o=Ft(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ft(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+sa(e);const a=-n.scrollTop;return tn(r).direction==="rtl"&&(i+=Ft(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Rb(e,t){const n=zt(e),r=hn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const u=na();(!u||u&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}return{width:s,height:i,x:a,y:c}}const Pb=new Set(["absolute","fixed"]);function Ob(e,t){const n=Gn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=pn(e)?gr(e):dn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function xd(e,t,n){let r;if(t==="viewport")r=Rb(e,n);else if(t==="document")r=_b(hn(e));else if(en(t))r=Ob(t,n);else{const o=md(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return cs(r)}function vd(e,t){const n=jn(e);return n===t||!en(n)||mr(n)?!1:tn(n).position==="fixed"||vd(n,t)}function Mb(e,t){const n=t.get(e);if(n)return n;let r=Gr(e,[],!1).filter(a=>en(a)&&pr(a)!=="body"),o=null;const s=tn(e).position==="fixed";let i=s?jn(e):e;for(;en(i)&&!mr(i);){const a=tn(i),c=ta(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Pb.has(o.position)||Kr(i)&&!c&&vd(e,i))?r=r.filter(d=>d!==i):o=a,i=jn(i)}return t.set(e,r),r}function Db(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ds(t)?[]:Mb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=xd(t,d,o);return u.top=Ft(f.top,u.top),u.right=An(f.right,u.right),u.bottom=An(f.bottom,u.bottom),u.left=Ft(f.left,u.left),u},xd(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Lb(e){const{width:t,height:n}=pd(e);return{width:t,height:n}}function $b(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=Gn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=dn(0);function u(){c.x=sa(o)}if(r||!r&&!s)if((pr(t)!=="body"||Kr(o))&&(a=fs(t)),r){const m=Gn(t,!0,s,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?gd(o,a):dn(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function ia(e){return tn(e).position==="static"}function wd(e,t){if(!pn(e)||tn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return hn(e)===n&&(n=n.ownerDocument.body),n}function bd(e,t){const n=zt(e);if(ds(e))return n;if(!pn(e)){let o=jn(e);for(;o&&!mr(o);){if(en(o)&&!ia(o))return o;o=jn(o)}return n}let r=wd(e,t);for(;r&&bb(r)&&ia(r);)r=wd(r,t);return r&&mr(r)&&ia(r)&&!ta(r)?n:r||Tb(e)||n}const Fb=async function(e){const t=this.getOffsetParent||bd,n=this.getDimensions,r=await n(e.floating);return{reference:$b(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zb(e){return tn(e).direction==="rtl"}const Bb={convertOffsetParentRelativeRectToViewportRelativeRect:Ab,getDocumentElement:hn,getClippingRect:Db,getOffsetParent:bd,getElementRects:Fb,getClientRects:jb,getDimensions:Lb,getScale:gr,isElement:en,isRTL:zb};function yd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Hb(e,t){let n=null,r;const o=hn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:m}=u;if(a||t(),!h||!m)return;const b=as(f),w=as(o.clientWidth-(d+h)),g=as(o.clientHeight-(f+m)),x=as(d),S={rootMargin:-b+"px "+-w+"px "+-g+"px "+-x+"px",threshold:Ft(0,An(1,c))||1};let E=!0;function C(k){const I=k[0].intersectionRatio;if(I!==c){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!yd(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 Ub(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:c=!1}=r,u=oa(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?Hb(u,n):null;let h=-1,m=null;i&&(m=new ResizeObserver(x=>{let[v]=x;v&&v.target===u&&m&&(m.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=m)==null||S.observe(t)})),n()}),u&&!c&&m.observe(u),m.observe(t));let b,w=c?Gn(e):null;c&&g();function g(){const x=Gn(e);w&&!yd(w,x)&&n(),w=x,b=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(x=m)==null||x.disconnect(),m=null,c&&cancelAnimationFrame(b)}}const Wb=pb,Vb=mb,qb=db,Kb=xb,Gb=fb,Sd=ub,Yb=gb,Xb=(e,t,n)=>{const r=new Map,o={platform:Bb,...n},s={...o.platform,_c:r};return cb(e,t,{...o,platform:s})};var Jb=typeof document<"u",Zb=function(){},hs=Jb?y.useLayoutEffect:Zb;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 Cd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kd(e,t){const n=Cd(e);return Math.round(t*n)/n}function aa(e){const t=p.useRef(e);return hs(()=>{t.current=e}),t}function Qb(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:c,open:u}=e,[d,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,m]=p.useState(r);ps(h,r)||m(r);const[b,w]=p.useState(null),[g,x]=p.useState(null),v=p.useCallback(L=>{L!==k.current&&(k.current=L,w(L))},[]),S=p.useCallback(L=>{L!==I.current&&(I.current=L,x(L))},[]),E=s||b,C=i||g,k=p.useRef(null),I=p.useRef(null),N=p.useRef(d),_=c!=null,O=aa(c),R=aa(o),$=aa(u),K=p.useCallback(()=>{if(!k.current||!I.current)return;const L={placement:t,strategy:n,middleware:h};R.current&&(L.platform=R.current),Xb(k.current,I.current,L).then(A=>{const q={...A,isPositioned:$.current!==!1};M.current&&!ps(N.current,q)&&(N.current=q,oo.flushSync(()=>{f(q)}))})},[h,t,n,R,$]);hs(()=>{u===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(L=>({...L,isPositioned:!1})))},[u]);const M=p.useRef(!1);hs(()=>(M.current=!0,()=>{M.current=!1}),[]),hs(()=>{if(E&&(k.current=E),C&&(I.current=C),E&&C){if(O.current)return O.current(E,C,K);K()}},[E,C,K,O,_]);const W=p.useMemo(()=>({reference:k,floating:I,setReference:v,setFloating:S}),[v,S]),U=p.useMemo(()=>({reference:E,floating:C}),[E,C]),V=p.useMemo(()=>{const L={position:n,left:0,top:0};if(!U.floating)return L;const A=kd(U.floating,d.x),q=kd(U.floating,d.y);return a?{...L,transform:"translate("+A+"px, "+q+"px)",...Cd(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:q}},[n,a,U.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:K,refs:W,elements:U,floatingStyles:V}),[d,K,W,U,V])}const ey=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?Sd({element:r.current,padding:o}).fn(n):{}:r?Sd({element:r,padding:o}).fn(n):{}}}},ty=(e,t)=>({...Wb(e),options:[e,t]}),ny=(e,t)=>({...Vb(e),options:[e,t]}),ry=(e,t)=>({...Yb(e),options:[e,t]}),oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Kb(e),options:[e,t]}),iy=(e,t)=>({...Gb(e),options:[e,t]}),ay=(e,t)=>({...ey(e),options:[e,t]});var ly="Arrow",Td=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(we.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Td.displayName=ly;var cy=Td;function Ed(e){const[t,n]=p.useState(void 0);return bt(()=>{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 c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;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 la="Popper",[Id,ms]=ln(la),[uy,Nd]=Id(la),Ad=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return l.jsx(uy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Ad.displayName=la;var jd="PopperAnchor",_d=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Nd(jd,n),i=p.useRef(null),a=Me(t,i),c=p.useRef(null);return p.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(we.div,{...o,ref:a})});_d.displayName=jd;var ca="PopperContent",[dy,fy]=Id(ca),Rd=p.forwardRef((e,t)=>{var B,j,H,ee,ue,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:b,...w}=e,g=Nd(ca,n),[x,v]=p.useState(null),S=Me(t,Oe=>v(Oe)),[E,C]=p.useState(null),k=Ed(E),I=(k==null?void 0:k.width)??0,N=(k==null?void 0:k.height)??0,_=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},R=Array.isArray(u)?u:[u],$=R.length>0,K={padding:O,boundary:R.filter(py),altBoundary:$},{refs:M,floatingStyles:W,placement:U,isPositioned:V,middlewareData:L}=Qb({strategy:"fixed",placement:_,whileElementsMounted:(...Oe)=>Ub(...Oe,{animationFrame:m==="always"}),elements:{reference:g.anchor},middleware:[ty({mainAxis:o+N,alignmentAxis:i}),c&&ny({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?ry():void 0,...K}),c&&oy({...K}),sy({...K,apply:({elements:Oe,rects:Ge,availableWidth:ke,availableHeight:be})=>{const{width:Ue,height:Ye}=Ge.reference,$e=Oe.floating.style;$e.setProperty("--radix-popper-available-width",`${ke}px`),$e.setProperty("--radix-popper-available-height",`${be}px`),$e.setProperty("--radix-popper-anchor-width",`${Ue}px`),$e.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),E&&ay({element:E,padding:a}),my({arrowWidth:I,arrowHeight:N}),h&&iy({strategy:"referenceHidden",...K})]}),[A,q]=Md(U),J=St(b);bt(()=>{V&&(J==null||J())},[V,J]);const se=(B=L.arrow)==null?void 0:B.x,te=(j=L.arrow)==null?void 0:j.y,pe=((H=L.arrow)==null?void 0:H.centerOffset)!==0,[Ie,Ne]=p.useState();return bt(()=>{x&&Ne(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:V?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ie,"--radix-popper-transform-origin":[(ee=L.transformOrigin)==null?void 0:ee.x,(ue=L.transformOrigin)==null?void 0:ue.y].join(" "),...((ce=L.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(dy,{scope:n,placedSide:A,onArrowChange:C,arrowX:se,arrowY:te,shouldHideArrow:pe,children:l.jsx(we.div,{"data-side":A,"data-align":q,...w,ref:S,style:{...w.style,animation:V?void 0:"none"}})})})});Rd.displayName=ca;var Pd="PopperArrow",hy={top:"bottom",right:"left",bottom:"top",left:"right"},Od=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=fy(Pd,r),i=hy[s.placedSide];return l.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:l.jsx(cy,{...o,ref:n,style:{...o.style,display:"block"}})})});Od.displayName=Pd;function py(e){return e!==null}var my=e=>({name:"transformOrigin",options:e,fn(t){var g,x,v;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=Md(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,m=(((v=o.arrow)==null?void 0:v.y)??0)+c/2;let b="",w="";return u==="bottom"?(b=i?f:`${h}px`,w=`${-c}px`):u==="top"?(b=i?f:`${h}px`,w=`${r.floating.height+c}px`):u==="right"?(b=`${-c}px`,w=i?f:`${m}px`):u==="left"&&(b=`${r.floating.width+c}px`,w=i?f:`${m}px`),{data:{x:b,y:w}}}});function Md(e){const[t,n="center"]=e.split("-");return[t,n]}var Dd=Ad,Ld=_d,$d=Rd,Fd=Od,ua="rovingFocusGroup.onEntryFocus",gy={bubbles:!1,cancelable:!0},Yr="RovingFocusGroup",[da,zd,xy]=Yi(Yr),[vy,Bd]=ln(Yr,[xy]),[wy,by]=vy(Yr),Hd=p.forwardRef((e,t)=>l.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(yy,{...e,ref:t})})}));Hd.displayName=Yr;var yy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=p.useRef(null),m=Me(t,h),b=ss(s),[w,g]=Un({prop:i,defaultProp:a??null,onChange:c,caller:Yr}),[x,v]=p.useState(!1),S=St(u),E=zd(n),C=p.useRef(!1),[k,I]=p.useState(0);return p.useEffect(()=>{const N=h.current;if(N)return N.addEventListener(ua,S),()=>N.removeEventListener(ua,S)},[S]),l.jsx(wy,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:w,onItemFocus:p.useCallback(N=>g(N),[g]),onItemShiftTab:p.useCallback(()=>v(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:l.jsx(we.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,N=>{const _=!C.current;if(N.target===N.currentTarget&&_&&!x){const O=new CustomEvent(ua,gy);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const R=E().filter(U=>U.focusable),$=R.find(U=>U.active),K=R.find(U=>U.id===w),W=[$,K,...R].filter(Boolean).map(U=>U.ref.current);Vd(W,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>v(!1))})})}),Ud="RovingFocusGroupItem",Wd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=cn(),u=s||c,d=by(Ud,n),f=d.currentTabStopId===u,h=zd(n),{onFocusableItemAdd:m,onFocusableItemRemove:b,currentTabStopId:w}=d;return p.useEffect(()=>{if(r)return m(),()=>b()},[r,m,b]),l.jsx(da.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(we.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=ky(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?Ty(S,E+1):S.slice(E+1)}setTimeout(()=>Vd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Wd.displayName=Ud;var Sy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Cy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ky(e,t,n){const r=Cy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Sy[r]}function Vd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ty(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ey=Hd,Iy=Wd,fa=["Enter"," "],Ny=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],Ay=[...Ny,...qd],jy={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},_y={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Xr="Menu",[Jr,Ry,Py]=Yi(Xr),[Yn,Kd]=ln(Xr,[Py,ms,Bd]),gs=ms(),Gd=Bd(),[Oy,Xn]=Yn(Xr),[My,Zr]=Yn(Xr),Yd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=gs(t),[c,u]=p.useState(null),d=p.useRef(!1),f=St(s),h=ss(o);return p.useEffect(()=>{const m=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),l.jsx(Dd,{...a,children:l.jsx(Oy,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(My,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Yd.displayName=Xr;var Dy="MenuAnchor",ha=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return l.jsx(Ld,{...o,...r,ref:t})});ha.displayName=Dy;var pa="MenuPortal",[Ly,Xd]=Yn(pa,{forceMount:void 0}),Jd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Xn(pa,t);return l.jsx(Ly,{scope:t,forceMount:n,children:l.jsx($t,{present:n||s.open,children:l.jsx(Uo,{asChild:!0,container:o,children:r})})})};Jd.displayName=pa;var Wt="MenuContent",[$y,ma]=Yn(Wt),Zd=p.forwardRef((e,t)=>{const n=Xd(Wt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Wt,e.__scopeMenu),i=Zr(Wt,e.__scopeMenu);return l.jsx(Jr.Provider,{scope:e.__scopeMenu,children:l.jsx($t,{present:r||s.open,children:l.jsx(Jr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(Fy,{...o,ref:t}):l.jsx(zy,{...o,ref:t})})})})}),Fy=p.forwardRef((e,t)=>{const n=Xn(Wt,e.__scopeMenu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),l.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),zy=p.forwardRef((e,t)=>{const n=Xn(Wt,e.__scopeMenu);return l.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),By=Mn.createSlot("MenuContent.ScrollLock"),ga=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,disableOutsideScroll:b,...w}=e,g=Xn(Wt,n),x=Zr(Wt,n),v=gs(n),S=Gd(n),E=Ry(n),[C,k]=p.useState(null),I=p.useRef(null),N=Me(t,I,g.onContentChange),_=p.useRef(0),O=p.useRef(""),R=p.useRef(0),$=p.useRef(null),K=p.useRef("right"),M=p.useRef(0),W=b?Yo:p.Fragment,U=b?{as:By,allowPinchZoom:!0}:void 0,V=A=>{var B,j;const q=O.current+A,J=E().filter(H=>!H.disabled),se=document.activeElement,te=(B=J.find(H=>H.ref.current===se))==null?void 0:B.textValue,pe=J.map(H=>H.textValue),Ie=Qy(pe,q,te),Ne=(j=J.find(H=>H.textValue===Ie))==null?void 0:j.ref.current;(function H(ee){O.current=ee,window.clearTimeout(_.current),ee!==""&&(_.current=window.setTimeout(()=>H(""),1e3))})(q),Ne&&setTimeout(()=>Ne.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Di();const L=p.useCallback(A=>{var J,se;return K.current===((J=$.current)==null?void 0:J.side)&&t0(A,(se=$.current)==null?void 0:se.area)},[]);return l.jsx($y,{scope:n,searchRef:O,onItemEnter:p.useCallback(A=>{L(A)&&A.preventDefault()},[L]),onItemLeave:p.useCallback(A=>{var q;L(A)||((q=I.current)==null||q.focus(),k(null))},[L]),onTriggerLeave:p.useCallback(A=>{L(A)&&A.preventDefault()},[L]),pointerGraceTimerRef:R,onPointerGraceIntentChange:p.useCallback(A=>{$.current=A},[]),children:l.jsx(W,{...U,children:l.jsx(Ho,{asChild:!0,trapped:o,onMountAutoFocus:le(s,A=>{var q;A.preventDefault(),(q=I.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:m,children:l.jsx(Ey,{asChild:!0,...S,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:le(c,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx($d,{role:"menu","aria-orientation":"vertical","data-state":gf(g.open),"data-radix-menu-content":"",dir:x.dir,...v,...w,ref:N,style:{outline:"none",...w.style},onKeyDown:le(w.onKeyDown,A=>{const J=A.target.closest("[data-radix-menu-content]")===A.currentTarget,se=A.ctrlKey||A.altKey||A.metaKey,te=A.key.length===1;J&&(A.key==="Tab"&&A.preventDefault(),!se&&te&&V(A.key));const pe=I.current;if(A.target!==pe||!Ay.includes(A.key))return;A.preventDefault();const Ne=E().filter(B=>!B.disabled).map(B=>B.ref.current);qd.includes(A.key)&&Ne.reverse(),Jy(Ne)}),onBlur:le(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(_.current),O.current="")}),onPointerMove:le(e.onPointerMove,eo(A=>{const q=A.target,J=M.current!==A.clientX;if(A.currentTarget.contains(q)&&J){const se=A.clientX>M.current?"right":"left";K.current=se,M.current=A.clientX}}))})})})})})})});Zd.displayName=Wt;var Hy="MenuGroup",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{role:"group",...r,ref:t})});xa.displayName=Hy;var Uy="MenuLabel",Qd=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{...r,ref:t})});Qd.displayName=Uy;var xs="MenuItem",ef="menu.itemSelect",vs=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=Zr(xs,e.__scopeMenu),a=ma(xs,e.__scopeMenu),c=Me(t,s),u=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ef,{bubbles:!0,cancelable:!0});f.addEventListener(ef,m=>r==null?void 0:r(m),{once:!0}),Mc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(tf,{...o,ref:c,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===" "||fa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});vs.displayName=xs;var tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(xs,n),a=Gd(n),c=p.useRef(null),u=Me(t,c),[d,f]=p.useState(!1),[h,m]=p.useState("");return p.useEffect(()=>{const b=c.current;b&&m((b.textContent??"").trim())},[s.children]),l.jsx(Jr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(Iy,{asChild:!0,...a,focusable:!r,children:l.jsx(we.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(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,eo(b=>i.onItemLeave(b))),onFocus:le(e.onFocus,()=>f(!0)),onBlur:le(e.onBlur,()=>f(!1))})})})}),Wy="MenuCheckboxItem",nf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(lf,{scope:e.__scopeMenu,checked:n,children:l.jsx(vs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nf.displayName=Wy;var rf="MenuRadioGroup",[Vy,qy]=Yn(rf,{value:void 0,onValueChange:()=>{}}),of=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=St(r);return l.jsx(Vy,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(xa,{...o,ref:t})})});of.displayName=rf;var sf="MenuRadioItem",af=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=qy(sf,e.__scopeMenu),s=n===o.value;return l.jsx(lf,{scope:e.__scopeMenu,checked:s,children:l.jsx(vs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});af.displayName=sf;var va="MenuItemIndicator",[lf,Ky]=Yn(va,{checked:!1}),cf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Ky(va,n);return l.jsx($t,{present:r||ws(s.checked)||s.checked===!0,children:l.jsx(we.span,{...o,ref:t,"data-state":wa(s.checked)})})});cf.displayName=va;var Gy="MenuSeparator",uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(we.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});uf.displayName=Gy;var Yy="MenuArrow",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=gs(n);return l.jsx(Fd,{...o,...r,ref:t})});df.displayName=Yy;var Xy="MenuSub",[OC,ff]=Yn(Xy),Qr="MenuSubTrigger",hf=p.forwardRef((e,t)=>{const n=Xn(Qr,e.__scopeMenu),r=Zr(Qr,e.__scopeMenu),o=ff(Qr,e.__scopeMenu),s=ma(Qr,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,u={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),l.jsx(ha,{asChild:!0,...u,children:l.jsx(tf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":gf(n.open),...e,ref:Ci(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 m,b;d();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const w=(b=n.content)==null?void 0:b.dataset.side,g=w==="right",x=g?-5:5,v=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:v,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:v,y:h.bottom}],side:w}),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 m;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||jy[r.dir].includes(f.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),f.preventDefault())})})})});hf.displayName=Qr;var pf="MenuSubContent",mf=p.forwardRef((e,t)=>{const n=Xd(Wt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Wt,e.__scopeMenu),i=Zr(Wt,e.__scopeMenu),a=ff(pf,e.__scopeMenu),c=p.useRef(null),u=Me(t,c);return l.jsx(Jr.Provider,{scope:e.__scopeMenu,children:l.jsx($t,{present:r||s.open,children:l.jsx(Jr.Slot,{scope:e.__scopeMenu,children:l.jsx(ga,{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=c.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 m;const f=d.currentTarget.contains(d.target),h=_y[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),d.preventDefault())})})})})})});mf.displayName=pf;function gf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function wa(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function Jy(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Zy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Qy(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=Zy(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function e0(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],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function t0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return e0(n,t)}function eo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var n0=Yd,r0=ha,o0=Jd,s0=Zd,i0=xa,a0=Qd,l0=vs,c0=nf,u0=of,d0=af,f0=cf,h0=uf,p0=df,m0=hf,g0=mf,bs="DropdownMenu",[x0,MC]=ln(bs,[Kd]),Nt=Kd(),[v0,xf]=x0(bs),vf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=Nt(t),u=p.useRef(null),[d,f]=Un({prop:o,defaultProp:s??!1,onChange:i,caller:bs});return l.jsx(v0,{scope:t,triggerId:cn(),triggerRef:u,contentId:cn(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(n0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};vf.displayName=bs;var wf="DropdownMenuTrigger",bf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=xf(wf,n),i=Nt(n);return l.jsx(r0,{asChild:!0,...i,children:l.jsx(we.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:Ci(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())})})})});bf.displayName=wf;var w0="DropdownMenuPortal",yf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nt(t);return l.jsx(o0,{...r,...n})};yf.displayName=w0;var Sf="DropdownMenuContent",Cf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=xf(Sf,n),s=Nt(n),i=p.useRef(!1);return l.jsx(s0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.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)"}})});Cf.displayName=Sf;var b0="DropdownMenuGroup",y0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(i0,{...o,...r,ref:t})});y0.displayName=b0;var S0="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(a0,{...o,...r,ref:t})});kf.displayName=S0;var C0="DropdownMenuItem",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(l0,{...o,...r,ref:t})});Tf.displayName=C0;var k0="DropdownMenuCheckboxItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(c0,{...o,...r,ref:t})});Ef.displayName=k0;var T0="DropdownMenuRadioGroup",E0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(u0,{...o,...r,ref:t})});E0.displayName=T0;var I0="DropdownMenuRadioItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(d0,{...o,...r,ref:t})});If.displayName=I0;var N0="DropdownMenuItemIndicator",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(f0,{...o,...r,ref:t})});Nf.displayName=N0;var A0="DropdownMenuSeparator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(h0,{...o,...r,ref:t})});Af.displayName=A0;var j0="DropdownMenuArrow",_0=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(p0,{...o,...r,ref:t})});_0.displayName=j0;var R0="DropdownMenuSubTrigger",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(m0,{...o,...r,ref:t})});jf.displayName=R0;var P0="DropdownMenuSubContent",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Nt(n);return l.jsx(g0,{...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)"}})});_f.displayName=P0;var O0=vf,M0=bf,D0=yf,Rf=Cf,Pf=kf,Of=Tf,Mf=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,zf=_f;const L0=O0,$0=M0,F0=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Ff,{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,l.jsx(oe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));F0.displayName=Ff.displayName;const z0=p.forwardRef(({className:e,...t},n)=>l.jsx(zf,{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}));z0.displayName=zf.displayName;const Bf=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(D0,{children:l.jsx(Rf,{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})}));Bf.displayName=Rf.displayName;const ba=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Of,{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}));ba.displayName=Of.displayName;const B0=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Mf,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Lf,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),t]}));B0.displayName=Mf.displayName;const H0=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Df,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Lf,{children:l.jsx(oe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));H0.displayName=Df.displayName;const U0=p.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Pf,{ref:r,className:Q("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));U0.displayName=Pf.displayName;const W0=p.forwardRef(({className:e,...t},n)=>l.jsx($f,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));W0.displayName=$f.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:c=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:m}){const{currentThreadId:b,messages:w,isStreaming:g,streamingAssistantId:x,isLoadingThread:v,error:S,send:E,stop:C,lastCheckpointId:k,lastCheckpointNs:I,listCheckpoints:N,navigateToCheckpoint:_,returnToLatest:O,hasMoreHistory:R,isLoadingHistory:$,loadOlderMessages:K,api:M}=jr(),[W,U]=y.useState(null),[V,L]=y.useState(""),[A,q]=y.useState(null),[J,se]=y.useState([]),[te,pe]=y.useState(0),[Ie,Ne]=y.useState(0),[B,j]=y.useState(!1),[H,ee]=y.useState(null),[ue,ce]=y.useState(null),[Oe,Ge]=y.useState(!1),[ke,be]=y.useState(null),[Ue,Ye]=y.useState([]),[$e,st]=y.useState(null),[pt,it]=y.useState(null),[dt,at]=y.useState(!1),Fe=y.useRef(null),Y=y.useRef(null),re=y.useRef(null),he=y.useCallback(()=>{Fe.current&&(Fe.current.value=""),Y.current&&(Y.current.value=""),pe(X=>X+1),Ne(X=>X+1)},[]),We=y.useRef(!1);y.useEffect(()=>{We.current&&!g&&(se([]),he()),We.current=g},[g,he]);const[Xe,Qe]=y.useState("desktop");y.useEffect(()=>{const X=()=>{const fe=window.innerWidth;Qe(fe<640?"phone":fe<1024?"tablet":"desktop")};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]),y.useEffect(()=>{let X=!1;if(!b){Ye([]),st(null),it(null),re.current=null;return}const fe={threadId:b,checkpointId:k??null,checkpointNs:I??null},je=re.current;if(!(je&&je.threadId===fe.threadId&&je.checkpointId===fe.checkpointId&&je.checkpointNs===fe.checkpointNs))return N(b).then(Pe=>{var yr;if(X)return;const ye=((Pe==null?void 0:Pe.checkpoints)??[]).slice().sort((Gt,T)=>new Date(T.createdAt).getTime()-new Date(Gt.createdAt).getTime());Ye(ye);const et=$e,wt=et&&ye.some(Gt=>Gt.checkpointId===et)?et:((yr=ye[0])==null?void 0:yr.checkpointId)??null;let bn=null;if(wt){const Gt=ye.find(T=>T.checkpointId===wt);bn=(Gt==null?void 0:Gt.checkpointNs)??null}st(wt),it(bn),re.current=fe}).catch(Pe=>{console.error("ChatInterface - listCheckpoints error:",Pe),X||(Ye([]),re.current=null)}),()=>{X=!0}},[b,k,I,$e,N]),y.useEffect(()=>{k&&(st(k),it(I??null))},[k,I]);const yt=y.useCallback(async()=>{if(!(!R||$))try{await K()}catch(X){console.warn("loadOlderMessages failed",X)}},[R,$,K]);y.useEffect(()=>{(async()=>{if(!M.baseUrl){be(null);return}try{const fe=await M.getAgent("default");be(fe.uiDefaultMessage||null)}catch(fe){console.warn("Failed to fetch default message:",fe),be(null)}})()},[M]),y.useEffect(()=>{S&&!Oe&&(m==null||m(S))},[S,Oe,m]);const lt=X=>{if(X.length>os)return`Message too long (${X.length}/${os} characters)`;try{return Xw(X),null}catch(fe){return(fe==null?void 0:fe.message)||"Invalid message"}},mt=async X=>{const fe=X.trim();if(!(!fe&&J.length===0)){if(fe){const je=lt(fe);if(je){q(je);return}}try{await E(fe||"",{checkpointId:$e??k??void 0,checkpointNs:pt??I??void 0,payloadExtras:W?{edit:!0,originalMessageId:W}:void 0,attachments:J}),f==null||f(fe),q(null),se([]),he(),U(null),L("")}catch(je){const Pe=(je==null?void 0:je.message)||"Failed to send message";q(Pe),m==null||m(Pe)}}},Kt=y.useCallback((X,fe)=>{u&&(U(X),L(fe),q(null))},[u]),On=y.useCallback(()=>{U(null),L(""),q(null)},[]),no=y.useCallback((X,fe)=>{Kt(X,fe)},[Kt]),er=y.useCallback(X=>{const fe=je=>{const Pe=je.content||[],ye=Pe.filter(et=>et.type==="text").map(et=>et.text).join("");if(ye)return ye;try{return JSON.stringify(Pe,null,2)}catch{return String(Pe)}};for(let je=X-1;je>=0;je--)if(w[je].role==="user"){const Pe=fe(w[je]);Pe&&E(Pe,{checkpointId:$e??k??void 0,checkpointNs:pt??I??void 0});break}},[w,E,$e,pt,k,I]),br=X=>{const fe=Array.from(X.target.files||[]);se(je=>[...je,...fe]),X.target.value=""},gn=X=>{se(fe=>{const je=fe.filter((Pe,ye)=>X!==ye);return je.length===0&&he(),je})},tr=async X=>{const fe=(X.target.files||[])[0];if(fe){ee(null),ce(null),j(!0);try{await E("",{checkpointId:$e??k??void 0,checkpointNs:pt??I??void 0,attachments:[fe]});const je=`Uploaded ${fe.name} - processing through chat stream`;ce(je)}catch(je){const Pe=je instanceof Error?je.message:"Failed to upload Excel file";console.error("Excel upload failed",je),ee(Pe),m==null||m(Pe)}finally{j(!1),X.target.value="",he()}}},D=X=>{if(!X)return"Unknown";const fe=Date.parse(X);return Number.isNaN(fe)?X:new Date(fe).toLocaleString()},Z=async X=>{if(b){at(!0);try{if(!X){await O(),st(null),it(null);return}const fe=Ue.find(Pe=>Pe.checkpointId===X),je=(fe==null?void 0:fe.checkpointNs)??null;await _(X,je),st(X),it(je)}finally{at(!1)}}},Re=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Ke=`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||""}`,vt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return l.jsxs("div",{className:Re,children:[!!S&&!Oe&&l.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:[l.jsx("span",{children:S}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>Ge(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(oe.X,{size:16})})]}),b&&Ue.length>0&&l.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:[l.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),l.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:$e??"",onChange:X=>{const fe=X.target.value||null;Z(fe)},children:[l.jsx("option",{value:"",children:"Latest"}),Ue.map(X=>l.jsxs("option",{value:X.checkpointId,children:[D(X.createdAt),X.preview?` — ${X.preview.slice(0,40)}`:""]},X.checkpointId))]})]}),l.jsxs("div",{className:`relative ${Ke}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Gi,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:g,streamingAssistantId:x,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xe,enableMessageEditing:u,editingMessageId:W,onStartReached:()=>{yt()},onEdit:no,onRegenerate:er,onCancelEdit:On,emptyMessage:ke??void 0,isNavigatingCheckpoint:dt}),v&&l.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:[l.jsx(oe.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),l.jsxs("div",{className:vt,children:[W&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(oe.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:On,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(oe.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Fe,type:"file",multiple:!0,onChange:X=>br(X),className:"hidden"},te),J.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:J.map((X,fe)=>l.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:[l.jsx(oe.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:X.name}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>gn(fe),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 ${X.name}`,children:l.jsx(oe.X,{size:12})})]},fe))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Y,type:"file",accept:".xls,.xlsx,.xlsm",onChange:tr,className:"hidden"},Ie),B&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(oe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ue&&!B&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ue}),H&&!B&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:H})]})]}),A&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:A}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(L0,{children:[l.jsx($0,{asChild:!0,children:l.jsx(Be,{type:"button",size:"icon",variant:"outline",disabled:g,title:"More input actions",className:d.moreButton||"",children:l.jsx(oe.Plus,{size:16})})}),l.jsxs(Bf,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(ba,{onClick:()=>{var X;return(X=Fe.current)==null?void 0:X.click()},className:"cursor-pointer",children:[l.jsx(oe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(ba,{onClick:()=>{var X;B||(X=Y.current)==null||X.click()},className:`cursor-pointer ${B?"opacity-60 pointer-events-none":""}`,children:[l.jsx(oe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(ag,{initialValue:V,editingMessageId:W,placeholder:W?"Edit your message...":t,isStreaming:g,disabled:!1,maxLength:os,onSend:mt,onCancelEdit:On,onStop:C,allowEmptySend:J.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${W?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${A?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Ss=p.forwardRef(({className:e,type:t,...n},r)=>l.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 ya(e,[t,n]){return Math.min(n,Math.max(t,e))}function V0(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Sa="ScrollArea",[Hf,DC]=ln(Sa),[q0,Vt]=Hf(Sa),Uf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=p.useState(null),[u,d]=p.useState(null),[f,h]=p.useState(null),[m,b]=p.useState(null),[w,g]=p.useState(null),[x,v]=p.useState(0),[S,E]=p.useState(0),[C,k]=p.useState(!1),[I,N]=p.useState(!1),_=Me(t,R=>c(R)),O=ss(o);return l.jsx(q0,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:b,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:v,onCornerHeightChange:E,children:l.jsx(we.div,{dir:O,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Uf.displayName=Sa;var Wf="ScrollAreaViewport",Vf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Vt(Wf,n),a=p.useRef(null),c=Me(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(we.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Vf.displayName=Wf;var mn="ScrollAreaScrollbar",Ca=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Vt(mn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?l.jsx(K0,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(G0,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(qf,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(ka,{...r,ref:t}):null});Ca.displayName=mn;var K0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Vt(mn,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx($t,{present:n||s,children:l.jsx(qf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),G0=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Vt(mn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Es(()=>c("SCROLL_END"),100),[a,c]=V0("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 p.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),p.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const m=u[d];f!==m&&(c("SCROLL"),i()),f=m};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx($t,{present:n||a!=="hidden",children:l.jsx(ka,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),qf=p.forwardRef((e,t)=>{const n=Vt(mn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",c=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 xr(n.viewport,c),xr(n.content,c),l.jsx($t,{present:r||s,children:l.jsx(ka,{"data-state":s?"visible":"hidden",...o,ref:t})})}),ka=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Vt(mn,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,c]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Jf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,m){return eS(h,i.current,a,m)}return n==="horizontal"?l.jsx(Y0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,m=Zf(h,a,o.dir);s.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(X0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,m=Zf(h,a);s.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),Y0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Vt(mn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarXChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Gf,{"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":Ts(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),eh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ks(i.paddingLeft),paddingEnd:ks(i.paddingRight)}})}})}),X0=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Vt(mn,e.__scopeScrollArea),[i,a]=p.useState(),c=p.useRef(null),u=Me(t,c,s.onScrollbarYChange);return p.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(Gf,{"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":Ts(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),eh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ks(i.paddingTop),paddingEnd:ks(i.paddingBottom)}})}})}),[J0,Kf]=Hf(mn),Gf=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,m=Vt(mn,n),[b,w]=p.useState(null),g=Me(t,_=>w(_)),x=p.useRef(null),v=p.useRef(""),S=m.viewport,E=r.content-r.viewport,C=St(d),k=St(c),I=Es(f,10);function N(_){if(x.current){const O=_.clientX-x.current.left,R=_.clientY-x.current.top;u({x:O,y:R})}}return p.useEffect(()=>{const _=O=>{const R=O.target;(b==null?void 0:b.contains(R))&&C(O,E)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,b,E,C]),p.useEffect(k,[r,k]),xr(b,I),xr(m.content,I),l.jsx(J0,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:St(s),onThumbPointerUp:St(i),onThumbPositionChange:k,onThumbPointerDown:St(a),children:l.jsx(we.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:le(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),x.current=b.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(_))}),onPointerMove:le(e.onPointerMove,N),onPointerUp:le(e.onPointerUp,_=>{const O=_.target;O.hasPointerCapture(_.pointerId)&&O.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=v.current,m.viewport&&(m.viewport.style.scrollBehavior=""),x.current=null})})})}),Cs="ScrollAreaThumb",Yf=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kf(Cs,e.__scopeScrollArea);return l.jsx($t,{present:n||o.hasThumb,children:l.jsx(Z0,{ref:t,...r})})}),Z0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Vt(Cs,n),i=Kf(Cs,n),{onThumbPositionChange:a}=i,c=Me(t,f=>i.onThumbChange(f)),u=p.useRef(void 0),d=Es(()=>{u.current&&(u.current(),u.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const m=tS(f,a);u.current=m,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(we.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:le(e.onPointerDownCapture,f=>{const m=f.target.getBoundingClientRect(),b=f.clientX-m.left,w=f.clientY-m.top;i.onThumbPointerDown({x:b,y:w})}),onPointerUp:le(e.onPointerUp,i.onThumbPointerUp)})});Yf.displayName=Cs;var Ta="ScrollAreaCorner",Xf=p.forwardRef((e,t)=>{const n=Vt(Ta,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(Q0,{...e,ref:t}):null});Xf.displayName=Ta;var Q0=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Vt(Ta,n),[s,i]=p.useState(0),[a,c]=p.useState(0),u=!!(s&&a);return xr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),xr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.jsx(we.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 ks(e){return e?parseInt(e,10):0}function Jf(e,t){const n=e/t;return isNaN(n)?0:n}function Ts(e){const t=Jf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function eS(e,t,n,r="ltr"){const o=Ts(n),s=o/2,i=t||s,a=o-i,c=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 Qf([c,u],f)(e)}function Zf(e,t,n="ltr"){const r=Ts(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=ya(e,c);return Qf([0,i],[0,a])(u)}function Qf(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 eh(e,t){return e>0&&e<t}var tS=(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=St(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function xr(e,t){const n=St(t);bt(()=>{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 th=Uf,nS=Vf,rS=Xf;const nh=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(th,{ref:r,className:Q("relative overflow-hidden",e),...n,children:[l.jsx(nS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(rh,{}),l.jsx(rS,{})]}));nh.displayName=th.displayName;const rh=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Ca,{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:l.jsx(Yf,{className:"relative flex-1 rounded-full bg-border"})}));rh.displayName=Ca.displayName;function Ea({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:m,createThread:b,deleteThread:w,renameThread:g,isLoadingThreads:x}=jr(),[v,S]=y.useState(h??[]),[E,C]=y.useState(null),[k,I]=y.useState(""),[N,_]=y.useState(!1);y.useEffect(()=>{S(h??[])},[h]);const O=async A=>{try{await f(A),a==null||a(A),c==null||c(A)}catch(q){console.error("Failed to select thread:",q)}},R=async()=>{try{_(!0);const A=await b();u==null||u(A),a==null||a(A)}catch(A){console.error("Failed to create thread:",A)}finally{_(!1)}},$=async(A,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?"))try{await w(A),d==null||d(A)}catch(J){console.error("Failed to delete thread:",J)}},K=(A,q)=>{q.stopPropagation(),C(A.threadId),I(A.title||`Thread ${A.threadId.slice(0,8)}`)},M=async A=>{if(k.trim())try{await g(A,k.trim()),C(null),I("")}catch(q){console.error("Failed to update title:",q)}},W=()=>{C(null),I("")},U=(A,q)=>{A.key==="Enter"?M(q):A.key==="Escape"&&W()},V=A=>{if(!A)return"";try{const q=new Date(A),se=new Date().getTime()-q.getTime(),te=Math.floor(se/(1e3*60*60*24));return te===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):te===1?"Yesterday":te<7?`${te} days ago`:q.toLocaleDateString()}catch{return""}},L=A=>A.title||`Thread ${A.threadId.slice(0,8)}`;return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&l.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:l.jsx(Be,{onClick:R,disabled:N||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:N?"Creating...":"New Chat",children:l.jsx(oe.MessageSquarePlus,{size:20})})}),l.jsx(nh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[l.jsx(oe.Loader2,{className:"h-5 w-5 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):v.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(oe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):v.slice().sort((A,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(A.updatedAt||A.createdAt||"").getTime()).map(A=>l.jsxs("div",{onClick:()=>O(A.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??m)===A.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:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:E===A.threadId?l.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[l.jsx(Ss,{value:k,onChange:q=>I(q.target.value),onKeyDown:q=>U(q,A.threadId),className:"h-6 text-sm",autoFocus:!0}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:()=>M(A.threadId),className:"h-6 w-6 p-0",children:l.jsx(oe.Check,{size:12})}),l.jsx(Be,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:l.jsx(oe.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:L(A)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(oe.Calendar,{size:10}),l.jsx("span",{children:V(A.updatedAt||A.createdAt)})]})]})}),l.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==A.threadId&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:q=>K(A,q),className:"h-6 w-6 p-0",title:"Edit title",children:l.jsx(oe.Edit3,{size:12})}),n&&l.jsx(Be,{variant:"ghost",size:"sm",onClick:q=>$(A.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:l.jsx(oe.Trash2,{size:12})})]})]}),i===A.threadId&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},A.threadId))})})]})}function vr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function oS(e){if(typeof e!="string")return;const t=e.trim();if(t)return t.replace(/\/+$/g,"")}function oh(){const e=[vr("__API_BASE_URL__"),vr("__CHAT_API_BASE_URL__"),vr("__CHAT_API_URL__")];for(const t of e){const n=oS(t);if(n)return n}}function sh(){const e=[vr("__API_AUTH_TOKEN__"),vr("__CHAT_API_KEY__"),vr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ih(){const e={},t=oh(),n=sh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ah(){const e=ih(),t=yn.getAuthToken(),n=oh();return{apiBaseUrl:e.baseUrl||yn.baseUrl||n||"http://localhost:8000",apiKey:t||e.apiKey||sh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const lh="chat-settings";function sS(){try{const e=localStorage.getItem(lh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function iS(e){try{localStorage.setItem(lh,JSON.stringify(e)),e.apiKey&&yn.setAuthToken(e.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function aS(){const e=ah(),t=sS(),n=yn.getAuthToken();return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:yn.baseUrl||t.apiBaseUrl||e.apiBaseUrl}}function lS(e){e.apiKey&&yn.setAuthToken(e.apiKey),iS(e)}var cS="Label",ch=p.forwardRef((e,t)=>l.jsx(we.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())}}));ch.displayName=cS;var uh=ch;const uS=ro.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),qt=p.forwardRef(({className:e,...t},n)=>l.jsx(uh,{ref:n,className:Q(uS(),e),...t}));qt.displayName=uh.displayName;function dh(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Is="Switch",[dS,LC]=ln(Is),[fS,hS]=dS(Is),fh=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,m]=p.useState(null),b=Me(t,S=>m(S)),w=p.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,v]=Un({prop:o,defaultProp:s??!1,onChange:u,caller:Is});return l.jsxs(fS,{scope:n,checked:x,disabled:a,children:[l.jsx(we.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":gh(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:b,onClick:le(e.onClick,S=>{v(E=>!E),g&&(w.current=S.isPropagationStopped(),w.current||S.stopPropagation())})}),g&&l.jsx(mh,{control:h,bubbles:!w.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fh.displayName=Is;var hh="SwitchThumb",ph=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=hS(hh,n);return l.jsx(we.span,{"data-state":gh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ph.displayName=hh;var pS="SwitchBubbleInput",mh=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Me(i,s),c=dh(n),u=Ed(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&m){const b=new Event("click",{bubbles:r});m.call(d,n),d.dispatchEvent(b)}},[c,n,r]),l.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}})});mh.displayName=pS;function gh(e){return e?"checked":"unchecked"}var xh=fh,mS=ph;const _n=p.forwardRef(({className:e,...t},n)=>l.jsx(xh,{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:l.jsx(mS,{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")})}));_n.displayName=xh.displayName;var vh=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"}),gS="VisuallyHidden",xS=p.forwardRef((e,t)=>l.jsx(we.span,{...e,ref:t,style:{...vh,...e.style}}));xS.displayName=gS;var vS=[" ","Enter","ArrowUp","ArrowDown"],wS=[" ","Enter"],Jn="Select",[Ns,As,bS]=Yi(Jn),[wr,$C]=ln(Jn,[bS,ms]),js=ms(),[yS,Rn]=wr(Jn),[SS,CS]=wr(Jn),wh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:m,form:b}=e,w=js(t),[g,x]=p.useState(null),[v,S]=p.useState(null),[E,C]=p.useState(!1),k=ss(u),[I,N]=Un({prop:r,defaultProp:o??!1,onChange:s,caller:Jn}),[_,O]=Un({prop:i,defaultProp:a,onChange:c,caller:Jn}),R=p.useRef(null),$=g?b||!!g.closest("form"):!0,[K,M]=p.useState(new Set),W=Array.from(K).map(U=>U.props.value).join(";");return l.jsx(Dd,{...w,children:l.jsxs(yS,{required:m,scope:t,trigger:g,onTriggerChange:x,valueNode:v,onValueNodeChange:S,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:cn(),value:_,onValueChange:O,open:I,onOpenChange:N,dir:k,triggerPointerDownPosRef:R,disabled:h,children:[l.jsx(Ns.Provider,{scope:t,children:l.jsx(SS,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(U=>{M(V=>new Set(V).add(U))},[]),onNativeOptionRemove:p.useCallback(U=>{M(V=>{const L=new Set(V);return L.delete(U),L})},[]),children:n})}),$?l.jsxs(Uh,{"aria-hidden":!0,required:m,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:U=>O(U.target.value),disabled:h,form:b,children:[_===void 0?l.jsx("option",{value:""}):null,Array.from(K)]},W):null]})})};wh.displayName=Jn;var bh="SelectTrigger",yh=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=js(n),i=Rn(bh,n),a=i.disabled||r,c=Me(t,i.onTriggerChange),u=As(n),d=p.useRef("touch"),[f,h,m]=Vh(w=>{const g=u().filter(S=>!S.disabled),x=g.find(S=>S.value===i.value),v=qh(g,w,x);v!==void 0&&i.onValueChange(v.value)}),b=w=>{a||(i.onOpenChange(!0),m()),w&&(i.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return l.jsx(Ld,{asChild:!0,...s,children:l.jsx(we.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":Wh(i.value)?"":void 0,...o,ref:c,onClick:le(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&b(w)}),onPointerDown:le(o.onPointerDown,w=>{d.current=w.pointerType;const g=w.target;g.hasPointerCapture(w.pointerId)&&g.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(b(w),w.preventDefault())}),onKeyDown:le(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&vS.includes(w.key)&&(b(),w.preventDefault())})})})});yh.displayName=bh;var Sh="SelectValue",Ch=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=Rn(Sh,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=Me(t,c.onValueNodeChange);return bt(()=>{u(d)},[u,d]),l.jsx(we.span,{...a,ref:f,style:{pointerEvents:"none"},children:Wh(c.value)?l.jsx(l.Fragment,{children:i}):s})});Ch.displayName=Sh;var kS="SelectIcon",kh=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(we.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});kh.displayName=kS;var TS="SelectPortal",Th=e=>l.jsx(Uo,{asChild:!0,...e});Th.displayName=TS;var Zn="SelectContent",Eh=p.forwardRef((e,t)=>{const n=Rn(Zn,e.__scopeSelect),[r,o]=p.useState();if(bt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?oo.createPortal(l.jsx(Ih,{scope:e.__scopeSelect,children:l.jsx(Ns.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(Nh,{...e,ref:t})});Eh.displayName=Zn;var nn=10,[Ih,Pn]=wr(Zn),ES="SelectContentImpl",IS=Mn.createSlot("SelectContent.RemoveScroll"),Nh=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:w,avoidCollisions:g,...x}=e,v=Rn(Zn,n),[S,E]=p.useState(null),[C,k]=p.useState(null),I=Me(t,B=>E(B)),[N,_]=p.useState(null),[O,R]=p.useState(null),$=As(n),[K,M]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return Hi(S)},[S]),Di();const U=p.useCallback(B=>{const[j,...H]=$().map(ce=>ce.ref.current),[ee]=H.slice(-1),ue=document.activeElement;for(const ce of B)if(ce===ue||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===j&&C&&(C.scrollTop=0),ce===ee&&C&&(C.scrollTop=C.scrollHeight),ce==null||ce.focus(),document.activeElement!==ue))return},[$,C]),V=p.useCallback(()=>U([N,S]),[U,N,S]);p.useEffect(()=>{K&&V()},[K,V]);const{onOpenChange:L,triggerPointerDownPosRef:A}=v;p.useEffect(()=>{if(S){let B={x:0,y:0};const j=ee=>{var ue,ce;B={x:Math.abs(Math.round(ee.pageX)-(((ue=A.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((ce=A.current)==null?void 0:ce.y)??0))}},H=ee=>{B.x<=10&&B.y<=10?ee.preventDefault():S.contains(ee.target)||L(!1),document.removeEventListener("pointermove",j),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",H,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",H,{capture:!0})}}},[S,L,A]),p.useEffect(()=>{const B=()=>L(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[L]);const[q,J]=Vh(B=>{const j=$().filter(ue=>!ue.disabled),H=j.find(ue=>ue.ref.current===document.activeElement),ee=qh(j,B,H);ee&&setTimeout(()=>ee.ref.current.focus())}),se=p.useCallback((B,j,H)=>{const ee=!W.current&&!H;(v.value!==void 0&&v.value===j||ee)&&(_(B),ee&&(W.current=!0))},[v.value]),te=p.useCallback(()=>S==null?void 0:S.focus(),[S]),pe=p.useCallback((B,j,H)=>{const ee=!W.current&&!H;(v.value!==void 0&&v.value===j||ee)&&R(B)},[v.value]),Ie=r==="popper"?Ia:Ah,Ne=Ie===Ia?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:m,sticky:b,hideWhenDetached:w,avoidCollisions:g}:{};return l.jsx(Ih,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:se,selectedItem:N,onItemLeave:te,itemTextRefCallback:pe,focusSelectedItem:V,selectedItemText:O,position:r,isPositioned:K,searchRef:q,children:l.jsx(Yo,{as:IS,allowPinchZoom:!0,children:l.jsx(Ho,{asChild:!0,trapped:v.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:le(o,B=>{var j;(j=v.trigger)==null||j.focus({preventScroll:!0}),B.preventDefault()}),children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(Ie,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:B=>B.preventDefault(),...x,...Ne,onPlaced:()=>M(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:le(x.onKeyDown,B=>{const j=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!j&&B.key.length===1&&J(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let ee=$().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(B.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const ue=B.target,ce=ee.indexOf(ue);ee=ee.slice(ce+1)}setTimeout(()=>U(ee)),B.preventDefault()}})})})})})})});Nh.displayName=ES;var NS="SelectItemAlignedPosition",Ah=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Rn(Zn,n),i=Pn(Zn,n),[a,c]=p.useState(null),[u,d]=p.useState(null),f=Me(t,I=>d(I)),h=As(n),m=p.useRef(!1),b=p.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:x,focusSelectedItem:v}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&x){const I=s.trigger.getBoundingClientRect(),N=u.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(s.dir!=="rtl"){const ue=O.left-N.left,ce=_.left-ue,Oe=I.left-ce,Ge=I.width+Oe,ke=Math.max(Ge,N.width),be=window.innerWidth-nn,Ue=ya(ce,[nn,Math.max(nn,be-ke)]);a.style.minWidth=Ge+"px",a.style.left=Ue+"px"}else{const ue=N.right-O.right,ce=window.innerWidth-_.right-ue,Oe=window.innerWidth-I.right-ce,Ge=I.width+Oe,ke=Math.max(Ge,N.width),be=window.innerWidth-nn,Ue=ya(ce,[nn,Math.max(nn,be-ke)]);a.style.minWidth=Ge+"px",a.style.right=Ue+"px"}const R=h(),$=window.innerHeight-nn*2,K=w.scrollHeight,M=window.getComputedStyle(u),W=parseInt(M.borderTopWidth,10),U=parseInt(M.paddingTop,10),V=parseInt(M.borderBottomWidth,10),L=parseInt(M.paddingBottom,10),A=W+U+K+L+V,q=Math.min(g.offsetHeight*5,A),J=window.getComputedStyle(w),se=parseInt(J.paddingTop,10),te=parseInt(J.paddingBottom,10),pe=I.top+I.height/2-nn,Ie=$-pe,Ne=g.offsetHeight/2,B=g.offsetTop+Ne,j=W+U+B,H=A-j;if(j<=pe){const ue=R.length>0&&g===R[R.length-1].ref.current;a.style.bottom="0px";const ce=u.clientHeight-w.offsetTop-w.offsetHeight,Oe=Math.max(Ie,Ne+(ue?te:0)+ce+V),Ge=j+Oe;a.style.height=Ge+"px"}else{const ue=R.length>0&&g===R[0].ref.current;a.style.top="0px";const Oe=Math.max(pe,W+w.offsetTop+(ue?se:0)+Ne)+H;a.style.height=Oe+"px",w.scrollTop=j-pe+w.offsetTop}a.style.margin=`${nn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=$+"px",r==null||r(),requestAnimationFrame(()=>m.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,x,s.dir,r]);bt(()=>S(),[S]);const[E,C]=p.useState();bt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=p.useCallback(I=>{I&&b.current===!0&&(S(),v==null||v(),b.current=!1)},[S,v]);return l.jsx(jS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:m,onScrollButtonChange:k,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:l.jsx(we.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ah.displayName=NS;var AS="SelectPopperPosition",Ia=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=nn,...s}=e,i=js(n);return l.jsx($d,{...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)"}})});Ia.displayName=AS;var[jS,Na]=wr(Zn,{}),Aa="SelectViewport",jh=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Pn(Aa,n),i=Na(Aa,n),a=Me(t,s.onViewportChange),c=p.useRef(0);return l.jsxs(l.Fragment,{children:[l.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}),l.jsx(Ns.Slot,{scope:n,children:l.jsx(we.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 m=Math.abs(c.current-d.scrollTop);if(m>0){const b=window.innerHeight-nn*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(w,g);if(x<b){const v=x+m,S=Math.min(b,v),E=v-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});jh.displayName=Aa;var _h="SelectGroup",[_S,RS]=wr(_h),PS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=cn();return l.jsx(_S,{scope:n,id:o,children:l.jsx(we.div,{role:"group","aria-labelledby":o,...r,ref:t})})});PS.displayName=_h;var Rh="SelectLabel",Ph=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=RS(Rh,n);return l.jsx(we.div,{id:o.id,...r,ref:t})});Ph.displayName=Rh;var _s="SelectItem",[OS,Oh]=wr(_s),Mh=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Rn(_s,n),c=Pn(_s,n),u=a.value===r,[d,f]=p.useState(s??""),[h,m]=p.useState(!1),b=Me(t,v=>{var S;return(S=c.itemRefCallback)==null?void 0:S.call(c,v,r,o)}),w=cn(),g=p.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 l.jsx(OS,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:p.useCallback(v=>{f(S=>S||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(Ns.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(we.div,{role:"option","aria-labelledby":w,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:le(i.onFocus,()=>m(!0)),onBlur:le(i.onBlur,()=>m(!1)),onClick:le(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:le(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:le(i.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:le(i.onPointerMove,v=>{var S;g.current=v.pointerType,o?(S=c.onItemLeave)==null||S.call(c):g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:le(i.onPointerLeave,v=>{var S;v.currentTarget===document.activeElement&&((S=c.onItemLeave)==null||S.call(c))}),onKeyDown:le(i.onKeyDown,v=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(wS.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});Mh.displayName=_s;var to="SelectItemText",Dh=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Rn(to,n),a=Pn(to,n),c=Oh(to,n),u=CS(to,n),[d,f]=p.useState(null),h=Me(t,x=>f(x),c.onItemTextChange,x=>{var v;return(v=a.itemTextRefCallback)==null?void 0:v.call(a,x,c.value,c.disabled)}),m=d==null?void 0:d.textContent,b=p.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:w,onNativeOptionRemove:g}=u;return bt(()=>(w(b),()=>g(b)),[w,g,b]),l.jsxs(l.Fragment,{children:[l.jsx(we.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?oo.createPortal(s.children,i.valueNode):null]})});Dh.displayName=to;var Lh="SelectItemIndicator",$h=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Oh(Lh,n).isSelected?l.jsx(we.span,{"aria-hidden":!0,...r,ref:t}):null});$h.displayName=Lh;var ja="SelectScrollUpButton",Fh=p.forwardRef((e,t)=>{const n=Pn(ja,e.__scopeSelect),r=Na(ja,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Bh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Fh.displayName=ja;var _a="SelectScrollDownButton",zh=p.forwardRef((e,t)=>{const n=Pn(_a,e.__scopeSelect),r=Na(_a,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(Bh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});zh.displayName=_a;var Bh=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Pn("SelectScrollButton",n),i=p.useRef(null),a=As(n),c=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>c(),[c]),bt(()=>{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]),l.jsx(we.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,()=>{c()})})}),MS="SelectSeparator",Hh=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(we.div,{"aria-hidden":!0,...r,ref:t})});Hh.displayName=MS;var Ra="SelectArrow",DS=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=js(n),s=Rn(Ra,n),i=Pn(Ra,n);return s.open&&i.position==="popper"?l.jsx(Fd,{...o,...r,ref:t}):null});DS.displayName=Ra;var LS="SelectBubbleInput",Uh=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Me(r,o),i=dh(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(we.select,{...n,style:{...vh,...n.style},ref:s,defaultValue:t})});Uh.displayName=LS;function Wh(e){return e===""||e===void 0}function Vh(e){const t=St(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function qh(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=$S(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function $S(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var FS=wh,Kh=yh,zS=Ch,BS=kh,HS=Th,Gh=Eh,US=jh,Yh=Ph,Xh=Mh,WS=Dh,VS=$h,Jh=Fh,Zh=zh,Qh=Hh;const ep=FS,tp=zS,Pa=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Kh,{ref:r,className:Q("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,l.jsx(BS,{asChild:!0,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Pa.displayName=Kh.displayName;const np=p.forwardRef(({className:e,...t},n)=>l.jsx(Jh,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronUp,{className:"h-4 w-4"})}));np.displayName=Jh.displayName;const rp=p.forwardRef(({className:e,...t},n)=>l.jsx(Zh,{ref:n,className:Q("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(oe.ChevronDown,{className:"h-4 w-4"})}));rp.displayName=Zh.displayName;const Oa=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(HS,{children:l.jsxs(Gh,{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:[l.jsx(np,{}),l.jsx(US,{className:Q("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(rp,{})]})}));Oa.displayName=Gh.displayName;const qS=p.forwardRef(({className:e,...t},n)=>l.jsx(Yh,{ref:n,className:Q("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));qS.displayName=Yh.displayName;const Qn=p.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Xh,{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:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(VS,{children:l.jsx(oe.Check,{className:"h-4 w-4"})})}),l.jsx(WS,{children:t})]}));Qn.displayName=Xh.displayName;const KS=p.forwardRef(({className:e,...t},n)=>l.jsx(Qh,{ref:n,className:Q("-mx-1 my-1 h-px bg-muted",e),...t}));KS.displayName=Qh.displayName;var GS="Separator",op="horizontal",YS=["horizontal","vertical"],sp=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=op,...o}=e,s=XS(r)?r:op,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(we.div,{"data-orientation":s,...a,...o,ref:t})});sp.displayName=GS;function XS(e){return YS.includes(e)}var ip=sp;const ap=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(ip,{ref:o,decorative:n,orientation:t,className:Q("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ap.displayName=ip.displayName;const JS=Wu,ZS=Aw,QS=Vu,lp=p.forwardRef(({className:e,...t},n)=>l.jsx(es,{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}));lp.displayName=es.displayName;const eC=ro.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"}}),cp=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(QS,{children:[l.jsx(lp,{}),l.jsxs(ts,{ref:o,className:Q(eC({side:e}),t),...r,children:[n,l.jsxs(qu,{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:[l.jsx(oe.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cp.displayName=ts.displayName;const up=({className:e,...t})=>l.jsx("div",{className:Q("flex flex-col space-y-2 text-center sm:text-left",e),...t});up.displayName="SheetHeader";const dp=p.forwardRef(({className:e,...t},n)=>l.jsx(qn,{ref:n,className:Q("text-lg font-semibold text-foreground",e),...t}));dp.displayName=qn.displayName;const fp=p.forwardRef(({className:e,...t},n)=>l.jsx(ns,{ref:n,className:Q("text-sm text-muted-foreground",e),...t}));fp.displayName=ns.displayName;const tC={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 nC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,c]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=_i();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},m=()=>{c(tC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},b=()=>{c(e),d(!1),o(!1)},w=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 l.jsxs(JS,{open:r,onOpenChange:o,children:[l.jsx(ZS,{asChild:!0,children:l.jsxs(Be,{variant:"outline",size:"sm",className:n,children:[l.jsx(oe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(Si,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(cp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(up,{children:[l.jsx(dp,{children:"Chat Settings"}),l.jsx(fp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(Br,{children:[l.jsx(Hr,{className:"pb-3",children:l.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(qt,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ss,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Be,{variant:"outline",onClick:w,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(qt,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(_n,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(qt,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ss,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Be,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(oe.EyeOff,{className:"h-4 w-4"}):l.jsx(oe.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(Br,{children:[l.jsx(Hr,{className:"pb-3",children:l.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(qt,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(ep,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(Pa,{children:l.jsx(tp,{})}),l.jsxs(Oa,{children:[l.jsx(Qn,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(Qn,{value:"fullscreen",children:"Fullscreen"}),l.jsx(Qn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(qt,{htmlFor:"theme",children:"Theme"}),l.jsxs(ep,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(Pa,{children:l.jsx(tp,{})}),l.jsxs(Oa,{children:[l.jsx(Qn,{value:"light",children:"Light"}),l.jsx(Qn,{value:"dark",children:"Dark"}),l.jsx(Qn,{value:"system",children:"System"})]})]})]}),l.jsx(ap,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(qt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(_n,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(qt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(_n,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(qt,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(_n,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(Br,{children:[l.jsx(Hr,{className:"pb-3",children:l.jsxs(Ur,{className:"text-lg flex items-center gap-2",children:[l.jsx(oe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(Po,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(qt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(_n,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(qt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(_n,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(qt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(_n,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Be,{variant:"outline",onClick:m,children:[l.jsx(oe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Be,{variant:"outline",onClick:b,children:"Cancel"}),l.jsxs(Be,{onClick:h,disabled:!u,children:[l.jsx(oe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function rC({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"}),c=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(xo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx(ys,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(xo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ys,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(xo,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx(ys,{onError:s.onError,enableFileUpload:!0})})]})})}Te.ChatApi=jl,Te.ChatInterface=ys,Te.ChatProvider=xo,Te.ChatSettings=nC,Te.MarkdownContent=$o,Te.MessageComponent=td,Te.MessageList=Gi,Te.ThreadManager=Ea,Te.applySettings=lS,Te.chatApiClient=yn,Te.default=rC,Te.del=Al,Te.get=Ot,Te.getChatToken=El,Te.getCurrentSettings=aS,Te.getDefaultApiConfig=ih,Te.getDefaultChatSettings=ah,Te.onChatTokenChanged=Il,Te.post=Gs,Te.put=Nl,Te.setChatToken=Ks,Te.useChat=jr,Te.useChatStream=_l,Te.useMessagesReducer=Rl,Object.defineProperties(Te,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});