teodor-new-chat-ui 4.1.13 → 4.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +5295 -5238
- package/dist/index.umd.js +43 -48
- package/package.json +7 -3
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(Ne,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):(Ne=typeof globalThis<"u"?globalThis:Ne||self,S(Ne.NewChatUI={},Ne.React,Ne.LucideReact,Ne.reactSlot,Ne.classVarianceAuthority,Ne.clsx,Ne.tailwindMerge,Ne.ReactDOM))})(this,function(Ne,S,re,Mn,Qr,vp,wp,_s){"use strict";var iC=Object.defineProperty;var aC=(Ne,S,re)=>S in Ne?iC(Ne,S,{enumerable:!0,configurable:!0,writable:!0,value:re}):Ne[S]=re;var gp=(Ne,S,re)=>aC(Ne,typeof S!="symbol"?S+"":S,re);function Pa(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Pa(S),eo=Pa(_s);var Rs={exports:{}},wr={};/**
|
|
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
|
|
9
|
+
*/var Oa;function bp(){if(Oa)return wr;Oa=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,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return wr.Fragment=n,wr.jsx=i,wr.jsxs=i,wr}var br={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,41 +14,36 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
|
|
17
|
+
*/var Ma;function yp(){return Ma||(Ma=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"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,w="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var H=v&&k[v]||k[w];return typeof H=="function"?H:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(k){{for(var H=arguments.length,oe=new Array(H>1?H-1:0),Ie=1;Ie<H;Ie++)oe[Ie-1]=arguments[Ie];y("error",k,oe)}}function y(k,H,oe){{var Ie=x.ReactDebugCurrentFrame,Ge=Ie.getStackAddendum();Ge!==""&&(H+="%s",oe=oe.concat([Ge]));var Ze=oe.map(function(Ue){return String(Ue)});Ze.unshift("Warning: "+H),Function.prototype.apply.call(console[k],console,Ze)}}var E=!1,C=!1,T=!1,I=!1,A=!1,P;P=Symbol.for("react.module.reference");function _(k){return!!(typeof k=="string"||typeof k=="function"||k===r||k===s||A||k===o||k===u||k===d||I||k===p||E||C||T||typeof k=="object"&&k!==null&&(k.$$typeof===h||k.$$typeof===f||k.$$typeof===i||k.$$typeof===a||k.$$typeof===l||k.$$typeof===P||k.getModuleId!==void 0))}function D(k,H,oe){var Ie=k.displayName;if(Ie)return Ie;var Ge=H.displayName||H.name||"";return Ge!==""?oe+"("+Ge+")":oe}function L(k){return k.displayName||"Context"}function F(k){if(k==null)return null;if(typeof k.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){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 k=="object")switch(k.$$typeof){case a:var H=k;return L(H)+".Consumer";case i:var oe=k;return L(oe._context)+".Provider";case l:return D(k,k.render,"ForwardRef");case f:var Ie=k.displayName||null;return Ie!==null?Ie:F(k.type)||"Memo";case h:{var Ge=k,Ze=Ge._payload,Ue=Ge._init;try{return F(Ue(Ze))}catch{return null}}}return null}var O=Object.assign,W=0,U,G,$,N,V,X,pe;function le(){}le.__reactDisabledLog=!0;function fe(){{if(W===0){U=console.log,G=console.info,$=console.warn,N=console.error,V=console.group,X=console.groupCollapsed,pe=console.groupEnd;var k={configurable:!0,enumerable:!0,value:le,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}W++}}function ye(){{if(W--,W===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:O({},k,{value:U}),info:O({},k,{value:G}),warn:O({},k,{value:$}),error:O({},k,{value:N}),group:O({},k,{value:V}),groupCollapsed:O({},k,{value:X}),groupEnd:O({},k,{value:pe})})}W<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var we=x.ReactCurrentDispatcher,z;function M(k,H,oe){{if(z===void 0)try{throw Error()}catch(Ge){var Ie=Ge.stack.trim().match(/\n( *(at )?)/);z=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+z+k}}var q=!1,Z;{var ce=typeof WeakMap=="function"?WeakMap:Map;Z=new ce}function te(k,H){if(!k||q)return"";{var oe=Z.get(k);if(oe!==void 0)return oe}var Ie;q=!0;var Ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ze;Ze=we.current,we.current=null,fe();try{if(H){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(bn){Ie=bn}Reflect.construct(k,[],Ue)}else{try{Ue.call()}catch(bn){Ie=bn}k.call(Ue.prototype)}}else{try{throw Error()}catch(bn){Ie=bn}k()}}catch(bn){if(bn&&Ie&&typeof bn.stack=="string"){for(var ze=bn.stack.split(`
|
|
19
|
+
`),kt=Ie.stack.split(`
|
|
20
|
+
`),ht=ze.length-1,mt=kt.length-1;ht>=1&&mt>=0&&ze[ht]!==kt[mt];)mt--;for(;ht>=1&&mt>=0;ht--,mt--)if(ze[ht]!==kt[mt]){if(ht!==1||mt!==1)do if(ht--,mt--,mt<0||ze[ht]!==kt[mt]){var Kt=`
|
|
21
|
+
`+ze[ht].replace(" at new "," at ");return k.displayName&&Kt.includes("<anonymous>")&&(Kt=Kt.replace("<anonymous>",k.displayName)),typeof k=="function"&&Z.set(k,Kt),Kt}while(ht>=1&&mt>=0);break}}}finally{q=!1,we.current=Ze,ye(),Error.prepareStackTrace=Ge}var vr=k?k.displayName||k.name:"",mp=vr?M(vr):"";return typeof k=="function"&&Z.set(k,mp),mp}function Fe(k,H,oe){return te(k,!1)}function Qe(k){var H=k.prototype;return!!(H&&H.isReactComponent)}function et(k,H,oe){if(k==null)return"";if(typeof k=="function")return te(k,Qe(k));if(typeof k=="string")return M(k);switch(k){case u:return M("Suspense");case d:return M("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case l:return Fe(k.render);case f:return et(k.type,H,oe);case h:{var Ie=k,Ge=Ie._payload,Ze=Ie._init;try{return et(Ze(Ge),H,oe)}catch{}}}return""}var je=Object.prototype.hasOwnProperty,Oe={},tt=x.ReactDebugCurrentFrame;function He(k){if(k){var H=k._owner,oe=et(k.type,k._source,H?H.type:null);tt.setExtraStackFrame(oe)}else tt.setExtraStackFrame(null)}function at(k,H,oe,Ie,Ge){{var Ze=Function.call.bind(je);for(var Ue in k)if(Ze(k,Ue)){var ze=void 0;try{if(typeof k[Ue]!="function"){var kt=Error((Ie||"React class")+": "+oe+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof k[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw kt.name="Invariant Violation",kt}ze=k[Ue](H,Ue,Ie,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ht){ze=ht}ze&&!(ze instanceof Error)&&(He(Ge),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",oe,Ue,typeof ze),He(null)),ze instanceof Error&&!(ze.message in Oe)&&(Oe[ze.message]=!0,He(Ge),b("Failed %s type: %s",oe,ze.message),He(null))}}}var dt=Array.isArray;function ne(k){return dt(k)}function ee(k){{var H=typeof Symbol=="function"&&Symbol.toStringTag,oe=H&&k[Symbol.toStringTag]||k.constructor.name||"Object";return oe}}function xe(k){try{return Ee(k),!1}catch{return!0}}function Ee(k){return""+k}function Se(k){if(xe(k))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ee(k)),Ee(k)}var Re=x.ReactCurrentOwner,Je={key:!0,ref:!0,__self:!0,__source:!0},Ke,lt;function At(k){if(je.call(k,"ref")){var H=Object.getOwnPropertyDescriptor(k,"ref").get;if(H&&H.isReactWarning)return!1}return k.ref!==void 0}function On(k){if(je.call(k,"key")){var H=Object.getOwnPropertyDescriptor(k,"key").get;if(H&&H.isReactWarning)return!1}return k.key!==void 0}function Jr(k,H){typeof k.ref=="string"&&Re.current}function j(k,H){{var oe=function(){Ke||(Ke=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};oe.isReactWarning=!0,Object.defineProperty(k,"key",{get:oe,configurable:!0})}}function Y(k,H){{var oe=function(){lt||(lt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};oe.isReactWarning=!0,Object.defineProperty(k,"ref",{get:oe,configurable:!0})}}var ue=function(k,H,oe,Ie,Ge,Ze,Ue){var ze={$$typeof:t,type:k,key:H,ref:oe,props:Ue,_owner:Ze};return ze._store={},Object.defineProperty(ze._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ze,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(ze,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ge}),Object.freeze&&(Object.freeze(ze.props),Object.freeze(ze)),ze};function Ce(k,H,oe,Ie,Ge){{var Ze,Ue={},ze=null,kt=null;oe!==void 0&&(Se(oe),ze=""+oe),On(H)&&(Se(H.key),ze=""+H.key),At(H)&&(kt=H.ref,Jr(H,Ge));for(Ze in H)je.call(H,Ze)&&!Je.hasOwnProperty(Ze)&&(Ue[Ze]=H[Ze]);if(k&&k.defaultProps){var ht=k.defaultProps;for(Ze in ht)Ue[Ze]===void 0&&(Ue[Ze]=ht[Ze])}if(ze||kt){var mt=typeof k=="function"?k.displayName||k.name||"Unknown":k;ze&&j(Ue,mt),kt&&Y(Ue,mt)}return ue(k,ze,kt,Ge,Ie,Re.current,Ue)}}var Me=x.ReactCurrentOwner,he=x.ReactDebugCurrentFrame;function it(k){if(k){var H=k._owner,oe=et(k.type,k._source,H?H.type:null);he.setExtraStackFrame(oe)}else he.setExtraStackFrame(null)}var jt;jt=!1;function ft(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function Ft(){{if(Me.current){var k=F(Me.current.type);if(k)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+k+"`."}return""}}function vn(k){return""}var hn={};function xr(k){{var H=Ft();if(!H){var oe=typeof k=="string"?k:k.displayName||k.name;oe&&(H=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+te+">.")}return H}}function ae(E,H){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var te=Oa(H);if(Jr[te])return;Jr[te]=!0;var Ee="";E&&E._owner&&E._owner!==Xn.current&&(Ee=" It was passed a child from "+L(E._owner.type)+"."),cn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,Ee),cn(null)}}function xe(E,H){{if(typeof E!="object")return;if(Q(E))for(var te=0;te<E.length;te++){var Ee=E[te];jn(Ee)&&ae(Ee,H)}else if(jn(E))E._store&&(E._store.validated=!0);else if(E){var qe=g(E);if(typeof qe=="function"&&qe!==E.entries)for(var Ze=qe.call(E),He;!(He=Ze.next()).done;)jn(He.value)&&ae(He.value,H)}}}function Be(E){{var H=E.type;if(H==null||typeof H=="string")return;var te;if(typeof H=="function")te=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))te=H.propTypes;else return;if(te){var Ee=L(H);st(te,E.props,"prop",Ee,E)}else if(H.PropTypes!==void 0&&!Jn){Jn=!0;var qe=L(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ot(E){{for(var H=Object.keys(E.props),te=0;te<H.length;te++){var Ee=H[te];if(Ee!=="children"&&Ee!=="key"){cn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),cn(null);break}}E.ref!==null&&(cn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),cn(null))}}var Mt={};function dn(E,H,te,Ee,qe,Ze){{var He=j(E);if(!He){var $e="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&($e+=" 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 St=Ns();St?$e+=St:$e+=un();var ut;E===null?ut="null":Q(E)?ut="array":E!==void 0&&E.$$typeof===t?(ut="<"+(L(E.type)||"Unknown")+" />",$e=" Did you accidentally export a JSX literal instead of a component?"):ut=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ut,$e)}var ft=gr(E,H,te,qe,Ze);if(ft==null)return ft;if(He){var Ht=H.children;if(Ht!==void 0)if(Ee)if(Q(Ht)){for(var vr=0;vr<Ht.length;vr++)xe(Ht[vr],E);Object.freeze&&Object.freeze(Ht)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(Ht,E)}if(Ne.call(H,"key")){var Zn=L(E),kt=Object.keys(H).filter(function(lC){return lC!=="key"}),Ma=kt.length>0?"{key: someKey, "+kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Mt[Zn+Ma]){var aC=kt.length>0?"{"+kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
-
|
|
27
|
-
<%s {...props} />
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<%s key={someKey} {...props} />`,Ma,Zn,aC,Zn),Mt[Zn+Ma]=!0}}return E===r?ot(ft):Be(ft),ft}}function Zr(E,H,te){return dn(E,H,te,!0)}function As(E,H,te){return dn(E,H,te,!1)}var js=As,gn=Zr;br.Fragment=r,br.jsx=js,br.jsxs=gn}()),br}process.env.NODE_ENV==="production"?Rs.exports=yp():Rs.exports=Sp();var c=Rs.exports;function $a(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cp}=Object.prototype,{getPrototypeOf:Ps}=Object,{iterator:to,toStringTag:za}=Symbol,no=(e=>t=>{const n=Cp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:Qn}=Array,er=ro("undefined");function yr(e){return e!==null&&!er(e)&&e.constructor!==null&&!er(e.constructor)&&Ct(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=Ut("ArrayBuffer");function Tp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const Ep=ro("string"),Ct=ro("function"),Ha=ro("number"),Sr=e=>e!==null&&typeof e=="object",kp=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(to in e)},Ip=e=>{if(!Sr(e)||yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Np=Ut("Date"),Ap=Ut("File"),jp=Ut("Blob"),_p=Ut("FileList"),Rp=e=>Sr(e)&&Ct(e.pipe),Pp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ct(e.append)&&((t=no(e))==="formdata"||t==="object"&&Ct(e.toString)&&e.toString()==="[object FormData]"))},Op=Ut("URLSearchParams"),[Mp,Dp,Lp,Fp]=["ReadableStream","Request","Response","Headers"].map(Ut),$p=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Qn(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(yr(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(yr(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 Rn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!er(e)&&e!==Rn;function Os(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;oo(n[i])&&oo(o)?n[i]=Os(n[i],o):oo(o)?n[i]=Os({},o):Qn(o)?n[i]=o.slice():(!t||!er(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Cr(arguments[o],r);return n}const zp=(e,t,n,{allOwnKeys:r}={})=>(Cr(t,(o,s)=>{n&&Ct(o)?e[s]=$a(o,n):e[s]=o},{allOwnKeys:r}),e),Bp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hp=(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)},Up=(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&&Ps(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wp=(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},Vp=e=>{if(!e)return null;if(Qn(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},Kp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ps(Uint8Array)),qp=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yp=Ut("HTMLFormElement"),Xp=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),Jp=Ut("RegExp"),Ka=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Cr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zp=e=>{Ka(e,(t,n)=>{if(Ct(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ct(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 Qn(e)?r(e):r(String(e).split(t)),n},em=()=>{},tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nm(e){return!!(e&&Ct(e.append)&&e[za]==="FormData"&&e[to])}const rm=e=>{const t=new Array(10),n=(r,o)=>{if(Sr(r)){if(t.indexOf(r)>=0)return;if(yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Qn(r)?[]:{};return Cr(r,(i,a)=>{const l=n(i,o+1);!er(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},om=Ut("AsyncFunction"),sm=e=>e&&(Sr(e)||Ct(e))&&Ct(e.then)&&Ct(e.catch),qa=((e,t)=>e?setImmediate:t?((n,r)=>(Rn.addEventListener("message",({source:o,data:s})=>{o===Rn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Rn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ct(Rn.postMessage)),im=typeof queueMicrotask<"u"?queueMicrotask.bind(Rn):typeof process<"u"&&process.nextTick||qa,_={isArray:Qn,isArrayBuffer:Ba,isBuffer:yr,isFormData:Pp,isArrayBufferView:Tp,isString:Ep,isNumber:Ha,isBoolean:kp,isObject:Sr,isPlainObject:oo,isEmptyObject:Ip,isReadableStream:Mp,isRequest:Dp,isResponse:Lp,isHeaders:Fp,isUndefined:er,isDate:Np,isFile:Ap,isBlob:jp,isRegExp:Jp,isFunction:Ct,isStream:Rp,isURLSearchParams:Op,isTypedArray:Kp,isFileList:_p,forEach:Cr,merge:Os,extend:zp,trim:$p,stripBOM:Bp,inherits:Hp,toFlatObject:Up,kindOf:no,kindOfTest:Ut,endsWith:Wp,toArray:Vp,forEachEntry:qp,matchAll:Gp,isHTMLForm:Yp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:Ka,freezeMethods:Zp,toObjectSet:Qp,toCamelCase:Xp,noop:em,toFiniteNumber:tm,findKey:Ua,global:Rn,isContextDefined:Wa,isSpecCompliantForm:nm,toJSONObject:rm,isAsyncFn:om,isThenable:sm,setImmediate:qa,asap:im,isIterable:e=>e!=null&&Ct(e[to])};function Ae(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)}_.inherits(Ae,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:_.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ae.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(Ae,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);_.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const am=null;function Ms(e){return _.isPlainObject(e)||_.isArray(e)}function Xa(e){return _.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 lm(e){return _.isArray(e)&&!e.some(Ms)}const cm=_.toFlatObject(_,{},null,function(t){return/^is[A-Z]/.test(t)});function so(e,t,n){if(!_.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=_.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!_.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(t);if(!_.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(_.isDate(w))return w.toISOString();if(_.isBoolean(w))return w.toString();if(!l&&_.isBlob(w))throw new Ae("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(w)||_.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(_.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(_.isArray(w)&&lm(w)||(_.isFileList(w)||_.endsWith(v,"[]"))&&(x=_.toArray(w)))return v=Xa(v),x.forEach(function(y,k){!(_.isUndefined(y)||y===null)&&t.append(i===!0?Ja([v],k,s):i===null?v:v+"[]",u(y))}),!1}return Ms(w)?!0:(t.append(Ja(g,v,s),u(w)),!1)}const f=[],h=Object.assign(cm,{defaultVisitor:d,convertValue:u,isVisitable:Ms});function p(w,v){if(!_.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),_.forEach(w,function(x,b){(!(_.isUndefined(x)||x===null)&&o.call(t,x,_.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!_.isObject(e))throw new TypeError("data must be an object");return p(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 Ds(e,t){this._pairs=[],e&&so(e,this,t)}const Qa=Ds.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 um(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||um;_.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=_.isURLSearchParams(t)?t.toString():new Ds(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){_.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ds,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,fm=Ls&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pm=Ls&&window.location.href||"http://localhost",gt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:fm,hasStandardBrowserWebWorkerEnv:hm,navigator:Fs,origin:pm},Symbol.toStringTag,{value:"Module"})),...dm};function mm(e,t){return so(e,new gt.classes.URLSearchParams,{visitor:function(n,r,o,s){return gt.isNode&&_.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gm(e){return _.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xm(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),l=s>=n.length;return i=!i&&_.isArray(o)?o.length:i,l?(_.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!_.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&_.isArray(o[i])&&(o[i]=xm(o[i])),!a)}if(_.isFormData(e)&&_.isFunction(e.entries)){const n={};return _.forEachEntry(e,(r,o)=>{t(gm(r),o,n,0)}),n}return null}function vm(e,t,n){if(_.isString(e))try{return(t||JSON.parse)(e),_.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Tr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=_.isObject(t);if(s&&_.isHTMLForm(t)&&(t=new FormData(t)),_.isFormData(t))return o?JSON.stringify(rl(t)):t;if(_.isArrayBuffer(t)||_.isBuffer(t)||_.isStream(t)||_.isFile(t)||_.isBlob(t)||_.isReadableStream(t))return t;if(_.isArrayBufferView(t))return t.buffer;if(_.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 mm(t,this.formSerializer).toString();if((a=_.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vm(t)):t}],transformResponse:[function(t){const n=this.transitional||Tr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(_.isResponse(t)||_.isReadableStream(t))return t;if(t&&_.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"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],e=>{Tr.headers[e]={}});const wm=_.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"]),bm=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]&&wm[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 Er(e){return e&&String(e).trim().toLowerCase()}function io(e){return e===!1||e==null?e:_.isArray(e)?e.map(io):String(e)}function ym(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Sm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $s(e,t,n,r,o){if(_.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!_.isString(t)){if(_.isString(r))return t.indexOf(r)!==-1;if(_.isRegExp(r))return r.test(t)}}function Cm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tm(e,t){const n=_.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 Tt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Er(l);if(!d)throw new Error("header name must be a non-empty string");const f=_.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=io(a))}const i=(a,l)=>_.forEach(a,(u,d)=>s(u,d,l));if(_.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(_.isString(t)&&(t=t.trim())&&!Sm(t))i(bm(t),n);else if(_.isObject(t)&&_.isIterable(t)){let a={},l,u;for(const d of t){if(!_.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?_.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Er(t),t){const r=_.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ym(o);if(_.isFunction(n))return n.call(this,o,r);if(_.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Er(t),t){const r=_.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||$s(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Er(i),i){const a=_.findKey(r,i);a&&(!n||$s(r,r[a],a,n))&&(delete r[a],o=!0)}}return _.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||$s(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return _.forEach(this,(o,s)=>{const i=_.findKey(r,s);if(i){n[i]=io(o),delete n[s];return}const a=t?Cm(s):String(s).trim();a!==s&&delete n[s],n[a]=io(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return _.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&_.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=Er(i);r[a]||(Tm(o,i),r[a]=!0)}return _.isArray(t)?t.forEach(s):s(t),this}};Tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_.reduceDescriptors(Tt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),_.freezeMethods(Tt);function zs(e,t){const n=this||Tr,r=t||n,o=Tt.from(r.headers);let s=r.data;return _.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 tr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}_.inherits(tr,Ae,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Em(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function km(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Im(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 ao=(e,t,n=3)=>{let r=0;const o=km(50,250);return Im(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>_.asap(()=>e(...t)),Nm=gt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,gt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(gt.origin),gt.navigator&&/(msie|trident)/i.test(gt.navigator.userAgent)):()=>!0,Am=gt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];_.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),_.isString(r)&&i.push("path="+r),_.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _m(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!jm(t);return e&&(r||n==!1)?_m(e,t):t}const ul=e=>e instanceof Tt?{...e}:e;function Pn(e,t){t=t||{};const n={};function r(u,d,f,h){return _.isPlainObject(u)&&_.isPlainObject(d)?_.merge.call({caseless:h},u,d):_.isPlainObject(d)?_.merge({},d):_.isArray(d)?d.slice():d}function o(u,d,f,h){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!_.isUndefined(d))return r(void 0,d)}function i(u,d){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(ul(u),ul(d),f,!0)};return _.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);_.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=Pn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Tt.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)):""))),_.isFormData(n)){if(gt.hasStandardBrowserEnv||gt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(_.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(gt.hasStandardBrowserEnv&&(r&&_.isFunction(r)&&(r=r(t)),r||r!==!1&&Nm(t.url))){const l=o&&s&&Am.read(s);l&&i.set(o,l)}return t},Rm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=Tt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=Tt.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};il(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ae("Request aborted",Ae.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||nl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&_.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),_.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=ao(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ao(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new tr(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 b=Em(o.url);if(b&>.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Pm=(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 Ae?d:new tr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>_.asap(a),l}},Om=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},Mm=async function*(e,t){for await(const n of Dm(e))yield*Om(n,t)},Dm=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=Mm(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:lo}=_,Lm=(({Request:e,Response:t})=>({Request:e,Response:t}))(_.global),{ReadableStream:pl,TextEncoder:ml}=_.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fm=e=>{e=_.merge.call({skipUndefined:!0},Lm,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(pl),l=o&&(typeof ml=="function"?(w=>v=>w.encode(v))(new ml):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&gl(()=>{let w=!1;const v=new n(gt.origin,{body:new pl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&gl(()=>_.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ae(`Response type '${w}' is not supported`,Ae.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(_.isBlob(w))return w.size;if(_.isSpecCompliantForm(w))return(await new n(gt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(_.isArrayBufferView(w)||_.isArrayBuffer(w))return w.byteLength;if(_.isURLSearchParams(w)&&(w=w+""),_.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=_.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:y,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:R="same-origin",fetchOptions:j}=dl(w),M=t||fetch;I=I?(I+"").toLowerCase():"text";let D=Pm([b,y&&y.toAbortSignal()],k),L=null;const P=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let V;try{if(T&&u&&g!=="get"&&g!=="head"&&(V=await p(A,x))!==0){let Y=new n(v,{method:"POST",body:x,duplex:"half"}),de;if(_.isFormData(x)&&(de=Y.headers.get("content-type"))&&A.setContentType(de),Y.body){const[se,pe]=al(V,ao(ll(T)));x=fl(Y.body,hl,se,pe)}}_.isString(R)||(R=R?"include":"omit");const U=s&&"credentials"in n.prototype,q={...j,signal:D,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:U?R:void 0};L=s&&new n(v,q);let F=await(s?M(L,j):M(v,q));const N=d&&(I==="stream"||I==="response");if(d&&(C||N&&P)){const Y={};["status","statusText","headers"].forEach(ge=>{Y[ge]=F[ge]});const de=_.toFiniteNumber(F.headers.get("content-length")),[se,pe]=C&&al(de,ao(ll(C),!0))||[];F=new r(fl(F.body,hl,se,()=>{pe&&pe(),P&&P()}),Y)}I=I||"text";let W=await f[_.findKey(f,I)||"text"](F,w);return!N&&P&&P(),await new Promise((Y,de)=>{il(Y,de,{data:W,headers:Tt.from(F.headers),status:F.status,statusText:F.statusText,config:w,request:L})})}catch(U){throw P&&P(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,w,L),{cause:U.cause||U}):Ae.from(U,U&&U.code,w,L)}}},$m=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,l,u,d=$m;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Fm(t)),d=u;return u};xl();const Bs={http:am,xhr:Rm,fetch:{get:xl}};_.forEach(Bs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,zm=e=>_.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=_.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,!zm(r)&&(o=Bs[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(_.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(vl).join(`
|
|
34
|
-
`):" "+vl(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Bs};function Hs(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new tr(null,e)}function bl(e){return Hs(e),e.headers=Tt.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),wl.getAdapter(e.adapter||Tr.adapter,e)(e).then(function(r){return Hs(e),r.data=zs.call(e,e.transformResponse,r),r.headers=Tt.from(r.headers),r},function(r){return sl(r)||(Hs(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=Tt.from(r.response.headers))),Promise.reject(r)})}const yl="1.12.2",co={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{co[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Sl={};co.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 Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.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}},co.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Bm(e,t,n){if(typeof e!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const uo={assertOptions:Bm,validators:co},Xt=uo.validators;let On=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=Pn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(_.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[n.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=Tt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[bl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=bl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Pn(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(t){On.prototype[t]=function(n,r){return this.request(Pn(r||{},{method:t,url:n,data:(r||{}).data}))}}),_.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Pn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}On.prototype[t]=n(),On.prototype[t+"Form"]=n(!0)});let Hm=class vp{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 tr(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 vp(function(o){t=o}),cancel:t}}};function Um(e){return function(n){return e.apply(null,n)}}function Wm(e){return _.isObject(e)&&e.isAxiosError===!0}const Us={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(Us).forEach(([e,t])=>{Us[t]=e});function Cl(e){const t=new On(e),n=$a(On.prototype.request,t);return _.extend(n,On.prototype,t,{allOwnKeys:!0}),_.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(Pn(e,o))},n}const at=Cl(Tr);at.Axios=On,at.CanceledError=tr,at.CancelToken=Hm,at.isCancel=sl,at.VERSION=yl,at.toFormData=so,at.AxiosError=Ae,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Um,at.isAxiosError=Wm,at.mergeConfig=Pn,at.AxiosHeaders=Tt,at.formToJSON=e=>rl(_.isHTMLForm(e)?new FormData(e):e),at.getAdapter=wl.getAdapter,at.HttpStatusCode=Us,at.default=at;const{Axios:xC,AxiosError:vC,CanceledError:wC,isCancel:bC,CancelToken:yC,VERSION:SC,all:CC,Cancel:TC,isAxiosError:EC,spread:kC,toFormData:IC,AxiosHeaders:NC,HttpStatusCode:AC,formToJSON:jC,getAdapter:_C,mergeConfig:RC}=at,Tl=typeof window<"u"?window.__API_BASE_URL__:void 0,El=Tl?fn(Tl):void 0;function fn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let fo=null;const Ws=new Set;function kl(){return fo}function Vs(e){fo=e,Ws.forEach(t=>t(e))}function Il(e){return Ws.add(e),()=>Ws.delete(e)}const Dt=at.create({...El?{baseURL:El}:{},timeout:3e4,withCredentials:!0});Dt.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),Dt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ks(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class jl{get baseUrl(){const t=Dt.defaults.baseURL;return t?fn(String(t)):""}updateConfig(t){t.baseUrl&&(Dt.defaults.baseURL=fn(String(t.baseUrl))),t.authToken!==void 0&&Vs(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Vs(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ks("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await Nl(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await Al(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await Ks("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const xn=new jl,_l=S.createContext(null);function Vm({children:e,apiConfig:t}){const n=xn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(_l.Provider,{value:r,children:e})}function qs(){const e=S.useContext(_l);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function Km(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 qm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Gm(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await qm(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function Ym(e){return e.type!=="thread_info"&&e.type!=="token"}const Xm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Jm(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 r=Gs(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=Gs(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]=S.useReducer(Jm,{...Xm,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]),l=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:l}),[l]);return{state:t,dispatch:n,...u}}function Pl(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=rg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Ys(e.messages);return o?{...e,messages:Xs(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Ys(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Xs(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=ng(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Ys(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Xs(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function 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 Zm(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 Qm(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 Qm(e,t,r=>({...r,content:eg(r.content,n)}))}function eg(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.startsWith(s)){i.text=s;continue}const l=tg(a,s);l?i.text=a+l:s.length!==a.length&&(i.text=s)}else n.push({type:"text",text:s})}else n.push(r);return n}function tg(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function ng(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 Zm(e,r,s)}return e}function rg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Ol(e={}){const t=S.useMemo(()=>fn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=S.useState(e.token??null),s=S.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=S.useState(!1),[u,d]=S.useState(null),[f,h]=S.useState(""),[p,w]=S.useState(null),[v,g]=S.useState(0),[x,b]=S.useState(!1),y=S.useRef(null),k=S.useRef(!0),C=S.useRef(0),T=S.useCallback(j=>{o(j)},[]),I=S.useCallback(()=>{var j;(j=y.current)==null||j.abort(),y.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=S.useCallback(()=>{h(""),w(null),d(null)},[]),R=S.useCallback((j,M,D)=>{y.current&&(y.current.abort(),y.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const L=new AbortController;return y.current=L,(async()=>{var V,U,q,F,N,W,Y,de;const P=se=>{var pe;try{const ge=JSON.parse(JSON.stringify(se));return(pe=ge==null?void 0:ge.payload)!=null&&pe.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ge}catch{return se}};try{let se={};try{if(r)se={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,Qe=((V=window.localStorage)==null?void 0:V.getItem("authToken"))||null;let Re=null;try{const ct=(U=window.localStorage)==null?void 0:U.getItem("chat-settings");ct&&(Re=((q=JSON.parse(ct))==null?void 0:q.apiKey)||null)}catch{}const st=Oe||Qe||Re||null;st&&(se={Authorization:`Bearer ${st}`})}}catch{}console.debug("[use-chat] POST",t+n,P(j));const pe=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...se,...s.current},body:JSON.stringify(j),signal:L.signal,credentials:i});if(!pe.ok||!pe.body){const Ne=await pe.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",pe.status,Ne==null?void 0:Ne.slice(0,500)),new Error(`stream ${pe.status}${Ne?": "+Ne:""}`)}b(!0);const ge=pe.body.getReader(),Se=new TextDecoder;let B="",O=[];C.current=0,g(0);let G=0,Z=null;const ce=()=>{if(O.length){const Ne=O.join("");O=[],k.current&&h(Oe=>Oe+Ne)}Z=null},ie=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(ce))};let De=Date.now();const Xe=setInterval(()=>{var Ne;if(Date.now()-De>6e4){const Oe="Stream idle timeout";d(Oe),L.abort(),(Ne=D==null?void 0:D.onError)==null||Ne.call(D,Oe)}},5e3),Je=1024*1024;try{const Ne=pe.headers.get("X-Thread-Id")||pe.headers.get("x-thread-id"),Oe=pe.headers.get("X-Thread-Created")||pe.headers.get("x-thread-created"),Qe=Ne??null,Re=String(Oe??"").toLowerCase()==="true";for((F=D==null?void 0:D.onOpen)==null||F.call(D,{threadId:Qe,created:Re});;){const{value:st,done:ct}=await ge.read();if(ct)break;B+=Se.decode(st,{stream:!0}),B.length>Je&&(B="",console.warn("Stream buffer reset: exceeded 1MB"));let Q;for(;(Q=B.indexOf(`
|
|
25
|
+
Check the top-level render call using <`+oe+">.")}return H}}function Q(k,H){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var oe=xr(H);if(hn[oe])return;hn[oe]=!0;var Ie="";k&&k._owner&&k._owner!==Me.current&&(Ie=" It was passed a child from "+F(k._owner.type)+"."),it(k),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,Ie),it(null)}}function ve(k,H){{if(typeof k!="object")return;if(ne(k))for(var oe=0;oe<k.length;oe++){var Ie=k[oe];ft(Ie)&&Q(Ie,H)}else if(ft(k))k._store&&(k._store.validated=!0);else if(k){var Ge=g(k);if(typeof Ge=="function"&&Ge!==k.entries)for(var Ze=Ge.call(k),Ue;!(Ue=Ze.next()).done;)ft(Ue.value)&&Q(Ue.value,H)}}}function $e(k){{var H=k.type;if(H==null||typeof H=="string")return;var oe;if(typeof H=="function")oe=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))oe=H.propTypes;else return;if(oe){var Ie=F(H);at(oe,k.props,"prop",Ie,k)}else if(H.PropTypes!==void 0&&!jt){jt=!0;var Ge=F(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ge||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function st(k){{for(var H=Object.keys(k.props),oe=0;oe<H.length;oe++){var Ie=H[oe];if(Ie!=="children"&&Ie!=="key"){it(k),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),it(null);break}}k.ref!==null&&(it(k),b("Invalid attribute `ref` supplied to `React.Fragment`."),it(null))}}function $t(k,H,oe,Ie,Ge,Ze){{var Ue=_(k);if(!Ue){var ze="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&(ze+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var kt=vn();kt?ze+=kt:ze+=Ft();var ht;k===null?ht="null":ne(k)?ht="array":k!==void 0&&k.$$typeof===t?(ht="<"+(F(k.type)||"Unknown")+" />",ze=" Did you accidentally export a JSX literal instead of a component?"):ht=typeof k,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ht,ze)}var mt=Ce(k,H,oe,Ge,Ze);if(mt==null)return mt;if(Ue){var Kt=H.children;if(Kt!==void 0)if(Ie)if(ne(Kt)){for(var vr=0;vr<Kt.length;vr++)ve(Kt[vr],k);Object.freeze&&Object.freeze(Kt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ve(Kt,k)}return k===r?st(mt):$e(mt),mt}}function wn(k,H,oe){return $t(k,H,oe,!0)}function Zr(k,H,oe){return $t(k,H,oe,!1)}var As=Zr,js=wn;br.Fragment=r,br.jsx=As,br.jsxs=js}()),br}process.env.NODE_ENV==="production"?Rs.exports=bp():Rs.exports=yp();var c=Rs.exports;function Da(e,t){return function(){return e.apply(t,arguments)}}const{toString:Sp}=Object.prototype,{getPrototypeOf:Ps}=Object,{iterator:to,toStringTag:La}=Symbol,no=(e=>t=>{const n=Sp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),qt=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:er}=Array,tr=ro("undefined");function yr(e){return e!==null&&!tr(e)&&e.constructor!==null&&!tr(e.constructor)&&Et(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Fa=qt("ArrayBuffer");function Cp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fa(e.buffer),t}const Tp=ro("string"),Et=ro("function"),$a=ro("number"),Sr=e=>e!==null&&typeof e=="object",kp=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(La in e)&&!(to in e)},Ep=e=>{if(!Sr(e)||yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ip=qt("Date"),Np=qt("File"),Ap=qt("Blob"),jp=qt("FileList"),_p=e=>Sr(e)&&Et(e.pipe),Rp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Et(e.append)&&((t=no(e))==="formdata"||t==="object"&&Et(e.toString)&&e.toString()==="[object FormData]"))},Pp=qt("URLSearchParams"),[Op,Mp,Dp,Lp]=["ReadableStream","Request","Response","Headers"].map(qt),Fp=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),er(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(yr(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 za(e,t){if(yr(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,Ba=e=>!tr(e)&&e!==Dn;function Os(){const{caseless:e,skipUndefined:t}=Ba(this)&&this||{},n={},r=(o,s)=>{const i=e&&za(n,s)||s;oo(n[i])&&oo(o)?n[i]=Os(n[i],o):oo(o)?n[i]=Os({},o):er(o)?n[i]=o.slice():(!t||!tr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Cr(arguments[o],r);return n}const $p=(e,t,n,{allOwnKeys:r}={})=>(Cr(t,(o,s)=>{n&&Et(o)?e[s]=Da(o,n):e[s]=o},{allOwnKeys:r}),e),zp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Bp=(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)},Hp=(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&&Ps(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Up=(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},Wp=e=>{if(!e)return null;if(er(e))return e;let t=e.length;if(!$a(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Vp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ps(Uint8Array)),Kp=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},qp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Gp=qt("HTMLFormElement"),Yp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Ha=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Xp=qt("RegExp"),Ua=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Cr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Jp=e=>{Ua(e,(t,n)=>{if(Et(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Et(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+"'")})}})},Zp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return er(e)?r(e):r(String(e).split(t)),n},Qp=()=>{},em=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function tm(e){return!!(e&&Et(e.append)&&e[La]==="FormData"&&e[to])}const nm=e=>{const t=new Array(10),n=(r,o)=>{if(Sr(r)){if(t.indexOf(r)>=0)return;if(yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=er(r)?[]:{};return Cr(r,(i,a)=>{const l=n(i,o+1);!tr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},rm=qt("AsyncFunction"),om=e=>e&&(Sr(e)||Et(e))&&Et(e.then)&&Et(e.catch),Wa=((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",Et(Dn.postMessage)),sm=typeof queueMicrotask<"u"?queueMicrotask.bind(Dn):typeof process<"u"&&process.nextTick||Wa,R={isArray:er,isArrayBuffer:Fa,isBuffer:yr,isFormData:Rp,isArrayBufferView:Cp,isString:Tp,isNumber:$a,isBoolean:kp,isObject:Sr,isPlainObject:oo,isEmptyObject:Ep,isReadableStream:Op,isRequest:Mp,isResponse:Dp,isHeaders:Lp,isUndefined:tr,isDate:Ip,isFile:Np,isBlob:Ap,isRegExp:Xp,isFunction:Et,isStream:_p,isURLSearchParams:Pp,isTypedArray:Vp,isFileList:jp,forEach:Cr,merge:Os,extend:$p,trim:Fp,stripBOM:zp,inherits:Bp,toFlatObject:Hp,kindOf:no,kindOfTest:qt,endsWith:Up,toArray:Wp,forEachEntry:Kp,matchAll:qp,isHTMLForm:Gp,hasOwnProperty:Ha,hasOwnProp:Ha,reduceDescriptors:Ua,freezeMethods:Jp,toObjectSet:Zp,toCamelCase:Yp,noop:Qp,toFiniteNumber:em,findKey:za,global:Dn,isContextDefined:Ba,isSpecCompliantForm:tm,toJSONObject:nm,isAsyncFn:rm,isThenable:om,setImmediate:Wa,asap:sm,isIterable:e=>e!=null&&Et(e[to])};function _e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}R.inherits(_e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:R.toJSONObject(this.config),code:this.code,status:this.status}}});const Va=_e.prototype,Ka={};["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=>{Ka[e]={value:e}}),Object.defineProperties(_e,Ka),Object.defineProperty(Va,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(Va);R.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return _e.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const im=null;function Ms(e){return R.isPlainObject(e)||R.isArray(e)}function qa(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function Ga(e,t,n){return e?e.concat(t).map(function(o,s){return o=qa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function am(e){return R.isArray(e)&&!e.some(Ms)}const lm=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function so(e,t,n){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=R.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,g){return!R.isUndefined(g[w])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if(R.isDate(v))return v.toISOString();if(R.isBoolean(v))return v.toString();if(!l&&R.isBlob(v))throw new _e("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(v)||R.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,w,g){let x=v;if(v&&!g&&typeof v=="object"){if(R.endsWith(w,"{}"))w=r?w:w.slice(0,-2),v=JSON.stringify(v);else if(R.isArray(v)&&am(v)||(R.isFileList(v)||R.endsWith(w,"[]"))&&(x=R.toArray(v)))return w=qa(w),x.forEach(function(y,E){!(R.isUndefined(y)||y===null)&&t.append(i===!0?Ga([w],E,s):i===null?w:w+"[]",u(y))}),!1}return Ms(v)?!0:(t.append(Ga(g,w,s),u(v)),!1)}const f=[],h=Object.assign(lm,{defaultVisitor:d,convertValue:u,isVisitable:Ms});function p(v,w){if(!R.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(v),R.forEach(v,function(x,b){(!(R.isUndefined(x)||x===null)&&o.call(t,x,R.isString(b)?b.trim():b,w,h))===!0&&p(x,w?w.concat(b):[b])}),f.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ya(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ds(e,t){this._pairs=[],e&&so(e,this,t)}const Xa=Ds.prototype;Xa.append=function(t,n){this._pairs.push([t,n])},Xa.toString=function(t){const n=t?function(r){return t.call(this,r,Ya)}:Ya;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function cm(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ja(e,t,n){if(!t)return e;const r=n&&n.encode||cm;R.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=R.isURLSearchParams(t)?t.toString():new Ds(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Za{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Qa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},um={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ds,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,dm=Ls&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),fm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",hm=Ls&&window.location.href||"http://localhost",wt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:dm,hasStandardBrowserWebWorkerEnv:fm,navigator:Fs,origin:hm},Symbol.toStringTag,{value:"Module"})),...um};function pm(e,t){return so(e,new wt.classes.URLSearchParams,{visitor:function(n,r,o,s){return wt.isNode&&R.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function mm(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function gm(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 el(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&R.isArray(o)?o.length:i,l?(R.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!R.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&R.isArray(o[i])&&(o[i]=gm(o[i])),!a)}if(R.isFormData(e)&&R.isFunction(e.entries)){const n={};return R.forEachEntry(e,(r,o)=>{t(mm(r),o,n,0)}),n}return null}function xm(e,t,n){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Tr={transitional:Qa,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=R.isObject(t);if(s&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return o?JSON.stringify(el(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return pm(t,this.formSerializer).toString();if((a=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),xm(t)):t}],transformResponse:[function(t){const n=this.transitional||Tr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:wt.classes.FormData,Blob:wt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Tr.headers[e]={}});const vm=R.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),wm=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
26
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&vm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},tl=Symbol("internals");function kr(e){return e&&String(e).trim().toLowerCase()}function io(e){return e===!1||e==null?e:R.isArray(e)?e.map(io):String(e)}function bm(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const ym=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $s(e,t,n,r,o){if(R.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function Sm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Cm(e,t){const n=R.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let It=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=kr(l);if(!d)throw new Error("header name must be a non-empty string");const f=R.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=io(a))}const i=(a,l)=>R.forEach(a,(u,d)=>s(u,d,l));if(R.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(R.isString(t)&&(t=t.trim())&&!ym(t))i(wm(t),n);else if(R.isObject(t)&&R.isIterable(t)){let a={},l,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?R.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=kr(t),t){const r=R.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return bm(o);if(R.isFunction(n))return n.call(this,o,r);if(R.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=kr(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||$s(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=kr(i),i){const a=R.findKey(r,i);a&&(!n||$s(r,r[a],a,n))&&(delete r[a],o=!0)}}return R.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||$s(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return R.forEach(this,(o,s)=>{const i=R.findKey(r,s);if(i){n[i]=io(o),delete n[s];return}const a=t?Sm(s):String(s).trim();a!==s&&delete n[s],n[a]=io(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return R.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&R.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
27
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[tl]=this[tl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=kr(i);r[a]||(Cm(o,i),r[a]=!0)}return R.isArray(t)?t.forEach(s):s(t),this}};It.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),R.reduceDescriptors(It.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),R.freezeMethods(It);function zs(e,t){const n=this||Tr,r=t||n,o=It.from(r.headers);let s=r.data;return R.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function nl(e){return!!(e&&e.__CANCEL__)}function nr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}R.inherits(nr,_e,{__CANCEL__:!0});function rl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Tm(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function km(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Em(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 ao=(e,t,n=3)=>{let r=0;const o=km(50,250);return Em(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},ol=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},sl=e=>(...t)=>R.asap(()=>e(...t)),Im=wt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,wt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(wt.origin),wt.navigator&&/(msie|trident)/i.test(wt.navigator.userAgent)):()=>!0,Nm=wt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];R.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),R.isString(r)&&i.push("path="+r),R.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Am(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function jm(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function il(e,t,n){let r=!Am(t);return e&&(r||n==!1)?jm(e,t):t}const al=e=>e instanceof It?{...e}:e;function Ln(e,t){t=t||{};const n={};function r(u,d,f,h){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:h},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function o(u,d,f,h){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!R.isUndefined(d))return r(void 0,d)}function i(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(al(u),al(d),f,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);R.isUndefined(h)&&f!==a||(n[d]=h)}),n}const ll=e=>{const t=Ln({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=It.from(i),t.url=Ja(il(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),R.isFormData(n)){if(wt.hasStandardBrowserEnv||wt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(R.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(wt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Im(t.url))){const l=o&&s&&Nm.read(s);l&&i.set(o,l)}return t},_m=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=ll(e);let s=o.data;const i=It.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,v;function w(){p&&p(),v&&v(),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=It.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};rl(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 _e("Request aborted",_e.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new _e(C,_e.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Qa;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new _e(E,C.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&R.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),R.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=ao(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ao(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new nr(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 b=Tm(o.url);if(b&&wt.protocols.indexOf(b)===-1){r(new _e("Unsupported protocol "+b+":",_e.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Rm=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof _e?d:new nr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>R.asap(a),l}},Pm=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},Om=async function*(e,t){for await(const n of Mm(e))yield*Pm(n,t)},Mm=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()}},cl=(e,t,n,r)=>{const o=Om(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},ul=64*1024,{isFunction:lo}=R,Dm=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:dl,TextEncoder:fl}=R.global,hl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Lm=e=>{e=R.merge.call({skipUndefined:!0},Dm,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(dl),l=o&&(typeof fl=="function"?(v=>w=>v.encode(w))(new fl):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&hl(()=>{let v=!1;const w=new n(wt.origin,{body:new dl,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!w}),d=i&&a&&hl(()=>R.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(w,g)=>{let x=w&&w[v];if(x)return x.call(w);throw new _e(`Response type '${v}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if(R.isBlob(v))return v.size;if(R.isSpecCompliantForm(v))return(await new n(wt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(R.isArrayBufferView(v)||R.isArrayBuffer(v))return v.byteLength;if(R.isURLSearchParams(v)&&(v=v+""),R.isString(v))return(await l(v)).byteLength},p=async(v,w)=>{const g=R.toFiniteNumber(v.getContentLength());return g??h(w)};return async v=>{let{url:w,method:g,data:x,signal:b,cancelToken:y,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:P="same-origin",fetchOptions:_}=ll(v),D=t||fetch;I=I?(I+"").toLowerCase():"text";let L=Rm([b,y&&y.toAbortSignal()],E),F=null;const O=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let W;try{if(T&&u&&g!=="get"&&g!=="head"&&(W=await p(A,x))!==0){let X=new n(w,{method:"POST",body:x,duplex:"half"}),pe;if(R.isFormData(x)&&(pe=X.headers.get("content-type"))&&A.setContentType(pe),X.body){const[le,fe]=ol(W,ao(sl(T)));x=cl(X.body,ul,le,fe)}}R.isString(P)||(P=P?"include":"omit");const U=s&&"credentials"in n.prototype,G={..._,signal:L,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:U?P:void 0};F=s&&new n(w,G);let $=await(s?D(F,_):D(w,G));const N=d&&(I==="stream"||I==="response");if(d&&(C||N&&O)){const X={};["status","statusText","headers"].forEach(ye=>{X[ye]=$[ye]});const pe=R.toFiniteNumber($.headers.get("content-length")),[le,fe]=C&&ol(pe,ao(sl(C),!0))||[];$=new r(cl($.body,ul,le,()=>{fe&&fe(),O&&O()}),X)}I=I||"text";let V=await f[R.findKey(f,I)||"text"]($,v);return!N&&O&&O(),await new Promise((X,pe)=>{rl(X,pe,{data:V,headers:It.from($.headers),status:$.status,statusText:$.statusText,config:v,request:F})})}catch(U){throw O&&O(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,v,F),{cause:U.cause||U}):_e.from(U,U&&U.code,v,F)}}},Fm=new Map,pl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=Fm;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Lm(t)),d=u;return u};pl();const Bs={http:im,xhr:_m,fetch:{get:pl}};R.forEach(Bs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ml=e=>`- ${e}`,$m=e=>R.isFunction(e)||e===null||e===!1,gl={getAdapter:(e,t)=>{e=R.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!$m(r)&&(o=Bs[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${a}'`);if(o&&(R.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
28
|
+
`+i.map(ml).join(`
|
|
29
|
+
`):" "+ml(i[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Bs};function Hs(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new nr(null,e)}function xl(e){return Hs(e),e.headers=It.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),gl.getAdapter(e.adapter||Tr.adapter,e)(e).then(function(r){return Hs(e),r.data=zs.call(e,e.transformResponse,r),r.headers=It.from(r.headers),r},function(r){return nl(r)||(Hs(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=It.from(r.response.headers))),Promise.reject(r)})}const vl="1.12.2",co={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{co[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const wl={};co.transitional=function(t,n,r){function o(s,i){return"[Axios v"+vl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new _e(o(i," has been removed"+(n?" in "+n:"")),_e.ERR_DEPRECATED);return n&&!wl[i]&&(wl[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}},co.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function zm(e,t,n){if(typeof e!="object")throw new _e("options must be an object",_e.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new _e("option "+s+" must be "+l,_e.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new _e("Unknown option "+s,_e.ERR_BAD_OPTION)}}const uo={assertOptions:zm,validators:co},en=uo.validators;let Fn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Za,response:new Za}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
30
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ln(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:en.transitional(en.boolean),forcedJSONParsing:en.transitional(en.boolean),clarifyTimeoutError:en.transitional(en.boolean)},!1),o!=null&&(R.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:en.function,serialize:en.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:en.spelling("baseURL"),withXsrfToken:en.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&R.merge(s.common,s[n.method]);s&&R.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=It.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(l=l&&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(!l){const v=[xl.bind(this),void 0];for(v.unshift(...a),v.push(...u),h=v.length,d=Promise.resolve(n);f<h;)d=d.then(v[f++],v[f++]);return d}h=a.length;let p=n;for(;f<h;){const v=a[f++],w=a[f++];try{p=v(p)}catch(g){w.call(this,g);break}}try{d=xl.call(this,p)}catch(v){return Promise.reject(v)}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=il(t.baseURL,t.url,t.allowAbsoluteUrls);return Ja(n,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){Fn.prototype[t]=function(n,r){return this.request(Ln(r||{},{method:t,url:n,data:(r||{}).data}))}}),R.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Ln(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Fn.prototype[t]=n(),Fn.prototype[t+"Form"]=n(!0)});let Bm=class xp{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 nr(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 xp(function(o){t=o}),cancel:t}}};function Hm(e){return function(n){return e.apply(null,n)}}function Um(e){return R.isObject(e)&&e.isAxiosError===!0}const Us={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(Us).forEach(([e,t])=>{Us[t]=e});function bl(e){const t=new Fn(e),n=Da(Fn.prototype.request,t);return R.extend(n,Fn.prototype,t,{allOwnKeys:!0}),R.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return bl(Ln(e,o))},n}const ct=bl(Tr);ct.Axios=Fn,ct.CanceledError=nr,ct.CancelToken=Bm,ct.isCancel=nl,ct.VERSION=vl,ct.toFormData=so,ct.AxiosError=_e,ct.Cancel=ct.CanceledError,ct.all=function(t){return Promise.all(t)},ct.spread=Hm,ct.isAxiosError=Um,ct.mergeConfig=Ln,ct.AxiosHeaders=It,ct.formToJSON=e=>el(R.isHTMLForm(e)?new FormData(e):e),ct.getAdapter=gl.getAdapter,ct.HttpStatusCode=Us,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:TC,AxiosHeaders:kC,HttpStatusCode:EC,formToJSON:IC,getAdapter:NC,mergeConfig:AC}=ct,yl=typeof window<"u"?window.__API_BASE_URL__:void 0,Sl=yl?pn(yl):void 0;function pn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let fo=null;const Ws=new Set;function Cl(){return fo}function Vs(e){fo=e,Ws.forEach(t=>t(e))}function Tl(e){return Ws.add(e),()=>Ws.delete(e)}const zt=ct.create({...Sl?{baseURL:Sl}:{},timeout:3e4,withCredentials:!0});zt.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),zt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function _t(e,t){return zt.defaults.baseURL?(await zt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ks(e,t,n){return zt.defaults.baseURL?(await zt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function kl(e,t,n){return zt.defaults.baseURL?(await zt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function El(e,t){return zt.defaults.baseURL?(await zt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Il{get baseUrl(){const t=zt.defaults.baseURL;return t?pn(String(t)):""}updateConfig(t){t.baseUrl&&(zt.defaults.baseURL=pn(String(t.baseUrl))),t.authToken!==void 0&&Vs(t.authToken)}getAuthToken(){return Cl()}setAuthToken(t){Vs(t)}onTokenChange(t){return Tl(t)}async listThreads(){const t=await _t("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ks("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await kl(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await El(`/threads/${t}`);return Rt(n)}async threadInfo(t){const n=await _t(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await _t("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await _t(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await _t(`/agents/${t}/schema`);return Rt(n)}async getMessages(t){const n=await _t(`/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 Rt(n)}async getState(t){const n=await _t(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Rt(n)}async getStateHistory(t){const n=await _t(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Rt(n)}async listCheckpoints(t){const n=await _t(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Rt(n)}async resume(t){const n=await Ks("/runs/resume",{thread_id:t.threadId,value:t.value});return Rt(n)}}const yn=new Il,Nl=S.createContext(null);function Wm({children:e,apiConfig:t}){const n=yn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(Nl.Provider,{value:r,children:e})}function qs(){const e=S.useContext(Nl);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function Vm(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 Km(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function qm(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await Km(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function Gm(e){return e.type!=="thread_info"&&e.type!=="token"}const Ym={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Xm(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 r=Gs(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=Gs(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 jl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>jl(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 Al(e=[]){const[t,n]=S.useReducer(Xm,{...Ym,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]),l=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:l}),[l]);return{state:t,dispatch:n,...u}}function jl(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=ng(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Ys(e.messages);return o?{...e,messages:Xs(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Ys(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Xs(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=tg(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Ys(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Xs(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function 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 Jm(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 Zm(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 Zm(e,t,r=>({...r,content:Qm(r.content,n)}))}function Qm(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.includes(s))continue;const l=eg(a,s);l?i.text=a+l:i.text=a+s}else n.push({type:"text",text:s})}else n.push(r);return n}function eg(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function tg(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 Jm(e,r,s)}return e}function ng(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function _l(e={}){const t=S.useMemo(()=>pn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=S.useState(e.token??null),s=S.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=S.useState(!1),[u,d]=S.useState(null),[f,h]=S.useState(""),[p,v]=S.useState(null),[w,g]=S.useState(0),[x,b]=S.useState(!1),y=S.useRef(null),E=S.useRef(!0),C=S.useRef(0),T=S.useCallback(_=>{o(_)},[]),I=S.useCallback(()=>{var _;(_=y.current)==null||_.abort(),y.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=S.useCallback(()=>{h(""),v(null),d(null)},[]),P=S.useCallback((_,D,L)=>{y.current&&(y.current.abort(),y.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const F=new AbortController;return y.current=F,(async()=>{var W,U,G,$,N,V,X,pe;const O=le=>{var fe;try{const ye=JSON.parse(JSON.stringify(le));return(fe=ye==null?void 0:ye.payload)!=null&&fe.files_info&&Array.isArray(ye.payload.files_info)&&(ye.payload.files_info=ye.payload.files_info.map(we=>({...we,data:we!=null&&we.data?`<base64 ${String(we.data).length} chars>`:we==null?void 0:we.data}))),ye}catch{return le}};try{let le={};try{if(r)le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,tt=((W=window.localStorage)==null?void 0:W.getItem("authToken"))||null;let He=null;try{const dt=(U=window.localStorage)==null?void 0:U.getItem("chat-settings");dt&&(He=((G=JSON.parse(dt))==null?void 0:G.apiKey)||null)}catch{}const at=Oe||tt||He||null;at&&(le={Authorization:`Bearer ${at}`})}}catch{}console.debug("[use-chat] POST",t+n,O(_));const fe=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...le,...s.current},body:JSON.stringify(_),signal:F.signal,credentials:i});if(!fe.ok||!fe.body){const je=await fe.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",fe.status,je==null?void 0:je.slice(0,500)),new Error(`stream ${fe.status}${je?": "+je:""}`)}b(!0);const ye=fe.body.getReader(),we=new TextDecoder;let z="",M=[];C.current=0,g(0);let q=0,Z=null;const ce=()=>{if(M.length){const je=M.join("");M=[],E.current&&h(Oe=>Oe+je)}Z=null},te=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(ce))};let Fe=Date.now();const Qe=setInterval(()=>{var je;if(Date.now()-Fe>6e4){const Oe="Stream idle timeout";d(Oe),F.abort(),(je=L==null?void 0:L.onError)==null||je.call(L,Oe)}},5e3),et=1024*1024;try{const je=fe.headers.get("X-Thread-Id")||fe.headers.get("x-thread-id"),Oe=fe.headers.get("X-Thread-Created")||fe.headers.get("x-thread-created"),tt=je??null,He=String(Oe??"").toLowerCase()==="true";for(($=L==null?void 0:L.onOpen)==null||$.call(L,{threadId:tt,created:He});;){const{value:at,done:dt}=await ye.read();if(dt)break;z+=we.decode(at,{stream:!0}),z.length>et&&(z="",console.warn("Stream buffer reset: exceeded 1MB"));let ne;for(;(ne=z.indexOf(`
|
|
36
31
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`)}function ig({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=S.useRef(null),i=S.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Ym(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Ol({baseUrl:e,token:null}),h=S.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return S.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ml=S.createContext(null),Dl=S.createContext(null),Ll=S.createContext(null),ag=S.createContext(!1),lg=20;function cg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=qs(),d=S.useMemo(()=>fn(u),[u]),[f,h]=S.useState([]),[p,w]=S.useState(t),[v,g]=S.useState(!1),[x,b]=S.useState(!1),[y,k]=S.useState(!1),[C,T]=S.useState(!1),[I,A]=S.useState(null),[R,j]=S.useState(void 0),[M,D]=S.useState(void 0),{state:L,seed:P,prepend:V,pushUser:U,onEvent:q,reset:F}=Rl(),N=S.useRef(p);S.useEffect(()=>{N.current=p},[p]);const W=S.useRef(!1),Y=S.useRef([]),de=S.useRef(null),se=S.useRef(null),pe=S.useCallback(($,J)=>new Promise((Te,Me)=>{const Le=async()=>{W.current=!0;try{await $(),Te()}catch(it){Me(it)}finally{W.current=!1;const it=Y.current.shift();it&&it().catch(()=>{})}};W.current?Y.current.push(Le):Le().catch(it=>{Me(it)})}),[]),ge=S.useCallback(async()=>{g(!0);try{const $=await l.listThreads();h($)}catch($){i==null||i(String($)),console.error("[ChatSessionProvider] Failed to refresh threads:",$)}finally{g(!1)}},[l,i]),Se=S.useRef(!1),B=S.useCallback(($,J)=>{const Te=Array.isArray($==null?void 0:$.messages)?$.messages:[];J==="replace"?P(Te,{checkpointId:($==null?void 0:$.checkpointId)??null,checkpointNs:($==null?void 0:$.checkpointNs)??null}):J==="prepend"&&Te.length&&V(Te),A(($==null?void 0:$.nextCursor)??null),k(!!($!=null&&$.hasMore)),j(Me=>($==null?void 0:$.checkpointId)??Me??void 0),D(Me=>($==null?void 0:$.checkpointNs)??Me??void 0)},[V,P]),O=S.useCallback(()=>{F([]),k(!1),T(!1),A(null),j(void 0),D(void 0)},[F]),G=S.useCallback(({from:$,to:J})=>{const Te=N.current;Te&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${$} -> ${J}) for thread ${Te}`)},[]),Z=S.useCallback($=>{const J=$.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:J,title:$.title,created:$.created,currentThreads:f.length});const Te={threadId:J,title:$.title||`Thread ${J.slice(0,8)}`,createdAt:$.createdAt||new Date().toISOString(),updatedAt:$.updatedAt||new Date().toISOString(),messageCount:$.messageCount||0};N.current!==J&&(!N.current&&L.messages.length<=1&&(se.current=J),w(J)),h(Me=>{const Le=Me.findIndex(it=>it.threadId===J);if(Le>=0){const it=[...Me];return it[Le]=Te,console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:",Le),it}else return console.log("[ChatSessionProvider] ➕ Added new thread to list"),[Te,...Me]})},[L.messages.length]),{startStream:ce,stop:ie,isStreaming:De,error:Xe,setAuthToken:Je}=ig({baseUrl:d,onThreadInfo:Z,onMessageEvent:q,onUnhandledEvent:$=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${$.type}`,$)},onSequenceGap:G});S.useEffect(()=>{Se.current=De},[De]),S.useEffect(()=>{var Te;const $=l.getAuthToken();Je($);const J=(Te=l.onTokenChange)==null?void 0:Te.call(l,Me=>{Je(Me)});return()=>{J==null||J()}},[l,Je]);const Ne=S.useCallback(async $=>{const J=`temp-${Date.now()}`,Te={threadId:J,title:$||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};h(Me=>[Te,...Me]),w(J);try{const Me=await l.createThread($),Le=typeof Me=="string"?Me:Me.threadId;return h(it=>it.map(Ot=>Ot.threadId===J?{...Ot,threadId:Le}:Ot)),w(Le),setTimeout(()=>ge(),10),Le}catch(Me){throw h(Le=>Le.filter(it=>it.threadId!==J)),w(null),Me}},[l,ge]),Oe=S.useCallback(async $=>{await l.deleteThread($),N.current===$&&(se.current=$,w(null),O()),await ge()},[l,O,ge]),Qe=S.useCallback(async($,J)=>{try{await l.updateThread($,J),h(Te=>Te.map(Me=>Me.threadId===$?{...Me,title:J}:Me))}catch(Te){throw await ge(),Te}},[l,ge]),Re=S.useCallback(async($,J,Te,Me=!1)=>{await pe(async()=>{if(se.current===$&&!Me){se.current=null;return}if(!(de.current===$&&!Me)){w(Le=>Le===$?Le:$),de.current=$,b(!0);try{const Le=await l.getMessages({threadId:$,checkpointId:J,checkpointNs:Te});B(Le,"replace"),j((Le==null?void 0:Le.checkpointId)??void 0),D((Le==null?void 0:Le.checkpointNs)??void 0)}catch(Le){throw i==null||i(String(Le)),Le}finally{de.current=null,b(!1)}}},`loadThread-${$}`)},[l,B,pe,i]),st=S.useCallback(async()=>{await pe(async()=>{N.current&&(se.current=N.current),w(null),O(),j(void 0),D(void 0);try{localStorage.removeItem("lastThreadId")}catch($){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",$)}},"clearCurrentThread")},[O,pe]),ct=S.useCallback(async $=>{const J=await l.listCheckpoints($);return Km(J,$)},[l]),Q=S.useCallback(async($,J)=>{if(!N.current)throw new Error("No active thread");await Re(N.current,$,J??void 0,!0)},[Re]),le=S.useCallback(async()=>{if(!N.current)throw new Error("No active thread");await Re(N.current,void 0,void 0,!0)},[Re]),me=S.useCallback(async $=>{if(!N.current)throw new Error("No active thread");if(C||!y)return;const J=I;if(J){T(!0);try{const Te=await l.getMessages({threadId:N.current,checkpointId:R,checkpointNs:M,limit:($==null?void 0:$.limit)??lg,beforeId:J});B(Te,"prepend")}finally{T(!1)}}},[l,B,y,R,M,I,C]),Ce=S.useCallback(async($,J)=>{var jn;const Te=N.current;!Te&&!(J!=null&&J.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const Me=(J==null?void 0:J.attachments)||[],{contentParts:Le,filesInfo:it}=await Gm(l,Me),Ot=[...Le];$&&$.trim()&&Ot.push({type:"text",text:$.trim()});const gr={id:((jn=crypto.randomUUID)==null?void 0:jn.call(crypto))||`user-${Date.now()}`,role:"user",content:Ot,createdAt:new Date().toISOString(),checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0};U(gr);const Xn={...gr,content:Ot},xr={...(J==null?void 0:J.payloadExtras)??{}},cn=Me.length>0,Jn={...Te?{threadId:Te}:{},payload:{messages:[Xn],files_info:it,...o&&cn&&s?{active_agent:s}:{},...xr},checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0,nodeFilter:J==null?void 0:J.nodeFilter,config:J==null?void 0:J.config};ce(Jn,{onError:un=>{console.warn("[ChatSessionProvider] Stream error:",un)},onOpen:({threadId:un,created:Ns})=>{!N.current&&un&&(L.messages.length<=1&&(se.current=un),w(un))},onGap:G})},[l,o,s,G,L.lastCheckpointId,L.lastCheckpointNs,L.messages.length,U,ce]),we=S.useCallback(async($,J,Te)=>{const Me=N.current;if(!Me)throw new Error("No active thread to handle interrupt");try{const Le=J?Te??!0:!1;await l.resume({threadId:Me,value:Le})}catch(Le){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${$}:`,Le),Le}},[l]);S.useEffect(()=>{if(a==null||a(p),p)try{localStorage.setItem("lastThreadId",p)}catch($){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",$)}},[p,a]),S.useEffect(()=>{let $=!0;return(async()=>{try{if(await ge(),!$)return;if(!r&&!t)try{const Te=localStorage.getItem("lastThreadId");Te&&(w(Te),n&&await Re(Te))}catch(Te){console.warn("[ChatSessionProvider] Failed to restore last thread:",Te)}else t&&n&&await Re(t)}catch(Te){console.error("[ChatSessionProvider] Initialization failed:",Te),i==null||i(String(Te))}})(),()=>{$=!1}},[]);const _e=S.useMemo(()=>({threads:f,currentThreadId:p,isLoadingThreads:v,isLoadingThread:x,setCurrentThreadId:w,createThread:Ne,deleteThread:Oe,renameThread:Qe,refreshThreads:ge,loadThread:Re,clearCurrentThread:st,listCheckpoints:ct,navigateToCheckpoint:Q,returnToLatest:le}),[st,Ne,p,Oe,x,v,ct,Re,Q,ge,Qe,le,f]),et=S.useMemo(()=>({messages:L.messages,assemblingId:L.assemblingId,lastUserMessage:null,hasMoreHistory:y,isLoadingHistory:C,send:Ce,stop:ie,loadOlderMessages:me,clearMessages:O,handleInterrupt:we}),[O,we,y,C,me,L.assemblingId,L.messages,Ce,ie]),Ke=S.useMemo(()=>({isStreaming:De,error:Xe,streamingAssistantId:L.assemblingId,lastCheckpointId:L.lastCheckpointId??null,lastCheckpointNs:L.lastCheckpointNs??null}),[De,L.assemblingId,L.lastCheckpointId,L.lastCheckpointNs,Xe]);return c.jsx(ag.Provider,{value:!0,children:c.jsx(Ll.Provider,{value:Ke,children:c.jsx(Ml.Provider,{value:_e,children:c.jsx(Dl.Provider,{value:et,children:e})})})})}function ho(){const e=S.useContext(Ml);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Js(){const e=S.useContext(Dl);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Fl(){const e=S.useContext(Ll);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function po({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Vm,{apiConfig:t,children:c.jsx(cg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function X(...e){return bp.twMerge(wp.clsx(e))}const ug=Qr.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"}}),Ue=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?_n.Slot:"button";return c.jsx(i,{className:X(ug({variant:t,size:n,className:e})),ref:s,...o})});Ue.displayName="Button";const $l=m.forwardRef(({className:e,...t},n)=>c.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}));$l.displayName="Textarea";function dg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=S.useState(e),[w,v]=S.useTransition(),g=S.useRef(null);S.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=S.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);S.useEffect(()=>{x()},[x]);const b=S.useCallback(async A=>{A&&A.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const j=i(R);j&&typeof j.then=="function"?j.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=S.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=S.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx($l,{ref:g,value:h,onChange:y,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ue,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ee.Square,{size:16})}):c.jsx(Ue,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(ee.Send,{size:16})})})]})})}const fg=S.memo(dg),mo=0,vn=1,nr=2,zl=4;function Bl(e){return()=>e}function hg(e){e()}function Hl(e,t){return n=>e(t(n))}function Ul(e,t){return()=>e(t)}function pg(e,t){return n=>e(t,n)}function Zs(e){return e!==void 0}function mg(...e){return()=>{e.map(hg)}}function rr(){}function go(e,t){return t(e),e}function gg(e,t){return t(e)}function tt(...e){return e}function Ve(e,t){return e(vn,t)}function je(e,t){e(mo,t)}function Qs(e){e(nr)}function lt(e){return e(zl)}function ue(e,t){return Ve(e,pg(t,mo))}function Wt(e,t){const n=e(vn,r=>{n(),t(r)});return n}function Wl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Vl(e,t){return e===t}function nt(e=Vl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function ne(e){return t=>Hl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=xg(...t);return(r,o)=>{switch(r){case nr:Qs(e);return;case vn:return Ve(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function Mn(e){return t=>n=>{e>0?e--:t(n)}}function hn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Pe(...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,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function xg(...e){return t=>e.reduceRight(gg,t)}function vg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case vn:return s?n===s?void 0:(r(),n=s,t=Ve(e,s),t):(r(),rr);case nr:r(),n=null;return}}}function K(e){let t=e;const n=ze();return(r,o)=>{switch(r){case mo:t=o;break;case vn:{o(t);break}case zl:return t}return n(r,o)}}function xt(e,t){return go(K(t),n=>ue(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case mo:e.slice().forEach(r=>{r(n)});return;case nr:e.splice(0,e.length);return;case vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return go(ze(),t=>ue(e,t))}function We(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:wg(),singleton:n}}const wg=()=>Symbol();function bg(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function dt(...e){const t=ze(),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,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case nr:{Qs(t);return}case vn:return r===o&&i(n),Ve(t,i)}}}function ve(e,t=Vl){return z(e,nt(t))}function ei(...e){return function(t,n){switch(t){case nr:return;case vn:return mg(...e.map(r=>Ve(r,n)))}}}var Et=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Et||{});const yg={0:"debug",3:"error",1:"log",2:"warn"},Sg=()=>typeof globalThis>"u"?window:globalThis,wn=We(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=Sg().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[yg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Dn(e,t,n){return ti(e,t,n).callbackRef}function ti(e,t,n){const r=S.useRef(null);let o=i=>{};const s=S.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Cg(e,t,n,r,o,s,i,a,l){const u=S.useCallback(d=>{const f=Tg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Kl("column-gap",getComputedStyle(d).columnGap,o):Kl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ti(u,n,l)}function Tg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Et.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Kl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}function ql(e,t,n){const r=S.useRef(null),o=S.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ti(o,!0,n),a=S.useCallback(()=>{o(i.current)},[o,i]);return S.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const bt=We(()=>{const e=ze(),t=ze(),n=K(0),r=ze(),o=K(0),s=ze(),i=ze(),a=K(0),l=K(0),u=K(0),d=K(0),f=ze(),h=ze(),p=K(!1),w=K(!1),v=K(!1);return ue(z(e,ne(({scrollTop:g})=>g)),t),ue(z(e,ne(({scrollHeight:g})=>g)),i),ue(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),kr={lvl:0};function Gl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function Ge(e){return e===kr}function Ir(e,t){if(!Ge(e))return t===e.k?e.v:t<e.k?Ir(e.l,t):Ir(e.r,t)}function Vt(e,t,n="k"){if(Ge(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Vt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vt(e.l,t,n)}function jt(e,t,n){return Ge(e)?Jl(t,n,1):t===e.k?ht(e,{k:t,v:n}):t<e.k?Zl(ht(e,{l:jt(e.l,t,n)})):Zl(ht(e,{r:jt(e.r,t,n)}))}function or(){return kr}function xo(e,t,n){if(Ge(e))return[];const r=Vt(e,t)[0];return Eg(ri(e,r,n))}function ni(e,t){if(Ge(e))return kr;const{k:n,l:r,r:o}=e;if(t===n){if(Ge(r))return o;if(Ge(o))return r;{const[s,i]=Xl(r);return vo(ht(e,{k:s,l:Yl(r),v:i}))}}else return t<n?vo(ht(e,{l:ni(r,t)})):vo(ht(e,{r:ni(o,t)}))}function Ln(e){return Ge(e)?[]:[...Ln(e.l),{k:e.k,v:e.v},...Ln(e.r)]}function ri(e,t,n){if(Ge(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ri(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ri(s,t,n))),a}function vo(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(oi(t))return Ql(ht(e,{lvl:n-1}));if(!Ge(t)&&!Ge(t.r))return ht(t.r,{l:ht(t,{r:t.r.l}),lvl:n,r:ht(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(oi(e))return si(ht(e,{lvl:n-1}));if(!Ge(r)&&!Ge(r.l)){const o=r.l,s=oi(o)?r.lvl-1:r.lvl;return ht(o,{l:ht(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:si(ht(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ht(e,t){return Jl(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 Yl(e){return Ge(e.r)?e.l:vo(ht(e,{r:Yl(e.r)}))}function oi(e){return Ge(e)||e.lvl>e.r.lvl}function Xl(e){return Ge(e.r)?[e.k,e.v]:Xl(e.r)}function Jl(e,t,n,r=kr,o=kr){return{k:e,l:r,lvl:n,r:o,v:t}}function Zl(e){return si(Ql(e))}function Ql(e){const{l:t}=e;return!Ge(t)&&t.lvl===e.lvl?ht(t,{r:ht(e,{l:t.r})}):e}function si(e){const{lvl:t,r:n}=e;return!Ge(n)&&!Ge(n.r)&&n.lvl===t&&n.r.lvl===t?ht(n,{l:ht(e,{r:n.l}),lvl:t+1}):e}function Eg(e){return Gl(e,({k:t,v:n})=>({index:t,value:n}))}function ec(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ii=We(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function tc(e,t,n){return e[wo(e,t,n)]}function wo(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 kg(e,t,n,r){const o=wo(e,t,r),s=wo(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bo(e){return!Ge(e.groupOffsetTree)}function ai({index:e},t){return t===e?0:t<e?-1:1}function Ig(){return{groupIndices:[],groupOffsetTree:or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:or()}}function Ng(e,t){let n=Ge(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ge(e)){e=jt(e,0,s);continue}const a=xo(e,i-1,o+1);if(a.some(Mg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ni(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=jt(e,o+1,h));u&&(e=jt(e,i,s))}return[e,n]}function Ag(e){return typeof e.groupIndex<"u"}function jg({offset:e},t){return t===e?0:t<e?-1:1}function Ar(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=tc(t,e,ai),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function nc(e,t){if(!bo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function rc(e,t,n){if(Ag(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=nc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function _g(e,t,n,r=0){return r>0&&(t=Math.max(t,tc(e,r,ai).offset)),Gl(kg(e,t,n,jg),Og)}function Rg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Et.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ge(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>jt(jt(w,v,h),v+1,p),i)}else[i,a]=Ng(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=li(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>jt(h,p,Ar(p,f,o)),or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Pg(e){return Ln(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 oc(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 li(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=wo(o,t-1,ai),a=o[l].offset;const u=Vt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Vt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of xo(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 Og(e){return{index:e.index,value:e}}function Mg(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 Dg={offsetHeight:"height",offsetWidth:"width"},Qt=We(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=xt(r,0),s=ze(),i=ze(),a=K(0),l=K([]),u=K(void 0),d=K(void 0),f=K((C,T)=>bn(C,Dg[T])),h=K(void 0),p=K(0),w=Ig(),v=xt(z(n,Pe(l,e,p),Zt(Rg,w),nt()),w),g=xt(z(l,nt(),Zt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ne(({prev:C})=>C)),[]);ue(z(l,be(C=>C.length>0),Pe(v,p),ne(([C,T,I])=>{const A=C.reduce((R,j,M)=>jt(R,j,Ar(j,T.offsetTree,I)||M),or());return{...T,groupIndices:C,groupOffsetTree:A}})),v),ue(z(r,Pe(v),be(([C,{lastIndex:T}])=>C<T),ne(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ue(u,d);const x=xt(z(u,ne(C=>C===void 0)),!0);ue(z(d,be(C=>C!==void 0&&Ge(lt(v).sizeTree)),ne(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Pe(v),Zt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),ne(C=>C.changed)));Ve(z(a,Zt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ne(C=>C.diff)),C=>{const{groupIndices:T}=lt(v);if(C>0)je(t,!0),je(s,C+oc(C,T));else if(C<0){const I=lt(g);I.length>0&&(C-=oc(-C,I)),je(i,C)}}),Ve(z(a,Pe(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Et.ERROR)});const y=At(s);ue(z(s,Pe(v),ne(([C,T])=>{const I=T.groupIndices.length>0,A=[],R=T.lastSize;if(I){const j=Ir(T.sizeTree,0);let M=0,D=0;for(;M<C;){const P=T.groupIndices[D],V=T.groupIndices.length===D+1?1/0:T.groupIndices[D+1]-P-1;A.push({endIndex:P,size:j,startIndex:P}),A.push({endIndex:P+1+V-1,size:R,startIndex:P+1}),D++,M+=V+1}const L=Ln(T.sizeTree);return M!==C&&L.shift(),L.reduce((P,{k:V,v:U})=>{let q=P.ranges;return P.prevSize!==0&&(q=[...P.ranges,{endIndex:V+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:V+C,prevSize:U,ranges:q}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Ln(T.sizeTree).reduce((j,{k:M,v:D})=>({prevIndex:M+C,prevSize:D,ranges:[...j.ranges,{endIndex:M+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=At(z(i,Pe(v,p),ne(([C,{offsetTree:T},I])=>{const A=-C;return Ar(A,T,I)})));return ue(z(i,Pe(v,p),ne(([C,T,I])=>{if(T.groupIndices.length>0){if(Ge(T.sizeTree))return T;let A=or();const R=lt(g);let j=0,M=0,D=0;for(;j<-C;){D=R[M];const L=R[M+1]-D-1;M++,j+=L+1}if(A=Ln(T.sizeTree).reduce((L,{k:P,v:V})=>jt(L,Math.max(0,P+C),V),A),j!==-C){const L=Ir(T.sizeTree,D);A=jt(A,0,L);const P=Vt(T.sizeTree,-C+1)[1];A=jt(A,1,P)}return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}else{const A=Ln(T.sizeTree).reduce((R,{k:j,v:M})=>jt(R,Math.max(0,j+C),M),or());return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(wn,ii),{singleton:!0});function Lg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const sc=We(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=At(z(s,ne(Lg)));return ue(z(a,ne(l=>l.totalCount)),n),ue(z(a,ne(l=>l.groupIndices)),e),ue(z(dt(o,t,r),be(([l,u])=>bo(u)),ne(([l,u,d])=>Vt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),ne(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(Qt,bt)),yn=We(([{log:e}])=>{const t=K(!1),n=At(z(t,be(r=>r),nt()));return Ve(t,r=>{r&<(e)("props updated",{},Et.DEBUG)}),{didMount:n,propsReady:t}},tt(wn),{singleton:!0}),Fg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ic(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Fg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const jr=We(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=ze(),w=ze(),v=K(0);let g=null,x=null,b=null;function y(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),je(l,!1)}return ue(z(p,Pe(n,f,r,v,a,i,h),Pe(e,s,o),ne(([[k,C,T,I,A,R,j,M],D,L,P])=>{const V=ic(k),{align:U,behavior:q,offset:F}=V,N=I-1,W=rc(V,C,N);let Y=Ar(W,C.offsetTree,D)+R;U==="end"?(Y+=L+Vt(C.sizeTree,W)[1]-T+P,W===N&&(Y+=j)):U==="center"?Y+=(L+Vt(C.sizeTree,W)[1]-T+P)/2:Y-=A,F&&(Y+=F);const de=se=>{y(),se?(M("retrying to scroll to",{location:k},Et.DEBUG),je(p,k)):(je(w,!0),M("list did not change, scroll successful",{},Et.DEBUG))};if(y(),q==="smooth"){let se=!1;b=Ve(t,pe=>{se=se||pe}),g=Wt(d,()=>{de(se)})}else g=Wt(z(t,$g(150)),de);return x=setTimeout(()=>{y()},1200),je(l,!0),M("scrolling from index to",{behavior:q,index:W,top:Y},Et.DEBUG),{behavior:q,top:Y}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},tt(Qt,bt,wn),{singleton:!0});function $g(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ci(e,t){e==0?t():requestAnimationFrame(()=>{ci(e-1,t)})}function ui(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const _r=We(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),l=K(0),u=K(!0);return ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),a),ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),u),Ve(z(dt(t,i),Pe(a,n,e,u),be(([[,d],f,{sizeTree:h},p,w])=>d&&(!Ge(h)||Zs(p))&&!f&&!w),Pe(l)),([,d])=>{Wt(o,()=>{je(u,!0)}),ci(4,()=>{Wt(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(Qt,bt,jr,yn),{singleton:!0});function ac(e,t){return Math.abs(e-t)<1.01}const Rr="up",Pr="down",zg="none",Bg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Hg=0,Or=We(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),l=ze(),u=ze(),d=K(4),f=K(Hg),h=xt(z(ei(z(ve(o),Mn(1),Jt(!0)),z(ve(o),Mn(1),Jt(!1),Wl(100))),nt()),!1),p=xt(z(ei(z(n,Jt(!0)),z(n,Jt(!1),Wl(200))),nt()),!1);ue(z(dt(ve(o),ve(f)),ne(([b,y])=>b<=y),nt()),a),ue(z(a,hn(50)),u);const w=At(z(dt(r,ve(s),ve(t),ve(e),ve(d)),Zt((b,[{scrollHeight:y,scrollTop:k},C,T,I,A])=>{const R=k+C-y>-A,j={scrollHeight:y,scrollTop:k,viewportHeight:C};if(R){let D,L;return k>b.state.scrollTop?(D="SCROLLED_DOWN",L=b.state.scrollTop-k):(D="SIZE_DECREASED",L=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:D,scrollTopDelta:L,state:j}}let M;return j.scrollHeight>b.state.scrollHeight?M="SIZE_INCREASED":C<b.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:j}},Bg),nt((b,y)=>b&&b.atBottom===y.atBottom))),v=xt(z(r,Zt((b,{scrollHeight:y,scrollTop:k,viewportHeight:C})=>{if(ac(b.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:k};{const T=y-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:y,scrollTop:k}:{changed:!0,jump:0,scrollHeight:y,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(b=>b.changed),ne(b=>b.jump)),0);ue(z(w,ne(b=>b.atBottom)),i),ue(z(i,hn(50)),l);const g=K(Pr);ue(z(r,ne(({scrollTop:b})=>b),nt(),Zt((b,y)=>lt(p)?{direction:b.direction,prevScrollTop:y}:{direction:y<b.prevScrollTop?Rr:Pr,prevScrollTop:y},{direction:Pr,prevScrollTop:0}),ne(b=>b.direction)),g),ue(z(r,hn(50),Jt(zg)),g);const x=K(0);return ue(z(h,be(b=>!b),Jt(0)),x),ue(z(o,hn(100),Pe(h),be(([b,y])=>!!y),Zt(([b,y],[k])=>[y,k],[0,0]),ne(([b,y])=>y-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},tt(bt)),yo="top",So="bottom",lc="none";function cc(e,t,n){return typeof e=="number"?n===Rr&&t===yo||n===Pr&&t===So?e:0:n===Rr?t===yo?e.main:e.reverse:t===So?e.main:e.reverse}function uc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const di=We(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=K(0),a=K(0),l=K(0),u=xt(z(dt(ve(r),ve(o),ve(n),ve(s,Nr),ve(l),ve(i),ve(t),ve(e),ve(a)),ne(([d,f,h,[p,w],v,g,x,b,y])=>{const k=d-b,C=g+x,T=Math.max(h-k,0);let I=lc;const A=uc(y,yo),R=uc(y,So);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Rr),w<d-T+f+R&&(I=Pr),I!==lc?[Math.max(k-h-cc(v,yo,I)-A,0),k-T-x+f+cc(v,So,I)+R]:null}),be(d=>d!=null),nt(Nr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(bt),{singleton:!0});function Ug(e,t,n){if(bo(t)){const r=nc(e,t);return[{index:Vt(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 fi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:fc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:fc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function dc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=ui(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Co(u,[],a,o,n,r)}function fc(e,t,n){if(e.length===0)return[];if(!bo(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=xo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Fn=We(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:w}])=>{const v=K([]),g=K(0),x=ze();ue(s.topItemsIndexes,v);const b=xt(z(dt(p,w,ve(l,Nr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,A,,,,,,,R])=>{const j=R&&R.length!==A;return T&&!I&&!j}),ne(([,,[T,I],A,R,j,M,D,L,P,V])=>{const U=R,{offsetTree:q,sizeTree:F}=U,N=lt(g);if(A===0)return{...fi,totalCount:A};if(T===0&&I===0)return N===0?{...fi,totalCount:A}:dc(N,j,R,L,P,V||[]);if(Ge(F))return N>0?null:Co(Ug(ui(j,A),U,V),[],A,P,U,L);const W=[];if(D.length>0){const ge=D[0],Se=D[D.length-1];let B=0;for(const O of xo(F,ge,Se)){const G=O.value,Z=Math.max(O.start,ge),ce=Math.min(O.end,Se);for(let ie=Z;ie<=ce;ie++)W.push({data:V==null?void 0:V[ie],index:ie,offset:B,size:G}),B+=G}}if(!M)return Co([],W,A,P,U,L);const Y=D.length>0?D[D.length-1]+1:0,de=_g(q,T,I,Y);if(de.length===0)return null;const se=A-1,pe=go([],ge=>{for(const Se of de){const B=Se.value;let O=B.offset,G=Se.start;const Z=B.size;if(B.offset<T){G+=Math.floor((T-B.offset+P)/(Z+P));const ie=G-Se.start;O+=ie*Z+ie*P}G<Y&&(O+=(Y-G)*Z,G=Y);const ce=Math.min(Se.end,se);for(let ie=G;ie<=ce&&!(O>=I);ie++)ge.push({data:V==null?void 0:V[ie],index:ie,offset:O,size:Z}),O+=Z+P}});return Co(pe,W,A,P,U,L)}),be(T=>T!==null),nt()),fi);ue(z(e,be(Zs),ne(T=>T==null?void 0:T.length)),o),ue(z(b,ne(T=>T.topListHeight)),f),ue(f,a),ue(z(b,ne(T=>[T.top,T.bottom])),i),ue(z(b,ne(T=>T.items)),x);const y=At(z(b,be(({items:T})=>T.length>0),Pe(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ne(([,T,I])=>[T-1,I]),nt(Nr),ne(([T])=>T))),k=At(z(b,hn(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ne(({items:T})=>T[0].index),nt())),C=At(z(b,be(({items:T})=>T.length>0),ne(({items:T})=>{let I=0,A=T.length-1;for(;T[I].type==="group"&&I<A;)I++;for(;T[A].type==="group"&&A>I;)A--;return{endIndex:T[A].index,startIndex:T[I].index}}),nt(ec)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:v,...h}},tt(Qt,sc,di,_r,jr,Or,yn,ii),{singleton:!0}),hc=We(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=xt(z(dt(n,e,r,t,o),ne(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ue(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(bt,Fn),{singleton:!0}),Wg=We(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=xt(z(dt(n,e,t),be(([o])=>o),ne(([,o,s])=>Math.max(0,o-s)),hn(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(bt,hc),{singleton:!0}),pc=We(()=>({context:K(null)})),Vg=({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,mc=We(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=ze();return ue(z(d,Pe(t,l,n,s,o,r,a),Pe(e),ne(([[f,h,p,w,v,g,x,b],y])=>{const{align:k,behavior:C,calculateViewLocation:T=Vg,done:I,...A}=f,R=rc(f,h,w-1),j=Ar(R,h.offsetTree,y)+v+g,M=j+Vt(h.sizeTree,R)[1],D=b+g,L=b+p-x,P=T({itemBottom:M,itemTop:j,locationParams:{align:k,behavior:C,...A},viewportBottom:L,viewportTop:D});return P?I&&Wt(z(i,be(V=>!V),Mn(lt(i)?1:2)),I):I&&I(),P}),be(f=>f!==null)),u),{scrollIntoView:d}},tt(Qt,bt,jr,Fn,wn),{singleton:!0});function gc(e){return e?e==="smooth"?"smooth":"auto":!1}const Kg=(e,t)=>typeof e=="function"?gc(e(t)):t&&gc(e),qg=We(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const w=K(!1),v=ze();let g=null;function x(C){je(i,{align:"end",behavior:C,index:"LAST"})}Ve(z(dt(z(ve(t),Mn(1)),l),Pe(ve(w),s,a,f),ne(([[C,T],I,A,R,j])=>{let M=T&&R,D="auto";return M&&(D=Kg(I,A||j),M=M&&!!D),{followOutputBehavior:D,shouldFollow:M,totalCount:C}}),be(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:T},Et.DEBUG),x(C)}):g=Wt(e,()=>{lt(d)("following output to ",{totalCount:T},Et.DEBUG),x(C),g=null})});function b(C){const T=Wt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},Et.DEBUG),x("auto"))});setTimeout(T,100)}Ve(z(dt(ve(w),t,u),be(([C,,T])=>C&&T),Zt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:C})=>C),Pe(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Ve(v,()=>{b(lt(w)!==!1)}),Ve(dt(ve(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),k=ze();return ue(ei(z(ve(r),ne(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),z(ve(t))),k),Ve(z(dt(z(k,Mn(1)),l),Pe(ve(y),a,f,h),ne(([[C,T],I,A,R,j])=>T&&A&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:R}))),be(C=>!!C),hn(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),je(p,C)}):g=Wt(e,()=>{lt(d)("scrolling into view",{}),je(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:y}},tt(Qt,Or,jr,_r,yn,wn,bt,pc,mc)),Gg=We(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ue(z(a,Pe(s),be(([,l])=>l!==0),Pe(o,r,t,n,e),ne(([[,l],u,d,f,h,p=[]])=>dc(l,u,d,f,h,p))),i),{}),tt(Qt,_r,Fn,yn),{singleton:!0}),Yg=We(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return Ve(z(e,Pe(r),be(([,o])=>o!==0),ne(([,o])=>({top:o}))),o=>{Wt(z(n,Mn(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},tt(yn,bt,Fn),{singleton:!0}),xc=We(([{scrollVelocity:e}])=>{const t=K(!1),n=ze(),r=K(!1);return ue(z(e,Pe(r,t,n),be(([o,s])=>!!s),ne(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),nt()),t),Ve(z(dt(t,e,n),Pe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},tt(Or),{singleton:!0}),hi=We(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=K(!1),i=K(void 0);return ue(z(dt(n,r),ne(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ue(z(t,Pe(r),ne(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(bt)),Xg=We(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=ze(),d=K(void 0),f=K(null),h=K(null);return ue(a,f),ue(l,h),Ve(z(u,Pe(t,r,i,f,h,n)),([p,w,v,g,x,b,y])=>{const k=Pg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=y,p({ranges:k,scrollTop:v})}),ue(z(d,be(Zs),ne(Jg)),o),ue(z(s,Pe(d),be(([,p])=>p!==void 0),nt(),ne(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(Qt,bt,_r,yn,hi));function Jg(e){return{align:"start",index:0,offset:e.scrollTop}}const Zg=We(([{topItemsIndexes:e}])=>{const t=K(0);return ue(z(t,be(n=>n>=0),ne(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(Fn));function vc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Qg=vc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ex=We(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:w}])=>{const v=At(z(l,Pe(i),Zt(([,x,b,y],[{bottom:k,items:C,offsetBottom:T,totalCount:I},A])=>{const R=k+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=R-y,j!==0&&(j+=A))),[j,C,I,R]},[0,[],0,0]),be(([x])=>x!==0),Pe(r,a,n,o,p,w),be(([,x,b,y,,,k])=>!k&&!y&&x!==0&&b===Rr),ne(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Et.DEBUG),x))));function g(x){x>0?(je(t,{behavior:"auto",top:-x}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-x}))}return Ve(z(v,Pe(e,s)),([x,b,y])=>{y&&Qg()?je(e,b-x):g(-x)}),Ve(z(dt(xt(s,!1),e,w),be(([x,b,y])=>!x&&!y&&b!==0),ne(([x,b])=>b),hn(1)),g),ue(z(f,ne(x=>({top:-x}))),t),Ve(z(u,Pe(h,d),ne(([x,{groupIndices:b,lastSize:y,sizeTree:k},C])=>{function T(I){return I*(y+C)}if(b.length===0)return T(x);{let I=0;const A=Ir(k,0);let R=0,j=0;for(;R<x;){R++,I+=A;let M=b.length===j+1?1/0:b[j+1]-b[j]-1;R+M>x&&(I-=A,M=x-R+1),R+=M,I+=T(M),j++}return I}})),x=>{je(e,x),requestAnimationFrame(()=>{je(t,{top:x}),requestAnimationFrame(()=>{je(e,0),je(w,!1)})})}),{deviation:e}},tt(bt,Or,Fn,Qt,wn,ii)),tx=We(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(di,Gg,yn,xc,hc,Yg,Wg,hi,mc,wn,pc)),wc=We(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:y,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},R])=>(ue(k.rangeChanged,R.scrollSeekRangeChanged),ue(z(R.windowViewportRect,ne(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,...R,...v,sizes:l,...g}),tt(Qt,_r,bt,Xg,qg,Fn,jr,ex,Zg,sc,tx));function nx(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 To=typeof document<"u"?S.useLayoutEffect:S.useEffect;function bc(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 l(g,x){g.propsReady&&je(g.propsReady,!1);for(const b of r){const y=g[t.required[b]];je(y,x[b])}for(const b of o)if(b in x){const y=g[t.optional[b]];je(y,x[b])}g.propsReady&&je(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=y=>{const k=g[t.methods[b]];je(k,y)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=vg(g[t.events[b]]),x),{})}const f=S.forwardRef((g,x)=>{const{children:b,...y}=g,[k]=S.useState(()=>go(bg(e),I=>{l(I,y)})),[C]=S.useState(Ul(d,k));To(()=>{for(const I of i)I in y&&Ve(C[I],y[I]);return()=>{Object.values(C).map(Qs)}},[y,C,k]),To(()=>{l(k,y)}),S.useImperativeHandle(x,Bl(u(k)));const T=n;return c.jsx(a.Provider,{value:k,children:n?c.jsx(T,{...nx([...r,...o,...i],y),children:b}):b})}),h=g=>{const x=S.useContext(a);return S.useCallback(b=>{je(x[g],b)},[x,g])},p=g=>{const x=S.useContext(a)[g],b=S.useCallback(y=>Ve(x,y),[x]);return S.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=S.useContext(a)[g],[b,y]=S.useState(Ul(lt,x));return To(()=>Ve(x,k=>{k!==b&&y(Bl(k))}),[x,b]),b},v=S.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=S.useContext(a)[g];To(()=>Ve(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const yc=S.createContext(void 0),Sc=S.createContext(void 0),Cc=typeof document<"u"?S.useLayoutEffect:S.useEffect;function pi(e){return"self"in e}function rx(e){return"body"in e}function Tc(e,t,n,r=rr,o,s){const i=S.useRef(null),a=S.useRef(null),l=S.useRef(null),u=S.useCallback(h=>{let p,w,v;const g=h.target;if(rx(g)||pi(g)){const b=pi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():_s.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;pi(p)?(g=Math.max(bn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],v=bn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),ac(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const mi="-webkit-sticky",Ec="sticky",gi=vc(()=>{if(typeof document>"u")return Ec;const e=document.createElement("div");return e.style.position=mi,e.style.position===mi?mi:Ec});function xi(e){return e}const ox=We(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(xi),o=K("div"),s=K(rr),i=(a,l=null)=>xt(z(n,ne(u=>u[a]),nt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),sx=We(([e,t])=>({...e,...t}),tt(wc,ox)),ix=({height:e})=>c.jsx("div",{style:{height:e}}),ax={overflowAnchor:"none",position:gi(),zIndex:1},kc={overflowAnchor:"none"},lx={...kc,display:"inline-block",height:"100%"},Ic=S.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=Lt("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),u=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),h=Ie("itemSize"),p=Ie("log"),w=Lt("gap"),v=Ie("horizontalDirection"),{callbackRef:g}=Cg(n,h,f,e?rr:a,p,w,o,v,Ie("skipAnimationFrameInResizeObserver")),[x,b]=S.useState(0);vi("deviation",P=>{x!==P&&b(P)});const y=Ie("EmptyPlaceholder"),k=Ie("ScrollSeekPlaceholder")||ix,C=Ie("ListComponent"),T=Ie("ItemComponent"),I=Ie("GroupComponent"),A=Ie("computeItemKey"),R=Ie("isSeeking"),j=Ie("groupIndices").length>0,M=Ie("alignToBottom"),D=Ie("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...D?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?c.jsx(y,{...vt(y,u)}):c.jsx(C,{...vt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:L,children:(e?t.topItems:t.items).map(P=>{const V=P.originalIndex,U=A(V+t.firstItemIndex,P.data,u);return R?S.createElement(k,{...vt(k,u),height:P.size,index:P.index,key:U,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?S.createElement(I,{...vt(I,u),"data-index":V,"data-item-index":P.index,"data-known-size":P.size,key:U,style:ax},d(P.index,u)):S.createElement(T,{...vt(T,u),...fx(T,P.data),"data-index":V,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:U,style:v?lx:kc},j?l(P.index,P.groupIndex,P.data,u):l(P.index,P.data,u))})})}),cx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},ux={outline:"none",overflowX:"auto",position:"relative"},Eo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),dx={position:gi(),top:0,width:"100%",zIndex:1};function vt(e,t){if(typeof e!="string")return{context:t}}function fx(e,t){return{item:typeof e=="string"?void 0:t}}const hx=S.memo(function(){const e=Ie("HeaderComponent"),t=Lt("headerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),px=S.memo(function(){const e=Ie("FooterComponent"),t=Lt("footerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null});function Nc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:w}=Tc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?ux:cx,...o},tabIndex:0,...i,...vt(l,s),children:r})})}function Ac({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=S.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Tc(a,u,l,w,h);return Cc(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...vt(l,s),children:r})})}const mx=({children:e})=>{const t=S.useContext(yc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=S.useMemo(()=>Hl(n,l=>bn(l,s?"width":"height")),[n,s]),a=Dn(i,!0,Ie("skipAnimationFrameInResizeObserver"));return S.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Eo(o),children:e})},gx=({children:e})=>{const t=S.useContext(yc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Ie("customScrollParent"),s=ql(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return S.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Eo(i),children:e})},xx=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...dx,marginTop:`${n}px`},o=Ie("context");return c.jsx(t,{style:r,...vt(t,o),children:e})},vx=S.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return c.jsxs(r||t?yx:bx,{...e,context:o,children:[n&&c.jsx(xx,{children:c.jsx(Ic,{showTopList:!0})}),c.jsxs(r||t?gx:mx,{children:[c.jsx(hx,{}),c.jsx(Ic,{}),c.jsx(px,{})]})]})}),{Component:wx,useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}=bc(sx,{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"}},vx),bx=Nc({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),yx=Ac({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),Sx=wx;tt(wc,We(()=>{const e=K(u=>c.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(xi),a=K(rr),l=(u,d=null)=>xt(z(s,ne(f=>f[u]),nt()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),gi();const jc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_c,floor:ko,max:Mr,min:wi,round:Rc}=Math;function Pc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Tx(e){return{...Cx,items:e}}function Io(e,t){return e&&e.width===t.width&&e.height===t.height}function Ex(e,t){return e&&e.column===t.column&&e.row===t.row}const kx=We(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:k},C])=>{const T=K(0),I=K(0),A=K(jc),R=K({height:0,width:0}),j=K({height:0,width:0}),M=ze(),D=ze(),L=K(0),P=K(null),V=K({column:0,row:0}),U=ze(),q=ze(),F=K(!1),N=K(0),W=K(!0),Y=K(!1),de=K(!1);Ve(z(w,Pe(N),be(([O,G])=>!!G)),()=>{je(W,!1)}),Ve(z(dt(w,W,j,R,N,Y),be(([O,G,Z,ce,,ie])=>O&&!G&&Z.height!==0&&ce.height!==0&&!ie)),([,,,,O])=>{je(Y,!0),ci(1,()=>{je(M,O)}),Wt(z(u),()=>{je(t,[0,0]),je(W,!0)})}),ue(z(q,be(O=>O!=null&&O.scrollTop>0),Jt(0)),I),Ve(z(w,Pe(q),be(([,O])=>O!=null)),([,O])=>{O&&(je(R,O.viewport),je(j,O.item),je(V,O.gap),O.scrollTop>0&&(je(F,!0),Wt(z(u,Mn(1)),G=>{je(F,!1)}),je(l,{top:O.scrollTop})))}),ue(z(R,ne(({height:O})=>O)),f),ue(z(dt(ve(R,Io),ve(j,Io),ve(V,(O,G)=>O&&O.column===G.column&&O.row===G.row),ve(u)),ne(([O,G,Z,ce])=>({gap:Z,item:G,scrollTop:ce,viewport:O}))),U),ue(z(dt(ve(T),r,ve(V,Ex),ve(j,Io),ve(R,Io),ve(P),ve(I),ve(F),ve(W),ve(N)),be(([,,,,,,,O])=>!O),ne(([O,[G,Z],ce,ie,De,Xe,Je,,Ne,Oe])=>{const{column:Qe,row:Re}=ce,{height:st,width:ct}=ie,{width:Q}=De;if(Je===0&&(O===0||Q===0))return jc;if(ct===0){const J=ui(Oe,O),Te=J+Math.max(Je-1,0);return Tx(Pc(J,Te,Xe))}const le=Oc(Q,ct,Qe);let me,Ce;Ne?G===0&&Z===0&&Je>0?(me=0,Ce=Je-1):(me=le*ko((G+Re)/(st+Re)),Ce=le*_c((Z+Re)/(st+Re))-1,Ce=wi(O-1,Mr(Ce,le-1)),me=wi(Ce,Mr(0,me))):(me=0,Ce=-1);const we=Pc(me,Ce,Xe),{bottom:_e,top:et}=Mc(De,ce,ie,we),Ke=_c(O/le),$=Ke*st+(Ke-1)*Re-_e;return{bottom:_e,itemHeight:st,items:we,itemWidth:ct,offsetBottom:$,offsetTop:et,top:et}})),A),ue(z(P,be(O=>O!==null),ne(O=>O.length)),T),ue(z(dt(R,j,A,V),be(([O,G,{items:Z}])=>Z.length>0&&G.height!==0&&O.height!==0),ne(([O,G,{items:Z},ce])=>{const{bottom:ie,top:De}=Mc(O,ce,G,Z);return[De,ie]}),nt(Nr)),t);const se=K(!1);ue(z(u,Pe(se),ne(([O,G])=>G||O!==0)),se);const pe=At(z(dt(A,T),be(([{items:O}])=>O.length>0),Pe(se),be(([[O,G],Z])=>{const ce=O.items[O.items.length-1].index===G-1;return(Z||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===G)&&ce}),ne(([[,O]])=>O-1),nt())),ge=At(z(ve(A),be(({items:O})=>O.length>0&&O[0].index===0),Jt(0),nt())),Se=At(z(ve(A),Pe(F),be(([{items:O},G])=>O.length>0&&!G),ne(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),nt(ec),hn(0)));ue(Se,p.scrollSeekRangeChanged),ue(z(M,Pe(R,j,T,V),ne(([O,G,Z,ce,ie])=>{const De=ic(O),{align:Xe,behavior:Je,offset:Ne}=De;let Oe=De.index;Oe==="LAST"&&(Oe=ce-1),Oe=Mr(0,Oe,wi(ce-1,Oe));let Qe=bi(G,ie,Z,Oe);return Xe==="end"?Qe=Rc(Qe-G.height+Z.height):Xe==="center"&&(Qe=Rc(Qe-G.height/2+Z.height/2)),Ne&&(Qe+=Ne),{behavior:Je,top:Qe}})),l);const B=xt(z(A,ne(O=>O.offsetBottom+O.bottom)),0);return ue(z(k,ne(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:g,data:P,deviation:L,footerHeight:o,gap:V,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:D,scrollTo:l,scrollToIndex:M,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:k,...p,gridState:A,horizontalDirection:de,initialTopMostItemIndex:N,totalListHeight:B,...h,endReached:pe,propsReady:v,rangeChanged:Se,startReached:ge,stateChanged:U,stateRestoreInProgress:F,...C}},tt(di,bt,Or,xc,yn,hi,wn));function Oc(e,t,n){return Mr(1,ko((e+n)/(ko(t)+n)))}function Mc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=bi(e,t,n,r[0].index);return{bottom:bi(e,t,n,r[r.length-1].index)+o,top:s}}function bi(e,t,n,r){const o=Oc(e.width,n.width,t.column),s=ko(r/o),i=s*n.height+Mr(0,s-1)*t.row;return i>0?i+t.row:i}const Ix=We(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(xi),i=K("div"),a=K(rr),l=(f,h=null)=>xt(z(t,ne(p=>p[f]),nt()),h),u=K(!1),d=K(!1);return ue(ve(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Nx=We(([e,t])=>({...e,...t}),tt(kx,Ix)),Ax=S.memo(function(){const e=rt("gridState"),t=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),o=rt("computeItemKey"),s=rt("isSeeking"),i=Ft("scrollHeight"),a=rt("ItemComponent"),l=rt("ListComponent"),u=rt("ScrollSeekPlaceholder"),d=rt("context"),f=Ft("itemDimensions"),h=Ft("gap"),p=rt("log"),w=rt("stateRestoreInProgress"),v=Ft("reportReadyState"),g=Dn(S.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const y=x.firstChild;if(y){const{height:k,width:C}=y.getBoundingClientRect();f({height:k,width:C})}h({column:Lc("column-gap",getComputedStyle(x).columnGap,p),row:Lc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return Cc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...vt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...vt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):S.createElement(a,{...vt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),jx=S.memo(function(){const e=rt("HeaderComponent"),t=Ft("headerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),_x=S.memo(function(){const e=rt("FooterComponent"),t=Ft("footerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),Rx=({children:e})=>{const t=S.useContext(Sc),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),o=Dn(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]),c.jsx("div",{ref:o,style:Eo(!1),children:e})},Px=({children:e})=>{const t=S.useContext(Sc),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),o=rt("customScrollParent"),s=ql(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]),c.jsx("div",{ref:s,style:Eo(!1),children:e})},Ox=S.memo(function({...e}){const t=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||t?Dx:Mx,o=n||t?Px:Rx,s=rt("context");return c.jsx(r,{...e,...vt(r,s),children:c.jsxs(o,{children:[c.jsx(jx,{}),c.jsx(Ax,{}),c.jsx(_x,{})]})})}),{useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}=bc(Nx,{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"}},Ox),Mx=Nc({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}),Dx=Ac({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft});function Lc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}const Lx=Qr.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 yi({className:e,variant:t,...n}){return c.jsx("div",{className:X(Lx({variant:t}),e),...n})}function oe(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 Fx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,$x(o,...t)]}function $x(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},zx=m[" useInsertionEffect ".trim().toString()]||pt;function $n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Bx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Hx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Bx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return zx(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Hx(e){return typeof e=="function"}function Fc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Si(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fc(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():Fc(e[o],null)}}}}function Fe(...e){return m.useCallback(Si(...e),e)}var Ux=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Ux.reduce((e,t)=>{const n=_n.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function $c(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function Wx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var _t=e=>{const{present:t,children:n}=e,r=Vx(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Fe(r.ref,Kx(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};_t.displayName="Presence";function Vx(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=No(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=No(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=No(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=No(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function No(e){return(e==null?void 0:e.animationName)||"none"}function Kx(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 qx=m[" useId ".trim().toString()]||(()=>{}),Gx=0;function tn(e){const[t,n]=m.useState(qx());return pt(()=>{n(r=>r??String(Gx++))},[e]),e||(t?`radix-${t}`:"")}var Ao="Collapsible",[Yx,OC]=en(Ao),[Xx,Ci]=Yx(Ao),zc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=$n({prop:r,defaultProp:o??!1,onChange:i,caller:Ao});return c.jsx(Xx,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(ye.div,{"data-state":Ei(l),"data-disabled":s?"":void 0,...a,ref:t})})});zc.displayName=Ao;var Bc="CollapsibleTrigger",Hc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ci(Bc,n);return c.jsx(ye.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:oe(e.onClick,o.onOpenToggle)})});Hc.displayName=Bc;var Ti="CollapsibleContent",Jx=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ci(Ti,e.__scopeCollapsible);return c.jsx(_t,{present:n||o.open,children:({present:s})=>c.jsx(Zx,{...r,ref:t,present:s})})});Jx.displayName=Ti;var Zx=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ci(Ti,n),[a,l]=m.useState(r),u=m.useRef(null),d=Fe(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const y=b.getBoundingClientRect();f.current=y.height,p.current=y.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(ye.div,{"data-state":Ei(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function Ei(e){return e?"open":"closed"}var Qx=zc;const Uc=Qx,Wc=Hc,Dr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Dr.displayName="Card";const Lr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Lr.displayName="CardHeader";const Fr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Fr.displayName="CardTitle";const Vc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Vc.displayName="CardDescription";const jo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));jo.displayName="CardContent";const Kc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));Kc.displayName="CardFooter";function qc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let zn=qc();function ev(e){zn=e}const Gc=/[&<>"']/,tv=new RegExp(Gc.source,"g"),Yc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,nv=new RegExp(Yc.source,"g"),rv={"&":"&","<":"<",">":">",'"':""","'":"'"},Xc=e=>rv[e];function wt(e,t){if(t){if(Gc.test(e))return e.replace(tv,Xc)}else if(Yc.test(e))return e.replace(nv,Xc);return e}const ov=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Jc(e){return e.replace(ov,(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 sv=/(^|[^\[])\^/g;function Ye(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(sv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const iv=/[^\w:]/g,av=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Zc(e,t,n){if(e){let r;try{r=decodeURIComponent(Jc(n)).replace(iv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!av.test(n)&&(n=dv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const _o={},lv=/^[^:]+:\/*[^/]*$/,cv=/^([^:]+:)[\s\S]*$/,uv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function dv(e,t){_o[" "+e]||(lv.test(e)?_o[" "+e]=e+"/":_o[" "+e]=Po(e,"/",!0)),e=_o[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(cv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(uv,"$1")+t:e+t}const Ro={exec:function(){}};function Qc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Po(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 fv(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 hv(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 eu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function tu(e,t,n,r){const o=t.href,s=t.title?wt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:wt(i)}}function pv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
32
|
+
`))>=0;){const ee=z.slice(0,ne);z=z.slice(ne+2);const xe=og(ee);if(!xe)continue;let Ee;try{Ee=JSON.parse(xe)}catch{console.debug("[use-chat] malformed SSE:",xe.slice(0,200));continue}const Se=rg(Ee)?Ee.data:Ee;Fe=Date.now();const Re=Se.seq;if(Re!==void 0){if(Re<=q){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Re,lastProcessedSeq:q,type:Se.type});continue}q>0&&Re>q+1&&((N=L==null?void 0:L.onGap)==null||N.call(L,{from:q,to:Re})),q=Re,C.current=Re,g(Re)}if(D==null||D(Se),Se.type==="token"&&e.autoAppendAssistant!==!1)M.push(Se.content),te();else if(Se.type==="message_delta"){const Je=Se.delta.filter(Ke=>Ke.type==="text").map(Ke=>Ke.text).join("");Je&&e.autoAppendAssistant!==!1&&(M.push(Je),te())}else Se.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(Z!==null&&cancelAnimationFrame(Z),ce(),Se.type==="checkpoint"?v(Se.checkpointId):Se.type==="error"&&d(Se.message))}}ce()}catch(je){if(je.name!=="AbortError"){const Oe=je.message||String(je);d(Oe),(V=L==null?void 0:L.onError)==null||V.call(L,Oe)}}finally{try{await ye.cancel()}catch{}finally{(X=ye.releaseLock)==null||X.call(ye)}Z!==null&&typeof window<"u"&&window.cancelAnimationFrame(Z),clearInterval(Qe),l(!1),b(!1),y.current=null,C.current=0,g(0)}}catch(le){if(le.name!=="AbortError"){const fe=le.message||String(le);d(fe),(pe=L==null?void 0:L.onError)==null||pe.call(L,fe)}}finally{l(!1),b(!1),y.current=null,C.current=0,g(0)}})(),{close:()=>F.abort()}},[t,n,r,e.autoAppendAssistant]);return S.useEffect(()=>()=>{var _;E.current=!1,(_=y.current)==null||_.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:w,connected:x,stream:P,stop:I,clear:A,setToken:T}}function rg(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function og(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
33
|
+
`)}function sg({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=S.useRef(null),i=S.useCallback(p=>{const v=p.seq??null;if(v!==null){const w=s.current;if(w!==null){if(v<=w)return;v>w+1&&(o==null||o({from:w,to:v}))}s.current=v}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Gm(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=_l({baseUrl:e,token:null}),h=S.useCallback((p,v)=>{s.current=null,a(p,i,{onOpen:v==null?void 0:v.onOpen,onError:w=>{var g;(g=v==null?void 0:v.onError)==null||g.call(v,w)},onGap:(v==null?void 0:v.onGap)??o})},[i,o,a]);return S.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Rl=S.createContext(null),Pl=S.createContext(null),Ol=S.createContext(null),ig=S.createContext(!1),ag=20;function lg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=qs(),d=S.useMemo(()=>pn(u),[u]),[f,h]=S.useState([]),[p,v]=S.useState(t),[w,g]=S.useState(!1),[x,b]=S.useState(!1),[y,E]=S.useState(!1),[C,T]=S.useState(!1),[I,A]=S.useState(null),[P,_]=S.useState(void 0),[D,L]=S.useState(void 0),{state:F,seed:O,prepend:W,pushUser:U,onEvent:G,reset:$}=Al(),N=S.useRef(p);S.useEffect(()=>{N.current=p},[p]);const V=S.useRef(!1),X=S.useRef([]),pe=S.useRef(null),le=S.useRef(null),fe=S.useRef(new Map),ye=S.useRef(p),we=S.useCallback((j,Y)=>new Promise((ue,Ce)=>{const Me=async()=>{V.current=!0;try{await j(),ue()}catch(he){Ce(he)}finally{V.current=!1;const he=X.current.shift();he&&he().catch(()=>{})}};V.current?X.current.push(Me):Me().catch(he=>{Ce(he)})}),[]),z=S.useCallback(async()=>{g(!0);try{const j=await l.listThreads();h(j)}catch(j){i==null||i(String(j)),console.error("[ChatSessionProvider] Failed to refresh threads:",j)}finally{g(!1)}},[l,i]),M=S.useRef(!1),q=S.useCallback((j,Y,ue)=>{const Ce=Array.isArray(j==null?void 0:j.messages)?j.messages:[],Me=ue??(j==null?void 0:j.threadId)??N.current;if(Y==="replace"){if(Me){const he={threadId:Me,messages:Ce.slice(),hasMore:!!(j!=null&&j.hasMore),nextCursor:(j==null?void 0:j.nextCursor)??null,checkpointId:(j==null?void 0:j.checkpointId)??null,checkpointNs:(j==null?void 0:j.checkpointNs)??null};fe.current.set(Me,he),ye.current=Me}O(Ce,{checkpointId:(j==null?void 0:j.checkpointId)??null,checkpointNs:(j==null?void 0:j.checkpointNs)??null})}else if(Y==="prepend"&&Ce.length&&Me){const he=fe.current.get(Me),it=(he==null?void 0:he.messages)??[],jt=new Set,ft=[...Ce,...it].filter(vn=>{const hn=vn==null?void 0:vn.id;return hn?jt.has(hn)?!1:(jt.add(hn),!0):!0}),Ft={threadId:Me,messages:ft,hasMore:(j==null?void 0:j.hasMore)??(he==null?void 0:he.hasMore)??!1,nextCursor:(j==null?void 0:j.nextCursor)??(he==null?void 0:he.nextCursor)??null,checkpointId:(he==null?void 0:he.checkpointId)??(j==null?void 0:j.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??(j==null?void 0:j.checkpointNs)??null};fe.current.set(Me,Ft),W(Ce)}else Y==="prepend"&&Ce.length&&W(Ce);Y==="replace"?(A((j==null?void 0:j.nextCursor)??null),E(!!(j!=null&&j.hasMore)),_((j==null?void 0:j.checkpointId)??void 0),L((j==null?void 0:j.checkpointNs)??void 0)):(A(he=>(j==null?void 0:j.nextCursor)??he??null),E(he=>(j==null?void 0:j.hasMore)!==void 0?!!(j!=null&&j.hasMore):he),_(he=>(j==null?void 0:j.checkpointId)??he??void 0),L(he=>(j==null?void 0:j.checkpointNs)??he??void 0))},[W,O]),Z=S.useCallback(j=>{O(j.messages,{checkpointId:j.checkpointId,checkpointNs:j.checkpointNs}),A(j.nextCursor),E(j.hasMore),_(j.checkpointId??void 0),L(j.checkpointNs??void 0),ye.current=j.threadId},[O]),ce=S.useCallback(j=>{j&&(fe.current.delete(j),ye.current===j&&(ye.current=null))},[]),te=S.useCallback(()=>{const j=N.current;j&&ce(j),$([]),E(!1),T(!1),A(null),_(void 0),L(void 0)},[ce,$]),Fe=S.useCallback(({from:j,to:Y})=>{const ue=N.current;ue&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${j} -> ${Y}) for thread ${ue}`)},[]),Qe=S.useCallback(j=>{const Y=j.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:Y,title:j.title,created:j.created,currentThreads:f.length});const ue={threadId:Y,title:j.title||`Thread ${Y.slice(0,8)}`,createdAt:j.createdAt||new Date().toISOString(),updatedAt:j.updatedAt||new Date().toISOString(),messageCount:j.messageCount||0};N.current!==Y&&(!N.current&&F.messages.length<=1&&(le.current=Y),v(Y)),h(Ce=>{const Me=Ce.findIndex(he=>he.threadId===Y);if(Me>=0){const he=[...Ce];return he[Me]=ue,console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:",Me),he}else return console.log("[ChatSessionProvider] ➕ Added new thread to list"),[ue,...Ce]})},[F.messages.length]),{startStream:et,stop:je,isStreaming:Oe,error:tt,setAuthToken:He}=sg({baseUrl:d,onThreadInfo:Qe,onMessageEvent:G,onUnhandledEvent:j=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${j.type}`,j)},onSequenceGap:Fe});S.useEffect(()=>{M.current=Oe},[Oe]),S.useEffect(()=>{var ue;const j=l.getAuthToken();He(j);const Y=(ue=l.onTokenChange)==null?void 0:ue.call(l,Ce=>{He(Ce)});return()=>{Y==null||Y()}},[l,He]);const at=S.useCallback(async j=>{const Y=`temp-${Date.now()}`,ue={threadId:Y,title:j||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};h(Ce=>[ue,...Ce]),v(Y);try{const Ce=await l.createThread(j),Me=typeof Ce=="string"?Ce:Ce.threadId;return h(he=>he.map(it=>it.threadId===Y?{...it,threadId:Me}:it)),v(Me),setTimeout(()=>z(),10),Me}catch(Ce){throw h(Me=>Me.filter(he=>he.threadId!==Y)),v(null),Ce}},[l,z]),dt=S.useCallback(async j=>{await l.deleteThread(j),ce(j),N.current===j&&(le.current=j,v(null),N.current=null,ye.current=null,te()),await z()},[l,te,ce,z]),ne=S.useCallback(async(j,Y)=>{try{await l.updateThread(j,Y),h(ue=>ue.map(Ce=>Ce.threadId===j?{...Ce,title:Y}:Ce))}catch(ue){throw await z(),ue}},[l,z]),ee=S.useCallback(async(j,Y,ue,Ce=!1)=>{await we(async()=>{if(le.current===j&&!Ce){le.current=null;return}if(pe.current===j&&!Ce)return;v(ft=>ft===j?ft:j),N.current=j;const Me=!Ce&&!Y&&!ue;let he=!1;if(Me){const ft=fe.current.get(j);ft&&(Z(ft),he=!0)}const it=Ce||!he||!!Y||!!ue,jt=async ft=>{ft&&b(!0),pe.current=j;try{const Ft=await l.getMessages({threadId:j,checkpointId:Y,checkpointNs:ue});q(Ft,"replace",j)}catch(Ft){throw(!he||Ce||ft)&&(i==null||i(String(Ft))),Ft}finally{pe.current=null,ft&&b(!1)}};it?await jt(!0):Me&&he&&jt(!1).catch(ft=>{console.warn("[ChatSessionProvider] Background refresh failed:",ft)})},`loadThread-${j}`)},[l,Z,q,we,i]),xe=S.useCallback(async()=>{await we(async()=>{const j=N.current;j&&ce(j),le.current=null,v(null),N.current=null,ye.current=null,te(),_(void 0),L(void 0);try{localStorage.removeItem("lastThreadId")}catch(Y){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",Y)}},"clearCurrentThread")},[te,ce,we]),Ee=S.useCallback(async j=>{const Y=await l.listCheckpoints(j);return Vm(Y,j)},[l]),Se=S.useCallback(async(j,Y)=>{if(!N.current)throw new Error("No active thread");await ee(N.current,j,Y??void 0,!0)},[ee]),Re=S.useCallback(async()=>{if(!N.current)throw new Error("No active thread");await ee(N.current,void 0,void 0,!0)},[ee]),Je=S.useCallback(async j=>{if(!N.current)throw new Error("No active thread");if(C||!y)return;const Y=I;if(Y){T(!0);try{const ue=N.current,Ce=await l.getMessages({threadId:ue,checkpointId:P,checkpointNs:D,limit:(j==null?void 0:j.limit)??ag,beforeId:Y});q(Ce,"prepend",ue??void 0)}finally{T(!1)}}},[l,q,y,P,D,I,C]),Ke=S.useCallback(async(j,Y)=>{var xr;const ue=N.current;!ue&&!(Y!=null&&Y.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const Ce=(Y==null?void 0:Y.attachments)||[],{contentParts:Me,filesInfo:he}=await qm(l,Ce),it=[...Me];j&&j.trim()&&it.push({type:"text",text:j.trim()});const jt={id:((xr=crypto.randomUUID)==null?void 0:xr.call(crypto))||`user-${Date.now()}`,role:"user",content:it,createdAt:new Date().toISOString(),checkpointId:(Y==null?void 0:Y.checkpointId)??F.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??F.lastCheckpointNs??void 0};U(jt);const ft={...jt,content:it},Ft={...(Y==null?void 0:Y.payloadExtras)??{}},vn=Ce.length>0,hn={...ue?{threadId:ue}:{},payload:{messages:[ft],files_info:he,...o&&vn&&s?{active_agent:s}:{},...Ft},checkpointId:(Y==null?void 0:Y.checkpointId)??F.lastCheckpointId??void 0,checkpointNs:(Y==null?void 0:Y.checkpointNs)??F.lastCheckpointNs??void 0,nodeFilter:Y==null?void 0:Y.nodeFilter,config:Y==null?void 0:Y.config};et(hn,{onError:Q=>{console.warn("[ChatSessionProvider] Stream error:",Q)},onOpen:({threadId:Q,created:ve})=>{!N.current&&Q&&(F.messages.length<=1&&(le.current=Q),v(Q))},onGap:Fe})},[l,o,s,Fe,F.lastCheckpointId,F.lastCheckpointNs,F.messages.length,U,et]),lt=S.useCallback(async(j,Y,ue)=>{const Ce=N.current;if(!Ce)throw new Error("No active thread to handle interrupt");try{const Me=Y?ue??!0:!1;await l.resume({threadId:Ce,value:Me})}catch(Me){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${j}:`,Me),Me}},[l]);S.useEffect(()=>{if(a==null||a(p),p)try{localStorage.setItem("lastThreadId",p)}catch(j){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",j)}},[p,a]),S.useEffect(()=>{let j=!0;return(async()=>{try{if(await z(),!j)return;if(!r&&!t)try{const ue=localStorage.getItem("lastThreadId");ue&&(v(ue),n&&await ee(ue))}catch(ue){console.warn("[ChatSessionProvider] Failed to restore last thread:",ue)}else t&&n&&await ee(t)}catch(ue){console.error("[ChatSessionProvider] Initialization failed:",ue),i==null||i(String(ue))}})(),()=>{j=!1}},[]),S.useEffect(()=>{const j=N.current;if(!j||ye.current!==j)return;const Y={threadId:j,messages:F.messages.slice(),hasMore:y,nextCursor:I,checkpointId:F.lastCheckpointId??null,checkpointNs:F.lastCheckpointNs??null},ue=fe.current.get(j);(!ue||ue.messages.length!==Y.messages.length||ue.messages.some((Me,he)=>{var it;return(Me==null?void 0:Me.id)!==((it=Y.messages[he])==null?void 0:it.id)})||(ue==null?void 0:ue.hasMore)!==Y.hasMore||(ue==null?void 0:ue.nextCursor)!==Y.nextCursor||(ue==null?void 0:ue.checkpointId)!==Y.checkpointId||(ue==null?void 0:ue.checkpointNs)!==Y.checkpointNs)&&fe.current.set(j,Y)},[y,I,F.lastCheckpointId,F.lastCheckpointNs,F.messages]);const At=S.useMemo(()=>({threads:f,currentThreadId:p,isLoadingThreads:w,isLoadingThread:x,setCurrentThreadId:v,createThread:at,deleteThread:dt,renameThread:ne,refreshThreads:z,loadThread:ee,clearCurrentThread:xe,listCheckpoints:Ee,navigateToCheckpoint:Se,returnToLatest:Re}),[xe,at,p,dt,x,w,Ee,ee,Se,z,ne,Re,f]),On=S.useMemo(()=>({messages:F.messages,assemblingId:F.assemblingId,lastUserMessage:null,hasMoreHistory:y,isLoadingHistory:C,send:Ke,stop:je,loadOlderMessages:Je,clearMessages:te,handleInterrupt:lt}),[te,lt,y,C,Je,F.assemblingId,F.messages,Ke,je]),Jr=S.useMemo(()=>({isStreaming:Oe,error:tt,streamingAssistantId:F.assemblingId,lastCheckpointId:F.lastCheckpointId??null,lastCheckpointNs:F.lastCheckpointNs??null}),[Oe,F.assemblingId,F.lastCheckpointId,F.lastCheckpointNs,tt]);return c.jsx(ig.Provider,{value:!0,children:c.jsx(Ol.Provider,{value:Jr,children:c.jsx(Rl.Provider,{value:At,children:c.jsx(Pl.Provider,{value:On,children:e})})})})}function ho(){const e=S.useContext(Rl);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Js(){const e=S.useContext(Pl);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Ml(){const e=S.useContext(Ol);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function po({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Wm,{apiConfig:t,children:c.jsx(lg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function J(...e){return wp.twMerge(vp.clsx(e))}const cg=Qr.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"}}),We=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Mn.Slot:"button";return c.jsx(i,{className:J(cg({variant:t,size:n,className:e})),ref:s,...o})});We.displayName="Button";const Dl=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:J("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}));Dl.displayName="Textarea";function ug({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=S.useState(e),[v,w]=S.useTransition(),g=S.useRef(null);S.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=S.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);S.useEffect(()=>{x()},[x]);const b=S.useCallback(async A=>{A&&A.preventDefault();const P=(h??"").trim();!P&&!f||w(()=>{try{const _=i(P);_&&typeof _.then=="function"?_.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=S.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=S.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Dl,{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"})}),c.jsx("div",{children:r?c.jsx(We,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(re.Square,{size:16})}):c.jsx(We,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||v,children:c.jsx(re.Send,{size:16})})})]})})}const dg=S.memo(ug),mo=0,Sn=1,rr=2,Ll=4;function Fl(e){return()=>e}function fg(e){e()}function $l(e,t){return n=>e(t(n))}function zl(e,t){return()=>e(t)}function hg(e,t){return n=>e(t,n)}function Zs(e){return e!==void 0}function pg(...e){return()=>{e.map(fg)}}function or(){}function go(e,t){return t(e),e}function mg(e,t){return t(e)}function nt(...e){return e}function qe(e,t){return e(Sn,t)}function Pe(e,t){e(mo,t)}function Qs(e){e(rr)}function ut(e){return e(Ll)}function de(e,t){return qe(e,hg(t,mo))}function Gt(e,t){const n=e(Sn,r=>{n(),t(r)});return n}function Bl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Hl(e,t){return e===t}function rt(e=Hl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function se(e){return t=>$l(t,e)}function tn(e){return t=>()=>{t(e)}}function B(e,...t){const n=gg(...t);return(r,o)=>{switch(r){case rr:Qs(e);return;case Sn:return qe(e,n(o))}}}function nn(e,t){return n=>r=>{n(t=e(t,r))}}function $n(e){return t=>n=>{e>0?e--:t(n)}}function mn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function gg(...e){return t=>e.reduceRight(mg,t)}function xg(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=qe(e,s),t):(r(),or);case rr:r(),n=null;return}}}function K(e){let t=e;const n=Be();return(r,o)=>{switch(r){case mo:t=o;break;case Sn:{o(t);break}case Ll:return t}return n(r,o)}}function bt(e,t){return go(K(t),n=>de(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case mo:e.slice().forEach(r=>{r(n)});return;case rr:e.splice(0,e.length);return;case Sn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Pt(e){return go(Be(),t=>de(e,t))}function Ve(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:vg(),singleton:n}}const vg=()=>Symbol();function wg(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function pt(...e){const t=Be(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);qe(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case rr:{Qs(t);return}case Sn:return r===o&&i(n),qe(t,i)}}}function be(e,t=Hl){return B(e,rt(t))}function ei(...e){return function(t,n){switch(t){case rr:return;case Sn:return pg(...e.map(r=>qe(r,n)))}}}var Nt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Nt||{});const bg={0:"debug",3:"error",1:"log",2:"warn"},yg=()=>typeof globalThis>"u"?window:globalThis,Cn=Ve(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=yg().VIRTUOSO_LOG_LEVEL)!=null?o:ut(e);r>=s&&console[bg[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 ti(e,t,n).callbackRef}function ti(e,t,n){const r=S.useRef(null);let o=i=>{};const s=S.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Sg(e,t,n,r,o,s,i,a,l){const u=S.useCallback(d=>{const f=Cg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let v;p&&(v=h.ownerDocument.defaultView);const w=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(w,0),viewportHeight:x}),s==null||s(a?Ul("column-gap",getComputedStyle(d).columnGap,o):Ul("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ti(u,n,l)}function Cg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Nt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Ul(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Wl(e,t,n){const r=S.useRef(null),o=S.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),v=u.top-p.top;h=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ti(o,!0,n),a=S.useCallback(()=>{o(i.current)},[o,i]);return S.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Ct=Ve(()=>{const e=Be(),t=Be(),n=K(0),r=Be(),o=K(0),s=Be(),i=Be(),a=K(0),l=K(0),u=K(0),d=K(0),f=Be(),h=Be(),p=K(!1),v=K(!1),w=K(!1);return de(B(e,se(({scrollTop:g})=>g)),t),de(B(e,se(({scrollHeight:g})=>g)),i),de(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Er={lvl:0};function Vl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function Ye(e){return e===Er}function Ir(e,t){if(!Ye(e))return t===e.k?e.v:t<e.k?Ir(e.l,t):Ir(e.r,t)}function Yt(e,t,n="k"){if(Ye(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Yt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Yt(e.l,t,n)}function Ot(e,t,n){return Ye(e)?Gl(t,n,1):t===e.k?gt(e,{k:t,v:n}):t<e.k?Yl(gt(e,{l:Ot(e.l,t,n)})):Yl(gt(e,{r:Ot(e.r,t,n)}))}function sr(){return Er}function xo(e,t,n){if(Ye(e))return[];const r=Yt(e,t)[0];return Tg(ri(e,r,n))}function ni(e,t){if(Ye(e))return Er;const{k:n,l:r,r:o}=e;if(t===n){if(Ye(r))return o;if(Ye(o))return r;{const[s,i]=ql(r);return vo(gt(e,{k:s,l:Kl(r),v:i}))}}else return t<n?vo(gt(e,{l:ni(r,t)})):vo(gt(e,{r:ni(o,t)}))}function Bn(e){return Ye(e)?[]:[...Bn(e.l),{k:e.k,v:e.v},...Bn(e.r)]}function ri(e,t,n){if(Ye(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ri(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ri(s,t,n))),a}function vo(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(oi(t))return Xl(gt(e,{lvl:n-1}));if(!Ye(t)&&!Ye(t.r))return gt(t.r,{l:gt(t,{r:t.r.l}),lvl:n,r:gt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(oi(e))return si(gt(e,{lvl:n-1}));if(!Ye(r)&&!Ye(r.l)){const o=r.l,s=oi(o)?r.lvl-1:r.lvl;return gt(o,{l:gt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:si(gt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function gt(e,t){return Gl(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 Kl(e){return Ye(e.r)?e.l:vo(gt(e,{r:Kl(e.r)}))}function oi(e){return Ye(e)||e.lvl>e.r.lvl}function ql(e){return Ye(e.r)?[e.k,e.v]:ql(e.r)}function Gl(e,t,n,r=Er,o=Er){return{k:e,l:r,lvl:n,r:o,v:t}}function Yl(e){return si(Xl(e))}function Xl(e){const{l:t}=e;return!Ye(t)&&t.lvl===e.lvl?gt(t,{r:gt(e,{l:t.r})}):e}function si(e){const{lvl:t,r:n}=e;return!Ye(n)&&!Ye(n.r)&&n.lvl===t&&n.r.lvl===t?gt(n,{l:gt(e,{r:n.l}),lvl:t+1}):e}function Tg(e){return Vl(e,({k:t,v:n})=>({index:t,value:n}))}function Jl(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ii=Ve(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function Zl(e,t,n){return e[wo(e,t,n)]}function wo(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 kg(e,t,n,r){const o=wo(e,t,r),s=wo(e,n,r,o);return e.slice(o,s+1)}function Tn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bo(e){return!Ye(e.groupOffsetTree)}function ai({index:e},t){return t===e?0:t<e?-1:1}function Eg(){return{groupIndices:[],groupOffsetTree:sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:sr()}}function Ig(e,t){let n=Ye(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ye(e)){e=Ot(e,0,s);continue}const a=xo(e,i-1,o+1);if(a.some(Og(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ni(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Ot(e,o+1,h));u&&(e=Ot(e,i,s))}return[e,n]}function Ng(e){return typeof e.groupIndex<"u"}function Ag({offset:e},t){return t===e?0:t<e?-1:1}function Ar(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Zl(t,e,ai),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Ql(e,t){if(!bo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ec(e,t,n){if(Ng(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Ql(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function jg(e,t,n,r=0){return r>0&&(t=Math.max(t,Zl(e,r,ai).offset)),Vl(kg(e,t,n,Ag),Pg)}function _g(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Nt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ye(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,w)=>Ot(Ot(v,w,h),w+1,p),i)}else[i,a]=Ig(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=li(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Ot(h,p,Ar(p,f,o)),sr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Rg(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 tc(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 li(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=wo(o,t-1,ai),a=o[l].offset;const u=Yt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Yt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of xo(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 Pg(e){return{index:e.index,value:e}}function Og(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 Mg={offsetHeight:"height",offsetWidth:"width"},rn=Ve(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=bt(r,0),s=Be(),i=Be(),a=K(0),l=K([]),u=K(void 0),d=K(void 0),f=K((C,T)=>Tn(C,Mg[T])),h=K(void 0),p=K(0),v=Eg(),w=bt(B(n,De(l,e,p),nn(_g,v),rt()),v),g=bt(B(l,rt(),nn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),se(({prev:C})=>C)),[]);de(B(l,Te(C=>C.length>0),De(w,p),se(([C,T,I])=>{const A=C.reduce((P,_,D)=>Ot(P,_,Ar(_,T.offsetTree,I)||D),sr());return{...T,groupIndices:C,groupOffsetTree:A}})),w),de(B(r,De(w),Te(([C,{lastIndex:T}])=>C<T),se(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),de(u,d);const x=bt(B(u,se(C=>C===void 0)),!0);de(B(d,Te(C=>C!==void 0&&Ye(ut(w).sizeTree)),se(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Pt(B(n,De(w),nn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),se(C=>C.changed)));qe(B(a,nn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),se(C=>C.diff)),C=>{const{groupIndices:T}=ut(w);if(C>0)Pe(t,!0),Pe(s,C+tc(C,T));else if(C<0){const I=ut(g);I.length>0&&(C-=tc(-C,I)),Pe(i,C)}}),qe(B(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Nt.ERROR)});const y=Pt(s);de(B(s,De(w),se(([C,T])=>{const I=T.groupIndices.length>0,A=[],P=T.lastSize;if(I){const _=Ir(T.sizeTree,0);let D=0,L=0;for(;D<C;){const O=T.groupIndices[L],W=T.groupIndices.length===L+1?1/0:T.groupIndices[L+1]-O-1;A.push({endIndex:O,size:_,startIndex:O}),A.push({endIndex:O+1+W-1,size:P,startIndex:O+1}),L++,D+=W+1}const F=Bn(T.sizeTree);return D!==C&&F.shift(),F.reduce((O,{k:W,v:U})=>{let G=O.ranges;return O.prevSize!==0&&(G=[...O.ranges,{endIndex:W+C-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:W+C,prevSize:U,ranges:G}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Bn(T.sizeTree).reduce((_,{k:D,v:L})=>({prevIndex:D+C,prevSize:L,ranges:[..._.ranges,{endIndex:D+C-1,size:_.prevSize,startIndex:_.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const E=Pt(B(i,De(w,p),se(([C,{offsetTree:T},I])=>{const A=-C;return Ar(A,T,I)})));return de(B(i,De(w,p),se(([C,T,I])=>{if(T.groupIndices.length>0){if(Ye(T.sizeTree))return T;let A=sr();const P=ut(g);let _=0,D=0,L=0;for(;_<-C;){L=P[D];const F=P[D+1]-L-1;D++,_+=F+1}if(A=Bn(T.sizeTree).reduce((F,{k:O,v:W})=>Ot(F,Math.max(0,O+C),W),A),_!==-C){const F=Ir(T.sizeTree,L);A=Ot(A,0,F);const O=Yt(T.sizeTree,-C+1)[1];A=Ot(A,1,O)}return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}else{const A=Bn(T.sizeTree).reduce((P,{k:_,v:D})=>Ot(P,Math.max(0,_+C),D),sr());return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}})),w),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},nt(Cn,ii),{singleton:!0});function Dg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const nc=Ve(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Pt(B(s,se(Dg)));return de(B(a,se(l=>l.totalCount)),n),de(B(a,se(l=>l.groupIndices)),e),de(B(pt(o,t,r),Te(([l,u])=>bo(u)),se(([l,u,d])=>Yt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),rt(),se(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},nt(rn,Ct)),kn=Ve(([{log:e}])=>{const t=K(!1),n=Pt(B(t,Te(r=>r),rt()));return qe(t,r=>{r&&ut(e)("props updated",{},Nt.DEBUG)}),{didMount:n,propsReady:t}},nt(Cn),{singleton:!0}),Lg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function rc(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Lg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const jr=Ve(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=Be(),v=Be(),w=K(0);let g=null,x=null,b=null;function y(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Pe(l,!1)}return de(B(p,De(n,f,r,w,a,i,h),De(e,s,o),se(([[E,C,T,I,A,P,_,D],L,F,O])=>{const W=rc(E),{align:U,behavior:G,offset:$}=W,N=I-1,V=ec(W,C,N);let X=Ar(V,C.offsetTree,L)+P;U==="end"?(X+=F+Yt(C.sizeTree,V)[1]-T+O,V===N&&(X+=_)):U==="center"?X+=(F+Yt(C.sizeTree,V)[1]-T+O)/2:X-=A,$&&(X+=$);const pe=le=>{y(),le?(D("retrying to scroll to",{location:E},Nt.DEBUG),Pe(p,E)):(Pe(v,!0),D("list did not change, scroll successful",{},Nt.DEBUG))};if(y(),G==="smooth"){let le=!1;b=qe(t,fe=>{le=le||fe}),g=Gt(d,()=>{pe(le)})}else g=Gt(B(t,Fg(150)),pe);return x=setTimeout(()=>{y()},1200),Pe(l,!0),D("scrolling from index to",{behavior:G,index:V,top:X},Nt.DEBUG),{behavior:G,top:X}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:w}},nt(rn,Ct,Cn),{singleton:!0});function Fg(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ci(e,t){e==0?t():requestAnimationFrame(()=>{ci(e-1,t)})}function ui(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const _r=Ve(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),l=K(0),u=K(!0);return de(B(i,De(l),Te(([d,f])=>!!f),tn(!1)),a),de(B(i,De(l),Te(([d,f])=>!!f),tn(!1)),u),qe(B(pt(t,i),De(a,n,e,u),Te(([[,d],f,{sizeTree:h},p,v])=>d&&(!Ye(h)||Zs(p))&&!f&&!v),De(l)),([,d])=>{Gt(o,()=>{Pe(u,!0)}),ci(4,()=>{Gt(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},nt(rn,Ct,jr,kn),{singleton:!0});function oc(e,t){return Math.abs(e-t)<1.01}const Rr="up",Pr="down",$g="none",zg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Bg=0,Or=Ve(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),l=Be(),u=Be(),d=K(4),f=K(Bg),h=bt(B(ei(B(be(o),$n(1),tn(!0)),B(be(o),$n(1),tn(!1),Bl(100))),rt()),!1),p=bt(B(ei(B(n,tn(!0)),B(n,tn(!1),Bl(200))),rt()),!1);de(B(pt(be(o),be(f)),se(([b,y])=>b<=y),rt()),a),de(B(a,mn(50)),u);const v=Pt(B(pt(r,be(s),be(t),be(e),be(d)),nn((b,[{scrollHeight:y,scrollTop:E},C,T,I,A])=>{const P=E+C-y>-A,_={scrollHeight:y,scrollTop:E,viewportHeight:C};if(P){let L,F;return E>b.state.scrollTop?(L="SCROLLED_DOWN",F=b.state.scrollTop-E):(L="SIZE_DECREASED",F=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:L,scrollTopDelta:F,state:_}}let D;return _.scrollHeight>b.state.scrollHeight?D="SIZE_INCREASED":C<b.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:_}},zg),rt((b,y)=>b&&b.atBottom===y.atBottom))),w=bt(B(r,nn((b,{scrollHeight:y,scrollTop:E,viewportHeight:C})=>{if(oc(b.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Te(b=>b.changed),se(b=>b.jump)),0);de(B(v,se(b=>b.atBottom)),i),de(B(i,mn(50)),l);const g=K(Pr);de(B(r,se(({scrollTop:b})=>b),rt(),nn((b,y)=>ut(p)?{direction:b.direction,prevScrollTop:y}:{direction:y<b.prevScrollTop?Rr:Pr,prevScrollTop:y},{direction:Pr,prevScrollTop:0}),se(b=>b.direction)),g),de(B(r,mn(50),tn($g)),g);const x=K(0);return de(B(h,Te(b=>!b),tn(0)),x),de(B(o,mn(100),De(h),Te(([b,y])=>!!y),nn(([b,y],[E])=>[y,E],[0,0]),se(([b,y])=>y-b)),x),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:x}},nt(Ct)),yo="top",So="bottom",sc="none";function ic(e,t,n){return typeof e=="number"?n===Rr&&t===yo||n===Pr&&t===So?e:0:n===Rr?t===yo?e.main:e.reverse:t===So?e.main:e.reverse}function ac(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const di=Ve(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=K(0),a=K(0),l=K(0),u=bt(B(pt(be(r),be(o),be(n),be(s,Nr),be(l),be(i),be(t),be(e),be(a)),se(([d,f,h,[p,v],w,g,x,b,y])=>{const E=d-b,C=g+x,T=Math.max(h-E,0);let I=sc;const A=ac(y,yo),P=ac(y,So);return p-=b,p+=h+x,v+=h+x,v-=b,p>d+C-A&&(I=Rr),v<d-T+f+P&&(I=Pr),I!==sc?[Math.max(E-h-ic(w,yo,I)-A,0),E-T-x+f+ic(w,So,I)+P]:null}),Te(d=>d!=null),rt(Nr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},nt(Ct),{singleton:!0});function Hg(e,t,n){if(bo(t)){const r=Ql(e,t);return[{index:Yt(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 fi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const w=e[e.length-1];d=w.offset+w.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:cc(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:cc(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function lc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=ui(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Co(u,[],a,o,n,r)}function cc(e,t,n){if(e.length===0)return[];if(!bo(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=xo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Hn=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const w=K([]),g=K(0),x=Be();de(s.topItemsIndexes,w);const b=bt(B(pt(p,v,be(l,Nr),be(o),be(r),be(u),d,be(w),be(t),be(n),e),Te(([T,I,,A,,,,,,,P])=>{const _=P&&P.length!==A;return T&&!I&&!_}),se(([,,[T,I],A,P,_,D,L,F,O,W])=>{const U=P,{offsetTree:G,sizeTree:$}=U,N=ut(g);if(A===0)return{...fi,totalCount:A};if(T===0&&I===0)return N===0?{...fi,totalCount:A}:lc(N,_,P,F,O,W||[]);if(Ye($))return N>0?null:Co(Hg(ui(_,A),U,W),[],A,O,U,F);const V=[];if(L.length>0){const ye=L[0],we=L[L.length-1];let z=0;for(const M of xo($,ye,we)){const q=M.value,Z=Math.max(M.start,ye),ce=Math.min(M.end,we);for(let te=Z;te<=ce;te++)V.push({data:W==null?void 0:W[te],index:te,offset:z,size:q}),z+=q}}if(!D)return Co([],V,A,O,U,F);const X=L.length>0?L[L.length-1]+1:0,pe=jg(G,T,I,X);if(pe.length===0)return null;const le=A-1,fe=go([],ye=>{for(const we of pe){const z=we.value;let M=z.offset,q=we.start;const Z=z.size;if(z.offset<T){q+=Math.floor((T-z.offset+O)/(Z+O));const te=q-we.start;M+=te*Z+te*O}q<X&&(M+=(X-q)*Z,q=X);const ce=Math.min(we.end,le);for(let te=q;te<=ce&&!(M>=I);te++)ye.push({data:W==null?void 0:W[te],index:te,offset:M,size:Z}),M+=Z+O}});return Co(fe,V,A,O,U,F)}),Te(T=>T!==null),rt()),fi);de(B(e,Te(Zs),se(T=>T==null?void 0:T.length)),o),de(B(b,se(T=>T.topListHeight)),f),de(f,a),de(B(b,se(T=>[T.top,T.bottom])),i),de(B(b,se(T=>T.items)),x);const y=Pt(B(b,Te(({items:T})=>T.length>0),De(o,e),Te(([{items:T},I])=>T[T.length-1].originalIndex===I-1),se(([,T,I])=>[T-1,I]),rt(Nr),se(([T])=>T))),E=Pt(B(b,mn(200),Te(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),se(({items:T})=>T[0].index),rt())),C=Pt(B(b,Te(({items:T})=>T.length>0),se(({items:T})=>{let I=0,A=T.length-1;for(;T[I].type==="group"&&I<A;)I++;for(;T[A].type==="group"&&A>I;)A--;return{endIndex:T[A].index,startIndex:T[I].index}}),rt(Jl)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:w,...h}},nt(rn,nc,di,_r,jr,Or,kn,ii),{singleton:!0}),uc=Ve(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=bt(B(pt(n,e,r,t,o),se(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return de(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},nt(Ct,Hn),{singleton:!0}),Ug=Ve(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=bt(B(pt(n,e,t),Te(([o])=>o),se(([,o,s])=>Math.max(0,o-s)),mn(0),rt()),0);return{alignToBottom:n,paddingTopAddition:r}},nt(Ct,uc),{singleton:!0}),dc=Ve(()=>({context:K(null)})),Wg=({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,fc=Ve(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=Be();return de(B(d,De(t,l,n,s,o,r,a),De(e),se(([[f,h,p,v,w,g,x,b],y])=>{const{align:E,behavior:C,calculateViewLocation:T=Wg,done:I,...A}=f,P=ec(f,h,v-1),_=Ar(P,h.offsetTree,y)+w+g,D=_+Yt(h.sizeTree,P)[1],L=b+g,F=b+p-x,O=T({itemBottom:D,itemTop:_,locationParams:{align:E,behavior:C,...A},viewportBottom:F,viewportTop:L});return O?I&&Gt(B(i,Te(W=>!W),$n(ut(i)?1:2)),I):I&&I(),O}),Te(f=>f!==null)),u),{scrollIntoView:d}},nt(rn,Ct,jr,Hn,Cn),{singleton:!0});function hc(e){return e?e==="smooth"?"smooth":"auto":!1}const Vg=(e,t)=>typeof e=="function"?hc(e(t)):t&&hc(e),Kg=Ve(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=K(!1),w=Be();let g=null;function x(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}qe(B(pt(B(be(t),$n(1)),l),De(be(v),s,a,f),se(([[C,T],I,A,P,_])=>{let D=T&&P,L="auto";return D&&(L=Vg(I,A||_),D=D&&!!L),{followOutputBehavior:L,shouldFollow:D,totalCount:C}}),Te(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("following output to ",{totalCount:T},Nt.DEBUG),x(C)}):g=Gt(e,()=>{ut(d)("following output to ",{totalCount:T},Nt.DEBUG),x(C),g=null})});function b(C){const T=Gt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(ut(d)("scrolling to bottom due to increased size",{},Nt.DEBUG),x("auto"))});setTimeout(T,100)}qe(B(pt(be(v),t,u),Te(([C,,T])=>C&&T),nn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:C})=>C),De(v,t)),([,C])=>{ut(a)&&b(C!==!1)}),qe(w,()=>{b(ut(v)!==!1)}),qe(pt(be(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),E=Be();return de(ei(B(be(r),se(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),B(be(t))),E),qe(B(pt(B(E,$n(1)),l),De(be(y),a,f,h),se(([[C,T],I,A,P,_])=>T&&A&&(I==null?void 0:I({context:_,totalCount:C,scrollingInProgress:P}))),Te(C=>!!C),mn(0)),C=>{g&&(g(),g=null),ut(n)?requestAnimationFrame(()=>{ut(d)("scrolling into view",{}),Pe(p,C)}):g=Gt(e,()=>{ut(d)("scrolling into view",{}),Pe(p,C),g=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:y}},nt(rn,Or,jr,_r,kn,Cn,Ct,dc,fc)),qg=Ve(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(de(B(a,De(s),Te(([,l])=>l!==0),De(o,r,t,n,e),se(([[,l],u,d,f,h,p=[]])=>lc(l,u,d,f,h,p))),i),{}),nt(rn,_r,Hn,kn),{singleton:!0}),Gg=Ve(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return qe(B(e,De(r),Te(([,o])=>o!==0),se(([,o])=>({top:o}))),o=>{Gt(B(n,$n(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},nt(kn,Ct,Hn),{singleton:!0}),pc=Ve(([{scrollVelocity:e}])=>{const t=K(!1),n=Be(),r=K(!1);return de(B(e,De(r,t,n),Te(([o,s])=>!!s),se(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),rt()),t),qe(B(pt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},nt(Or),{singleton:!0}),hi=Ve(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=K(!1),i=K(void 0);return de(B(pt(n,r),se(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),de(B(t,De(r),se(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},nt(Ct)),Yg=Ve(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=Be(),d=K(void 0),f=K(null),h=K(null);return de(a,f),de(l,h),qe(B(u,De(t,r,i,f,h,n)),([p,v,w,g,x,b,y])=>{const E=Rg(v.sizeTree);g&&x!==null&&b!==null&&(w=x.scrollTop-b.offsetTop),w-=y,p({ranges:E,scrollTop:w})}),de(B(d,Te(Zs),se(Xg)),o),de(B(s,De(d),Te(([,p])=>p!==void 0),rt(),se(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},nt(rn,Ct,_r,kn,hi));function Xg(e){return{align:"start",index:0,offset:e.scrollTop}}const Jg=Ve(([{topItemsIndexes:e}])=>{const t=K(0);return de(B(t,Te(n=>n>=0),se(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},nt(Hn));function mc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Zg=mc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Qg=Ve(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const w=Pt(B(l,De(i),nn(([,x,b,y],[{bottom:E,items:C,offsetBottom:T,totalCount:I},A])=>{const P=E+T;let _=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(_=P-y,_!==0&&(_+=A))),[_,C,I,P]},[0,[],0,0]),Te(([x])=>x!==0),De(r,a,n,o,p,v),Te(([,x,b,y,,,E])=>!E&&!y&&x!==0&&b===Rr),se(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Nt.DEBUG),x))));function g(x){x>0?(Pe(t,{behavior:"auto",top:-x}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-x}))}return qe(B(w,De(e,s)),([x,b,y])=>{y&&Zg()?Pe(e,b-x):g(-x)}),qe(B(pt(bt(s,!1),e,v),Te(([x,b,y])=>!x&&!y&&b!==0),se(([x,b])=>b),mn(1)),g),de(B(f,se(x=>({top:-x}))),t),qe(B(u,De(h,d),se(([x,{groupIndices:b,lastSize:y,sizeTree:E},C])=>{function T(I){return I*(y+C)}if(b.length===0)return T(x);{let I=0;const A=Ir(E,0);let P=0,_=0;for(;P<x;){P++,I+=A;let D=b.length===_+1?1/0:b[_+1]-b[_]-1;P+D>x&&(I-=A,D=x-P+1),P+=D,I+=T(D),_++}return I}})),x=>{Pe(e,x),requestAnimationFrame(()=>{Pe(t,{top:x}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},nt(Ct,Or,Hn,rn,Cn,ii)),ex=Ve(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),nt(di,qg,kn,pc,uc,Gg,Ug,hi,fc,Cn,dc)),gc=Ve(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},w,g,x,{listState:b,topItemsIndexes:y,...E},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},P])=>(de(E.rangeChanged,P.scrollSeekRangeChanged),de(B(P.windowViewportRect,se(_=>_.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...P,...w,sizes:l,...g}),nt(rn,_r,Ct,Yg,Kg,Hn,jr,Qg,Jg,nc,ex));function tx(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 To=typeof document<"u"?S.useLayoutEffect:S.useEffect;function xc(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 l(g,x){g.propsReady&&Pe(g.propsReady,!1);for(const b of r){const y=g[t.required[b]];Pe(y,x[b])}for(const b of o)if(b in x){const y=g[t.optional[b]];Pe(y,x[b])}g.propsReady&&Pe(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=y=>{const E=g[t.methods[b]];Pe(E,y)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=xg(g[t.events[b]]),x),{})}const f=S.forwardRef((g,x)=>{const{children:b,...y}=g,[E]=S.useState(()=>go(wg(e),I=>{l(I,y)})),[C]=S.useState(zl(d,E));To(()=>{for(const I of i)I in y&&qe(C[I],y[I]);return()=>{Object.values(C).map(Qs)}},[y,C,E]),To(()=>{l(E,y)}),S.useImperativeHandle(x,Fl(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...tx([...r,...o,...i],y),children:b}):b})}),h=g=>{const x=S.useContext(a);return S.useCallback(b=>{Pe(x[g],b)},[x,g])},p=g=>{const x=S.useContext(a)[g],b=S.useCallback(y=>qe(x,y),[x]);return S.useSyncExternalStore(b,()=>ut(x),()=>ut(x))},v=g=>{const x=S.useContext(a)[g],[b,y]=S.useState(zl(ut,x));return To(()=>qe(x,E=>{E!==b&&y(Fl(E))}),[x,b]),b},w=S.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,x)=>{const b=S.useContext(a)[g];To(()=>qe(b,x),[x,b])},useEmitterValue:w,usePublisher:h}}const vc=S.createContext(void 0),wc=S.createContext(void 0),bc=typeof document<"u"?S.useLayoutEffect:S.useEffect;function pi(e){return"self"in e}function nx(e){return"body"in e}function yc(e,t,n,r=or,o,s){const i=S.useRef(null),a=S.useRef(null),l=S.useRef(null),u=S.useCallback(h=>{let p,v,w;const g=h.target;if(nx(g)||pi(g)){const b=pi(g)?g:g.defaultView;w=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else w=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(w,0),viewportHeight:v})};h.suppressFlushSync?x():_s.flushSync(x),a.current!==null&&(w===a.current||w<=0||w===p-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let w,g,x;pi(p)?(g=Math.max(Tn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),w=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],w=Tn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-w;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),oc(w,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:w}),v&&t(!0);return}v?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const mi="-webkit-sticky",Sc="sticky",gi=mc(()=>{if(typeof document>"u")return Sc;const e=document.createElement("div");return e.style.position=mi,e.style.position===mi?mi:Sc});function xi(e){return e}const rx=Ve(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(xi),o=K("div"),s=K(or),i=(a,l=null)=>bt(B(n,se(u=>u[a]),rt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),ox=Ve(([e,t])=>({...e,...t}),nt(gc,rx)),sx=({height:e})=>c.jsx("div",{style:{height:e}}),ix={overflowAnchor:"none",position:gi(),zIndex:1},Cc={overflowAnchor:"none"},ax={...Cc,display:"inline-block",height:"100%"},Tc=S.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=Bt("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=Bt("windowScrollContainerState"),i=Bt("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),p=Ae("log"),v=Bt("gap"),w=Ae("horizontalDirection"),{callbackRef:g}=Sg(n,h,f,e?or:a,p,v,o,w,Ae("skipAnimationFrameInResizeObserver")),[x,b]=S.useState(0);vi("deviation",O=>{x!==O&&b(O)});const y=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||sx,C=Ae("ListComponent"),T=Ae("ItemComponent"),I=Ae("GroupComponent"),A=Ae("computeItemKey"),P=Ae("isSeeking"),_=Ae("groupIndices").length>0,D=Ae("alignToBottom"),L=Ae("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:x!==0?x:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...L?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?c.jsx(y,{...yt(y,u)}):c.jsx(C,{...yt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:F,children:(e?t.topItems:t.items).map(O=>{const W=O.originalIndex,U=A(W+t.firstItemIndex,O.data,u);return P?S.createElement(E,{...yt(E,u),height:O.size,index:O.index,key:U,type:O.type||"item",...O.type==="group"?{}:{groupIndex:O.groupIndex}}):O.type==="group"?S.createElement(I,{...yt(I,u),"data-index":W,"data-item-index":O.index,"data-known-size":O.size,key:U,style:ix},d(O.index,u)):S.createElement(T,{...yt(T,u),...dx(T,O.data),"data-index":W,"data-item-group-index":O.groupIndex,"data-item-index":O.index,"data-known-size":O.size,key:U,style:w?ax:Cc},_?l(O.index,O.groupIndex,O.data,u):l(O.index,O.data,u))})})}),lx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},cx={outline:"none",overflowX:"auto",position:"relative"},ko=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),ux={position:gi(),top:0,width:"100%",zIndex:1};function yt(e,t){if(typeof e!="string")return{context:t}}function dx(e,t){return{item:typeof e=="string"?void 0:t}}const fx=S.memo(function(){const e=Ae("HeaderComponent"),t=Bt("headerHeight"),n=Ae("HeaderFooterTag"),r=zn(S.useMemo(()=>s=>{t(Tn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...yt(e,o)})}):null}),hx=S.memo(function(){const e=Ae("FooterComponent"),t=Bt("footerHeight"),n=Ae("HeaderFooterTag"),r=zn(S.useMemo(()=>s=>{t(Tn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...yt(e,o)})}):null});function kc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=yc(a,u,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?cx:lx,...o},tabIndex:0,...i,...yt(l,s),children:r})})}function Ec({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=S.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:x}=yc(a,u,l,v,h);return bc(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",w),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...yt(l,s),children:r})})}const px=({children:e})=>{const t=S.useContext(vc),n=Bt("viewportHeight"),r=Bt("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=S.useMemo(()=>$l(n,l=>Tn(l,s?"width":"height")),[n,s]),a=zn(i,!0,Ae("skipAnimationFrameInResizeObserver"));return S.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:ko(o),children:e})},mx=({children:e})=>{const t=S.useContext(vc),n=Bt("windowViewportRect"),r=Bt("fixedItemHeight"),o=Ae("customScrollParent"),s=Wl(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return S.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:ko(i),children:e})},gx=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...ux,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...yt(t,o),children:e})},xx=S.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?bx:wx,{...e,context:o,children:[n&&c.jsx(gx,{children:c.jsx(Tc,{showTopList:!0})}),c.jsxs(r||t?mx:px,{children:[c.jsx(fx,{}),c.jsx(Tc,{}),c.jsx(hx,{})]})]})}),{Component:vx,useEmitter:vi,useEmitterValue:Ae,usePublisher:Bt}=xc(ox,{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"}},xx),wx=kc({useEmitter:vi,useEmitterValue:Ae,usePublisher:Bt}),bx=Ec({useEmitter:vi,useEmitterValue:Ae,usePublisher:Bt}),yx=vx;nt(gc,Ve(()=>{const e=K(u=>c.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(xi),a=K(or),l=(u,d=null)=>bt(B(s,se(f=>f[u]),rt()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),gi();const Ic={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Sx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Nc,floor:Eo,max:Mr,min:wi,round:Ac}=Math;function jc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Cx(e){return{...Sx,items:e}}function Io(e,t){return e&&e.width===t.width&&e.height===t.height}function Tx(e,t){return e&&e.column===t.column&&e.row===t.row}const kx=Ve(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:w},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:E},C])=>{const T=K(0),I=K(0),A=K(Ic),P=K({height:0,width:0}),_=K({height:0,width:0}),D=Be(),L=Be(),F=K(0),O=K(null),W=K({column:0,row:0}),U=Be(),G=Be(),$=K(!1),N=K(0),V=K(!0),X=K(!1),pe=K(!1);qe(B(v,De(N),Te(([M,q])=>!!q)),()=>{Pe(V,!1)}),qe(B(pt(v,V,_,P,N,X),Te(([M,q,Z,ce,,te])=>M&&!q&&Z.height!==0&&ce.height!==0&&!te)),([,,,,M])=>{Pe(X,!0),ci(1,()=>{Pe(D,M)}),Gt(B(u),()=>{Pe(t,[0,0]),Pe(V,!0)})}),de(B(G,Te(M=>M!=null&&M.scrollTop>0),tn(0)),I),qe(B(v,De(G),Te(([,M])=>M!=null)),([,M])=>{M&&(Pe(P,M.viewport),Pe(_,M.item),Pe(W,M.gap),M.scrollTop>0&&(Pe($,!0),Gt(B(u,$n(1)),q=>{Pe($,!1)}),Pe(l,{top:M.scrollTop})))}),de(B(P,se(({height:M})=>M)),f),de(B(pt(be(P,Io),be(_,Io),be(W,(M,q)=>M&&M.column===q.column&&M.row===q.row),be(u)),se(([M,q,Z,ce])=>({gap:Z,item:q,scrollTop:ce,viewport:M}))),U),de(B(pt(be(T),r,be(W,Tx),be(_,Io),be(P,Io),be(O),be(I),be($),be(V),be(N)),Te(([,,,,,,,M])=>!M),se(([M,[q,Z],ce,te,Fe,Qe,et,,je,Oe])=>{const{column:tt,row:He}=ce,{height:at,width:dt}=te,{width:ne}=Fe;if(et===0&&(M===0||ne===0))return Ic;if(dt===0){const At=ui(Oe,M),On=At+Math.max(et-1,0);return Cx(jc(At,On,Qe))}const ee=_c(ne,dt,tt);let xe,Ee;je?q===0&&Z===0&&et>0?(xe=0,Ee=et-1):(xe=ee*Eo((q+He)/(at+He)),Ee=ee*Nc((Z+He)/(at+He))-1,Ee=wi(M-1,Mr(Ee,ee-1)),xe=wi(Ee,Mr(0,xe))):(xe=0,Ee=-1);const Se=jc(xe,Ee,Qe),{bottom:Re,top:Je}=Rc(Fe,ce,te,Se),Ke=Nc(M/ee),lt=Ke*at+(Ke-1)*He-Re;return{bottom:Re,itemHeight:at,items:Se,itemWidth:dt,offsetBottom:lt,offsetTop:Je,top:Je}})),A),de(B(O,Te(M=>M!==null),se(M=>M.length)),T),de(B(pt(P,_,A,W),Te(([M,q,{items:Z}])=>Z.length>0&&q.height!==0&&M.height!==0),se(([M,q,{items:Z},ce])=>{const{bottom:te,top:Fe}=Rc(M,ce,q,Z);return[Fe,te]}),rt(Nr)),t);const le=K(!1);de(B(u,De(le),se(([M,q])=>q||M!==0)),le);const fe=Pt(B(pt(A,T),Te(([{items:M}])=>M.length>0),De(le),Te(([[M,q],Z])=>{const ce=M.items[M.items.length-1].index===q-1;return(Z||M.bottom>0&&M.itemHeight>0&&M.offsetBottom===0&&M.items.length===q)&&ce}),se(([[,M]])=>M-1),rt())),ye=Pt(B(be(A),Te(({items:M})=>M.length>0&&M[0].index===0),tn(0),rt())),we=Pt(B(be(A),De($),Te(([{items:M},q])=>M.length>0&&!q),se(([{items:M}])=>({endIndex:M[M.length-1].index,startIndex:M[0].index})),rt(Jl),mn(0)));de(we,p.scrollSeekRangeChanged),de(B(D,De(P,_,T,W),se(([M,q,Z,ce,te])=>{const Fe=rc(M),{align:Qe,behavior:et,offset:je}=Fe;let Oe=Fe.index;Oe==="LAST"&&(Oe=ce-1),Oe=Mr(0,Oe,wi(ce-1,Oe));let tt=bi(q,te,Z,Oe);return Qe==="end"?tt=Ac(tt-q.height+Z.height):Qe==="center"&&(tt=Ac(tt-q.height/2+Z.height/2)),je&&(tt+=je),{behavior:et,top:tt}})),l);const z=bt(B(A,se(M=>M.offsetBottom+M.bottom)),0);return de(B(E,se(M=>({height:M.visibleHeight,width:M.visibleWidth}))),P),{customScrollParent:g,data:O,deviation:F,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:_,overscan:n,restoreStateFrom:G,scrollBy:i,scrollContainerState:a,scrollHeight:L,scrollTo:l,scrollToIndex:D,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:P,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:E,...p,gridState:A,horizontalDirection:pe,initialTopMostItemIndex:N,totalListHeight:z,...h,endReached:fe,propsReady:w,rangeChanged:we,startReached:ye,stateChanged:U,stateRestoreInProgress:$,...C}},nt(di,Ct,Or,pc,kn,hi,Cn));function _c(e,t,n){return Mr(1,Eo((e+n)/(Eo(t)+n)))}function Rc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=bi(e,t,n,r[0].index);return{bottom:bi(e,t,n,r[r.length-1].index)+o,top:s}}function bi(e,t,n,r){const o=_c(e.width,n.width,t.column),s=Eo(r/o),i=s*n.height+Mr(0,s-1)*t.row;return i>0?i+t.row:i}const Ex=Ve(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(xi),i=K("div"),a=K(or),l=(f,h=null)=>bt(B(t,se(p=>p[f]),rt()),h),u=K(!1),d=K(!1);return de(be(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Ix=Ve(([e,t])=>({...e,...t}),nt(kx,Ex)),Nx=S.memo(function(){const e=ot("gridState"),t=ot("listClassName"),n=ot("itemClassName"),r=ot("itemContent"),o=ot("computeItemKey"),s=ot("isSeeking"),i=Ht("scrollHeight"),a=ot("ItemComponent"),l=ot("ListComponent"),u=ot("ScrollSeekPlaceholder"),d=ot("context"),f=Ht("itemDimensions"),h=Ht("gap"),p=ot("log"),v=ot("stateRestoreInProgress"),w=Ht("reportReadyState"),g=zn(S.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const y=x.firstChild;if(y){const{height:E,width:C}=y.getBoundingClientRect();f({height:E,width:C})}h({column:Oc("column-gap",getComputedStyle(x).columnGap,p),row:Oc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return bc(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...yt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...yt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):S.createElement(a,{...yt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),Ax=S.memo(function(){const e=ot("HeaderComponent"),t=Ht("headerHeight"),n=ot("headerFooterTag"),r=zn(S.useMemo(()=>s=>{t(Tn(s,"height"))},[t]),!0,!1),o=ot("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...yt(e,o)})}):null}),jx=S.memo(function(){const e=ot("FooterComponent"),t=Ht("footerHeight"),n=ot("headerFooterTag"),r=zn(S.useMemo(()=>s=>{t(Tn(s,"height"))},[t]),!0,!1),o=ot("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...yt(e,o)})}):null}),_x=({children:e})=>{const t=S.useContext(wc),n=Ht("itemDimensions"),r=Ht("viewportDimensions"),o=zn(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]),c.jsx("div",{ref:o,style:ko(!1),children:e})},Rx=({children:e})=>{const t=S.useContext(wc),n=Ht("windowViewportRect"),r=Ht("itemDimensions"),o=ot("customScrollParent"),s=Wl(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]),c.jsx("div",{ref:s,style:ko(!1),children:e})},Px=S.memo(function({...e}){const t=ot("useWindowScroll"),n=ot("customScrollParent"),r=n||t?Mx:Ox,o=n||t?Rx:_x,s=ot("context");return c.jsx(r,{...e,...yt(r,s),children:c.jsxs(o,{children:[c.jsx(Ax,{}),c.jsx(Nx,{}),c.jsx(jx,{})]})})}),{useEmitter:Pc,useEmitterValue:ot,usePublisher:Ht}=xc(Ix,{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"}},Px),Ox=kc({useEmitter:Pc,useEmitterValue:ot,usePublisher:Ht}),Mx=Ec({useEmitter:Pc,useEmitterValue:ot,usePublisher:Ht});function Oc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Nt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Dx=Qr.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 yi({className:e,variant:t,...n}){return c.jsx("div",{className:J(Dx({variant:t}),e),...n})}function ae(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 Lx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function on(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...v}=f,w=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>v,Object.values(v));return c.jsx(w.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var w;const p=((w=h==null?void 0:h[e])==null?void 0:w[l])||a,v=m.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Fx(o,...t)]}function Fx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var xt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},$x=m[" useInsertionEffect ".trim().toString()]||xt;function Un({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=zx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Bx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function zx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return $x(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Bx(e){return typeof e=="function"}function Mc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Si(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Mc(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():Mc(e[o],null)}}}}function Le(...e){return m.useCallback(Si(...e),e)}var Hx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ke=Hx.reduce((e,t)=>{const n=Mn.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Dc(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function Ux(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Mt=e=>{const{present:t,children:n}=e,r=Wx(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Le(r.ref,Vx(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Mt.displayName="Presence";function Wx(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Ux(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=No(r.current);s.current=a==="mounted"?u:"none"},[a]),xt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=No(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),xt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const w=No(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&w&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=No(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function No(e){return(e==null?void 0:e.animationName)||"none"}function Vx(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 Kx=m[" useId ".trim().toString()]||(()=>{}),qx=0;function sn(e){const[t,n]=m.useState(Kx());return xt(()=>{n(r=>r??String(qx++))},[e]),e||(t?`radix-${t}`:"")}var Ao="Collapsible",[Gx,_C]=on(Ao),[Yx,Ci]=Gx(Ao),Lc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=Un({prop:r,defaultProp:o??!1,onChange:i,caller:Ao});return c.jsx(Yx,{scope:n,disabled:s,contentId:sn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(ke.div,{"data-state":ki(l),"data-disabled":s?"":void 0,...a,ref:t})})});Lc.displayName=Ao;var Fc="CollapsibleTrigger",$c=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ci(Fc,n);return c.jsx(ke.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:ae(e.onClick,o.onOpenToggle)})});$c.displayName=Fc;var Ti="CollapsibleContent",Xx=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ci(Ti,e.__scopeCollapsible);return c.jsx(Mt,{present:n||o.open,children:({present:s})=>c.jsx(Jx,{...r,ref:t,present:s})})});Xx.displayName=Ti;var Jx=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ci(Ti,n),[a,l]=m.useState(r),u=m.useRef(null),d=Le(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),v=p.current,w=i.open||a,g=m.useRef(w),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),xt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const y=b.getBoundingClientRect();f.current=y.height,p.current=y.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(ke.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":v?`${v}px`:void 0,...e.style},children:w&&o})});function ki(e){return e?"open":"closed"}var Zx=Lc;const zc=Zx,Bc=$c,Dr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:J("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Dr.displayName="Card";const Lr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:J("flex flex-col space-y-1.5 p-6",e),...t}));Lr.displayName="CardHeader";const Fr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:J("text-2xl font-semibold leading-none tracking-tight",e),...t}));Fr.displayName="CardTitle";const Hc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:J("text-sm text-muted-foreground",e),...t}));Hc.displayName="CardDescription";const jo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:J("p-6 pt-0",e),...t}));jo.displayName="CardContent";const Uc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:J("flex items-center p-6 pt-0",e),...t}));Uc.displayName="CardFooter";function Wc(){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=Wc();function Qx(e){Wn=e}const Vc=/[&<>"']/,ev=new RegExp(Vc.source,"g"),Kc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,tv=new RegExp(Kc.source,"g"),nv={"&":"&","<":"<",">":">",'"':""","'":"'"},qc=e=>nv[e];function St(e,t){if(t){if(Vc.test(e))return e.replace(ev,qc)}else if(Kc.test(e))return e.replace(tv,qc);return e}const rv=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Gc(e){return e.replace(rv,(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 ov=/(^|[^\[])\^/g;function Xe(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ov,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const sv=/[^\w:]/g,iv=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Yc(e,t,n){if(e){let r;try{r=decodeURIComponent(Gc(n)).replace(sv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!iv.test(n)&&(n=uv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const _o={},av=/^[^:]+:\/*[^/]*$/,lv=/^([^:]+:)[\s\S]*$/,cv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function uv(e,t){_o[" "+e]||(av.test(e)?_o[" "+e]=e+"/":_o[" "+e]=Po(e,"/",!0)),e=_o[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(lv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(cv,"$1")+t:e+t}const Ro={exec:function(){}};function Xc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Po(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 dv(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 fv(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 Jc(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Zc(e,t,n,r){const o=t.href,s=t.title?St(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:St(i)}}function hv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
39
34
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
40
|
-
`)}class
|
|
41
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
42
|
-
`,1)[0].replace(/^\t+/,
|
|
35
|
+
`)}class Ei{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:Po(r,`
|
|
36
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=hv(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=Po(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,v,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 b=new RegExp(`^( {0,3}${w})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
37
|
+
`,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
|
|
43
38
|
`,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
44
|
-
`,t=t.substring(f.length+1),
|
|
45
|
-
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||
|
|
39
|
+
`,t=t.substring(f.length+1),v=!0),!v){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+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
40
|
+
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||E.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
46
41
|
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;p+=`
|
|
47
42
|
`+f}!l&&!f.trim()&&(l=!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(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const 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
|
|
49
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=
|
|
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:
|
|
51
|
-
]`).replace("lheading",
|
|
43
|
+
`,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const 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(T=>T.type==="space"),C=E.length>0&&E.some(T=>/\n.*\n/.test(T.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]):St(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:Xc(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
44
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=Xc(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
45
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:St(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]):St(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=Po(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=dv(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),Zc(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 Zc(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=h.slice(1,-1);return{type:"em",raw:h,text:v,tokens:this.lexer.inlineTokens(v)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=St(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=St(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=St(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=St(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=St(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]):St(r[0]):r[0]:o=St(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:Ro,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=Xe(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.listItemStart=Xe(/^( *)(bull) */).replace("bull",me.bullet).getRegex(),me.list=Xe(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=Xe(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Xe(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=Xe(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=Xe(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=Xe(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:Xe(`^ *(?: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:Ro,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Xe(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
|
|
46
|
+
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ie={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ro,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:Ro,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ie._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ie.punctuation=Xe(ie.punctuation).replace(/punctuation/g,ie._punctuation).getRegex(),ie.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ie.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ie._comment=Xe(me._comment).replace("(?:-->|$)","-->").getRegex(),ie.emStrong.lDelim=Xe(ie.emStrong.lDelim).replace(/punct/g,ie._punctuation).getRegex(),ie.emStrong.rDelimAst=Xe(ie.emStrong.rDelimAst,"g").replace(/punct/g,ie._punctuation).getRegex(),ie.emStrong.rDelimUnd=Xe(ie.emStrong.rDelimUnd,"g").replace(/punct/g,ie._punctuation).getRegex(),ie._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ie._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ie._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])?)+(?![-_])/,ie.autolink=Xe(ie.autolink).replace("scheme",ie._scheme).replace("email",ie._email).getRegex(),ie._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ie.tag=Xe(ie.tag).replace("comment",ie._comment).replace("attribute",ie._attribute).getRegex(),ie._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ie._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ie._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ie.link=Xe(ie.link).replace("label",ie._label).replace("href",ie._href).replace("title",ie._title).getRegex(),ie.reflink=Xe(ie.reflink).replace("label",ie._label).replace("ref",me._label).getRegex(),ie.nolink=Xe(ie.nolink).replace("ref",me._label).getRegex(),ie.reflinkSearch=Xe(ie.reflinkSearch,"g").replace("reflink",ie.reflink).replace("nolink",ie.nolink).getRegex(),ie.normal={...ie},ie.pedantic={...ie.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:Xe(/^!?\[(label)\]\((.*?)\)/).replace("label",ie._label).getRegex(),reflink:Xe(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ie._label).getRegex()},ie.gfm={...ie.normal,escape:Xe(ie.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ie.gfm.url=Xe(ie.gfm.url,"i").replace("email",ie.gfm._extended_email).getRegex(),ie.breaks={...ie.gfm,br:Xe(ie.br).replace("{2,}","*").getRegex(),text:Xe(ie.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function pv(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 Qc(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 Ei,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:ie.normal};this.options.pedantic?(n.block=me.pedantic,n.inline=ie.pedantic):this.options.gfm&&(n.block=me.gfm,this.options.breaks?n.inline=ie.breaks:n.inline=ie.gfm),this.tokenizer.rules=n}static get rules(){return{block:me,inline:ie}}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
47
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
53
48
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
54
49
|
`+r.raw,o.text+=`
|
|
@@ -58,9 +53,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
58
53
|
`+r.raw,o.text+=`
|
|
59
54
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
60
55
|
`+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,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+
|
|
62
|
-
`,o?'<pre><code class="'+this.options.langPrefix+
|
|
63
|
-
`:"<pre><code>"+(r?t:
|
|
56
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Jc("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)+"["+Jc("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(u=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Qc)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Qc))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let h;this.options.extensions.startInline.forEach(function(p){h=p.call({lexer:this},f),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,pv)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class Ii{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$/,"")+`
|
|
57
|
+
`,o?'<pre><code class="'+this.options.langPrefix+St(o)+'">'+(r?t:St(t,!0))+`</code></pre>
|
|
58
|
+
`:"<pre><code>"+(r?t:St(t,!0))+`</code></pre>
|
|
64
59
|
`}blockquote(t){return`<blockquote>
|
|
65
60
|
${t}</blockquote>
|
|
66
61
|
`}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
|
|
@@ -78,14 +73,14 @@ ${t}</blockquote>
|
|
|
78
73
|
`}tablerow(t){return`<tr>
|
|
79
74
|
${t}</tr>
|
|
80
75
|
`}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=
|
|
82
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Oo{constructor(t){this.options=t||
|
|
83
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+wt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function su(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=gv(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(hv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&he.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;he.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.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&&he.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function he(e,t,n){return su(Sn.lex,Cn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},ev(he.defaults),he},he.getDefaults=qc,he.defaults=zn,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.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=he.defaults.renderer||new Ii;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=he.defaults.tokenizer||new ki;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=he.defaults.hooks||new Oo;for(const s in n.hooks){const i=o[s];Oo.passThroughHooks.has(s)?o[s]=a=>{if(he.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=he.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}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=su(Sn.lexInline,Cn.parseInline),he.Parser=Cn,he.parser=Cn.parse,he.Renderer=Ii,he.TextRenderer=ru,he.Lexer=Sn,he.lexer=Sn.lex,he.Tokenizer=ki,he.Slugger=ou,he.Hooks=Oo,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,Cn.parse,Sn.lex;function Ni({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 he.parse(o)}return he.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:X("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function iu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function au(e,t){return await(await iu(`/files/${e}/view`,t)).text()}async function xv(e,t){const n=await iu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function vv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const wv=1,bv=1e6;let Ai=0;function yv(){return Ai=(Ai+1)%Number.MAX_SAFE_INTEGER,Ai.toString()}const ji=new Map,lu=e=>{if(ji.has(e))return;const t=setTimeout(()=>{ji.delete(e),$r({type:"REMOVE_TOAST",toastId:e})},bv);ji.set(e,t)},Sv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,wv)};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?lu(n):e.toasts.forEach(r=>{lu(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)}}},Mo=[];let Do={toasts:[]};function $r(e){Do=Sv(Do,e),Mo.forEach(t=>{t(Do)})}function Cv({...e}){const t=yv(),n=o=>$r({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>$r({type:"DISMISS_TOAST",toastId:t});return $r({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function _i(){const[e,t]=m.useState(Do);return m.useEffect(()=>(Mo.push(t),()=>{const n=Mo.indexOf(t);n>-1&&Mo.splice(n,1)}),[e]),{...e,toast:Cv,dismiss:n=>$r({type:"DISMISS_TOAST",toastId:n})}}function mt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Tv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Ev="DismissableLayer",Ri="dismissableLayer.update",kv="dismissableLayer.pointerDownOutside",Iv="dismissableLayer.focusOutside",cu,uu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(uu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Fe(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=x,C=jv(I=>{const A=I.target,R=[...u.branches].some(j=>j.contains(A));!k||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=_v(I=>{const A=I.target;[...u.branches].some(j=>j.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Tv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),du(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=cu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),du())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ri,I),()=>document.removeEventListener(Ri,I)},[]),c.jsx(ye.div,{...l,ref:w,style:{pointerEvents:y?k?"auto":"none":void 0,...e.style},onFocusCapture:oe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:oe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:oe(e.onPointerDownCapture,C.onPointerDownCapture)})});Lo.displayName=Ev;var Nv="DismissableLayerBranch",Av=m.forwardRef((e,t)=>{const n=m.useContext(uu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ye.div,{...e,ref:o})});Av.displayName=Nv;function jv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){fu(kv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function _v(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&fu(Iv,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 du(){const e=new CustomEvent(Ri);document.dispatchEvent(e)}function fu(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?$c(o,s):o.dispatchEvent(s)}var Pi="focusScope.autoFocusOnMount",Oi="focusScope.autoFocusOnUnmount",hu={bubbles:!1,cancelable:!0},Rv="FocusScope",Fo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Fe(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(y){if(p.paused||!a)return;const k=y.target;a.contains(k)?f.current=k:Tn(f.current,{select:!0})},g=function(y){if(p.paused||!a)return;const k=y.relatedTarget;k!==null&&(a.contains(k)||Tn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const C of y)C.removedNodes.length>0&&Tn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){gu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Pi,hu);a.addEventListener(Pi,u),a.dispatchEvent(x),x.defaultPrevented||(Pv(Fv(pu(a)),{select:!0}),document.activeElement===v&&Tn(a))}return()=>{a.removeEventListener(Pi,u),setTimeout(()=>{const x=new CustomEvent(Oi,hu);a.addEventListener(Oi,d),a.dispatchEvent(x),x.defaultPrevented||Tn(v??document.body,{select:!0}),a.removeEventListener(Oi,d),gu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[y,k]=Ov(b);y&&k?!v.shiftKey&&x===k?(v.preventDefault(),n&&Tn(y,{select:!0})):v.shiftKey&&x===y&&(v.preventDefault(),n&&Tn(k,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});Fo.displayName=Rv;function Pv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}function Ov(e){const t=pu(e),n=mu(t,e),r=mu(t.reverse(),e);return[n,r]}function pu(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 mu(e,t){for(const n of e)if(!Mv(n,{upTo:t}))return n}function Mv(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 Dv(e){return e instanceof HTMLInputElement&&"select"in e}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dv(e)&&t&&e.select()}}var gu=Lv();function Lv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=xu(e,t),e.unshift(t)},remove(t){var n;e=xu(e,t),(n=e[0])==null||n.resume()}}}function xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Fv(e){return e.filter(t=>t.tagName!=="A")}var $v="Portal",$o=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?_s.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});$o.displayName=$v;var Mi=0;function Di(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??vu()),document.body.insertAdjacentElement("beforeend",e[1]??vu()),Mi++,()=>{Mi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mi--}},[])}function vu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nn=function(){return nn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},nn.apply(this,arguments)};function wu(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 zv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var zo="right-scroll-bar-position",Bo="width-before-scroll-bar",Bv="with-scroll-bars-hidden",Hv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uv(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 Wv=typeof window<"u"?m.useLayoutEffect:m.useEffect,bu=new WeakMap;function Vv(e,t){var n=Uv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return Wv(function(){var r=bu.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)})}bu.set(n,e)},[e]),n}function Kv(e){return e}function qv(e,t){t===void 0&&(t=Kv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gv(e){e===void 0&&(e={});var t=qv(null);return t.options=nn({async:!0,ssr:!1},e),t}var yu=function(e){var t=e.sideCar,n=wu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,nn({},n))};yu.isSideCarExport=!0;function Yv(e,t){return e.useMedium(t),yu}var Su=Gv(),Fi=function(){},Ho=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,y=e.gapMode,k=wu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Vv([n,t]),I=nn(nn({},k),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Su,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:T})):m.createElement(b,nn({},I,{className:l,ref:T}),a))});Ho.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ho.classNames={fullWidth:Bo,zeroRight:zo};var Xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xv();return t&&e.setAttribute("nonce",t),e}function Zv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ew=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jv())&&(Zv(t,n),Qv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tw=function(){var e=ew();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Cu=function(){var e=tw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},nw={left:0,top:0,right:0,gap:0},$i=function(e){return parseInt(e||"",10)||0},rw=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[$i(n),$i(r),$i(o)]},ow=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nw;var t=rw(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])}},sw=Cu(),sr="data-scroll-locked",iw=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(
|
|
76
|
+
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Yc(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=Yc(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 eu{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 tu{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 Ii,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new eu,this.slugger=new tu}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,l,u,d,f,h,p,v,w,g,x,b,y,E,C,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Gc(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(v=p.ordered,w=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],y=b.checked,E=b.task,x="",b.task&&(C=this.renderer.checkbox(y),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,E,y);r+=this.renderer.list(h,v,w);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
77
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Oo{constructor(t){this.options=t||Wn}preprocess(t){return t}postprocess(t){return t}}gp(Oo,"passThroughHooks",new Set(["preprocess","postprocess"]));function mv(e,t,n){return r=>{if(r.message+=`
|
|
78
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+St(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 nu(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=mv(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(fv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&ge.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;ge.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ge.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return nu(En.lex,In.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},Qx(ge.defaults),ge},ge.getDefaults=Wc,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 Ii;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ge.defaults.tokenizer||new Ei;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ge.defaults.hooks||new Oo;for(const s in n.hooks){const i=o[s];Oo.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 l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ge.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=nu(En.lexInline,In.parseInline),ge.Parser=In,ge.parser=In.parse,ge.Renderer=Ii,ge.TextRenderer=eu,ge.Lexer=En,ge.lexer=En.lex,ge.Tokenizer=Ei,ge.Slugger=tu,ge.Hooks=Oo,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,In.parse,En.lex;function Ni({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 c.jsx("div",{className:J("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function ru(e,t){return await _t(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function ou(e,t){return await(await ru(`/files/${e}/view`,t)).text()}async function gv(e,t){const n=await ru(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await _t(`/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 xv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await _t("/files",{params:r})}const vv=1,wv=1e6;let Ai=0;function bv(){return Ai=(Ai+1)%Number.MAX_SAFE_INTEGER,Ai.toString()}const ji=new Map,su=e=>{if(ji.has(e))return;const t=setTimeout(()=>{ji.delete(e),$r({type:"REMOVE_TOAST",toastId:e})},wv);ji.set(e,t)},yv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,vv)};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?su(n):e.toasts.forEach(r=>{su(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)}}},Mo=[];let Do={toasts:[]};function $r(e){Do=yv(Do,e),Mo.forEach(t=>{t(Do)})}function Sv({...e}){const t=bv(),n=o=>$r({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>$r({type:"DISMISS_TOAST",toastId:t});return $r({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function _i(){const[e,t]=m.useState(Do);return m.useEffect(()=>(Mo.push(t),()=>{const n=Mo.indexOf(t);n>-1&&Mo.splice(n,1)}),[e]),{...e,toast:Sv,dismiss:n=>$r({type:"DISMISS_TOAST",toastId:n})}}function vt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Cv(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Tv="DismissableLayer",Ri="dismissableLayer.update",kv="dismissableLayer.pointerDownOutside",Ev="dismissableLayer.focusOutside",iu,au=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(au),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=Le(t,I=>f(I)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(g),b=d?w.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,C=Av(I=>{const A=I.target,P=[...u.branches].some(_=>_.contains(A));!E||P||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=jv(I=>{const A=I.target;[...u.branches].some(_=>_.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Cv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(iu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),lu(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=iu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),lu())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ri,I),()=>document.removeEventListener(Ri,I)},[]),c.jsx(ke.div,{...l,ref:v,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});Lo.displayName=Tv;var Iv="DismissableLayerBranch",Nv=m.forwardRef((e,t)=>{const n=m.useContext(au),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ke.div,{...e,ref:o})});Nv.displayName=Iv;function Av(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){cu(kv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function jv(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&cu(Ev,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 lu(){const e=new CustomEvent(Ri);document.dispatchEvent(e)}function cu(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?Dc(o,s):o.dispatchEvent(s)}var Pi="focusScope.autoFocusOnMount",Oi="focusScope.autoFocusOnUnmount",uu={bubbles:!1,cancelable:!0},_v="FocusScope",Fo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=vt(o),d=vt(s),f=m.useRef(null),h=Le(t,w=>l(w)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let w=function(y){if(p.paused||!a)return;const E=y.target;a.contains(E)?f.current=E:Nn(f.current,{select:!0})},g=function(y){if(p.paused||!a)return;const E=y.relatedTarget;E!==null&&(a.contains(E)||Nn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const C of y)C.removedNodes.length>0&&Nn(a)};document.addEventListener("focusin",w),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){hu.add(p);const w=document.activeElement;if(!a.contains(w)){const x=new CustomEvent(Pi,uu);a.addEventListener(Pi,u),a.dispatchEvent(x),x.defaultPrevented||(Rv(Lv(du(a)),{select:!0}),document.activeElement===w&&Nn(a))}return()=>{a.removeEventListener(Pi,u),setTimeout(()=>{const x=new CustomEvent(Oi,uu);a.addEventListener(Oi,d),a.dispatchEvent(x),x.defaultPrevented||Nn(w??document.body,{select:!0}),a.removeEventListener(Oi,d),hu.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(w=>{if(!n&&!r||p.paused)return;const g=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,x=document.activeElement;if(g&&x){const b=w.currentTarget,[y,E]=Pv(b);y&&E?!w.shiftKey&&x===E?(w.preventDefault(),n&&Nn(y,{select:!0})):w.shiftKey&&x===y&&(w.preventDefault(),n&&Nn(E,{select:!0})):x===b&&w.preventDefault()}},[n,r,p.paused]);return c.jsx(ke.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});Fo.displayName=_v;function Rv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Nn(r,{select:t}),document.activeElement!==n)return}function Pv(e){const t=du(e),n=fu(t,e),r=fu(t.reverse(),e);return[n,r]}function du(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 fu(e,t){for(const n of e)if(!Ov(n,{upTo:t}))return n}function Ov(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 Mv(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&&Mv(e)&&t&&e.select()}}var hu=Dv();function Dv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=pu(e,t),e.unshift(t)},remove(t){var n;e=pu(e,t),(n=e[0])==null||n.resume()}}}function pu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Lv(e){return e.filter(t=>t.tagName!=="A")}var Fv="Portal",$o=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);xt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?_s.createPortal(c.jsx(ke.div,{...r,ref:t}),i):null});$o.displayName=Fv;var Mi=0;function Di(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??mu()),document.body.insertAdjacentElement("beforeend",e[1]??mu()),Mi++,()=>{Mi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mi--}},[])}function mu(){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 an=function(){return an=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},an.apply(this,arguments)};function gu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function $v(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var zo="right-scroll-bar-position",Bo="width-before-scroll-bar",zv="with-scroll-bars-hidden",Bv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Hv(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 Uv=typeof window<"u"?m.useLayoutEffect:m.useEffect,xu=new WeakMap;function Wv(e,t){var n=Hv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return Uv(function(){var r=xu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}xu.set(n,e)},[e]),n}function Vv(e){return e}function Kv(e,t){t===void 0&&(t=Vv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function qv(e){e===void 0&&(e={});var t=Kv(null);return t.options=an({async:!0,ssr:!1},e),t}var vu=function(e){var t=e.sideCar,n=gu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,an({},n))};vu.isSideCarExport=!0;function Gv(e,t){return e.useMedium(t),vu}var wu=qv(),Fi=function(){},Ho=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,w=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,y=e.gapMode,E=gu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Wv([n,t]),I=an(an({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:wu,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?m.cloneElement(m.Children.only(a),an(an({},I),{ref:T})):m.createElement(b,an({},I,{className:l,ref:T}),a))});Ho.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ho.classNames={fullWidth:Bo,zeroRight:zo};var Yv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Xv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Yv();return t&&e.setAttribute("nonce",t),e}function Jv(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 Qv=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Xv())&&(Jv(t,n),Zv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ew=function(){var e=Qv();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bu=function(){var e=ew(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},tw={left:0,top:0,right:0,gap:0},$i=function(e){return parseInt(e||"",10)||0},nw=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[$i(n),$i(r),$i(o)]},rw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return tw;var t=nw(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])}},ow=bu(),ir="data-scroll-locked",sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
79
|
+
.`.concat(zv,` {
|
|
85
80
|
overflow: hidden `).concat(r,`;
|
|
86
81
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
87
82
|
}
|
|
88
|
-
body[`).concat(
|
|
83
|
+
body[`).concat(ir,`] {
|
|
89
84
|
overflow: hidden `).concat(r,`;
|
|
90
85
|
overscroll-behavior: contain;
|
|
91
86
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -114,21 +109,21 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
|
|
|
114
109
|
margin-right: 0 `).concat(r,`;
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
body[`).concat(
|
|
118
|
-
`).concat(
|
|
112
|
+
body[`).concat(ir,`] {
|
|
113
|
+
`).concat(Bv,": ").concat(a,`px;
|
|
119
114
|
}
|
|
120
|
-
`)},
|
|
115
|
+
`)},yu=function(){var e=parseInt(document.body.getAttribute(ir)||"0",10);return isFinite(e)?e:0},iw=function(){m.useEffect(function(){return document.body.setAttribute(ir,(yu()+1).toString()),function(){var e=yu()-1;e<=0?document.body.removeAttribute(ir):document.body.setAttribute(ir,e.toString())}},[])},aw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;iw();var s=m.useMemo(function(){return rw(o)},[o]);return m.createElement(ow,{styles:sw(s,!t,o,n?"":"!important")})},zi=!1;if(typeof window<"u")try{var Uo=Object.defineProperty({},"passive",{get:function(){return zi=!0,!0}});window.addEventListener("test",Uo,Uo),window.removeEventListener("test",Uo,Uo)}catch{zi=!1}var ar=zi?{passive:!1}:!1,lw=function(e){return e.tagName==="TEXTAREA"},Su=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!lw(e)&&n[t]==="visible")},cw=function(e){return Su(e,"overflowY")},uw=function(e){return Su(e,"overflowX")},Cu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Tu(e,r);if(o){var s=ku(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},dw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},fw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Tu=function(e,t){return e==="v"?cw(t):uw(t)},ku=function(e,t){return e==="v"?dw(t):fw(t)},hw=function(e,t){return e==="h"&&t==="rtl"?-1:1},pw=function(e,t,n,r,o){var s=hw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=ku(e,a),v=p[0],w=p[1],g=p[2],x=w-g-s*v;(v||x)&&Tu(e,a)&&(f+=x,h+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Wo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Eu=function(e){return[e.deltaX,e.deltaY]},Iu=function(e){return e&&"current"in e?e.current:e},mw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},gw=function(e){return`
|
|
121
116
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
122
117
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
123
|
-
`)},
|
|
118
|
+
`)},xw=0,lr=[];function vw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(xw++)[0],s=m.useState(bu)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var w=$v([e.lockRef.current],(e.shards||[]).map(Iu),!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=m.useCallback(function(w,g){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!i.current.allowPinchZoom;var x=Wo(w),b=n.current,y="deltaX"in w?w.deltaX:b[0]-x[0],E="deltaY"in w?w.deltaY:b[1]-x[1],C,T=w.target,I=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in w&&I==="h"&&T.type==="range")return!1;var A=Cu(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Cu(I,T)),!A)return!1;if(!r.current&&"changedTouches"in w&&(y||E)&&(r.current=C),!C)return!0;var P=r.current||C;return pw(P,g,w,P==="h"?y:E)},[]),l=m.useCallback(function(w){var g=w;if(!(!lr.length||lr[lr.length-1]!==s)){var x="deltaY"in g?Eu(g):Wo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&mw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var y=(i.current.shards||[]).map(Iu).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=m.useCallback(function(w,g,x,b){var y={name:w,delta:g,target:x,should:b,shadowParent:ww(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),d=m.useCallback(function(w){n.current=Wo(w),r.current=void 0},[]),f=m.useCallback(function(w){u(w.type,Eu(w),w.target,a(w,e.lockRef.current))},[]),h=m.useCallback(function(w){u(w.type,Wo(w),w.target,a(w,e.lockRef.current))},[]);m.useEffect(function(){return lr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ar),document.addEventListener("touchmove",l,ar),document.addEventListener("touchstart",d,ar),function(){lr=lr.filter(function(w){return w!==s}),document.removeEventListener("wheel",l,ar),document.removeEventListener("touchmove",l,ar),document.removeEventListener("touchstart",d,ar)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:gw(o)}):null,p?m.createElement(aw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ww(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const bw=Gv(wu,vw);var Vo=m.forwardRef(function(e,t){return m.createElement(Ho,an({},e,{ref:t,sideCar:bw}))});Vo.classNames=Ho.classNames;var yw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},cr=new WeakMap,Ko=new WeakMap,qo={},Bi=0,Nu=function(e){return e&&(e.host||Nu(e.parentNode))},Sw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Nu(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})},Cw=function(e,t,n,r){var o=Sw(t,Array.isArray(e)?e:[e]);qo[n]||(qo[n]=new WeakMap);var s=qo[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",w=(cr.get(h)||0)+1,g=(s.get(h)||0)+1;cr.set(h,w),s.set(h,g),i.push(h),w===1&&v&&Ko.set(h,!0),g===1&&h.setAttribute(n,"true"),v||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=cr.get(f)-1,p=s.get(f)-1;cr.set(f,h),s.set(f,p),h||(Ko.has(f)||f.removeAttribute(r),Ko.delete(f)),p||f.removeAttribute(n)}),Bi--,Bi||(cr=new WeakMap,cr=new WeakMap,Ko=new WeakMap,qo={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=yw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Cw(r,o,n,"aria-hidden")):function(){return null}},Go="Dialog",[Au,RC]=on(Go),[Tw,Xt]=Au(Go),ju=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=Un({prop:r,defaultProp:o??!1,onChange:s,caller:Go});return c.jsx(Tw,{scope:t,triggerRef:a,contentRef:l,contentId:sn(),titleId:sn(),descriptionId:sn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};ju.displayName=Go;var _u="DialogTrigger",Ru=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xt(_u,n),s=Le(t,o.triggerRef);return c.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vi(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Ru.displayName=_u;var Ui="DialogPortal",[kw,Pu]=Au(Ui,{forceMount:void 0}),Ou=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Xt(Ui,t);return c.jsx(kw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Mt,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:i})}))})};Ou.displayName=Ui;var Yo="DialogOverlay",Mu=m.forwardRef((e,t)=>{const n=Pu(Yo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Xt(Yo,e.__scopeDialog);return s.modal?c.jsx(Mt,{present:r||s.open,children:c.jsx(Iw,{...o,ref:t})}):null});Mu.displayName=Yo;var Ew=Mn.createSlot("DialogOverlay.RemoveScroll"),Iw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xt(Yo,n);return c.jsx(Vo,{as:Ew,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ke.div,{"data-state":Vi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Vn="DialogContent",Du=m.forwardRef((e,t)=>{const n=Pu(Vn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Xt(Vn,e.__scopeDialog);return c.jsx(Mt,{present:r||s.open,children:s.modal?c.jsx(Nw,{...o,ref:t}):c.jsx(Aw,{...o,ref:t})})});Du.displayName=Vn;var Nw=m.forwardRef((e,t)=>{const n=Xt(Vn,e.__scopeDialog),r=m.useRef(null),o=Le(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(Lu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),Aw=m.forwardRef((e,t)=>{const n=Xt(Vn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Lu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Lu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Xt(Vn,n),l=m.useRef(null),u=Le(t,l);return Di(),c.jsxs(c.Fragment,{children:[c.jsx(Fo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Lo,{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)})}),c.jsxs(c.Fragment,{children:[c.jsx(jw,{titleId:a.titleId}),c.jsx(Rw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Wi="DialogTitle",Fu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xt(Wi,n);return c.jsx(ke.h2,{id:o.titleId,...r,ref:t})});Fu.displayName=Wi;var $u="DialogDescription",zu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xt($u,n);return c.jsx(ke.p,{id:o.descriptionId,...r,ref:t})});zu.displayName=$u;var Bu="DialogClose",Hu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Xt(Bu,n);return c.jsx(ke.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});Hu.displayName=Bu;function Vi(e){return e?"open":"closed"}var Uu="DialogTitleWarning",[PC,Wu]=Lx(Uu,{contentName:Vn,titleName:Wi,docsSlug:"dialog"}),jw=({titleId:e})=>{const t=Wu(Uu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
124
119
|
|
|
125
120
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
126
121
|
|
|
127
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},
|
|
128
|
-
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function
|
|
129
|
-
… [truncated ${
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[
|
|
131
|
-
… [truncated ${we.length-Un} chars]`:we,et=k==="expanded";return c.jsxs(Uc,{open:et,onOpenChange:Ke=>C(Ke?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(yi,{variant:"outline",children:(me.name??"tool")+(me.toolCallId?` • ${me.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:et?_e:_e.slice(0,d)+(_e.length>d?"...":"")})}),c.jsx(Wc,{asChild:!0,children:c.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:et?c.jsxs(c.Fragment,{children:[" ",c.jsx(ee.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},me.toolCallId??Ce)})})}if(!N){const le=c.jsx("div",{className:"space-y-2",children:t.content.map((me,Ce)=>c.jsx(Qe,{part:me,i:Ce},Ce))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[le,c.jsx(Vw,{className:Y})]}):le}},[de,pe.length,ge.length,Se.length,r,t.model,N,se.name,B,k,u,Re,Y]),ct=S.useMemo(()=>Ww(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:X(Xe(),p.container),children:c.jsxs("div",{className:X(Je(),p.content),children:[(i||a||N)&&c.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",Y,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[De(),a&&ct&&c.jsx("span",{className:X("font-medium",q?"text-xs":"text-sm"),children:ct}),N&&se.name&&c.jsxs(yi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",Y,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),C(le=>le==="collapsed"?"preview":"collapsed"))},onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:se.name}),c.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})})]}),N&&!se.name&&c.jsx(Ue,{variant:"ghost",size:"sm",className:X("h-6 px-1",Y,"hover:bg-foreground/10"),onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",k!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:X("text-xs opacity-60",Y,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(N?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":N?"Copy visible":"Copy message",title:N?"Copy visible portion":"Copy message",children:c.jsx(ee.Copy,{className:X(b?"text-success":Y,q?"h-3 w-3":"h-4 w-4")})}),N&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G("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"})]}),F==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ee.Edit,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ee.RotateCcw,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:st()}),N&&k==="expanded"&&(se.toolCallId||se.name)&&c.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[se.name&&c.jsxs("div",{children:["Function: ",se.name]}),se.toolCallId&&c.jsxs("div",{children:["Call ID: ",se.toolCallId]})]}),!(i||a||N)&&s&&!o&&c.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Copy,{className:X(b?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),F==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Edit,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.RotateCcw,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),V&&c.jsx(Fw,{isOpen:L,onClose:()=>{P(!1),U(null)},fileId:V.id,fileName:V.name,mimeType:V.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&od(e.message)===od(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Kw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Qo,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children: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 c.jsxs("div",{className:Qo,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Qo,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:qw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)})}function qw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(zr(e))})}catch{return String(e)}}function Gw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Dr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Lr,{className:"pb-3",children:[c.jsx(Fr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Vc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Kc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ue,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(Ue,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Yw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Xw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Qo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const id=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,qi=S.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const y=S.useRef(null),k=S.useRef(null),C=S.useRef(!1),[T,I]=S.useState(!0),A=S.useCallback(M=>{I(M),g&&g(!M),x&&x(M)},[g,x]),R=S.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=S.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Sx,{ref:M=>{y.current=M},scrollerRef:M=>{k.current=M instanceof HTMLDivElement?M:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(M,D)=>id(D,M),itemContent:(M,D)=>{const L=id(D,M);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":L,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(sd,{message:D,messageIndex:M,isStreamingMessage:t&&n===D.id,streamingDebounceMs:r,isEditing:i===D.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(M),onCancelEdit:d})})}})})});qi.displayName="MessageList";const es=1e4;function Jw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
122
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},_w="DialogDescriptionWarning",Rw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Wu(_w).contentName}}.`;return m.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Vu=ju,Pw=Ru,Ku=Ou,Xo=Mu,Jo=Du,Kn=Fu,Zo=zu,qu=Hu;const Ow=Vu,Mw=Ku,Gu=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{ref:n,className:J("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}));Gu.displayName=Xo.displayName;const Yu=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,l=>{if(s||!m.isValidElement(l))return;const u=l.type;if(u===Kn||(u==null?void 0:u.displayName)===Kn.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(Mw,{children:[c.jsx(Gu,{}),c.jsxs(Jo,{ref:r,className:J("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(Kn,{className:"sr-only",children:"Dialog"}),t,c.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:[c.jsx(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Yu.displayName=Jo.displayName;const Xu=({className:e,...t})=>c.jsx("div",{className:J("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Xu.displayName="DialogHeader";const Ju=m.forwardRef(({className:e,...t},n)=>c.jsx(Kn,{ref:n,className:J("text-lg font-semibold leading-none tracking-tight",e),...t}));Ju.displayName=Kn.displayName;const Dw=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:J("text-sm text-muted-foreground",e),...t}));Dw.displayName=Zo.displayName;function Lw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=S.useState(!1),[a,l]=S.useState(null),[u,d]=S.useState(null),{toast:f}=_i(),h=S.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await ou(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);S.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await gv(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"})}},v=async()=>{if(n)try{const x=await ou(n),b=new Blob([x],{type:o}),y=URL.createObjectURL(b);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?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(re.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(We,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(re.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(re.Image,{className:"h-5 w-5"}):c.jsx(re.FileText,{className:"h-5 w-5"});return c.jsx(Ow,{open:e,onOpenChange:t,children:c.jsxs(Yu,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Xu,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[g(),c.jsxs("div",{children:[c.jsx(Ju,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(We,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(re.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(We,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(re.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:w()})]})})}function Zu(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 Qu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function zr(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(zr).filter(r=>r!==void 0);return n.length?n:void 0}if(Qu(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=zr(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(Qu(e))return"";try{const t=zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ed(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 ed(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=p?p[2].trim():"",g=v?v[2].trim():"";n[i].push({title:w,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Qo="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",qn=1e5;function Fw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function $w(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function zw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Bw(e){const t=(r,o=qn)=>{try{const s=zr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
|
|
123
|
+
… [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Hw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Uw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function td(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Ww({className:e}){const[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:J("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const nd=S.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:v,onRegenerate:w,onCancelEdit:g,onCopy:x}){const[b,y]=S.useState(!1),[E,C]=S.useState("collapsed"),[T,I]=S.useState(!1),{currentThreadId:A}=ho(),{handleInterrupt:P}=Js(),{toast:_}=_i(),[D,L]=S.useState({}),[F,O]=S.useState(!1),[W,U]=S.useState(null),G=l==="phone"||l==="half-screen",$=t.role,N=$==="tool",V=!(r&&$!=="user"),X=S.useMemo(()=>{switch($){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))]"}},[$]),pe=S.useMemo(()=>Fw(t.content),[t.content]),le=S.useMemo(()=>$w(t.content),[t.content]),fe=S.useMemo(()=>t.content.filter(ne=>ne.type==="image_url"),[t.content]),ye=S.useMemo(()=>t.content.filter(ne=>ne.type==="file"),[t.content]),we=S.useMemo(()=>t.content.filter(ne=>ne.type==="interrupt"),[t.content]),z=S.useMemo(()=>Bw(t.content),[t.content]);S.useMemo(()=>Hw(t.content),[t.content]);const M=S.useMemo(()=>z.length<=qn?z:`${z.slice(0,qn)}
|
|
124
|
+
… [truncated ${z.length-qn} chars]`,[z]),q=S.useCallback(async(ne="all")=>{const xe=ne==="visible"&&N?M:N?z:pe;async function Ee(Se){try{await navigator.clipboard.writeText(Se)}catch{try{const Re=document.createElement("textarea");Re.value=Se,Re.setAttribute("readonly",""),Re.style.position="absolute",Re.style.left="-9999px",document.body.appendChild(Re),Re.select(),document.execCommand("copy"),document.body.removeChild(Re)}catch(Re){throw console.error("Failed to copy:",Re),Re}}}try{await Ee(xe),y(!0),setTimeout(()=>y(!1),2e3),x==null||x(xe)}catch(Se){console.error("Failed to copy:",Se)}},[N,z,pe,M,x]),Z=S.useCallback(()=>{if(!v)return;const ne=N?z:pe;v(t.id,ne)},[v,t.id,N,z,pe]),ce=S.useCallback(()=>{w==null||w(n)},[w,n]),te=S.useCallback(async(ne,ee,xe)=>{if(!V){ne.preventDefault();return}if(D[xe]){ne.preventDefault();return}try{const Ee=String(ee.url??""),Se=Ee.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(Se){ne.preventDefault();const Re=Se[1],Je=ee.name||`file_${Re}`,Ke=ee.mimeType||"application/octet-stream";U({id:Re,name:Je,mimeType:Ke}),O(!0);return}if(Ee.startsWith("data:")){ne.preventDefault(),L(Ke=>({...Ke,[xe]:!0}));const Re=`${ee.name}_${ee.size}_${Date.now()}`,Je=_({title:"Fetching file...",description:"",open:!0});try{const Ke=await xv(A??void 0);if(!Ke||!Array.isArray(Ke))throw new Error("Invalid file list response");const lt=Ke.find(At=>!At||typeof At!="object"||!((At.filename??"")===(ee.name??""))?!1:typeof ee.size=="number"&&typeof At.size=="number"?At.size===ee.size:!0);if(!(lt!=null&<.id))throw new Error(`File "${ee.name}" is not yet available on the server`);if(!lt.id||!lt.filename)throw new Error("Invalid file data received from server");U({id:lt.id,name:ee.name||lt.filename||`file_${lt.id}`,mimeType:ee.mimeType||lt.mime_type||"application/octet-stream"}),O(!0),Je.update({id:Je.id,title:"Success",description:`Opened ${ee.name}`,open:!0})}catch(Ke){console.error("Failed to fetch server file:",Ke);const lt=Ke instanceof Error?Ke.message:"Unknown error occurred";Je.update({id:Je.id,title:"Failed",description:lt}),_({title:"Failed to fetch file",description:lt,open:!0})}finally{L(Ke=>({...Ke,[xe]:!1}))}}}catch(Ee){console.error("File click error:",Ee),L(Se=>({...Se,[xe]:!1}))}},[V,D,_,A]),Fe=S.useCallback(()=>{const ee=J(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch($){case"user":return c.jsx(re.User,{className:ee});case"assistant":return c.jsx(re.Bot,{className:ee});case"tool":return c.jsx(re.Wrench,{className:ee});default:return c.jsx(re.Bot,{className:ee})}},[G,X,$]),Qe=S.useCallback(()=>{const ne="group relative mb-4 flex w-full";switch($){case"user":return J(ne,"justify-end");case"assistant":case"tool":case"system":return J(ne,"justify-start");default:return ne}},[$]),et=S.useCallback(()=>{const ne=J("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");switch($){case"user":return J(ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return J(ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return J(ne,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return J(ne,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return J(ne,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[G,$]),je=S.useCallback(async ne=>{try{const ee=ne.id||`interrupt-${Date.now()}`;await P(ee,!0)}catch(ee){console.error("Failed to approve interrupt:",ee)}},[P]),Oe=S.useCallback(async ne=>{try{const ee=ne.id||`interrupt-${Date.now()}`;await P(ee,!1)}catch(ee){console.error("Failed to reject interrupt:",ee)}},[P]),tt=S.useCallback(({part:ne,i:ee})=>{if(ne.type==="text"){const xe=ne.text??"",Ee=xe.trim(),Se=Zu(Ee);return Se&&$!=="tool"?c.jsx(Vw,{data:Se},ee):$==="user"&&f&&Ee.length>h?c.jsxs(zc,{open:T,onOpenChange:I,children:[c.jsx("div",{className:J("text-sm text-[hsl(var(--chat-bubble-user-text))]",G&&"text-xs"),children:T?c.jsx(Ni,{content:Ee,allowHtml:!1}):c.jsxs("pre",{className:J("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",G&&"text-xs"),children:[Ee.substring(0,h),"..."]})}),c.jsx(Bc,{asChild:!0,children:c.jsx(We,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ee.length-h," chars)"]})})})]},ee):c.jsx(Ni,{content:xe,allowHtml:!1},ee)}if(ne.type==="image_url"){const xe=ne;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:xe.url,alt:xe.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ee)}if(ne.type==="file"){const xe=ne,Ee=xe.name||"file";return c.jsxs("a",{href:xe.url,onClick:Se=>te(Se,xe,ee),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
125
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[D[ee]?c.jsx(re.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ee,D[ee]?" (processing)":""]})]},ee)}return ne.type==="interrupt"?c.jsx(qw,{interruptPart:ne,onApprove:je,onReject:Oe},ee):null},[te,D,je,Oe,$,f,h,T,G]),He=S.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),at=S.useCallback(()=>{const ne=pe.trim().length>0||fe.length>0||ye.length>0||we.length>0;if(!N&&!ne&&!r)return He();if(t.model==="reflection"){const ee=pe.trim(),xe=Zu(ee);if(xe&&typeof xe=="object")return c.jsx(Gw,{data:xe})}if(N&&le.name==="get_issues"){const ee=t.content.find(Se=>Se.type==="tool_end"),xe=(ee==null?void 0:ee.output)??z,Ee=ed(xe);if(Ee)return c.jsx(Yw,{issues:Ee})}if(N){const ee=zw(t.content);if(ee.length>0)return c.jsx("div",{className:"space-y-2",children:ee.map((xe,Ee)=>{const Se=typeof xe.output=="string"?xe.output:Ki(xe.output),Re=Se.length>qn?`${Se.slice(0,qn)}
|
|
126
|
+
… [truncated ${Se.length-qn} chars]`:Se,Je=E==="expanded";return c.jsxs(zc,{open:Je,onOpenChange:Ke=>C(Ke?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(yi,{variant:"outline",children:(xe.name??"tool")+(xe.toolCallId?` • ${xe.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Je?Re:Re.slice(0,d)+(Re.length>d?"...":"")})}),c.jsx(Bc,{asChild:!0,children:c.jsx(We,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:Je?c.jsxs(c.Fragment,{children:[" ",c.jsx(re.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(re.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},xe.toolCallId??Ee)})})}if(!N){const ee=c.jsx("div",{className:"space-y-2",children:t.content.map((xe,Ee)=>c.jsx(tt,{part:xe,i:Ee},Ee))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ee,c.jsx(Ww,{className:X})]}):ee}},[pe,fe.length,ye.length,we.length,r,t.model,N,le.name,z,E,u,He,X]),dt=S.useMemo(()=>Uw(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:J(Qe(),p.container),children:c.jsxs("div",{className:J(et(),p.content),children:[(i||a||N)&&c.jsxs("div",{className:J("flex items-center justify-between mb-2 pb-2 border-b border-current/10",G&&"mb-1 pb-1",X,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[Fe(),a&&dt&&c.jsx("span",{className:J("font-medium",G?"text-xs":"text-sm"),children:dt}),N&&le.name&&c.jsxs(yi,{variant:"outline",className:J("text-xs flex items-center gap-1 cursor-pointer",X,"border border-current/40",G&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E!=="collapsed",onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),C(ee=>ee==="collapsed"?"preview":"collapsed"))},onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:le.name}),c.jsx("span",{className:"inline-flex items-center",children:E!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})})]}),N&&!le.name&&c.jsx(We,{variant:"ghost",size:"sm",className:J("h-6 px-1",X,"hover:bg-foreground/10"),onClick:()=>C(ne=>ne==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E!=="collapsed"?c.jsx(re.ChevronUp,{className:"h-3 w-3"}):c.jsx(re.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:J("text-xs opacity-60",X,G&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:J("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>q(N?"visible":"all"),className:J("h-6 w-6 p-0 hover:bg-foreground/10",X,G&&"h-5 w-5"),"aria-label":N?"Copy visible":"Copy message",title:N?"Copy visible portion":"Copy message",children:c.jsx(re.Copy,{className:J(b?"text-success":X,G?"h-3 w-3":"h-4 w-4")})}),N&&c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>q("all"),className:J("h-6 px-1 text-xs hover:bg-foreground/10",X),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),$==="user"&&v&&c.jsx(We,{variant:"ghost",size:"sm",onClick:Z,className:J("h-6 w-6 p-0 hover:bg-foreground/10",X,G&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(re.Edit,{className:J(X,G?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&w&&c.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:J("h-6 w-6 p-0 hover:bg-foreground/10",X,G&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(re.RotateCcw,{className:J(X,G?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:at()}),N&&E==="expanded"&&(le.toolCallId||le.name)&&c.jsxs("div",{className:J("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[le.name&&c.jsxs("div",{children:["Function: ",le.name]}),le.toolCallId&&c.jsxs("div",{children:["Call ID: ",le.toolCallId]})]}),!(i||a||N)&&s&&!o&&c.jsxs("div",{className:J("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>q(),className:J("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(re.Copy,{className:J(b?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),$==="user"&&v&&c.jsx(We,{variant:"ghost",size:"sm",onClick:Z,className:J("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(re.Edit,{className:J("text-current",G?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&w&&c.jsx(We,{variant:"ghost",size:"sm",onClick:ce,className:J("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:c.jsx(re.RotateCcw,{className:J("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&c.jsx(Lw,{isOpen:F,onClose:()=>{O(!1),U(null)},fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&td(e.message)===td(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(v=>e[v]===t[v]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Vw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Qo,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children: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 c.jsxs("div",{className:Qo,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Qo,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:Kw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)})}function Kw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(zr(e))})}catch{return String(e)}}function qw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Dr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Lr,{className:"pb-3",children:[c.jsx(Fr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Hc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Uc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(We,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(We,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Gw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Yw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Qo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const rd=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,qi=S.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:x},b)=>{const y=S.useRef(null),E=S.useRef(null),C=S.useRef(!1),[T,I]=S.useState(!0),A=S.useCallback(D=>{I(D),g&&g(!D),x&&x(D)},[g,x]),P=S.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),_=S.useMemo(()=>!v||w?!1:T?"auto":!1,[T,v,w]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(yx,{ref:D=>{y.current=D},scrollerRef:D=>{E.current=D instanceof HTMLDivElement?D:null},data:e,followOutput:_,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{P&&P()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(D,L)=>rd(L,D),itemContent:(D,L)=>{const F=rd(L,D);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":F,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(nd,{message:L,messageIndex:D,isStreamingMessage:t&&n===L.id,streamingDebounceMs:r,isEditing:i===L.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(D),onCancelEdit:d})})}})})});qi.displayName="MessageList";const es=1e4;function Xw(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
127
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
133
128
|
|
|
134
129
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
|
|
@@ -136,4 +131,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
136
131
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
137
132
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
138
133
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
139
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Zw(e,t=es){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 Qw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Zw(t),Jw(t)}function Gi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=S.useRef(null),y=S.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:y,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=_n.createSlot(a),u=S.forwardRef((v,g)=>{const{scope:x,children:b}=v,y=s(a,x),k=Fe(g,y.collectionRef);return c.jsx(l,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=_n.createSlot(d),p=S.forwardRef((v,g)=>{const{scope:x,children:b,...y}=v,k=S.useRef(null),C=Fe(g,k),T=s(d,x);return S.useEffect(()=>(T.itemMap.set(k,{ref:k,...y}),()=>void T.itemMap.delete(k))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return S.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var eb=m.createContext(void 0);function ts(e){const t=m.useContext(eb);return e||t||"ltr"}const tb=["top","right","bottom","left"],En=Math.min,Rt=Math.max,ns=Math.round,rs=Math.floor,rn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Yi(e,t,n){return Rt(e,En(t,n))}function pn(e,t){return typeof e=="function"?e(t):e}function mn(e){return e.split("-")[0]}function cr(e){return e.split("-")[1]}function Xi(e){return e==="x"?"y":"x"}function Ji(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function on(e){return ob.has(mn(e))?"y":"x"}function Zi(e){return Xi(on(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=cr(e),o=Zi(e),s=Ji(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function ib(e){const t=os(e);return[Qi(e),t,Qi(t)]}function Qi(e){return e.replace(/start|end/g,t=>rb[t])}const ad=["left","right"],ld=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?ld:ad:t?ad:ld;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=cr(e);let s=cb(mn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Qi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>nb[t])}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function cd(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function ss(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 ud(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Zi(t),a=Ji(i),l=mn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(cr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const fb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ud(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y,data:k,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=y??f,p={...p,[g]:{...p[g],...k}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=ud(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=pn(t,e),w=cd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=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=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:y,strategy:l}):b);return{top:(x.top-C.top+w.top)/k.y,bottom:(C.bottom-x.bottom+w.bottom)/k.y,left:(x.left-C.left+w.left)/k.x,right:(C.right-x.right+w.right)/k.x}}const hb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=pn(e,t)||{};if(u==null)return{};const f=cd(d),h={x:n,y:r},p=Zi(o),w=Ji(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",k=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const A=k/2-C/2,R=I/2-v[w]/2-1,j=En(f[x],R),M=En(f[b],R),D=j,L=I-v[w]-M,P=I/2-v[w]/2+A,V=Yi(D,P,L),U=!l.arrow&&cr(o)!=null&&P!==V&&s.reference[w]/2-(P<D?j:M)-v[w]/2<0,q=U?P<D?P-D:P-L:0;return{[p]:h[p]+q,data:{[p]:V,centerOffset:P-V-q,...U&&{alignmentOffset:q}},reset:U}}}),pb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=pn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=mn(o),b=on(a),y=mn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(y||!v?[os(a)]:ib(a)),T=w!=="none";!h&&T&&C.push(...ub(a,v,w,k));const I=[a,...C],A=await Br(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[x]),f){const P=sb(o,i,k);R.push(A[P[0]],A[P[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(P=>P<=0)){var M,D;const P=(((M=s.flip)==null?void 0:M.index)||0)+1,V=I[P];if(V&&(!(f==="alignment"?b!==on(V):!1)||j.every(F=>on(F.placement)===b?F.overflows[0]>0:!0)))return{data:{index:P,overflows:j},reset:{placement:V}};let U=(D=j.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:D.placement;if(!U)switch(p){case"bestFit":{var L;const q=(L=j.filter(F=>{if(T){const N=on(F.placement);return N===b||N==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(N=>N>0).reduce((N,W)=>N+W,0)]).sort((F,N)=>F[1]-N[1])[0])==null?void 0:L[0];q&&(U=q);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function dd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fd(e){return tb.some(t=>e[t]>=0)}const mb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=pn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=dd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:fd(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=dd(s,n.floating);return{data:{escapedOffsets:i,escaped:fd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function gb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=mn(n),a=cr(n),l=on(n)==="y",u=hd.has(i)?-1:1,d=s&&l?-1:1,f=pn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const xb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await gb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},vb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=pn(e,t),u={x:n,y:r},d=await Br(t,l),f=on(mn(o)),h=Xi(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],y=p-d[x];p=Yi(b,p,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],y=w-d[x];w=Yi(b,w,y)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},wb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=pn(e,t),d={x:n,y:r},f=on(o),h=Xi(f);let p=d[h],w=d[f];const v=pn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const y=h==="y"?"height":"width",k=s.reference[h]-s.floating[y]+g.mainAxis,C=s.reference[h]+s.reference[y]-g.mainAxis;p<k?p=k:p>C&&(p=C)}if(u){var x,b;const y=h==="y"?"width":"height",k=hd.has(mn(o)),C=s.reference[f]-s.floating[y]+(k&&((x=i.offset)==null?void 0:x[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:p,[f]:w}}}},bb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=pn(e,t),d=await Br(t,u),f=mn(o),h=cr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,y=w-d.left-d.right,k=En(v-d[g],b),C=En(w-d[x],y),T=!t.middlewareData.shift;let I=k,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Rt(d.left,0),M=Rt(d.right,0),D=Rt(d.top,0),L=Rt(d.bottom,0);p?A=w-2*(j!==0||M!==0?j+M:Rt(d.left,d.right)):I=v-2*(D!==0||L!==0?D+L:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const R=await i.getDimensions(a.floating);return w!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function ur(e){return pd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(pd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pd(e){return is()?e instanceof Node||e instanceof Pt(e).Node:!1}function qt(e){return is()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return is()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function md(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Gt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!yb.has(o)}const Sb=new Set(["table","td","th"]);function Cb(e){return Sb.has(ur(e))}const Tb=[":popover-open",":modal"];function as(e){return Tb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Eb=["transform","translate","scale","rotate","perspective"],kb=["transform","translate","scale","rotate","perspective","filter"],Ib=["paint","layout","strict","content"];function ea(e){const t=ta(),n=qt(e)?Gt(e):e;return Eb.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)||kb.some(r=>(n.willChange||"").includes(r))||Ib.some(r=>(n.contain||"").includes(r))}function Nb(e){let t=kn(e);for(;an(t)&&!dr(t);){if(ea(t))return t;if(as(t))return null;t=kn(t)}return null}function ta(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function dr(e){return Ab.has(ur(e))}function Gt(e){return Pt(e).getComputedStyle(e)}function ls(e){return qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ur(e)==="html")return e;const t=e.assignedSlot||e.parentNode||md(e)&&e.host||sn(e);return md(t)?t.host:t}function gd(e){const t=kn(e);return dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&Hr(t)?t:gd(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=na(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xd(e){const t=Gt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ra(e){return qt(e)?e:e.contextElement}function fr(e){const t=ra(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=xd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const jb=rn(0);function vd(e){const t=Pt(e);return!ta()||!t.visualViewport?jb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _b(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ra(e);let i=rn(1);t&&(r?qt(r)&&(i=fr(r)):i=fr(e));const a=_b(s,n,r)?vd(s):rn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Pt(s),p=r&&qt(r)?Pt(r):r;let w=h,v=na(w);for(;v&&r&&p!==w;){const g=fr(v),x=v.getBoundingClientRect(),b=Gt(v),y=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,k=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=y,u+=k,w=Pt(v),v=na(w)}}return ss({width:d,height:f,x:l,y:u})}function oa(e,t){const n=ls(e).scrollLeft;return t?t.left+n:Wn(sn(e)).left+n}function wd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:oa(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Rb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((ur(r)!=="body"||Hr(i))&&(l=ls(r)),an(r))){const p=Wn(r);u=fr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?wd(i,l,!0):rn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Pb(e){return Array.from(e.getClientRects())}function Ob(e){const t=sn(e),n=ls(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+oa(e);const a=-n.scrollTop;return Gt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Mb(e,t){const n=Pt(e),r=sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=ta();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}const Db=new Set(["absolute","fixed"]);function Lb(e,t){const n=Wn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?fr(e):rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function bd(e,t,n){let r;if(t==="viewport")r=Mb(e,n);else if(t==="document")r=Ob(sn(e));else if(qt(t))r=Lb(t,n);else{const o=vd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function yd(e,t){const n=kn(e);return n===t||!qt(n)||dr(n)?!1:Gt(n).position==="fixed"||yd(n,t)}function Fb(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>qt(a)&&ur(a)!=="body"),o=null;const s=Gt(e).position==="fixed";let i=s?kn(e):e;for(;qt(i)&&!dr(i);){const a=Gt(i),l=ea(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||Hr(i)&&!l&&yd(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function $b(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:Fb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=bd(t,d,o);return u.top=Rt(f.top,u.top),u.right=En(f.right,u.right),u.bottom=En(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},bd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zb(e){const{width:t,height:n}=xd(e);return{width:t,height:n}}function Bb(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=Wn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=oa(o)}if(r||!r&&!s)if((ur(t)!=="body"||Hr(o))&&(a=ls(t)),r){const p=Wn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wd(o,a):rn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function sa(e){return Gt(e).position==="static"}function Sd(e,t){if(!an(e)||Gt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){const n=Pt(e);if(as(e))return n;if(!an(e)){let o=kn(e);for(;o&&!dr(o);){if(qt(o)&&!sa(o))return o;o=kn(o)}return n}let r=Sd(e,t);for(;r&&Cb(r)&&sa(r);)r=Sd(r,t);return r&&dr(r)&&sa(r)&&!ea(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:Bb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ub(e){return Gt(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:Rb,getDocumentElement:sn,getClippingRect:$b,getOffsetParent:Cd,getElementRects:Hb,getClientRects:Pb,getDimensions:zb,getScale:fr,isElement:qt,isRTL:Ub};function Td(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,r;const o=sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const w=rs(f),v=rs(o.clientWidth-(d+h)),g=rs(o.clientHeight-(f+p)),x=rs(d),y={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,En(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Td(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,y)}n.observe(e)}return i(!0),s}function Kb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ra(e),d=o||s?[...u?Ur(u):[],...Ur(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Vb(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,v=l?Wn(e):null;l&&g();function g(){const x=Wn(e);v&&!Td(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const qb=xb,Gb=vb,Yb=pb,Xb=bb,Jb=mb,Ed=hb,Zb=wb,Qb=(e,t,n)=>{const r=new Map,o={platform:Wb,...n},s={...o.platform,_c:r};return fb(e,t,{...o,platform:s})};var ey=typeof document<"u",ty=function(){},cs=ey?S.useLayoutEffect:ty;function us(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(!us(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)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function kd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Id(e,t){const n=kd(e);return Math.round(t*n)/n}function ia(e){const t=m.useRef(e);return cs(()=>{t.current=e}),t}function ny(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);us(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(F=>{F!==T.current&&(T.current=F,v(F))},[]),y=m.useCallback(F=>{F!==I.current&&(I.current=F,x(F))},[]),k=s||w,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),R=l!=null,j=ia(l),M=ia(o),D=ia(u),L=m.useCallback(()=>{if(!T.current||!I.current)return;const F={placement:t,strategy:n,middleware:h};M.current&&(F.platform=M.current),Qb(T.current,I.current,F).then(N=>{const W={...N,isPositioned:D.current!==!1};P.current&&!us(A.current,W)&&(A.current=W,eo.flushSync(()=>{f(W)}))})},[h,t,n,M,D]);cs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[u]);const P=m.useRef(!1);cs(()=>(P.current=!0,()=>{P.current=!1}),[]),cs(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(j.current)return j.current(k,C,L);L()}},[k,C,L,j,R]);const V=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:y}),[b,y]),U=m.useMemo(()=>({reference:k,floating:C}),[k,C]),q=m.useMemo(()=>{const F={position:n,left:0,top:0};if(!U.floating)return F;const N=Id(U.floating,d.x),W=Id(U.floating,d.y);return a?{...F,transform:"translate("+N+"px, "+W+"px)",...kd(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:W}},[n,a,U.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:V,elements:U,floatingStyles:q}),[d,L,V,U,q])}const ry=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Ed({element:r.current,padding:o}).fn(n):{}:r?Ed({element:r,padding:o}).fn(n):{}}}},oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Gb(e),options:[e,t]}),iy=(e,t)=>({...Zb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...ry(e),options:[e,t]});var dy="Arrow",Nd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Nd.displayName=dy;var fy=Nd;function Ad(e){const[t,n]=m.useState(void 0);return pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var aa="Popper",[jd,ds]=en(aa),[hy,_d]=jd(aa),Rd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(hy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Rd.displayName=aa;var Pd="PopperAnchor",Od=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_d(Pd,n),i=m.useRef(null),a=Fe(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(ye.div,{...o,ref:a})});Od.displayName=Pd;var la="PopperContent",[py,my]=jd(la),Md=m.forwardRef((e,t)=>{var B,O,G,Z,ce,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:w,...v}=e,g=_d(la,n),[x,b]=m.useState(null),y=Fe(t,De=>b(De)),[k,C]=m.useState(null),T=Ad(k),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(u)?u:[u],D=M.length>0,L={padding:j,boundary:M.filter(xy),altBoundary:D},{refs:P,floatingStyles:V,placement:U,isPositioned:q,middlewareData:F}=ny({strategy:"fixed",placement:R,whileElementsMounted:(...De)=>Kb(...De,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[oy({mainAxis:o+A,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...L}),l&&ay({...L}),ly({...L,apply:({elements:De,rects:Xe,availableWidth:Je,availableHeight:Ne})=>{const{width:Oe,height:Qe}=Xe.reference,Re=De.floating.style;Re.setProperty("--radix-popper-available-width",`${Je}px`),Re.setProperty("--radix-popper-available-height",`${Ne}px`),Re.setProperty("--radix-popper-anchor-width",`${Oe}px`),Re.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),k&&uy({element:k,padding:a}),vy({arrowWidth:I,arrowHeight:A}),h&&cy({strategy:"referenceHidden",...L})]}),[N,W]=Fd(U),Y=mt(w);pt(()=>{q&&(Y==null||Y())},[q,Y]);const de=(B=F.arrow)==null?void 0:B.x,se=(O=F.arrow)==null?void 0:O.y,pe=((G=F.arrow)==null?void 0:G.centerOffset)!==0,[ge,Se]=m.useState();return pt(()=>{x&&Se(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Z=F.transformOrigin)==null?void 0:Z.x,(ce=F.transformOrigin)==null?void 0:ce.y].join(" "),...((ie=F.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(py,{scope:n,placedSide:N,onArrowChange:C,arrowX:de,arrowY:se,shouldHideArrow:pe,children:c.jsx(ye.div,{"data-side":N,"data-align":W,...v,ref:y,style:{...v.style,animation:q?void 0:"none"}})})})});Md.displayName=la;var Dd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},Ld=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(Dd,r),i=gy[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(fy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ld.displayName=Dd;function xy(e){return e!==null}var vy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Fd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Fd(e){const[t,n="center"]=e.split("-");return[t,n]}var $d=Rd,zd=Od,Bd=Md,Hd=Ld,ca="rovingFocusGroup.onEntryFocus",wy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[ua,Ud,by]=Gi(Wr),[yy,Wd]=en(Wr,[by]),[Sy,Cy]=yy(Wr),Vd=m.forwardRef((e,t)=>c.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ty,{...e,ref:t})})}));Vd.displayName=Wr;var Ty=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Fe(t,h),w=ts(s),[v,g]=$n({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[x,b]=m.useState(!1),y=mt(u),k=Ud(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ca,y),()=>A.removeEventListener(ca,y)},[y]),c.jsx(Sy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:oe(e.onMouseDown,()=>{C.current=!0}),onFocus:oe(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!x){const j=new CustomEvent(ca,wy);if(A.currentTarget.dispatchEvent(j),!j.defaultPrevented){const M=k().filter(U=>U.focusable),D=M.find(U=>U.active),L=M.find(U=>U.id===v),V=[D,L,...M].filter(Boolean).map(U=>U.ref.current);Gd(V,d)}}C.current=!1}),onBlur:oe(e.onBlur,()=>b(!1))})})}),Kd="RovingFocusGroupItem",qd=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Cy(Kd,n),f=d.currentTabStopId===u,h=Ud(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(ua.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:oe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:oe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:oe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Iy(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(k=>k.focusable).map(k=>k.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const k=y.indexOf(g.currentTarget);y=d.loop?Ny(y,k+1):y.slice(k+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});qd.displayName=Kd;var Ey={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Iy(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ey[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ay=Vd,jy=qd,da=["Enter"," "],_y=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Ry=[..._y,...Yd],Py={ltr:[...da,"ArrowRight"],rtl:[...da,"ArrowLeft"]},Oy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,My,Dy]=Gi(Vr),[Vn,Xd]=en(Vr,[Dy,ds,Wd]),fs=ds(),Jd=Wd(),[Ly,Kn]=Vn(Vr),[Fy,qr]=Vn(Vr),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=fs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=ts(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx($d,{...a,children:c.jsx(Ly,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Fy,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Zd.displayName=Vr;var $y="MenuAnchor",fa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(zd,{...o,...r,ref:t})});fa.displayName=$y;var ha="MenuPortal",[zy,Qd]=Vn(ha,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Kn(ha,t);return c.jsx(zy,{scope:t,forceMount:n,children:c.jsx(_t,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:r})})})};ef.displayName=ha;var $t="MenuContent",[By,pa]=Vn($t),tf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Hy,{...o,ref:t}):c.jsx(Uy,{...o,ref:t})})})})}),Hy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(ma,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Uy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu);return c.jsx(ma,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wy=_n.createSlot("MenuContent.ScrollLock"),ma=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...v}=e,g=Kn($t,n),x=qr($t,n),b=fs(n),y=Jd(n),k=My(n),[C,T]=m.useState(null),I=m.useRef(null),A=Fe(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),M=m.useRef(0),D=m.useRef(null),L=m.useRef("right"),P=m.useRef(0),V=w?Vo:m.Fragment,U=w?{as:Wy,allowPinchZoom:!0}:void 0,q=N=>{var B,O;const W=j.current+N,Y=k().filter(G=>!G.disabled),de=document.activeElement,se=(B=Y.find(G=>G.ref.current===de))==null?void 0:B.textValue,pe=Y.map(G=>G.textValue),ge=n0(pe,W,se),Se=(O=Y.find(G=>G.textValue===ge))==null?void 0:O.ref.current;(function G(Z){j.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>G(""),1e3))})(W),Se&&setTimeout(()=>Se.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Di();const F=m.useCallback(N=>{var Y,de;return L.current===((Y=D.current)==null?void 0:Y.side)&&o0(N,(de=D.current)==null?void 0:de.area)},[]);return c.jsx(By,{scope:n,searchRef:j,onItemEnter:m.useCallback(N=>{F(N)&&N.preventDefault()},[F]),onItemLeave:m.useCallback(N=>{var W;F(N)||((W=I.current)==null||W.focus(),T(null))},[F]),onTriggerLeave:m.useCallback(N=>{F(N)&&N.preventDefault()},[F]),pointerGraceTimerRef:M,onPointerGraceIntentChange:m.useCallback(N=>{D.current=N},[]),children:c.jsx(V,{...U,children:c.jsx(Fo,{asChild:!0,trapped:o,onMountAutoFocus:oe(s,N=>{var W;N.preventDefault(),(W=I.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Ay,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:oe(l,N=>{x.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Bd,{role:"menu","aria-orientation":"vertical","data-state":wf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:oe(v.onKeyDown,N=>{const Y=N.target.closest("[data-radix-menu-content]")===N.currentTarget,de=N.ctrlKey||N.altKey||N.metaKey,se=N.key.length===1;Y&&(N.key==="Tab"&&N.preventDefault(),!de&&se&&q(N.key));const pe=I.current;if(N.target!==pe||!Ry.includes(N.key))return;N.preventDefault();const Se=k().filter(B=>!B.disabled).map(B=>B.ref.current);Yd.includes(N.key)&&Se.reverse(),e0(Se)}),onBlur:oe(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:oe(e.onPointerMove,Yr(N=>{const W=N.target,Y=P.current!==N.clientX;if(N.currentTarget.contains(W)&&Y){const de=N.clientX>P.current?"right":"left";L.current=de,P.current=N.clientX}}))})})})})})})});tf.displayName=$t;var Vy="MenuGroup",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});ga.displayName=Vy;var Ky="MenuLabel",nf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});nf.displayName=Ky;var hs="MenuItem",rf="menu.itemSelect",ps=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=qr(hs,e.__scopeMenu),a=pa(hs,e.__scopeMenu),l=Fe(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,p=>r==null?void 0:r(p),{once:!0}),$c(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(of,{...o,ref:l,disabled:n,onClick:oe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:oe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:oe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||da.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ps.displayName=hs;var of=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pa(hs,n),a=Jd(n),l=m.useRef(null),u=Fe(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(jy,{asChild:!0,...a,focusable:!r,children:c.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:oe(e.onPointerMove,Yr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:oe(e.onPointerLeave,Yr(w=>i.onItemLeave(w))),onFocus:oe(e.onFocus,()=>f(!0)),onBlur:oe(e.onBlur,()=>f(!1))})})})}),qy="MenuCheckboxItem",sf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(df,{scope:e.__scopeMenu,checked:n,children:c.jsx(ps,{role:"menuitemcheckbox","aria-checked":ms(n)?"mixed":n,...o,ref:t,"data-state":va(n),onSelect:oe(o.onSelect,()=>r==null?void 0:r(ms(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=qy;var af="MenuRadioGroup",[Gy,Yy]=Vn(af,{value:void 0,onValueChange:()=>{}}),lf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(Gy,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ga,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Yy(cf,e.__scopeMenu),s=n===o.value;return c.jsx(df,{scope:e.__scopeMenu,checked:s,children:c.jsx(ps,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":va(s),onSelect:oe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var xa="MenuItemIndicator",[df,Xy]=Vn(xa,{checked:!1}),ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Xy(xa,n);return c.jsx(_t,{present:r||ms(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":va(s.checked)})})});ff.displayName=xa;var Jy="MenuSeparator",hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=Jy;var Zy="MenuArrow",pf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(Hd,{...o,...r,ref:t})});pf.displayName=Zy;var Qy="MenuSub",[LC,mf]=Vn(Qy),Gr="MenuSubTrigger",gf=m.forwardRef((e,t)=>{const n=Kn(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=mf(Gr,e.__scopeMenu),s=pa(Gr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(fa,{asChild:!0,...u,children:c.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:Si(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:oe(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,Yr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Py[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});gf.displayName=Gr;var xf="MenuSubContent",vf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu),a=mf(xf,e.__scopeMenu),l=m.useRef(null),u=Fe(t,l);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:c.jsx(ma,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:oe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:oe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Oy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});vf.displayName=xf;function wf(e){return e?"open":"closed"}function ms(e){return e==="indeterminate"}function va(e){return ms(e)?"indeterminate":e?"checked":"unchecked"}function e0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function t0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function n0(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=t0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function r0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function o0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return r0(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var s0=Zd,i0=fa,a0=ef,l0=tf,c0=ga,u0=nf,d0=ps,f0=sf,h0=lf,p0=uf,m0=ff,g0=hf,x0=pf,v0=gf,w0=vf,gs="DropdownMenu",[b0,FC]=en(gs,[Xd]),yt=Xd(),[y0,bf]=b0(gs),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=yt(t),u=m.useRef(null),[d,f]=$n({prop:o,defaultProp:s??!1,onChange:i,caller:gs});return c.jsx(y0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(s0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=gs;var Sf="DropdownMenuTrigger",Cf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(Sf,n),i=yt(n);return c.jsx(i0,{asChild:!0,...i,children:c.jsx(ye.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:Si(t,s.triggerRef),onPointerDown:oe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:oe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var S0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return c.jsx(a0,{...r,...n})};Tf.displayName=S0;var Ef="DropdownMenuContent",kf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Ef,n),s=yt(n),i=m.useRef(!1);return c.jsx(l0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:oe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:oe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kf.displayName=Ef;var C0="DropdownMenuGroup",T0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(c0,{...o,...r,ref:t})});T0.displayName=C0;var E0="DropdownMenuLabel",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(u0,{...o,...r,ref:t})});If.displayName=E0;var k0="DropdownMenuItem",Nf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(d0,{...o,...r,ref:t})});Nf.displayName=k0;var I0="DropdownMenuCheckboxItem",Af=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(f0,{...o,...r,ref:t})});Af.displayName=I0;var N0="DropdownMenuRadioGroup",A0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(h0,{...o,...r,ref:t})});A0.displayName=N0;var j0="DropdownMenuRadioItem",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(p0,{...o,...r,ref:t})});jf.displayName=j0;var _0="DropdownMenuItemIndicator",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(m0,{...o,...r,ref:t})});_f.displayName=_0;var R0="DropdownMenuSeparator",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(g0,{...o,...r,ref:t})});Rf.displayName=R0;var P0="DropdownMenuArrow",O0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(x0,{...o,...r,ref:t})});O0.displayName=P0;var M0="DropdownMenuSubTrigger",Pf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(v0,{...o,...r,ref:t})});Pf.displayName=M0;var D0="DropdownMenuSubContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(w0,{...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)"}})});Of.displayName=D0;var L0=yf,F0=Cf,$0=Tf,Mf=kf,Df=If,Lf=Nf,Ff=Af,$f=jf,zf=_f,Bf=Rf,Hf=Pf,Uf=Of;const z0=L0,B0=F0,H0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Hf,{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,c.jsx(ee.ChevronRight,{className:"ml-auto h-4 w-4"})]}));H0.displayName=Hf.displayName;const U0=m.forwardRef(({className:e,...t},n)=>c.jsx(Uf,{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}));U0.displayName=Uf.displayName;const Wf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx($0,{children:c.jsx(Mf,{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})}));Wf.displayName=Mf.displayName;const wa=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Lf,{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}));wa.displayName=Lf.displayName;const W0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Ff,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),t]}));W0.displayName=Ff.displayName;const V0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs($f,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));V0.displayName=$f.displayName;const K0=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Df,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));K0.displayName=Df.displayName;const q0=m.forwardRef(({className:e,...t},n)=>c.jsx(Bf,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));q0.displayName=Bf.displayName;function xs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:w}=qs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:y}=ho(),{messages:k,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:A,loadOlderMessages:R}=Js(),{isStreaming:j,error:M,streamingAssistantId:D,lastCheckpointId:L,lastCheckpointNs:P}=Fl(),[V,U]=S.useState(null),[q,F]=S.useState(""),[N,W]=S.useState(null),[Y,de]=S.useState([]),[se,pe]=S.useState(0),[ge,Se]=S.useState(0),[B,O]=S.useState(!1),[G,Z]=S.useState(null),[ce,ie]=S.useState(null),[De,Xe]=S.useState(!1),[Je,Ne]=S.useState(null),[Oe,Qe]=S.useState([]),[Re,st]=S.useState(null),[ct,Q]=S.useState(null),[le,me]=S.useState(!1),Ce=S.useRef(null),we=S.useRef(null),_e=S.useRef(null),et=S.useCallback(()=>{Ce.current&&(Ce.current.value=""),we.current&&(we.current.value=""),pe(ae=>ae+1),Se(ae=>ae+1)},[]),Ke=S.useRef(!1);S.useEffect(()=>{Ke.current&&!j&&(de([]),et()),Ke.current=j},[j,et]);const[$,J]=S.useState("desktop");S.useEffect(()=>{const ae=()=>{const xe=window.innerWidth;J(xe<640?"phone":xe<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),S.useEffect(()=>{let ae=!1;if(!v){Qe([]),st(null),Q(null),_e.current=null;return}const xe={threadId:v,checkpointId:L??null,checkpointNs:P??null},Be=_e.current;if(!(Be&&Be.threadId===xe.threadId&&Be.checkpointId===xe.checkpointId&&Be.checkpointNs===xe.checkpointNs))return x(v).then(ot=>{var js;if(ae)return;const Mt=((ot==null?void 0:ot.checkpoints)??[]).slice().sort((gn,E)=>new Date(E.createdAt).getTime()-new Date(gn.createdAt).getTime());Qe(Mt);const dn=Re,Zr=dn&&Mt.some(gn=>gn.checkpointId===dn)?dn:((js=Mt[0])==null?void 0:js.checkpointId)??null;let As=null;if(Zr){const gn=Mt.find(E=>E.checkpointId===Zr);As=(gn==null?void 0:gn.checkpointNs)??null}st(Zr),Q(As),_e.current=xe}).catch(ot=>{console.error("ChatInterface - listCheckpoints error:",ot),ae||(Qe([]),_e.current=null)}),()=>{ae=!0}},[v,L,P,Re,x]),S.useEffect(()=>{L&&(st(L),Q(P??null))},[L,P]);const Te=S.useCallback(async()=>{if(!(!C||T))try{await R()}catch(ae){console.warn("loadOlderMessages failed",ae)}},[C,T,R]);S.useEffect(()=>{(async()=>{if(!w.baseUrl){Ne(null);return}try{const xe=await w.getAgent("default");Ne(xe.uiDefaultMessage||null)}catch(xe){console.warn("Failed to fetch default message:",xe),Ne(null)}})()},[w]),S.useEffect(()=>{M&&!De&&(p==null||p(M))},[M,De,p]);const Me=ae=>{if(ae.length>es)return`Message too long (${ae.length}/${es} characters)`;try{return Qw(ae),null}catch(xe){return(xe==null?void 0:xe.message)||"Invalid message"}},Le=async ae=>{const xe=ae.trim();if(!(!xe&&Y.length===0)){if(xe){const Be=Me(xe);if(Be){W(Be);return}}try{await I(xe||"",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,payloadExtras:V?{edit:!0,originalMessageId:V}:void 0,attachments:Y}),f==null||f(xe),W(null),de([]),et(),U(null),F("")}catch(Be){const ot=(Be==null?void 0:Be.message)||"Failed to send message";W(ot),p==null||p(ot)}}},it=S.useCallback((ae,xe)=>{u&&(U(ae),F(xe),W(null))},[u]),Ot=S.useCallback(()=>{U(null),F(""),W(null)},[]),gr=S.useCallback((ae,xe)=>{it(ae,xe)},[it]),Xn=S.useCallback(ae=>{const xe=Be=>{const ot=Be.content||[],Mt=ot.filter(dn=>dn.type==="text").map(dn=>dn.text).join("");if(Mt)return Mt;try{return JSON.stringify(ot,null,2)}catch{return String(ot)}};for(let Be=ae-1;Be>=0;Be--)if(k[Be].role==="user"){const ot=xe(k[Be]);ot&&I(ot,{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0});break}},[k,I,Re,ct,L,P]),xr=ae=>{const xe=Array.from(ae.target.files||[]);de(Be=>[...Be,...xe]),ae.target.value=""},cn=ae=>{de(xe=>{const Be=xe.filter((ot,Mt)=>ae!==Mt);return Be.length===0&&et(),Be})},Jn=async ae=>{const xe=(ae.target.files||[])[0];if(xe){Z(null),ie(null),O(!0);try{await I("",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,attachments:[xe]});const Be=`Uploaded ${xe.name} - processing through chat stream`;ie(Be)}catch(Be){const ot=Be instanceof Error?Be.message:"Failed to upload Excel file";console.error("Excel upload failed",Be),Z(ot),p==null||p(ot)}finally{O(!1),ae.target.value="",et()}}},jn=ae=>{if(!ae)return"Unknown";const xe=Date.parse(ae);return Number.isNaN(xe)?ae:new Date(xe).toLocaleString()},un=async ae=>{if(v){me(!0);try{if(!ae){await y(),st(null),Q(null);return}const xe=Oe.find(ot=>ot.checkpointId===ae),Be=(xe==null?void 0:xe.checkpointNs)??null;await b(ae,Be),st(ae),Q(Be)}finally{me(!1)}}},Ns=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Jr=`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||""}`,Oa=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Ns,children:[!!M&&!De&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:M}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>Xe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ee.X,{size:16})})]}),v&&Oe.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Re??"",onChange:ae=>{const xe=ae.target.value||null;un(xe)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(ae=>c.jsxs("option",{value:ae.checkpointId,children:[jn(ae.createdAt),ae.preview?` — ${ae.preview.slice(0,40)}`:""]},ae.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Jr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(qi,{className:"h-full",style:{height:"100%"},messages:k,isStreaming:j,streamingAssistantId:D,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:$,enableMessageEditing:u,editingMessageId:V,onStartReached:()=>{Te()},onEdit:gr,onRegenerate:Xn,onCancelEdit:Ot,emptyMessage:Je??void 0,isNavigatingCheckpoint:le}),g&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Oa,children:[V&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ee.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Ot,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ee.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Ce,type:"file",multiple:!0,onChange:ae=>xr(ae),className:"hidden"},se),Y.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((ae,xe)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ee.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>cn(xe),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 ${ae.name}`,children:c.jsx(ee.X,{size:12})})]},xe))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:we,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Jn,className:"hidden"},ge),B&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ce&&!B&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ce}),G&&!B&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),N&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:N}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(z0,{children:[c.jsx(B0,{asChild:!0,children:c.jsx(Ue,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:c.jsx(ee.Plus,{size:16})})}),c.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(wa,{onClick:()=>{var ae;return(ae=Ce.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(ee.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(wa,{onClick:()=>{var ae;B||(ae=we.current)==null||ae.click()},className:`cursor-pointer ${B?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ee.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(fg,{initialValue:q,editingMessageId:V,placeholder:V?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:es,onSend:Le,onCancelEdit:Ot,onStop:A,allowEmptySend:Y.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${N?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const vs=m.forwardRef(({className:e,type:t,...n},r)=>c.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}));vs.displayName="Input";function ba(e,[t,n]){return Math.min(n,Math.max(t,e))}function G0(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ya="ScrollArea",[Vf,$C]=en(ya),[Y0,zt]=Vf(ya),Kf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[y,k]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),R=Fe(t,M=>l(M)),j=ts(o);return c.jsx(Y0,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:c.jsx(ye.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=ya;var qf="ScrollAreaViewport",Gf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(qf,n),a=m.useRef(null),l=Fe(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var ln="ScrollAreaScrollbar",Sa=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(X0,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(J0,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ca,{...r,ref:t}):null});Sa.displayName=ln;var X0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(_t,{present:n||s,children:c.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),J0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ss(()=>l("SCROLL_END"),100),[a,l]=G0("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(_t,{present:n||a!=="hidden",children:c.jsx(Ca,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:oe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:oe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yf=m.forwardRef((e,t)=>{const n=zt(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Ss(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return hr(n.viewport,l),hr(n.content,l),c.jsx(_t,{present:r||s,children:c.jsx(Ca,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ca=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(ln,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return rS(h,i.current,a,p)}return n==="horizontal"?c.jsx(Z0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=th(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(Q0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=th(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),Z0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"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":ys(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),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:bs(i.paddingLeft),paddingEnd:bs(i.paddingRight)}})}})}),Q0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"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":ys(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),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:bs(i.paddingTop),paddingEnd:bs(i.paddingBottom)}})}})}),[eS,Xf]=Vf(ln),Jf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=zt(ln,n),[w,v]=m.useState(null),g=Fe(t,R=>v(R)),x=m.useRef(null),b=m.useRef(""),y=p.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),I=Ss(f,10);function A(R){if(x.current){const j=R.clientX-x.current.left,M=R.clientY-x.current.top;u({x:j,y:M})}}return m.useEffect(()=>{const R=j=>{const M=j.target;(w==null?void 0:w.contains(M))&&C(j,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[y,w,k,C]),m.useEffect(T,[r,T]),hr(w,I),hr(p.content,I),c.jsx(eS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:c.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:oe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:oe(e.onPointerMove,A),onPointerUp:oe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),ws="ScrollAreaThumb",Zf=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(ws,e.__scopeScrollArea);return c.jsx(_t,{present:n||o.hasThumb,children:c.jsx(tS,{ref:t,...r})})}),tS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(ws,n),i=Xf(ws,n),{onThumbPositionChange:a}=i,l=Fe(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Ss(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=oS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:oe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:oe(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=ws;var Ta="ScrollAreaCorner",Qf=m.forwardRef((e,t)=>{const n=zt(Ta,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(nS,{...e,ref:t}):null});Qf.displayName=Ta;var nS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(Ta,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(ye.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 bs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function ys(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rS(e,t,n,r="ltr"){const o=ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return nh([l,u],f)(e)}function th(e,t,n="ltr"){const r=ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=ba(e,l);return nh([0,i],[0,a])(u)}function nh(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 rh(e,t){return e>0&&e<t}var oS=(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 Ss(e,t){const n=mt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function hr(e,t){const n=mt(t);pt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var oh=Kf,sS=Gf,iS=Qf;const sh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(oh,{ref:r,className:X("relative overflow-hidden",e),...n,children:[c.jsx(sS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ih,{}),c.jsx(iS,{})]}));sh.displayName=oh.displayName;const ih=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Sa,{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:c.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=Sa.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:l,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=ho(),[b,y]=S.useState(h??[]),[k,C]=S.useState(null),[T,I]=S.useState(""),[A,R]=S.useState(!1);S.useEffect(()=>{y(h??[])},[h]);const j=async N=>{try{await f(N),a==null||a(N),l==null||l(N)}catch(W){console.error("Failed to select thread:",W)}},M=async()=>{try{R(!0);const N=await w();u==null||u(N),a==null||a(N)}catch(N){console.error("Failed to create thread:",N)}finally{R(!1)}},D=async(N,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await v(N),d==null||d(N)}catch(Y){console.error("Failed to delete thread:",Y)}},L=(N,W)=>{W.stopPropagation(),C(N.threadId),I(N.title||`Thread ${N.threadId.slice(0,8)}`)},P=async N=>{if(T.trim())try{await g(N,T.trim()),C(null),I("")}catch(W){console.error("Failed to update title:",W)}},V=()=>{C(null),I("")},U=(N,W)=>{N.key==="Enter"?P(W):N.key==="Escape"&&V()},q=N=>{if(!N)return"";try{const W=new Date(N),de=new Date().getTime()-W.getTime(),se=Math.floor(de/(1e3*60*60*24));return se===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):se===1?"Yesterday":se<7?`${se} days ago`:W.toLocaleDateString()}catch{return""}},F=N=>N.title||`Thread ${N.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ue,{onClick:M,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(ee.MessageSquarePlus,{size:20})})}),c.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ee.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ee.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((N,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(N.updatedAt||N.createdAt||"").getTime()).map(N=>c.jsxs("div",{onClick:()=>j(N.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===N.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===N.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[c.jsx(vs,{value:T,onChange:W=>I(W.target.value),onKeyDown:W=>U(W,N.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>P(N.threadId),className:"h-6 w-6 p-0",children:c.jsx(ee.Check,{size:12})}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:c.jsx(ee.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:F(N)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ee.Calendar,{size:10}),c.jsx("span",{children:q(N.updatedAt||N.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==N.threadId&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>L(N,W),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ee.Edit3,{size:12})}),n&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>D(N.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ee.Trash2,{size:12})})]})]}),i===N.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},N.threadId))})})]})}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function aS(e){if(typeof e!="string")return;const t=e.trim();if(t)return fn(t)}function ah(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e){const n=aS(t);if(n)return n}}function lh(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ch(...e){for(const t of e)if(typeof t=="string"&&t.trim())return fn(t);return fn()}function uh(){const e={},t=ah(),n=lh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function dh(){const e=uh(),t=xn.getAuthToken(),n=ah();return{apiBaseUrl:ch(e.baseUrl,xn.baseUrl,n),apiKey:t||e.apiKey||lh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const fh="chat-settings";function lS(){try{const e=localStorage.getItem(fh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function cS(e){try{const t={...e,apiBaseUrl:fn(e.apiBaseUrl)};localStorage.setItem(fh,JSON.stringify(t)),t.apiKey&&xn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function uS(){const e=dh(),t=lS(),n=xn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ch(xn.baseUrl,r,e.apiBaseUrl)}}function dS(e){xn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),cS(e)}var fS="Label",hh=m.forwardRef((e,t)=>c.jsx(ye.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())}}));hh.displayName=fS;var ph=hh;const hS=Qr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=m.forwardRef(({className:e,...t},n)=>c.jsx(ph,{ref:n,className:X(hS(),e),...t}));Bt.displayName=ph.displayName;function mh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Cs="Switch",[pS,zC]=en(Cs),[mS,gS]=pS(Cs),gh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=Fe(t,y=>p(y)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=$n({prop:o,defaultProp:s??!1,onChange:u,caller:Cs});return c.jsxs(mS,{scope:n,checked:x,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":bh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:oe(e.onClick,y=>{b(k=>!k),g&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),g&&c.jsx(wh,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});gh.displayName=Cs;var xh="SwitchThumb",vh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=gS(xh,n);return c.jsx(ye.span,{"data-state":bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});vh.displayName=xh;var xS="SwitchBubbleInput",wh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Fe(i,s),l=mh(n),u=Ad(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wh.displayName=xS;function bh(e){return e?"checked":"unchecked"}var yh=gh,vS=vh;const In=m.forwardRef(({className:e,...t},n)=>c.jsx(yh,{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:c.jsx(vS,{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")})}));In.displayName=yh.displayName;var Sh=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"}),wS="VisuallyHidden",bS=m.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...Sh,...e.style}}));bS.displayName=wS;var yS=[" ","Enter","ArrowUp","ArrowDown"],SS=[" ","Enter"],qn="Select",[Ts,Es,CS]=Gi(qn),[mr,BC]=en(qn,[CS,ds]),ks=ds(),[TS,Nn]=mr(qn),[ES,kS]=mr(qn),Ch=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:w}=e,v=ks(t),[g,x]=m.useState(null),[b,y]=m.useState(null),[k,C]=m.useState(!1),T=ts(u),[I,A]=$n({prop:r,defaultProp:o??!1,onChange:s,caller:qn}),[R,j]=$n({prop:i,defaultProp:a,onChange:l,caller:qn}),M=m.useRef(null),D=g?w||!!g.closest("form"):!0,[L,P]=m.useState(new Set),V=Array.from(L).map(U=>U.props.value).join(";");return c.jsx($d,{...v,children:c.jsxs(TS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:tn(),value:R,onValueChange:j,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[c.jsx(Ts.Provider,{scope:t,children:c.jsx(ES,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(U=>{P(q=>new Set(q).add(U))},[]),onNativeOptionRemove:m.useCallback(U=>{P(q=>{const F=new Set(q);return F.delete(U),F})},[]),children:n})}),D?c.jsxs(qh,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:U=>j(U.target.value),disabled:h,form:w,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(L)]},V):null]})})};Ch.displayName=qn;var Th="SelectTrigger",Eh=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ks(n),i=Nn(Th,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),u=Es(n),d=m.useRef("touch"),[f,h,p]=Yh(v=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),b=Xh(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(zd,{asChild:!0,...s,children:c.jsx(ye.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":Gh(i.value)?"":void 0,...o,ref:l,onClick:oe(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:oe(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:oe(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&yS.includes(v.key)&&(w(),v.preventDefault())})})})});Eh.displayName=Th;var kh="SelectValue",Ih=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Nn(kh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Fe(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Gh(l.value)?c.jsx(c.Fragment,{children:i}):s})});Ih.displayName=kh;var IS="SelectIcon",Nh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Nh.displayName=IS;var NS="SelectPortal",Ah=e=>c.jsx($o,{asChild:!0,...e});Ah.displayName=NS;var Gn="SelectContent",jh=m.forwardRef((e,t)=>{const n=Nn(Gn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(c.jsx(_h,{scope:e.__scopeSelect,children:c.jsx(Ts.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Rh,{...e,ref:t})});jh.displayName=Gn;var Yt=10,[_h,An]=mr(Gn),AS="SelectContentImpl",jS=_n.createSlot("SelectContent.RemoveScroll"),Rh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=Nn(Gn,n),[y,k]=m.useState(null),[C,T]=m.useState(null),I=Fe(t,B=>k(B)),[A,R]=m.useState(null),[j,M]=m.useState(null),D=Es(n),[L,P]=m.useState(!1),V=m.useRef(!1);m.useEffect(()=>{if(y)return Hi(y)},[y]),Di();const U=m.useCallback(B=>{const[O,...G]=D().map(ie=>ie.ref.current),[Z]=G.slice(-1),ce=document.activeElement;for(const ie of B)if(ie===ce||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===O&&C&&(C.scrollTop=0),ie===Z&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==ce))return},[D,C]),q=m.useCallback(()=>U([A,y]),[U,A,y]);m.useEffect(()=>{L&&q()},[L,q]);const{onOpenChange:F,triggerPointerDownPosRef:N}=b;m.useEffect(()=>{if(y){let B={x:0,y:0};const O=Z=>{var ce,ie;B={x:Math.abs(Math.round(Z.pageX)-(((ce=N.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ie=N.current)==null?void 0:ie.y)??0))}},G=Z=>{B.x<=10&&B.y<=10?Z.preventDefault():y.contains(Z.target)||F(!1),document.removeEventListener("pointermove",O),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",G,{capture:!0})}}},[y,F,N]),m.useEffect(()=>{const B=()=>F(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[F]);const[W,Y]=Yh(B=>{const O=D().filter(ce=>!ce.disabled),G=O.find(ce=>ce.ref.current===document.activeElement),Z=Xh(O,B,G);Z&&setTimeout(()=>Z.ref.current.focus())}),de=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&(R(B),Z&&(V.current=!0))},[b.value]),se=m.useCallback(()=>y==null?void 0:y.focus(),[y]),pe=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&M(B)},[b.value]),ge=r==="popper"?ka:Ph,Se=ge===ka?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(_h,{scope:n,content:y,viewport:C,onViewportChange:T,itemRefCallback:de,selectedItem:A,onItemLeave:se,itemTextRefCallback:pe,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:L,searchRef:W,children:c.jsx(Vo,{as:jS,allowPinchZoom:!0,children:c.jsx(Fo,{asChild:!0,trapped:b.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:oe(o,B=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),B.preventDefault()}),children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:B=>B.preventDefault(),...x,...Se,onPlaced:()=>P(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:oe(x.onKeyDown,B=>{const O=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!O&&B.key.length===1&&Y(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let Z=D().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(B.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const ce=B.target,ie=Z.indexOf(ce);Z=Z.slice(ie+1)}setTimeout(()=>U(Z)),B.preventDefault()}})})})})})})});Rh.displayName=AS;var _S="SelectItemAlignedPosition",Ph=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Nn(Gn,n),i=An(Gn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Fe(t,I=>d(I)),h=Es(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,y=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-A.left,ie=R.left-ce,De=I.left-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.left=Oe+"px"}else{const ce=A.right-j.right,ie=window.innerWidth-R.right-ce,De=window.innerWidth-I.right-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.right=Oe+"px"}const M=h(),D=window.innerHeight-Yt*2,L=v.scrollHeight,P=window.getComputedStyle(u),V=parseInt(P.borderTopWidth,10),U=parseInt(P.paddingTop,10),q=parseInt(P.borderBottomWidth,10),F=parseInt(P.paddingBottom,10),N=V+U+L+F+q,W=Math.min(g.offsetHeight*5,N),Y=window.getComputedStyle(v),de=parseInt(Y.paddingTop,10),se=parseInt(Y.paddingBottom,10),pe=I.top+I.height/2-Yt,ge=D-pe,Se=g.offsetHeight/2,B=g.offsetTop+Se,O=V+U+B,G=N-O;if(O<=pe){const ce=M.length>0&&g===M[M.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-v.offsetTop-v.offsetHeight,De=Math.max(ge,Se+(ce?se:0)+ie+q),Xe=O+De;a.style.height=Xe+"px"}else{const ce=M.length>0&&g===M[0].ref.current;a.style.top="0px";const De=Math.max(pe,V+v.offsetTop+(ce?de:0)+Se)+G;a.style.height=De+"px",v.scrollTop=O-pe+v.offsetTop}a.style.margin=`${Yt}px 0`,a.style.minHeight=W+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>y(),[y]);const[k,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&w.current===!0&&(y(),b==null||b(),w.current=!1)},[y,b]);return c.jsx(PS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:c.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ph.displayName=_S;var RS="SelectPopperPosition",ka=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Yt,...s}=e,i=ks(n);return c.jsx(Bd,{...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)"}})});ka.displayName=RS;var[PS,Ia]=mr(Gn,{}),Na="SelectViewport",Oh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=An(Na,n),i=Ia(Na,n),a=Fe(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Ts.Slot,{scope:n,children:c.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:oe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const w=window.innerHeight-Yt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,y=Math.min(w,b),k=b-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Oh.displayName=Na;var Mh="SelectGroup",[OS,MS]=mr(Mh),DS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(OS,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});DS.displayName=Mh;var Dh="SelectLabel",Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=MS(Dh,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Lh.displayName=Dh;var Is="SelectItem",[LS,Fh]=mr(Is),$h=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Nn(Is,n),l=An(Is,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Fe(t,b=>{var y;return(y=l.itemRefCallback)==null?void 0:y.call(l,b,r,o)}),v=tn(),g=m.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(LS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(y=>y||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ts.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:oe(i.onFocus,()=>p(!0)),onBlur:oe(i.onBlur,()=>p(!1)),onClick:oe(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:oe(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:oe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:oe(i.onPointerMove,b=>{var y;g.current=b.pointerType,o?(y=l.onItemLeave)==null||y.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:oe(i.onPointerLeave,b=>{var y;b.currentTarget===document.activeElement&&((y=l.onItemLeave)==null||y.call(l))}),onKeyDown:oe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(SS.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});$h.displayName=Is;var Xr="SelectItemText",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Nn(Xr,n),a=An(Xr,n),l=Fh(Xr,n),u=kS(Xr,n),[d,f]=m.useState(null),h=Fe(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(ye.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});zh.displayName=Xr;var Bh="SelectItemIndicator",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Fh(Bh,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Hh.displayName=Bh;var Aa="SelectScrollUpButton",Uh=m.forwardRef((e,t)=>{const n=An(Aa,e.__scopeSelect),r=Ia(Aa,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Uh.displayName=Aa;var ja="SelectScrollDownButton",Wh=m.forwardRef((e,t)=>{const n=An(ja,e.__scopeSelect),r=Ia(ja,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Wh.displayName=ja;var Vh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=An("SelectScrollButton",n),i=m.useRef(null),a=Es(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:oe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:oe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:oe(o.onPointerLeave,()=>{l()})})}),FS="SelectSeparator",Kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Kh.displayName=FS;var _a="SelectArrow",$S=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ks(n),s=Nn(_a,n),i=An(_a,n);return s.open&&i.position==="popper"?c.jsx(Hd,{...o,...r,ref:t}):null});$S.displayName=_a;var zS="SelectBubbleInput",qh=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Fe(r,o),i=mh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(ye.select,{...n,style:{...Sh,...n.style},ref:s,defaultValue:t})});qh.displayName=zS;function Gh(e){return e===""||e===void 0}function Yh(e){const t=mt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Xh(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=BS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function BS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var HS=Ch,Jh=Eh,US=Ih,WS=Nh,VS=Ah,Zh=jh,KS=Oh,Qh=Lh,ep=$h,qS=zh,GS=Hh,tp=Uh,np=Wh,rp=Kh;const op=HS,sp=US,Ra=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Jh,{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,c.jsx(WS,{asChild:!0,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ra.displayName=Jh.displayName;const ip=m.forwardRef(({className:e,...t},n)=>c.jsx(tp,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronUp,{className:"h-4 w-4"})}));ip.displayName=tp.displayName;const ap=m.forwardRef(({className:e,...t},n)=>c.jsx(np,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4"})}));ap.displayName=np.displayName;const Pa=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(VS,{children:c.jsxs(Zh,{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:[c.jsx(ip,{}),c.jsx(KS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ap,{})]})}));Pa.displayName=Zh.displayName;const YS=m.forwardRef(({className:e,...t},n)=>c.jsx(Qh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));YS.displayName=Qh.displayName;const Yn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ep,{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:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(GS,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),c.jsx(qS,{children:t})]}));Yn.displayName=ep.displayName;const XS=m.forwardRef(({className:e,...t},n)=>c.jsx(rp,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));XS.displayName=rp.displayName;var JS="Separator",lp="horizontal",ZS=["horizontal","vertical"],cp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=lp,...o}=e,s=QS(r)?r:lp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});cp.displayName=JS;function QS(e){return ZS.includes(e)}var up=cp;const dp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(up,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dp.displayName=up.displayName;const eC=Gu,tC=Ow,nC=Yu,fp=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{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}));fp.displayName=Xo.displayName;const rC=Qr.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"}}),hp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(nC,{children:[c.jsx(fp,{}),c.jsxs(Jo,{ref:o,className:X(rC({side:e}),t),...r,children:[n,c.jsxs(Xu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ee.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hp.displayName=Jo.displayName;const pp=({className:e,...t})=>c.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});pp.displayName="SheetHeader";const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(Hn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));mp.displayName=Hn.displayName;const gp=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));gp.displayName=Zo.displayName;const oC={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 sC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=S.useState(!1),[s,i]=S.useState(!1),[a,l]=S.useState(e),[u,d]=S.useState(!1),{toast:f}=_i();S.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),S.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(oC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(eC,{open:r,onOpenChange:o,children:[c.jsx(tC,{asChild:!0,children:c.jsxs(Ue,{variant:"outline",size:"sm",className:n,children:[c.jsx(ee.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(yi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(hp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(pp,{children:[c.jsx(mp,{children:"Chat Settings"}),c.jsx(gp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ue,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(In,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ue,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(op,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Yn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Yn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"theme",children:"Theme"}),c.jsxs(op,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"light",children:"Light"}),c.jsx(Yn,{value:"dark",children:"Dark"}),c.jsx(Yn,{value:"system",children:"System"})]})]})]}),c.jsx(dp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(In,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(In,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(In,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(In,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(In,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(In,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ue,{variant:"outline",onClick:p,children:[c.jsx(ee.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ue,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Ue,{onClick:h,disabled:!u,children:[c.jsx(ee.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function iC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=S.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(xs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(po,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}ke.ChatApi=jl,ke.ChatInterface=xs,ke.ChatProviders=po,ke.ChatSettings=sC,ke.MarkdownContent=Ni,ke.MessageComponent=sd,ke.MessageList=qi,ke.ThreadManager=Ea,ke.applySettings=dS,ke.chatApiClient=xn,ke.default=iC,ke.del=Al,ke.get=It,ke.getChatToken=kl,ke.getCurrentSettings=uS,ke.getDefaultApiConfig=uh,ke.getDefaultChatSettings=dh,ke.onChatTokenChanged=Il,ke.post=Ks,ke.put=Nl,ke.setChatToken=Vs,ke.useApi=qs,ke.useChatStream=Ol,ke.useMessages=Js,ke.useMessagesReducer=Rl,ke.useStream=Fl,ke.useThreads=ho,Object.defineProperties(ke,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
134
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Jw(e,t=es){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 Zw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Jw(t),Xw(t)}function Gi(e){const t=e+"CollectionProvider",[n,r]=on(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:x}=w,b=S.useRef(null),y=S.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:y,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=Mn.createSlot(a),u=S.forwardRef((w,g)=>{const{scope:x,children:b}=w,y=s(a,x),E=Le(g,y.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Mn.createSlot(d),p=S.forwardRef((w,g)=>{const{scope:x,children:b,...y}=w,E=S.useRef(null),C=Le(g,E),T=s(d,x);return S.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(w){const g=s(e+"CollectionConsumer",w);return S.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Qw=m.createContext(void 0);function ts(e){const t=m.useContext(Qw);return e||t||"ltr"}const eb=["top","right","bottom","left"],An=Math.min,Dt=Math.max,ns=Math.round,rs=Math.floor,ln=e=>({x:e,y:e}),tb={left:"right",right:"left",bottom:"top",top:"bottom"},nb={start:"end",end:"start"};function Yi(e,t,n){return Dt(e,An(t,n))}function gn(e,t){return typeof e=="function"?e(t):e}function xn(e){return e.split("-")[0]}function ur(e){return e.split("-")[1]}function Xi(e){return e==="x"?"y":"x"}function Ji(e){return e==="y"?"height":"width"}const rb=new Set(["top","bottom"]);function cn(e){return rb.has(xn(e))?"y":"x"}function Zi(e){return Xi(cn(e))}function ob(e,t,n){n===void 0&&(n=!1);const r=ur(e),o=Zi(e),s=Ji(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function sb(e){const t=os(e);return[Qi(e),t,Qi(t)]}function Qi(e){return e.replace(/start|end/g,t=>nb[t])}const od=["left","right"],sd=["right","left"],ib=["top","bottom"],ab=["bottom","top"];function lb(e,t,n){switch(e){case"top":case"bottom":return n?t?sd:od:t?od:sd;case"left":case"right":return t?ib:ab;default:return[]}}function cb(e,t,n,r){const o=ur(e);let s=lb(xn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Qi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>tb[t])}function ub(e){return{top:0,right:0,bottom:0,left:0,...e}}function id(e){return typeof e!="number"?ub(e):{top:e,right:e,bottom:e,left:e}}function ss(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=cn(t),i=Zi(t),a=Ji(i),l=xn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(ur(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const db=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ad(u,r,l),h=r,p={},v=0;for(let w=0;w<a.length;w++){const{name:g,fn:x}=a[w],{x:b,y,data:E,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=y??f,p={...p,[g]:{...p[g],...E}},C&&v<=50&&(v++,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,l)),w=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=gn(t,e),v=id(p),g=a[h?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,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=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:y,strategy:l}):b);return{top:(x.top-C.top+v.top)/E.y,bottom:(C.bottom-x.bottom+v.bottom)/E.y,left:(x.left-C.left+v.left)/E.x,right:(C.right-x.right+v.right)/E.x}}const fb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=gn(e,t)||{};if(u==null)return{};const f=id(d),h={x:n,y:r},p=Zi(o),v=Ji(p),w=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[v]);const A=E/2-C/2,P=I/2-w[v]/2-1,_=An(f[x],P),D=An(f[b],P),L=_,F=I-w[v]-D,O=I/2-w[v]/2+A,W=Yi(L,O,F),U=!l.arrow&&ur(o)!=null&&O!==W&&s.reference[v]/2-(O<L?_:D)-w[v]/2<0,G=U?O<L?O-L:O-F:0;return{[p]:h[p]+G,data:{[p]:W,centerOffset:O-W-G,...U&&{alignmentOffset:G}},reset:U}}}),hb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...g}=gn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=xn(o),b=cn(a),y=xn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(y||!w?[os(a)]:sb(a)),T=v!=="none";!h&&T&&C.push(...cb(a,w,v,E));const I=[a,...C],A=await Br(t,g),P=[];let _=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(A[x]),f){const O=ob(o,i,E);P.push(A[O[0]],A[O[1]])}if(_=[..._,{placement:o,overflows:P}],!P.every(O=>O<=0)){var D,L;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,W=I[O];if(W&&(!(f==="alignment"?b!==cn(W):!1)||_.every($=>cn($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:O,overflows:_},reset:{placement:W}};let U=(L=_.filter(G=>G.overflows[0]<=0).sort((G,$)=>G.overflows[1]-$.overflows[1])[0])==null?void 0:L.placement;if(!U)switch(p){case"bestFit":{var F;const G=(F=_.filter($=>{if(T){const N=cn($.placement);return N===b||N==="y"}return!0}).map($=>[$.placement,$.overflows.filter(N=>N>0).reduce((N,V)=>N+V,0)]).sort(($,N)=>$[1]-N[1])[0])==null?void 0:F[0];G&&(U=G);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 eb.some(t=>e[t]>=0)}const pb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=gn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=ld(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:cd(i)}}}case"escaped":{const s=await Br(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 mb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=xn(n),a=ur(n),l=cn(n)==="y",u=ud.has(i)?-1:1,d=s&&l?-1:1,f=gn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const gb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await mb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},xb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=gn(e,t),u={x:n,y:r},d=await Br(t,l),f=cn(xn(o)),h=Xi(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],y=p-d[x];p=Yi(b,p,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=v+d[g],y=v-d[x];v=Yi(b,v,y)}const w=a.fn({...t,[h]:p,[f]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:s,[f]:i}}}}}},vb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=gn(e,t),d={x:n,y:r},f=cn(o),h=Xi(f);let p=d[h],v=d[f];const w=gn(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(l){const y=h==="y"?"height":"width",E=s.reference[h]-s.floating[y]+g.mainAxis,C=s.reference[h]+s.reference[y]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var x,b;const y=h==="y"?"width":"height",E=ud.has(xn(o)),C=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},wb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=gn(e,t),d=await Br(t,u),f=xn(o),h=ur(o),p=cn(o)==="y",{width:v,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 b=w-d.top-d.bottom,y=v-d.left-d.right,E=An(w-d[g],b),C=An(v-d[x],y),T=!t.middlewareData.shift;let I=E,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const _=Dt(d.left,0),D=Dt(d.right,0),L=Dt(d.top,0),F=Dt(d.bottom,0);p?A=v-2*(_!==0||D!==0?_+D:Dt(d.left,d.right)):I=w-2*(L!==0||F!==0?L+F:Dt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const P=await i.getDimensions(a.floating);return v!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function dr(e){return dd(e)?(e.nodeName||"").toLowerCase():"#document"}function Lt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function un(e){var t;return(t=(dd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dd(e){return is()?e instanceof Node||e instanceof Lt(e).Node:!1}function Jt(e){return is()?e instanceof Element||e instanceof Lt(e).Element:!1}function dn(e){return is()?e instanceof HTMLElement||e instanceof Lt(e).HTMLElement:!1}function fd(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Lt(e).ShadowRoot}const bb=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Zt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!bb.has(o)}const yb=new Set(["table","td","th"]);function Sb(e){return yb.has(dr(e))}const Cb=[":popover-open",":modal"];function as(e){return Cb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tb=["transform","translate","scale","rotate","perspective"],kb=["transform","translate","scale","rotate","perspective","filter"],Eb=["paint","layout","strict","content"];function ea(e){const t=ta(),n=Jt(e)?Zt(e):e;return Tb.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)||kb.some(r=>(n.willChange||"").includes(r))||Eb.some(r=>(n.contain||"").includes(r))}function Ib(e){let t=jn(e);for(;dn(t)&&!fr(t);){if(ea(t))return t;if(as(t))return null;t=jn(t)}return null}function ta(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Nb=new Set(["html","body","#document"]);function fr(e){return Nb.has(dr(e))}function Zt(e){return Lt(e).getComputedStyle(e)}function ls(e){return Jt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function jn(e){if(dr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fd(e)&&e.host||un(e);return fd(t)?t.host:t}function hd(e){const t=jn(e);return fr(t)?e.ownerDocument?e.ownerDocument.body:e.body:dn(t)&&Hr(t)?t:hd(t)}function Ur(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=Lt(o);if(s){const a=na(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pd(e){const t=Zt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=dn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ra(e){return Jt(e)?e:e.contextElement}function hr(e){const t=ra(e);if(!dn(t))return ln(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=pd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Ab=ln(0);function md(e){const t=Lt(e);return!ta()||!t.visualViewport?Ab:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Lt(e)?!1:t}function Gn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ra(e);let i=ln(1);t&&(r?Jt(r)&&(i=hr(r)):i=hr(e));const a=jb(s,n,r)?md(s):ln(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Lt(s),p=r&&Jt(r)?Lt(r):r;let v=h,w=na(v);for(;w&&r&&p!==v;){const g=hr(w),x=w.getBoundingClientRect(),b=Zt(w),y=x.left+(w.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(w.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=y,u+=E,v=Lt(w),w=na(v)}}return ss({width:d,height:f,x:l,y:u})}function cs(e,t){const n=ls(e).scrollLeft;return t?t.left+n:Gn(un(e)).left+n}function gd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-cs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function _b(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=un(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=ln(1);const d=ln(0),f=dn(r);if((f||!f&&!s)&&((dr(r)!=="body"||Hr(i))&&(l=ls(r)),dn(r))){const p=Gn(r);u=hr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?gd(i,l):ln(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Rb(e){return Array.from(e.getClientRects())}function Pb(e){const t=un(e),n=ls(e),r=e.ownerDocument.body,o=Dt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Dt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+cs(e);const a=-n.scrollTop;return Zt(r).direction==="rtl"&&(i+=Dt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const xd=25;function Ob(e,t){const n=Lt(e),r=un(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=ta();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=cs(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=xd&&(s-=v)}else u<=xd&&(s+=u);return{width:s,height:i,x:a,y:l}}const Mb=new Set(["absolute","fixed"]);function Db(e,t){const n=Gn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=dn(e)?hr(e):ln(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function vd(e,t,n){let r;if(t==="viewport")r=Ob(e,n);else if(t==="document")r=Pb(un(e));else if(Jt(t))r=Db(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 ss(r)}function wd(e,t){const n=jn(e);return n===t||!Jt(n)||fr(n)?!1:Zt(n).position==="fixed"||wd(n,t)}function Lb(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>Jt(a)&&dr(a)!=="body"),o=null;const s=Zt(e).position==="fixed";let i=s?jn(e):e;for(;Jt(i)&&!fr(i);){const a=Zt(i),l=ea(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Mb.has(o.position)||Hr(i)&&!l&&wd(e,i))?r=r.filter(d=>d!==i):o=a,i=jn(i)}return t.set(e,r),r}function Fb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:Lb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=vd(t,d,o);return u.top=Dt(f.top,u.top),u.right=An(f.right,u.right),u.bottom=An(f.bottom,u.bottom),u.left=Dt(f.left,u.left),u},vd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function $b(e){const{width:t,height:n}=pd(e);return{width:t,height:n}}function zb(e,t,n){const r=dn(t),o=un(t),s=n==="fixed",i=Gn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=ln(0);function u(){l.x=cs(o)}if(r||!r&&!s)if((dr(t)!=="body"||Hr(o))&&(a=ls(t)),r){const p=Gn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?gd(o,a):ln(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function oa(e){return Zt(e).position==="static"}function bd(e,t){if(!dn(e)||Zt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return un(e)===n&&(n=n.ownerDocument.body),n}function yd(e,t){const n=Lt(e);if(as(e))return n;if(!dn(e)){let o=jn(e);for(;o&&!fr(o);){if(Jt(o)&&!oa(o))return o;o=jn(o)}return n}let r=bd(e,t);for(;r&&Sb(r)&&oa(r);)r=bd(r,t);return r&&fr(r)&&oa(r)&&!ea(r)?n:r||Ib(e)||n}const Bb=async function(e){const t=this.getOffsetParent||yd,n=this.getDimensions,r=await n(e.floating);return{reference:zb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hb(e){return Zt(e).direction==="rtl"}const Ub={convertOffsetParentRelativeRectToViewportRelativeRect:_b,getDocumentElement:un,getClippingRect:Fb,getOffsetParent:yd,getElementRects:Bb,getClientRects:Rb,getDimensions:$b,getScale:hr,isElement:Jt,isRTL:Hb};function Sd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Wb(e,t){let n=null,r;const o=un(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=rs(f),w=rs(o.clientWidth-(d+h)),g=rs(o.clientHeight-(f+p)),x=rs(d),y={rootMargin:-v+"px "+-w+"px "+-g+"px "+-x+"px",threshold:Dt(0,An(1,l))||1};let E=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Sd(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 Vb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ra(e),d=o||s?[...u?Ur(u):[],...Ur(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Wb(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,w=l?Gn(e):null;l&&g();function g(){const x=Gn(e);w&&!Sd(w,x)&&n(),w=x,v=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const Kb=gb,qb=xb,Gb=hb,Yb=wb,Xb=pb,Cd=fb,Jb=vb,Zb=(e,t,n)=>{const r=new Map,o={platform:Ub,...n},s={...o.platform,_c:r};return db(e,t,{...o,platform:s})};var Qb=typeof document<"u",ey=function(){},us=Qb?S.useLayoutEffect:ey;function ds(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(!ds(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)&&!ds(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Td(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kd(e,t){const n=Td(e);return Math.round(t*n)/n}function sa(e){const t=m.useRef(e);return us(()=>{t.current=e}),t}function ty(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);ds(h,r)||p(r);const[v,w]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback($=>{$!==T.current&&(T.current=$,w($))},[]),y=m.useCallback($=>{$!==I.current&&(I.current=$,x($))},[]),E=s||v,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),P=l!=null,_=sa(l),D=sa(o),L=sa(u),F=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};D.current&&($.platform=D.current),Zb(T.current,I.current,$).then(N=>{const V={...N,isPositioned:L.current!==!1};O.current&&!ds(A.current,V)&&(A.current=V,eo.flushSync(()=>{f(V)}))})},[h,t,n,D,L]);us(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const O=m.useRef(!1);us(()=>(O.current=!0,()=>{O.current=!1}),[]),us(()=>{if(E&&(T.current=E),C&&(I.current=C),E&&C){if(_.current)return _.current(E,C,F);F()}},[E,C,F,_,P]);const W=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:y}),[b,y]),U=m.useMemo(()=>({reference:E,floating:C}),[E,C]),G=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!U.floating)return $;const N=kd(U.floating,d.x),V=kd(U.floating,d.y);return a?{...$,transform:"translate("+N+"px, "+V+"px)",...Td(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:V}},[n,a,U.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:F,refs:W,elements:U,floatingStyles:G}),[d,F,W,U,G])}const ny=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?Cd({element:r.current,padding:o}).fn(n):{}:r?Cd({element:r,padding:o}).fn(n):{}}}},ry=(e,t)=>({...Kb(e),options:[e,t]}),oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Jb(e),options:[e,t]}),iy=(e,t)=>({...Gb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...ny(e),options:[e,t]});var uy="Arrow",Ed=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(ke.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ed.displayName=uy;var dy=Ed;function Id(e){const[t,n]=m.useState(void 0);return xt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ia="Popper",[Nd,fs]=on(ia),[fy,Ad]=Nd(ia),jd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(fy,{scope:t,anchor:r,onAnchorChange:o,children:n})};jd.displayName=ia;var _d="PopperAnchor",Rd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ad(_d,n),i=m.useRef(null),a=Le(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(ke.div,{...o,ref:a})});Rd.displayName=_d;var aa="PopperContent",[hy,py]=Nd(aa),Pd=m.forwardRef((e,t)=>{var z,M,q,Z,ce,te;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...w}=e,g=Ad(aa,n),[x,b]=m.useState(null),y=Le(t,Fe=>b(Fe)),[E,C]=m.useState(null),T=Id(E),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,P=r+(s!=="center"?"-"+s:""),_=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(u)?u:[u],L=D.length>0,F={padding:_,boundary:D.filter(gy),altBoundary:L},{refs:O,floatingStyles:W,placement:U,isPositioned:G,middlewareData:$}=ty({strategy:"fixed",placement:P,whileElementsMounted:(...Fe)=>Vb(...Fe,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[ry({mainAxis:o+A,alignmentAxis:i}),l&&oy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?sy():void 0,...F}),l&&iy({...F}),ay({...F,apply:({elements:Fe,rects:Qe,availableWidth:et,availableHeight:je})=>{const{width:Oe,height:tt}=Qe.reference,He=Fe.floating.style;He.setProperty("--radix-popper-available-width",`${et}px`),He.setProperty("--radix-popper-available-height",`${je}px`),He.setProperty("--radix-popper-anchor-width",`${Oe}px`),He.setProperty("--radix-popper-anchor-height",`${tt}px`)}}),E&&cy({element:E,padding:a}),xy({arrowWidth:I,arrowHeight:A}),h&&ly({strategy:"referenceHidden",...F})]}),[N,V]=Dd(U),X=vt(v);xt(()=>{G&&(X==null||X())},[G,X]);const pe=(z=$.arrow)==null?void 0:z.x,le=(M=$.arrow)==null?void 0:M.y,fe=((q=$.arrow)==null?void 0:q.centerOffset)!==0,[ye,we]=m.useState();return xt(()=>{x&&we(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:G?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ye,"--radix-popper-transform-origin":[(Z=$.transformOrigin)==null?void 0:Z.x,(ce=$.transformOrigin)==null?void 0:ce.y].join(" "),...((te=$.hide)==null?void 0:te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(hy,{scope:n,placedSide:N,onArrowChange:C,arrowX:pe,arrowY:le,shouldHideArrow:fe,children:c.jsx(ke.div,{"data-side":N,"data-align":V,...w,ref:y,style:{...w.style,animation:G?void 0:"none"}})})})});Pd.displayName=aa;var Od="PopperArrow",my={top:"bottom",right:"left",bottom:"top",left:"right"},Md=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=py(Od,r),i=my[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(dy,{...o,ref:n,style:{...o.style,display:"block"}})})});Md.displayName=Od;function gy(e){return e!==null}var xy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Dd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",w="";return u==="bottom"?(v=i?f:`${h}px`,w=`${-l}px`):u==="top"?(v=i?f:`${h}px`,w=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,w=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,w=i?f:`${p}px`),{data:{x:v,y:w}}}});function Dd(e){const[t,n="center"]=e.split("-");return[t,n]}var Ld=jd,Fd=Rd,$d=Pd,zd=Md,la="rovingFocusGroup.onEntryFocus",vy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[ca,Bd,wy]=Gi(Wr),[by,Hd]=on(Wr,[wy]),[yy,Sy]=by(Wr),Ud=m.forwardRef((e,t)=>c.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Cy,{...e,ref:t})})}));Ud.displayName=Wr;var Cy=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Le(t,h),v=ts(s),[w,g]=Un({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[x,b]=m.useState(!1),y=vt(u),E=Bd(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(la,y),()=>A.removeEventListener(la,y)},[y]),c.jsx(yy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:w,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(ke.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,A=>{const P=!C.current;if(A.target===A.currentTarget&&P&&!x){const _=new CustomEvent(la,vy);if(A.currentTarget.dispatchEvent(_),!_.defaultPrevented){const D=E().filter(U=>U.focusable),L=D.find(U=>U.active),F=D.find(U=>U.id===w),W=[L,F,...D].filter(Boolean).map(U=>U.ref.current);Kd(W,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Wd="RovingFocusGroupItem",Vd=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=sn(),u=s||l,d=Sy(Wd,n),f=d.currentTabStopId===u,h=Bd(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:w}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(ca.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(ke.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ae(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Ey(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?Iy(y,E+1):y.slice(E+1)}setTimeout(()=>Kd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Vd.displayName=Wd;var Ty={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ey(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ty[r]}function Kd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Iy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ny=Ud,Ay=Vd,ua=["Enter"," "],jy=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],_y=[...jy,...qd],Ry={ltr:[...ua,"ArrowRight"],rtl:[...ua,"ArrowLeft"]},Py={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,Oy,My]=Gi(Vr),[Yn,Gd]=on(Vr,[My,fs,Hd]),hs=fs(),Yd=Hd(),[Dy,Xn]=Yn(Vr),[Ly,qr]=Yn(Vr),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=hs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=vt(s),h=ts(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Ld,{...a,children:c.jsx(Dy,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Ly,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Xd.displayName=Vr;var Fy="MenuAnchor",da=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return c.jsx(Fd,{...o,...r,ref:t})});da.displayName=Fy;var fa="MenuPortal",[$y,Jd]=Yn(fa,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Xn(fa,t);return c.jsx($y,{scope:t,forceMount:n,children:c.jsx(Mt,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:r})})})};Zd.displayName=fa;var Ut="MenuContent",[zy,ha]=Yn(Ut),Qd=m.forwardRef((e,t)=>{const n=Jd(Ut,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Ut,e.__scopeMenu),i=qr(Ut,e.__scopeMenu);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(Mt,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(By,{...o,ref:t}):c.jsx(Hy,{...o,ref:t})})})})}),By=m.forwardRef((e,t)=>{const n=Xn(Ut,e.__scopeMenu),r=m.useRef(null),o=Le(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(pa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Hy=m.forwardRef((e,t)=>{const n=Xn(Ut,e.__scopeMenu);return c.jsx(pa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Uy=Mn.createSlot("MenuContent.ScrollLock"),pa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...w}=e,g=Xn(Ut,n),x=qr(Ut,n),b=hs(n),y=Yd(n),E=Oy(n),[C,T]=m.useState(null),I=m.useRef(null),A=Le(t,I,g.onContentChange),P=m.useRef(0),_=m.useRef(""),D=m.useRef(0),L=m.useRef(null),F=m.useRef("right"),O=m.useRef(0),W=v?Vo:m.Fragment,U=v?{as:Uy,allowPinchZoom:!0}:void 0,G=N=>{var z,M;const V=_.current+N,X=E().filter(q=>!q.disabled),pe=document.activeElement,le=(z=X.find(q=>q.ref.current===pe))==null?void 0:z.textValue,fe=X.map(q=>q.textValue),ye=t0(fe,V,le),we=(M=X.find(q=>q.textValue===ye))==null?void 0:M.ref.current;(function q(Z){_.current=Z,window.clearTimeout(P.current),Z!==""&&(P.current=window.setTimeout(()=>q(""),1e3))})(V),we&&setTimeout(()=>we.focus())};m.useEffect(()=>()=>window.clearTimeout(P.current),[]),Di();const $=m.useCallback(N=>{var X,pe;return F.current===((X=L.current)==null?void 0:X.side)&&r0(N,(pe=L.current)==null?void 0:pe.area)},[]);return c.jsx(zy,{scope:n,searchRef:_,onItemEnter:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),onItemLeave:m.useCallback(N=>{var V;$(N)||((V=I.current)==null||V.focus(),T(null))},[$]),onTriggerLeave:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback(N=>{L.current=N},[]),children:c.jsx(W,{...U,children:c.jsx(Fo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,N=>{var V;N.preventDefault(),(V=I.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Ny,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,N=>{x.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx($d,{role:"menu","aria-orientation":"vertical","data-state":xf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...w,ref:A,style:{outline:"none",...w.style},onKeyDown:ae(w.onKeyDown,N=>{const X=N.target.closest("[data-radix-menu-content]")===N.currentTarget,pe=N.ctrlKey||N.altKey||N.metaKey,le=N.key.length===1;X&&(N.key==="Tab"&&N.preventDefault(),!pe&&le&&G(N.key));const fe=I.current;if(N.target!==fe||!_y.includes(N.key))return;N.preventDefault();const we=E().filter(z=>!z.disabled).map(z=>z.ref.current);qd.includes(N.key)&&we.reverse(),Qy(we)}),onBlur:ae(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(P.current),_.current="")}),onPointerMove:ae(e.onPointerMove,Yr(N=>{const V=N.target,X=O.current!==N.clientX;if(N.currentTarget.contains(V)&&X){const pe=N.clientX>O.current?"right":"left";F.current=pe,O.current=N.clientX}}))})})})})})})});Qd.displayName=Ut;var Wy="MenuGroup",ma=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ke.div,{role:"group",...r,ref:t})});ma.displayName=Wy;var Vy="MenuLabel",ef=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ke.div,{...r,ref:t})});ef.displayName=Vy;var ps="MenuItem",tf="menu.itemSelect",ms=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=qr(ps,e.__scopeMenu),a=ha(ps,e.__scopeMenu),l=Le(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(tf,{bubbles:!0,cancelable:!0});f.addEventListener(tf,p=>r==null?void 0:r(p),{once:!0}),Dc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(nf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ae(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ua.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ms.displayName=ps;var nf=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ha(ps,n),a=Yd(n),l=m.useRef(null),u=Le(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Ay,{asChild:!0,...a,focusable:!r,children:c.jsx(ke.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ae(e.onPointerMove,Yr(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,Yr(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),Ky="MenuCheckboxItem",rf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(cf,{scope:e.__scopeMenu,checked:n,children:c.jsx(ms,{role:"menuitemcheckbox","aria-checked":gs(n)?"mixed":n,...o,ref:t,"data-state":xa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(gs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=Ky;var of="MenuRadioGroup",[qy,Gy]=Yn(of,{value:void 0,onValueChange:()=>{}}),sf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return c.jsx(qy,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ma,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Gy(af,e.__scopeMenu),s=n===o.value;return c.jsx(cf,{scope:e.__scopeMenu,checked:s,children:c.jsx(ms,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":xa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var ga="MenuItemIndicator",[cf,Yy]=Yn(ga,{checked:!1}),uf=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Yy(ga,n);return c.jsx(Mt,{present:r||gs(s.checked)||s.checked===!0,children:c.jsx(ke.span,{...o,ref:t,"data-state":xa(s.checked)})})});uf.displayName=ga;var Xy="MenuSeparator",df=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ke.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=Xy;var Jy="MenuArrow",ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=hs(n);return c.jsx(zd,{...o,...r,ref:t})});ff.displayName=Jy;var Zy="MenuSub",[OC,hf]=Yn(Zy),Gr="MenuSubTrigger",pf=m.forwardRef((e,t)=>{const n=Xn(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=hf(Gr,e.__scopeMenu),s=ha(Gr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(da,{asChild:!0,...u,children:c.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:Si(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:ae(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,Yr(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const w=(v=n.content)==null?void 0:v.dataset.side,g=w==="right",x=g?-5:5,b=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:b,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:ae(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Ry[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});pf.displayName=Gr;var mf="MenuSubContent",gf=m.forwardRef((e,t)=>{const n=Jd(Ut,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Xn(Ut,e.__scopeMenu),i=qr(Ut,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=m.useRef(null),u=Le(t,l);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(Mt,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:c.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=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Py[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function gs(e){return e==="indeterminate"}function xa(e){return gs(e)?"indeterminate":e?"checked":"unchecked"}function Qy(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function e0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function t0(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=e0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function n0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function r0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return n0(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var o0=Xd,s0=da,i0=Zd,a0=Qd,l0=ma,c0=ef,u0=ms,d0=rf,f0=sf,h0=lf,p0=uf,m0=df,g0=ff,x0=pf,v0=gf,xs="DropdownMenu",[w0,MC]=on(xs,[Gd]),Tt=Gd(),[b0,vf]=w0(xs),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Tt(t),u=m.useRef(null),[d,f]=Un({prop:o,defaultProp:s??!1,onChange:i,caller:xs});return c.jsx(b0,{scope:t,triggerId:sn(),triggerRef:u,contentId:sn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(o0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};wf.displayName=xs;var bf="DropdownMenuTrigger",yf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(bf,n),i=Tt(n);return c.jsx(s0,{asChild:!0,...i,children:c.jsx(ke.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:Si(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=bf;var y0="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Tt(t);return c.jsx(i0,{...r,...n})};Sf.displayName=y0;var Cf="DropdownMenuContent",Tf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=Tt(n),i=m.useRef(!1);return c.jsx(a0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tf.displayName=Cf;var S0="DropdownMenuGroup",C0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(l0,{...o,...r,ref:t})});C0.displayName=S0;var T0="DropdownMenuLabel",kf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(c0,{...o,...r,ref:t})});kf.displayName=T0;var k0="DropdownMenuItem",Ef=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(u0,{...o,...r,ref:t})});Ef.displayName=k0;var E0="DropdownMenuCheckboxItem",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(d0,{...o,...r,ref:t})});If.displayName=E0;var I0="DropdownMenuRadioGroup",N0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(f0,{...o,...r,ref:t})});N0.displayName=I0;var A0="DropdownMenuRadioItem",Nf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(h0,{...o,...r,ref:t})});Nf.displayName=A0;var j0="DropdownMenuItemIndicator",Af=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(p0,{...o,...r,ref:t})});Af.displayName=j0;var _0="DropdownMenuSeparator",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(m0,{...o,...r,ref:t})});jf.displayName=_0;var R0="DropdownMenuArrow",P0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(g0,{...o,...r,ref:t})});P0.displayName=R0;var O0="DropdownMenuSubTrigger",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(x0,{...o,...r,ref:t})});_f.displayName=O0;var M0="DropdownMenuSubContent",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Tt(n);return c.jsx(v0,{...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)"}})});Rf.displayName=M0;var D0=wf,L0=yf,F0=Sf,Pf=Tf,Of=kf,Mf=Ef,Df=If,Lf=Nf,Ff=Af,$f=jf,zf=_f,Bf=Rf;const $0=D0,z0=L0,B0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(zf,{ref:o,className:J("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(re.ChevronRight,{className:"ml-auto h-4 w-4"})]}));B0.displayName=zf.displayName;const H0=m.forwardRef(({className:e,...t},n)=>c.jsx(Bf,{ref:n,className:J("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}));H0.displayName=Bf.displayName;const Hf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(F0,{children:c.jsx(Pf,{ref:r,sideOffset:t,className:J("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})}));Hf.displayName=Pf.displayName;const va=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Mf,{ref:r,className:J("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=Mf.displayName;const U0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Df,{ref:o,className:J("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Ff,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),t]}));U0.displayName=Df.displayName;const W0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Lf,{ref:r,className:J("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Ff,{children:c.jsx(re.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));W0.displayName=Lf.displayName;const V0=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Of,{ref:r,className:J("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));V0.displayName=Of.displayName;const K0=m.forwardRef(({className:e,...t},n)=>c.jsx($f,{ref:n,className:J("-mx-1 my-1 h-px bg-muted",e),...t}));K0.displayName=$f.displayName;function vs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=qs(),{currentThreadId:w,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:y}=ho(),{messages:E,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:A,loadOlderMessages:P}=Js(),{isStreaming:_,error:D,streamingAssistantId:L,lastCheckpointId:F,lastCheckpointNs:O}=Ml(),[W,U]=S.useState(null),[G,$]=S.useState(""),[N,V]=S.useState(null),[X,pe]=S.useState([]),[le,fe]=S.useState(0),[ye,we]=S.useState(0),[z,M]=S.useState(!1),[q,Z]=S.useState(null),[ce,te]=S.useState(null),[Fe,Qe]=S.useState(!1),[et,je]=S.useState(null),[Oe,tt]=S.useState([]),[He,at]=S.useState(null),[dt,ne]=S.useState(null),[ee,xe]=S.useState(!1),Ee=S.useRef(null),Se=S.useRef(null),Re=S.useRef(null),Je=S.useCallback(()=>{Ee.current&&(Ee.current.value=""),Se.current&&(Se.current.value=""),fe(Q=>Q+1),we(Q=>Q+1)},[]),Ke=S.useRef(!1);S.useEffect(()=>{Ke.current&&!_&&(pe([]),Je()),Ke.current=_},[_,Je]);const[lt,At]=S.useState("desktop");S.useEffect(()=>{const Q=()=>{const ve=window.innerWidth;At(ve<640?"phone":ve<1024?"tablet":"desktop")};return Q(),window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),S.useEffect(()=>{let Q=!1;if(!w){tt([]),at(null),ne(null),Re.current=null;return}const ve={threadId:w,checkpointId:F??null,checkpointNs:O??null},$e=Re.current;if(!($e&&$e.threadId===ve.threadId&&$e.checkpointId===ve.checkpointId&&$e.checkpointNs===ve.checkpointNs))return x(w).then(st=>{var js;if(Q)return;const $t=((st==null?void 0:st.checkpoints)??[]).slice().sort((k,H)=>new Date(H.createdAt).getTime()-new Date(k.createdAt).getTime());tt($t);const wn=He,Zr=wn&&$t.some(k=>k.checkpointId===wn)?wn:((js=$t[0])==null?void 0:js.checkpointId)??null;let As=null;if(Zr){const k=$t.find(H=>H.checkpointId===Zr);As=(k==null?void 0:k.checkpointNs)??null}at(Zr),ne(As),Re.current=ve}).catch(st=>{console.error("ChatInterface - listCheckpoints error:",st),Q||(tt([]),Re.current=null)}),()=>{Q=!0}},[w,F,O,He,x]),S.useEffect(()=>{F&&(at(F),ne(O??null))},[F,O]);const On=S.useCallback(async()=>{if(!(!C||T))try{await P()}catch(Q){console.warn("loadOlderMessages failed",Q)}},[C,T,P]);S.useEffect(()=>{(async()=>{if(!v.baseUrl){je(null);return}try{const ve=await v.getAgent("default");je(ve.uiDefaultMessage||null)}catch(ve){console.warn("Failed to fetch default message:",ve),je(null)}})()},[v]),S.useEffect(()=>{D&&!Fe&&(p==null||p(D))},[D,Fe,p]);const Jr=Q=>{if(Q.length>es)return`Message too long (${Q.length}/${es} characters)`;try{return Zw(Q),null}catch(ve){return(ve==null?void 0:ve.message)||"Invalid message"}},j=async Q=>{const ve=Q.trim();if(!(!ve&&X.length===0)){if(ve){const $e=Jr(ve);if($e){V($e);return}}try{await I(ve||"",{checkpointId:He??F??void 0,checkpointNs:dt??O??void 0,payloadExtras:W?{edit:!0,originalMessageId:W}:void 0,attachments:X}),f==null||f(ve),V(null),pe([]),Je(),U(null),$("")}catch($e){const st=($e==null?void 0:$e.message)||"Failed to send message";V(st),p==null||p(st)}}},Y=S.useCallback((Q,ve)=>{u&&(U(Q),$(ve),V(null))},[u]),ue=S.useCallback(()=>{U(null),$(""),V(null)},[]),Ce=S.useCallback((Q,ve)=>{Y(Q,ve)},[Y]),Me=S.useCallback(Q=>{const ve=$e=>{const st=$e.content||[],$t=st.filter(wn=>wn.type==="text").map(wn=>wn.text).join("");if($t)return $t;try{return JSON.stringify(st,null,2)}catch{return String(st)}};for(let $e=Q-1;$e>=0;$e--)if(E[$e].role==="user"){const st=ve(E[$e]);st&&I(st,{checkpointId:He??F??void 0,checkpointNs:dt??O??void 0});break}},[E,I,He,dt,F,O]),he=Q=>{const ve=Array.from(Q.target.files||[]);pe($e=>[...$e,...ve]),Q.target.value=""},it=Q=>{pe(ve=>{const $e=ve.filter((st,$t)=>Q!==$t);return $e.length===0&&Je(),$e})},jt=async Q=>{const ve=(Q.target.files||[])[0];if(ve){Z(null),te(null),M(!0);try{await I("",{checkpointId:He??F??void 0,checkpointNs:dt??O??void 0,attachments:[ve]});const $e=`Uploaded ${ve.name} - processing through chat stream`;te($e)}catch($e){const st=$e instanceof Error?$e.message:"Failed to upload Excel file";console.error("Excel upload failed",$e),Z(st),p==null||p(st)}finally{M(!1),Q.target.value="",Je()}}},ft=Q=>{if(!Q)return"Unknown";const ve=Date.parse(Q);return Number.isNaN(ve)?Q:new Date(ve).toLocaleString()},Ft=async Q=>{if(w){xe(!0);try{if(!Q){await y(),at(null),ne(null);return}const ve=Oe.find(st=>st.checkpointId===Q),$e=(ve==null?void 0:ve.checkpointNs)??null;await b(Q,$e),at(Q),ne($e)}finally{xe(!1)}}},vn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,hn=`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||""}`,xr=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:vn,children:[!!D&&!Fe&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:D}),c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>Qe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(re.X,{size:16})})]}),w&&Oe.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:He??"",onChange:Q=>{const ve=Q.target.value||null;Ft(ve)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(Q=>c.jsxs("option",{value:Q.checkpointId,children:[ft(Q.createdAt),Q.preview?` — ${Q.preview.slice(0,40)}`:""]},Q.checkpointId))]})]}),c.jsxs("div",{className:`relative ${hn}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(qi,{className:"h-full",style:{height:"100%"},messages:E,isStreaming:_,streamingAssistantId:L,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:lt,enableMessageEditing:u,editingMessageId:W,onStartReached:()=>{On()},onEdit:Ce,onRegenerate:Me,onCancelEdit:ue,emptyMessage:et??void 0,isNavigatingCheckpoint:ee}),g&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(re.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:xr,children:[W&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(re.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(We,{variant:"ghost",size:"sm",onClick:ue,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(re.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Ee,type:"file",multiple:!0,onChange:Q=>he(Q),className:"hidden"},le),X.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:X.map((Q,ve)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(re.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:Q.name}),c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>it(ve),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 ${Q.name}`,children:c.jsx(re.X,{size:12})})]},ve))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Se,type:"file",accept:".xls,.xlsx,.xlsm",onChange:jt,className:"hidden"},ye),z&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(re.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ce&&!z&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ce}),q&&!z&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:q})]})]}),N&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:N}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs($0,{children:[c.jsx(z0,{asChild:!0,children:c.jsx(We,{type:"button",size:"icon",variant:"outline",disabled:_,title:"More input actions",className:d.moreButton||"",children:c.jsx(re.Plus,{size:16})})}),c.jsxs(Hf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(va,{onClick:()=>{var Q;return(Q=Ee.current)==null?void 0:Q.click()},className:"cursor-pointer",children:[c.jsx(re.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(va,{onClick:()=>{var Q;z||(Q=Se.current)==null||Q.click()},className:`cursor-pointer ${z?"opacity-60 pointer-events-none":""}`,children:[c.jsx(re.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(dg,{initialValue:G,editingMessageId:W,placeholder:W?"Edit your message...":t,isStreaming:_,disabled:!1,maxLength:es,onSend:j,onCancelEdit:ue,onStop:A,allowEmptySend:X.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":""} ${N?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const ws=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:J("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}));ws.displayName="Input";function wa(e,[t,n]){return Math.min(n,Math.max(t,e))}function q0(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ba="ScrollArea",[Uf,DC]=on(ba),[G0,Wt]=Uf(ba),Wf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[w,g]=m.useState(null),[x,b]=m.useState(0),[y,E]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),P=Le(t,D=>l(D)),_=ts(o);return c.jsx(G0,{scope:n,type:r,dir:_,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(ke.div,{dir:_,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Wf.displayName=ba;var Vf="ScrollAreaViewport",Kf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Wt(Vf,n),a=m.useRef(null),l=Le(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(ke.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Kf.displayName=Vf;var fn="ScrollAreaScrollbar",ya=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Wt(fn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(Y0,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(X0,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(qf,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Sa,{...r,ref:t}):null});ya.displayName=fn;var Y0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Wt(fn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Mt,{present:n||s,children:c.jsx(qf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),X0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Wt(fn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Cs(()=>l("SCROLL_END"),100),[a,l]=q0("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Mt,{present:n||a!=="hidden",children:c.jsx(Sa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),qf=m.forwardRef((e,t)=>{const n=Wt(fn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Cs(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return pr(n.viewport,l),pr(n.content,l),c.jsx(Mt,{present:r||s,children:c.jsx(Sa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Sa=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Wt(fn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Zf(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return nS(h,i.current,a,p)}return n==="horizontal"?c.jsx(J0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Qf(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(Z0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Qf(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),J0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Wt(fn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Yf,{"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":Ss(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),th(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ys(i.paddingLeft),paddingEnd:ys(i.paddingRight)}})}})}),Z0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Wt(fn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Le(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Yf,{"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":Ss(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),th(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ys(i.paddingTop),paddingEnd:ys(i.paddingBottom)}})}})}),[Q0,Gf]=Uf(fn),Yf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Wt(fn,n),[v,w]=m.useState(null),g=Le(t,P=>w(P)),x=m.useRef(null),b=m.useRef(""),y=p.viewport,E=r.content-r.viewport,C=vt(d),T=vt(l),I=Cs(f,10);function A(P){if(x.current){const _=P.clientX-x.current.left,D=P.clientY-x.current.top;u({x:_,y:D})}}return m.useEffect(()=>{const P=_=>{const D=_.target;(v==null?void 0:v.contains(D))&&C(_,E)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[y,v,E,C]),m.useEffect(T,[r,T]),pr(v,I),pr(p.content,I),c.jsx(Q0,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:T,onThumbPointerDown:vt(a),children:c.jsx(ke.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:ae(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),x.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(P))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,P=>{const _=P.target;_.hasPointerCapture(P.pointerId)&&_.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),bs="ScrollAreaThumb",Xf=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Gf(bs,e.__scopeScrollArea);return c.jsx(Mt,{present:n||o.hasThumb,children:c.jsx(eS,{ref:t,...r})})}),eS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Wt(bs,n),i=Gf(bs,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Cs(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=rS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(ke.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,w=f.clientY-p.top;i.onThumbPointerDown({x:v,y:w})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Xf.displayName=bs;var Ca="ScrollAreaCorner",Jf=m.forwardRef((e,t)=>{const n=Wt(Ca,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(tS,{...e,ref:t}):null});Jf.displayName=Ca;var tS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Wt(Ca,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return pr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),pr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(ke.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 ys(e){return e?parseInt(e,10):0}function Zf(e,t){const n=e/t;return isNaN(n)?0:n}function Ss(e){const t=Zf(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function nS(e,t,n,r="ltr"){const o=Ss(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return eh([l,u],f)(e)}function Qf(e,t,n="ltr"){const r=Ss(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=wa(e,l);return eh([0,i],[0,a])(u)}function eh(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 th(e,t){return e>0&&e<t}var rS=(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 Cs(e,t){const n=vt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function pr(e,t){const n=vt(t);xt(()=>{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 nh=Wf,oS=Kf,sS=Jf;const rh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nh,{ref:r,className:J("relative overflow-hidden",e),...n,children:[c.jsx(oS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(oh,{}),c.jsx(sS,{})]}));rh.displayName=nh.displayName;const oh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(ya,{ref:r,orientation:t,className:J("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Xf,{className:"relative flex-1 rounded-full bg-border"})}));oh.displayName=ya.displayName;function Ta({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:p,createThread:v,deleteThread:w,renameThread:g,isLoadingThreads:x}=ho(),[b,y]=S.useState(h??[]),[E,C]=S.useState(null),[T,I]=S.useState(""),[A,P]=S.useState(!1);S.useEffect(()=>{y(h??[])},[h]);const _=async N=>{try{await f(N),a==null||a(N),l==null||l(N)}catch(V){console.error("Failed to select thread:",V)}},D=async()=>{try{P(!0);const N=await v();u==null||u(N),a==null||a(N)}catch(N){console.error("Failed to create thread:",N)}finally{P(!1)}},L=async(N,V)=>{if(V.stopPropagation(),!!confirm("Delete this thread?"))try{await w(N),d==null||d(N)}catch(X){console.error("Failed to delete thread:",X)}},F=(N,V)=>{V.stopPropagation(),C(N.threadId),I(N.title||`Thread ${N.threadId.slice(0,8)}`)},O=async N=>{if(T.trim())try{await g(N,T.trim()),C(null),I("")}catch(V){console.error("Failed to update title:",V)}},W=()=>{C(null),I("")},U=(N,V)=>{N.key==="Enter"?O(V):N.key==="Escape"&&W()},G=N=>{if(!N)return"";try{const V=new Date(N),pe=new Date().getTime()-V.getTime(),le=Math.floor(pe/(1e3*60*60*24));return le===0?V.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):le===1?"Yesterday":le<7?`${le} days ago`:V.toLocaleDateString()}catch{return""}},$=N=>N.title||`Thread ${N.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(We,{onClick:D,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(re.MessageSquarePlus,{size:20})})}),c.jsx(rh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(re.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(re.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((N,V)=>new Date(V.updatedAt||V.createdAt||"").getTime()-new Date(N.updatedAt||N.createdAt||"").getTime()).map(N=>c.jsxs("div",{onClick:()=>_(N.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===N.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:E===N.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:V=>V.stopPropagation(),children:[c.jsx(ws,{value:T,onChange:V=>I(V.target.value),onKeyDown:V=>U(V,N.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(We,{variant:"ghost",size:"sm",onClick:()=>O(N.threadId),className:"h-6 w-6 p-0",children:c.jsx(re.Check,{size:12})}),c.jsx(We,{variant:"ghost",size:"sm",onClick:W,className:"h-6 w-6 p-0",children:c.jsx(re.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:$(N)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(re.Calendar,{size:10}),c.jsx("span",{children:G(N.updatedAt||N.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==N.threadId&&c.jsx(We,{variant:"ghost",size:"sm",onClick:V=>F(N,V),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(re.Edit3,{size:12})}),n&&c.jsx(We,{variant:"ghost",size:"sm",onClick:V=>L(N.threadId,V),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(re.Trash2,{size:12})})]})]}),i===N.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},N.threadId))})})]})}function mr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function iS(e){if(typeof e!="string")return;const t=e.trim();if(t)return pn(t)}function sh(){const e=[mr("__API_BASE_URL__"),mr("__CHAT_API_BASE_URL__"),mr("__CHAT_API_URL__")];for(const t of e){const n=iS(t);if(n)return n}}function ih(){const e=[mr("__API_AUTH_TOKEN__"),mr("__CHAT_API_KEY__"),mr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ah(...e){for(const t of e)if(typeof t=="string"&&t.trim())return pn(t);return pn()}function lh(){const e={},t=sh(),n=ih();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ch(){const e=lh(),t=yn.getAuthToken(),n=sh();return{apiBaseUrl:ah(e.baseUrl,yn.baseUrl,n),apiKey:t||e.apiKey||ih()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const uh="chat-settings";function aS(){try{const e=localStorage.getItem(uh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function lS(e){try{const t={...e,apiBaseUrl:pn(e.apiBaseUrl)};localStorage.setItem(uh,JSON.stringify(t)),t.apiKey&&yn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function cS(){const e=ch(),t=aS(),n=yn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ah(yn.baseUrl,r,e.apiBaseUrl)}}function uS(e){yn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),lS(e)}var dS="Label",dh=m.forwardRef((e,t)=>c.jsx(ke.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())}}));dh.displayName=dS;var fh=dh;const fS=Qr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vt=m.forwardRef(({className:e,...t},n)=>c.jsx(fh,{ref:n,className:J(fS(),e),...t}));Vt.displayName=fh.displayName;function hh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ts="Switch",[hS,LC]=on(Ts),[pS,mS]=hS(Ts),ph=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=Le(t,y=>p(y)),w=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=Un({prop:o,defaultProp:s??!1,onChange:u,caller:Ts});return c.jsxs(pS,{scope:n,checked:x,disabled:a,children:[c.jsx(ke.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":vh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ae(e.onClick,y=>{b(E=>!E),g&&(w.current=y.isPropagationStopped(),w.current||y.stopPropagation())})}),g&&c.jsx(xh,{control:h,bubbles:!w.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});ph.displayName=Ts;var mh="SwitchThumb",gh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=mS(mh,n);return c.jsx(ke.span,{"data-state":vh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});gh.displayName=mh;var gS="SwitchBubbleInput",xh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Le(i,s),l=hh(n),u=Id(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xh.displayName=gS;function vh(e){return e?"checked":"unchecked"}var wh=ph,xS=gh;const _n=m.forwardRef(({className:e,...t},n)=>c.jsx(wh,{className:J("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(xS,{className:J("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=wh.displayName;var bh=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"}),vS="VisuallyHidden",wS=m.forwardRef((e,t)=>c.jsx(ke.span,{...e,ref:t,style:{...bh,...e.style}}));wS.displayName=vS;var bS=[" ","Enter","ArrowUp","ArrowDown"],yS=[" ","Enter"],Jn="Select",[ks,Es,SS]=Gi(Jn),[gr,FC]=on(Jn,[SS,fs]),Is=fs(),[CS,Rn]=gr(Jn),[TS,kS]=gr(Jn),yh=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,w=Is(t),[g,x]=m.useState(null),[b,y]=m.useState(null),[E,C]=m.useState(!1),T=ts(u),[I,A]=Un({prop:r,defaultProp:o??!1,onChange:s,caller:Jn}),[P,_]=Un({prop:i,defaultProp:a,onChange:l,caller:Jn}),D=m.useRef(null),L=g?v||!!g.closest("form"):!0,[F,O]=m.useState(new Set),W=Array.from(F).map(U=>U.props.value).join(";");return c.jsx(Ld,{...w,children:c.jsxs(CS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:sn(),value:P,onValueChange:_,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:D,disabled:h,children:[c.jsx(ks.Provider,{scope:t,children:c.jsx(TS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(U=>{O(G=>new Set(G).add(U))},[]),onNativeOptionRemove:m.useCallback(U=>{O(G=>{const $=new Set(G);return $.delete(U),$})},[]),children:n})}),L?c.jsxs(Vh,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:P,onChange:U=>_(U.target.value),disabled:h,form:v,children:[P===void 0?c.jsx("option",{value:""}):null,Array.from(F)]},W):null]})})};yh.displayName=Jn;var Sh="SelectTrigger",Ch=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Is(n),i=Rn(Sh,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),u=Es(n),d=m.useRef("touch"),[f,h,p]=qh(w=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),b=Gh(g,w,x);b!==void 0&&i.onValueChange(b.value)}),v=w=>{a||(i.onOpenChange(!0),p()),w&&(i.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return c.jsx(Fd,{asChild:!0,...s,children:c.jsx(ke.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":Kh(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&v(w)}),onPointerDown:ae(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"&&(v(w),w.preventDefault())}),onKeyDown:ae(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&bS.includes(w.key)&&(v(),w.preventDefault())})})})});Ch.displayName=Sh;var Th="SelectValue",kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Rn(Th,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return xt(()=>{u(d)},[u,d]),c.jsx(ke.span,{...a,ref:f,style:{pointerEvents:"none"},children:Kh(l.value)?c.jsx(c.Fragment,{children:i}):s})});kh.displayName=Th;var ES="SelectIcon",Eh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ke.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Eh.displayName=ES;var IS="SelectPortal",Ih=e=>c.jsx($o,{asChild:!0,...e});Ih.displayName=IS;var Zn="SelectContent",Nh=m.forwardRef((e,t)=>{const n=Rn(Zn,e.__scopeSelect),[r,o]=m.useState();if(xt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(c.jsx(Ah,{scope:e.__scopeSelect,children:c.jsx(ks.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(jh,{...e,ref:t})});Nh.displayName=Zn;var Qt=10,[Ah,Pn]=gr(Zn),NS="SelectContentImpl",AS=Mn.createSlot("SelectContent.RemoveScroll"),jh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:w,avoidCollisions:g,...x}=e,b=Rn(Zn,n),[y,E]=m.useState(null),[C,T]=m.useState(null),I=Le(t,z=>E(z)),[A,P]=m.useState(null),[_,D]=m.useState(null),L=Es(n),[F,O]=m.useState(!1),W=m.useRef(!1);m.useEffect(()=>{if(y)return Hi(y)},[y]),Di();const U=m.useCallback(z=>{const[M,...q]=L().map(te=>te.ref.current),[Z]=q.slice(-1),ce=document.activeElement;for(const te of z)if(te===ce||(te==null||te.scrollIntoView({block:"nearest"}),te===M&&C&&(C.scrollTop=0),te===Z&&C&&(C.scrollTop=C.scrollHeight),te==null||te.focus(),document.activeElement!==ce))return},[L,C]),G=m.useCallback(()=>U([A,y]),[U,A,y]);m.useEffect(()=>{F&&G()},[F,G]);const{onOpenChange:$,triggerPointerDownPosRef:N}=b;m.useEffect(()=>{if(y){let z={x:0,y:0};const M=Z=>{var ce,te;z={x:Math.abs(Math.round(Z.pageX)-(((ce=N.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((te=N.current)==null?void 0:te.y)??0))}},q=Z=>{z.x<=10&&z.y<=10?Z.preventDefault():y.contains(Z.target)||$(!1),document.removeEventListener("pointermove",M),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",M),document.addEventListener("pointerup",q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",q,{capture:!0})}}},[y,$,N]),m.useEffect(()=>{const z=()=>$(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[$]);const[V,X]=qh(z=>{const M=L().filter(ce=>!ce.disabled),q=M.find(ce=>ce.ref.current===document.activeElement),Z=Gh(M,z,q);Z&&setTimeout(()=>Z.ref.current.focus())}),pe=m.useCallback((z,M,q)=>{const Z=!W.current&&!q;(b.value!==void 0&&b.value===M||Z)&&(P(z),Z&&(W.current=!0))},[b.value]),le=m.useCallback(()=>y==null?void 0:y.focus(),[y]),fe=m.useCallback((z,M,q)=>{const Z=!W.current&&!q;(b.value!==void 0&&b.value===M||Z)&&D(z)},[b.value]),ye=r==="popper"?ka:_h,we=ye===ka?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:w,avoidCollisions:g}:{};return c.jsx(Ah,{scope:n,content:y,viewport:C,onViewportChange:T,itemRefCallback:pe,selectedItem:A,onItemLeave:le,itemTextRefCallback:fe,focusSelectedItem:G,selectedItemText:_,position:r,isPositioned:F,searchRef:V,children:c.jsx(Vo,{as:AS,allowPinchZoom:!0,children:c.jsx(Fo,{asChild:!0,trapped:b.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:ae(o,z=>{var M;(M=b.trigger)==null||M.focus({preventScroll:!0}),z.preventDefault()}),children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ye,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:z=>z.preventDefault(),...x,...we,onPlaced:()=>O(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:ae(x.onKeyDown,z=>{const M=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!M&&z.key.length===1&&X(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Z=L().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const ce=z.target,te=Z.indexOf(ce);Z=Z.slice(te+1)}setTimeout(()=>U(Z)),z.preventDefault()}})})})})})})});jh.displayName=NS;var jS="SelectItemAlignedPosition",_h=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Rn(Zn,n),i=Pn(Zn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Le(t,I=>d(I)),h=Es(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,y=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),_=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=_.left-A.left,te=P.left-ce,Fe=I.left-te,Qe=I.width+Fe,et=Math.max(Qe,A.width),je=window.innerWidth-Qt,Oe=wa(te,[Qt,Math.max(Qt,je-et)]);a.style.minWidth=Qe+"px",a.style.left=Oe+"px"}else{const ce=A.right-_.right,te=window.innerWidth-P.right-ce,Fe=window.innerWidth-I.right-te,Qe=I.width+Fe,et=Math.max(Qe,A.width),je=window.innerWidth-Qt,Oe=wa(te,[Qt,Math.max(Qt,je-et)]);a.style.minWidth=Qe+"px",a.style.right=Oe+"px"}const D=h(),L=window.innerHeight-Qt*2,F=w.scrollHeight,O=window.getComputedStyle(u),W=parseInt(O.borderTopWidth,10),U=parseInt(O.paddingTop,10),G=parseInt(O.borderBottomWidth,10),$=parseInt(O.paddingBottom,10),N=W+U+F+$+G,V=Math.min(g.offsetHeight*5,N),X=window.getComputedStyle(w),pe=parseInt(X.paddingTop,10),le=parseInt(X.paddingBottom,10),fe=I.top+I.height/2-Qt,ye=L-fe,we=g.offsetHeight/2,z=g.offsetTop+we,M=W+U+z,q=N-M;if(M<=fe){const ce=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";const te=u.clientHeight-w.offsetTop-w.offsetHeight,Fe=Math.max(ye,we+(ce?le:0)+te+G),Qe=M+Fe;a.style.height=Qe+"px"}else{const ce=D.length>0&&g===D[0].ref.current;a.style.top="0px";const Fe=Math.max(fe,W+w.offsetTop+(ce?pe:0)+we)+q;a.style.height=Fe+"px",w.scrollTop=M-fe+w.offsetTop}a.style.margin=`${Qt}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,x,s.dir,r]);xt(()=>y(),[y]);const[E,C]=m.useState();xt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&v.current===!0&&(y(),b==null||b(),v.current=!1)},[y,b]);return c.jsx(RS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(ke.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});_h.displayName=jS;var _S="SelectPopperPosition",ka=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Qt,...s}=e,i=Is(n);return c.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)"}})});ka.displayName=_S;var[RS,Ea]=gr(Zn,{}),Ia="SelectViewport",Rh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Pn(Ia,n),i=Ea(Ia,n),a=Le(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(ks.Slot,{scope:n,children:c.jsx(ke.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-Qt*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(w,g);if(x<v){const b=x+p,y=Math.min(v,b),E=b-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Rh.displayName=Ia;var Ph="SelectGroup",[PS,OS]=gr(Ph),MS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=sn();return c.jsx(PS,{scope:n,id:o,children:c.jsx(ke.div,{role:"group","aria-labelledby":o,...r,ref:t})})});MS.displayName=Ph;var Oh="SelectLabel",Mh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=OS(Oh,n);return c.jsx(ke.div,{id:o.id,...r,ref:t})});Mh.displayName=Oh;var Ns="SelectItem",[DS,Dh]=gr(Ns),Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Rn(Ns,n),l=Pn(Ns,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=Le(t,b=>{var y;return(y=l.itemRefCallback)==null?void 0:y.call(l,b,r,o)}),w=sn(),g=m.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(DS,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:m.useCallback(b=>{f(y=>y||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ke.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:v,onFocus:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!1)),onClick:ae(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:ae(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var y;g.current=b.pointerType,o?(y=l.onItemLeave)==null||y.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var y;b.currentTarget===document.activeElement&&((y=l.onItemLeave)==null||y.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(yS.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Lh.displayName=Ns;var Xr="SelectItemText",Fh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Rn(Xr,n),a=Pn(Xr,n),l=Dh(Xr,n),u=kS(Xr,n),[d,f]=m.useState(null),h=Le(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:w,onNativeOptionRemove:g}=u;return xt(()=>(w(v),()=>g(v)),[w,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(ke.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});Fh.displayName=Xr;var $h="SelectItemIndicator",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Dh($h,n).isSelected?c.jsx(ke.span,{"aria-hidden":!0,...r,ref:t}):null});zh.displayName=$h;var Na="SelectScrollUpButton",Bh=m.forwardRef((e,t)=>{const n=Pn(Na,e.__scopeSelect),r=Ea(Na,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return xt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Uh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Bh.displayName=Na;var Aa="SelectScrollDownButton",Hh=m.forwardRef((e,t)=>{const n=Pn(Aa,e.__scopeSelect),r=Ea(Aa,e.__scopeSelect),[o,s]=m.useState(!1),i=Le(t,r.onScrollButtonChange);return xt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Uh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Hh.displayName=Aa;var Uh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Pn("SelectScrollButton",n),i=m.useRef(null),a=Es(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),xt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(ke.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),LS="SelectSeparator",Wh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ke.div,{"aria-hidden":!0,...r,ref:t})});Wh.displayName=LS;var ja="SelectArrow",FS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Is(n),s=Rn(ja,n),i=Pn(ja,n);return s.open&&i.position==="popper"?c.jsx(zd,{...o,...r,ref:t}):null});FS.displayName=ja;var $S="SelectBubbleInput",Vh=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Le(r,o),i=hh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(ke.select,{...n,style:{...bh,...n.style},ref:s,defaultValue:t})});Vh.displayName=$S;function Kh(e){return e===""||e===void 0}function qh(e){const t=vt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Gh(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=zS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function zS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var BS=yh,Yh=Ch,HS=kh,US=Eh,WS=Ih,Xh=Nh,VS=Rh,Jh=Mh,Zh=Lh,KS=Fh,qS=zh,Qh=Bh,ep=Hh,tp=Wh;const np=BS,rp=HS,_a=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Yh,{ref:r,className:J("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(US,{asChild:!0,children:c.jsx(re.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));_a.displayName=Yh.displayName;const op=m.forwardRef(({className:e,...t},n)=>c.jsx(Qh,{ref:n,className:J("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronUp,{className:"h-4 w-4"})}));op.displayName=Qh.displayName;const sp=m.forwardRef(({className:e,...t},n)=>c.jsx(ep,{ref:n,className:J("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(re.ChevronDown,{className:"h-4 w-4"})}));sp.displayName=ep.displayName;const Ra=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(WS,{children:c.jsxs(Xh,{ref:o,className:J("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(op,{}),c.jsx(VS,{className:J("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(sp,{})]})}));Ra.displayName=Xh.displayName;const GS=m.forwardRef(({className:e,...t},n)=>c.jsx(Jh,{ref:n,className:J("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));GS.displayName=Jh.displayName;const Qn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Zh,{ref:r,className:J("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(qS,{children:c.jsx(re.Check,{className:"h-4 w-4"})})}),c.jsx(KS,{children:t})]}));Qn.displayName=Zh.displayName;const YS=m.forwardRef(({className:e,...t},n)=>c.jsx(tp,{ref:n,className:J("-mx-1 my-1 h-px bg-muted",e),...t}));YS.displayName=tp.displayName;var XS="Separator",ip="horizontal",JS=["horizontal","vertical"],ap=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=ip,...o}=e,s=ZS(r)?r:ip,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(ke.div,{"data-orientation":s,...a,...o,ref:t})});ap.displayName=XS;function ZS(e){return JS.includes(e)}var lp=ap;const cp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(lp,{ref:o,decorative:n,orientation:t,className:J("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));cp.displayName=lp.displayName;const QS=Vu,eC=Pw,tC=Ku,up=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{className:J("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}));up.displayName=Xo.displayName;const nC=Qr.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"}}),dp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(tC,{children:[c.jsx(up,{}),c.jsxs(Jo,{ref:o,className:J(nC({side:e}),t),...r,children:[n,c.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:[c.jsx(re.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));dp.displayName=Jo.displayName;const fp=({className:e,...t})=>c.jsx("div",{className:J("flex flex-col space-y-2 text-center sm:text-left",e),...t});fp.displayName="SheetHeader";const hp=m.forwardRef(({className:e,...t},n)=>c.jsx(Kn,{ref:n,className:J("text-lg font-semibold text-foreground",e),...t}));hp.displayName=Kn.displayName;const pp=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:J("text-sm text-muted-foreground",e),...t}));pp.displayName=Zo.displayName;const rC={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 oC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=S.useState(!1),[s,i]=S.useState(!1),[a,l]=S.useState(e),[u,d]=S.useState(!1),{toast:f}=_i();S.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),S.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(rC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(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 c.jsxs(QS,{open:r,onOpenChange:o,children:[c.jsx(eC,{asChild:!0,children:c.jsxs(We,{variant:"outline",size:"sm",className:n,children:[c.jsx(re.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(yi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(dp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(fp,{children:[c.jsx(hp,{children:"Chat Settings"}),c.jsx(pp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Vt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ws,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(We,{variant:"outline",onClick:w,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Vt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(_n,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Vt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(ws,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(We,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(re.EyeOff,{className:"h-4 w-4"}):c.jsx(re.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Vt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(np,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(_a,{children:c.jsx(rp,{})}),c.jsxs(Ra,{children:[c.jsx(Qn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Qn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Qn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Vt,{htmlFor:"theme",children:"Theme"}),c.jsxs(np,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(_a,{children:c.jsx(rp,{})}),c.jsxs(Ra,{children:[c.jsx(Qn,{value:"light",children:"Light"}),c.jsx(Qn,{value:"dark",children:"Dark"}),c.jsx(Qn,{value:"system",children:"System"})]})]})]}),c.jsx(cp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Vt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(_n,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Vt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(_n,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Vt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(_n,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(re.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Vt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(_n,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Vt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(_n,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Vt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(_n,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(We,{variant:"outline",onClick:p,children:[c.jsx(re.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(We,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(We,{onClick:h,disabled:!u,children:[c.jsx(re.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function sC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=S.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(vs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ta,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(vs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(po,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ta,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(vs,{onError:s.onError,enableFileUpload:!0})})]})})}Ne.ChatApi=Il,Ne.ChatInterface=vs,Ne.ChatProviders=po,Ne.ChatSettings=oC,Ne.MarkdownContent=Ni,Ne.MessageComponent=nd,Ne.MessageList=qi,Ne.ThreadManager=Ta,Ne.applySettings=uS,Ne.chatApiClient=yn,Ne.default=sC,Ne.del=El,Ne.get=_t,Ne.getChatToken=Cl,Ne.getCurrentSettings=cS,Ne.getDefaultApiConfig=lh,Ne.getDefaultChatSettings=ch,Ne.onChatTokenChanged=Tl,Ne.post=Ks,Ne.put=kl,Ne.setChatToken=Vs,Ne.useApi=qs,Ne.useChatStream=_l,Ne.useMessages=Js,Ne.useMessagesReducer=Al,Ne.useStream=Ml,Ne.useThreads=ho,Object.defineProperties(Ne,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|