teodor-new-chat-ui 4.3.392 → 4.3.393
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/components/ui/resizable.d.ts +1 -1
- package/dist/index.esm.js +3690 -3567
- package/dist/index.umd.js +43 -43
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Ce,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ce=typeof globalThis<"u"?globalThis:Ce||self,y(Ce.NewChatUI={},Ce.React,Ce.LucideReact,Ce.reactSlot,Ce.classVarianceAuthority,Ce.clsx,Ce.tailwindMerge,Ce.ReactDOM))})(this,function(Ce,y,ae,zn,
|
|
1
|
+
(function(Ce,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],y):(Ce=typeof globalThis<"u"?globalThis:Ce||self,y(Ce.NewChatUI={},Ce.React,Ce.LucideReact,Ce.reactSlot,Ce.classVarianceAuthority,Ce.clsx,Ce.tailwindMerge,Ce.ReactDOM))})(this,function(Ce,y,ae,zn,wo,mm,gm,Qs){"use strict";var hT=Object.defineProperty;var pT=(Ce,y,ae)=>y in Ce?hT(Ce,y,{enumerable:!0,configurable:!0,writable:!0,value:ae}):Ce[y]=ae;var hm=(Ce,y,ae)=>pT(Ce,typeof y!="symbol"?y+"":y,ae);var ei=typeof document<"u"?document.currentScript:null;function ul(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=ul(y),bo=ul(Qs);var ti={exports:{}},Ar={};/**
|
|
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 dl;function xm(){if(dl)return Ar;dl=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:h,ref:p,props:f,_owner:o.current}}return Ar.Fragment=n,Ar.jsx=i,Ar.jsxs=i,Ar}var jr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,33 +14,34 @@
|
|
|
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
|
-
`+Y+N}}var
|
|
17
|
+
*/var fl;function vm(){return fl||(fl=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,w="@@iterator";function g(N){if(N===null||typeof N!="object")return null;var ee=v&&N[v]||N[w];return typeof ee=="function"?ee:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var ee=arguments.length,ce=new Array(ee>1?ee-1:0),Ee=1;Ee<ee;Ee++)ce[Ee-1]=arguments[Ee];C("error",N,ce)}}function C(N,ee,ce){{var Ee=x.ReactDebugCurrentFrame,Qe=Ee.getStackAddendum();Qe!==""&&(ee+="%s",ce=ce.concat([Qe]));var rt=ce.map(function(Be){return String(Be)});rt.unshift("Warning: "+ee),Function.prototype.apply.call(console[N],console,rt)}}var T=!1,S=!1,k=!1,E=!1,j=!1,O;O=Symbol.for("react.module.reference");function F(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===u||N===d||E||N===p||T||S||k||typeof N=="object"&&N!==null&&(N.$$typeof===h||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===O||N.getModuleId!==void 0))}function H(N,ee,ce){var Ee=N.displayName;if(Ee)return Ee;var Qe=ee.displayName||ee.name||"";return Qe!==""?ce+"("+Qe+")":ce}function U(N){return N.displayName||"Context"}function K(N){if(N==null)return null;if(typeof N.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){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 N=="object")switch(N.$$typeof){case a:var ee=N;return U(ee)+".Consumer";case i:var ce=N;return U(ce._context)+".Provider";case l:return H(N,N.render,"ForwardRef");case f:var Ee=N.displayName||null;return Ee!==null?Ee:K(N.type)||"Memo";case h:{var Qe=N,rt=Qe._payload,Be=Qe._init;try{return K(Be(rt))}catch{return null}}}return null}var P=Object.assign,z=0,I,D,R,A,B,W,_;function V(){}V.__reactDisabledLog=!0;function ie(){{if(z===0){I=console.log,D=console.info,R=console.warn,A=console.error,B=console.group,W=console.groupCollapsed,_=console.groupEnd;var N={configurable:!0,enumerable:!0,value:V,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}z++}}function Q(){{if(z--,z===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},N,{value:I}),info:P({},N,{value:D}),warn:P({},N,{value:R}),error:P({},N,{value:A}),group:P({},N,{value:B}),groupCollapsed:P({},N,{value:W}),groupEnd:P({},N,{value:_})})}z<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=x.ReactCurrentDispatcher,Y;function L(N,ee,ce){{if(Y===void 0)try{throw Error()}catch(Qe){var Ee=Qe.stack.trim().match(/\n( *(at )?)/);Y=Ee&&Ee[1]||""}return`
|
|
18
|
+
`+Y+N}}var q=!1,te;{var G=typeof WeakMap=="function"?WeakMap:Map;te=new G}function X(N,ee){if(!N||q)return"";{var ce=te.get(N);if(ce!==void 0)return ce}var Ee;q=!0;var Qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var rt;rt=oe.current,oe.current=null,ie();try{if(ee){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(Ge){Ee=Ge}Reflect.construct(N,[],Be)}else{try{Be.call()}catch(Ge){Ee=Ge}N.call(Be.prototype)}}else{try{throw Error()}catch(Ge){Ee=Ge}N()}}catch(Ge){if(Ge&&Ee&&typeof Ge.stack=="string"){for(var Fe=Ge.stack.split(`
|
|
19
19
|
`),At=Ee.stack.split(`
|
|
20
20
|
`),pt=Fe.length-1,gt=At.length-1;pt>=1&>>=0&&Fe[pt]!==At[gt];)gt--;for(;pt>=1&>>=0;pt--,gt--)if(Fe[pt]!==At[gt]){if(pt!==1||gt!==1)do if(pt--,gt--,gt<0||Fe[pt]!==At[gt]){var ge=`
|
|
21
|
-
`+Fe[pt].replace(" at new "," at ");return N.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",N.displayName)),typeof N=="function"&&te.set(N,ge),ge}while(pt>=1&>>=0);break}}}finally{
|
|
21
|
+
`+Fe[pt].replace(" at new "," at ");return N.displayName&&ge.includes("<anonymous>")&&(ge=ge.replace("<anonymous>",N.displayName)),typeof N=="function"&&te.set(N,ge),ge}while(pt>=1&>>=0);break}}}finally{q=!1,oe.current=rt,Q(),Error.prepareStackTrace=Qe}var Se=N?N.displayName||N.name:"",Ae=Se?L(Se):"";return typeof N=="function"&&te.set(N,Ae),Ae}function he(N,ee,ce){return X(N,!1)}function fe(N){var ee=N.prototype;return!!(ee&&ee.isReactComponent)}function Z(N,ee,ce){if(N==null)return"";if(typeof N=="function")return X(N,fe(N));if(typeof N=="string")return L(N);switch(N){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return he(N.render);case f:return Z(N.type,ee,ce);case h:{var Ee=N,Qe=Ee._payload,rt=Ee._init;try{return Z(rt(Qe),ee,ce)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,we={},_e=x.ReactDebugCurrentFrame;function Ne(N){if(N){var ee=N._owner,ce=Z(N.type,N._source,ee?ee.type:null);_e.setExtraStackFrame(ce)}else _e.setExtraStackFrame(null)}function $e(N,ee,ce,Ee,Qe){{var rt=Function.call.bind(le);for(var Be in N)if(rt(N,Be)){var Fe=void 0;try{if(typeof N[Be]!="function"){var At=Error((Ee||"React class")+": "+ce+" type `"+Be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw At.name="Invariant Violation",At}Fe=N[Be](ee,Be,Ee,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pt){Fe=pt}Fe&&!(Fe instanceof Error)&&(Ne(Qe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",ce,Be,typeof Fe),Ne(null)),Fe instanceof Error&&!(Fe.message in we)&&(we[Fe.message]=!0,Ne(Qe),b("Failed %s type: %s",ce,Fe.message),Ne(null))}}}var Xe=Array.isArray;function nt(N){return Xe(N)}function Ve(N){{var ee=typeof Symbol=="function"&&Symbol.toStringTag,ce=ee&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ce}}function qe(N){try{return ot(N),!1}catch{return!0}}function ot(N){return""+N}function kt(N){if(qe(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(N)),ot(N)}var lt=x.ReactCurrentOwner,Te={key:!0,ref:!0,__self:!0,__source:!0},Oe,at;function ht(N){if(le.call(N,"ref")){var ee=Object.getOwnPropertyDescriptor(N,"ref").get;if(ee&&ee.isReactWarning)return!1}return N.ref!==void 0}function Tt(N){if(le.call(N,"key")){var ee=Object.getOwnPropertyDescriptor(N,"key").get;if(ee&&ee.isReactWarning)return!1}return N.key!==void 0}function St(N,ee){typeof N.ref=="string"&<.current}function Le(N,ee){{var ce=function(){Oe||(Oe=!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)",ee))};ce.isReactWarning=!0,Object.defineProperty(N,"key",{get:ce,configurable:!0})}}function Ht(N,ee){{var ce=function(){at||(at=!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)",ee))};ce.isReactWarning=!0,Object.defineProperty(N,"ref",{get:ce,configurable:!0})}}var Je=function(N,ee,ce,Ee,Qe,rt,Be){var Fe={$$typeof:t,type:N,key:ee,ref:ce,props:Be,_owner:rt};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Qe}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function Ke(N,ee,ce,Ee,Qe){{var rt,Be={},Fe=null,At=null;ce!==void 0&&(kt(ce),Fe=""+ce),Tt(ee)&&(kt(ee.key),Fe=""+ee.key),ht(ee)&&(At=ee.ref,St(ee,Qe));for(rt in ee)le.call(ee,rt)&&!Te.hasOwnProperty(rt)&&(Be[rt]=ee[rt]);if(N&&N.defaultProps){var pt=N.defaultProps;for(rt in pt)Be[rt]===void 0&&(Be[rt]=pt[rt])}if(Fe||At){var gt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Fe&&Le(Be,gt),At&&Ht(Be,gt)}return Je(N,Fe,At,Qe,Ee,lt.current,Be)}}var dt=x.ReactCurrentOwner,wt=x.ReactDebugCurrentFrame;function Ue(N){if(N){var ee=N._owner,ce=Z(N.type,N._source,ee?ee.type:null);wt.setExtraStackFrame(ce)}else wt.setExtraStackFrame(null)}var Ct;Ct=!1;function M(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function se(){{if(dt.current){var N=K(dt.current.type);if(N)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+N+"`."}return""}}function me(N){return""}var We={};function Pe(N){{var ee=se();if(!ee){var ce=typeof N=="string"?N:N.displayName||N.name;ce&&(ee=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ce+">.")}return ee}}function mt(N,ee){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ce=Pe(ee);if(We[ce])return;We[ce]=!0;var Ee="";N&&N._owner&&N._owner!==dt.current&&(Ee=" It was passed a child from "+
|
|
25
|
+
Check the top-level render call using <`+ce+">.")}return ee}}function mt(N,ee){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ce=Pe(ee);if(We[ce])return;We[ce]=!0;var Ee="";N&&N._owner&&N._owner!==dt.current&&(Ee=" It was passed a child from "+K(N._owner.type)+"."),Ue(N),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ce,Ee),Ue(null)}}function Ze(N,ee){{if(typeof N!="object")return;if(nt(N))for(var ce=0;ce<N.length;ce++){var Ee=N[ce];M(Ee)&&mt(Ee,ee)}else if(M(N))N._store&&(N._store.validated=!0);else if(N){var Qe=g(N);if(typeof Qe=="function"&&Qe!==N.entries)for(var rt=Qe.call(N),Be;!(Be=rt.next()).done;)M(Be.value)&&mt(Be.value,ee)}}}function Nt(N){{var ee=N.type;if(ee==null||typeof ee=="string")return;var ce;if(typeof ee=="function")ce=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===f))ce=ee.propTypes;else return;if(ce){var Ee=K(ee);$e(ce,N.props,"prop",Ee,N)}else if(ee.PropTypes!==void 0&&!Ct){Ct=!0;var Qe=K(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Qe||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xo(N){{for(var ee=Object.keys(N.props),ce=0;ce<ee.length;ce++){var Ee=ee[ce];if(Ee!=="children"&&Ee!=="key"){Ue(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),Ue(null);break}}N.ref!==null&&(Ue(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var vo={};function Js(N,ee,ce,Ee,Qe,rt){{var Be=F(N);if(!Be){var Fe="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Fe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var At=me();At?Fe+=At:Fe+=se();var pt;N===null?pt="null":nt(N)?pt="array":N!==void 0&&N.$$typeof===t?(pt="<"+(K(N.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):pt=typeof N,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pt,Fe)}var gt=Ke(N,ee,ce,Qe,rt);if(gt==null)return gt;if(Be){var ge=ee.children;if(ge!==void 0)if(Ee)if(nt(ge)){for(var Se=0;Se<ge.length;Se++)Ze(ge[Se],N);Object.freeze&&Object.freeze(ge)}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 Ze(ge,N)}if(le.call(ee,"key")){var Ae=K(N),Ge=Object.keys(ee).filter(function(fT){return fT!=="key"}),Bn=Ge.length>0?"{key: someKey, "+Ge.join(": ..., ")+": ...}":"{key: someKey}";if(!vo[Ae+Bn]){var tn=Ge.length>0?"{"+Ge.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Bn,Ae,tn,Ae),go[Ae+Bn]=!0}}return N===r?mo(gt):Nt(gt),gt}}function rl(N,ee,ce){return Xs(N,ee,ce,!0)}function ol(N,ee,ce){return Xs(N,ee,ce,!1)}var sl=ol,Js=rl;Ar.Fragment=r,Ar.jsx=sl,Ar.jsxs=Js}()),Ar}process.env.NODE_ENV==="production"?ei.exports=hm():ei.exports=pm();var l=ei.exports;function cl(e,t){return function(){return e.apply(t,arguments)}}const{toString:mm}=Object.prototype,{getPrototypeOf:ti}=Object,{iterator:bo,toStringTag:ul}=Symbol,wo=(e=>t=>{const n=mm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),nn=e=>(e=e.toLowerCase(),t=>wo(t)===e),yo=e=>t=>typeof t===e,{isArray:ar}=Array,lr=yo("undefined");function jr(e){return e!==null&&!lr(e)&&e.constructor!==null&&!lr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const dl=nn("ArrayBuffer");function gm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&dl(e.buffer),t}const xm=yo("string"),Lt=yo("function"),fl=yo("number"),_r=e=>e!==null&&typeof e=="object",vm=e=>e===!0||e===!1,So=e=>{if(wo(e)!=="object")return!1;const t=ti(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ul in e)&&!(bo in e)},bm=e=>{if(!_r(e)||jr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},wm=nn("Date"),ym=nn("File"),Sm=nn("Blob"),Cm=nn("FileList"),km=e=>_r(e)&&Lt(e.pipe),Tm=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=wo(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},Em=nn("URLSearchParams"),[Im,Nm,Am,jm]=["ReadableStream","Request","Response","Headers"].map(nn),_m=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Mr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ar(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(jr(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 hl(e,t){if(jr(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 Hn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,pl=e=>!lr(e)&&e!==Hn;function ni(){const{caseless:e,skipUndefined:t}=pl(this)&&this||{},n={},r=(o,s)=>{const i=e&&hl(n,s)||s;So(n[i])&&So(o)?n[i]=ni(n[i],o):So(o)?n[i]=ni({},o):ar(o)?n[i]=o.slice():(!t||!lr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Mr(arguments[o],r);return n}const Mm=(e,t,n,{allOwnKeys:r}={})=>(Mr(t,(o,s)=>{n&&Lt(o)?e[s]=cl(o,n):e[s]=o},{allOwnKeys:r}),e),Rm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Pm=(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)},Om=(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&&ti(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Dm=(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},Lm=e=>{if(!e)return null;if(ar(e))return e;let t=e.length;if(!fl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},$m=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ti(Uint8Array)),Fm=(e,t)=>{const r=(e&&e[bo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Bm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},zm=nn("HTMLFormElement"),Hm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),ml=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Um=nn("RegExp"),gl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Mr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Wm=e=>{gl(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Vm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ar(e)?r(e):r(String(e).split(t)),n},qm=()=>{},Km=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Gm(e){return!!(e&&Lt(e.append)&&e[ul]==="FormData"&&e[bo])}const Ym=e=>{const t=new Array(10),n=(r,o)=>{if(_r(r)){if(t.indexOf(r)>=0)return;if(jr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ar(r)?[]:{};return Mr(r,(i,a)=>{const c=n(i,o+1);!lr(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},Xm=nn("AsyncFunction"),Jm=e=>e&&(_r(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),xl=((e,t)=>e?setImmediate:t?((n,r)=>(Hn.addEventListener("message",({source:o,data:s})=>{o===Hn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Hn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(Hn.postMessage)),Zm=typeof queueMicrotask<"u"?queueMicrotask.bind(Hn):typeof process<"u"&&process.nextTick||xl,$={isArray:ar,isArrayBuffer:dl,isBuffer:jr,isFormData:Tm,isArrayBufferView:gm,isString:xm,isNumber:fl,isBoolean:vm,isObject:_r,isPlainObject:So,isEmptyObject:bm,isReadableStream:Im,isRequest:Nm,isResponse:Am,isHeaders:jm,isUndefined:lr,isDate:wm,isFile:ym,isBlob:Sm,isRegExp:Um,isFunction:Lt,isStream:km,isURLSearchParams:Em,isTypedArray:$m,isFileList:Cm,forEach:Mr,merge:ni,extend:Mm,trim:_m,stripBOM:Rm,inherits:Pm,toFlatObject:Om,kindOf:wo,kindOfTest:nn,endsWith:Dm,toArray:Lm,forEachEntry:Fm,matchAll:Bm,isHTMLForm:zm,hasOwnProperty:ml,hasOwnProp:ml,reduceDescriptors:gl,freezeMethods:Wm,toObjectSet:Vm,toCamelCase:Hm,noop:qm,toFiniteNumber:Km,findKey:hl,global:Hn,isContextDefined:pl,isSpecCompliantForm:Gm,toJSONObject:Ym,isAsyncFn:Xm,isThenable:Jm,setImmediate:xl,asap:Zm,isIterable:e=>e!=null&&Lt(e[bo])};function Me(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(Me,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 vl=Me.prototype,bl={};["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=>{bl[e]={value:e}}),Object.defineProperties(Me,bl),Object.defineProperty(vl,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(vl);$.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Me.call(i,a,c,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Qm=null;function ri(e){return $.isPlainObject(e)||$.isArray(e)}function wl(e){return $.endsWith(e,"[]")?e.slice(0,-2):e}function yl(e,t,n){return e?e.concat(t).map(function(o,s){return o=wl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function eg(e){return $.isArray(e)&&!e.some(ri)}const tg=$.toFlatObject($,{},null,function(t){return/^is[A-Z]/.test(t)});function Co(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(b,g){return!$.isUndefined(g[b])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&$.isSpecCompliantForm(t);if(!$.isFunction(o))throw new TypeError("visitor must be a function");function u(v){if(v===null)return"";if($.isDate(v))return v.toISOString();if($.isBoolean(v))return v.toString();if(!c&&$.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return $.isArrayBuffer(v)||$.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,b,g){let x=v;if(v&&!g&&typeof v=="object"){if($.endsWith(b,"{}"))b=r?b:b.slice(0,-2),v=JSON.stringify(v);else if($.isArray(v)&&eg(v)||($.isFileList(v)||$.endsWith(b,"[]"))&&(x=$.toArray(v)))return b=wl(b),x.forEach(function(C,T){!($.isUndefined(C)||C===null)&&t.append(i===!0?yl([b],T,s):i===null?b:b+"[]",u(C))}),!1}return ri(v)?!0:(t.append(yl(g,b,s),u(v)),!1)}const f=[],h=Object.assign(tg,{defaultVisitor:d,convertValue:u,isVisitable:ri});function p(v,b){if(!$.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+b.join("."));f.push(v),$.forEach(v,function(x,w){(!($.isUndefined(x)||x===null)&&o.call(t,x,$.isString(w)?w.trim():w,b,h))===!0&&p(x,b?b.concat(w):[w])}),f.pop()}}if(!$.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Sl(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function oi(e,t){this._pairs=[],e&&Co(e,this,t)}const Cl=oi.prototype;Cl.append=function(t,n){this._pairs.push([t,n])},Cl.toString=function(t){const n=t?function(r){return t.call(this,r,Sl)}:Sl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ng(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function kl(e,t,n){if(!t)return e;const r=n&&n.encode||ng;$.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=$.isURLSearchParams(t)?t.toString():new oi(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 El={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},rg={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:oi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},si=typeof window<"u"&&typeof document<"u",ii=typeof navigator=="object"&&navigator||void 0,og=si&&(!ii||["ReactNative","NativeScript","NS"].indexOf(ii.product)<0),sg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ig=si&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:si,hasStandardBrowserEnv:og,hasStandardBrowserWebWorkerEnv:sg,navigator:ii,origin:ig},Symbol.toStringTag,{value:"Module"})),...rg};function ag(e,t){return Co(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&$.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function lg(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function cg(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 Il(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&$.isArray(o)?o.length:i,c?($.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]=cg(o[i])),!a)}if($.isFormData(e)&&$.isFunction(e.entries)){const n={};return $.forEachEntry(e,(r,o)=>{t(lg(r),o,n,0)}),n}return null}function ug(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 Rr={transitional:El,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(Il(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 ag(t,this.formSerializer).toString();if((a=$.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Co(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),ug(t)):t}],transformResponse:[function(t){const n=this.transitional||Rr.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"?Me.from(a,Me.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:jt.classes.FormData,Blob:jt.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=>{Rr.headers[e]={}});const dg=$.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"]),fg=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]&&
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Nl]=this[Nl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Pr(i);r[a]||(gg(o,i),r[a]=!0)}return $.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),$.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),$.freezeMethods($t);function li(e,t){const n=this||Rr,r=t||n,o=$t.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 Al(e){return!!(e&&e.__CANCEL__)}function cr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}$.inherits(cr,Me,{__CANCEL__:!0});function jl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function xg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function vg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[s];i||(i=u),n[o]=c,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function bg(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 To=(e,t,n=3)=>{let r=0;const o=vg(50,250);return bg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,u=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},_l=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ml=e=>(...t)=>$.asap(()=>e(...t)),wg=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,yg=jt.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 Sg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Cg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Rl(e,t,n){let r=!Sg(t);return e&&(r||n==!1)?Cg(e,t):t}const Pl=e=>e instanceof $t?{...e}:e;function Un(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 c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Pl(u),Pl(d),f,!0)};return $.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);$.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ol=e=>{const t=Un({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=kl(Rl(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(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if($.isFunction(n.getHeaders)){const c=n.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(jt.hasStandardBrowserEnv&&(r&&$.isFunction(r)&&(r=r(t)),r||r!==!1&&wg(t.url))){const c=o&&s&&yg.read(s);c&&i.set(o,c)}return t},kg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ol(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,p,v;function b(){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 C=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:C,config:e,request:g};jl(function(E){n(E),b()},function(E){r(E),b()},S),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 Me("Request aborted",Me.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const S=T&&T.message?T.message:"Network Error",k=new Me(S,Me.ERR_NETWORK,e,g);k.event=T||null,r(k),g=null},g.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||El;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new Me(T,S.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&$.forEach(i.toJSON(),function(T,S){g.setRequestHeader(S,T)}),$.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=To(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,p]=To(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{g&&(r(!C||C.type?new cr(null,e,g):C),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=xg(o.url);if(w&&jt.protocols.indexOf(w)===-1){r(new Me("Unsupported protocol "+w+":",Me.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Tg=(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 Me?d:new cr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>$.asap(a),c}},Eg=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},Ig=async function*(e,t){for await(const n of Ng(e))yield*Eg(n,t)},Ng=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()}},Dl=(e,t,n,r)=>{const o=Ig(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await o.next();if(u){a(),c.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}c.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Ll=64*1024,{isFunction:Eo}=$,Ag=(({Request:e,Response:t})=>({Request:e,Response:t}))($.global),{ReadableStream:$l,TextEncoder:Fl}=$.global,Bl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},jg=e=>{e=$.merge.call({skipUndefined:!0},Ag,e);const{fetch:t,Request:n,Response:r}=e,o=t?Eo(t):typeof fetch=="function",s=Eo(n),i=Eo(r);if(!o)return!1;const a=o&&Eo($l),c=o&&(typeof Fl=="function"?(v=>b=>v.encode(b))(new Fl):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&Bl(()=>{let v=!1;const b=new n(jt.origin,{body:new $l,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!b}),d=i&&a&&Bl(()=>$.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(b,g)=>{let x=b&&b[v];if(x)return x.call(b);throw new Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if($.isBlob(v))return v.size;if($.isSpecCompliantForm(v))return(await new n(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if($.isArrayBufferView(v)||$.isArrayBuffer(v))return v.byteLength;if($.isURLSearchParams(v)&&(v=v+""),$.isString(v))return(await c(v)).byteLength},p=async(v,b)=>{const g=$.toFiniteNumber(v.getContentLength());return g??h(b)};return async v=>{let{url:b,method:g,data:x,signal:w,cancelToken:C,timeout:T,onDownloadProgress:S,onUploadProgress:k,responseType:E,headers:j,withCredentials:O="same-origin",fetchOptions:F}=Ol(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Tg([w,C&&C.toAbortSignal()],T),q=null;const P=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let z;try{if(k&&u&&g!=="get"&&g!=="head"&&(z=await p(j,x))!==0){let W=new n(b,{method:"POST",body:x,duplex:"half"}),_;if($.isFormData(x)&&(_=W.headers.get("content-type"))&&j.setContentType(_),W.body){const[V,ie]=_l(z,To(Ml(k)));x=Dl(W.body,Ll,V,ie)}}$.isString(O)||(O=O?"include":"omit");const I=s&&"credentials"in n.prototype,D={...F,signal:U,method:g.toUpperCase(),headers:j.normalize().toJSON(),body:x,duplex:"half",credentials:I?O:void 0};q=s&&new n(b,D);let R=await(s?H(q,F):H(b,D));const A=d&&(E==="stream"||E==="response");if(d&&(S||A&&P)){const W={};["status","statusText","headers"].forEach(Q=>{W[Q]=R[Q]});const _=$.toFiniteNumber(R.headers.get("content-length")),[V,ie]=S&&_l(_,To(Ml(S),!0))||[];R=new r(Dl(R.body,Ll,V,()=>{ie&&ie(),P&&P()}),W)}E=E||"text";let B=await f[$.findKey(f,E)||"text"](R,v);return!A&&P&&P(),await new Promise((W,_)=>{jl(W,_,{data:B,headers:$t.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:q})})}catch(I){throw P&&P(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,q),{cause:I.cause||I}):Me.from(I,I&&I.code,v,q)}}},_g=new Map,zl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,u,d=_g;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:jg(t)),d=u;return u};zl();const ci={http:Qm,xhr:kg,fetch:{get:zl}};$.forEach(ci,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Hl=e=>`- ${e}`,Mg=e=>$.isFunction(e)||e===null||e===!1,Ul={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,!Mg(r)&&(o=ci[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`Unknown adapter '${a}'`);if(o&&($.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Un(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&No.assertOptions(r,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:No.assertOptions(o,{encode:un.function,serialize:un.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),No.assertOptions(n,{baseUrl:un.spelling("baseURL"),withXsrfToken:un.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"],v=>{delete s[v]}),n.headers=$t.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(n)===!1||(c=c&&b.synchronous,a.unshift(b.fulfilled,b.rejected))});const u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let d,f=0,h;if(!c){const v=[Wl.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++],b=a[f++];try{p=v(p)}catch(g){b.call(this,g);break}}try{d=Wl.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=Un(this.defaults,t);const n=Rl(t.baseURL,t.url,t.allowAbsoluteUrls);return kl(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(n,r){return this.request(Un(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(Un(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=n(),Wn.prototype[t+"Form"]=n(!0)});let Pg=class um{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 cr(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 um(function(o){t=o}),cancel:t}}};function Og(e){return function(n){return e.apply(null,n)}}function Dg(e){return $.isObject(e)&&e.isAxiosError===!0}const di={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(di).forEach(([e,t])=>{di[t]=e});function Kl(e){const t=new Wn(e),n=cl(Wn.prototype.request,t);return $.extend(n,Wn.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Kl(Un(e,o))},n}const xt=Kl(Rr);xt.Axios=Wn,xt.CanceledError=cr,xt.CancelToken=Pg,xt.isCancel=Al,xt.VERSION=Vl,xt.toFormData=Co,xt.AxiosError=Me,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Og,xt.isAxiosError=Dg,xt.mergeConfig=Un,xt.AxiosHeaders=$t,xt.formToJSON=e=>Il($.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=Ul.getAdapter,xt.HttpStatusCode=di,xt.default=xt;const{Axios:fT,AxiosError:hT,CanceledError:pT,isCancel:mT,CancelToken:gT,VERSION:xT,all:vT,Cancel:bT,isAxiosError:wT,spread:yT,toFormData:ST,AxiosHeaders:CT,HttpStatusCode:kT,formToJSON:TT,getAdapter:ET,mergeConfig:IT}=xt,Gl=typeof window<"u"?window.__API_BASE_URL__:void 0,Yl=Gl?wn(Gl):void 0;function wn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Ao=null;const fi=new Set;function Xl(){return Ao}function jo(e){Ao=e,fi.forEach(t=>t(e))}function Jl(e){return fi.add(e),()=>fi.delete(e)}const Lg=3e4,$g=9e4,Kt=xt.create({...Yl?{baseURL:Yl}:{},timeout:Lg,withCredentials:!0});Kt.interceptors.request.use(e=>(Ao&&(e.headers.Authorization=`Bearer ${Ao}`),e)),Kt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),jo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function _o(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zl(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function hi(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ft(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ql{get baseUrl(){const t=Kt.defaults.baseURL;return t?wn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=wn(String(t.baseUrl))),t.authToken!==void 0&&jo(t.authToken)}getAuthToken(){return Xl()}setAuthToken(t){jo(t)}onTokenChange(t){return Jl(t)}async listThreads(){const t=await Gt("/threads"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Gt("/threads/shared"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await _o("/threads",t?{title:t}:void 0);return Ft(r)}async updateThread(t,n){const r=await Zl(`/threads/${t}`,{title:n});return Ft(r)}async deleteThread(t){const n=await hi(`/threads/${t}`);return Ft(n)}async shareThread(t,n){const r=await _o(`/threads/${t}/share`,{shared_with_user_id:n});return Ft(r)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Ft(n)}async listAgents(){const t=await Gt("/agents"),n=Ft(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Ft(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Ft(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ft(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:$g});return Ft(n)}async cancelRun(t){const n=await _o("/runs/cancel",{threadId:t});return Ft(n)}async unshareThread(t,n){const r=await hi(`/threads/${t}/share/${n}`);return Ft(r)}}const Tn=new Ql,ec=y.createContext(null);function Fg({children:e,apiConfig:t}){const n=Tn;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 l.jsx(ec.Provider,{value:r,children:e})}function pi(){const e=y.useContext(ec);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Bg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function zg(e=[]){const t=[],n=[];for(const r of e)try{const o=await Bg(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}const tc=120;function Hg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>tc?`${n.slice(0,tc-3)}…`:n:""}function nc(e){return Hg(e.content)||""}function Ug(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=nc(n);r&&t.set(n.id,r)}return t}function Wg(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=nc(o);s&&t.set(r.checkpointId,s)}}return t}function Or(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ur(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Vg(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function rc(e){const t=Or(e);if(t)return Or(t.configurable)??t}function Vn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>qg(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function qg(e,t){var w;if(!e)return null;const r=(Array.isArray((w=e.values)==null?void 0:w.messages)?e.values.messages:[]).filter(C=>!!(C&&typeof C=="object"&&typeof C.role=="string")),o=Or(e.metadata)??{},s=rc(e.config),i=Or(e.parent_config??e.parentConfig),a=rc(i),c=ur(s,["checkpoint_id","checkpointId"]),u=ur(s,["checkpoint_ns","checkpointNs"]),d=ur(a,["checkpoint_id","checkpointId"]),f=ur(a,["checkpoint_id","checkpointId"])??null,h=ur(a,["checkpoint_ns","checkpointNs"])??null,p=Or(e.config),v=Array.isArray(e.tasks)?e.tasks.map(C=>({...C})):e.tasks??null,b=Array.isArray(e.next)?[...e.next]:e.next??null,g=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),x={...o,step:Vg(o,["step"])??0,source:ur(o,["source"])??null};return{checkpointId:c??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Kg(r,t),metadata:x,config:p??null,parentConfig:i??null,next:b,tasks:v}}function Kg(e,t){return Gg(e,t)}function Gg(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Yg(e){return y.useMemo(()=>e.map((t,n)=>{var r;return{id:t.checkpointId??`cp-${n}`,label:t.metadata.source==="input"?"User Input":`Step ${t.metadata.step}`,messageId:((r=t.messages[t.messages.length-1])==null?void 0:r.id)??null,step:t.metadata.step,source:t.metadata.source,createdAt:t.createdAt??null,next:t.next&&t.next.length>0?String(t.next[0]):null,parentConfig:t.parentConfig??null}}),[e])}function Xg({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:c=!0,isStreaming:u,getMessages:d}){const[f,h]=y.useState(null),v=y.useMemo(()=>Vn(f),[f]).checkpoints,b=Yg(v),[g,x]=y.useState(!1),[w,C]=y.useState(null),[T,S]=y.useState(!1),[k,E]=y.useState(!1),[j,O]=y.useState(!1),[F,H]=y.useState(null),U=y.useRef(o),q=y.useRef(null),P=y.useRef(null),z=y.useRef(null),I=y.useRef(null),D=y.useRef(!1),R=y.useRef(null),A=y.useRef(new Map);y.useEffect(()=>{U.current=o},[o]);const B=y.useCallback(async G=>{var he,fe;if(!G.threadId)return;const X=G.threadId;(he=G.onStart)==null||he.call(G),G.setLoading(!0);try{await G.action(X)}catch(Z){if(U.current===X){const le=String(Z);(fe=G.handleError)==null||fe.call(G,le),r==null||r(le)}throw Z}finally{G.setLoading(!1)}},[r]),W=y.useCallback(async(G,X)=>{if(!G)return;const he=`${G}:${X??"latest"}`,fe=A.current.get(he);if(fe)return fe;const Z=B({threadId:G,setLoading:S,onStart:()=>H(null),handleError:le=>H(le),action:async le=>{const be=await e.getStateHistory({threadId:le,checkpointId:X??void 0});if(U.current!==le){console.log(`[useThreadHistoryState] Thread changed during load (was ${le}, now ${U.current}), discarding stale data`);return}const{checkpoints:_e}=Vn(be),Ne=_e.find($e=>$e.messages&&$e.messages.length>0)??(X?_e.find($e=>$e.checkpointId===X):null)??_e[0];t((Ne==null?void 0:Ne.messages)??[],{checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}),h(be),x(!!(Ne!=null&&Ne.nextCursor)),C((Ne==null?void 0:Ne.nextCursor)??null)}});A.current.set(he,Z);try{await Z}finally{A.current.delete(he)}return U.current===G&&(R.current=he),Z},[e,t,B]),_=y.useCallback(async(G,X)=>{I.current=G;try{await W(G,X)}finally{I.current===G&&(I.current=null)}},[W]),V=y.useCallback(G=>{P.current=G},[]),ie=y.useCallback(G=>{z.current=G},[]),Q=y.useCallback(G=>{const X=G.threadId??U.current;if(!X||U.current&&U.current!==X)return;const{checkpoints:he}=Vn(G);if(!he.length)return;const fe=he.find(Z=>Z.messages&&Z.messages.length>0)??he.find(Z=>!!Z.checkpointId)??he[0];t((fe==null?void 0:fe.messages)??[],{checkpointId:(fe==null?void 0:fe.checkpointId)??null,checkpointNs:(fe==null?void 0:fe.checkpointNs)??null}),h(G),x(!!(fe!=null&&fe.nextCursor)),C((fe==null?void 0:fe.nextCursor)??null),R.current=`${X}:latest`,P.current=null,z.current=null},[t]),oe=y.useCallback(async(G,X)=>{const he=U.current;await B({threadId:he,setLoading:O,action:async fe=>{const Z=await e.getStateHistory({threadId:fe,checkpointId:G,checkpointNs:X??void 0});if(U.current!==fe){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${fe}, now ${U.current}), discarding stale data`);return}const{checkpoints:le}=Vn(Z),be=le.find(_e=>_e.checkpointId===G&&(X?_e.checkpointNs===X:!0));if(!be){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:G,checkpointNs:X});return}h(Z),t(be.messages??[],{checkpointId:be.checkpointId??null,checkpointNs:be.checkpointNs??null})}}).catch(()=>{})},[e,t,B]),Y=y.useCallback((G,X)=>{t(d(),{checkpointId:G??null,checkpointNs:X??null})},[d,t]),L=y.useCallback(async()=>{U.current&&await _(U.current)},[_]),K=y.useCallback(async()=>{const G=U.current;!G||!w||await B({threadId:G,setLoading:E,action:async X=>{const he=await e.getStateHistory({threadId:X,checkpointId:w});if(U.current!==X)return;const{checkpoints:fe}=Vn(he);if(fe.length>0){const Z=fe[fe.length-1];n((Z==null?void 0:Z.messages)??[]),x(!!(Z!=null&&Z.nextCursor)),C((Z==null?void 0:Z.nextCursor)??null)}}}).catch(()=>{})},[e,w,r,n,B]);y.useEffect(()=>{if(!c||!o||T||u)return;if(P.current===o){P.current=null,q.current=o;return}if(z.current===o){q.current=o;return}if(I.current===o){I.current=null,q.current=o;return}if(q.current===o)return;q.current=o;const G=!D.current&&!!i&&o===s;let X;G&&i?(X=i,D.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",X,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const he=`${o}:${X??"latest"}`;R.current!==he&&_(o,X)},[c,o,i,a,s,T,u,_]);const te=y.useCallback(()=>{h(null),x(!1),C(null),S(!1),E(!1),O(!1),H(null),P.current=null,z.current=null,q.current=null,R.current=null,I.current=null},[]);return{threadCheckpoints:v,threadTimeline:b,isLoadingThread:T,isHistoryLoading:k,isLoadingCheckpoint:j,threadStateError:F,hasMoreHistory:g,loadThread:_,navigateToCheckpoint:oe,loadOlderMessages:K,setCurrentCheckpointId:Y,returnToLatest:L,handleStateHistoryEvent:Q,markSkipNextLoad:V,markStreamPendingThread:ie,resetHistoryState:te}}const Jg=["detail","message","error","description","title"];function Mo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Mo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Jg){const r=Mo(t[n]);if(r)return r}if("errors"in t){const n=Mo(t.errors);if(n)return n}}return null}function Zg(e){if(!e)return"Request failed";const t=e.response,n=Mo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function Qg({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=y.useState([]),[a,c]=y.useState(t),[u,d]=y.useState(!1),[f,h]=y.useState(null),[p,v]=y.useState([]),[b,g]=y.useState(!1),[,x]=y.useState(null),[w,C]=y.useState(null),[T,S]=y.useState(!1),k=y.useRef(a),E=y.useRef(new Map);y.useEffect(()=>{k.current=a},[a]);const j=y.useCallback(async()=>{d(!0),h(null);try{const R=await e.listThreads();i(R??[])}catch(R){const A=String(R);h(A),n==null||n(A)}finally{d(!1)}},[e,n]),O=y.useCallback(async()=>{g(!0),x(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const A=String(R);x(A),n==null||n(A)}finally{g(!1)}},[e,n]);y.useEffect(()=>{j()},[j]),y.useEffect(()=>{O()},[O]),y.useEffect(()=>{r==null||r(a)},[a,r]);const F=y.useCallback(async R=>{try{const A=await e.createThread(R);return c(A.threadId),await j(),A.threadId}catch(A){const B=String(A);return n==null||n(B),null}},[e,n,j]),H=y.useCallback(async R=>{const A=s;i(W=>W.filter(_=>_.threadId!==R));const B=new AbortController;E.current.set(R,B);try{await e.deleteThread(R),k.current===R&&(c(null),o==null||o())}catch(W){i(A);const _=String(W);n==null||n(_)}finally{E.current.delete(R)}},[e,o,n,s]),U=y.useCallback(async(R,A)=>{try{await e.updateThread(R,A),await j()}catch(B){n==null||n(String(B))}},[e,n,j]),q=y.useCallback(async(R,A)=>{S(!0),C("Sharing thread…");try{await e.shareThread(R,A),await O(),C("Shared successfully")}catch(B){const W=Zg(B);throw n==null||n(W),C(`Failed to share: ${W}`),new Error(W)}finally{S(!1)}},[e,n,O]),P=y.useCallback(async(R,A)=>{try{await e.unshareThread(R,A),await O()}catch(B){const W=String(B);throw n==null||n(W),B}},[e,n,O]),z=y.useMemo(()=>({createThread:F,deleteThread:H,renameThread:U,refreshThreads:j,refreshSharedThreads:O,shareThread:q,unshareThread:P}),[F,H,U,j,O,q,P]),I=y.useCallback(R=>{if(!(R!=null&&R.threadId))return;const A={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(B=>{let W=!1;const _=B.map(V=>V.threadId===A.threadId?(W=!0,console.debug("[useThreadsState] thread_info: updating existing thread",A.threadId),{...V,title:A.title??V.title,updatedAt:A.updatedAt??V.updatedAt,messageCount:A.messageCount??V.messageCount}):V);return W?_:(console.debug("[useThreadsState] thread_info: adding thread to list",A.threadId),[A,...B])})},[]),D=y.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:c,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:b,actions:z,addThreadFromEvent:I,shareInFlight:T,shareStatus:w,clearShareStatus:D}}function mi(e){return e.filter(t=>{var s;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(i=>{var a;return i&&i.type==="text"&&((a=i.text)==null?void 0:a.trim())}),r=(t.content??[]).some(i=>i&&i.type==="image_url"),o=!!((s=t.artifact)!=null&&s.plots&&t.artifact.plots.length>0);return!!(n||r||o)})}function sc(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function ex(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function ic(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function ac(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function tx(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??ac(e);let c="",u=e.slice();if(s){const f=nx(a,s);if(f===""?c="":f===s?c=s:c=f,c){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+c};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:c}];o.lastText=a+c}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(c||i.length);return{newParts:u,newMeta:o,changed:d}}function lc(e){return e.replace(/\s+/g," ").trim()}function nx(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=lc(e),o=lc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function rx(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 sc(e,r,s)}return e}function ox(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const sx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ix(e,t){var n;switch(t.type){case"reset":return{messages:mi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=mi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=mi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return uc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>uc(o,s),e):e}default:return e}}function cc(e=[]){const[t,n]=y.useReducer(ix,{...sx,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),c=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:c}),[c]);return{state:t,dispatch:n,...u}}function uc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=ox(t.model);if(e.messages.some(u=>u.id===s)){const u=e.messagesStreamMeta??{},d={...u,[s]:u[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const c={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(t.type==="message.delta"){const s=e.assemblingId??ic(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const c=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],h=f??{lastSeq:null,lastText:ac(c.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:v,newMeta:b,changed:g}=tx(c.content,t.delta,h,p);if(!g)return e;const x={...c,content:v},w=sc(i,a,x),C=!f||f.lastSeq!==b.lastSeq||f.lastText!==b.lastText,T=C?{...d,[s]:b}:u;return C?{...e,messages:w,messagesStreamMeta:T}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??ic(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(c=>c.id===s&&c.role==="assistant");if(a>=0){const c=i[a];if(!((n=c.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:c.id,contentTypes:(r=c.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=c.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=rx(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Vn(t),i=s.interrupt,a=s.latest,c=i===null?ex(e.messages):e.messages;return{...e,messages:c,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function dc(e={}){const t=y.useMemo(()=>wn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,c]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,v]=y.useState(null),[b,g]=y.useState(0),[x,w]=y.useState(!1),C=y.useRef(null),T=y.useRef(!0),S=y.useRef(0),k=y.useRef(null),E=y.useRef(null),j=y.useRef(null),O=y.useRef(null),F=y.useCallback(P=>{o(P)},[]),H=y.useCallback(()=>{h(""),v(null),d(null),E.current=null,j.current=null,O.current=null},[]),U=y.useCallback(()=>{var P;console.debug("[use-chat] stop() invoked - aborting stream"),(P=C.current)==null||P.abort(),C.current=null,k.current=null,c(!1),w(!1),S.current=0,g(0)},[]),q=y.useCallback((P,z,I)=>{C.current&&(C.current.abort(),C.current=null),c(!0),d(null),e.autoAppendAssistant!==!1&&h(""),v(null),E.current=null,j.current=null,O.current=null;const D=new AbortController;C.current=D;let R=null,A=null,B=!1;return k.current={threadId:P.threadId??null,headers:{}},(async()=>{var _,V,ie,Q,oe,Y,L,K,te,G,X,he,fe,Z,le,be,_e,Ne;const W=$e=>{var Xe;try{const nt=JSON.parse(JSON.stringify($e));return(Xe=nt==null?void 0:nt.payload)!=null&&Xe.files_info&&Array.isArray(nt.payload.files_info)&&(nt.payload.files_info=nt.payload.files_info.map(Ve=>({...Ve,data:Ve!=null&&Ve.data?`<base64 ${String(Ve.data).length} chars>`:Ve==null?void 0:Ve.data}))),nt}catch{return $e}};try{let $e={};try{if(r)$e={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const qe=window.__AUTH_TOKEN__,dt=((_=window.localStorage)==null?void 0:_.getItem("authToken"))||null;let bt=null;try{const Ct=(V=window.localStorage)==null?void 0:V.getItem("chat-settings");Ct&&(bt=((ie=JSON.parse(Ct))==null?void 0:ie.apiKey)||null)}catch{}const Ue=qe||dt||bt||null;Ue&&($e={Authorization:`Bearer ${Ue}`})}}catch{}console.debug("[use-chat] POST",t+n,W(P));let Xe={};if(typeof window<"u")try{const Je=(Q=window.localStorage)==null?void 0:Q.getItem("authSessionId");Je&&(Xe={"X-Session-Id":Je})}catch{}const nt={...$e,...Xe,...s.current},Ve={"Content-Type":"application/json",Accept:"text/event-stream",...nt},Ke=await fetch(t+n,{method:"POST",headers:Ve,body:JSON.stringify(P),signal:D.signal,credentials:i});if(k.current&&(k.current.headers=nt),!Ke.ok||!Ke.body){const Je=await Ke.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ke.status,Je==null?void 0:Je.slice(0,500));const qe=`stream ${Ke.status}${Je?": "+Je:""}`;throw(oe=I==null?void 0:I.onConnectionError)==null||oe.call(I,qe),B=!0,R="error",A=qe,new Error(qe)}w(!0);const ot=Ke.body.getReader(),kt=new TextDecoder;let lt="",Te=[];S.current=0,g(0);let Oe=0,at=null;const ht=()=>{if(Te.length){const Je=Te.join("");Te=[],T.current&&h(qe=>qe+Je)}at=null},Tt=()=>{typeof window<"u"&&at==null&&(at=requestAnimationFrame(ht))};let St=Date.now();const Le=setInterval(()=>{var Je;if(Date.now()-St>18e5){const qe="Stream idle timeout";d(qe),R="error",A=qe,D.abort(),(Je=I==null?void 0:I.onError)==null||Je.call(I,qe)}},5e3),Ht=1024*1024;try{const Je=Ke.headers.get("X-Thread-Id")||Ke.headers.get("x-thread-id"),qe=Ke.headers.get("X-Thread-Created")||Ke.headers.get("x-thread-created"),dt=Je??null,bt=String(qe??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:dt}),(Y=I==null?void 0:I.onOpen)==null||Y.call(I,{threadId:dt,created:bt});;){const{value:Ue,done:Ct}=await ot.read();if(Ct)break;lt+=kt.decode(Ue,{stream:!0}),lt.length>Ht&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let M;for(;(M=lt.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,Bn,Ae,tn,Ae),vo[Ae+Bn]=!0}}return N===r?xo(gt):Nt(gt),gt}}function al(N,ee,ce){return Js(N,ee,ce,!0)}function ll(N,ee,ce){return Js(N,ee,ce,!1)}var cl=ll,Zs=al;jr.Fragment=r,jr.jsx=cl,jr.jsxs=Zs}()),jr}process.env.NODE_ENV==="production"?ti.exports=xm():ti.exports=vm();var c=ti.exports;function hl(e,t){return function(){return e.apply(t,arguments)}}const{toString:wm}=Object.prototype,{getPrototypeOf:ni}=Object,{iterator:yo,toStringTag:pl}=Symbol,So=(e=>t=>{const n=wm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),nn=e=>(e=e.toLowerCase(),t=>So(t)===e),Co=e=>t=>typeof t===e,{isArray:ar}=Array,lr=Co("undefined");function _r(e){return e!==null&&!lr(e)&&e.constructor!==null&&!lr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ml=nn("ArrayBuffer");function bm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ml(e.buffer),t}const ym=Co("string"),Lt=Co("function"),gl=Co("number"),Mr=e=>e!==null&&typeof e=="object",Sm=e=>e===!0||e===!1,ko=e=>{if(So(e)!=="object")return!1;const t=ni(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(pl in e)&&!(yo in e)},Cm=e=>{if(!Mr(e)||_r(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},km=nn("Date"),Tm=nn("File"),Em=nn("Blob"),Im=nn("FileList"),Nm=e=>Mr(e)&&Lt(e.pipe),Am=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=So(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},jm=nn("URLSearchParams"),[_m,Mm,Rm,Pm]=["ReadableStream","Request","Response","Headers"].map(nn),Om=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Rr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ar(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_r(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 xl(e,t){if(_r(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 Hn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,vl=e=>!lr(e)&&e!==Hn;function ri(){const{caseless:e,skipUndefined:t}=vl(this)&&this||{},n={},r=(o,s)=>{const i=e&&xl(n,s)||s;ko(n[i])&&ko(o)?n[i]=ri(n[i],o):ko(o)?n[i]=ri({},o):ar(o)?n[i]=o.slice():(!t||!lr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Rr(arguments[o],r);return n}const Dm=(e,t,n,{allOwnKeys:r}={})=>(Rr(t,(o,s)=>{n&&Lt(o)?e[s]=hl(o,n):e[s]=o},{allOwnKeys:r}),e),Lm=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$m=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Fm=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&ni(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bm=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},zm=e=>{if(!e)return null;if(ar(e))return e;let t=e.length;if(!gl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ni(Uint8Array)),Um=(e,t)=>{const r=(e&&e[yo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vm=nn("HTMLFormElement"),Km=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),wl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qm=nn("RegExp"),bl=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Rr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gm=e=>{bl(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Ym=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ar(e)?r(e):r(String(e).split(t)),n},Xm=()=>{},Jm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zm(e){return!!(e&&Lt(e.append)&&e[pl]==="FormData"&&e[yo])}const Qm=e=>{const t=new Array(10),n=(r,o)=>{if(Mr(r)){if(t.indexOf(r)>=0)return;if(_r(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ar(r)?[]:{};return Rr(r,(i,a)=>{const l=n(i,o+1);!lr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},eg=nn("AsyncFunction"),tg=e=>e&&(Mr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),yl=((e,t)=>e?setImmediate:t?((n,r)=>(Hn.addEventListener("message",({source:o,data:s})=>{o===Hn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Hn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(Hn.postMessage)),ng=typeof queueMicrotask<"u"?queueMicrotask.bind(Hn):typeof process<"u"&&process.nextTick||yl,$={isArray:ar,isArrayBuffer:ml,isBuffer:_r,isFormData:Am,isArrayBufferView:bm,isString:ym,isNumber:gl,isBoolean:Sm,isObject:Mr,isPlainObject:ko,isEmptyObject:Cm,isReadableStream:_m,isRequest:Mm,isResponse:Rm,isHeaders:Pm,isUndefined:lr,isDate:km,isFile:Tm,isBlob:Em,isRegExp:qm,isFunction:Lt,isStream:Nm,isURLSearchParams:jm,isTypedArray:Hm,isFileList:Im,forEach:Rr,merge:ri,extend:Dm,trim:Om,stripBOM:Lm,inherits:$m,toFlatObject:Fm,kindOf:So,kindOfTest:nn,endsWith:Bm,toArray:zm,forEachEntry:Um,matchAll:Wm,isHTMLForm:Vm,hasOwnProperty:wl,hasOwnProp:wl,reduceDescriptors:bl,freezeMethods:Gm,toObjectSet:Ym,toCamelCase:Km,noop:Xm,toFiniteNumber:Jm,findKey:xl,global:Hn,isContextDefined:vl,isSpecCompliantForm:Zm,toJSONObject:Qm,isAsyncFn:eg,isThenable:tg,setImmediate:yl,asap:ng,isIterable:e=>e!=null&&Lt(e[yo])};function Me(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(Me,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 Sl=Me.prototype,Cl={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Cl[e]={value:e}}),Object.defineProperties(Me,Cl),Object.defineProperty(Sl,"isAxiosError",{value:!0}),Me.from=(e,t,n,r,o,s)=>{const i=Object.create(Sl);$.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 Me.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const rg=null;function oi(e){return $.isPlainObject(e)||$.isArray(e)}function kl(e){return $.endsWith(e,"[]")?e.slice(0,-2):e}function Tl(e,t,n){return e?e.concat(t).map(function(o,s){return o=kl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function og(e){return $.isArray(e)&&!e.some(oi)}const sg=$.toFlatObject($,{},null,function(t){return/^is[A-Z]/.test(t)});function To(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(w,g){return!$.isUndefined(g[w])});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(v){if(v===null)return"";if($.isDate(v))return v.toISOString();if($.isBoolean(v))return v.toString();if(!l&&$.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return $.isArrayBuffer(v)||$.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($.endsWith(w,"{}"))w=r?w:w.slice(0,-2),v=JSON.stringify(v);else if($.isArray(v)&&og(v)||($.isFileList(v)||$.endsWith(w,"[]"))&&(x=$.toArray(v)))return w=kl(w),x.forEach(function(C,T){!($.isUndefined(C)||C===null)&&t.append(i===!0?Tl([w],T,s):i===null?w:w+"[]",u(C))}),!1}return oi(v)?!0:(t.append(Tl(g,w,s),u(v)),!1)}const f=[],h=Object.assign(sg,{defaultVisitor:d,convertValue:u,isVisitable:oi});function p(v,w){if(!$.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(v),$.forEach(v,function(x,b){(!($.isUndefined(x)||x===null)&&o.call(t,x,$.isString(b)?b.trim():b,w,h))===!0&&p(x,w?w.concat(b):[b])}),f.pop()}}if(!$.isObject(e))throw new TypeError("data must be an object");return p(e),t}function El(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function si(e,t){this._pairs=[],e&&To(e,this,t)}const Il=si.prototype;Il.append=function(t,n){this._pairs.push([t,n])},Il.toString=function(t){const n=t?function(r){return t.call(this,r,El)}:El;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function ig(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Nl(e,t,n){if(!t)return e;const r=n&&n.encode||ig;$.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=$.isURLSearchParams(t)?t.toString():new si(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Al{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 jl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ag={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:si,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ii=typeof window<"u"&&typeof document<"u",ai=typeof navigator=="object"&&navigator||void 0,lg=ii&&(!ai||["ReactNative","NativeScript","NS"].indexOf(ai.product)<0),cg=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ug=ii&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ii,hasStandardBrowserEnv:lg,hasStandardBrowserWebWorkerEnv:cg,navigator:ai,origin:ug},Symbol.toStringTag,{value:"Module"})),...ag};function dg(e,t){return To(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&$.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fg(e){return $.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hg(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function _l(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&$.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]=hg(o[i])),!a)}if($.isFormData(e)&&$.isFunction(e.entries)){const n={};return $.forEachEntry(e,(r,o)=>{t(fg(r),o,n,0)}),n}return null}function pg(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 Pr={transitional:jl,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(_l(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 dg(t,this.formSerializer).toString();if((a=$.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return To(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pg(t)):t}],transformResponse:[function(t){const n=this.transitional||Pr.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"?Me.from(a,Me.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:jt.classes.FormData,Blob:jt.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=>{Pr.headers[e]={}});const mg=$.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gg=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&mg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ml=Symbol("internals");function Or(e){return e&&String(e).trim().toLowerCase()}function Eo(e){return e===!1||e==null?e:$.isArray(e)?e.map(Eo):String(e)}function xg(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const vg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function li(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 wg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function bg(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 $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Or(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]=Eo(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())&&!vg(t))i(gg(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=Or(t),t){const r=$.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xg(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=Or(t),t){const r=$.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||li(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Or(i),i){const a=$.findKey(r,i);a&&(!n||li(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||li(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]=Eo(o),delete n[s];return}const a=t?wg(s):String(s).trim();a!==s&&delete n[s],n[a]=Eo(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[Ml]=this[Ml]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Or(i);r[a]||(bg(o,i),r[a]=!0)}return $.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),$.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),$.freezeMethods($t);function ci(e,t){const n=this||Pr,r=t||n,o=$t.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 Rl(e){return!!(e&&e.__CANCEL__)}function cr(e,t,n){Me.call(this,e??"canceled",Me.ERR_CANCELED,t,n),this.name="CanceledError"}$.inherits(cr,Me,{__CANCEL__:!0});function Pl(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Me("Request failed with status code "+n.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sg(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Cg(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Io=(e,t,n=3)=>{let r=0;const o=Sg(50,250);return Cg(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Ol=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Dl=e=>(...t)=>$.asap(()=>e(...t)),kg=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,Tg=jt.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 Eg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ig(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ll(e,t,n){let r=!Eg(t);return e&&(r||n==!1)?Ig(e,t):t}const $l=e=>e instanceof $t?{...e}:e;function Un(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($l(u),$l(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 Fl=e=>{const t=Un({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=Nl(Ll(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(jt.hasStandardBrowserEnv||jt.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(jt.hasStandardBrowserEnv&&(r&&$.isFunction(r)&&(r=r(t)),r||r!==!1&&kg(t.url))){const l=o&&s&&Tg.read(s);l&&i.set(o,l)}return t},Ng=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Fl(e);let s=o.data;const i=$t.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 C=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:C,config:e,request:g};Pl(function(E){n(E),w()},function(E){r(E),w()},S),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 Me("Request aborted",Me.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const S=T&&T.message?T.message:"Network Error",k=new Me(S,Me.ERR_NETWORK,e,g);k.event=T||null,r(k),g=null},g.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||jl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new Me(T,S.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&$.forEach(i.toJSON(),function(T,S){g.setRequestHeader(S,T)}),$.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,v]=Io(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=Io(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{g&&(r(!C||C.type?new cr(null,e,g):C),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=yg(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new Me("Unsupported protocol "+b+":",Me.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ag=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Me?d:new cr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Me(`timeout ${t} of ms exceeded`,Me.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}},jg=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},_g=async function*(e,t){for await(const n of Mg(e))yield*jg(n,t)},Mg=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()}},Bl=(e,t,n,r)=>{const o=_g(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})},zl=64*1024,{isFunction:No}=$,Rg=(({Request:e,Response:t})=>({Request:e,Response:t}))($.global),{ReadableStream:Hl,TextEncoder:Ul}=$.global,Wl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pg=e=>{e=$.merge.call({skipUndefined:!0},Rg,e);const{fetch:t,Request:n,Response:r}=e,o=t?No(t):typeof fetch=="function",s=No(n),i=No(r);if(!o)return!1;const a=o&&No(Hl),l=o&&(typeof Ul=="function"?(v=>w=>v.encode(w))(new Ul):async v=>new Uint8Array(await new n(v).arrayBuffer())),u=s&&a&&Wl(()=>{let v=!1;const w=new n(jt.origin,{body:new Hl,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!w}),d=i&&a&&Wl(()=>$.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 Me(`Response type '${v}' is not supported`,Me.ERR_NOT_SUPPORT,g)})});const h=async v=>{if(v==null)return 0;if($.isBlob(v))return v.size;if($.isSpecCompliantForm(v))return(await new n(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if($.isArrayBufferView(v)||$.isArrayBuffer(v))return v.byteLength;if($.isURLSearchParams(v)&&(v=v+""),$.isString(v))return(await l(v)).byteLength},p=async(v,w)=>{const g=$.toFiniteNumber(v.getContentLength());return g??h(w)};return async v=>{let{url:w,method:g,data:x,signal:b,cancelToken:C,timeout:T,onDownloadProgress:S,onUploadProgress:k,responseType:E,headers:j,withCredentials:O="same-origin",fetchOptions:F}=Fl(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Ag([b,C&&C.toAbortSignal()],T),K=null;const P=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let z;try{if(k&&u&&g!=="get"&&g!=="head"&&(z=await p(j,x))!==0){let W=new n(w,{method:"POST",body:x,duplex:"half"}),_;if($.isFormData(x)&&(_=W.headers.get("content-type"))&&j.setContentType(_),W.body){const[V,ie]=Ol(z,Io(Dl(k)));x=Bl(W.body,zl,V,ie)}}$.isString(O)||(O=O?"include":"omit");const I=s&&"credentials"in n.prototype,D={...F,signal:U,method:g.toUpperCase(),headers:j.normalize().toJSON(),body:x,duplex:"half",credentials:I?O:void 0};K=s&&new n(w,D);let R=await(s?H(K,F):H(w,D));const A=d&&(E==="stream"||E==="response");if(d&&(S||A&&P)){const W={};["status","statusText","headers"].forEach(Q=>{W[Q]=R[Q]});const _=$.toFiniteNumber(R.headers.get("content-length")),[V,ie]=S&&Ol(_,Io(Dl(S),!0))||[];R=new r(Bl(R.body,zl,V,()=>{ie&&ie(),P&&P()}),W)}E=E||"text";let B=await f[$.findKey(f,E)||"text"](R,v);return!A&&P&&P(),await new Promise((W,_)=>{Pl(W,_,{data:B,headers:$t.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:K})})}catch(I){throw P&&P(),I&&I.name==="TypeError"&&/Load failed|fetch/i.test(I.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,v,K),{cause:I.cause||I}):Me.from(I,I&&I.code,v,K)}}},Og=new Map,Vl=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=Og;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Pg(t)),d=u;return u};Vl();const ui={http:rg,xhr:Ng,fetch:{get:Vl}};$.forEach(ui,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Kl=e=>`- ${e}`,Dg=e=>$.isFunction(e)||e===null||e===!1,ql={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,!Dg(r)&&(o=ui[(a=String(r)).toLowerCase()],o===void 0))throw new Me(`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(Kl).join(`
|
|
34
|
+
`):" "+Kl(i[0]):"as no adapter specified";throw new Me("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ui};function di(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new cr(null,e)}function Gl(e){return di(e),e.headers=$t.from(e.headers),e.data=ci.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ql.getAdapter(e.adapter||Pr.adapter,e)(e).then(function(r){return di(e),r.data=ci.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return Rl(r)||(di(e),r&&r.response&&(r.response.data=ci.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const Yl="1.12.2",Ao={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ao[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Xl={};Ao.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 Me(o(i," has been removed"+(n?" in "+n:"")),Me.ERR_DEPRECATED);return n&&!Xl[i]&&(Xl[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}},Ao.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lg(e,t,n){if(typeof e!="object")throw new Me("options must be an object",Me.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 Me("option "+s+" must be "+l,Me.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Me("Unknown option "+s,Me.ERR_BAD_OPTION)}}const jo={assertOptions:Lg,validators:Ao},un=jo.validators;let Wn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Al,response:new Al}}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=Un(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&jo.assertOptions(r,{silentJSONParsing:un.transitional(un.boolean),forcedJSONParsing:un.transitional(un.boolean),clarifyTimeoutError:un.transitional(un.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:jo.assertOptions(o,{encode:un.function,serialize:un.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),jo.assertOptions(n,{baseUrl:un.spelling("baseURL"),withXsrfToken:un.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"],v=>{delete s[v]}),n.headers=$t.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=[Gl.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=Gl.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=Un(this.defaults,t);const n=Ll(t.baseURL,t.url,t.allowAbsoluteUrls);return Nl(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){Wn.prototype[t]=function(n,r){return this.request(Un(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(Un(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Wn.prototype[t]=n(),Wn.prototype[t+"Form"]=n(!0)});let $g=class pm{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new cr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new pm(function(o){t=o}),cancel:t}}};function Fg(e){return function(n){return e.apply(null,n)}}function Bg(e){return $.isObject(e)&&e.isAxiosError===!0}const fi={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(fi).forEach(([e,t])=>{fi[t]=e});function Jl(e){const t=new Wn(e),n=hl(Wn.prototype.request,t);return $.extend(n,Wn.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Jl(Un(e,o))},n}const xt=Jl(Pr);xt.Axios=Wn,xt.CanceledError=cr,xt.CancelToken=$g,xt.isCancel=Rl,xt.VERSION=Yl,xt.toFormData=To,xt.AxiosError=Me,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Fg,xt.isAxiosError=Bg,xt.mergeConfig=Un,xt.AxiosHeaders=$t,xt.formToJSON=e=>_l($.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=ql.getAdapter,xt.HttpStatusCode=fi,xt.default=xt;const{Axios:yT,AxiosError:ST,CanceledError:CT,isCancel:kT,CancelToken:TT,VERSION:ET,all:IT,Cancel:NT,isAxiosError:AT,spread:jT,toFormData:_T,AxiosHeaders:MT,HttpStatusCode:RT,formToJSON:PT,getAdapter:OT,mergeConfig:DT}=xt,Zl=typeof window<"u"?window.__API_BASE_URL__:void 0,Ql=Zl?bn(Zl):void 0;function bn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let _o=null;const hi=new Set;function ec(){return _o}function Mo(e){_o=e,hi.forEach(t=>t(e))}function tc(e){return hi.add(e),()=>hi.delete(e)}const zg=3e4,Hg=9e4,qt=xt.create({...Ql?{baseURL:Ql}:{},timeout:zg,withCredentials:!0});qt.interceptors.request.use(e=>(_o&&(e.headers.Authorization=`Bearer ${_o}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Mo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ro(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function nc(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function pi(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ft(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class rc{get baseUrl(){const t=qt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Mo(t.authToken)}getAuthToken(){return ec()}setAuthToken(t){Mo(t)}onTokenChange(t){return tc(t)}async listThreads(){const t=await Gt("/threads"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Gt("/threads/shared"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ro("/threads",t?{title:t}:void 0);return Ft(r)}async updateThread(t,n){const r=await nc(`/threads/${t}`,{title:n});return Ft(r)}async deleteThread(t){const n=await pi(`/threads/${t}`);return Ft(n)}async shareThread(t,n){const r=await Ro(`/threads/${t}/share`,{shared_with_user_id:n});return Ft(r)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Ft(n)}async listAgents(){const t=await Gt("/agents"),n=Ft(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Ft(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Ft(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ft(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Hg});return Ft(n)}async cancelRun(t){const n=await Ro("/runs/cancel",{threadId:t});return Ft(n)}async unshareThread(t,n){const r=await pi(`/threads/${t}/share/${n}`);return Ft(r)}}const Tn=new rc,oc=y.createContext(null);function Ug({children:e,apiConfig:t}){const n=Tn;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(oc.Provider,{value:r,children:e})}function mi(){const e=y.useContext(oc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Wg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Vg(e=[]){const t=[],n=[];for(const r of e)try{const o=await Wg(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}const sc=120;function Kg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>sc?`${n.slice(0,sc-3)}…`:n:""}function ic(e){return Kg(e.content)||""}function qg(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=ic(n);r&&t.set(n.id,r)}return t}function Gg(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=ic(o);s&&t.set(r.checkpointId,s)}}return t}function Dr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function ur(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function Yg(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function ac(e){const t=Dr(e);if(t)return Dr(t.configurable)??t}function Vn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>Xg(s,i)).filter(s=>!!s)].sort((s,i)=>lc(i.createdAt)-lc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function Xg(e,t){var b;if(!e)return null;const r=(Array.isArray((b=e.values)==null?void 0:b.messages)?e.values.messages:[]).filter(C=>!!(C&&typeof C=="object"&&typeof C.role=="string")),o=Dr(e.metadata)??{},s=ac(e.config),i=Dr(e.parent_config??e.parentConfig),a=ac(i),l=ur(s,["checkpoint_id","checkpointId"]),u=ur(s,["checkpoint_ns","checkpointNs"]),d=ur(a,["checkpoint_id","checkpointId"]),f=ur(a,["checkpoint_id","checkpointId"])??null,h=ur(a,["checkpoint_ns","checkpointNs"])??null,p=Dr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(C=>({...C})):e.tasks??null,w=Array.isArray(e.next)?[...e.next]:e.next??null,g=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),x={...o,step:Yg(o,["step"])??0,source:ur(o,["source"])??null};return{checkpointId:l??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Jg(r,t),metadata:x,config:p??null,parentConfig:i??null,next:w,tasks:v}}function Jg(e,t){return Zg(e,t)}function Zg(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function lc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Qg(e){return y.useMemo(()=>e.map((t,n)=>{var r;return{id:t.checkpointId??`cp-${n}`,label:t.metadata.source==="input"?"User Input":`Step ${t.metadata.step}`,messageId:((r=t.messages[t.messages.length-1])==null?void 0:r.id)??null,step:t.metadata.step,source:t.metadata.source,createdAt:t.createdAt??null,next:t.next&&t.next.length>0?String(t.next[0]):null,parentConfig:t.parentConfig??null}}),[e])}function ex({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:u,getMessages:d}){const[f,h]=y.useState(null),v=y.useMemo(()=>Vn(f),[f]).checkpoints,w=Qg(v),[g,x]=y.useState(!1),[b,C]=y.useState(null),[T,S]=y.useState(!1),[k,E]=y.useState(!1),[j,O]=y.useState(!1),[F,H]=y.useState(null),U=y.useRef(o),K=y.useRef(null),P=y.useRef(null),z=y.useRef(null),I=y.useRef(null),D=y.useRef(!1),R=y.useRef(null),A=y.useRef(new Map);y.useEffect(()=>{U.current=o},[o]);const B=y.useCallback(async G=>{var he,fe;if(!G.threadId)return;const X=G.threadId;(he=G.onStart)==null||he.call(G),G.setLoading(!0);try{await G.action(X)}catch(Z){if(U.current===X){const le=String(Z);(fe=G.handleError)==null||fe.call(G,le),r==null||r(le)}throw Z}finally{G.setLoading(!1)}},[r]),W=y.useCallback(async(G,X)=>{if(!G)return;const he=`${G}:${X??"latest"}`,fe=A.current.get(he);if(fe)return fe;const Z=B({threadId:G,setLoading:S,onStart:()=>H(null),handleError:le=>H(le),action:async le=>{const we=await e.getStateHistory({threadId:le,checkpointId:X??void 0});if(U.current!==le){console.log(`[useThreadHistoryState] Thread changed during load (was ${le}, now ${U.current}), discarding stale data`);return}const{checkpoints:_e}=Vn(we),Ne=_e.find($e=>$e.messages&&$e.messages.length>0)??(X?_e.find($e=>$e.checkpointId===X):null)??_e[0];t((Ne==null?void 0:Ne.messages)??[],{checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}),h(we),x(!!(Ne!=null&&Ne.nextCursor)),C((Ne==null?void 0:Ne.nextCursor)??null)}});A.current.set(he,Z);try{await Z}finally{A.current.delete(he)}return U.current===G&&(R.current=he),Z},[e,t,B]),_=y.useCallback(async(G,X)=>{I.current=G;try{await W(G,X)}finally{I.current===G&&(I.current=null)}},[W]),V=y.useCallback(G=>{P.current=G},[]),ie=y.useCallback(G=>{z.current=G},[]),Q=y.useCallback(G=>{const X=G.threadId??U.current;if(!X||U.current&&U.current!==X)return;const{checkpoints:he}=Vn(G);if(!he.length)return;const fe=he.find(Z=>Z.messages&&Z.messages.length>0)??he.find(Z=>!!Z.checkpointId)??he[0];t((fe==null?void 0:fe.messages)??[],{checkpointId:(fe==null?void 0:fe.checkpointId)??null,checkpointNs:(fe==null?void 0:fe.checkpointNs)??null}),h(G),x(!!(fe!=null&&fe.nextCursor)),C((fe==null?void 0:fe.nextCursor)??null),R.current=`${X}:latest`,P.current=null,z.current=null},[t]),oe=y.useCallback(async(G,X)=>{const he=U.current;await B({threadId:he,setLoading:O,action:async fe=>{const Z=await e.getStateHistory({threadId:fe,checkpointId:G,checkpointNs:X??void 0});if(U.current!==fe){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${fe}, now ${U.current}), discarding stale data`);return}const{checkpoints:le}=Vn(Z),we=le.find(_e=>_e.checkpointId===G&&(X?_e.checkpointNs===X:!0));if(!we){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:G,checkpointNs:X});return}h(Z),t(we.messages??[],{checkpointId:we.checkpointId??null,checkpointNs:we.checkpointNs??null})}}).catch(()=>{})},[e,t,B]),Y=y.useCallback((G,X)=>{t(d(),{checkpointId:G??null,checkpointNs:X??null})},[d,t]),L=y.useCallback(async()=>{U.current&&await _(U.current)},[_]),q=y.useCallback(async()=>{const G=U.current;!G||!b||await B({threadId:G,setLoading:E,action:async X=>{const he=await e.getStateHistory({threadId:X,checkpointId:b});if(U.current!==X)return;const{checkpoints:fe}=Vn(he);if(fe.length>0){const Z=fe[fe.length-1];n((Z==null?void 0:Z.messages)??[]),x(!!(Z!=null&&Z.nextCursor)),C((Z==null?void 0:Z.nextCursor)??null)}}}).catch(()=>{})},[e,b,r,n,B]);y.useEffect(()=>{if(!l||!o||T||u)return;if(P.current===o){P.current=null,K.current=o;return}if(z.current===o){K.current=o;return}if(I.current===o){I.current=null,K.current=o;return}if(K.current===o)return;K.current=o;const G=!D.current&&!!i&&o===s;let X;G&&i?(X=i,D.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",X,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const he=`${o}:${X??"latest"}`;R.current!==he&&_(o,X)},[l,o,i,a,s,T,u,_]);const te=y.useCallback(()=>{h(null),x(!1),C(null),S(!1),E(!1),O(!1),H(null),P.current=null,z.current=null,K.current=null,R.current=null,I.current=null},[]);return{threadCheckpoints:v,threadTimeline:w,isLoadingThread:T,isHistoryLoading:k,isLoadingCheckpoint:j,threadStateError:F,hasMoreHistory:g,loadThread:_,navigateToCheckpoint:oe,loadOlderMessages:q,setCurrentCheckpointId:Y,returnToLatest:L,handleStateHistoryEvent:Q,markSkipNextLoad:V,markStreamPendingThread:ie,resetHistoryState:te}}const tx=["detail","message","error","description","title"];function Po(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Po(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of tx){const r=Po(t[n]);if(r)return r}if("errors"in t){const n=Po(t.errors);if(n)return n}}return null}function nx(e){if(!e)return"Request failed";const t=e.response,n=Po(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function rx({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=y.useState([]),[a,l]=y.useState(t),[u,d]=y.useState(!1),[f,h]=y.useState(null),[p,v]=y.useState([]),[w,g]=y.useState(!1),[,x]=y.useState(null),[b,C]=y.useState(null),[T,S]=y.useState(!1),k=y.useRef(a),E=y.useRef(new Map);y.useEffect(()=>{k.current=a},[a]);const j=y.useCallback(async()=>{d(!0),h(null);try{const R=await e.listThreads();i(R??[])}catch(R){const A=String(R);h(A),n==null||n(A)}finally{d(!1)}},[e,n]),O=y.useCallback(async()=>{g(!0),x(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const A=String(R);x(A),n==null||n(A)}finally{g(!1)}},[e,n]);y.useEffect(()=>{j()},[j]),y.useEffect(()=>{O()},[O]),y.useEffect(()=>{r==null||r(a)},[a,r]);const F=y.useCallback(async R=>{try{const A=await e.createThread(R);return l(A.threadId),await j(),A.threadId}catch(A){const B=String(A);return n==null||n(B),null}},[e,n,j]),H=y.useCallback(async R=>{const A=s;i(W=>W.filter(_=>_.threadId!==R));const B=new AbortController;E.current.set(R,B);try{await e.deleteThread(R),k.current===R&&(l(null),o==null||o())}catch(W){i(A);const _=String(W);n==null||n(_)}finally{E.current.delete(R)}},[e,o,n,s]),U=y.useCallback(async(R,A)=>{try{await e.updateThread(R,A),await j()}catch(B){n==null||n(String(B))}},[e,n,j]),K=y.useCallback(async(R,A)=>{S(!0),C("Sharing thread…");try{await e.shareThread(R,A),await O(),C("Shared successfully")}catch(B){const W=nx(B);throw n==null||n(W),C(`Failed to share: ${W}`),new Error(W)}finally{S(!1)}},[e,n,O]),P=y.useCallback(async(R,A)=>{try{await e.unshareThread(R,A),await O()}catch(B){const W=String(B);throw n==null||n(W),B}},[e,n,O]),z=y.useMemo(()=>({createThread:F,deleteThread:H,renameThread:U,refreshThreads:j,refreshSharedThreads:O,shareThread:K,unshareThread:P}),[F,H,U,j,O,K,P]),I=y.useCallback(R=>{if(!(R!=null&&R.threadId))return;const A={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(B=>{let W=!1;const _=B.map(V=>V.threadId===A.threadId?(W=!0,console.debug("[useThreadsState] thread_info: updating existing thread",A.threadId),{...V,title:A.title??V.title,updatedAt:A.updatedAt??V.updatedAt,messageCount:A.messageCount??V.messageCount}):V);return W?_:(console.debug("[useThreadsState] thread_info: adding thread to list",A.threadId),[A,...B])})},[]),D=y.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:l,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:w,actions:z,addThreadFromEvent:I,shareInFlight:T,shareStatus:b,clearShareStatus:D}}function gi(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 cc(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Lr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Lr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(cc(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Lr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function dr(e){if(typeof e=="string")return e;if(cc(e))return"";try{const t=Lr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ox(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function sx(e){const t=dr(e);return typeof e=="string"&&ox(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function $r(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=gi(t);if(n!==null)return $r(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?$r(e.content):e}function ix(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function xi(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Oo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function ax(e){const t=r=>{try{const o=Lr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
36
|
+
`)):t(e)}function lx(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uc(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function cx(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ux(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function dx({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=cx(n),i=o?`data:${s};base64,${e}`:t,a=ux(r),l=a.length?a.join(" / "):void 0,u=l?`${l} artifact`:"artifact image";return{src:i,alt:u,label:l}}function fx(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return dx({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function vi(e){return e.filter(t=>{var s;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(i=>{var a;return i&&i.type==="text"&&((a=i.text)==null?void 0:a.trim())}),r=(t.content??[]).some(i=>i&&i.type==="image_url"),o=!!((s=t.artifact)!=null&&s.plots&&t.artifact.plots.length>0);return!!(n||r||o)})}function Fr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function hx(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function dc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function fc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function px(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??fc(e);let l="",u=e.slice();if(s){const f=mx(a,s);if(f===""?l="":f===s?l=s:l=f,l){const h=u[u.length-1];if((h==null?void 0:h.type)==="text"){const p=h.text??"",v={...h,text:p+l};u=[...u.slice(0,u.length-1),v]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function hc(e){return e.replace(/\s+/g," ").trim()}function mx(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=hc(e),o=hc(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function gx(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 Fr(e,r,s)}return e}function xx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const vx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function wx(e,t){var n;switch(t.type){case"reset":return{messages:vi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=vi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=vi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return mc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>mc(o,s),e):e}default:return e}}function pc(e=[]){const[t,n]=y.useReducer(wx,{...vx,messages:e}),r=y.useRef([]),o=y.useRef(null),s=y.useRef(null),i=y.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=y.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=y.useCallback(d=>{r.current.push(d),a()},[a]);y.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=y.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function mc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=xx(t.model);if(e.messages.some(u=>u.id===s)){const u=e.messagesStreamMeta??{},d={...u,[s]:u[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return Sx(e,t);if(t.type==="tool.progress")return Cx(e,t);if(t.type==="tool.end")return kx(e,t);if(t.type==="message.delta"){const s=e.assemblingId??dc(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],h=f??{lastSeq:null,lastText:fc(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof h.lastSeq=="number"&&p<=h.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:h.lastSeq}),e;const{newParts:v,newMeta:w,changed:g}=px(l.content,t.delta,h,p);if(!g)return e;const x={...l,content:v},b=Fr(i,a,x),C=!f||f.lastSeq!==w.lastSeq||f.lastText!==w.lastText,T=C?{...d,[s]:w}:u;return C?{...e,messages:b,messagesStreamMeta:T}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??dc(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=gx(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Vn(t),i=s.interrupt,a=s.latest,l=i===null?hx(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}const bx="tool-";function wi(e){return e.call_id??e.id??null}function gc(e,t,n){const r=e??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:`${bx}${r}`,role:"tool",name:t??void 0,content:[{type:"tool_call",id:r,name:t??"tool",args:n??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:r,toolName:t??void 0,toolStreaming:!0,toolProgress:[]}}}function bi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||xi(r).toolCallId===t)return n}return-1}function yx(e){if(e==null)return[];const t=$r(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=dr(t??e);return n?[{type:"text",text:n}]:[]}function xc(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Sx(e,t){const n=wi(t),r=bi(e.messages,n),o=t.name??t.tool??void 0;if(r>=0){const i=e.messages[r],l={...i.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},u={...i,name:o??i.name,additionalKwargs:l};return{...e,messages:Fr(e.messages,r,u)}}const s=gc(n,o,t.args);return{...e,messages:[...e.messages,s]}}function Cx(e,t){const n=wi(t);if(!n)return e;const r=bi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=xc(e.messages[r],o);return{...e,messages:Fr(e.messages,r,a)}}function kx(e,t){const n=wi(t);let r=e.messages,o=bi(r,n);if(o===-1){const p=t.name??t.tool??void 0;r=[...r,gc(n,p,{})],o=r.length-1}const s=r[o],i=t.output??t.error??null,a=yx(i),l=[...s.content,...a],u={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(u.artifact=t.artifact);const d=xc(s,u),f=t.artifact??s.artifact,h={...d,name:t.name??t.tool??s.name,content:l,artifact:f,additionalKwargs:{...d.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Fr(r,o,h)}}function vc(e={}){const t=y.useMemo(()=>bn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=y.useState(e.token??null),s=y.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,v]=y.useState(null),[w,g]=y.useState(0),[x,b]=y.useState(!1),C=y.useRef(null),T=y.useRef(!0),S=y.useRef(0),k=y.useRef(null),E=y.useRef(null),j=y.useRef(null),O=y.useRef(null),F=y.useCallback(P=>{o(P)},[]),H=y.useCallback(()=>{h(""),v(null),d(null),E.current=null,j.current=null,O.current=null},[]),U=y.useCallback(()=>{var P;console.debug("[use-chat] stop() invoked - aborting stream"),(P=C.current)==null||P.abort(),C.current=null,k.current=null,l(!1),b(!1),S.current=0,g(0)},[]),K=y.useCallback((P,z,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),v(null),E.current=null,j.current=null,O.current=null;const D=new AbortController;C.current=D;let R=null,A=null,B=!1;return k.current={threadId:P.threadId??null,headers:{}},(async()=>{var _,V,ie,Q,oe,Y,L,q,te,G,X,he,fe,Z,le,we,_e,Ne;const W=$e=>{var Xe;try{const nt=JSON.parse(JSON.stringify($e));return(Xe=nt==null?void 0:nt.payload)!=null&&Xe.files_info&&Array.isArray(nt.payload.files_info)&&(nt.payload.files_info=nt.payload.files_info.map(Ve=>({...Ve,data:Ve!=null&&Ve.data?`<base64 ${String(Ve.data).length} chars>`:Ve==null?void 0:Ve.data}))),nt}catch{return $e}};try{let $e={};try{if(r)$e={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,dt=((_=window.localStorage)==null?void 0:_.getItem("authToken"))||null;let wt=null;try{const Ct=(V=window.localStorage)==null?void 0:V.getItem("chat-settings");Ct&&(wt=((ie=JSON.parse(Ct))==null?void 0:ie.apiKey)||null)}catch{}const Ue=Ke||dt||wt||null;Ue&&($e={Authorization:`Bearer ${Ue}`})}}catch{}console.debug("[use-chat] POST",t+n,W(P));let Xe={};if(typeof window<"u")try{const Je=(Q=window.localStorage)==null?void 0:Q.getItem("authSessionId");Je&&(Xe={"X-Session-Id":Je})}catch{}const nt={...$e,...Xe,...s.current},Ve={"Content-Type":"application/json",Accept:"text/event-stream",...nt},qe=await fetch(t+n,{method:"POST",headers:Ve,body:JSON.stringify(P),signal:D.signal,credentials:i});if(k.current&&(k.current.headers=nt),!qe.ok||!qe.body){const Je=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,Je==null?void 0:Je.slice(0,500));const Ke=`stream ${qe.status}${Je?": "+Je:""}`;throw(oe=I==null?void 0:I.onConnectionError)==null||oe.call(I,Ke),B=!0,R="error",A=Ke,new Error(Ke)}b(!0);const ot=qe.body.getReader(),kt=new TextDecoder;let lt="",Te=[];S.current=0,g(0);let Oe=0,at=null;const ht=()=>{if(Te.length){const Je=Te.join("");Te=[],T.current&&h(Ke=>Ke+Je)}at=null},Tt=()=>{typeof window<"u"&&at==null&&(at=requestAnimationFrame(ht))};let St=Date.now();const Le=setInterval(()=>{var Je;if(Date.now()-St>18e5){const Ke="Stream idle timeout";d(Ke),R="error",A=Ke,D.abort(),(Je=I==null?void 0:I.onError)==null||Je.call(I,Ke)}},5e3),Ht=1024*1024;try{const Je=qe.headers.get("X-Thread-Id")||qe.headers.get("x-thread-id"),Ke=qe.headers.get("X-Thread-Created")||qe.headers.get("x-thread-created"),dt=Je??null,wt=String(Ke??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:dt}),(Y=I==null?void 0:I.onOpen)==null||Y.call(I,{threadId:dt,created:wt});;){const{value:Ue,done:Ct}=await ot.read();if(Ct)break;lt+=kt.decode(Ue,{stream:!0}),lt.length>Ht&&(lt="",console.warn("Stream buffer reset: exceeded 1MB"));let M;for(;(M=lt.indexOf(`
|
|
36
37
|
|
|
37
|
-
`))>=0;){const se=lt.slice(0,M);lt=lt.slice(M+2);const me=
|
|
38
|
-
`)}const cx=["message.start","message.delta","message.end"],ux=["tool.start","tool.end","tool.progress"],dx=["thread_info","checkpoint"],fx=["error","interrupt","heartbeat","state_history","cancelled"],hx=[...cx,...ux,...dx,...fx],px=new Set(hx);function mx(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return px.has(t)}const fc=200;function gx({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:c,onHeartbeat:u,onToolEvent:d}){const f=y.useRef(null),h=y.useRef(null),p=y.useRef(new Map),v=y.useRef(null),b=y.useRef(null),g=y.useCallback(I=>{try{const D=globalThis.structuredClone;if(typeof D=="function")return D(I)}catch{}try{return JSON.parse(JSON.stringify(I))}catch{return I}},[]),x=y.useCallback((I,D)=>{if(!I)return;const R=p.current.get(I)??[],A=g(D),B=R.length>=fc?[...R.slice(R.length-fc+1),A]:[...R,A];p.current.set(I,B)},[g]),w=y.useCallback(I=>{I&&p.current.set(I,[])},[]),C=y.useCallback(I=>{const D=I??h.current;if(!D)return;const R=p.current.get(D);R!=null&&R.length&&R.forEach(A=>{try{n(A)}catch(B){console.error("[useChatStreamingService] Failed to replay buffered event",B)}})},[n]),T=y.useCallback(I=>{h.current=I.threadId,v.current&&(v.current.threadIdGuess=I.threadId),b.current=I,w(I.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",I);try{t(I)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}},[w,t]),S=y.useCallback(I=>{try{u==null||u(I)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}},[u]),k=y.useCallback(I=>{var A,B,W,_;const D=I;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((A=D.message)==null?void 0:A.includes("token"))||((B=D.message)==null?void 0:B.includes("401"))||((W=D.message)==null?void 0:W.includes("unauthorized"))||((_=D.message)==null?void 0:_.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{c==null||c(D.message)}catch(V){console.warn("[useChatStreamingService] onAuthError handler failed",V)}}},[c]),E=y.useMemo(()=>({thread_info:I=>(T(I),!0),heartbeat:I=>(S(I),!0),error:I=>(k(I),!1)}),[T,S,k]),j=y.useCallback(I=>{var B;const D=I.seq??null;if(D!==null){const W=f.current;if(W!==null){if(D<=W)return;D>W+1&&(s==null||s({from:W,to:D}))}f.current=D}const R=E[I.type];if(R&&R(I))return;const A=I.threadId??(I.type==="state_history"?I.threadId:void 0)??h.current??((B=v.current)==null?void 0:B.threadIdGuess)??null;if(I.type==="state_history"){h.current=A??h.current;try{r==null||r(I)}catch(W){console.error("[useChatStreamingService] onStateHistory handler failed",W)}}if(mx(I)){(I.type==="tool.start"||I.type==="tool.end")&&(d==null||d(I)),I.type==="checkpoint"||I.type==="state_history"?w(A??null):x(A??null,I);try{n(I)}catch(W){console.error("[useChatStreamingService] Error in onMessageEvent handler:",W)}return}try{o==null||o(I)}catch(W){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",W)}},[x,w,n,s,r,o,E]),{stream:O,stop:F,isStreaming:H,error:U,setToken:q}=dc({baseUrl:e,token:void 0}),P=y.useCallback((I,D)=>{f.current=null,b.current=null,h.current=I.threadId??null,v.current={request:I,callbacks:D,manualStop:!1,threadIdGuess:I.threadId??null},O(I,j,{onOpen:D==null?void 0:D.onOpen,onError:R=>{var A;(A=D==null?void 0:D.onError)==null||A.call(D,R)},onGap:(D==null?void 0:D.onGap)??s,onConnectionError:R=>{var A;a==null||a(R),(A=D==null?void 0:D.onConnectionError)==null||A.call(D,R)},onAuthError:R=>{var A;c==null||c(R),(A=D==null?void 0:D.onAuthError)==null||A.call(D,R)},onHeartbeat:R=>{var A;try{u==null||u(R)}catch(B){console.warn("[useChatStreamingService] onHeartbeat handler failed",B)}try{(A=D==null?void 0:D.onHeartbeat)==null||A.call(D,R)}catch(B){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",B)}},onClosed:R=>{var _,V,ie,Q;const A=((_=v.current)==null?void 0:_.manualStop)??!1,B=h.current??((V=v.current)==null?void 0:V.threadIdGuess)??((ie=R.lastStateHistory)==null?void 0:ie.threadId)??null;(R.reason==="complete"||R.reason==="aborted"&&A)&&w(B);const W={...R,threadId:B,threadInfo:b.current,manualStop:A};try{i==null||i(W)}catch(oe){console.warn("[useChatStreamingService] onStreamClosed handler failed",oe)}try{(Q=D==null?void 0:D.onClosed)==null||Q.call(D,W)}catch(oe){console.warn("[useChatStreamingService] downstream onClosed handler failed",oe)}v.current&&(v.current=null)}})},[w,j,c,a,u,s,i,O]),z=y.useCallback(()=>{v.current&&(v.current.manualStop=!0),F()},[F]);return y.useMemo(()=>({startStream:P,stop:z,isStreaming:H,error:U,setAuthToken:q,replayBufferedEvents:C}),[P,z,H,U,q,C])}const hc=y.createContext(null),pc=y.createContext(null),mc=y.createContext(null);y.createContext(!1);function xx({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:u}){const{api:d,baseUrl:f}=pi(),h=y.useMemo(()=>wn(f),[f]),{state:p,seed:v,prepend:b,pushUser:g,onEvent:x}=cc(),{threads:w,currentThreadId:C,setCurrentThreadId:T,currentThreadIdRef:S,isLoadingThreads:k,threadsError:E,sharedThreads:j,isLoadingSharedThreads:O,actions:F,addThreadFromEvent:H,shareInFlight:U,shareStatus:q,clearShareStatus:P}=Qg({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[z,I]=y.useState(!1),D=y.useCallback(()=>p.messages,[p.messages]),{threadCheckpoints:R,threadTimeline:A,isLoadingThread:B,isHistoryLoading:W,isLoadingCheckpoint:_,threadStateError:V,hasMoreHistory:ie,loadThread:Q,navigateToCheckpoint:oe,loadOlderMessages:Y,setCurrentCheckpointId:L,returnToLatest:K,handleStateHistoryEvent:te,markSkipNextLoad:G,markStreamPendingThread:X,resetHistoryState:he}=Xg({api:d,seed:v,prepend:b,onError:s,currentThreadId:C,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:z,getMessages:D}),fe=y.useMemo(()=>Wg(R),[R]),Z=y.useCallback(Te=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Te.threadId),H(Te),S.current!==Te.threadId&&((Te.created??!S.current)&&G(Te.threadId),X(Te.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(Te.threadId))},[H,G,X]),{startStream:le,stop:be,isStreaming:_e,error:Ne,setAuthToken:$e}=gx({baseUrl:h,onThreadInfo:Z,onMessageEvent:x,onStateHistory:te,onUnhandledEvent:Te=>{console.warn("[ChatSessionProvider] Unhandled event:",Te.type)},onAuthError:i,onConnectionError:c,onToolEvent:Te=>{Te.type==="tool.end"&&(u==null||u(Te))}});y.useEffect(()=>{I(_e)},[_e]);const Xe=y.useCallback(async()=>{v([],{}),T(null),be(),he();try{await d.getAgent("default")}catch(Te){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Te)}},[v,be,d,he]),nt=y.useCallback(async(Te,Oe,at)=>{const ht=S.current;if(!ht)throw new Error("No active thread to handle interrupt");const Tt=Oe?at??!0:!1;try{const St={threadId:ht,checkpointId:p.lastCheckpointId??void 0,checkpointNs:p.lastCheckpointNs??void 0,command:{kind:"resume",value:Tt}};le(St)}catch(St){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Te}:`,St),St}},[p.lastCheckpointId,p.lastCheckpointNs,le]),Ve=y.useCallback(async(Te,Oe)=>{let at=S.current;const ht=(Te==null?void 0:Te.text)??"",Tt=(Te==null?void 0:Te.attachments)??[],St=(ht==null?void 0:ht.trim())??"",Le={...(Te==null?void 0:Te.payload)??{}},Ht=Array.isArray(Le.messages)?Le.messages:void 0;Ht&&delete Le.messages;const Je=!!(Ht&&Ht.length);if(!at&&!St&&Tt.length===0&&!Je)return;if(!at){const mt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ze=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);at=`${mt}${Ze}`,G(at),T(at)}const{contentParts:qe,filesInfo:dt}=await zg(Tt),bt=[...qe];St&&bt.push({type:"text",text:ht});const Ue=Oe==null?void 0:Oe.originalMessageId,Ct=!!(Oe!=null&&Oe.edit&&Ue),M=!Je&&bt.length>0;let se=null;M&&(se={id:Ct?Ue:`msg-${Date.now()}`,role:"user",content:bt,createdAt:new Date().toISOString()},Ct?g(se,Ue):g(se));const me=Je?Ht:se?[se]:[],We={...Le,...dt.length?{files_info:dt}:{}};me.length?We.messages=me:"messages"in We||(We.messages=[]);const Pe={threadId:at,payload:We,checkpointId:(Oe==null?void 0:Oe.checkpointId)??p.lastCheckpointId??void 0,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??p.lastCheckpointNs??void 0,edit:!!(Oe!=null&&Oe.edit),timelineCheckpoints:A};le(Pe)},[d,g,p,le,A]),Ke=y.useMemo(()=>({threads:w,currentThreadId:C,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:j,isLoadingSharedThreads:O,actions:F,shareInFlight:U,shareStatus:q,clearShareStatus:P}),[w,C,T,k,E,j,O,F,U,q,P]),ot=y.useMemo(()=>{const Te=p.assemblingId??null;return Te?{assemblingMessageId:Te}:null},[p.assemblingId]),kt=y.useMemo(()=>({threadId:C,messages:p.messages,interrupt:null,checkpoint:{id:p.lastCheckpointId??null,namespace:p.lastCheckpointNs??null},checkpoints:R,timelineCheckpoints:A,metadata:ot,isLoading:B,isHistoryLoading:W,isLoadingCheckpoint:_,error:V,hasMore:ie,loadOlder:Y,clearState:Xe,navigateToCheckpoint:oe,setCurrentCheckpointId:L,returnToLatest:K,loadThread:Q,clearThread:Xe,respondToInterrupt:nt,messagePreviews:fe}),[C,p,R,A,B,W,_,V,ie,Y,Xe,oe,L,K,Q,nt,fe,ot]),lt=y.useMemo(()=>({isStreaming:_e,error:Ne,connectionState:_e?"connected":"idle",submit:Ve,send:Ve,stop:be,setAuthToken:$e}),[_e,Ne,Ve,be,$e]);return l.jsx(hc.Provider,{value:Ke,children:l.jsx(pc.Provider,{value:kt,children:l.jsx(mc.Provider,{value:lt,children:e})})})}function Ro(){const e=y.useContext(hc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Po(){const e=y.useContext(pc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function gc(){const e=y.useContext(mc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function Oo({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:c,onThreadChange:u,onToolEnd:d}){return l.jsx(Fg,{apiConfig:t,children:l.jsx(xx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:c,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function ne(...e){return fm.twMerge(dm.clsx(e))}const vx=xo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),et=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?zn.Slot:"button";return l.jsx(i,{className:ne(vx({variant:t,size:n,className:e})),ref:s,...o})});et.displayName="Button";const xc=m.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:ne("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}));xc.displayName="Textarea";function vc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:c,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1}){const v=i!==void 0,[b,g]=y.useState(e),x=(v?i:b)??"",[w,C]=y.useTransition(),T=y.useRef(null),S=y.useRef(0),k=y.useRef(null);y.useEffect(()=>{v||(g(e??""),k.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,v]);const E=y.useCallback(()=>{const z=T.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);y.useEffect(()=>{E()},[E,x]);const j=y.useCallback((z,{fromUser:I})=>{v||g(z),I&&(a==null||a(z))},[v,a]),O=y.useCallback(async z=>{z&&z.preventDefault();const I=(x??"").trim();if(!I&&!p)return;const D=++S.current;k.current={id:D,shouldClear:!0},C(()=>{var R,A,B;try{const W=c(I);W&&typeof W.then=="function"?W.then(()=>{var _,V;((_=k.current)==null?void 0:_.id)===D&&k.current.shouldClear&&(v||(g(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=k.current)==null?void 0:V.id)===D&&(k.current=null)}).catch(()=>{var _;((_=k.current)==null?void 0:_.id)===D&&(k.current=null)}):(((R=k.current)==null?void 0:R.id)===D&&k.current.shouldClear&&(v||(g(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((A=k.current)==null?void 0:A.id)===D&&(k.current=null))}catch{((B=k.current)==null?void 0:B.id)===D&&(k.current=null)}})},[x,c,p,v,a]),F=y.useCallback(z=>{const I=z.target.value;j(I,{fromUser:!0}),k.current&&(k.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`)},[j]),H=y.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),O()):z.key==="Escape"&&t&&(z.preventDefault(),u==null||u())},[O,t,u]),P=`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))]":""} ${h}`;return l.jsx("form",{onSubmit:z=>void O(z),className:`w-full ${f}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsx("div",{className:"flex-1",children:l.jsx(xc,{ref:T,value:x,onChange:F,onKeyDown:H,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),l.jsx("div",{children:r?l.jsx(et,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:l.jsx(ae.Square,{size:16})}):l.jsx(et,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!x.trim()&&!p||w,children:l.jsx(ae.Send,{size:16})})})]})})}const bx=y.memo(vc);function pe(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 bc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function En(...e){return t=>{let n=!1;const r=e.map(o=>{const s=bc(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():bc(e[o],null)}}}}function ze(...e){return m.useCallback(En(...e),e)}function wx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,c=m.useMemo(()=>a,Object.values(a));return l.jsx(n.Provider,{value:c,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 yn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),c=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...v}=f,b=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,g=m.useMemo(()=>v,Object.values(v));return l.jsx(b.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var b;const p=((b=h==null?void 0:h[e])==null?void 0:b[c])||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 c=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,yx(o,...t)]}function yx(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:u})=>{const f=c(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Sx=m[" useInsertionEffect ".trim().toString()]||Et;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Cx({defaultProp:t,onChange:n}),a=e!==void 0,c=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=kx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[c,u]}function Cx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Sx(()=>{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 kx(e){return typeof e=="function"}var Tx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Tx.reduce((e,t)=>{const n=zn.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function wc(e,t){e&&vo.flushSync(()=>e.dispatchEvent(t))}function gi(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:g,children:x}=b,w=y.useRef(null),C=y.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:C,collectionRef:w,children:x})};i.displayName=t;const a=e+"CollectionSlot",c=zn.createSlot(a),u=y.forwardRef((b,g)=>{const{scope:x,children:w}=b,C=s(a,x),T=ze(g,C.collectionRef);return l.jsx(c,{ref:T,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=zn.createSlot(d),p=y.forwardRef((b,g)=>{const{scope:x,children:w,...C}=b,T=y.useRef(null),S=ze(g,T),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...C}),()=>void k.itemMap.delete(T))),l.jsx(h,{[f]:"",ref:S,children:w})});p.displayName=d;function v(b){const g=s(e+"CollectionConsumer",b);return y.useCallback(()=>{const w=g.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>C.indexOf(k.ref.current)-C.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Ex=m.createContext(void 0);function Do(e){const t=m.useContext(Ex);return e||t||"ltr"}function It(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 Ix(e,t=globalThis==null?void 0:globalThis.document){const n=It(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 Nx="DismissableLayer",xi="dismissableLayer.update",Ax="dismissableLayer.pointerDownOutside",jx="dismissableLayer.focusOutside",yc,Sc=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,...c}=e,u=m.useContext(Sc),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=ze(t,E=>f(E)),b=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=b.indexOf(g),w=d?b.indexOf(d):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,T=w>=x,S=Rx(E=>{const j=E.target,O=[...u.branches].some(F=>F.contains(j));!T||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Px(E=>{const j=E.target;[...u.branches].some(F=>F.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Ix(E=>{w===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(yc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Cc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yc)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Cc())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(xi,E),()=>document.removeEventListener(xi,E)},[]),l.jsx(ye.div,{...c,ref:v,style:{pointerEvents:C?T?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,S.onPointerDownCapture)})});Lo.displayName=Nx;var _x="DismissableLayerBranch",Mx=m.forwardRef((e,t)=>{const n=m.useContext(Sc),r=m.useRef(null),o=ze(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),l.jsx(ye.div,{...e,ref:o})});Mx.displayName=_x;function Rx(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){kc(Ax,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Px(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&kc(jx,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 Cc(){const e=new CustomEvent(xi);document.dispatchEvent(e)}function kc(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?wc(o,s):o.dispatchEvent(s)}var vi=0;function bi(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Tc()),document.body.insertAdjacentElement("beforeend",e[1]??Tc()),vi++,()=>{vi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),vi--}},[])}function Tc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var wi="focusScope.autoFocusOnMount",yi="focusScope.autoFocusOnUnmount",Ec={bubbles:!1,cancelable:!0},Ox="FocusScope",$o=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=m.useState(null),u=It(o),d=It(s),f=m.useRef(null),h=ze(t,b=>c(b)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let b=function(C){if(p.paused||!a)return;const T=C.target;a.contains(T)?f.current=T:In(f.current,{select:!0})},g=function(C){if(p.paused||!a)return;const T=C.relatedTarget;T!==null&&(a.contains(T)||In(f.current,{select:!0}))},x=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&In(a)};document.addEventListener("focusin",b),document.addEventListener("focusout",g);const w=new MutationObserver(x);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",g),w.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Ac.add(p);const b=document.activeElement;if(!a.contains(b)){const x=new CustomEvent(wi,Ec);a.addEventListener(wi,u),a.dispatchEvent(x),x.defaultPrevented||(Dx(zx(Ic(a)),{select:!0}),document.activeElement===b&&In(a))}return()=>{a.removeEventListener(wi,u),setTimeout(()=>{const x=new CustomEvent(yi,Ec);a.addEventListener(yi,d),a.dispatchEvent(x),x.defaultPrevented||In(b??document.body,{select:!0}),a.removeEventListener(yi,d),Ac.remove(p)},0)}}},[a,u,d,p]);const v=m.useCallback(b=>{if(!n&&!r||p.paused)return;const g=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,x=document.activeElement;if(g&&x){const w=b.currentTarget,[C,T]=Lx(w);C&&T?!b.shiftKey&&x===T?(b.preventDefault(),n&&In(C,{select:!0})):b.shiftKey&&x===C&&(b.preventDefault(),n&&In(T,{select:!0})):x===w&&b.preventDefault()}},[n,r,p.paused]);return l.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});$o.displayName=Ox;function Dx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}function Lx(e){const t=Ic(e),n=Nc(t,e),r=Nc(t.reverse(),e);return[n,r]}function Ic(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 Nc(e,t){for(const n of e)if(!$x(n,{upTo:t}))return n}function $x(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 Fx(e){return e instanceof HTMLInputElement&&"select"in e}function In(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Fx(e)&&t&&e.select()}}var Ac=Bx();function Bx(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=jc(e,t),e.unshift(t)},remove(t){var n;e=jc(e,t),(n=e[0])==null||n.resume()}}}function jc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function zx(e){return e.filter(t=>t.tagName!=="A")}var Hx=m[" useId ".trim().toString()]||(()=>{}),Ux=0;function Pt(e){const[t,n]=m.useState(Hx());return Et(()=>{n(r=>r??String(Ux++))},[e]),t?`radix-${t}`:""}const Wx=["top","right","bottom","left"],Nn=Math.min,Ut=Math.max,Fo=Math.round,Bo=Math.floor,dn=e=>({x:e,y:e}),Vx={left:"right",right:"left",bottom:"top",top:"bottom"},qx={start:"end",end:"start"};function Si(e,t,n){return Ut(e,Nn(t,n))}function Sn(e,t){return typeof e=="function"?e(t):e}function Cn(e){return e.split("-")[0]}function fr(e){return e.split("-")[1]}function Ci(e){return e==="x"?"y":"x"}function ki(e){return e==="y"?"height":"width"}const Kx=new Set(["top","bottom"]);function fn(e){return Kx.has(Cn(e))?"y":"x"}function Ti(e){return Ci(fn(e))}function Gx(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=Ti(e),s=ki(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=zo(i)),[i,zo(i)]}function Yx(e){const t=zo(e);return[Ei(e),t,Ei(t)]}function Ei(e){return e.replace(/start|end/g,t=>qx[t])}const _c=["left","right"],Mc=["right","left"],Xx=["top","bottom"],Jx=["bottom","top"];function Zx(e,t,n){switch(e){case"top":case"bottom":return n?t?Mc:_c:t?_c:Mc;case"left":case"right":return t?Xx:Jx;default:return[]}}function Qx(e,t,n,r){const o=fr(e);let s=Zx(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ei)))),s}function zo(e){return e.replace(/left|right|bottom|top/g,t=>Vx[t])}function ev(e){return{top:0,right:0,bottom:0,left:0,...e}}function Rc(e){return typeof e!="number"?ev(e):{top:e,right:e,bottom:e,left:e}}function Ho(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 Pc(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=Ti(t),a=ki(i),c=Cn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(c){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(fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const tv=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=Pc(u,r,c),h=r,p={},v=0;for(let b=0;b<a.length;b++){const{name:g,fn:x}=a[b],{x:w,y:C,data:T,reset:S}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=C??f,p={...p,[g]:{...p[g],...T}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=Pc(u,h,c)),b=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Dr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Sn(t,e),v=Rc(p),g=a[h?f==="floating"?"reference":"floating":f],x=Ho(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Ho(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:c}):w);return{top:(x.top-S.top+v.top)/T.y,bottom:(S.bottom-x.bottom+v.bottom)/T.y,left:(x.left-S.left+v.left)/T.x,right:(S.right-x.right+v.right)/T.x}}const nv=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:u,padding:d=0}=Sn(e,t)||{};if(u==null)return{};const f=Rc(d),h={x:n,y:r},p=Ti(o),v=ki(p),b=await i.getDimensions(u),g=p==="y",x=g?"top":"left",w=g?"bottom":"right",C=g?"clientHeight":"clientWidth",T=s.reference[v]+s.reference[p]-h[p]-s.floating[v],S=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[C]||s.floating[v]);const j=T/2-S/2,O=E/2-b[v]/2-1,F=Nn(f[x],O),H=Nn(f[w],O),U=F,q=E-b[v]-H,P=E/2-b[v]/2+j,z=Si(U,P,q),I=!c.arrow&&fr(o)!=null&&P!==z&&s.reference[v]/2-(P<U?F:H)-b[v]/2<0,D=I?P<U?P-U:P-q:0;return{[p]:h[p]+D,data:{[p]:z,centerOffset:P-z-D,...I&&{alignmentOffset:D}},reset:I}}}),rv=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:b=!0,...g}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Cn(o),w=fn(a),C=Cn(a)===a,T=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=h||(C||!b?[zo(a)]:Yx(a)),k=v!=="none";!h&&k&&S.push(...Qx(a,b,v,T));const E=[a,...S],j=await Dr(t,g),O=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(j[x]),f){const P=Gx(o,i,T);O.push(j[P[0]],j[P[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every(P=>P<=0)){var H,U;const P=(((H=s.flip)==null?void 0:H.index)||0)+1,z=E[P];if(z&&(!(f==="alignment"?w!==fn(z):!1)||F.every(R=>fn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:P,overflows:F},reset:{placement:z}};let I=(U=F.filter(D=>D.overflows[0]<=0).sort((D,R)=>D.overflows[1]-R.overflows[1])[0])==null?void 0:U.placement;if(!I)switch(p){case"bestFit":{var q;const D=(q=F.filter(R=>{if(k){const A=fn(R.placement);return A===w||A==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(A=>A>0).reduce((A,B)=>A+B,0)]).sort((R,A)=>R[1]-A[1])[0])==null?void 0:q[0];D&&(I=D);break}case"initialPlacement":I=a;break}if(o!==I)return{reset:{placement:I}}}return{}}}};function Oc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Dc(e){return Wx.some(t=>e[t]>=0)}const ov=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Sn(e,t);switch(r){case"referenceHidden":{const s=await Dr(t,{...o,elementContext:"reference"}),i=Oc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Dc(i)}}}case"escaped":{const s=await Dr(t,{...o,altBoundary:!0}),i=Oc(s,n.floating);return{data:{escapedOffsets:i,escaped:Dc(i)}}}default:return{}}}}},Lc=new Set(["left","top"]);async function sv(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Cn(n),a=fr(n),c=fn(n)==="y",u=Lc.has(i)?-1:1,d=s&&c?-1:1,f=Sn(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),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const iv=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await sv(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},av=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:w}=g;return{x,y:w}}},...c}=Sn(e,t),u={x:n,y:r},d=await Dr(t,c),f=fn(Cn(o)),h=Ci(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=p+d[g],C=p-d[x];p=Si(w,p,C)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=v+d[g],C=v-d[x];v=Si(w,v,C)}const b=a.fn({...t,[h]:p,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:s,[f]:i}}}}}},lv=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:u=!0}=Sn(e,t),d={x:n,y:r},f=fn(o),h=Ci(f);let p=d[h],v=d[f];const b=Sn(a,t),g=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(c){const C=h==="y"?"height":"width",T=s.reference[h]-s.floating[C]+g.mainAxis,S=s.reference[h]+s.reference[C]-g.mainAxis;p<T?p=T:p>S&&(p=S)}if(u){var x,w;const C=h==="y"?"width":"height",T=Lc.has(Cn(o)),S=s.reference[f]-s.floating[C]+(T&&((x=i.offset)==null?void 0:x[f])||0)+(T?0:g.crossAxis),k=s.reference[f]+s.reference[C]+(T?0:((w=i.offset)==null?void 0:w[f])||0)-(T?g.crossAxis:0);v<S?v=S:v>k&&(v=k)}return{[h]:p,[f]:v}}}},cv=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...u}=Sn(e,t),d=await Dr(t,u),f=Cn(o),h=fr(o),p=fn(o)==="y",{width:v,height:b}=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 w=b-d.top-d.bottom,C=v-d.left-d.right,T=Nn(b-d[g],w),S=Nn(v-d[x],C),k=!t.middlewareData.shift;let E=T,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),k&&!h){const F=Ut(d.left,0),H=Ut(d.right,0),U=Ut(d.top,0),q=Ut(d.bottom,0);p?j=v-2*(F!==0||H!==0?F+H:Ut(d.left,d.right)):E=b-2*(U!==0||q!==0?U+q:Ut(d.top,d.bottom))}await c({...t,availableWidth:j,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||b!==O.height?{reset:{rects:!0}}:{}}}};function Uo(){return typeof window<"u"}function hr(e){return $c(e)?(e.nodeName||"").toLowerCase():"#document"}function Wt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=($c(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $c(e){return Uo()?e instanceof Node||e instanceof Wt(e).Node:!1}function rn(e){return Uo()?e instanceof Element||e instanceof Wt(e).Element:!1}function pn(e){return Uo()?e instanceof HTMLElement||e instanceof Wt(e).HTMLElement:!1}function Fc(e){return!Uo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Wt(e).ShadowRoot}const uv=new Set(["inline","contents"]);function Lr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!uv.has(o)}const dv=new Set(["table","td","th"]);function fv(e){return dv.has(hr(e))}const hv=[":popover-open",":modal"];function Wo(e){return hv.some(t=>{try{return e.matches(t)}catch{return!1}})}const pv=["transform","translate","scale","rotate","perspective"],mv=["transform","translate","scale","rotate","perspective","filter"],gv=["paint","layout","strict","content"];function Ii(e){const t=Ni(),n=rn(e)?on(e):e;return pv.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)||mv.some(r=>(n.willChange||"").includes(r))||gv.some(r=>(n.contain||"").includes(r))}function xv(e){let t=An(e);for(;pn(t)&&!pr(t);){if(Ii(t))return t;if(Wo(t))return null;t=An(t)}return null}function Ni(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const vv=new Set(["html","body","#document"]);function pr(e){return vv.has(hr(e))}function on(e){return Wt(e).getComputedStyle(e)}function Vo(e){return rn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function An(e){if(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Fc(e)&&e.host||hn(e);return Fc(t)?t.host:t}function Bc(e){const t=An(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&Lr(t)?t:Bc(t)}function $r(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Bc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Wt(o);if(s){const a=Ai(i);return t.concat(i,i.visualViewport||[],Lr(o)?o:[],a&&n?$r(a):[])}return t.concat(o,$r(o,[],n))}function Ai(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function zc(e){const t=on(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=pn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Fo(n)!==s||Fo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ji(e){return rn(e)?e:e.contextElement}function mr(e){const t=ji(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=zc(t);let i=(s?Fo(n.width):n.width)/r,a=(s?Fo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const bv=dn(0);function Hc(e){const t=Wt(e);return!Ni()||!t.visualViewport?bv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wv(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Wt(e)?!1:t}function qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ji(e);let i=dn(1);t&&(r?rn(r)&&(i=mr(r)):i=mr(e));const a=wv(s,n,r)?Hc(s):dn(0);let c=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Wt(s),p=r&&rn(r)?Wt(r):r;let v=h,b=Ai(v);for(;b&&r&&p!==v;){const g=mr(b),x=b.getBoundingClientRect(),w=on(b),C=x.left+(b.clientLeft+parseFloat(w.paddingLeft))*g.x,T=x.top+(b.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=C,u+=T,v=Wt(b),b=Ai(v)}}return Ho({width:d,height:f,x:c,y:u})}function qo(e,t){const n=Vo(e).scrollLeft;return t?t.left+n:qn(hn(e)).left+n}function Uc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function yv(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=hn(r),a=t?Wo(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},u=dn(1);const d=dn(0),f=pn(r);if((f||!f&&!s)&&((hr(r)!=="body"||Lr(i))&&(c=Vo(r)),pn(r))){const p=qn(r);u=mr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Uc(i,c):dn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Sv(e){return Array.from(e.getClientRects())}function Cv(e){const t=hn(e),n=Vo(e),r=e.ownerDocument.body,o=Ut(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ut(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+qo(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Ut(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Wc=25;function kv(e,t){const n=Wt(e),r=hn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const d=Ni();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const u=qo(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<=Wc&&(s-=v)}else u<=Wc&&(s+=u);return{width:s,height:i,x:a,y:c}}const Tv=new Set(["absolute","fixed"]);function Ev(e,t){const n=qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=pn(e)?mr(e):dn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,u=r*s.y;return{width:i,height:a,x:c,y:u}}function Vc(e,t,n){let r;if(t==="viewport")r=kv(e,n);else if(t==="document")r=Cv(hn(e));else if(rn(t))r=Ev(t,n);else{const o=Hc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Ho(r)}function qc(e,t){const n=An(e);return n===t||!rn(n)||pr(n)?!1:on(n).position==="fixed"||qc(n,t)}function Iv(e,t){const n=t.get(e);if(n)return n;let r=$r(e,[],!1).filter(a=>rn(a)&&hr(a)!=="body"),o=null;const s=on(e).position==="fixed";let i=s?An(e):e;for(;rn(i)&&!pr(i);){const a=on(i),c=Ii(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Tv.has(o.position)||Lr(i)&&!c&&qc(e,i))?r=r.filter(d=>d!==i):o=a,i=An(i)}return t.set(e,r),r}function Nv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Wo(t)?[]:Iv(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Vc(t,d,o);return u.top=Ut(f.top,u.top),u.right=Nn(f.right,u.right),u.bottom=Nn(f.bottom,u.bottom),u.left=Ut(f.left,u.left),u},Vc(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Av(e){const{width:t,height:n}=zc(e);return{width:t,height:n}}function jv(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=dn(0);function u(){c.x=qo(o)}if(r||!r&&!s)if((hr(t)!=="body"||Lr(o))&&(a=Vo(t)),r){const p=qn(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Uc(o,a):dn(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function _i(e){return on(e).position==="static"}function Kc(e,t){if(!pn(e)||on(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return hn(e)===n&&(n=n.ownerDocument.body),n}function Gc(e,t){const n=Wt(e);if(Wo(e))return n;if(!pn(e)){let o=An(e);for(;o&&!pr(o);){if(rn(o)&&!_i(o))return o;o=An(o)}return n}let r=Kc(e,t);for(;r&&fv(r)&&_i(r);)r=Kc(r,t);return r&&pr(r)&&_i(r)&&!Ii(r)?n:r||xv(e)||n}const _v=async function(e){const t=this.getOffsetParent||Gc,n=this.getDimensions,r=await n(e.floating);return{reference:jv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mv(e){return on(e).direction==="rtl"}const Rv={convertOffsetParentRelativeRectToViewportRelativeRect:yv,getDocumentElement:hn,getClippingRect:Nv,getOffsetParent:Gc,getElementRects:_v,getClientRects:Sv,getDimensions:Av,getScale:mr,isElement:rn,isRTL:Mv};function Yc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Pv(e,t){let n=null,r;const o=hn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Bo(f),b=Bo(o.clientWidth-(d+h)),g=Bo(o.clientHeight-(f+p)),x=Bo(d),C={rootMargin:-v+"px "+-b+"px "+-g+"px "+-x+"px",threshold:Ut(0,Nn(1,c))||1};let T=!0;function S(k){const E=k[0].intersectionRatio;if(E!==c){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Yc(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Ov(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=ji(e),d=o||s?[...u?$r(u):[],...$r(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Pv(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[w]=x;w&&w.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),u&&!c&&p.observe(u),p.observe(t));let v,b=c?qn(e):null;c&&g();function g(){const x=qn(e);b&&!Yc(b,x)&&n(),b=x,v=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(v)}}const Dv=iv,Lv=av,$v=rv,Fv=cv,Bv=ov,Xc=nv,zv=lv,Hv=(e,t,n)=>{const r=new Map,o={platform:Rv,...n},s={...o.platform,_c:r};return tv(e,t,{...o,platform:s})};var Uv=typeof document<"u",Wv=function(){},Ko=Uv?y.useLayoutEffect:Wv;function Go(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(!Go(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)&&!Go(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Jc(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Zc(e,t){const n=Jc(e);return Math.round(t*n)/n}function Mi(e){const t=m.useRef(e);return Ko(()=>{t.current=e}),t}function Vv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Go(h,r)||p(r);const[v,b]=m.useState(null),[g,x]=m.useState(null),w=m.useCallback(R=>{R!==k.current&&(k.current=R,b(R))},[]),C=m.useCallback(R=>{R!==E.current&&(E.current=R,x(R))},[]),T=s||v,S=i||g,k=m.useRef(null),E=m.useRef(null),j=m.useRef(d),O=c!=null,F=Mi(c),H=Mi(o),U=Mi(u),q=m.useCallback(()=>{if(!k.current||!E.current)return;const R={placement:t,strategy:n,middleware:h};H.current&&(R.platform=H.current),Hv(k.current,E.current,R).then(A=>{const B={...A,isPositioned:U.current!==!1};P.current&&!Go(j.current,B)&&(j.current=B,vo.flushSync(()=>{f(B)}))})},[h,t,n,H,U]);Ko(()=>{u===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[u]);const P=m.useRef(!1);Ko(()=>(P.current=!0,()=>{P.current=!1}),[]),Ko(()=>{if(T&&(k.current=T),S&&(E.current=S),T&&S){if(F.current)return F.current(T,S,q);q()}},[T,S,q,F,O]);const z=m.useMemo(()=>({reference:k,floating:E,setReference:w,setFloating:C}),[w,C]),I=m.useMemo(()=>({reference:T,floating:S}),[T,S]),D=m.useMemo(()=>{const R={position:n,left:0,top:0};if(!I.floating)return R;const A=Zc(I.floating,d.x),B=Zc(I.floating,d.y);return a?{...R,transform:"translate("+A+"px, "+B+"px)",...Jc(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:B}},[n,a,I.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:q,refs:z,elements:I,floatingStyles:D}),[d,q,z,I,D])}const qv=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?Xc({element:r.current,padding:o}).fn(n):{}:r?Xc({element:r,padding:o}).fn(n):{}}}},Kv=(e,t)=>({...Dv(e),options:[e,t]}),Gv=(e,t)=>({...Lv(e),options:[e,t]}),Yv=(e,t)=>({...zv(e),options:[e,t]}),Xv=(e,t)=>({...$v(e),options:[e,t]}),Jv=(e,t)=>({...Fv(e),options:[e,t]}),Zv=(e,t)=>({...Bv(e),options:[e,t]}),Qv=(e,t)=>({...qv(e),options:[e,t]});var eb="Arrow",Qc=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return l.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});Qc.displayName=eb;var tb=Qc;function eu(e){const[t,n]=m.useState(void 0);return Et(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,u=Array.isArray(c)?c[0]:c;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Ri="Popper",[tu,Yo]=yn(Ri),[nb,nu]=tu(Ri),ru=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return l.jsx(nb,{scope:t,anchor:r,onAnchorChange:o,children:n})};ru.displayName=Ri;var ou="PopperAnchor",su=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=nu(ou,n),i=m.useRef(null),a=ze(t,i),c=m.useRef(null);return m.useEffect(()=>{const u=c.current;c.current=(r==null?void 0:r.current)||i.current,u!==c.current&&s.onAnchorChange(c.current)}),r?null:l.jsx(ye.div,{...o,ref:a})});su.displayName=ou;var Pi="PopperContent",[rb,ob]=tu(Pi),iu=m.forwardRef((e,t)=>{var Y,L,K,te,G,X;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...b}=e,g=nu(Pi,n),[x,w]=m.useState(null),C=ze(t,he=>w(he)),[T,S]=m.useState(null),k=eu(T),E=(k==null?void 0:k.width)??0,j=(k==null?void 0:k.height)??0,O=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],U=H.length>0,q={padding:F,boundary:H.filter(ib),altBoundary:U},{refs:P,floatingStyles:z,placement:I,isPositioned:D,middlewareData:R}=Vv({strategy:"fixed",placement:O,whileElementsMounted:(...he)=>Ov(...he,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[Kv({mainAxis:o+j,alignmentAxis:i}),c&&Gv({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Yv():void 0,...q}),c&&Xv({...q}),Jv({...q,apply:({elements:he,rects:fe,availableWidth:Z,availableHeight:le})=>{const{width:be,height:_e}=fe.reference,Ne=he.floating.style;Ne.setProperty("--radix-popper-available-width",`${Z}px`),Ne.setProperty("--radix-popper-available-height",`${le}px`),Ne.setProperty("--radix-popper-anchor-width",`${be}px`),Ne.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),T&&Qv({element:T,padding:a}),ab({arrowWidth:E,arrowHeight:j}),h&&Zv({strategy:"referenceHidden",...q})]}),[A,B]=cu(I),W=It(v);Et(()=>{D&&(W==null||W())},[D,W]);const _=(Y=R.arrow)==null?void 0:Y.x,V=(L=R.arrow)==null?void 0:L.y,ie=((K=R.arrow)==null?void 0:K.centerOffset)!==0,[Q,oe]=m.useState();return Et(()=>{x&&oe(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:D?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(te=R.transformOrigin)==null?void 0:te.x,(G=R.transformOrigin)==null?void 0:G.y].join(" "),...((X=R.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(rb,{scope:n,placedSide:A,onArrowChange:S,arrowX:_,arrowY:V,shouldHideArrow:ie,children:l.jsx(ye.div,{"data-side":A,"data-align":B,...b,ref:C,style:{...b.style,animation:D?void 0:"none"}})})})});iu.displayName=Pi;var au="PopperArrow",sb={top:"bottom",right:"left",bottom:"top",left:"right"},lu=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=ob(au,r),i=sb[s.placedSide];return l.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:l.jsx(tb,{...o,ref:n,style:{...o.style,display:"block"}})})});lu.displayName=au;function ib(e){return e!==null}var ab=e=>({name:"transformOrigin",options:e,fn(t){var g,x,w;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[u,d]=cu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+c/2;let v="",b="";return u==="bottom"?(v=i?f:`${h}px`,b=`${-c}px`):u==="top"?(v=i?f:`${h}px`,b=`${r.floating.height+c}px`):u==="right"?(v=`${-c}px`,b=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+c}px`,b=i?f:`${p}px`),{data:{x:v,y:b}}}});function cu(e){const[t,n="center"]=e.split("-");return[t,n]}var uu=ru,du=su,fu=iu,hu=lu,lb="Portal",Xo=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Zs.createPortal(l.jsx(ye.div,{...r,ref:t}),i):null});Xo.displayName=lb;function cb(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Yt=e=>{const{present:t,children:n}=e,r=ub(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=ze(r.ref,db(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Yt.displayName="Presence";function ub(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,c]=cb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=Jo(r.current);s.current=a==="mounted"?u:"none"},[a]),Et(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=Jo(u);e?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Et(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const b=Jo(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&b&&(c("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function db(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 Oi="rovingFocusGroup.onEntryFocus",fb={bubbles:!1,cancelable:!0},Fr="RovingFocusGroup",[Di,pu,hb]=gi(Fr),[pb,mu]=yn(Fr,[hb]),[mb,gb]=pb(Fr),gu=m.forwardRef((e,t)=>l.jsx(Di.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Di.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(xb,{...e,ref:t})})}));gu.displayName=Fr;var xb=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=ze(t,h),v=Do(s),[b,g]=dr({prop:i,defaultProp:a??null,onChange:c,caller:Fr}),[x,w]=m.useState(!1),C=It(u),T=pu(n),S=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(Oi,C),()=>j.removeEventListener(Oi,C)},[C]),l.jsx(mb,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:b,onItemFocus:m.useCallback(j=>g(j),[g]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:m.useCallback(()=>E(j=>j-1),[]),children:l.jsx(ye.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{S.current=!0}),onFocus:pe(e.onFocus,j=>{const O=!S.current;if(j.target===j.currentTarget&&O&&!x){const F=new CustomEvent(Oi,fb);if(j.currentTarget.dispatchEvent(F),!F.defaultPrevented){const H=T().filter(I=>I.focusable),U=H.find(I=>I.active),q=H.find(I=>I.id===b),z=[U,q,...H].filter(Boolean).map(I=>I.ref.current);bu(z,d)}}S.current=!1}),onBlur:pe(e.onBlur,()=>w(!1))})})}),xu="RovingFocusGroupItem",vu=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=Pt(),u=s||c,d=gb(xu,n),f=d.currentTabStopId===u,h=pu(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:b}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),l.jsx(Di.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:l.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=wb(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=h().filter(T=>T.focusable).map(T=>T.ref.current);if(x==="last")C.reverse();else if(x==="prev"||x==="next"){x==="prev"&&C.reverse();const T=C.indexOf(g.currentTarget);C=d.loop?yb(C,T+1):C.slice(T+1)}setTimeout(()=>bu(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})});vu.displayName=xu;var vb={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function bb(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function wb(e,t,n){const r=bb(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return vb[r]}function bu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function yb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Sb=gu,Cb=vu,kb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gr=new WeakMap,Zo=new WeakMap,Qo={},Li=0,wu=function(e){return e&&(e.host||wu(e.parentNode))},Tb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=wu(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})},Eb=function(e,t,n,r){var o=Tb(t,Array.isArray(e)?e:[e]);Qo[n]||(Qo[n]=new WeakMap);var s=Qo[n],i=[],a=new Set,c=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),v=p!==null&&p!=="false",b=(gr.get(h)||0)+1,g=(s.get(h)||0)+1;gr.set(h,b),s.set(h,g),i.push(h),b===1&&v&&Zo.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(),Li++,function(){i.forEach(function(f){var h=gr.get(f)-1,p=s.get(f)-1;gr.set(f,h),s.set(f,p),h||(Zo.has(f)||f.removeAttribute(r),Zo.delete(f)),p||f.removeAttribute(n)}),Li--,Li||(gr=new WeakMap,gr=new WeakMap,Zo=new WeakMap,Qo={})}},$i=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=kb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Eb(r,o,n,"aria-hidden")):function(){return null}},mn=function(){return mn=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},mn.apply(this,arguments)};function yu(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 Ib(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 es="right-scroll-bar-position",ts="width-before-scroll-bar",Nb="with-scroll-bars-hidden",Ab="--removed-body-scroll-bar-size";function Fi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function jb(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var _b=typeof window<"u"?m.useLayoutEffect:m.useEffect,Su=new WeakMap;function Mb(e,t){var n=jb(null,function(r){return e.forEach(function(o){return Fi(o,r)})});return _b(function(){var r=Su.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Fi(a,null)}),s.forEach(function(a){o.has(a)||Fi(a,i)})}Su.set(n,e)},[e]),n}function Rb(e){return e}function Pb(e,t){t===void 0&&(t=Rb);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ob(e){e===void 0&&(e={});var t=Pb(null);return t.options=mn({async:!0,ssr:!1},e),t}var Cu=function(e){var t=e.sideCar,n=yu(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,mn({},n))};Cu.isSideCarExport=!0;function Db(e,t){return e.useMedium(t),Cu}var ku=Ob(),Bi=function(){},ns=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Bi,onWheelCapture:Bi,onTouchMoveCapture:Bi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,v=e.noIsolation,b=e.inert,g=e.allowPinchZoom,x=e.as,w=x===void 0?"div":x,C=e.gapMode,T=yu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,k=Mb([n,t]),E=mn(mn({},T),o);return m.createElement(m.Fragment,null,d&&m.createElement(S,{sideCar:ku,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:b,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:C}),i?m.cloneElement(m.Children.only(a),mn(mn({},E),{ref:k})):m.createElement(w,mn({},E,{className:c,ref:k}),a))});ns.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ns.classNames={fullWidth:ts,zeroRight:es};var Lb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function $b(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Lb();return t&&e.setAttribute("nonce",t),e}function Fb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Bb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var zb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=$b())&&(Fb(t,n),Bb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Hb=function(){var e=zb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Tu=function(){var e=Hb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ub={left:0,top:0,right:0,gap:0},zi=function(e){return parseInt(e||"",10)||0},Wb=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[zi(n),zi(r),zi(o)]},Vb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ub;var t=Wb(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])}},qb=Tu(),xr="data-scroll-locked",Kb=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
39
|
-
.`.concat(
|
|
38
|
+
`))>=0;){const se=lt.slice(0,M);lt=lt.slice(M+2);const me=Ex(se);if(!me)continue;let We;try{We=JSON.parse(me)}catch{console.debug("[use-chat] malformed SSE:",me.slice(0,200));continue}const Pe=Tx(We)?We.data:We;St=Date.now();const mt=Pe.seq;if(mt!==void 0){if(mt<=Oe){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:mt,lastProcessedSeq:Oe,type:Pe.type});continue}Oe>0&&mt>Oe+1&&((L=I==null?void 0:I.onGap)==null||L.call(I,{from:Oe,to:mt})),Oe=mt,S.current=mt,g(mt)}if(Pe.type==="checkpoint")E.current=Pe.checkpointId??null,j.current=Pe.checkpointNs??null,v(Pe.checkpointId??null);else if(Pe.type==="state_history"){O.current=Pe;try{const Nt=Vn(Pe).latest;Nt&&(E.current=Nt.checkpointId??null,j.current=Nt.checkpointNs??null,v(Nt.checkpointId??null))}catch(Ze){console.warn("[use-chat] Failed to hydrate state_history payload",Ze)}}try{z==null||z(Pe)}catch(Ze){console.error("[use-chat] Error in onEvent callback:",Ze,"for event:",Pe.type)}if(Pe.type==="message.delta"){const Ze=Pe.delta.filter(Nt=>Nt.type==="text").map(Nt=>Nt.text).join("");Ze&&e.autoAppendAssistant!==!1&&(Te.push(Ze),Tt())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(q=I==null?void 0:I.onHeartbeat)==null||q.call(I,Pe)}catch(Ze){console.warn("[use-chat] heartbeat callback failed",Ze)}}else if(at!==null&&cancelAnimationFrame(at),ht(),Pe.type==="checkpoint")v(Pe.checkpointId);else if(Pe.type==="error"){const Ze=Pe;if(d(Ze.message),R="error",A=Ze.message,Ze.error_type==="auth_error"||Ze.code==="TOKEN_EXPIRED"||((te=Ze.message)==null?void 0:te.includes("token"))||((G=Ze.message)==null?void 0:G.includes("401"))||((X=Ze.message)==null?void 0:X.includes("unauthorized"))||((he=Ze.message)==null?void 0:he.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ze.message);try{(fe=I==null?void 0:I.onAuthError)==null||fe.call(I,Ze.message)}catch(xo){console.warn("[use-chat] onAuthError handler failed",xo)}D.abort()}}}}ht(),R===null&&!D.signal.aborted&&(R="complete")}catch(Je){if(Je.name==="AbortError")R=R??"aborted";else{const Ke=Je.message||String(Je);R="error",A=Ke,d(Ke),(Z=I==null?void 0:I.onError)==null||Z.call(I,Ke)}}finally{try{await ot.cancel()}catch{}finally{(le=ot.releaseLock)==null||le.call(ot)}at!==null&&typeof window<"u"&&window.cancelAnimationFrame(at),clearInterval(Le)}}catch($e){if($e.name==="AbortError")R=R??"aborted";else{const Xe=$e.message||String($e);R="error",A=Xe,d(Xe),(we=I==null?void 0:I.onError)==null||we.call(I,Xe),B||((_e=I==null?void 0:I.onConnectionError)==null||_e.call(I,Xe),B=!0)}}finally{const $e=S.current,Xe=E.current,nt=j.current,Ve=O.current,qe=R??(D.signal.aborted?"aborted":A?"error":"complete");try{(Ne=I==null?void 0:I.onClosed)==null||Ne.call(I,{reason:qe,lastSeq:$e,lastCheckpointId:Xe,lastCheckpointNs:nt,lastStateHistory:Ve,error:A})}catch(ot){console.warn("[use-chat] onClosed callback failed",ot)}l(!1),b(!1),C.current=null,S.current=0,g(0),k.current=null}})(),{close:()=>D.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;T.current=!1,(P=C.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:w,connected:x,stream:K,stop:U,clear:H,setToken:F}}function Tx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Ex(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(`
|
|
39
|
+
`)}const Ix=["message.start","message.delta","message.end"],Nx=["tool.start","tool.end","tool.progress"],Ax=["thread_info","checkpoint"],jx=["error","interrupt","heartbeat","state_history","cancelled"],_x=[...Ix,...Nx,...Ax,...jx],Mx=new Set(_x);function Rx(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return Mx.has(t)}const wc=200;function Px({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onStateHistory:r,onUnhandledEvent:o,onSequenceGap:s,onStreamClosed:i,onConnectionError:a,onAuthError:l,onHeartbeat:u,onToolEvent:d}){const f=y.useRef(null),h=y.useRef(null),p=y.useRef(new Map),v=y.useRef(null),w=y.useRef(null),g=y.useCallback(I=>{try{const D=globalThis.structuredClone;if(typeof D=="function")return D(I)}catch{}try{return JSON.parse(JSON.stringify(I))}catch{return I}},[]),x=y.useCallback((I,D)=>{if(!I)return;const R=p.current.get(I)??[],A=g(D),B=R.length>=wc?[...R.slice(R.length-wc+1),A]:[...R,A];p.current.set(I,B)},[g]),b=y.useCallback(I=>{I&&p.current.set(I,[])},[]),C=y.useCallback(I=>{const D=I??h.current;if(!D)return;const R=p.current.get(D);R!=null&&R.length&&R.forEach(A=>{try{n(A)}catch(B){console.error("[useChatStreamingService] Failed to replay buffered event",B)}})},[n]),T=y.useCallback(I=>{h.current=I.threadId,v.current&&(v.current.threadIdGuess=I.threadId),w.current=I,b(I.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",I);try{t(I)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}},[b,t]),S=y.useCallback(I=>{try{u==null||u(I)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}},[u]),k=y.useCallback(I=>{var A,B,W,_;const D=I;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((A=D.message)==null?void 0:A.includes("token"))||((B=D.message)==null?void 0:B.includes("401"))||((W=D.message)==null?void 0:W.includes("unauthorized"))||((_=D.message)==null?void 0:_.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{l==null||l(D.message)}catch(V){console.warn("[useChatStreamingService] onAuthError handler failed",V)}}},[l]),E=y.useMemo(()=>({thread_info:I=>(T(I),!0),heartbeat:I=>(S(I),!0),error:I=>(k(I),!1)}),[T,S,k]),j=y.useCallback(I=>{var B;const D=I.seq??null;if(D!==null){const W=f.current;if(W!==null){if(D<=W)return;D>W+1&&(s==null||s({from:W,to:D}))}f.current=D}const R=E[I.type];if(R&&R(I))return;const A=I.threadId??(I.type==="state_history"?I.threadId:void 0)??h.current??((B=v.current)==null?void 0:B.threadIdGuess)??null;if(I.type==="state_history"){h.current=A??h.current;try{r==null||r(I)}catch(W){console.error("[useChatStreamingService] onStateHistory handler failed",W)}}if(Rx(I)){(I.type==="tool.start"||I.type==="tool.end")&&(d==null||d(I)),I.type==="checkpoint"||I.type==="state_history"?b(A??null):x(A??null,I);try{n(I)}catch(W){console.error("[useChatStreamingService] Error in onMessageEvent handler:",W)}return}try{o==null||o(I)}catch(W){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",W)}},[x,b,n,s,r,o,E]),{stream:O,stop:F,isStreaming:H,error:U,setToken:K}=vc({baseUrl:e,token:void 0}),P=y.useCallback((I,D)=>{f.current=null,w.current=null,h.current=I.threadId??null,v.current={request:I,callbacks:D,manualStop:!1,threadIdGuess:I.threadId??null},O(I,j,{onOpen:D==null?void 0:D.onOpen,onError:R=>{var A;(A=D==null?void 0:D.onError)==null||A.call(D,R)},onGap:(D==null?void 0:D.onGap)??s,onConnectionError:R=>{var A;a==null||a(R),(A=D==null?void 0:D.onConnectionError)==null||A.call(D,R)},onAuthError:R=>{var A;l==null||l(R),(A=D==null?void 0:D.onAuthError)==null||A.call(D,R)},onHeartbeat:R=>{var A;try{u==null||u(R)}catch(B){console.warn("[useChatStreamingService] onHeartbeat handler failed",B)}try{(A=D==null?void 0:D.onHeartbeat)==null||A.call(D,R)}catch(B){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",B)}},onClosed:R=>{var _,V,ie,Q;const A=((_=v.current)==null?void 0:_.manualStop)??!1,B=h.current??((V=v.current)==null?void 0:V.threadIdGuess)??((ie=R.lastStateHistory)==null?void 0:ie.threadId)??null;(R.reason==="complete"||R.reason==="aborted"&&A)&&b(B);const W={...R,threadId:B,threadInfo:w.current,manualStop:A};try{i==null||i(W)}catch(oe){console.warn("[useChatStreamingService] onStreamClosed handler failed",oe)}try{(Q=D==null?void 0:D.onClosed)==null||Q.call(D,W)}catch(oe){console.warn("[useChatStreamingService] downstream onClosed handler failed",oe)}v.current&&(v.current=null)}})},[b,j,l,a,u,s,i,O]),z=y.useCallback(()=>{v.current&&(v.current.manualStop=!0),F()},[F]);return y.useMemo(()=>({startStream:P,stop:z,isStreaming:H,error:U,setAuthToken:K,replayBufferedEvents:C}),[P,z,H,U,K,C])}const bc=y.createContext(null),yc=y.createContext(null),Sc=y.createContext(null);y.createContext(!1);function Ox({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:u}){const{api:d,baseUrl:f}=mi(),h=y.useMemo(()=>bn(f),[f]),{state:p,seed:v,prepend:w,pushUser:g,onEvent:x}=pc(),{threads:b,currentThreadId:C,setCurrentThreadId:T,currentThreadIdRef:S,isLoadingThreads:k,threadsError:E,sharedThreads:j,isLoadingSharedThreads:O,actions:F,addThreadFromEvent:H,shareInFlight:U,shareStatus:K,clearShareStatus:P}=rx({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[z,I]=y.useState(!1),D=y.useCallback(()=>p.messages,[p.messages]),{threadCheckpoints:R,threadTimeline:A,isLoadingThread:B,isHistoryLoading:W,isLoadingCheckpoint:_,threadStateError:V,hasMoreHistory:ie,loadThread:Q,navigateToCheckpoint:oe,loadOlderMessages:Y,setCurrentCheckpointId:L,returnToLatest:q,handleStateHistoryEvent:te,markSkipNextLoad:G,markStreamPendingThread:X,resetHistoryState:he}=ex({api:d,seed:v,prepend:w,onError:s,currentThreadId:C,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:z,getMessages:D}),fe=y.useMemo(()=>Gg(R),[R]),Z=y.useCallback(Te=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Te.threadId),H(Te),S.current!==Te.threadId&&((Te.created??!S.current)&&G(Te.threadId),X(Te.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(Te.threadId))},[H,G,X]),{startStream:le,stop:we,isStreaming:_e,error:Ne,setAuthToken:$e}=Px({baseUrl:h,onThreadInfo:Z,onMessageEvent:x,onStateHistory:te,onUnhandledEvent:Te=>{console.warn("[ChatSessionProvider] Unhandled event:",Te.type)},onAuthError:i,onConnectionError:l,onToolEvent:Te=>{Te.type==="tool.end"&&(u==null||u(Te))}});y.useEffect(()=>{I(_e)},[_e]);const Xe=y.useCallback(async()=>{v([],{}),T(null),we(),he();try{await d.getAgent("default")}catch(Te){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Te)}},[v,we,d,he]),nt=y.useCallback(async(Te,Oe,at)=>{const ht=S.current;if(!ht)throw new Error("No active thread to handle interrupt");const Tt=Oe?at??!0:!1;try{const St={threadId:ht,checkpointId:p.lastCheckpointId??void 0,checkpointNs:p.lastCheckpointNs??void 0,command:{kind:"resume",value:Tt}};le(St)}catch(St){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Te}:`,St),St}},[p.lastCheckpointId,p.lastCheckpointNs,le]),Ve=y.useCallback(async(Te,Oe)=>{let at=S.current;const ht=(Te==null?void 0:Te.text)??"",Tt=(Te==null?void 0:Te.attachments)??[],St=(ht==null?void 0:ht.trim())??"",Le={...(Te==null?void 0:Te.payload)??{}},Ht=Array.isArray(Le.messages)?Le.messages:void 0;Ht&&delete Le.messages;const Je=!!(Ht&&Ht.length);if(!at&&!St&&Tt.length===0&&!Je)return;if(!at){const mt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ze=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);at=`${mt}${Ze}`,G(at),T(at)}const{contentParts:Ke,filesInfo:dt}=await Vg(Tt),wt=[...Ke];St&&wt.push({type:"text",text:ht});const Ue=Oe==null?void 0:Oe.originalMessageId,Ct=!!(Oe!=null&&Oe.edit&&Ue),M=!Je&&wt.length>0;let se=null;M&&(se={id:Ct?Ue:`msg-${Date.now()}`,role:"user",content:wt,createdAt:new Date().toISOString()},Ct?g(se,Ue):g(se));const me=Je?Ht:se?[se]:[],We={...Le,...dt.length?{files_info:dt}:{}};me.length?We.messages=me:"messages"in We||(We.messages=[]);const Pe={threadId:at,payload:We,checkpointId:(Oe==null?void 0:Oe.checkpointId)??p.lastCheckpointId??void 0,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??p.lastCheckpointNs??void 0,edit:!!(Oe!=null&&Oe.edit),timelineCheckpoints:A};le(Pe)},[d,g,p,le,A]),qe=y.useMemo(()=>({threads:b,currentThreadId:C,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:j,isLoadingSharedThreads:O,actions:F,shareInFlight:U,shareStatus:K,clearShareStatus:P}),[b,C,T,k,E,j,O,F,U,K,P]),ot=y.useMemo(()=>{const Te=p.assemblingId??null;return Te?{assemblingMessageId:Te}:null},[p.assemblingId]),kt=y.useMemo(()=>({threadId:C,messages:p.messages,interrupt:null,checkpoint:{id:p.lastCheckpointId??null,namespace:p.lastCheckpointNs??null},checkpoints:R,timelineCheckpoints:A,metadata:ot,isLoading:B,isHistoryLoading:W,isLoadingCheckpoint:_,error:V,hasMore:ie,loadOlder:Y,clearState:Xe,navigateToCheckpoint:oe,setCurrentCheckpointId:L,returnToLatest:q,loadThread:Q,clearThread:Xe,respondToInterrupt:nt,messagePreviews:fe}),[C,p,R,A,B,W,_,V,ie,Y,Xe,oe,L,q,Q,nt,fe,ot]),lt=y.useMemo(()=>({isStreaming:_e,error:Ne,connectionState:_e?"connected":"idle",submit:Ve,send:Ve,stop:we,setAuthToken:$e}),[_e,Ne,Ve,we,$e]);return c.jsx(bc.Provider,{value:qe,children:c.jsx(yc.Provider,{value:kt,children:c.jsx(Sc.Provider,{value:lt,children:e})})})}function Do(){const e=y.useContext(bc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Lo(){const e=y.useContext(yc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function Cc(){const e=y.useContext(Sc);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function $o({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:u,onToolEnd:d}){return c.jsx(Ug,{apiConfig:t,children:c.jsx(Ox,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function ne(...e){return gm.twMerge(mm.clsx(e))}const Dx=wo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),et=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?zn.Slot:"button";return c.jsx(i,{className:ne(Dx({variant:t,size:n,className:e})),ref:s,...o})});et.displayName="Button";const kc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ne("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}));kc.displayName="Textarea";function Tc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,value:i,onValueChange:a,onSend:l,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1}){const v=i!==void 0,[w,g]=y.useState(e),x=(v?i:w)??"",[b,C]=y.useTransition(),T=y.useRef(null),S=y.useRef(0),k=y.useRef(null);y.useEffect(()=>{v||(g(e??""),k.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,v]);const E=y.useCallback(()=>{const z=T.current;z&&(z.style.height="auto",z.style.height=`${z.scrollHeight}px`)},[]);y.useEffect(()=>{E()},[E,x]);const j=y.useCallback((z,{fromUser:I})=>{v||g(z),I&&(a==null||a(z))},[v,a]),O=y.useCallback(async z=>{z&&z.preventDefault();const I=(x??"").trim();if(!I&&!p)return;const D=++S.current;k.current={id:D,shouldClear:!0},C(()=>{var R,A,B;try{const W=l(I);W&&typeof W.then=="function"?W.then(()=>{var _,V;((_=k.current)==null?void 0:_.id)===D&&k.current.shouldClear&&(v||(g(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=k.current)==null?void 0:V.id)===D&&(k.current=null)}).catch(()=>{var _;((_=k.current)==null?void 0:_.id)===D&&(k.current=null)}):(((R=k.current)==null?void 0:R.id)===D&&k.current.shouldClear&&(v||(g(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((A=k.current)==null?void 0:A.id)===D&&(k.current=null))}catch{((B=k.current)==null?void 0:B.id)===D&&(k.current=null)}})},[x,l,p,v,a]),F=y.useCallback(z=>{const I=z.target.value;j(I,{fromUser:!0}),k.current&&(k.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`)},[j]),H=y.useCallback(z=>{z.key==="Enter"&&!z.shiftKey?(z.preventDefault(),O()):z.key==="Escape"&&t&&(z.preventDefault(),u==null||u())},[O,t,u]),P=`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))]":""} ${h}`;return c.jsx("form",{onSubmit:z=>void O(z),className:`w-full ${f}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(kc,{ref:T,value:x,onChange:F,onKeyDown:H,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(et,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:c.jsx(ae.Square,{size:16})}):c.jsx(et,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!x.trim()&&!p||b,children:c.jsx(ae.Send,{size:16})})})]})})}const Lx=y.memo(Tc);function pe(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 Ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function En(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ec(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():Ec(e[o],null)}}}}function ze(...e){return m.useCallback(En(...e),e)}function $x(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 yn(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 Et=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Bx=m[" useInsertionEffect ".trim().toString()]||Et;function fr({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=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 zx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Bx(()=>{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"}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=zn.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 Ic(e,t){e&&bo.flushSync(()=>e.dispatchEvent(t))}function yi(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=w=>{const{scope:g,children:x}=w,b=y.useRef(null),C=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:C,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=zn.createSlot(a),u=y.forwardRef((w,g)=>{const{scope:x,children:b}=w,C=s(a,x),T=ze(g,C.collectionRef);return c.jsx(l,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=zn.createSlot(d),p=y.forwardRef((w,g)=>{const{scope:x,children:b,...C}=w,T=y.useRef(null),S=ze(g,T),k=s(d,x);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...C}),()=>void k.itemMap.delete(T))),c.jsx(h,{[f]:"",ref:S,children:b})});p.displayName=d;function v(w){const g=s(e+"CollectionConsumer",w);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>C.indexOf(k.ref.current)-C.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var Wx=m.createContext(void 0);function Fo(e){const t=m.useContext(Wx);return e||t||"ltr"}function It(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 Vx(e,t=globalThis==null?void 0:globalThis.document){const n=It(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 Kx="DismissableLayer",Si="dismissableLayer.update",qx="dismissableLayer.pointerDownOutside",Gx="dismissableLayer.focusOutside",Nc,Ac=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(Ac),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),v=ze(t,E=>f(E)),w=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=w.indexOf(g),b=d?w.indexOf(d):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=x,S=Jx(E=>{const j=E.target,O=[...u.branches].some(F=>F.contains(j));!T||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Zx(E=>{const j=E.target;[...u.branches].some(F=>F.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Vx(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Nc=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Nc)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jc())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(Si,E),()=>document.removeEventListener(Si,E)},[]),c.jsx(ye.div,{...l,ref:v,style:{pointerEvents:C?T?"auto":"none":void 0,...e.style},onFocusCapture:pe(e.onFocusCapture,k.onFocusCapture),onBlurCapture:pe(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:pe(e.onPointerDownCapture,S.onPointerDownCapture)})});Bo.displayName=Kx;var Yx="DismissableLayerBranch",Xx=m.forwardRef((e,t)=>{const n=m.useContext(Ac),r=m.useRef(null),o=ze(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})});Xx.displayName=Yx;function Jx(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){_c(qx,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 Zx(e,t=globalThis==null?void 0:globalThis.document){const n=It(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&_c(Gx,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function jc(){const e=new CustomEvent(Si);document.dispatchEvent(e)}function _c(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?Ic(o,s):o.dispatchEvent(s)}var Ci=0;function ki(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Mc()),document.body.insertAdjacentElement("beforeend",e[1]??Mc()),Ci++,()=>{Ci===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ci--}},[])}function Mc(){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 Ti="focusScope.autoFocusOnMount",Ei="focusScope.autoFocusOnUnmount",Rc={bubbles:!1,cancelable:!0},Qx="FocusScope",zo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=It(o),d=It(s),f=m.useRef(null),h=ze(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(C){if(p.paused||!a)return;const T=C.target;a.contains(T)?f.current=T:In(f.current,{select:!0})},g=function(C){if(p.paused||!a)return;const T=C.relatedTarget;T!==null&&(a.contains(T)||In(f.current,{select:!0}))},x=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&In(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){Dc.add(p);const w=document.activeElement;if(!a.contains(w)){const x=new CustomEvent(Ti,Rc);a.addEventListener(Ti,u),a.dispatchEvent(x),x.defaultPrevented||(ev(sv(Pc(a)),{select:!0}),document.activeElement===w&&In(a))}return()=>{a.removeEventListener(Ti,u),setTimeout(()=>{const x=new CustomEvent(Ei,Rc);a.addEventListener(Ei,d),a.dispatchEvent(x),x.defaultPrevented||In(w??document.body,{select:!0}),a.removeEventListener(Ei,d),Dc.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,[C,T]=tv(b);C&&T?!w.shiftKey&&x===T?(w.preventDefault(),n&&In(C,{select:!0})):w.shiftKey&&x===C&&(w.preventDefault(),n&&In(T,{select:!0})):x===b&&w.preventDefault()}},[n,r,p.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:v})});zo.displayName=Qx;function ev(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}function tv(e){const t=Pc(e),n=Oc(t,e),r=Oc(t.reverse(),e);return[n,r]}function Pc(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 Oc(e,t){for(const n of e)if(!nv(n,{upTo:t}))return n}function nv(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 rv(e){return e instanceof HTMLInputElement&&"select"in e}function In(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&rv(e)&&t&&e.select()}}var Dc=ov();function ov(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Lc(e,t),e.unshift(t)},remove(t){var n;e=Lc(e,t),(n=e[0])==null||n.resume()}}}function Lc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function sv(e){return e.filter(t=>t.tagName!=="A")}var iv=m[" useId ".trim().toString()]||(()=>{}),av=0;function Pt(e){const[t,n]=m.useState(iv());return Et(()=>{n(r=>r??String(av++))},[e]),t?`radix-${t}`:""}const lv=["top","right","bottom","left"],Nn=Math.min,Ut=Math.max,Ho=Math.round,Uo=Math.floor,dn=e=>({x:e,y:e}),cv={left:"right",right:"left",bottom:"top",top:"bottom"},uv={start:"end",end:"start"};function Ii(e,t,n){return Ut(e,Nn(t,n))}function Sn(e,t){return typeof e=="function"?e(t):e}function Cn(e){return e.split("-")[0]}function hr(e){return e.split("-")[1]}function Ni(e){return e==="x"?"y":"x"}function Ai(e){return e==="y"?"height":"width"}const dv=new Set(["top","bottom"]);function fn(e){return dv.has(Cn(e))?"y":"x"}function ji(e){return Ni(fn(e))}function fv(e,t,n){n===void 0&&(n=!1);const r=hr(e),o=ji(e),s=Ai(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Wo(i)),[i,Wo(i)]}function hv(e){const t=Wo(e);return[_i(e),t,_i(t)]}function _i(e){return e.replace(/start|end/g,t=>uv[t])}const $c=["left","right"],Fc=["right","left"],pv=["top","bottom"],mv=["bottom","top"];function gv(e,t,n){switch(e){case"top":case"bottom":return n?t?Fc:$c:t?$c:Fc;case"left":case"right":return t?pv:mv;default:return[]}}function xv(e,t,n,r){const o=hr(e);let s=gv(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(_i)))),s}function Wo(e){return e.replace(/left|right|bottom|top/g,t=>cv[t])}function vv(e){return{top:0,right:0,bottom:0,left:0,...e}}function Bc(e){return typeof e!="number"?vv(e):{top:e,right:e,bottom:e,left:e}}function Vo(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 zc(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=ji(t),a=Ai(i),l=Cn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let 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(hr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const wv=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}=zc(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:C,data:T,reset:S}=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=C??f,p={...p,[g]:{...p[g],...T}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=zc(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}=Sn(t,e),v=Bc(p),g=a[h?f==="floating"?"reference":"floating":f],x=Vo(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,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=Vo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(x.top-S.top+v.top)/T.y,bottom:(S.bottom-x.bottom+v.bottom)/T.y,left:(x.left-S.left+v.left)/T.x,right:(S.right-x.right+v.right)/T.x}}const bv=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}=Sn(e,t)||{};if(u==null)return{};const f=Bc(d),h={x:n,y:r},p=ji(o),v=Ai(p),w=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",C=g?"clientHeight":"clientWidth",T=s.reference[v]+s.reference[p]-h[p]-s.floating[v],S=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[C]||s.floating[v]);const j=T/2-S/2,O=E/2-w[v]/2-1,F=Nn(f[x],O),H=Nn(f[b],O),U=F,K=E-w[v]-H,P=E/2-w[v]/2+j,z=Ii(U,P,K),I=!l.arrow&&hr(o)!=null&&P!==z&&s.reference[v]/2-(P<U?F:H)-w[v]/2<0,D=I?P<U?P-U:P-K:0;return{[p]:h[p]+D,data:{[p]:z,centerOffset:P-z-D,...I&&{alignmentOffset:D}},reset:I}}}),yv=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}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Cn(o),b=fn(a),C=Cn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),S=h||(C||!w?[Wo(a)]:hv(a)),k=v!=="none";!h&&k&&S.push(...xv(a,w,v,T));const E=[a,...S],j=await Br(t,g),O=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(j[x]),f){const P=fv(o,i,T);O.push(j[P[0]],j[P[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every(P=>P<=0)){var H,U;const P=(((H=s.flip)==null?void 0:H.index)||0)+1,z=E[P];if(z&&(!(f==="alignment"?b!==fn(z):!1)||F.every(R=>fn(R.placement)===b?R.overflows[0]>0:!0)))return{data:{index:P,overflows:F},reset:{placement:z}};let I=(U=F.filter(D=>D.overflows[0]<=0).sort((D,R)=>D.overflows[1]-R.overflows[1])[0])==null?void 0:U.placement;if(!I)switch(p){case"bestFit":{var K;const D=(K=F.filter(R=>{if(k){const A=fn(R.placement);return A===b||A==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(A=>A>0).reduce((A,B)=>A+B,0)]).sort((R,A)=>R[1]-A[1])[0])==null?void 0:K[0];D&&(I=D);break}case"initialPlacement":I=a;break}if(o!==I)return{reset:{placement:I}}}return{}}}};function Hc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Uc(e){return lv.some(t=>e[t]>=0)}const Sv=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Sn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=Hc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Uc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Hc(s,n.floating);return{data:{escapedOffsets:i,escaped:Uc(i)}}}default:return{}}}}},Wc=new Set(["left","top"]);async function Cv(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Cn(n),a=hr(n),l=fn(n)==="y",u=Wc.has(i)?-1:1,d=s&&l?-1:1,f=Sn(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 kv=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 Cv(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}}}}},Tv=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}=Sn(e,t),u={x:n,y:r},d=await Br(t,l),f=fn(Cn(o)),h=Ni(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],C=p-d[x];p=Ii(b,p,C)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=v+d[g],C=v-d[x];v=Ii(b,v,C)}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}}}}}},Ev=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}=Sn(e,t),d={x:n,y:r},f=fn(o),h=Ni(f);let p=d[h],v=d[f];const w=Sn(a,t),g=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(l){const C=h==="y"?"height":"width",T=s.reference[h]-s.floating[C]+g.mainAxis,S=s.reference[h]+s.reference[C]-g.mainAxis;p<T?p=T:p>S&&(p=S)}if(u){var x,b;const C=h==="y"?"width":"height",T=Wc.has(Cn(o)),S=s.reference[f]-s.floating[C]+(T&&((x=i.offset)==null?void 0:x[f])||0)+(T?0:g.crossAxis),k=s.reference[f]+s.reference[C]+(T?0:((b=i.offset)==null?void 0:b[f])||0)-(T?g.crossAxis:0);v<S?v=S:v>k&&(v=k)}return{[h]:p,[f]:v}}}},Iv=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}=Sn(e,t),d=await Br(t,u),f=Cn(o),h=hr(o),p=fn(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,C=v-d.left-d.right,T=Nn(w-d[g],b),S=Nn(v-d[x],C),k=!t.middlewareData.shift;let E=T,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const F=Ut(d.left,0),H=Ut(d.right,0),U=Ut(d.top,0),K=Ut(d.bottom,0);p?j=v-2*(F!==0||H!==0?F+H:Ut(d.left,d.right)):E=w-2*(U!==0||K!==0?U+K:Ut(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||w!==O.height?{reset:{rects:!0}}:{}}}};function Ko(){return typeof window<"u"}function pr(e){return Vc(e)?(e.nodeName||"").toLowerCase():"#document"}function Wt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=(Vc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Vc(e){return Ko()?e instanceof Node||e instanceof Wt(e).Node:!1}function rn(e){return Ko()?e instanceof Element||e instanceof Wt(e).Element:!1}function pn(e){return Ko()?e instanceof HTMLElement||e instanceof Wt(e).HTMLElement:!1}function Kc(e){return!Ko()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Wt(e).ShadowRoot}const Nv=new Set(["inline","contents"]);function zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Nv.has(o)}const Av=new Set(["table","td","th"]);function jv(e){return Av.has(pr(e))}const _v=[":popover-open",":modal"];function qo(e){return _v.some(t=>{try{return e.matches(t)}catch{return!1}})}const Mv=["transform","translate","scale","rotate","perspective"],Rv=["transform","translate","scale","rotate","perspective","filter"],Pv=["paint","layout","strict","content"];function Mi(e){const t=Ri(),n=rn(e)?on(e):e;return Mv.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)||Rv.some(r=>(n.willChange||"").includes(r))||Pv.some(r=>(n.contain||"").includes(r))}function Ov(e){let t=An(e);for(;pn(t)&&!mr(t);){if(Mi(t))return t;if(qo(t))return null;t=An(t)}return null}function Ri(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Dv=new Set(["html","body","#document"]);function mr(e){return Dv.has(pr(e))}function on(e){return Wt(e).getComputedStyle(e)}function Go(e){return rn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function An(e){if(pr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Kc(e)&&e.host||hn(e);return Kc(t)?t.host:t}function qc(e){const t=An(e);return mr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&zr(t)?t:qc(t)}function Hr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=qc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Wt(o);if(s){const a=Pi(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Hr(a):[])}return t.concat(o,Hr(o,[],n))}function Pi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Gc(e){const t=on(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=pn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ho(n)!==s||Ho(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Oi(e){return rn(e)?e:e.contextElement}function gr(e){const t=Oi(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Gc(t);let i=(s?Ho(n.width):n.width)/r,a=(s?Ho(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Lv=dn(0);function Yc(e){const t=Wt(e);return!Ri()||!t.visualViewport?Lv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $v(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Wt(e)?!1:t}function Kn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Oi(e);let i=dn(1);t&&(r?rn(r)&&(i=gr(r)):i=gr(e));const a=$v(s,n,r)?Yc(s):dn(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=Wt(s),p=r&&rn(r)?Wt(r):r;let v=h,w=Pi(v);for(;w&&r&&p!==v;){const g=gr(w),x=w.getBoundingClientRect(),b=on(w),C=x.left+(w.clientLeft+parseFloat(b.paddingLeft))*g.x,T=x.top+(w.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=C,u+=T,v=Wt(w),w=Pi(v)}}return Vo({width:d,height:f,x:l,y:u})}function Yo(e,t){const n=Go(e).scrollLeft;return t?t.left+n:Kn(hn(e)).left+n}function Xc(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Yo(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Fv(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=hn(r),a=t?qo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=dn(1);const d=dn(0),f=pn(r);if((f||!f&&!s)&&((pr(r)!=="body"||zr(i))&&(l=Go(r)),pn(r))){const p=Kn(r);u=gr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Xc(i,l):dn(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 Bv(e){return Array.from(e.getClientRects())}function zv(e){const t=hn(e),n=Go(e),r=e.ownerDocument.body,o=Ut(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Ut(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yo(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Ut(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Jc=25;function Hv(e,t){const n=Wt(e),r=hn(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=Ri();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Yo(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<=Jc&&(s-=v)}else u<=Jc&&(s+=u);return{width:s,height:i,x:a,y:l}}const Uv=new Set(["absolute","fixed"]);function Wv(e,t){const n=Kn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=pn(e)?gr(e):dn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Zc(e,t,n){let r;if(t==="viewport")r=Hv(e,n);else if(t==="document")r=zv(hn(e));else if(rn(t))r=Wv(t,n);else{const o=Yc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vo(r)}function Qc(e,t){const n=An(e);return n===t||!rn(n)||mr(n)?!1:on(n).position==="fixed"||Qc(n,t)}function Vv(e,t){const n=t.get(e);if(n)return n;let r=Hr(e,[],!1).filter(a=>rn(a)&&pr(a)!=="body"),o=null;const s=on(e).position==="fixed";let i=s?An(e):e;for(;rn(i)&&!mr(i);){const a=on(i),l=Mi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Uv.has(o.position)||zr(i)&&!l&&Qc(e,i))?r=r.filter(d=>d!==i):o=a,i=An(i)}return t.set(e,r),r}function Kv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?qo(t)?[]:Vv(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Zc(t,d,o);return u.top=Ut(f.top,u.top),u.right=Nn(f.right,u.right),u.bottom=Nn(f.bottom,u.bottom),u.left=Ut(f.left,u.left),u},Zc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function qv(e){const{width:t,height:n}=Gc(e);return{width:t,height:n}}function Gv(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=Kn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=dn(0);function u(){l.x=Yo(o)}if(r||!r&&!s)if((pr(t)!=="body"||zr(o))&&(a=Go(t)),r){const p=Kn(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?Xc(o,a):dn(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 Di(e){return on(e).position==="static"}function eu(e,t){if(!pn(e)||on(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return hn(e)===n&&(n=n.ownerDocument.body),n}function tu(e,t){const n=Wt(e);if(qo(e))return n;if(!pn(e)){let o=An(e);for(;o&&!mr(o);){if(rn(o)&&!Di(o))return o;o=An(o)}return n}let r=eu(e,t);for(;r&&jv(r)&&Di(r);)r=eu(r,t);return r&&mr(r)&&Di(r)&&!Mi(r)?n:r||Ov(e)||n}const Yv=async function(e){const t=this.getOffsetParent||tu,n=this.getDimensions,r=await n(e.floating);return{reference:Gv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xv(e){return on(e).direction==="rtl"}const Jv={convertOffsetParentRelativeRectToViewportRelativeRect:Fv,getDocumentElement:hn,getClippingRect:Kv,getOffsetParent:tu,getElementRects:Yv,getClientRects:Bv,getDimensions:qv,getScale:gr,isElement:rn,isRTL:Xv};function nu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zv(e,t){let n=null,r;const o=hn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,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=Uo(f),w=Uo(o.clientWidth-(d+h)),g=Uo(o.clientHeight-(f+p)),x=Uo(d),C={rootMargin:-v+"px "+-w+"px "+-g+"px "+-x+"px",threshold:Ut(0,Nn(1,l))||1};let T=!0;function S(k){const E=k[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!nu(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Qv(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=Oi(e),d=o||s?[...u?Hr(u):[],...Hr(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Zv(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 C;(C=p)==null||C.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,w=l?Kn(e):null;l&&g();function g(){const x=Kn(e);w&&!nu(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 ew=kv,tw=Tv,nw=yv,rw=Iv,ow=Sv,ru=bv,sw=Ev,iw=(e,t,n)=>{const r=new Map,o={platform:Jv,...n},s={...o.platform,_c:r};return wv(e,t,{...o,platform:s})};var aw=typeof document<"u",lw=function(){},Xo=aw?y.useLayoutEffect:lw;function Jo(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(!Jo(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)&&!Jo(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function ou(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function su(e,t){const n=ou(e);return Math.round(t*n)/n}function Li(e){const t=m.useRef(e);return Xo(()=>{t.current=e}),t}function cw(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);Jo(h,r)||p(r);const[v,w]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(R=>{R!==k.current&&(k.current=R,w(R))},[]),C=m.useCallback(R=>{R!==E.current&&(E.current=R,x(R))},[]),T=s||v,S=i||g,k=m.useRef(null),E=m.useRef(null),j=m.useRef(d),O=l!=null,F=Li(l),H=Li(o),U=Li(u),K=m.useCallback(()=>{if(!k.current||!E.current)return;const R={placement:t,strategy:n,middleware:h};H.current&&(R.platform=H.current),iw(k.current,E.current,R).then(A=>{const B={...A,isPositioned:U.current!==!1};P.current&&!Jo(j.current,B)&&(j.current=B,bo.flushSync(()=>{f(B)}))})},[h,t,n,H,U]);Xo(()=>{u===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[u]);const P=m.useRef(!1);Xo(()=>(P.current=!0,()=>{P.current=!1}),[]),Xo(()=>{if(T&&(k.current=T),S&&(E.current=S),T&&S){if(F.current)return F.current(T,S,K);K()}},[T,S,K,F,O]);const z=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:C}),[b,C]),I=m.useMemo(()=>({reference:T,floating:S}),[T,S]),D=m.useMemo(()=>{const R={position:n,left:0,top:0};if(!I.floating)return R;const A=su(I.floating,d.x),B=su(I.floating,d.y);return a?{...R,transform:"translate("+A+"px, "+B+"px)",...ou(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:A,top:B}},[n,a,I.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:K,refs:z,elements:I,floatingStyles:D}),[d,K,z,I,D])}const uw=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?ru({element:r.current,padding:o}).fn(n):{}:r?ru({element:r,padding:o}).fn(n):{}}}},dw=(e,t)=>({...ew(e),options:[e,t]}),fw=(e,t)=>({...tw(e),options:[e,t]}),hw=(e,t)=>({...sw(e),options:[e,t]}),pw=(e,t)=>({...nw(e),options:[e,t]}),mw=(e,t)=>({...rw(e),options:[e,t]}),gw=(e,t)=>({...ow(e),options:[e,t]}),xw=(e,t)=>({...uw(e),options:[e,t]});var vw="Arrow",iu=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"})})});iu.displayName=vw;var ww=iu;function au(e){const[t,n]=m.useState(void 0);return Et(()=>{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 $i="Popper",[lu,Zo]=yn($i),[bw,cu]=lu($i),uu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(bw,{scope:t,anchor:r,onAnchorChange:o,children:n})};uu.displayName=$i;var du="PopperAnchor",fu=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=cu(du,n),i=m.useRef(null),a=ze(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})});fu.displayName=du;var Fi="PopperContent",[yw,Sw]=lu(Fi),hu=m.forwardRef((e,t)=>{var Y,L,q,te,G,X;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=cu(Fi,n),[x,b]=m.useState(null),C=ze(t,he=>b(he)),[T,S]=m.useState(null),k=au(T),E=(k==null?void 0:k.width)??0,j=(k==null?void 0:k.height)??0,O=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(u)?u:[u],U=H.length>0,K={padding:F,boundary:H.filter(kw),altBoundary:U},{refs:P,floatingStyles:z,placement:I,isPositioned:D,middlewareData:R}=cw({strategy:"fixed",placement:O,whileElementsMounted:(...he)=>Qv(...he,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[dw({mainAxis:o+j,alignmentAxis:i}),l&&fw({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?hw():void 0,...K}),l&&pw({...K}),mw({...K,apply:({elements:he,rects:fe,availableWidth:Z,availableHeight:le})=>{const{width:we,height:_e}=fe.reference,Ne=he.floating.style;Ne.setProperty("--radix-popper-available-width",`${Z}px`),Ne.setProperty("--radix-popper-available-height",`${le}px`),Ne.setProperty("--radix-popper-anchor-width",`${we}px`),Ne.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),T&&xw({element:T,padding:a}),Tw({arrowWidth:E,arrowHeight:j}),h&&gw({strategy:"referenceHidden",...K})]}),[A,B]=gu(I),W=It(v);Et(()=>{D&&(W==null||W())},[D,W]);const _=(Y=R.arrow)==null?void 0:Y.x,V=(L=R.arrow)==null?void 0:L.y,ie=((q=R.arrow)==null?void 0:q.centerOffset)!==0,[Q,oe]=m.useState();return Et(()=>{x&&oe(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:D?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[(te=R.transformOrigin)==null?void 0:te.x,(G=R.transformOrigin)==null?void 0:G.y].join(" "),...((X=R.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(yw,{scope:n,placedSide:A,onArrowChange:S,arrowX:_,arrowY:V,shouldHideArrow:ie,children:c.jsx(ye.div,{"data-side":A,"data-align":B,...w,ref:C,style:{...w.style,animation:D?void 0:"none"}})})})});hu.displayName=Fi;var pu="PopperArrow",Cw={top:"bottom",right:"left",bottom:"top",left:"right"},mu=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Sw(pu,r),i=Cw[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(ww,{...o,ref:n,style:{...o.style,display:"block"}})})});mu.displayName=pu;function kw(e){return e!==null}var Tw=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]=gu(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 gu(e){const[t,n="center"]=e.split("-");return[t,n]}var xu=uu,vu=fu,wu=hu,bu=mu,Ew="Portal",Qo=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Qs.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});Qo.displayName=Ew;function Iw(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Yt=e=>{const{present:t,children:n}=e,r=Nw(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=ze(r.ref,Aw(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Yt.displayName="Presence";function Nw(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Iw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=es(r.current);s.current=a==="mounted"?u:"none"},[a]),Et(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=es(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]),Et(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const w=es(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=es(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 es(e){return(e==null?void 0:e.animationName)||"none"}function Aw(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 Bi="rovingFocusGroup.onEntryFocus",jw={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[zi,yu,_w]=yi(Ur),[Mw,Su]=yn(Ur,[_w]),[Rw,Pw]=Mw(Ur),Cu=m.forwardRef((e,t)=>c.jsx(zi.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(zi.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ow,{...e,ref:t})})}));Cu.displayName=Ur;var Ow=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=ze(t,h),v=Fo(s),[w,g]=fr({prop:i,defaultProp:a??null,onChange:l,caller:Ur}),[x,b]=m.useState(!1),C=It(u),T=yu(n),S=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(Bi,C),()=>j.removeEventListener(Bi,C)},[C]),c.jsx(Rw,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:w,onItemFocus:m.useCallback(j=>g(j),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:m.useCallback(()=>E(j=>j-1),[]),children:c.jsx(ye.div,{tabIndex:x||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:pe(e.onMouseDown,()=>{S.current=!0}),onFocus:pe(e.onFocus,j=>{const O=!S.current;if(j.target===j.currentTarget&&O&&!x){const F=new CustomEvent(Bi,jw);if(j.currentTarget.dispatchEvent(F),!F.defaultPrevented){const H=T().filter(I=>I.focusable),U=H.find(I=>I.active),K=H.find(I=>I.id===w),z=[U,K,...H].filter(Boolean).map(I=>I.ref.current);Eu(z,d)}}S.current=!1}),onBlur:pe(e.onBlur,()=>b(!1))})})}),ku="RovingFocusGroupItem",Tu=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),u=s||l,d=Pw(ku,n),f=d.currentTabStopId===u,h=yu(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:w}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(zi.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:pe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:pe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:pe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=$w(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let C=h().filter(T=>T.focusable).map(T=>T.ref.current);if(x==="last")C.reverse();else if(x==="prev"||x==="next"){x==="prev"&&C.reverse();const T=C.indexOf(g.currentTarget);C=d.loop?Fw(C,T+1):C.slice(T+1)}setTimeout(()=>Eu(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:w!=null}):i})})});Tu.displayName=ku;var Dw={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Lw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function $w(e,t,n){const r=Lw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Dw[r]}function Eu(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Fw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bw=Cu,zw=Tu,Hw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},xr=new WeakMap,ts=new WeakMap,ns={},Hi=0,Iu=function(e){return e&&(e.host||Iu(e.parentNode))},Uw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Iu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ww=function(e,t,n,r){var o=Uw(t,Array.isArray(e)?e:[e]);ns[n]||(ns[n]=new WeakMap);var s=ns[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=(xr.get(h)||0)+1,g=(s.get(h)||0)+1;xr.set(h,w),s.set(h,g),i.push(h),w===1&&v&&ts.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(),Hi++,function(){i.forEach(function(f){var h=xr.get(f)-1,p=s.get(f)-1;xr.set(f,h),s.set(f,p),h||(ts.has(f)||f.removeAttribute(r),ts.delete(f)),p||f.removeAttribute(n)}),Hi--,Hi||(xr=new WeakMap,xr=new WeakMap,ts=new WeakMap,ns={})}},Ui=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Hw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ww(r,o,n,"aria-hidden")):function(){return null}},mn=function(){return mn=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},mn.apply(this,arguments)};function Nu(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 Vw(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 rs="right-scroll-bar-position",os="width-before-scroll-bar",Kw="with-scroll-bars-hidden",qw="--removed-body-scroll-bar-size";function Wi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Gw(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Yw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Au=new WeakMap;function Xw(e,t){var n=Gw(null,function(r){return e.forEach(function(o){return Wi(o,r)})});return Yw(function(){var r=Au.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Wi(a,null)}),s.forEach(function(a){o.has(a)||Wi(a,i)})}Au.set(n,e)},[e]),n}function Jw(e){return e}function Zw(e,t){t===void 0&&(t=Jw);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 Qw(e){e===void 0&&(e={});var t=Zw(null);return t.options=mn({async:!0,ssr:!1},e),t}var ju=function(e){var t=e.sideCar,n=Nu(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,mn({},n))};ju.isSideCarExport=!0;function eb(e,t){return e.useMedium(t),ju}var _u=Qw(),Vi=function(){},ss=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Vi,onWheelCapture:Vi,onTouchMoveCapture:Vi}),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,C=e.gapMode,T=Nu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,k=Xw([n,t]),E=mn(mn({},T),o);return m.createElement(m.Fragment,null,d&&m.createElement(S,{sideCar:_u,removeScrollBar:u,shards:f,noRelative:p,noIsolation:v,inert:w,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:C}),i?m.cloneElement(m.Children.only(a),mn(mn({},E),{ref:k})):m.createElement(b,mn({},E,{className:l,ref:k}),a))});ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ss.classNames={fullWidth:os,zeroRight:rs};var tb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function nb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=tb();return t&&e.setAttribute("nonce",t),e}function rb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ob(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var sb=function(){var e=0,t=null;return{add:function(n){e==0&&(t=nb())&&(rb(t,n),ob(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ib=function(){var e=sb();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Mu=function(){var e=ib(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},ab={left:0,top:0,right:0,gap:0},Ki=function(e){return parseInt(e||"",10)||0},lb=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[Ki(n),Ki(r),Ki(o)]},cb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ab;var t=lb(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])}},ub=Mu(),vr="data-scroll-locked",db=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(Kw,` {
|
|
40
41
|
overflow: hidden `).concat(r,`;
|
|
41
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
42
43
|
}
|
|
43
|
-
body[`).concat(
|
|
44
|
+
body[`).concat(vr,`] {
|
|
44
45
|
overflow: hidden `).concat(r,`;
|
|
45
46
|
overscroll-behavior: contain;
|
|
46
47
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -53,29 +54,29 @@ React keys must be passed directly to JSX without using spread:
|
|
|
53
54
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
.`).concat(
|
|
57
|
+
.`).concat(rs,` {
|
|
57
58
|
right: `).concat(a,"px ").concat(r,`;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
.`).concat(
|
|
61
|
+
.`).concat(os,` {
|
|
61
62
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
.`).concat(
|
|
65
|
+
.`).concat(rs," .").concat(rs,` {
|
|
65
66
|
right: 0 `).concat(r,`;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
.`).concat(
|
|
69
|
+
.`).concat(os," .").concat(os,` {
|
|
69
70
|
margin-right: 0 `).concat(r,`;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
body[`).concat(
|
|
73
|
-
`).concat(
|
|
73
|
+
body[`).concat(vr,`] {
|
|
74
|
+
`).concat(qw,": ").concat(a,`px;
|
|
74
75
|
}
|
|
75
|
-
`)},
|
|
76
|
+
`)},Ru=function(){var e=parseInt(document.body.getAttribute(vr)||"0",10);return isFinite(e)?e:0},fb=function(){m.useEffect(function(){return document.body.setAttribute(vr,(Ru()+1).toString()),function(){var e=Ru()-1;e<=0?document.body.removeAttribute(vr):document.body.setAttribute(vr,e.toString())}},[])},hb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;fb();var s=m.useMemo(function(){return cb(o)},[o]);return m.createElement(ub,{styles:db(s,!t,o,n?"":"!important")})},qi=!1;if(typeof window<"u")try{var is=Object.defineProperty({},"passive",{get:function(){return qi=!0,!0}});window.addEventListener("test",is,is),window.removeEventListener("test",is,is)}catch{qi=!1}var wr=qi?{passive:!1}:!1,pb=function(e){return e.tagName==="TEXTAREA"},Pu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!pb(e)&&n[t]==="visible")},mb=function(e){return Pu(e,"overflowY")},gb=function(e){return Pu(e,"overflowX")},Ou=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Du(e,r);if(o){var s=Lu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},xb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},vb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Du=function(e,t){return e==="v"?mb(t):gb(t)},Lu=function(e,t){return e==="v"?xb(t):vb(t)},wb=function(e,t){return e==="h"&&t==="rtl"?-1:1},bb=function(e,t,n,r,o){var s=wb(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=Lu(e,a),v=p[0],w=p[1],g=p[2],x=w-g-s*v;(v||x)&&Du(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},as=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$u=function(e){return[e.deltaX,e.deltaY]},Fu=function(e){return e&&"current"in e?e.current:e},yb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Sb=function(e){return`
|
|
76
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
77
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
78
|
-
`)},sw=0,br=[];function iw(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(sw++)[0],s=m.useState(Tu)[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 b=Ib([e.lockRef.current],(e.shards||[]).map(Mu),!0).filter(Boolean);return b.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),b.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(b,g){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!i.current.allowPinchZoom;var x=os(b),w=n.current,C="deltaX"in b?b.deltaX:w[0]-x[0],T="deltaY"in b?b.deltaY:w[1]-x[1],S,k=b.target,E=Math.abs(C)>Math.abs(T)?"h":"v";if("touches"in b&&E==="h"&&k.type==="range")return!1;var j=Nu(E,k);if(!j)return!0;if(j?S=E:(S=E==="v"?"h":"v",j=Nu(E,k)),!j)return!1;if(!r.current&&"changedTouches"in b&&(C||T)&&(r.current=S),!S)return!0;var O=r.current||S;return nw(O,g,b,O==="h"?C:T)},[]),c=m.useCallback(function(b){var g=b;if(!(!br.length||br[br.length-1]!==s)){var x="deltaY"in g?_u(g):os(g),w=t.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&rw(S.delta,x)})[0];if(w&&w.should){g.cancelable&&g.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(Mu).filter(Boolean).filter(function(S){return S.contains(g.target)}),T=C.length>0?a(g,C[0]):!i.current.noIsolation;T&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(b,g,x,w){var C={name:b,delta:g,target:x,should:w,shadowParent:aw(x)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(T){return T!==C})},1)},[]),d=m.useCallback(function(b){n.current=os(b),r.current=void 0},[]),f=m.useCallback(function(b){u(b.type,_u(b),b.target,a(b,e.lockRef.current))},[]),h=m.useCallback(function(b){u(b.type,os(b),b.target,a(b,e.lockRef.current))},[]);m.useEffect(function(){return br.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,vr),document.addEventListener("touchmove",c,vr),document.addEventListener("touchstart",d,vr),function(){br=br.filter(function(b){return b!==s}),document.removeEventListener("wheel",c,vr),document.removeEventListener("touchmove",c,vr),document.removeEventListener("touchstart",d,vr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:ow(o)}):null,p?m.createElement(Yb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const lw=Db(ku,iw);var ss=m.forwardRef(function(e,t){return m.createElement(ns,mn({},e,{ref:t,sideCar:lw}))});ss.classNames=ns.classNames;var Ui=["Enter"," "],cw=["ArrowDown","PageUp","Home"],Ru=["ArrowUp","PageDown","End"],uw=[...cw,...Ru],dw={ltr:[...Ui,"ArrowRight"],rtl:[...Ui,"ArrowLeft"]},fw={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Br="Menu",[zr,hw,pw]=gi(Br),[Kn,Pu]=yn(Br,[pw,Yo,mu]),is=Yo(),Ou=mu(),[mw,Gn]=Kn(Br),[gw,Hr]=Kn(Br),Du=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=is(t),[c,u]=m.useState(null),d=m.useRef(!1),f=It(s),h=Do(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})}},[]),l.jsx(uu,{...a,children:l.jsx(mw,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(gw,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Du.displayName=Br;var xw="MenuAnchor",Wi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(du,{...o,...r,ref:t})});Wi.displayName=xw;var Vi="MenuPortal",[vw,Lu]=Kn(Vi,{forceMount:void 0}),$u=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Gn(Vi,t);return l.jsx(vw,{scope:t,forceMount:n,children:l.jsx(Yt,{present:n||s.open,children:l.jsx(Xo,{asChild:!0,container:o,children:r})})})};$u.displayName=Vi;var Xt="MenuContent",[bw,qi]=Kn(Xt),Fu=m.forwardRef((e,t)=>{const n=Lu(Xt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Gn(Xt,e.__scopeMenu),i=Hr(Xt,e.__scopeMenu);return l.jsx(zr.Provider,{scope:e.__scopeMenu,children:l.jsx(Yt,{present:r||s.open,children:l.jsx(zr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(ww,{...o,ref:t}):l.jsx(yw,{...o,ref:t})})})})}),ww=m.forwardRef((e,t)=>{const n=Gn(Xt,e.__scopeMenu),r=m.useRef(null),o=ze(t,r);return m.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(Ki,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yw=m.forwardRef((e,t)=>{const n=Gn(Xt,e.__scopeMenu);return l.jsx(Ki,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Sw=zn.createSlot("MenuContent.ScrollLock"),Ki=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...b}=e,g=Gn(Xt,n),x=Hr(Xt,n),w=is(n),C=Ou(n),T=hw(n),[S,k]=m.useState(null),E=m.useRef(null),j=ze(t,E,g.onContentChange),O=m.useRef(0),F=m.useRef(""),H=m.useRef(0),U=m.useRef(null),q=m.useRef("right"),P=m.useRef(0),z=v?ss:m.Fragment,I=v?{as:Sw,allowPinchZoom:!0}:void 0,D=A=>{var Y,L;const B=F.current+A,W=T().filter(K=>!K.disabled),_=document.activeElement,V=(Y=W.find(K=>K.ref.current===_))==null?void 0:Y.textValue,ie=W.map(K=>K.textValue),Q=Pw(ie,B,V),oe=(L=W.find(K=>K.textValue===Q))==null?void 0:L.ref.current;(function K(te){F.current=te,window.clearTimeout(O.current),te!==""&&(O.current=window.setTimeout(()=>K(""),1e3))})(B),oe&&setTimeout(()=>oe.focus())};m.useEffect(()=>()=>window.clearTimeout(O.current),[]),bi();const R=m.useCallback(A=>{var W,_;return q.current===((W=U.current)==null?void 0:W.side)&&Dw(A,(_=U.current)==null?void 0:_.area)},[]);return l.jsx(bw,{scope:n,searchRef:F,onItemEnter:m.useCallback(A=>{R(A)&&A.preventDefault()},[R]),onItemLeave:m.useCallback(A=>{var B;R(A)||((B=E.current)==null||B.focus(),k(null))},[R]),onTriggerLeave:m.useCallback(A=>{R(A)&&A.preventDefault()},[R]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(A=>{U.current=A},[]),children:l.jsx(z,{...I,children:l.jsx($o,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,A=>{var B;A.preventDefault(),(B=E.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:l.jsx(Sb,{asChild:!0,...C,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:pe(c,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(fu,{role:"menu","aria-orientation":"vertical","data-state":nd(g.open),"data-radix-menu-content":"",dir:x.dir,...w,...b,ref:j,style:{outline:"none",...b.style},onKeyDown:pe(b.onKeyDown,A=>{const W=A.target.closest("[data-radix-menu-content]")===A.currentTarget,_=A.ctrlKey||A.altKey||A.metaKey,V=A.key.length===1;W&&(A.key==="Tab"&&A.preventDefault(),!_&&V&&D(A.key));const ie=E.current;if(A.target!==ie||!uw.includes(A.key))return;A.preventDefault();const oe=T().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);Ru.includes(A.key)&&oe.reverse(),Mw(oe)}),onBlur:pe(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(O.current),F.current="")}),onPointerMove:pe(e.onPointerMove,Wr(A=>{const B=A.target,W=P.current!==A.clientX;if(A.currentTarget.contains(B)&&W){const _=A.clientX>P.current?"right":"left";q.current=_,P.current=A.clientX}}))})})})})})})});Fu.displayName=Xt;var Cw="MenuGroup",Gi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"group",...r,ref:t})});Gi.displayName=Cw;var kw="MenuLabel",Bu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{...r,ref:t})});Bu.displayName=kw;var as="MenuItem",zu="menu.itemSelect",ls=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Hr(as,e.__scopeMenu),a=qi(as,e.__scopeMenu),c=ze(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(zu,{bubbles:!0,cancelable:!0});f.addEventListener(zu,p=>r==null?void 0:r(p),{once:!0}),wc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(Hu,{...o,ref:c,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Ui.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ls.displayName=as;var Hu=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=qi(as,n),a=Ou(n),c=m.useRef(null),u=ze(t,c),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=c.current;v&&p((v.textContent??"").trim())},[s.children]),l.jsx(zr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(Cb,{asChild:!0,...a,focusable:!r,children:l.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:pe(e.onPointerMove,Wr(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,Wr(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),Tw="MenuCheckboxItem",Uu=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(Gu,{scope:e.__scopeMenu,checked:n,children:l.jsx(ls,{role:"menuitemcheckbox","aria-checked":cs(n)?"mixed":n,...o,ref:t,"data-state":Xi(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(cs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Uu.displayName=Tw;var Wu="MenuRadioGroup",[Ew,Iw]=Kn(Wu,{value:void 0,onValueChange:()=>{}}),Vu=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return l.jsx(Ew,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(Gi,{...o,ref:t})})});Vu.displayName=Wu;var qu="MenuRadioItem",Ku=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Iw(qu,e.__scopeMenu),s=n===o.value;return l.jsx(Gu,{scope:e.__scopeMenu,checked:s,children:l.jsx(ls,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Xi(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Ku.displayName=qu;var Yi="MenuItemIndicator",[Gu,Nw]=Kn(Yi,{checked:!1}),Yu=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Nw(Yi,n);return l.jsx(Yt,{present:r||cs(s.checked)||s.checked===!0,children:l.jsx(ye.span,{...o,ref:t,"data-state":Xi(s.checked)})})});Yu.displayName=Yi;var Aw="MenuSeparator",Xu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Xu.displayName=Aw;var jw="MenuArrow",Ju=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=is(n);return l.jsx(hu,{...o,...r,ref:t})});Ju.displayName=jw;var _w="MenuSub",[NT,Zu]=Kn(_w),Ur="MenuSubTrigger",Qu=m.forwardRef((e,t)=>{const n=Gn(Ur,e.__scopeMenu),r=Hr(Ur,e.__scopeMenu),o=Zu(Ur,e.__scopeMenu),s=qi(Ur,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=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),c(null)}},[a,c]),l.jsx(Wi,{asChild:!0,...u,children:l.jsx(Hu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":nd(n.open),...e,ref:En(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:pe(e.onPointerMove,Wr(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:pe(e.onPointerLeave,Wr(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const b=(v=n.content)==null?void 0:v.dataset.side,g=b==="right",x=g?-5:5,w=h[g?"left":"right"],C=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:w,y:h.top},{x:C,y:h.top},{x:C,y:h.bottom},{x:w,y:h.bottom}],side:b}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||dw[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Qu.displayName=Ur;var ed="MenuSubContent",td=m.forwardRef((e,t)=>{const n=Lu(Xt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Gn(Xt,e.__scopeMenu),i=Hr(Xt,e.__scopeMenu),a=Zu(ed,e.__scopeMenu),c=m.useRef(null),u=ze(t,c);return l.jsx(zr.Provider,{scope:e.__scopeMenu,children:l.jsx(Yt,{present:r||s.open,children:l.jsx(zr.Slot,{scope:e.__scopeMenu,children:l.jsx(Ki,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=fw[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});td.displayName=ed;function nd(e){return e?"open":"closed"}function cs(e){return e==="indeterminate"}function Xi(e){return cs(e)?"indeterminate":e?"checked":"unchecked"}function Mw(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Rw(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Pw(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=Rw(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function Ow(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],c=t[i],u=a.x,d=a.y,f=c.x,h=c.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function Dw(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Ow(n,t)}function Wr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Lw=Du,$w=Wi,Fw=$u,Bw=Fu,zw=Gi,Hw=Bu,Uw=ls,Ww=Uu,Vw=Vu,qw=Ku,Kw=Yu,Gw=Xu,Yw=Ju,Xw=Qu,Jw=td,us="DropdownMenu",[Zw,AT]=yn(us,[Pu]),Ot=Pu(),[Qw,rd]=Zw(us),od=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=Ot(t),u=m.useRef(null),[d,f]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:us});return l.jsx(Qw,{scope:t,triggerId:Pt(),triggerRef:u,contentId:Pt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(Lw,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};od.displayName=us;var sd="DropdownMenuTrigger",id=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=rd(sd,n),i=Ot(n);return l.jsx($w,{asChild:!0,...i,children:l.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:En(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});id.displayName=sd;var ey="DropdownMenuPortal",ad=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return l.jsx(Fw,{...r,...n})};ad.displayName=ey;var ld="DropdownMenuContent",cd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=rd(ld,n),s=Ot(n),i=m.useRef(!1);return l.jsx(Bw,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(e.onInteractOutside,a=>{const c=a.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});cd.displayName=ld;var ty="DropdownMenuGroup",ny=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(zw,{...o,...r,ref:t})});ny.displayName=ty;var ry="DropdownMenuLabel",ud=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Hw,{...o,...r,ref:t})});ud.displayName=ry;var oy="DropdownMenuItem",dd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Uw,{...o,...r,ref:t})});dd.displayName=oy;var sy="DropdownMenuCheckboxItem",fd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Ww,{...o,...r,ref:t})});fd.displayName=sy;var iy="DropdownMenuRadioGroup",ay=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Vw,{...o,...r,ref:t})});ay.displayName=iy;var ly="DropdownMenuRadioItem",hd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(qw,{...o,...r,ref:t})});hd.displayName=ly;var cy="DropdownMenuItemIndicator",pd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Kw,{...o,...r,ref:t})});pd.displayName=cy;var uy="DropdownMenuSeparator",md=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Gw,{...o,...r,ref:t})});md.displayName=uy;var dy="DropdownMenuArrow",fy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Yw,{...o,...r,ref:t})});fy.displayName=dy;var hy="DropdownMenuSubTrigger",gd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Xw,{...o,...r,ref:t})});gd.displayName=hy;var py="DropdownMenuSubContent",xd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(Jw,{...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)"}})});xd.displayName=py;var my=od,gy=id,xy=ad,vd=cd,bd=ud,wd=dd,yd=fd,Sd=hd,Cd=pd,kd=md,Td=gd,Ed=xd;const Ji=my,Zi=gy,vy=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(Td,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,l.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));vy.displayName=Td.displayName;const by=m.forwardRef(({className:e,...t},n)=>l.jsx(Ed,{ref:n,className:ne("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}));by.displayName=Ed.displayName;const ds=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(xy,{children:l.jsx(vd,{ref:r,sideOffset:t,className:ne("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})}));ds.displayName=vd.displayName;const Yn=m.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(wd,{ref:r,className:ne("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}));Yn.displayName=wd.displayName;const wy=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(yd,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Cd,{children:l.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));wy.displayName=yd.displayName;const yy=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Sd,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Cd,{children:l.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));yy.displayName=Sd.displayName;const Sy=m.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(bd,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Sy.displayName=bd.displayName;const Cy=m.forwardRef(({className:e,...t},n)=>l.jsx(kd,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Cy.displayName=kd.displayName;function ky(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let c=s.length-1;c>=0;c--){const u=s[c];if(u.role==="user"&&u.id){i=u.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((c,u)=>u.timestamp-c.timestamp);const a=[];for(let c=0;c<s.length;c++){const{checkpoint:u}=s[c],d=u.checkpointId;if(!d)continue;const f={attemptIndex:c,attemptCount:i,isLatestAttempt:c===0,baseUserMessageId:o};n.set(d,f),i>1&&a.push({checkpointId:d,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}function Ty(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="number"?n:null}function Ey(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function Iy(e){const{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}=y.useMemo(()=>{const s=new Map,i=new Map,a=new Map;for(const d of e){const f=d.checkpointId??null;if(!f)continue;const h=Ty(d.metadata,"step"),p=Ey(d.metadata,"source"),v={id:f,step:h,source:p,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null};if(s.set(f,v),h!==null&&p){const b=`${h}:${p}`,g=i.get(b)??[];g.push(v),i.set(b,g)}}const{attemptMetaById:c,userMessageIdToAttempts:u}=ky(e);for(const[d,f]of s.entries()){const h=c.get(d);h?a.set(d,{...f,attemptIndex:h.attemptIndex,attemptCount:h.attemptCount,isLatestAttempt:h.isLatestAttempt,baseUserMessageId:h.baseUserMessageId??null}):a.set(d,{...f,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpointMetaById:s,checkpointIndexByKey:i,attemptMetaById:a,userMessageIdToAttempts:u}},[e]);return{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}}const fs=1e4;function Ny(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
79
|
+
`)},Cb=0,br=[];function kb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Cb++)[0],s=m.useState(Mu)[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=Vw([e.lockRef.current],(e.shards||[]).map(Fu),!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=as(w),b=n.current,C="deltaX"in w?w.deltaX:b[0]-x[0],T="deltaY"in w?w.deltaY:b[1]-x[1],S,k=w.target,E=Math.abs(C)>Math.abs(T)?"h":"v";if("touches"in w&&E==="h"&&k.type==="range")return!1;var j=Ou(E,k);if(!j)return!0;if(j?S=E:(S=E==="v"?"h":"v",j=Ou(E,k)),!j)return!1;if(!r.current&&"changedTouches"in w&&(C||T)&&(r.current=S),!S)return!0;var O=r.current||S;return bb(O,g,w,O==="h"?C:T)},[]),l=m.useCallback(function(w){var g=w;if(!(!br.length||br[br.length-1]!==s)){var x="deltaY"in g?$u(g):as(g),b=t.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&yb(S.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Fu).filter(Boolean).filter(function(S){return S.contains(g.target)}),T=C.length>0?a(g,C[0]):!i.current.noIsolation;T&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(w,g,x,b){var C={name:w,delta:g,target:x,should:b,shadowParent:Tb(x)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(T){return T!==C})},1)},[]),d=m.useCallback(function(w){n.current=as(w),r.current=void 0},[]),f=m.useCallback(function(w){u(w.type,$u(w),w.target,a(w,e.lockRef.current))},[]),h=m.useCallback(function(w){u(w.type,as(w),w.target,a(w,e.lockRef.current))},[]);m.useEffect(function(){return br.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,wr),document.addEventListener("touchmove",l,wr),document.addEventListener("touchstart",d,wr),function(){br=br.filter(function(w){return w!==s}),document.removeEventListener("wheel",l,wr),document.removeEventListener("touchmove",l,wr),document.removeEventListener("touchstart",d,wr)}},[]);var p=e.removeScrollBar,v=e.inert;return m.createElement(m.Fragment,null,v?m.createElement(s,{styles:Sb(o)}):null,p?m.createElement(hb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Tb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Eb=eb(_u,kb);var ls=m.forwardRef(function(e,t){return m.createElement(ss,mn({},e,{ref:t,sideCar:Eb}))});ls.classNames=ss.classNames;var Gi=["Enter"," "],Ib=["ArrowDown","PageUp","Home"],Bu=["ArrowUp","PageDown","End"],Nb=[...Ib,...Bu],Ab={ltr:[...Gi,"ArrowRight"],rtl:[...Gi,"ArrowLeft"]},jb={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,_b,Mb]=yi(Wr),[qn,zu]=yn(Wr,[Mb,Zo,Su]),cs=Zo(),Hu=Su(),[Rb,Gn]=qn(Wr),[Pb,Kr]=qn(Wr),Uu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=cs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=It(s),h=Fo(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(xu,{...a,children:c.jsx(Rb,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Pb,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Uu.displayName=Wr;var Ob="MenuAnchor",Yi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(vu,{...o,...r,ref:t})});Yi.displayName=Ob;var Xi="MenuPortal",[Db,Wu]=qn(Xi,{forceMount:void 0}),Vu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Gn(Xi,t);return c.jsx(Db,{scope:t,forceMount:n,children:c.jsx(Yt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:r})})})};Vu.displayName=Xi;var Xt="MenuContent",[Lb,Ji]=qn(Xt),Ku=m.forwardRef((e,t)=>{const n=Wu(Xt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Gn(Xt,e.__scopeMenu),i=Kr(Xt,e.__scopeMenu);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Yt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx($b,{...o,ref:t}):c.jsx(Fb,{...o,ref:t})})})})}),$b=m.forwardRef((e,t)=>{const n=Gn(Xt,e.__scopeMenu),r=m.useRef(null),o=ze(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ui(s)},[]),c.jsx(Zi,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Fb=m.forwardRef((e,t)=>{const n=Gn(Xt,e.__scopeMenu);return c.jsx(Zi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Bb=zn.createSlot("MenuContent.ScrollLock"),Zi=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=Gn(Xt,n),x=Kr(Xt,n),b=cs(n),C=Hu(n),T=_b(n),[S,k]=m.useState(null),E=m.useRef(null),j=ze(t,E,g.onContentChange),O=m.useRef(0),F=m.useRef(""),H=m.useRef(0),U=m.useRef(null),K=m.useRef("right"),P=m.useRef(0),z=v?ls:m.Fragment,I=v?{as:Bb,allowPinchZoom:!0}:void 0,D=A=>{var Y,L;const B=F.current+A,W=T().filter(q=>!q.disabled),_=document.activeElement,V=(Y=W.find(q=>q.ref.current===_))==null?void 0:Y.textValue,ie=W.map(q=>q.textValue),Q=Zb(ie,B,V),oe=(L=W.find(q=>q.textValue===Q))==null?void 0:L.ref.current;(function q(te){F.current=te,window.clearTimeout(O.current),te!==""&&(O.current=window.setTimeout(()=>q(""),1e3))})(B),oe&&setTimeout(()=>oe.focus())};m.useEffect(()=>()=>window.clearTimeout(O.current),[]),ki();const R=m.useCallback(A=>{var W,_;return K.current===((W=U.current)==null?void 0:W.side)&&ey(A,(_=U.current)==null?void 0:_.area)},[]);return c.jsx(Lb,{scope:n,searchRef:F,onItemEnter:m.useCallback(A=>{R(A)&&A.preventDefault()},[R]),onItemLeave:m.useCallback(A=>{var B;R(A)||((B=E.current)==null||B.focus(),k(null))},[R]),onTriggerLeave:m.useCallback(A=>{R(A)&&A.preventDefault()},[R]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(A=>{U.current=A},[]),children:c.jsx(z,{...I,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:pe(s,A=>{var B;A.preventDefault(),(B=E.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Bw,{asChild:!0,...C,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:pe(l,A=>{x.isUsingKeyboardRef.current||A.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(wu,{role:"menu","aria-orientation":"vertical","data-state":cd(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...w,ref:j,style:{outline:"none",...w.style},onKeyDown:pe(w.onKeyDown,A=>{const W=A.target.closest("[data-radix-menu-content]")===A.currentTarget,_=A.ctrlKey||A.altKey||A.metaKey,V=A.key.length===1;W&&(A.key==="Tab"&&A.preventDefault(),!_&&V&&D(A.key));const ie=E.current;if(A.target!==ie||!Nb.includes(A.key))return;A.preventDefault();const oe=T().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);Bu.includes(A.key)&&oe.reverse(),Xb(oe)}),onBlur:pe(e.onBlur,A=>{A.currentTarget.contains(A.target)||(window.clearTimeout(O.current),F.current="")}),onPointerMove:pe(e.onPointerMove,Gr(A=>{const B=A.target,W=P.current!==A.clientX;if(A.currentTarget.contains(B)&&W){const _=A.clientX>P.current?"right":"left";K.current=_,P.current=A.clientX}}))})})})})})})});Ku.displayName=Xt;var zb="MenuGroup",Qi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});Qi.displayName=zb;var Hb="MenuLabel",qu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});qu.displayName=Hb;var us="MenuItem",Gu="menu.itemSelect",ds=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Kr(us,e.__scopeMenu),a=Ji(us,e.__scopeMenu),l=ze(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Gu,{bubbles:!0,cancelable:!0});f.addEventListener(Gu,p=>r==null?void 0:r(p),{once:!0}),Ic(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(Yu,{...o,ref:l,disabled:n,onClick:pe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:pe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:pe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Gi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ds.displayName=us;var Yu=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ji(us,n),a=Hu(n),l=m.useRef(null),u=ze(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(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(zw,{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:pe(e.onPointerMove,Gr(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:pe(e.onPointerLeave,Gr(v=>i.onItemLeave(v))),onFocus:pe(e.onFocus,()=>f(!0)),onBlur:pe(e.onBlur,()=>f(!1))})})})}),Ub="MenuCheckboxItem",Xu=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(td,{scope:e.__scopeMenu,checked:n,children:c.jsx(ds,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...o,ref:t,"data-state":ta(n),onSelect:pe(o.onSelect,()=>r==null?void 0:r(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Xu.displayName=Ub;var Ju="MenuRadioGroup",[Wb,Vb]=qn(Ju,{value:void 0,onValueChange:()=>{}}),Zu=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return c.jsx(Wb,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Qi,{...o,ref:t})})});Zu.displayName=Ju;var Qu="MenuRadioItem",ed=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Vb(Qu,e.__scopeMenu),s=n===o.value;return c.jsx(td,{scope:e.__scopeMenu,checked:s,children:c.jsx(ds,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ta(s),onSelect:pe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});ed.displayName=Qu;var ea="MenuItemIndicator",[td,Kb]=qn(ea,{checked:!1}),nd=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Kb(ea,n);return c.jsx(Yt,{present:r||fs(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":ta(s.checked)})})});nd.displayName=ea;var qb="MenuSeparator",rd=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});rd.displayName=qb;var Gb="MenuArrow",od=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(bu,{...o,...r,ref:t})});od.displayName=Gb;var Yb="MenuSub",[LT,sd]=qn(Yb),qr="MenuSubTrigger",id=m.forwardRef((e,t)=>{const n=Gn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=sd(qr,e.__scopeMenu),s=Ji(qr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Yi,{asChild:!0,...u,children:c.jsx(Yu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":cd(n.open),...e,ref:En(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:pe(e.onPointerMove,Gr(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:pe(e.onPointerLeave,Gr(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"],C=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:C,y:h.top},{x:C,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:pe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Ab[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});id.displayName=qr;var ad="MenuSubContent",ld=m.forwardRef((e,t)=>{const n=Wu(Xt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Gn(Xt,e.__scopeMenu),i=Kr(Xt,e.__scopeMenu),a=sd(ad,e.__scopeMenu),l=m.useRef(null),u=ze(t,l);return c.jsx(Vr.Provider,{scope:e.__scopeMenu,children:c.jsx(Yt,{present:r||s.open,children:c.jsx(Vr.Slot,{scope:e.__scopeMenu,children:c.jsx(Zi,{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:pe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:pe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:pe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=jb[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});ld.displayName=ad;function cd(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ta(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function Xb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Jb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Zb(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=Jb(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 Qb(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 ey(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Qb(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ty=Uu,ny=Yi,ry=Vu,oy=Ku,sy=Qi,iy=qu,ay=ds,ly=Xu,cy=Zu,uy=ed,dy=nd,fy=rd,hy=od,py=id,my=ld,hs="DropdownMenu",[gy,$T]=yn(hs,[zu]),Ot=zu(),[xy,ud]=gy(hs),dd=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),u=m.useRef(null),[d,f]=fr({prop:o,defaultProp:s??!1,onChange:i,caller:hs});return c.jsx(xy,{scope:t,triggerId:Pt(),triggerRef:u,contentId:Pt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(ty,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};dd.displayName=hs;var fd="DropdownMenuTrigger",hd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ud(fd,n),i=Ot(n);return c.jsx(ny,{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:En(t,s.triggerRef),onPointerDown:pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});hd.displayName=fd;var vy="DropdownMenuPortal",pd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return c.jsx(ry,{...r,...n})};pd.displayName=vy;var md="DropdownMenuContent",gd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ud(md,n),s=Ot(n),i=m.useRef(!1);return c.jsx(oy,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:pe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:pe(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)"}})});gd.displayName=md;var wy="DropdownMenuGroup",by=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(sy,{...o,...r,ref:t})});by.displayName=wy;var yy="DropdownMenuLabel",xd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(iy,{...o,...r,ref:t})});xd.displayName=yy;var Sy="DropdownMenuItem",vd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ay,{...o,...r,ref:t})});vd.displayName=Sy;var Cy="DropdownMenuCheckboxItem",wd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ly,{...o,...r,ref:t})});wd.displayName=Cy;var ky="DropdownMenuRadioGroup",Ty=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(cy,{...o,...r,ref:t})});Ty.displayName=ky;var Ey="DropdownMenuRadioItem",bd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(uy,{...o,...r,ref:t})});bd.displayName=Ey;var Iy="DropdownMenuItemIndicator",yd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(dy,{...o,...r,ref:t})});yd.displayName=Iy;var Ny="DropdownMenuSeparator",Sd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(fy,{...o,...r,ref:t})});Sd.displayName=Ny;var Ay="DropdownMenuArrow",jy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(hy,{...o,...r,ref:t})});jy.displayName=Ay;var _y="DropdownMenuSubTrigger",Cd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(py,{...o,...r,ref:t})});Cd.displayName=_y;var My="DropdownMenuSubContent",kd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(my,{...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)"}})});kd.displayName=My;var Ry=dd,Py=hd,Oy=pd,Td=gd,Ed=xd,Id=vd,Nd=wd,Ad=bd,jd=yd,_d=Sd,Md=Cd,Rd=kd;const na=Ry,ra=Py,Dy=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Md,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));Dy.displayName=Md.displayName;const Ly=m.forwardRef(({className:e,...t},n)=>c.jsx(Rd,{ref:n,className:ne("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}));Ly.displayName=Rd.displayName;const ps=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(Oy,{children:c.jsx(Td,{ref:r,sideOffset:t,className:ne("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})}));ps.displayName=Td.displayName;const Yn=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Id,{ref:r,className:ne("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}));Yn.displayName=Id.displayName;const $y=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Nd,{ref:o,className:ne("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(jd,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));$y.displayName=Nd.displayName;const Fy=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ad,{ref:r,className:ne("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(jd,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Fy.displayName=Ad.displayName;const By=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Ed,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));By.displayName=Ed.displayName;const zy=m.forwardRef(({className:e,...t},n)=>c.jsx(_d,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));zy.displayName=_d.displayName;function Hy(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const u=s[l];if(u.role==="user"&&u.id){i=u.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,u)=>u.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:u}=s[l],d=u.checkpointId;if(!d)continue;const f={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,f),i>1&&a.push({checkpointId:d,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}function Uy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="number"?n:null}function Wy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function Vy(e){const{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}=y.useMemo(()=>{const s=new Map,i=new Map,a=new Map;for(const d of e){const f=d.checkpointId??null;if(!f)continue;const h=Uy(d.metadata,"step"),p=Wy(d.metadata,"source"),v={id:f,step:h,source:p,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null};if(s.set(f,v),h!==null&&p){const w=`${h}:${p}`,g=i.get(w)??[];g.push(v),i.set(w,g)}}const{attemptMetaById:l,userMessageIdToAttempts:u}=Hy(e);for(const[d,f]of s.entries()){const h=l.get(d);h?a.set(d,{...f,attemptIndex:h.attemptIndex,attemptCount:h.attemptCount,isLatestAttempt:h.isLatestAttempt,baseUserMessageId:h.baseUserMessageId??null}):a.set(d,{...f,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpointMetaById:s,checkpointIndexByKey:i,attemptMetaById:a,userMessageIdToAttempts:u}},[e]);return{checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:r,userMessageIdToAttempts:o}}const ms=1e4;function Ky(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
79
80
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
80
81
|
|
|
81
82
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s)=>`${"#".repeat(parseInt(o))} ${s}
|
|
@@ -83,35 +84,34 @@ React keys must be passed directly to JSX without using spread:
|
|
|
83
84
|
`).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
|
|
84
85
|
`).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
|
|
85
86
|
`).replace(/<li>(.*?)<\/li>/gi,`- $1
|
|
86
|
-
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function Ay(e,t=fs){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 jy(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Ay(t),Ny(t)}const hs=0,jn=1,wr=2,Id=4;function Nd(e){return()=>e}function _y(e){e()}function Ad(e,t){return n=>e(t(n))}function jd(e,t){return()=>e(t)}function My(e,t){return n=>e(t,n)}function Qi(e){return e!==void 0}function Ry(...e){return()=>{e.map(_y)}}function yr(){}function ps(e,t){return t(e),e}function Py(e,t){return t(e)}function ct(...e){return e}function tt(e,t){return e(jn,t)}function Re(e,t){e(hs,t)}function ea(e){e(wr)}function vt(e){return e(Id)}function xe(e,t){return tt(e,My(t,hs))}function sn(e,t){const n=e(jn,r=>{n(),t(r)});return n}function _d(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Md(e,t){return e===t}function ut(e=Md){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>Ad(t,e)}function gn(e){return t=>()=>{t(e)}}function J(e,...t){const n=Oy(...t);return(r,o)=>{switch(r){case wr:ea(e);return;case jn:return tt(e,n(o))}}}function xn(e,t){return n=>r=>{n(t=e(t,r))}}function Xn(e){return t=>n=>{e>0?e--:t(n)}}function kn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);tt(s,c=>{const u=n;n=n|a,t[i]=c,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function Oy(...e){return t=>e.reduceRight(Py,t)}function Dy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case jn:return s?n===s?void 0:(r(),n=s,t=tt(e,s),t):(r(),yr);case wr:r(),n=null;return}}}function re(e){let t=e;const n=He();return(r,o)=>{switch(r){case hs:t=o;break;case jn:{o(t);break}case Id:return t}return n(r,o)}}function _t(e,t){return ps(re(t),n=>xe(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case hs:e.slice().forEach(r=>{r(n)});return;case wr:e.splice(0,e.length);return;case jn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Vt(e){return ps(He(),t=>xe(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ly(),singleton:n}}const Ly=()=>Symbol();function $y(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);tt(s,c=>{n[i]=c,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case wr:{ea(t);return}case jn:return r===o&&i(n),tt(t,i)}}}function ke(e,t=Md){return J(e,ut(t))}function ta(...e){return function(t,n){switch(t){case wr:return;case jn:return Ry(...e.map(r=>tt(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const Fy={0:"debug",3:"error",1:"log",2:"warn"},By=()=>typeof globalThis>"u"?window:globalThis,_n=Ye(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=By().VIRTUOSO_LOG_LEVEL)!=null?o:vt(e);r>=s&&console[Fy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Jn(e,t,n){return na(e,t,n).callbackRef}function na(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function zy(e,t,n,r,o,s,i,a,c){const u=y.useCallback(d=>{const f=Hy(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 b=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(b,0),viewportHeight:x}),s==null||s(a?Rd("column-gap",getComputedStyle(d).columnGap,o):Rd("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return na(u,n,c)}function Hy(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const c=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function Rd(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Pd(e,t,n){const r=y.useRef(null),o=y.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),d=u.width;let f,h;if(t){const 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}=na(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ye(()=>{const e=He(),t=He(),n=re(0),r=He(),o=re(0),s=He(),i=He(),a=re(0),c=re(0),u=re(0),d=re(0),f=He(),h=He(),p=re(!1),v=re(!1),b=re(!1);return xe(J(e,ue(({scrollTop:g})=>g)),t),xe(J(e,ue(({scrollHeight:g})=>g)),i),xe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:b,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Vr={lvl:0};function Od(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function st(e){return e===Vr}function qr(e,t){if(!st(e))return t===e.k?e.v:t<e.k?qr(e.l,t):qr(e.r,t)}function an(e,t,n="k"){if(st(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=an(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return an(e.l,t,n)}function qt(e,t,n){return st(e)?$d(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?Fd(yt(e,{l:qt(e.l,t,n)})):Fd(yt(e,{r:qt(e.r,t,n)}))}function Sr(){return Vr}function ms(e,t,n){if(st(e))return[];const r=an(e,t)[0];return Uy(oa(e,r,n))}function ra(e,t){if(st(e))return Vr;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=Ld(r);return gs(yt(e,{k:s,l:Dd(r),v:i}))}}else return t<n?gs(yt(e,{l:ra(r,t)})):gs(yt(e,{r:ra(o,t)}))}function Zn(e){return st(e)?[]:[...Zn(e.l),{k:e.k,v:e.v},...Zn(e.r)]}function oa(e,t,n){if(st(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(oa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(oa(s,t,n))),a}function gs(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(sa(t))return Bd(yt(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(sa(e))return ia(yt(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=sa(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ia(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return $d(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 Dd(e){return st(e.r)?e.l:gs(yt(e,{r:Dd(e.r)}))}function sa(e){return st(e)||e.lvl>e.r.lvl}function Ld(e){return st(e.r)?[e.k,e.v]:Ld(e.r)}function $d(e,t,n,r=Vr,o=Vr){return{k:e,l:r,lvl:n,r:o,v:t}}function Fd(e){return ia(Bd(e))}function Bd(e){const{l:t}=e;return!st(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function ia(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function Uy(e){return Od(e,({k:t,v:n})=>({index:t,value:n}))}function zd(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Kr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const aa=Ye(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function Hd(e,t,n){return e[xs(e,t,n)]}function xs(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 Wy(e,t,n,r){const o=xs(e,t,r),s=xs(e,n,r,o);return e.slice(o,s+1)}function Mn(e,t){return Math.round(e.getBoundingClientRect()[t])}function vs(e){return!st(e.groupOffsetTree)}function la({index:e},t){return t===e?0:t<e?-1:1}function Vy(){return{groupIndices:[],groupOffsetTree:Sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Sr()}}function qy(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=qt(e,0,s);continue}const a=ms(e,i-1,o+1);if(a.some(Qy(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=ra(e,f)):(u=h!==s,c=!0),d>o&&o>=f&&h!==s&&(e=qt(e,o+1,h));u&&(e=qt(e,i,s))}return[e,n]}function Ky(e){return typeof e.groupIndex<"u"}function Gy({offset:e},t){return t===e?0:t<e?-1:1}function Gr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Hd(t,e,la),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Ud(e,t){if(!vs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Wd(e,t,n){if(Ky(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Ud(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Yy(e,t,n,r=0){return r>0&&(t=Math.max(t,Hd(e,r,la).offset)),Od(Wy(e,t,n,Gy),Zy)}function Xy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&st(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,b)=>qt(qt(v,b,h),b+1,p),i)}else[i,a]=qy(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ca(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,Gr(p,f,o)),Sr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Jy(e){return Zn(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 Vd(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function ca(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=xs(o,t-1,la),a=o[c].offset;const u=an(n,t-1);s=u[0],i=u[1],o.length&&o[c].size===an(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:u,value:d}of ms(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 Zy(e){return{index:e.index,value:e}}function Qy(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 e0={offsetHeight:"height",offsetWidth:"width"},vn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=_t(r,0),s=He(),i=He(),a=re(0),c=re([]),u=re(void 0),d=re(void 0),f=re((S,k)=>Mn(S,e0[k])),h=re(void 0),p=re(0),v=Vy(),b=_t(J(n,De(c,e,p),xn(Xy,v),ut()),v),g=_t(J(c,ut(),xn((S,k)=>({current:k,prev:S.current}),{current:[],prev:[]}),ue(({prev:S})=>S)),[]);xe(J(c,Ie(S=>S.length>0),De(b,p),ue(([S,k,E])=>{const j=S.reduce((O,F,H)=>qt(O,F,Gr(F,k.offsetTree,E)||H),Sr());return{...k,groupIndices:S,groupOffsetTree:j}})),b),xe(J(r,De(b),Ie(([S,{lastIndex:k}])=>S<k),ue(([S,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:S}])),n),xe(u,d);const x=_t(J(u,ue(S=>S===void 0)),!0);xe(J(d,Ie(S=>S!==void 0&&st(vt(b).sizeTree)),ue(S=>[{endIndex:0,size:S,startIndex:0}])),n);const w=Vt(J(n,De(b),xn(({sizes:S},[k,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ue(S=>S.changed)));tt(J(a,xn((S,k)=>({diff:S.prev-k,prev:k}),{diff:0,prev:0}),ue(S=>S.diff)),S=>{const{groupIndices:k}=vt(b);if(S>0)Re(t,!0),Re(s,S+Vd(S,k));else if(S<0){const E=vt(g);E.length>0&&(S-=Vd(-S,E)),Re(i,S)}}),tt(J(a,De(e)),([S,k])=>{S<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const C=Vt(s);xe(J(s,De(b),ue(([S,k])=>{const E=k.groupIndices.length>0,j=[],O=k.lastSize;if(E){const F=qr(k.sizeTree,0);let H=0,U=0;for(;H<S;){const P=k.groupIndices[U],z=k.groupIndices.length===U+1?1/0:k.groupIndices[U+1]-P-1;j.push({endIndex:P,size:F,startIndex:P}),j.push({endIndex:P+1+z-1,size:O,startIndex:P+1}),U++,H+=z+1}const q=Zn(k.sizeTree);return H!==S&&q.shift(),q.reduce((P,{k:z,v:I})=>{let D=P.ranges;return P.prevSize!==0&&(D=[...P.ranges,{endIndex:z+S-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:z+S,prevSize:I,ranges:D}},{prevIndex:S,prevSize:0,ranges:j}).ranges}return Zn(k.sizeTree).reduce((F,{k:H,v:U})=>({prevIndex:H+S,prevSize:U,ranges:[...F.ranges,{endIndex:H+S-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const T=Vt(J(i,De(b,p),ue(([S,{offsetTree:k},E])=>{const j=-S;return Gr(j,k,E)})));return xe(J(i,De(b,p),ue(([S,k,E])=>{if(k.groupIndices.length>0){if(st(k.sizeTree))return k;let j=Sr();const O=vt(g);let F=0,H=0,U=0;for(;F<-S;){U=O[H];const q=O[H+1]-U-1;H++,F+=q+1}if(j=Zn(k.sizeTree).reduce((q,{k:P,v:z})=>qt(q,Math.max(0,P+S),z),j),F!==-S){const q=qr(k.sizeTree,U);j=qt(j,0,q);const P=an(k.sizeTree,-S+1)[1];j=qt(j,1,P)}return{...k,sizeTree:j,...ca(k.offsetTree,0,j,E)}}else{const j=Zn(k.sizeTree).reduce((O,{k:F,v:H})=>qt(O,Math.max(0,F+S),H),Sr());return{...k,sizeTree:j,...ca(k.offsetTree,0,j,E)}}})),b),{beforeUnshiftWith:C,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:c,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:b,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},ct(_n,aa),{singleton:!0});function t0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const qd=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Vt(J(s,ue(t0)));return xe(J(a,ue(c=>c.totalCount)),n),xe(J(a,ue(c=>c.groupIndices)),e),xe(J(wt(o,t,r),Ie(([c,u])=>vs(u)),ue(([c,u,d])=>an(u.groupOffsetTree,Math.max(c-d,0),"v")[0]),ut(),ue(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},ct(vn,Dt)),Rn=Ye(([{log:e}])=>{const t=re(!1),n=Vt(J(t,Ie(r=>r),ut()));return tt(t,r=>{r&&vt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ct(_n),{singleton:!0}),n0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Kd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!n0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Yr=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=He(),v=He(),b=re(0);let g=null,x=null,w=null;function C(){g&&(g(),g=null),w&&(w(),w=null),x&&(clearTimeout(x),x=null),Re(c,!1)}return xe(J(p,De(n,f,r,b,a,i,h),De(e,s,o),ue(([[T,S,k,E,j,O,F,H],U,q,P])=>{const z=Kd(T),{align:I,behavior:D,offset:R}=z,A=E-1,B=Wd(z,S,A);let W=Gr(B,S.offsetTree,U)+O;I==="end"?(W+=q+an(S.sizeTree,B)[1]-k+P,B===A&&(W+=F)):I==="center"?W+=(q+an(S.sizeTree,B)[1]-k+P)/2:W-=j,R&&(W+=R);const _=V=>{C(),V?(H("retrying to scroll to",{location:T},Bt.DEBUG),Re(p,T)):(Re(v,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(C(),D==="smooth"){let V=!1;w=tt(t,ie=>{V=V||ie}),g=sn(d,()=>{_(V)})}else g=sn(J(t,r0(150)),_);return x=setTimeout(()=>{C()},1200),Re(c,!0),H("scrolling from index to",{behavior:D,index:B,top:W},Bt.DEBUG),{behavior:D,top:W}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:b}},ct(vn,Dt,_n),{singleton:!0});function r0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ua(e,t){e==0?t():requestAnimationFrame(()=>{ua(e-1,t)})}function da(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Xr=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),c=re(0),u=re(!0);return xe(J(i,De(c),Ie(([d,f])=>!!f),gn(!1)),a),xe(J(i,De(c),Ie(([d,f])=>!!f),gn(!1)),u),tt(J(wt(t,i),De(a,n,e,u),Ie(([[,d],f,{sizeTree:h},p,v])=>d&&(!st(h)||Qi(p))&&!f&&!v),De(c)),([,d])=>{sn(o,()=>{Re(u,!0)}),ua(4,()=>{sn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},ct(vn,Dt,Yr,Rn),{singleton:!0});function Gd(e,t){return Math.abs(e-t)<1.01}const Jr="up",Zr="down",o0="none",s0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},i0=0,Qr=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),c=He(),u=He(),d=re(4),f=re(i0),h=_t(J(ta(J(ke(o),Xn(1),gn(!0)),J(ke(o),Xn(1),gn(!1),_d(100))),ut()),!1),p=_t(J(ta(J(n,gn(!0)),J(n,gn(!1),_d(200))),ut()),!1);xe(J(wt(ke(o),ke(f)),ue(([w,C])=>w<=C),ut()),a),xe(J(a,kn(50)),u);const v=Vt(J(wt(r,ke(s),ke(t),ke(e),ke(d)),xn((w,[{scrollHeight:C,scrollTop:T},S,k,E,j])=>{const O=T+S-C>-j,F={scrollHeight:C,scrollTop:T,viewportHeight:S};if(O){let U,q;return T>w.state.scrollTop?(U="SCROLLED_DOWN",q=w.state.scrollTop-T):(U="SIZE_DECREASED",q=w.state.scrollTop-T||w.scrollTopDelta),{atBottom:!0,atBottomBecause:U,scrollTopDelta:q,state:F}}let H;return F.scrollHeight>w.state.scrollHeight?H="SIZE_INCREASED":S<w.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":T<w.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:F}},s0),ut((w,C)=>w&&w.atBottom===C.atBottom))),b=_t(J(r,xn((w,{scrollHeight:C,scrollTop:T,viewportHeight:S})=>{if(Gd(w.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const k=C-(T+S)<1;return w.scrollTop!==T&&k?{changed:!0,jump:w.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(w=>w.changed),ue(w=>w.jump)),0);xe(J(v,ue(w=>w.atBottom)),i),xe(J(i,kn(50)),c);const g=re(Zr);xe(J(r,ue(({scrollTop:w})=>w),ut(),xn((w,C)=>vt(p)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?Jr:Zr,prevScrollTop:C},{direction:Zr,prevScrollTop:0}),ue(w=>w.direction)),g),xe(J(r,kn(50),gn(o0)),g);const x=re(0);return xe(J(h,Ie(w=>!w),gn(0)),x),xe(J(o,kn(100),De(h),Ie(([w,C])=>!!C),xn(([w,C],[T])=>[C,T],[0,0]),ue(([w,C])=>C-w)),x),{atBottomState:v,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:b,scrollDirection:g,scrollVelocity:x}},ct(Dt)),bs="top",ws="bottom",Yd="none";function Xd(e,t,n){return typeof e=="number"?n===Jr&&t===bs||n===Zr&&t===ws?e:0:n===Jr?t===bs?e.main:e.reverse:t===ws?e.main:e.reverse}function Jd(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const fa=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=re(0),a=re(0),c=re(0),u=_t(J(wt(ke(r),ke(o),ke(n),ke(s,Kr),ke(c),ke(i),ke(t),ke(e),ke(a)),ue(([d,f,h,[p,v],b,g,x,w,C])=>{const T=d-w,S=g+x,k=Math.max(h-T,0);let E=Yd;const j=Jd(C,bs),O=Jd(C,ws);return p-=w,p+=h+x,v+=h+x,v-=w,p>d+S-j&&(E=Jr),v<d-k+f+O&&(E=Zr),E!==Yd?[Math.max(T-h-Xd(b,bs,E)-j,0),T-k-x+f+Xd(b,ws,E)+O]:null}),Ie(d=>d!=null),ut(Kr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},ct(Dt),{singleton:!0});function a0(e,t,n){if(vs(t)){const r=Ud(e,t);return[{index:an(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 ha={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ys(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const b=e[e.length-1];d=b.offset+b.size}const f=n-i,h=a+f*c+(f-1)*r,p=u,v=h-d;return{bottom:d,firstItemIndex:s,items:Qd(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:Qd(t,o,s),topListHeight:t.reduce((b,g)=>g.size+b,0),totalCount:n}}function Zd(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=da(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return ys(u,[],a,o,n,r)}function Qd(e,t,n){if(e.length===0)return[];if(!vs(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=ms(t.groupOffsetTree,r,o);let a,c=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:u.index-(c+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Qn=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:v}])=>{const b=re([]),g=re(0),x=He();xe(s.topItemsIndexes,b);const w=_t(J(wt(p,v,ke(c,Kr),ke(o),ke(r),ke(u),d,ke(b),ke(t),ke(n),e),Ie(([k,E,,j,,,,,,,O])=>{const F=O&&O.length!==j;return k&&!E&&!F}),ue(([,,[k,E],j,O,F,H,U,q,P,z])=>{const I=O,{offsetTree:D,sizeTree:R}=I,A=vt(g);if(j===0)return{...ha,totalCount:j};if(k===0&&E===0)return A===0?{...ha,totalCount:j}:Zd(A,F,O,q,P,z||[]);if(st(R))return A>0?null:ys(a0(da(F,j),I,z),[],j,P,I,q);const B=[];if(U.length>0){const Q=U[0],oe=U[U.length-1];let Y=0;for(const L of ms(R,Q,oe)){const K=L.value,te=Math.max(L.start,Q),G=Math.min(L.end,oe);for(let X=te;X<=G;X++)B.push({data:z==null?void 0:z[X],index:X,offset:Y,size:K}),Y+=K}}if(!H)return ys([],B,j,P,I,q);const W=U.length>0?U[U.length-1]+1:0,_=Yy(D,k,E,W);if(_.length===0)return null;const V=j-1,ie=ps([],Q=>{for(const oe of _){const Y=oe.value;let L=Y.offset,K=oe.start;const te=Y.size;if(Y.offset<k){K+=Math.floor((k-Y.offset+P)/(te+P));const X=K-oe.start;L+=X*te+X*P}K<W&&(L+=(W-K)*te,K=W);const G=Math.min(oe.end,V);for(let X=K;X<=G&&!(L>=E);X++)Q.push({data:z==null?void 0:z[X],index:X,offset:L,size:te}),L+=te+P}});return ys(ie,B,j,P,I,q)}),Ie(k=>k!==null),ut()),ha);xe(J(e,Ie(Qi),ue(k=>k==null?void 0:k.length)),o),xe(J(w,ue(k=>k.topListHeight)),f),xe(f,a),xe(J(w,ue(k=>[k.top,k.bottom])),i),xe(J(w,ue(k=>k.items)),x);const C=Vt(J(w,Ie(({items:k})=>k.length>0),De(o,e),Ie(([{items:k},E])=>k[k.length-1].originalIndex===E-1),ue(([,k,E])=>[k-1,E]),ut(Kr),ue(([k])=>k))),T=Vt(J(w,kn(200),Ie(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),ut())),S=Vt(J(w,Ie(({items:k})=>k.length>0),ue(({items:k})=>{let E=0,j=k.length-1;for(;k[E].type==="group"&&E<j;)E++;for(;k[j].type==="group"&&j>E;)j--;return{endIndex:k[j].index,startIndex:k[E].index}}),ut(zd)));return{endReached:C,initialItemCount:g,itemsRendered:x,listState:w,rangeChanged:S,startReached:T,topItemsIndexes:b,...h}},ct(vn,qd,fa,Xr,Yr,Qr,Rn,aa),{singleton:!0}),ef=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=_t(J(wt(n,e,r,t,o),ue(([a,c,u,d,f])=>a+c+u+d+f.offsetBottom+f.bottom)),0);return xe(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(Dt,Qn),{singleton:!0}),l0=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=_t(J(wt(n,e,t),Ie(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),kn(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(Dt,ef),{singleton:!0}),tf=Ye(()=>({context:re(null)})),c0=({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,nf=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:u}])=>{const d=He();return xe(J(d,De(t,c,n,s,o,r,a),De(e),ue(([[f,h,p,v,b,g,x,w],C])=>{const{align:T,behavior:S,calculateViewLocation:k=c0,done:E,...j}=f,O=Wd(f,h,v-1),F=Gr(O,h.offsetTree,C)+b+g,H=F+an(h.sizeTree,O)[1],U=w+g,q=w+p-x,P=k({itemBottom:H,itemTop:F,locationParams:{align:T,behavior:S,...j},viewportBottom:q,viewportTop:U});return P?E&&sn(J(i,Ie(z=>!z),Xn(vt(i)?1:2)),E):E&&E(),P}),Ie(f=>f!==null)),u),{scrollIntoView:d}},ct(vn,Dt,Yr,Qn,_n),{singleton:!0});function rf(e){return e?e==="smooth"?"smooth":"auto":!1}const u0=(e,t)=>typeof e=="function"?rf(e(t)):t&&rf(e),d0=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const v=re(!1),b=He();let g=null;function x(S){Re(i,{align:"end",behavior:S,index:"LAST"})}tt(J(wt(J(ke(t),Xn(1)),c),De(ke(v),s,a,f),ue(([[S,k],E,j,O,F])=>{let H=k&&O,U="auto";return H&&(U=u0(E,j||F),H=H&&!!U),{followOutputBehavior:U,shouldFollow:H,totalCount:S}}),Ie(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:k})=>{g&&(g(),g=null),vt(n)?requestAnimationFrame(()=>{vt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(S)}):g=sn(e,()=>{vt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(S),g=null})});function w(S){const k=sn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(vt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),x("auto"))});setTimeout(k,100)}tt(J(wt(ke(v),t,u),Ie(([S,,k])=>S&&k),xn(({value:S},[,k])=>({refreshed:S===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:S})=>S),De(v,t)),([,S])=>{vt(a)&&w(S!==!1)}),tt(b,()=>{w(vt(v)!==!1)}),tt(wt(ke(v),o),([S,k])=>{S&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const C=re(null),T=He();return xe(ta(J(ke(r),ue(S=>{var k;return(k=S==null?void 0:S.length)!=null?k:0})),J(ke(t))),T),tt(J(wt(J(T,Xn(1)),c),De(ke(C),a,f,h),ue(([[S,k],E,j,O,F])=>k&&j&&(E==null?void 0:E({context:F,totalCount:S,scrollingInProgress:O}))),Ie(S=>!!S),kn(0)),S=>{g&&(g(),g=null),vt(n)?requestAnimationFrame(()=>{vt(d)("scrolling into view",{}),Re(p,S)}):g=sn(e,()=>{vt(d)("scrolling into view",{}),Re(p,S),g=null})}),{autoscrollToBottom:b,followOutput:v,scrollIntoViewOnChange:C}},ct(vn,Qr,Yr,Xr,Rn,_n,Dt,tf,nf)),f0=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(J(a,De(s),Ie(([,c])=>c!==0),De(o,r,t,n,e),ue(([[,c],u,d,f,h,p=[]])=>Zd(c,u,d,f,h,p))),i),{}),ct(vn,Xr,Qn,Rn),{singleton:!0}),h0=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return tt(J(e,De(r),Ie(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{sn(J(n,Xn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},ct(Rn,Dt,Qn),{singleton:!0}),of=Ye(([{scrollVelocity:e}])=>{const t=re(!1),n=He(),r=re(!1);return xe(J(e,De(r,t,n),Ie(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:c,exit:u}=s;if(i){if(u(o,a))return!1}else if(c(o,a))return!0;return i}),ut()),t),tt(J(wt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(Qr),{singleton:!0}),pa=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=re(!1),i=re(void 0);return xe(J(wt(n,r),ue(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),xe(J(t,De(r),ue(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(Dt)),p0=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=He(),d=re(void 0),f=re(null),h=re(null);return xe(a,f),xe(c,h),tt(J(u,De(t,r,i,f,h,n)),([p,v,b,g,x,w,C])=>{const T=Jy(v.sizeTree);g&&x!==null&&w!==null&&(b=x.scrollTop-w.offsetTop),b-=C,p({ranges:T,scrollTop:b})}),xe(J(d,Ie(Qi),ue(m0)),o),xe(J(s,De(d),Ie(([,p])=>p!==void 0),ut(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ct(vn,Dt,Xr,Rn,pa));function m0(e){return{align:"start",index:0,offset:e.scrollTop}}const g0=Ye(([{topItemsIndexes:e}])=>{const t=re(0);return xe(J(t,Ie(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(Qn));function sf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const x0=sf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),v0=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:v}])=>{const b=Vt(J(c,De(i),xn(([,x,w,C],[{bottom:T,items:S,offsetBottom:k,totalCount:E},j])=>{const O=T+k;let F=0;return w===E&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(F=O-C,F!==0&&(F+=j))),[F,S,E,O]},[0,[],0,0]),Ie(([x])=>x!==0),De(r,a,n,o,p,v),Ie(([,x,w,C,,,T])=>!T&&!C&&x!==0&&w===Jr),ue(([[x],,,,,w])=>(w("Upward scrolling compensation",{amount:x},Bt.DEBUG),x))));function g(x){x>0?(Re(t,{behavior:"auto",top:-x}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-x}))}return tt(J(b,De(e,s)),([x,w,C])=>{C&&x0()?Re(e,w-x):g(-x)}),tt(J(wt(_t(s,!1),e,v),Ie(([x,w,C])=>!x&&!C&&w!==0),ue(([x,w])=>w),kn(1)),g),xe(J(f,ue(x=>({top:-x}))),t),tt(J(u,De(h,d),ue(([x,{groupIndices:w,lastSize:C,sizeTree:T},S])=>{function k(E){return E*(C+S)}if(w.length===0)return k(x);{let E=0;const j=qr(T,0);let O=0,F=0;for(;O<x;){O++,E+=j;let H=w.length===F+1?1/0:w[F+1]-w[F]-1;O+H>x&&(E-=j,H=x-O+1),O+=H,E+=k(H),F++}return E}})),x=>{Re(e,x),requestAnimationFrame(()=>{Re(t,{top:x}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},ct(Dt,Qr,Qn,vn,_n,aa)),b0=Ye(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),ct(fa,f0,Rn,of,ef,h0,l0,pa,nf,_n,tf)),af=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v},b,g,x,{listState:w,topItemsIndexes:C,...T},{scrollToIndex:S},k,{topItemCount:E},{groupCounts:j},O])=>(xe(T.rangeChanged,O.scrollSeekRangeChanged),xe(J(O.windowViewportRect,ue(F=>F.visibleHeight)),b.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...x,groupIndices:s,itemSize:i,listState:w,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...T,...O,...b,sizes:c,...g}),ct(vn,Xr,Dt,p0,d0,Qn,Yr,v0,g0,qd,b0));function w0(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 Ss=typeof document<"u"?y.useLayoutEffect:y.useEffect;function lf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function c(g,x){g.propsReady&&Re(g.propsReady,!1);for(const w of r){const C=g[t.required[w]];Re(C,x[w])}for(const w of o)if(w in x){const C=g[t.optional[w]];Re(C,x[w])}g.propsReady&&Re(g.propsReady,!0)}function u(g){return s.reduce((x,w)=>(x[w]=C=>{const T=g[t.methods[w]];Re(T,C)},x),{})}function d(g){return i.reduce((x,w)=>(x[w]=Dy(g[t.events[w]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:w,...C}=g,[T]=y.useState(()=>ps($y(e),E=>{c(E,C)})),[S]=y.useState(jd(d,T));Ss(()=>{for(const E of i)E in C&&tt(S[E],C[E]);return()=>{Object.values(S).map(ea)}},[C,S,T]),Ss(()=>{c(T,C)}),y.useImperativeHandle(x,Nd(u(T)));const k=n;return l.jsx(a.Provider,{value:T,children:n?l.jsx(k,{...w0([...r,...o,...i],C),children:w}):w})}),h=g=>{const x=y.useContext(a);return y.useCallback(w=>{Re(x[g],w)},[x,g])},p=g=>{const x=y.useContext(a)[g],w=y.useCallback(C=>tt(x,C),[x]);return y.useSyncExternalStore(w,()=>vt(x),()=>vt(x))},v=g=>{const x=y.useContext(a)[g],[w,C]=y.useState(jd(vt,x));return Ss(()=>tt(x,T=>{T!==w&&C(Nd(T))}),[x,w]),w},b=y.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,x)=>{const w=y.useContext(a)[g];Ss(()=>tt(w,x),[x,w])},useEmitterValue:b,usePublisher:h}}const cf=y.createContext(void 0),uf=y.createContext(void 0),df=typeof document<"u"?y.useLayoutEffect:y.useEffect;function ma(e){return"self"in e}function y0(e){return"body"in e}function ff(e,t,n,r=yr,o,s){const i=y.useRef(null),a=y.useRef(null),c=y.useRef(null),u=y.useCallback(h=>{let p,v,b;const g=h.target;if(y0(g)||ma(g)){const w=ma(g)?g:g.defaultView;b=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else b=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(b,0),viewportHeight:v})};h.suppressFlushSync?x():Zs.flushSync(x),a.current!==null&&(b===a.current||b<=0||b===p-v)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const 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 b,g,x;ma(p)?(g=Math.max(Mn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),b=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],b=Mn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const w=g-b;if(h.top=Math.ceil(Math.max(Math.min(w,h.top),0)),Gd(b,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:b}),v&&t(!0);return}v?(a.current=h.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),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 ga="-webkit-sticky",hf="sticky",xa=sf(()=>{if(typeof document>"u")return hf;const e=document.createElement("div");return e.style.position=ga,e.style.position===ga?ga:hf});function va(e){return e}const S0=Ye(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(va),o=re("div"),s=re(yr),i=(a,c=null)=>_t(J(n,ue(u=>u[a]),ut()),c);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),C0=Ye(([e,t])=>({...e,...t}),ct(af,S0)),k0=({height:e})=>l.jsx("div",{style:{height:e}}),T0={overflowAnchor:"none",position:xa(),zIndex:1},pf={overflowAnchor:"none"},E0={...pf,display:"inline-block",height:"100%"},mf=y.memo(function({showTopList:e=!1}){const t=je("listState"),n=Jt("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=Jt("windowScrollContainerState"),i=Jt("scrollContainerState"),a=o||r?s:i,c=je("itemContent"),u=je("context"),d=je("groupContent"),f=je("trackItemSizes"),h=je("itemSize"),p=je("log"),v=Jt("gap"),b=je("horizontalDirection"),{callbackRef:g}=zy(n,h,f,e?yr:a,p,v,o,b,je("skipAnimationFrameInResizeObserver")),[x,w]=y.useState(0);ba("deviation",P=>{x!==P&&w(P)});const C=je("EmptyPlaceholder"),T=je("ScrollSeekPlaceholder")||k0,S=je("ListComponent"),k=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),O=je("isSeeking"),F=je("groupIndices").length>0,H=je("alignToBottom"),U=je("initialItemFinalLocationReached"),q=e?{}:{boxSizing:"border-box",...b?{display:"inline-block",height:"100%",marginLeft:x!==0?x:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?l.jsx(C,{...Mt(C,u)}):l.jsx(S,{...Mt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:q,children:(e?t.topItems:t.items).map(P=>{const z=P.originalIndex,I=j(z+t.firstItemIndex,P.data,u);return O?y.createElement(T,{...Mt(T,u),height:P.size,index:P.index,key:I,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(E,{...Mt(E,u),"data-index":z,"data-item-index":P.index,"data-known-size":P.size,key:I,style:T0},d(P.index,u)):y.createElement(k,{...Mt(k,u),...j0(k,P.data),"data-index":z,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:I,style:b?E0:pf},F?c(P.index,P.groupIndex,P.data,u):c(P.index,P.data,u))})})}),I0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},N0={outline:"none",overflowX:"auto",position:"relative"},Cs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),A0={position:xa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function j0(e,t){return{item:typeof e=="string"?void 0:t}}const _0=y.memo(function(){const e=je("HeaderComponent"),t=Jt("headerHeight"),n=je("HeaderFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null}),M0=y.memo(function(){const e=je("FooterComponent"),t=Jt("footerHeight"),n=je("HeaderFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null});function gf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=ff(a,u,c,d,void 0,f);return e("scrollTo",v),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?N0:I0,...o},tabIndex:0,...i,...Mt(c,s),children:r})})}function xf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),v=t("scrollerRef"),{scrollByCallback:b,scrollerRef:g,scrollToCallback:x}=ff(a,u,c,v,h);return df(()=>{var w;return g.current=h||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",b),l.jsx(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(c,s),children:r})})}const R0=({children:e})=>{const t=y.useContext(cf),n=Jt("viewportHeight"),r=Jt("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=y.useMemo(()=>Ad(n,c=>Mn(c,s?"width":"height")),[n,s]),a=Jn(i,!0,je("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:Cs(o),children:e})},P0=({children:e})=>{const t=y.useContext(cf),n=Jt("windowViewportRect"),r=Jt("fixedItemHeight"),o=je("customScrollParent"),s=Pd(n,o,je("skipAnimationFrameInResizeObserver")),i=je("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),l.jsx("div",{"data-viewport-type":"window",ref:s,style:Cs(i),children:e})},O0=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...A0,marginTop:`${n}px`},o=je("context");return l.jsx(t,{style:r,...Mt(t,o),children:e})},D0=y.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return l.jsxs(r||t?F0:$0,{...e,context:o,children:[n&&l.jsx(O0,{children:l.jsx(mf,{showTopList:!0})}),l.jsxs(r||t?P0:R0,{children:[l.jsx(_0,{}),l.jsx(mf,{}),l.jsx(M0,{})]})]})}),{Component:L0,useEmitter:ba,useEmitterValue:je,usePublisher:Jt}=lf(C0,{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"}},D0),$0=gf({useEmitter:ba,useEmitterValue:je,usePublisher:Jt}),F0=xf({useEmitter:ba,useEmitterValue:je,usePublisher:Jt}),B0=L0;ct(af,Ye(()=>{const e=re(u=>l.jsxs("td",{children:["Item $",u]})),t=re(null),n=re(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=re(null),o=re(null),s=re({}),i=re(va),a=re(yr),c=(u,d=null)=>_t(J(s,ue(f=>f[u]),ut()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),xa();const vf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},z0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:bf,floor:ks,max:eo,min:wa,round:wf}=Math;function yf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function H0(e){return{...z0,items:e}}function Ts(e,t){return e&&e.width===t.width&&e.height===t.height}function U0(e,t){return e&&e.column===t.column&&e.row===t.row}const W0=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:v,propsReady:b},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:T},S])=>{const k=re(0),E=re(0),j=re(vf),O=re({height:0,width:0}),F=re({height:0,width:0}),H=He(),U=He(),q=re(0),P=re(null),z=re({column:0,row:0}),I=He(),D=He(),R=re(!1),A=re(0),B=re(!0),W=re(!1),_=re(!1);tt(J(v,De(A),Ie(([L,K])=>!!K)),()=>{Re(B,!1)}),tt(J(wt(v,B,F,O,A,W),Ie(([L,K,te,G,,X])=>L&&!K&&te.height!==0&&G.height!==0&&!X)),([,,,,L])=>{Re(W,!0),ua(1,()=>{Re(H,L)}),sn(J(u),()=>{Re(t,[0,0]),Re(B,!0)})}),xe(J(D,Ie(L=>L!=null&&L.scrollTop>0),gn(0)),E),tt(J(v,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Re(O,L.viewport),Re(F,L.item),Re(z,L.gap),L.scrollTop>0&&(Re(R,!0),sn(J(u,Xn(1)),K=>{Re(R,!1)}),Re(c,{top:L.scrollTop})))}),xe(J(O,ue(({height:L})=>L)),f),xe(J(wt(ke(O,Ts),ke(F,Ts),ke(z,(L,K)=>L&&L.column===K.column&&L.row===K.row),ke(u)),ue(([L,K,te,G])=>({gap:te,item:K,scrollTop:G,viewport:L}))),I),xe(J(wt(ke(k),r,ke(z,U0),ke(F,Ts),ke(O,Ts),ke(P),ke(E),ke(R),ke(B),ke(A)),Ie(([,,,,,,,L])=>!L),ue(([L,[K,te],G,X,he,fe,Z,,le,be])=>{const{column:_e,row:Ne}=G,{height:$e,width:Xe}=X,{width:nt}=he;if(Z===0&&(L===0||nt===0))return vf;if(Xe===0){const ht=da(be,L),Tt=ht+Math.max(Z-1,0);return H0(yf(ht,Tt,fe))}const Ve=Sf(nt,Xe,_e);let Ke,ot;le?K===0&&te===0&&Z>0?(Ke=0,ot=Z-1):(Ke=Ve*ks((K+Ne)/($e+Ne)),ot=Ve*bf((te+Ne)/($e+Ne))-1,ot=wa(L-1,eo(ot,Ve-1)),Ke=wa(ot,eo(0,Ke))):(Ke=0,ot=-1);const kt=yf(Ke,ot,fe),{bottom:lt,top:Te}=Cf(he,G,X,kt),Oe=bf(L/Ve),at=Oe*$e+(Oe-1)*Ne-lt;return{bottom:lt,itemHeight:$e,items:kt,itemWidth:Xe,offsetBottom:at,offsetTop:Te,top:Te}})),j),xe(J(P,Ie(L=>L!==null),ue(L=>L.length)),k),xe(J(wt(O,F,j,z),Ie(([L,K,{items:te}])=>te.length>0&&K.height!==0&&L.height!==0),ue(([L,K,{items:te},G])=>{const{bottom:X,top:he}=Cf(L,G,K,te);return[he,X]}),ut(Kr)),t);const V=re(!1);xe(J(u,De(V),ue(([L,K])=>K||L!==0)),V);const ie=Vt(J(wt(j,k),Ie(([{items:L}])=>L.length>0),De(V),Ie(([[L,K],te])=>{const G=L.items[L.items.length-1].index===K-1;return(te||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===K)&&G}),ue(([[,L]])=>L-1),ut())),Q=Vt(J(ke(j),Ie(({items:L})=>L.length>0&&L[0].index===0),gn(0),ut())),oe=Vt(J(ke(j),De(R),Ie(([{items:L},K])=>L.length>0&&!K),ue(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(zd),kn(0)));xe(oe,p.scrollSeekRangeChanged),xe(J(H,De(O,F,k,z),ue(([L,K,te,G,X])=>{const he=Kd(L),{align:fe,behavior:Z,offset:le}=he;let be=he.index;be==="LAST"&&(be=G-1),be=eo(0,be,wa(G-1,be));let _e=ya(K,X,te,be);return fe==="end"?_e=wf(_e-K.height+te.height):fe==="center"&&(_e=wf(_e-K.height/2+te.height/2)),le&&(_e+=le),{behavior:Z,top:_e}})),c);const Y=_t(J(j,ue(L=>L.offsetBottom+L.bottom)),0);return xe(J(T,ue(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:g,data:P,deviation:q,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:F,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:c,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:O,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:T,...p,gridState:j,horizontalDirection:_,initialTopMostItemIndex:A,totalListHeight:Y,...h,endReached:ie,propsReady:b,rangeChanged:oe,startReached:Q,stateChanged:I,stateRestoreInProgress:R,...S}},ct(fa,Dt,Qr,of,Rn,pa,_n));function Sf(e,t,n){return eo(1,ks((e+n)/(ks(t)+n)))}function Cf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ya(e,t,n,r[0].index);return{bottom:ya(e,t,n,r[r.length-1].index)+o,top:s}}function ya(e,t,n,r){const o=Sf(e.width,n.width,t.column),s=ks(r/o),i=s*n.height+eo(0,s-1)*t.row;return i>0?i+t.row:i}const V0=Ye(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(va),i=re("div"),a=re(yr),c=(f,h=null)=>_t(J(t,ue(p=>p[f]),ut()),h),u=re(!1),d=re(!1);return xe(ke(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),q0=Ye(([e,t])=>({...e,...t}),ct(W0,V0)),K0=y.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=Zt("scrollHeight"),a=ft("ItemComponent"),c=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=Zt("itemDimensions"),h=Zt("gap"),p=ft("log"),v=ft("stateRestoreInProgress"),b=Zt("reportReadyState"),g=Jn(y.useMemo(()=>x=>{const w=x.parentElement.parentElement.scrollHeight;i(w);const C=x.firstChild;if(C){const{height:T,width:S}=C.getBoundingClientRect();f({height:T,width:S})}h({column:Tf("column-gap",getComputedStyle(x).columnGap,p),row:Tf("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return df(()=>{e.itemHeight>0&&e.itemWidth>0&&b(!0)},[e]),v?null:l.jsx(c,{className:t,ref:g,...Mt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const w=o(x.index,x.data,d);return s?l.jsx(u,{...Mt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},w):y.createElement(a,{...Mt(a,d),className:n,"data-index":x.index,key:w},r(x.index,x.data,d))})})}),G0=y.memo(function(){const e=ft("HeaderComponent"),t=Zt("headerHeight"),n=ft("headerFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null}),Y0=y.memo(function(){const e=ft("FooterComponent"),t=Zt("footerHeight"),n=ft("headerFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null}),X0=({children:e})=>{const t=y.useContext(uf),n=Zt("itemDimensions"),r=Zt("viewportDimensions"),o=Jn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),l.jsx("div",{ref:o,style:Cs(!1),children:e})},J0=({children:e})=>{const t=y.useContext(uf),n=Zt("windowViewportRect"),r=Zt("itemDimensions"),o=ft("customScrollParent"),s=Pd(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),l.jsx("div",{ref:s,style:Cs(!1),children:e})},Z0=y.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?eS:Q0,o=n||t?J0:X0,s=ft("context");return l.jsx(r,{...e,...Mt(r,s),children:l.jsxs(o,{children:[l.jsx(G0,{}),l.jsx(K0,{}),l.jsx(Y0,{})]})})}),{useEmitter:kf,useEmitterValue:ft,usePublisher:Zt}=lf(q0,{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"}},Z0),Q0=gf({useEmitter:kf,useEmitterValue:ft,usePublisher:Zt}),eS=xf({useEmitter:kf,useEmitterValue:ft,usePublisher:Zt});function Tf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const tS=xo.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 Ef({className:e,variant:t,...n}){return l.jsx("div",{className:ne(tS({variant:t}),e),...n})}function Sa(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 If(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function to(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(to).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(If(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=to(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function no(e){if(typeof e=="string")return e;if(If(e))return"";try{const t=to(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function nS(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function rS(e){const t=no(e);return typeof e=="string"&&nS(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Es(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Sa(t);if(n!==null)return Es(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Es(e.content):e}function oS(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Nf(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Is(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function sS(e){const t=r=>{try{const o=to(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
87
|
-
`)):t(e)}function iS(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Af(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function aS(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function lS(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function cS({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=aS(n),i=o?`data:${s};base64,${e}`:t,a=lS(r),c=a.length?a.join(" / "):void 0,u=c?`${c} artifact`:"artifact image";return{src:i,alt:u,label:c}}function uS(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return cS({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}async function jf(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function _f(e,t){return await(await jf(`/files/${e}/view`,t)).text()}async function dS(e,t){const n=await jf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/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 fS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}var Ns="Dialog",[Mf,_T]=yn(Ns),[hS,ln]=Mf(Ns),Rf=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),c=m.useRef(null),[u,d]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Ns});return l.jsx(hS,{scope:t,triggerRef:a,contentRef:c,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Rf.displayName=Ns;var Pf="DialogTrigger",Of=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Pf,n),s=ze(t,o.triggerRef);return l.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ta(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Of.displayName=Pf;var Ca="DialogPortal",[pS,Df]=Mf(Ca,{forceMount:void 0}),Lf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=ln(Ca,t);return l.jsx(pS,{scope:t,forceMount:n,children:m.Children.map(r,i=>l.jsx(Yt,{present:n||s.open,children:l.jsx(Xo,{asChild:!0,container:o,children:i})}))})};Lf.displayName=Ca;var As="DialogOverlay",$f=m.forwardRef((e,t)=>{const n=Df(As,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(As,e.__scopeDialog);return s.modal?l.jsx(Yt,{present:r||s.open,children:l.jsx(gS,{...o,ref:t})}):null});$f.displayName=As;var mS=zn.createSlot("DialogOverlay.RemoveScroll"),gS=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(As,n);return l.jsx(ss,{as:mS,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(ye.div,{"data-state":Ta(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),er="DialogContent",Ff=m.forwardRef((e,t)=>{const n=Df(er,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(er,e.__scopeDialog);return l.jsx(Yt,{present:r||s.open,children:s.modal?l.jsx(xS,{...o,ref:t}):l.jsx(vS,{...o,ref:t})})});Ff.displayName=er;var xS=m.forwardRef((e,t)=>{const n=ln(er,e.__scopeDialog),r=m.useRef(null),o=ze(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return $i(s)},[]),l.jsx(Bf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),vS=m.forwardRef((e,t)=>{const n=ln(er,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return l.jsx(Bf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Bf=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=ln(er,n),c=m.useRef(null),u=ze(t,c);return bi(),l.jsxs(l.Fragment,{children:[l.jsx($o,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(Lo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ta(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(bS,{titleId:a.titleId}),l.jsx(yS,{contentRef:c,descriptionId:a.descriptionId})]})]})}),ka="DialogTitle",zf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(ka,n);return l.jsx(ye.h2,{id:o.titleId,...r,ref:t})});zf.displayName=ka;var Hf="DialogDescription",Uf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Hf,n);return l.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Uf.displayName=Hf;var Wf="DialogClose",Vf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Wf,n);return l.jsx(ye.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Vf.displayName=Wf;function Ta(e){return e?"open":"closed"}var qf="DialogTitleWarning",[MT,Kf]=wx(qf,{contentName:er,titleName:ka,docsSlug:"dialog"}),bS=({titleId:e})=>{const t=Kf(qf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
87
|
+
`).trim():n.replace(/</g,"<").replace(/>/g,">").trim()}function qy(e,t=ms){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 Gy(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),qy(t),Ky(t)}const gs=0,jn=1,yr=2,Pd=4;function Od(e){return()=>e}function Yy(e){e()}function Dd(e,t){return n=>e(t(n))}function Ld(e,t){return()=>e(t)}function Xy(e,t){return n=>e(t,n)}function oa(e){return e!==void 0}function Jy(...e){return()=>{e.map(Yy)}}function Sr(){}function xs(e,t){return t(e),e}function Zy(e,t){return t(e)}function ct(...e){return e}function tt(e,t){return e(jn,t)}function Re(e,t){e(gs,t)}function sa(e){e(yr)}function vt(e){return e(Pd)}function xe(e,t){return tt(e,Xy(t,gs))}function sn(e,t){const n=e(jn,r=>{n(),t(r)});return n}function $d(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Fd(e,t){return e===t}function ut(e=Fd){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ie(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>Dd(t,e)}function gn(e){return t=>()=>{t(e)}}function J(e,...t){const n=Qy(...t);return(r,o)=>{switch(r){case yr:sa(e);return;case jn:return tt(e,n(o))}}}function xn(e,t){return n=>r=>{n(t=e(t,r))}}function Xn(e){return t=>n=>{e>0?e--:t(n)}}function kn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);tt(s,l=>{const 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 Qy(...e){return t=>e.reduceRight(Zy,t)}function e0(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case jn:return s?n===s?void 0:(r(),n=s,t=tt(e,s),t):(r(),Sr);case yr:r(),n=null;return}}}function re(e){let t=e;const n=He();return(r,o)=>{switch(r){case gs:t=o;break;case jn:{o(t);break}case Pd:return t}return n(r,o)}}function _t(e,t){return xs(re(t),n=>xe(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case gs:e.slice().forEach(r=>{r(n)});return;case yr:e.splice(0,e.length);return;case jn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Vt(e){return xs(He(),t=>xe(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:t0(),singleton:n}}const t0=()=>Symbol();function n0(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function bt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);tt(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case yr:{sa(t);return}case jn:return r===o&&i(n),tt(t,i)}}}function ke(e,t=Fd){return J(e,ut(t))}function ia(...e){return function(t,n){switch(t){case yr:return;case jn:return Jy(...e.map(r=>tt(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const r0={0:"debug",3:"error",1:"log",2:"warn"},o0=()=>typeof globalThis>"u"?window:globalThis,_n=Ye(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=o0().VIRTUOSO_LOG_LEVEL)!=null?o:vt(e);r>=s&&console[r0[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Jn(e,t,n){return aa(e,t,n).callbackRef}function aa(e,t,n){const r=y.useRef(null);let o=i=>{};const s=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function s0(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=i0(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?Bd("column-gap",getComputedStyle(d).columnGap,o):Bd("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return aa(u,n,l)}function i0(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Bd(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function zd(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),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}=aa(o,!0,n),a=y.useCallback(()=>{o(i.current)},[o,i]);return y.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ye(()=>{const e=He(),t=He(),n=re(0),r=He(),o=re(0),s=He(),i=He(),a=re(0),l=re(0),u=re(0),d=re(0),f=He(),h=He(),p=re(!1),v=re(!1),w=re(!1);return xe(J(e,ue(({scrollTop:g})=>g)),t),xe(J(e,ue(({scrollHeight:g})=>g)),i),xe(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}),Yr={lvl:0};function Hd(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 st(e){return e===Yr}function Xr(e,t){if(!st(e))return t===e.k?e.v:t<e.k?Xr(e.l,t):Xr(e.r,t)}function an(e,t,n="k"){if(st(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=an(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return an(e.l,t,n)}function Kt(e,t,n){return st(e)?Vd(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?Kd(yt(e,{l:Kt(e.l,t,n)})):Kd(yt(e,{r:Kt(e.r,t,n)}))}function Cr(){return Yr}function vs(e,t,n){if(st(e))return[];const r=an(e,t)[0];return a0(ca(e,r,n))}function la(e,t){if(st(e))return Yr;const{k:n,l:r,r:o}=e;if(t===n){if(st(r))return o;if(st(o))return r;{const[s,i]=Wd(r);return ws(yt(e,{k:s,l:Ud(r),v:i}))}}else return t<n?ws(yt(e,{l:la(r,t)})):ws(yt(e,{r:la(o,t)}))}function Zn(e){return st(e)?[]:[...Zn(e.l),{k:e.k,v:e.v},...Zn(e.r)]}function ca(e,t,n){if(st(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ca(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ca(s,t,n))),a}function ws(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(ua(t))return qd(yt(e,{lvl:n-1}));if(!st(t)&&!st(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ua(e))return da(yt(e,{lvl:n-1}));if(!st(r)&&!st(r.l)){const o=r.l,s=ua(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:da(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return Vd(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 Ud(e){return st(e.r)?e.l:ws(yt(e,{r:Ud(e.r)}))}function ua(e){return st(e)||e.lvl>e.r.lvl}function Wd(e){return st(e.r)?[e.k,e.v]:Wd(e.r)}function Vd(e,t,n,r=Yr,o=Yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Kd(e){return da(qd(e))}function qd(e){const{l:t}=e;return!st(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function da(e){const{lvl:t,r:n}=e;return!st(n)&&!st(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function a0(e){return Hd(e,({k:t,v:n})=>({index:t,value:n}))}function Gd(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Jr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const fa=Ye(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function Yd(e,t,n){return e[bs(e,t,n)]}function bs(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 l0(e,t,n,r){const o=bs(e,t,r),s=bs(e,n,r,o);return e.slice(o,s+1)}function Mn(e,t){return Math.round(e.getBoundingClientRect()[t])}function ys(e){return!st(e.groupOffsetTree)}function ha({index:e},t){return t===e?0:t<e?-1:1}function c0(){return{groupIndices:[],groupOffsetTree:Cr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Cr()}}function u0(e,t){let n=st(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),st(e)){e=Kt(e,0,s);continue}const a=vs(e,i-1,o+1);if(a.some(x0(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=la(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=Kt(e,o+1,h));u&&(e=Kt(e,i,s))}return[e,n]}function d0(e){return typeof e.groupIndex<"u"}function f0({offset:e},t){return t===e?0:t<e?-1:1}function Zr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Yd(t,e,ha),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Xd(e,t){if(!ys(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Jd(e,t,n){if(d0(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Xd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function h0(e,t,n,r=0){return r>0&&(t=Math.max(t,Yd(e,r,ha).offset)),Hd(l0(e,t,n,f0),g0)}function p0(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&st(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((v,w)=>Kt(Kt(v,w,h),w+1,p),i)}else[i,a]=u0(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=pa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>Kt(h,p,Zr(p,f,o)),Cr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function m0(e){return Zn(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 Zd(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 pa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=bs(o,t-1,ha),a=o[l].offset;const u=an(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===an(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of vs(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 g0(e){return{index:e.index,value:e}}function x0(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 v0={offsetHeight:"height",offsetWidth:"width"},vn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=_t(r,0),s=He(),i=He(),a=re(0),l=re([]),u=re(void 0),d=re(void 0),f=re((S,k)=>Mn(S,v0[k])),h=re(void 0),p=re(0),v=c0(),w=_t(J(n,De(l,e,p),xn(p0,v),ut()),v),g=_t(J(l,ut(),xn((S,k)=>({current:k,prev:S.current}),{current:[],prev:[]}),ue(({prev:S})=>S)),[]);xe(J(l,Ie(S=>S.length>0),De(w,p),ue(([S,k,E])=>{const j=S.reduce((O,F,H)=>Kt(O,F,Zr(F,k.offsetTree,E)||H),Cr());return{...k,groupIndices:S,groupOffsetTree:j}})),w),xe(J(r,De(w),Ie(([S,{lastIndex:k}])=>S<k),ue(([S,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:S}])),n),xe(u,d);const x=_t(J(u,ue(S=>S===void 0)),!0);xe(J(d,Ie(S=>S!==void 0&&st(vt(w).sizeTree)),ue(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Vt(J(n,De(w),xn(({sizes:S},[k,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ue(S=>S.changed)));tt(J(a,xn((S,k)=>({diff:S.prev-k,prev:k}),{diff:0,prev:0}),ue(S=>S.diff)),S=>{const{groupIndices:k}=vt(w);if(S>0)Re(t,!0),Re(s,S+Zd(S,k));else if(S<0){const E=vt(g);E.length>0&&(S-=Zd(-S,E)),Re(i,S)}}),tt(J(a,De(e)),([S,k])=>{S<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const C=Vt(s);xe(J(s,De(w),ue(([S,k])=>{const E=k.groupIndices.length>0,j=[],O=k.lastSize;if(E){const F=Xr(k.sizeTree,0);let H=0,U=0;for(;H<S;){const P=k.groupIndices[U],z=k.groupIndices.length===U+1?1/0:k.groupIndices[U+1]-P-1;j.push({endIndex:P,size:F,startIndex:P}),j.push({endIndex:P+1+z-1,size:O,startIndex:P+1}),U++,H+=z+1}const K=Zn(k.sizeTree);return H!==S&&K.shift(),K.reduce((P,{k:z,v:I})=>{let D=P.ranges;return P.prevSize!==0&&(D=[...P.ranges,{endIndex:z+S-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:z+S,prevSize:I,ranges:D}},{prevIndex:S,prevSize:0,ranges:j}).ranges}return Zn(k.sizeTree).reduce((F,{k:H,v:U})=>({prevIndex:H+S,prevSize:U,ranges:[...F.ranges,{endIndex:H+S-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const T=Vt(J(i,De(w,p),ue(([S,{offsetTree:k},E])=>{const j=-S;return Zr(j,k,E)})));return xe(J(i,De(w,p),ue(([S,k,E])=>{if(k.groupIndices.length>0){if(st(k.sizeTree))return k;let j=Cr();const O=vt(g);let F=0,H=0,U=0;for(;F<-S;){U=O[H];const K=O[H+1]-U-1;H++,F+=K+1}if(j=Zn(k.sizeTree).reduce((K,{k:P,v:z})=>Kt(K,Math.max(0,P+S),z),j),F!==-S){const K=Xr(k.sizeTree,U);j=Kt(j,0,K);const P=an(k.sizeTree,-S+1)[1];j=Kt(j,1,P)}return{...k,sizeTree:j,...pa(k.offsetTree,0,j,E)}}else{const j=Zn(k.sizeTree).reduce((O,{k:F,v:H})=>Kt(O,Math.max(0,F+S),H),Cr());return{...k,sizeTree:j,...pa(k.offsetTree,0,j,E)}}})),w),{beforeUnshiftWith:C,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:w,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},ct(_n,fa),{singleton:!0});function w0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Qd=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Vt(J(s,ue(w0)));return xe(J(a,ue(l=>l.totalCount)),n),xe(J(a,ue(l=>l.groupIndices)),e),xe(J(bt(o,t,r),Ie(([l,u])=>ys(u)),ue(([l,u,d])=>an(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ut(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ct(vn,Dt)),Rn=Ye(([{log:e}])=>{const t=re(!1),n=Vt(J(t,Ie(r=>r),ut()));return tt(t,r=>{r&&vt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ct(_n),{singleton:!0}),b0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ef(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!b0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Qr=Ye(([{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=He(),v=He(),w=re(0);let g=null,x=null,b=null;function C(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),Re(l,!1)}return xe(J(p,De(n,f,r,w,a,i,h),De(e,s,o),ue(([[T,S,k,E,j,O,F,H],U,K,P])=>{const z=ef(T),{align:I,behavior:D,offset:R}=z,A=E-1,B=Jd(z,S,A);let W=Zr(B,S.offsetTree,U)+O;I==="end"?(W+=K+an(S.sizeTree,B)[1]-k+P,B===A&&(W+=F)):I==="center"?W+=(K+an(S.sizeTree,B)[1]-k+P)/2:W-=j,R&&(W+=R);const _=V=>{C(),V?(H("retrying to scroll to",{location:T},Bt.DEBUG),Re(p,T)):(Re(v,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(C(),D==="smooth"){let V=!1;b=tt(t,ie=>{V=V||ie}),g=sn(d,()=>{_(V)})}else g=sn(J(t,y0(150)),_);return x=setTimeout(()=>{C()},1200),Re(l,!0),H("scrolling from index to",{behavior:D,index:B,top:W},Bt.DEBUG),{behavior:D,top:W}})),u),{scrollTargetReached:v,scrollToIndex:p,topListHeight:w}},ct(vn,Dt,_n),{singleton:!0});function y0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ma(e,t){e==0?t():requestAnimationFrame(()=>{ma(e-1,t)})}function ga(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const eo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),l=re(0),u=re(!0);return xe(J(i,De(l),Ie(([d,f])=>!!f),gn(!1)),a),xe(J(i,De(l),Ie(([d,f])=>!!f),gn(!1)),u),tt(J(bt(t,i),De(a,n,e,u),Ie(([[,d],f,{sizeTree:h},p,v])=>d&&(!st(h)||oa(p))&&!f&&!v),De(l)),([,d])=>{sn(o,()=>{Re(u,!0)}),ma(4,()=>{sn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(vn,Dt,Qr,Rn),{singleton:!0});function tf(e,t){return Math.abs(e-t)<1.01}const to="up",no="down",S0="none",C0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},k0=0,ro=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),l=He(),u=He(),d=re(4),f=re(k0),h=_t(J(ia(J(ke(o),Xn(1),gn(!0)),J(ke(o),Xn(1),gn(!1),$d(100))),ut()),!1),p=_t(J(ia(J(n,gn(!0)),J(n,gn(!1),$d(200))),ut()),!1);xe(J(bt(ke(o),ke(f)),ue(([b,C])=>b<=C),ut()),a),xe(J(a,kn(50)),u);const v=Vt(J(bt(r,ke(s),ke(t),ke(e),ke(d)),xn((b,[{scrollHeight:C,scrollTop:T},S,k,E,j])=>{const O=T+S-C>-j,F={scrollHeight:C,scrollTop:T,viewportHeight:S};if(O){let U,K;return T>b.state.scrollTop?(U="SCROLLED_DOWN",K=b.state.scrollTop-T):(U="SIZE_DECREASED",K=b.state.scrollTop-T||b.scrollTopDelta),{atBottom:!0,atBottomBecause:U,scrollTopDelta:K,state:F}}let H;return F.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":S<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":T<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:F}},C0),ut((b,C)=>b&&b.atBottom===C.atBottom))),w=_t(J(r,xn((b,{scrollHeight:C,scrollTop:T,viewportHeight:S})=>{if(tf(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:T};{const k=C-(T+S)<1;return b.scrollTop!==T&&k?{changed:!0,jump:b.scrollTop-T,scrollHeight:C,scrollTop:T}:{changed:!0,jump:0,scrollHeight:C,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(b=>b.changed),ue(b=>b.jump)),0);xe(J(v,ue(b=>b.atBottom)),i),xe(J(i,kn(50)),l);const g=re(no);xe(J(r,ue(({scrollTop:b})=>b),ut(),xn((b,C)=>vt(p)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?to:no,prevScrollTop:C},{direction:no,prevScrollTop:0}),ue(b=>b.direction)),g),xe(J(r,kn(50),gn(S0)),g);const x=re(0);return xe(J(h,Ie(b=>!b),gn(0)),x),xe(J(o,kn(100),De(h),Ie(([b,C])=>!!C),xn(([b,C],[T])=>[C,T],[0,0]),ue(([b,C])=>C-b)),x),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:w,scrollDirection:g,scrollVelocity:x}},ct(Dt)),Ss="top",Cs="bottom",nf="none";function rf(e,t,n){return typeof e=="number"?n===to&&t===Ss||n===no&&t===Cs?e:0:n===to?t===Ss?e.main:e.reverse:t===Cs?e.main:e.reverse}function of(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const xa=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=re(0),a=re(0),l=re(0),u=_t(J(bt(ke(r),ke(o),ke(n),ke(s,Jr),ke(l),ke(i),ke(t),ke(e),ke(a)),ue(([d,f,h,[p,v],w,g,x,b,C])=>{const T=d-b,S=g+x,k=Math.max(h-T,0);let E=nf;const j=of(C,Ss),O=of(C,Cs);return p-=b,p+=h+x,v+=h+x,v-=b,p>d+S-j&&(E=to),v<d-k+f+O&&(E=no),E!==nf?[Math.max(T-h-rf(w,Ss,E)-j,0),T-k-x+f+rf(w,Cs,E)+O]:null}),Ie(d=>d!=null),ut(Jr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},ct(Dt),{singleton:!0});function T0(e,t,n){if(ys(t)){const r=Xd(e,t);return[{index:an(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 va={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ks(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:af(e,o,s),offsetBottom:v,offsetTop:u,top:p,topItems:af(t,o,s),topListHeight:t.reduce((w,g)=>g.size+w,0),totalCount:n}}function sf(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=ga(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return ks(u,[],a,o,n,r)}function af(e,t,n){if(e.length===0)return[];if(!ys(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=vs(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 Qn=Ye(([{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=re([]),g=re(0),x=He();xe(s.topItemsIndexes,w);const b=_t(J(bt(p,v,ke(l,Jr),ke(o),ke(r),ke(u),d,ke(w),ke(t),ke(n),e),Ie(([k,E,,j,,,,,,,O])=>{const F=O&&O.length!==j;return k&&!E&&!F}),ue(([,,[k,E],j,O,F,H,U,K,P,z])=>{const I=O,{offsetTree:D,sizeTree:R}=I,A=vt(g);if(j===0)return{...va,totalCount:j};if(k===0&&E===0)return A===0?{...va,totalCount:j}:sf(A,F,O,K,P,z||[]);if(st(R))return A>0?null:ks(T0(ga(F,j),I,z),[],j,P,I,K);const B=[];if(U.length>0){const Q=U[0],oe=U[U.length-1];let Y=0;for(const L of vs(R,Q,oe)){const q=L.value,te=Math.max(L.start,Q),G=Math.min(L.end,oe);for(let X=te;X<=G;X++)B.push({data:z==null?void 0:z[X],index:X,offset:Y,size:q}),Y+=q}}if(!H)return ks([],B,j,P,I,K);const W=U.length>0?U[U.length-1]+1:0,_=h0(D,k,E,W);if(_.length===0)return null;const V=j-1,ie=xs([],Q=>{for(const oe of _){const Y=oe.value;let L=Y.offset,q=oe.start;const te=Y.size;if(Y.offset<k){q+=Math.floor((k-Y.offset+P)/(te+P));const X=q-oe.start;L+=X*te+X*P}q<W&&(L+=(W-q)*te,q=W);const G=Math.min(oe.end,V);for(let X=q;X<=G&&!(L>=E);X++)Q.push({data:z==null?void 0:z[X],index:X,offset:L,size:te}),L+=te+P}});return ks(ie,B,j,P,I,K)}),Ie(k=>k!==null),ut()),va);xe(J(e,Ie(oa),ue(k=>k==null?void 0:k.length)),o),xe(J(b,ue(k=>k.topListHeight)),f),xe(f,a),xe(J(b,ue(k=>[k.top,k.bottom])),i),xe(J(b,ue(k=>k.items)),x);const C=Vt(J(b,Ie(({items:k})=>k.length>0),De(o,e),Ie(([{items:k},E])=>k[k.length-1].originalIndex===E-1),ue(([,k,E])=>[k-1,E]),ut(Jr),ue(([k])=>k))),T=Vt(J(b,kn(200),Ie(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),ut())),S=Vt(J(b,Ie(({items:k})=>k.length>0),ue(({items:k})=>{let E=0,j=k.length-1;for(;k[E].type==="group"&&E<j;)E++;for(;k[j].type==="group"&&j>E;)j--;return{endIndex:k[j].index,startIndex:k[E].index}}),ut(Gd)));return{endReached:C,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:S,startReached:T,topItemsIndexes:w,...h}},ct(vn,Qd,xa,eo,Qr,ro,Rn,fa),{singleton:!0}),lf=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=_t(J(bt(n,e,r,t,o),ue(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return xe(ke(i),s),{totalListHeight:i,totalListHeightChanged:s}},ct(Dt,Qn),{singleton:!0}),E0=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=_t(J(bt(n,e,t),Ie(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),kn(0),ut()),0);return{alignToBottom:n,paddingTopAddition:r}},ct(Dt,lf),{singleton:!0}),cf=Ye(()=>({context:re(null)})),I0=({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,uf=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=He();return xe(J(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,h,p,v,w,g,x,b],C])=>{const{align:T,behavior:S,calculateViewLocation:k=I0,done:E,...j}=f,O=Jd(f,h,v-1),F=Zr(O,h.offsetTree,C)+w+g,H=F+an(h.sizeTree,O)[1],U=b+g,K=b+p-x,P=k({itemBottom:H,itemTop:F,locationParams:{align:T,behavior:S,...j},viewportBottom:K,viewportTop:U});return P?E&&sn(J(i,Ie(z=>!z),Xn(vt(i)?1:2)),E):E&&E(),P}),Ie(f=>f!==null)),u),{scrollIntoView:d}},ct(vn,Dt,Qr,Qn,_n),{singleton:!0});function df(e){return e?e==="smooth"?"smooth":"auto":!1}const N0=(e,t)=>typeof e=="function"?df(e(t)):t&&df(e),A0=Ye(([{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=re(!1),w=He();let g=null;function x(S){Re(i,{align:"end",behavior:S,index:"LAST"})}tt(J(bt(J(ke(t),Xn(1)),l),De(ke(v),s,a,f),ue(([[S,k],E,j,O,F])=>{let H=k&&O,U="auto";return H&&(U=N0(E,j||F),H=H&&!!U),{followOutputBehavior:U,shouldFollow:H,totalCount:S}}),Ie(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:k})=>{g&&(g(),g=null),vt(n)?requestAnimationFrame(()=>{vt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(S)}):g=sn(e,()=>{vt(d)("following output to ",{totalCount:k},Bt.DEBUG),x(S),g=null})});function b(S){const k=sn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(vt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),x("auto"))});setTimeout(k,100)}tt(J(bt(ke(v),t,u),Ie(([S,,k])=>S&&k),xn(({value:S},[,k])=>({refreshed:S===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:S})=>S),De(v,t)),([,S])=>{vt(a)&&b(S!==!1)}),tt(w,()=>{b(vt(v)!==!1)}),tt(bt(ke(v),o),([S,k])=>{S&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const C=re(null),T=He();return xe(ia(J(ke(r),ue(S=>{var k;return(k=S==null?void 0:S.length)!=null?k:0})),J(ke(t))),T),tt(J(bt(J(T,Xn(1)),l),De(ke(C),a,f,h),ue(([[S,k],E,j,O,F])=>k&&j&&(E==null?void 0:E({context:F,totalCount:S,scrollingInProgress:O}))),Ie(S=>!!S),kn(0)),S=>{g&&(g(),g=null),vt(n)?requestAnimationFrame(()=>{vt(d)("scrolling into view",{}),Re(p,S)}):g=sn(e,()=>{vt(d)("scrolling into view",{}),Re(p,S),g=null})}),{autoscrollToBottom:w,followOutput:v,scrollIntoViewOnChange:C}},ct(vn,ro,Qr,eo,Rn,_n,Dt,cf,uf)),j0=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(J(a,De(s),Ie(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],u,d,f,h,p=[]])=>sf(l,u,d,f,h,p))),i),{}),ct(vn,eo,Qn,Rn),{singleton:!0}),_0=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return tt(J(e,De(r),Ie(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{sn(J(n,Xn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},ct(Rn,Dt,Qn),{singleton:!0}),ff=Ye(([{scrollVelocity:e}])=>{const t=re(!1),n=He(),r=re(!1);return xe(J(e,De(r,t,n),Ie(([o,s])=>!!s),ue(([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}),ut()),t),tt(J(bt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ct(ro),{singleton:!0}),wa=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=re(!1),i=re(void 0);return xe(J(bt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),xe(J(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ct(Dt)),M0=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=He(),d=re(void 0),f=re(null),h=re(null);return xe(a,f),xe(l,h),tt(J(u,De(t,r,i,f,h,n)),([p,v,w,g,x,b,C])=>{const T=m0(v.sizeTree);g&&x!==null&&b!==null&&(w=x.scrollTop-b.offsetTop),w-=C,p({ranges:T,scrollTop:w})}),xe(J(d,Ie(oa),ue(R0)),o),xe(J(s,De(d),Ie(([,p])=>p!==void 0),ut(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ct(vn,Dt,eo,Rn,wa));function R0(e){return{align:"start",index:0,offset:e.scrollTop}}const P0=Ye(([{topItemsIndexes:e}])=>{const t=re(0);return xe(J(t,Ie(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(Qn));function hf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const O0=hf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),D0=Ye(([{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=Vt(J(l,De(i),xn(([,x,b,C],[{bottom:T,items:S,offsetBottom:k,totalCount:E},j])=>{const O=T+k;let F=0;return b===E&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(F=O-C,F!==0&&(F+=j))),[F,S,E,O]},[0,[],0,0]),Ie(([x])=>x!==0),De(r,a,n,o,p,v),Ie(([,x,b,C,,,T])=>!T&&!C&&x!==0&&b===to),ue(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Bt.DEBUG),x))));function g(x){x>0?(Re(t,{behavior:"auto",top:-x}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-x}))}return tt(J(w,De(e,s)),([x,b,C])=>{C&&O0()?Re(e,b-x):g(-x)}),tt(J(bt(_t(s,!1),e,v),Ie(([x,b,C])=>!x&&!C&&b!==0),ue(([x,b])=>b),kn(1)),g),xe(J(f,ue(x=>({top:-x}))),t),tt(J(u,De(h,d),ue(([x,{groupIndices:b,lastSize:C,sizeTree:T},S])=>{function k(E){return E*(C+S)}if(b.length===0)return k(x);{let E=0;const j=Xr(T,0);let O=0,F=0;for(;O<x;){O++,E+=j;let H=b.length===F+1?1/0:b[F+1]-b[F]-1;O+H>x&&(E-=j,H=x-O+1),O+=H,E+=k(H),F++}return E}})),x=>{Re(e,x),requestAnimationFrame(()=>{Re(t,{top:x}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},ct(Dt,ro,Qn,vn,_n,fa)),L0=Ye(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),ct(xa,j0,Rn,ff,lf,_0,E0,wa,uf,_n,cf)),pf=Ye(([{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:C,...T},{scrollToIndex:S},k,{topItemCount:E},{groupCounts:j},O])=>(xe(T.rangeChanged,O.scrollSeekRangeChanged),xe(J(O.windowViewportRect,ue(F=>F.visibleHeight)),w.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:f,...T,...O,...w,sizes:l,...g}),ct(vn,eo,Dt,M0,A0,Qn,Qr,D0,P0,Qd,L0));function $0(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 Ts=typeof document<"u"?y.useLayoutEffect:y.useEffect;function mf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,x){g.propsReady&&Re(g.propsReady,!1);for(const b of r){const C=g[t.required[b]];Re(C,x[b])}for(const b of o)if(b in x){const C=g[t.optional[b]];Re(C,x[b])}g.propsReady&&Re(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=C=>{const T=g[t.methods[b]];Re(T,C)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=e0(g[t.events[b]]),x),{})}const f=y.forwardRef((g,x)=>{const{children:b,...C}=g,[T]=y.useState(()=>xs(n0(e),E=>{l(E,C)})),[S]=y.useState(Ld(d,T));Ts(()=>{for(const E of i)E in C&&tt(S[E],C[E]);return()=>{Object.values(S).map(sa)}},[C,S,T]),Ts(()=>{l(T,C)}),y.useImperativeHandle(x,Od(u(T)));const k=n;return c.jsx(a.Provider,{value:T,children:n?c.jsx(k,{...$0([...r,...o,...i],C),children:b}):b})}),h=g=>{const x=y.useContext(a);return y.useCallback(b=>{Re(x[g],b)},[x,g])},p=g=>{const x=y.useContext(a)[g],b=y.useCallback(C=>tt(x,C),[x]);return y.useSyncExternalStore(b,()=>vt(x),()=>vt(x))},v=g=>{const x=y.useContext(a)[g],[b,C]=y.useState(Ld(vt,x));return Ts(()=>tt(x,T=>{T!==b&&C(Od(T))}),[x,b]),b},w=y.version.startsWith("18")?p:v;return{Component:f,useEmitter:(g,x)=>{const b=y.useContext(a)[g];Ts(()=>tt(b,x),[x,b])},useEmitterValue:w,usePublisher:h}}const gf=y.createContext(void 0),xf=y.createContext(void 0),vf=typeof document<"u"?y.useLayoutEffect:y.useEffect;function ba(e){return"self"in e}function F0(e){return"body"in e}function wf(e,t,n,r=Sr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,v,w;const g=h.target;if(F0(g)||ba(g)){const b=ba(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():Qs.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]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=h.behavior==="smooth";let w,g,x;ba(p)?(g=Math.max(Mn(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=Mn(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)),tf(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 ya="-webkit-sticky",bf="sticky",Sa=hf(()=>{if(typeof document>"u")return bf;const e=document.createElement("div");return e.style.position=ya,e.style.position===ya?ya:bf});function Ca(e){return e}const B0=Ye(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Ca),o=re("div"),s=re(Sr),i=(a,l=null)=>_t(J(n,ue(u=>u[a]),ut()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),z0=Ye(([e,t])=>({...e,...t}),ct(pf,B0)),H0=({height:e})=>c.jsx("div",{style:{height:e}}),U0={overflowAnchor:"none",position:Sa(),zIndex:1},yf={overflowAnchor:"none"},W0={...yf,display:"inline-block",height:"100%"},Sf=y.memo(function({showTopList:e=!1}){const t=je("listState"),n=Jt("sizeRanges"),r=je("useWindowScroll"),o=je("customScrollParent"),s=Jt("windowScrollContainerState"),i=Jt("scrollContainerState"),a=o||r?s:i,l=je("itemContent"),u=je("context"),d=je("groupContent"),f=je("trackItemSizes"),h=je("itemSize"),p=je("log"),v=Jt("gap"),w=je("horizontalDirection"),{callbackRef:g}=s0(n,h,f,e?Sr:a,p,v,o,w,je("skipAnimationFrameInResizeObserver")),[x,b]=y.useState(0);ka("deviation",P=>{x!==P&&b(P)});const C=je("EmptyPlaceholder"),T=je("ScrollSeekPlaceholder")||H0,S=je("ListComponent"),k=je("ItemComponent"),E=je("GroupComponent"),j=je("computeItemKey"),O=je("isSeeking"),F=je("groupIndices").length>0,H=je("alignToBottom"),U=je("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:x!==0?x:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?c.jsx(C,{...Mt(C,u)}):c.jsx(S,{...Mt(S,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:K,children:(e?t.topItems:t.items).map(P=>{const z=P.originalIndex,I=j(z+t.firstItemIndex,P.data,u);return O?y.createElement(T,{...Mt(T,u),height:P.size,index:P.index,key:I,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(E,{...Mt(E,u),"data-index":z,"data-item-index":P.index,"data-known-size":P.size,key:I,style:U0},d(P.index,u)):y.createElement(k,{...Mt(k,u),...G0(k,P.data),"data-index":z,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:I,style:w?W0:yf},F?l(P.index,P.groupIndex,P.data,u):l(P.index,P.data,u))})})}),V0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},K0={outline:"none",overflowX:"auto",position:"relative"},Es=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),q0={position:Sa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function G0(e,t){return{item:typeof e=="string"?void 0:t}}const Y0=y.memo(function(){const e=je("HeaderComponent"),t=Jt("headerHeight"),n=je("HeaderFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),X0=y.memo(function(){const e=je("FooterComponent"),t=Jt("footerHeight"),n=je("HeaderFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,je("skipAnimationFrameInResizeObserver")),o=je("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null});function Cf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:v}=wf(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?K0:V0,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function kf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),v=t("scrollerRef"),{scrollByCallback:w,scrollerRef:g,scrollToCallback:x}=wf(a,u,l,v,h);return vf(()=>{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,...Mt(l,s),children:r})})}const J0=({children:e})=>{const t=y.useContext(gf),n=Jt("viewportHeight"),r=Jt("fixedItemHeight"),o=je("alignToBottom"),s=je("horizontalDirection"),i=y.useMemo(()=>Dd(n,l=>Mn(l,s?"width":"height")),[n,s]),a=Jn(i,!0,je("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Es(o),children:e})},Z0=({children:e})=>{const t=y.useContext(gf),n=Jt("windowViewportRect"),r=Jt("fixedItemHeight"),o=je("customScrollParent"),s=zd(n,o,je("skipAnimationFrameInResizeObserver")),i=je("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Es(i),children:e})},Q0=({children:e})=>{const t=je("TopItemListComponent")||"div",n=je("headerHeight"),r={...q0,marginTop:`${n}px`},o=je("context");return c.jsx(t,{style:r,...Mt(t,o),children:e})},eS=y.memo(function(e){const t=je("useWindowScroll"),n=je("topItemsIndexes").length>0,r=je("customScrollParent"),o=je("context");return c.jsxs(r||t?rS:nS,{...e,context:o,children:[n&&c.jsx(Q0,{children:c.jsx(Sf,{showTopList:!0})}),c.jsxs(r||t?Z0:J0,{children:[c.jsx(Y0,{}),c.jsx(Sf,{}),c.jsx(X0,{})]})]})}),{Component:tS,useEmitter:ka,useEmitterValue:je,usePublisher:Jt}=mf(z0,{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"}},eS),nS=Cf({useEmitter:ka,useEmitterValue:je,usePublisher:Jt}),rS=kf({useEmitter:ka,useEmitterValue:je,usePublisher:Jt}),oS=tS;ct(pf,Ye(()=>{const e=re(u=>c.jsxs("td",{children:["Item $",u]})),t=re(null),n=re(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=re(null),o=re(null),s=re({}),i=re(Ca),a=re(Sr),l=(u,d=null)=>_t(J(s,ue(f=>f[u]),ut()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Sa();const Tf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sS={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ef,floor:Is,max:oo,min:Ta,round:If}=Math;function Nf(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function iS(e){return{...sS,items:e}}function Ns(e,t){return e&&e.width===t.width&&e.height===t.height}function aS(e,t){return e&&e.column===t.column&&e.row===t.row}const lS=Ye(([{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:C,windowViewportRect:T},S])=>{const k=re(0),E=re(0),j=re(Tf),O=re({height:0,width:0}),F=re({height:0,width:0}),H=He(),U=He(),K=re(0),P=re(null),z=re({column:0,row:0}),I=He(),D=He(),R=re(!1),A=re(0),B=re(!0),W=re(!1),_=re(!1);tt(J(v,De(A),Ie(([L,q])=>!!q)),()=>{Re(B,!1)}),tt(J(bt(v,B,F,O,A,W),Ie(([L,q,te,G,,X])=>L&&!q&&te.height!==0&&G.height!==0&&!X)),([,,,,L])=>{Re(W,!0),ma(1,()=>{Re(H,L)}),sn(J(u),()=>{Re(t,[0,0]),Re(B,!0)})}),xe(J(D,Ie(L=>L!=null&&L.scrollTop>0),gn(0)),E),tt(J(v,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Re(O,L.viewport),Re(F,L.item),Re(z,L.gap),L.scrollTop>0&&(Re(R,!0),sn(J(u,Xn(1)),q=>{Re(R,!1)}),Re(l,{top:L.scrollTop})))}),xe(J(O,ue(({height:L})=>L)),f),xe(J(bt(ke(O,Ns),ke(F,Ns),ke(z,(L,q)=>L&&L.column===q.column&&L.row===q.row),ke(u)),ue(([L,q,te,G])=>({gap:te,item:q,scrollTop:G,viewport:L}))),I),xe(J(bt(ke(k),r,ke(z,aS),ke(F,Ns),ke(O,Ns),ke(P),ke(E),ke(R),ke(B),ke(A)),Ie(([,,,,,,,L])=>!L),ue(([L,[q,te],G,X,he,fe,Z,,le,we])=>{const{column:_e,row:Ne}=G,{height:$e,width:Xe}=X,{width:nt}=he;if(Z===0&&(L===0||nt===0))return Tf;if(Xe===0){const ht=ga(we,L),Tt=ht+Math.max(Z-1,0);return iS(Nf(ht,Tt,fe))}const Ve=Af(nt,Xe,_e);let qe,ot;le?q===0&&te===0&&Z>0?(qe=0,ot=Z-1):(qe=Ve*Is((q+Ne)/($e+Ne)),ot=Ve*Ef((te+Ne)/($e+Ne))-1,ot=Ta(L-1,oo(ot,Ve-1)),qe=Ta(ot,oo(0,qe))):(qe=0,ot=-1);const kt=Nf(qe,ot,fe),{bottom:lt,top:Te}=jf(he,G,X,kt),Oe=Ef(L/Ve),at=Oe*$e+(Oe-1)*Ne-lt;return{bottom:lt,itemHeight:$e,items:kt,itemWidth:Xe,offsetBottom:at,offsetTop:Te,top:Te}})),j),xe(J(P,Ie(L=>L!==null),ue(L=>L.length)),k),xe(J(bt(O,F,j,z),Ie(([L,q,{items:te}])=>te.length>0&&q.height!==0&&L.height!==0),ue(([L,q,{items:te},G])=>{const{bottom:X,top:he}=jf(L,G,q,te);return[he,X]}),ut(Jr)),t);const V=re(!1);xe(J(u,De(V),ue(([L,q])=>q||L!==0)),V);const ie=Vt(J(bt(j,k),Ie(([{items:L}])=>L.length>0),De(V),Ie(([[L,q],te])=>{const G=L.items[L.items.length-1].index===q-1;return(te||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===q)&&G}),ue(([[,L]])=>L-1),ut())),Q=Vt(J(ke(j),Ie(({items:L})=>L.length>0&&L[0].index===0),gn(0),ut())),oe=Vt(J(ke(j),De(R),Ie(([{items:L},q])=>L.length>0&&!q),ue(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(Gd),kn(0)));xe(oe,p.scrollSeekRangeChanged),xe(J(H,De(O,F,k,z),ue(([L,q,te,G,X])=>{const he=ef(L),{align:fe,behavior:Z,offset:le}=he;let we=he.index;we==="LAST"&&(we=G-1),we=oo(0,we,Ta(G-1,we));let _e=Ea(q,X,te,we);return fe==="end"?_e=If(_e-q.height+te.height):fe==="center"&&(_e=If(_e-q.height/2+te.height/2)),le&&(_e+=le),{behavior:Z,top:_e}})),l);const Y=_t(J(j,ue(L=>L.offsetBottom+L.bottom)),0);return xe(J(T,ue(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:g,data:P,deviation:K,footerHeight:o,gap:z,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:F,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:x,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:T,...p,gridState:j,horizontalDirection:_,initialTopMostItemIndex:A,totalListHeight:Y,...h,endReached:ie,propsReady:w,rangeChanged:oe,startReached:Q,stateChanged:I,stateRestoreInProgress:R,...S}},ct(xa,Dt,ro,ff,Rn,wa,_n));function Af(e,t,n){return oo(1,Is((e+n)/(Is(t)+n)))}function jf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ea(e,t,n,r[0].index);return{bottom:Ea(e,t,n,r[r.length-1].index)+o,top:s}}function Ea(e,t,n,r){const o=Af(e.width,n.width,t.column),s=Is(r/o),i=s*n.height+oo(0,s-1)*t.row;return i>0?i+t.row:i}const cS=Ye(()=>{const e=re(f=>`Item ${f}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Ca),i=re("div"),a=re(Sr),l=(f,h=null)=>_t(J(t,ue(p=>p[f]),ut()),h),u=re(!1),d=re(!1);return xe(ke(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")}}),uS=Ye(([e,t])=>({...e,...t}),ct(lS,cS)),dS=y.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=Zt("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=Zt("itemDimensions"),h=Zt("gap"),p=ft("log"),v=ft("stateRestoreInProgress"),w=Zt("reportReadyState"),g=Jn(y.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const C=x.firstChild;if(C){const{height:T,width:S}=C.getBoundingClientRect();f({height:T,width:S})}h({column:Mf("column-gap",getComputedStyle(x).columnGap,p),row:Mf("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return vf(()=>{e.itemHeight>0&&e.itemWidth>0&&w(!0)},[e]),v?null:c.jsx(l,{className:t,ref:g,...Mt(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,{...Mt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):y.createElement(a,{...Mt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),fS=y.memo(function(){const e=ft("HeaderComponent"),t=Zt("headerHeight"),n=ft("headerFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),hS=y.memo(function(){const e=ft("FooterComponent"),t=Zt("footerHeight"),n=ft("headerFooterTag"),r=Jn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,!1),o=ft("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),pS=({children:e})=>{const t=y.useContext(xf),n=Zt("itemDimensions"),r=Zt("viewportDimensions"),o=Jn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Es(!1),children:e})},mS=({children:e})=>{const t=y.useContext(xf),n=Zt("windowViewportRect"),r=Zt("itemDimensions"),o=ft("customScrollParent"),s=zd(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Es(!1),children:e})},gS=y.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?vS:xS,o=n||t?mS:pS,s=ft("context");return c.jsx(r,{...e,...Mt(r,s),children:c.jsxs(o,{children:[c.jsx(fS,{}),c.jsx(dS,{}),c.jsx(hS,{})]})})}),{useEmitter:_f,useEmitterValue:ft,usePublisher:Zt}=mf(uS,{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"}},gS),xS=Cf({useEmitter:_f,useEmitterValue:ft,usePublisher:Zt}),vS=kf({useEmitter:_f,useEmitterValue:ft,usePublisher:Zt});function Mf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const wS=wo.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 Rf({className:e,variant:t,...n}){return c.jsx("div",{className:ne(wS({variant:t}),e),...n})}async function Pf(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Of(e,t){return await(await Pf(`/files/${e}/view`,t)).text()}async function bS(e,t){const n=await Pf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/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 yS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}var As="Dialog",[Df,BT]=yn(As),[SS,ln]=Df(As),Lf=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]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:As});return c.jsx(SS,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Lf.displayName=As;var $f="DialogTrigger",Ff=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln($f,n),s=ze(t,o.triggerRef);return c.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Aa(o.open),...r,ref:s,onClick:pe(e.onClick,o.onOpenToggle)})});Ff.displayName=$f;var Ia="DialogPortal",[CS,Bf]=Df(Ia,{forceMount:void 0}),zf=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=ln(Ia,t);return c.jsx(CS,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Yt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:i})}))})};zf.displayName=Ia;var js="DialogOverlay",Hf=m.forwardRef((e,t)=>{const n=Bf(js,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(js,e.__scopeDialog);return s.modal?c.jsx(Yt,{present:r||s.open,children:c.jsx(TS,{...o,ref:t})}):null});Hf.displayName=js;var kS=zn.createSlot("DialogOverlay.RemoveScroll"),TS=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(js,n);return c.jsx(ls,{as:kS,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ye.div,{"data-state":Aa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),er="DialogContent",Uf=m.forwardRef((e,t)=>{const n=Bf(er,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(er,e.__scopeDialog);return c.jsx(Yt,{present:r||s.open,children:s.modal?c.jsx(ES,{...o,ref:t}):c.jsx(IS,{...o,ref:t})})});Uf.displayName=er;var ES=m.forwardRef((e,t)=>{const n=ln(er,e.__scopeDialog),r=m.useRef(null),o=ze(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Ui(s)},[]),c.jsx(Wf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:pe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:pe(e.onFocusOutside,s=>s.preventDefault())})}),IS=m.forwardRef((e,t)=>{const n=ln(er,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Wf,{...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()}})}),Wf=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=ln(er,n),l=m.useRef(null),u=ze(t,l);return ki(),c.jsxs(c.Fragment,{children:[c.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Aa(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(NS,{titleId:a.titleId}),c.jsx(jS,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Na="DialogTitle",Vf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Na,n);return c.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Vf.displayName=Na;var Kf="DialogDescription",qf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Kf,n);return c.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});qf.displayName=Kf;var Gf="DialogClose",Yf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Gf,n);return c.jsx(ye.button,{type:"button",...r,ref:t,onClick:pe(e.onClick,()=>o.onOpenChange(!1))})});Yf.displayName=Gf;function Aa(e){return e?"open":"closed"}var Xf="DialogTitleWarning",[zT,Jf]=$x(Xf,{contentName:er,titleName:Na,docsSlug:"dialog"}),NS=({titleId:e})=>{const t=Jf(Xf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
88
88
|
|
|
89
89
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
90
90
|
|
|
91
|
-
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},wS="DialogDescriptionWarning",yS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Kf(wS).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},Ea=Rf,SS=Of,Ia=Lf,ro=$f,oo=Ff,tr=zf,js=Uf,Gf=Vf;const Yf=Ea,CS=Ia,Xf=m.forwardRef(({className:e,...t},n)=>l.jsx(ro,{ref:n,className:ne("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}));Xf.displayName=ro.displayName;const Na=m.forwardRef(({className:e,children:t,...n},r)=>{const o=m.useMemo(()=>{let s=!1;function i(a){m.Children.forEach(a,c=>{if(s||!m.isValidElement(c))return;const u=c.type;if(u===tr||(u==null?void 0:u.displayName)===tr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return l.jsxs(CS,{children:[l.jsx(Xf,{}),l.jsxs(oo,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&l.jsx(tr,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Gf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(ae.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Na.displayName=oo.displayName;const Aa=({className:e,...t})=>l.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Aa.displayName="DialogHeader";const ja=m.forwardRef(({className:e,...t},n)=>l.jsx(tr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));ja.displayName=tr.displayName;const kS=m.forwardRef(({className:e,...t},n)=>l.jsx(js,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));kS.displayName=js.displayName;const TS=1,ES=1e6;let _a=0;function IS(){return _a=(_a+1)%Number.MAX_SAFE_INTEGER,_a.toString()}const Ma=new Map,Jf=e=>{if(Ma.has(e))return;const t=setTimeout(()=>{Ma.delete(e),so({type:"REMOVE_TOAST",toastId:e})},ES);Ma.set(e,t)},NS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,TS)};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?Jf(n):e.toasts.forEach(r=>{Jf(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)}}},_s=[];let Ms={toasts:[]};function so(e){Ms=NS(Ms,e),_s.forEach(t=>{t(Ms)})}function AS({...e}){const t=IS(),n=o=>so({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>so({type:"DISMISS_TOAST",toastId:t});return so({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ra(){const[e,t]=m.useState(Ms);return m.useEffect(()=>(_s.push(t),()=>{const n=_s.indexOf(t);n>-1&&_s.splice(n,1)}),[e]),{...e,toast:AS,dismiss:n=>so({type:"DISMISS_TOAST",toastId:n})}}function jS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,c]=y.useState(null),[u,d]=y.useState(null),{toast:f}=Ra(),h=y.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const x=await _f(n);c(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await dS(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 _f(n),w=new Blob([x],{type:o}),C=URL.createObjectURL(w);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},b=()=>s?l.jsxs("div",{className:"flex items-center justify-center py-12",children:[l.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),l.jsx("span",{children:"Loading file..."})]}):u?l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),l.jsx("p",{className:"text-red-600 mb-4",children:u}),l.jsx(et,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?l.jsx("div",{className:"flex justify-center",children:l.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?l.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:l.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?l.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):l.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[l.jsx(ae.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),l.jsx("p",{className:"text-lg font-medium mb-2",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?l.jsx(ae.Image,{className:"h-5 w-5"}):l.jsx(ae.FileText,{className:"h-5 w-5"});return l.jsx(Yf,{open:e,onOpenChange:t,children:l.jsxs(Na,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(Aa,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[g(),l.jsxs("div",{children:[l.jsx(ja,{className:"text-left",children:r}),l.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(et,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[l.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(et,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[l.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),l.jsx("div",{className:"flex-1 overflow-hidden",children:b()})]})})}function Zf(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let nr=Zf();function _S(e){nr=e}const Qf=/[&<>"']/,MS=new RegExp(Qf.source,"g"),eh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,RS=new RegExp(eh.source,"g"),PS={"&":"&","<":"<",">":">",'"':""","'":"'"},th=e=>PS[e];function Rt(e,t){if(t){if(Qf.test(e))return e.replace(MS,th)}else if(eh.test(e))return e.replace(RS,th);return e}const OS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function nh(e){return e.replace(OS,(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 DS=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(DS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const LS=/[^\w:]/g,$S=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function rh(e,t,n){if(e){let r;try{r=decodeURIComponent(nh(n)).replace(LS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!$S.test(n)&&(n=HS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Rs={},FS=/^[^:]+:\/*[^/]*$/,BS=/^([^:]+:)[\s\S]*$/,zS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function HS(e,t){Rs[" "+e]||(FS.test(e)?Rs[" "+e]=e+"/":Rs[" "+e]=Os(e,"/",!0)),e=Rs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(BS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(zS,"$1")+t:e+t}const Ps={exec:function(){}};function oh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,u=i;for(;--u>=0&&a[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Os(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 US(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 WS(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 sh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function ih(e,t,n,r){const o=t.href,s=t.title?Rt(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:Rt(i)}}function VS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
91
|
+
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},AS="DialogDescriptionWarning",jS=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Jf(AS).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},ja=Lf,_S=Ff,_a=zf,so=Hf,io=Uf,tr=Vf,_s=qf,Zf=Yf;const Qf=ja,MS=_a,eh=m.forwardRef(({className:e,...t},n)=>c.jsx(so,{ref:n,className:ne("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}));eh.displayName=so.displayName;const Ma=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===tr||(u==null?void 0:u.displayName)===tr.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(MS,{children:[c.jsx(eh,{}),c.jsxs(io,{ref:r,className:ne("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(tr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Zf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ma.displayName=io.displayName;const Ra=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ra.displayName="DialogHeader";const Pa=m.forwardRef(({className:e,...t},n)=>c.jsx(tr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Pa.displayName=tr.displayName;const RS=m.forwardRef(({className:e,...t},n)=>c.jsx(_s,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));RS.displayName=_s.displayName;const PS=1,OS=1e6;let Oa=0;function DS(){return Oa=(Oa+1)%Number.MAX_SAFE_INTEGER,Oa.toString()}const Da=new Map,th=e=>{if(Da.has(e))return;const t=setTimeout(()=>{Da.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},OS);Da.set(e,t)},LS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,PS)};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?th(n):e.toasts.forEach(r=>{th(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)}}},Ms=[];let Rs={toasts:[]};function ao(e){Rs=LS(Rs,e),Ms.forEach(t=>{t(Rs)})}function $S({...e}){const t=DS(),n=o=>ao({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>ao({type:"DISMISS_TOAST",toastId:t});return ao({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function La(){const[e,t]=m.useState(Rs);return m.useEffect(()=>(Ms.push(t),()=>{const n=Ms.indexOf(t);n>-1&&Ms.splice(n,1)}),[e]),{...e,toast:$S,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}function FS({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=y.useState(!1),[a,l]=y.useState(null),[u,d]=y.useState(null),{toast:f}=La(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await Of(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await bS(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 Of(n),b=new Blob([x],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}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(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(et,{onClick:h,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ae.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>o.startsWith("image/")?c.jsx(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(Qf,{open:e,onOpenChange:t,children:c.jsxs(Ma,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Ra,{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(Pa,{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(et,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(et,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:w()})]})})}function nh(){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 nr=nh();function BS(e){nr=e}const rh=/[&<>"']/,zS=new RegExp(rh.source,"g"),oh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,HS=new RegExp(oh.source,"g"),US={"&":"&","<":"<",">":">",'"':""","'":"'"},sh=e=>US[e];function Rt(e,t){if(t){if(rh.test(e))return e.replace(zS,sh)}else if(oh.test(e))return e.replace(HS,sh);return e}const WS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function ih(e){return e.replace(WS,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const VS=/(^|[^\[])\^/g;function it(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(VS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const KS=/[^\w:]/g,qS=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ah(e,t,n){if(e){let r;try{r=decodeURIComponent(ih(n)).replace(KS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!qS.test(n)&&(n=JS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ps={},GS=/^[^:]+:\/*[^/]*$/,YS=/^([^:]+:)[\s\S]*$/,XS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function JS(e,t){Ps[" "+e]||(GS.test(e)?Ps[" "+e]=e+"/":Ps[" "+e]=Ds(e,"/",!0)),e=Ps[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(YS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(XS,"$1")+t:e+t}const Os={exec:function(){}};function lh(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 Ds(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 ZS(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 QS(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 ch(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function uh(e,t,n,r){const o=t.href,s=t.title?Rt(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:Rt(i)}}function eC(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
92
92
|
`).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(`
|
|
93
|
-
`)}class
|
|
94
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
93
|
+
`)}class $a{constructor(t){this.options=t||nr}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:Ds(r,`
|
|
94
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=eC(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=Ds(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(`
|
|
95
95
|
`,1)[0].replace(/^\t+/,T=>" ".repeat(3*T.length)),f=t.split(`
|
|
96
|
-
`,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),
|
|
96
|
+
`,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+`
|
|
97
97
|
`,t=t.substring(f.length+1),v=!0),!v){const T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
98
98
|
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||T.test(f)||S.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
99
|
-
`+f.slice(i);else{if(
|
|
100
|
-
`+f}!
|
|
101
|
-
`,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 C=x.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const T=x.items[a].tokens.filter(k=>k.type==="space"),S=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));x.loose=S}if(x.loose)for(a=0;a<C;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]):Rt(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:
|
|
102
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,
|
|
103
|
-
`?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:Rt(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]):Rt(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=
|
|
104
|
-
]`).replace("lheading",
|
|
105
|
-
`),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,
|
|
99
|
+
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||S.test(d))break;p+=`
|
|
100
|
+
`+f}!l&&!f.trim()&&(l=!0),r+=h+`
|
|
101
|
+
`,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 C=x.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const T=x.items[a].tokens.filter(k=>k.type==="space"),S=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));x.loose=S}if(x.loose)for(a=0;a<C;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]):Rt(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:lh(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
102
|
+
`):[]};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]=lh(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)===`
|
|
103
|
+
`?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:Rt(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]):Rt(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=Ds(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=ZS(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)),uh(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 uh(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=Rt(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=Rt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Rt(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=Rt(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=Rt(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]):Rt(r[0]):r[0]:o=Rt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const be={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:Os,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=it(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=it(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=it(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._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",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=it(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=it(be._paragraph).replace("hr",be.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",be._tag).getRegex(),be.blockquote=it(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=it(be.gfm.table).replace("hr",be.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",be._tag).getRegex(),be.gfm.paragraph=it(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.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",be._tag).getRegex(),be.pedantic={...be.normal,html:it(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._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:Os,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:it(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
|
|
104
|
+
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const de={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Os,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:Os,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};de._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",de.punctuation=it(de.punctuation).replace(/punctuation/g,de._punctuation).getRegex(),de.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,de.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,de._comment=it(be._comment).replace("(?:-->|$)","-->").getRegex(),de.emStrong.lDelim=it(de.emStrong.lDelim).replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimAst=it(de.emStrong.rDelimAst,"g").replace(/punct/g,de._punctuation).getRegex(),de.emStrong.rDelimUnd=it(de.emStrong.rDelimUnd,"g").replace(/punct/g,de._punctuation).getRegex(),de._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,de._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,de._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])?)+(?![-_])/,de.autolink=it(de.autolink).replace("scheme",de._scheme).replace("email",de._email).getRegex(),de._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,de.tag=it(de.tag).replace("comment",de._comment).replace("attribute",de._attribute).getRegex(),de._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,de._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,de._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,de.link=it(de.link).replace("label",de._label).replace("href",de._href).replace("title",de._title).getRegex(),de.reflink=it(de.reflink).replace("label",de._label).replace("ref",be._label).getRegex(),de.nolink=it(de.nolink).replace("ref",be._label).getRegex(),de.reflinkSearch=it(de.reflinkSearch,"g").replace("reflink",de.reflink).replace("nolink",de.nolink).getRegex(),de.normal={...de},de.pedantic={...de.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:it(/^!?\[(label)\]\((.*?)\)/).replace("label",de._label).getRegex(),reflink:it(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",de._label).getRegex()},de.gfm={...de.normal,escape:it(de.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},de.gfm.url=it(de.gfm.url,"i").replace("email",de.gfm._extended_email).getRegex(),de.breaks={...de.gfm,br:it(de.br).replace("{2,}","*").getRegex(),text:it(de.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function tC(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 dh(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 Pn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||nr,this.options.tokenizer=this.options.tokenizer||new $a,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:be.normal,inline:de.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=de.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=de.breaks:n.inline=de.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:de}}static lex(t,n){return new Pn(n).lex(t)}static lexInline(t,n){return new Pn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
105
|
+
`),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+=`
|
|
106
106
|
`: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+=`
|
|
107
107
|
`+r.raw,o.text+=`
|
|
108
108
|
`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
109
109
|
`+r.raw,o.text+=`
|
|
110
|
-
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const
|
|
110
|
+
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let u;this.options.extensions.startBlock.forEach(function(d){u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(a=Math.min(a,u))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
|
|
111
111
|
`+r.raw,o.text+=`
|
|
112
112
|
`+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+=`
|
|
113
113
|
`+r.raw,o.text+=`
|
|
114
|
-
`+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,
|
|
114
|
+
`+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)+"["+ch("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)+"["+ch("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,dh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,dh))){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,tC)){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 Fa{constructor(t){this.options=t||nr}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$/,"")+`
|
|
115
115
|
`,o?'<pre><code class="'+this.options.langPrefix+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
|
|
116
116
|
`:"<pre><code>"+(r?t:Rt(t,!0))+`</code></pre>
|
|
117
117
|
`}blockquote(t){return`<blockquote>
|
|
@@ -131,7 +131,7 @@ ${t}</blockquote>
|
|
|
131
131
|
`}tablerow(t){return`<tr>
|
|
132
132
|
${t}</tr>
|
|
133
133
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
134
|
-
`}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=
|
|
135
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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
|
|
136
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(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 uh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=KS(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(WS(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&ve.walkTokens(c,r.walkTokens),h=t(c,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,!c.length))return u();let d=0;ve.walkTokens(c,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(ve.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&&ve.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function ve(e,t,n){return uh(Pn.lex,On.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},_S(ve.defaults),ve},ve.getDefaults=Zf,ve.defaults=nr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.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=ve.defaults.renderer||new Oa;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new Pa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new Ds;for(const s in n.hooks){const i=o[s];Ds.passThroughHooks.has(s)?o[s]=a=>{if(ve.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=ve.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}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=uh(Pn.lexInline,On.parseInline),ve.Parser=On,ve.parser=On.parse,ve.Renderer=Oa,ve.TextRenderer=lh,ve.Lexer=Pn,ve.lexer=Pn.lex,ve.Tokenizer=Pa,ve.Slugger=ch,ve.Hooks=Ds,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,On.parse,Pn.lex;function io({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return l.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}const GS={MODE:"library"};function YS(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Qs&&Qs.tagName.toUpperCase()==="SCRIPT"&&Qs.src||new URL("index.umd.js",document.baseURI).href}<"u"?GS:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function XS(){return!YS()}function JS(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function ZS(){return XS()||JS()}function QS({preview:e,idx:t}){return y.useEffect(()=>{ZS()&&console.debug(`[MessageComponent] Preview ${t} mounted:`,{src:e.src.substring(0,100),alt:e.alt,label:e.label})},[t,e]),l.jsxs("div",{className:"space-y-2",children:[e.label&&l.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),l.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:l.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function eC({artifact:e}){const[t,n]=y.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=y.useState(l.jsx(ae.Clock,{className:"w-4 h-4"})),[s,i]=y.useState("Processing");return y.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(l.jsx(ae.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(l.jsx(ae.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(l.jsx(ae.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(l.jsx(ae.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),l.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:"mt-1 flex-shrink-0",children:l.jsx(ae.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),l.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",l.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),l.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,l.jsx("span",{children:s})]}),e.query&&l.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[l.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),l.jsx("p",{className:"line-clamp-2",children:e.query})]}),e.progress_url&&l.jsx("div",{className:"pt-2",children:l.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[l.jsx("span",{children:"Monitor Progress"}),l.jsx(ae.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&l.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function tC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return l.jsx(eC,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}});const n=y.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>uS(o)).filter(o=>o!==null):[],[e]);return n.length>0?l.jsx("div",{className:"space-y-2",children:n.map((r,o)=>l.jsx(QS,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?l.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:l.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",l.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const ao=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ao.displayName="Card";const lo=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));lo.displayName="CardHeader";const co=m.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));co.displayName="CardTitle";const dh=m.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));dh.displayName="CardDescription";const uo=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));uo.displayName="CardContent";const fh=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));fh.displayName="CardFooter";function nC({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=l.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=no(s);a=l.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:u})}const c=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return l.jsxs(ao,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[l.jsxs(lo,{className:"pb-3",children:[l.jsx(co,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),l.jsx(dh,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a&&l.jsx(uo,{className:"pt-0 pb-3",children:a}),l.jsx(fh,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(et,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),l.jsx(et,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const rC="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function hh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:rC,children:l.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>l.jsx("li",{children:String(n)},r))})}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:no(e)}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:no(e)})}function oC({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=y.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&l.jsx(ae.Loader,{className:"h-3 w-3 animate-spin"}),l.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&l.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,c)=>{var u;return l.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[l.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[l.jsx("span",{children:((u=a.type)==null?void 0:u.replace(/\./g," "))??"progress"}),l.jsx("span",{children:a.idx??c+1})]}),a.content&&l.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),l.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&l.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&l.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${c}`)})})]}):null}function sC({message:e,viewMode:t,isStreaming:n=!1}){const o=Nf(e).name||"tool",s=c=>{if(c==null)return null;const u=typeof c=="string"?Sa(c)??c:c;if(u&&typeof u=="object")return l.jsx(hh,{data:u});const d=typeof u=="string"?u:(()=>{try{return no(u)}catch{return String(u??"")}})();return l.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=c=>{if(c==null)return null;const{content:u,isMarkdown:d}=rS(c);return d?l.jsx(io,{content:u,className:"text-current"}):s(c)},a=()=>{const c=e.content.find(f=>f.type!=="tool_call");if(!c)return l.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:l.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const h=(c.text??"").trim();if(!h)return null;const p=Es(h);return i(p)}const u=to(c),d=Es(u);return i(d)};return l.jsxs("div",{className:"space-y-2",children:[l.jsx(oC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function iC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Ra(),[o,s]=y.useState({}),[i,a]=y.useState(null),[c,u]=y.useState(!1),d=y.useCallback(()=>{u(!1),a(null)},[]),f=y.useCallback(p=>{a(p),u(!0)},[]),h=y.useCallback(async(p,v,b)=>{var g,x;if(!t){p.preventDefault();return}if(o[b]){p.preventDefault();return}try{const w=String(v.url??""),C=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const T=C[1],S=v.name||`file_${T}`,k=v.mimeType||"application/octet-stream";f({id:T,name:S,mimeType:k});return}if(w.startsWith("data:")){p.preventDefault(),s(S=>({...S,[b]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const S=await fS(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const k=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");f({id:k.id,name:v.name||k.filename||`file_${k.id}`,mimeType:v.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const k=S instanceof Error?S.message:"Unknown error occurred";(x=T.update)==null||x.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(S=>({...S,[b]:!1}))}}}catch(w){console.error("File click error:",w),s(C=>({...C,[b]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:c,currentFileInfo:i,closeFileViewer:d}}function aC({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return l.jsxs("div",{className:"flex flex-col gap-1",children:[l.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?l.jsx(io,{content:e,allowHtml:!1}):l.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),l.jsx(et,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?l.jsxs(l.Fragment,{children:[l.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):l.jsxs(l.Fragment,{children:[l.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function lC({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),l.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function ph(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Ls=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateUserMessages:u=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:h=!0,customStyles:p={},onEdit:v,onRegenerate:b,onCancelEdit:g,onCopy:x,activeInterrupt:w,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:S,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:j,defaultCheckpointId:O=null,messageParentCheckpointId:F=null}){const[H,U]=y.useState(!1),[q,P]=y.useState("preview"),[z,I]=y.useState(!1),{currentThreadId:D}=Ro(),{respondToInterrupt:R}=Po(),A=c==="phone"||c==="half-screen",B=t.role,W=B==="tool",_=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),V=!!_,ie=!(r&&B!=="user"),{uploadingFiles:Q,handleFileClick:oe,fileViewerOpen:Y,currentFileInfo:L,closeFileViewer:K}=iC({allowFileOpen:ie,currentThreadId:D}),te=y.useMemo(()=>{switch(B){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[B]),G=y.useMemo(()=>{if(_)return"";const M=t.content;return Array.isArray(M)?oS(M):""},[_,t]),X=y.useMemo(()=>{if(_)return{};const M=t.content;return Array.isArray(M)?Nf(t):{}},[_,t]),he=y.useMemo(()=>W?!!(t.additionalKwargs??{}).toolStreaming:!1,[W,t]),fe=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="image_url"):[]},[_,t]),Z=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="file"):[]},[_,t]),le=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="interrupt"):[]},[_,t]),be=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),_e=Is(be),Ne=w==null?void 0:w.value,$e=y.useMemo(()=>{if(_)return"";const M=t.content;return Array.isArray(M)?sS(M):""},[_,t]),Xe=y.useMemo(()=>_||!h?null:t.artifact||null,[_,t,h]),nt=y.useCallback(async()=>{const M=W?$e:G;async function se(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const We=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":We})]);return}throw new Error("Clipboard API not supported in this context.")}try{await se(M),U(!0),setTimeout(()=>U(!1),2e3),x==null||x(M)}catch(me){console.error("Failed to copy:",me)}},[W,$e,G,x]),Ve=y.useCallback(()=>{if(!v)return;const M=W?$e:G,se="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,M,se)},[v,t.id,W,$e,G,t]),Ke=y.useCallback(()=>{b==null||b(n)},[b,n]),ot=y.useCallback(()=>{const se=ne(A?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",te);switch(B){case"user":return l.jsx(ae.User,{className:se});case"assistant":return l.jsx(ae.Bot,{className:se});case"tool":return l.jsx(ae.Wrench,{className:se});default:return l.jsx(ae.Bot,{className:se})}},[A,te,B]),kt=y.useCallback(()=>{const M="group relative mb-4 flex w-full";switch(B){case"user":return ne(M,"justify-end");case"assistant":case"tool":case"system":return ne(M,"justify-start");default:return M}},[B]),lt=y.useCallback(()=>{const M=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",A&&"px-3 py-2 text-sm");if(V)return ne(M,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(B){case"user":return ne(M,"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 ne(M,"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 ne(M,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(M,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(M,"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")}},[A,V,B]),Te=y.useCallback(async M=>{if(C)return;const se=Is((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!se){console.warn("Interrupt part missing id",M);return}try{T==null||T(),await R(se,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{S==null||S()}},[C,S,T,R]),Oe=y.useCallback(async M=>{if(C)return;const se=Is((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!se){console.warn("Interrupt part missing id",M);return}try{T==null||T(),await R(se,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{S==null||S()}},[C,S,T,R]),at=y.useCallback(({part:M,i:se})=>{if(M.type==="text"){const me=M.text??"",We=me.trim(),Pe=Sa(We);return Pe&&B!=="tool"?l.jsx(hh,{data:Pe},se):B==="user"&&u&&We.length>d?l.jsx(aC,{text:We,expanded:z,onExpandedChange:I,previewLength:d,isCompact:A},se):l.jsx(io,{content:me,allowHtml:!1},se)}if(M.type==="image_url"){const me=M;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:me.url,alt:me.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},se)}if(M.type==="file"){const me=M,We=me.name||"file";return l.jsxs("a",{href:me.url,onClick:Pe=>oe(Pe.nativeEvent,me,se),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
137
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[Q[se]?l.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[We,Q[se]?" (processing)":""]})]},se)}if(M.type==="interrupt"){const me=M,We=Is((me==null?void 0:me.id)??(me==null?void 0:me.interrupt_id)),Pe=!!(_e&&We&&We===_e),mt=Pe?Ne??(me==null?void 0:me.value):me==null?void 0:me.value,Ze=We?{...me,id:We,interrupt_id:We}:me;return l.jsx(nC,{interruptPart:Ze,onApprove:Te,onReject:Oe,disabled:C,isActive:Pe,payload:mt},se)}return null},[oe,Q,Te,Oe,B,u,d,z,A,_e,Ne,w,C,le]),ht=y.useCallback(()=>l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[l.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Tt=y.useCallback(()=>{const M=G.trim().length>0||fe.length>0||Z.length>0||le.length>0;if(!W&&Z.length>0&&!r)return ht();if(!W&&!M&&!r)return null;if(W)return!f&&Xe?null:f?l.jsx(sC,{message:t,viewMode:q,isStreaming:he},t.id):null;if(!W&&!_){const se=t,me=l.jsx("div",{className:"space-y-2",children:se.content.map((We,Pe)=>l.jsx(at,{part:We,i:Pe},Pe))});return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[me,l.jsx(lC,{className:te})]}):me}},[G,fe.length,Z.length,le.length,r,W,q,f,Xe,ht,te]),St=y.useMemo(()=>_?"Assistant":iS(t),[_,t]),Le=y.useMemo(()=>_?[]:Array.isArray(k)?k:[],[k,_]),Ht=y.useMemo(()=>{var M;return Le.length?O&&Le.some(se=>se.id===O)?O:((M=Le[0])==null?void 0:M.id)??null:null},[O,Le]),qe=y.useMemo(()=>!Le.length||!E?null:Le.some(M=>M.id===E)?E:null,[E,Le])??Ht,dt=B==="user"&&Le.length>0&&typeof j=="function",bt=y.useCallback((M,se=!1)=>{if(!j)return;const me=(M==null?void 0:M.id)??null,We=(M==null?void 0:M.parentId)??F??null;j(me,We,se)},[F,j]),Ue=y.useMemo(()=>qe?Le.findIndex(M=>M.id===qe):-1,[qe,Le]),Ct=y.useMemo(()=>Ue<0?null:Le[Ue]??null,[Ue,Le]);return W&&!f&&!Xe?null:V&&_?l.jsx("div",{className:ne(kt(),p.container),children:l.jsxs("div",{className:ne(lt(),p.content),children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[l.jsx(ae.Bot,{className:ne("h-4 w-4",te)}),a&&l.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),l.jsx(io,{content:_.content,className:"text-current"})]})}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:ne(kt(),p.container),children:l.jsxs("div",{className:ne(lt(),p.content),children:[(i||a||W)&&l.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",A&&"mb-1 pb-1",te,p.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[ot(),a&&St&&l.jsx("span",{className:ne("font-medium",A?"text-xs":"text-sm"),children:St}),W&&l.jsxs(Ef,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",te,"border border-current/40",A&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":q==="expanded",onClick:()=>P(M=>M==="expanded"?"preview":"expanded"),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),P(se=>se==="expanded"?"preview":"expanded"))},children:[l.jsx("span",{children:X.name??"Tool Output"}),X.toolCallId&&l.jsx("span",{className:"opacity-70",children:X.toolCallId.slice(0,8)}),q==="expanded"?l.jsx(ae.ChevronUp,{className:"h-3 w-3"}):l.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[dt&&Ct&&Ue>=0&&l.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue<Le.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ue>=Le.length-1)return;const M=Le[Ue+1];M&&bt(M)},"aria-label":"Older checkpoint (back in time)",disabled:Ue>=Le.length-1,children:l.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("span",{className:"whitespace-nowrap",children:[Le.length-Ue," / ",Le.length]})}),l.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ue<=0))if(Ue===1)bt(null,!0);else{const M=Le[Ue-1];M&&bt(M,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ue<=0,children:l.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&l.jsx("time",{className:ne("text-xs opacity-60",te,A&&"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&&l.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[l.jsx("div",{className:"relative",children:l.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:l.jsx(ae.Copy,{className:ne(H?"text-success":te,A?"h-3 w-3":"h-4 w-4")})})}),B==="user"&&v&&l.jsx(et,{variant:"ghost",size:"sm",onClick:Ve,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(ae.Edit,{className:ne(te,A?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&b&&l.jsx(et,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(ae.RotateCcw,{className:ne(te,A?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsxs("div",{className:"relative",children:[Tt(),h&&Xe&&l.jsx("div",{className:"mt-3",children:l.jsx(tC,{artifact:Xe,idx:0})})]}),W&&q==="expanded"&&(X.toolCallId||X.name)&&l.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",A&&"text-xs"),children:[X.name&&l.jsxs("div",{children:["Function: ",X.name]}),X.toolCallId&&l.jsxs("div",{children:["Call ID: ",X.toolCallId]})]}),!(i||a||W)&&s&&!o&&l.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[l.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:l.jsx(ae.Copy,{className:ne(H?"text-success":"text-current",A?"h-3 w-3":"h-4 w-4")})}),B==="user"&&v&&l.jsx(et,{variant:"ghost",size:"sm",onClick:Ve,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:l.jsx(ae.Edit,{className:ne("text-current",A?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&b&&l.jsx(et,{variant:"ghost",size:"sm",onClick:Ke,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:l.jsx(ae.RotateCcw,{className:ne("text-current",A?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&l.jsx(jS,{isOpen:Y,onClose:K,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var c,u,d,f,h,p,v,b;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Af(e.message)===Af(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","attemptMeta"].every(g=>e[g]===t[g]),s=((c=e.customStyles)==null?void 0:c.container)===((u=t.customStyles)==null?void 0:u.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((h=e.customStyles)==null?void 0:h.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((b=t.customStyles)==null?void 0:b.header);if(!o||!s)return!1;const i=ph(e.message),a=ph(t.message);return i.length===a.length});Ls.displayName="MessageComponent";function cC(e,t){return y.useMemo(()=>{var d,f,h,p,v;const n=e&&"type"in e&&e.type==="default_message";let r=[],o=null,s={},i={},a=null,c=null,u=null;if(!n&&e){const b=e,g=b.checkpointId??null;s=b.additionalKwargs??{},i=b.responseMetadata??{};const x=g&&t.checkpointMetaById?t.checkpointMetaById.get(g)??null:null;a=typeof s.step=="number"?s.step:typeof i.step=="number"?i.step:(x==null?void 0:x.step)??null;const w=typeof s.source=="string"?s.source:typeof i.source=="string"?i.source:(x==null?void 0:x.source)??null;c=w?String(w):null;const C=a!==null&&c?`${a}:${c}`:null;if(C&&((d=t.checkpointIndexByKey)!=null&&d.has(C))?r=t.checkpointIndexByKey.get(C)??[]:g&&x&&(r=[x]),o=g??((f=r[0])==null?void 0:f.id)??null,u=g?((h=t.attemptMetaById)==null?void 0:h.get(g))??null:null,!u&&(e==null?void 0:e.role)==="user"&&(e!=null&&e.id)&&t.userMessageIdToAttempts){const T=t.userMessageIdToAttempts.get(e.id);if(T&&T.length>0){const S=T[0].checkpointId;u=((p=t.attemptMetaById)==null?void 0:p.get(S))??null,u&&console.log(`[useMessageMetadata] Found attempt by user message ID "${e.id}":`,T.length,"versions")}}if(!u&&r.length>0&&t.attemptMetaById){const T=t.attemptMetaById.get(r[0].id);T&&(u=T)}if(u&&u.attemptCount>1&&t.attemptMetaById){const T=u.baseUserMessageId;if(T){const S=[];for(const[k,E]of t.attemptMetaById.entries())if(E.baseUserMessageId===T){const j=(v=t.checkpointMetaById)==null?void 0:v.get(k);j&&S.push(j)}S.length>0&&(r=S)}}if(u&&u.attemptCount>1&&t.checkpointMetaById&&t.attemptMetaById){const T=[];for(const[S,k]of t.checkpointMetaById.entries()){const E=t.attemptMetaById.get(S);E&&E.attemptCount===u.attemptCount&&E.baseUserMessageId===u.baseUserMessageId&&T.push(k)}T.sort((S,k)=>{const E=S.createdAt?Date.parse(S.createdAt):0;return(k.createdAt?Date.parse(k.createdAt):0)-E}),T.length>0&&(r=T,console.log("[useMessageMetadata] Populated checkpointCandidates with all attempts:",{messageId:e.id,attemptCount:u.attemptCount,candidateIds:r.map(S=>S.id)}))}}return{checkpointCandidates:r,defaultCheckpointId:o,attemptMeta:u,resolvedStep:a,resolvedSource:c}},[e,t.checkpointMetaById,t.checkpointIndexByKey,t.attemptMetaById,t.userMessageIdToAttempts])}const mh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,gh=y.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:c,onEdit:u,onRegenerate:d,onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:b,showToolMessages:g,showArtifactPreviews:x,checkpointMetaById:w,checkpointIndexByKey:C,attemptMetaById:T,userMessageIdToAttempts:S,activeCheckpointId:k,onSelectCheckpoint:E}){const j=mh(t,n),O="type"in t&&t.type==="default_message",H=!!t.__syntheticStreaming,{checkpointCandidates:U,defaultCheckpointId:q,attemptMeta:P}=cC(t,{checkpointMetaById:w,checkpointIndexByKey:C,attemptMetaById:T,userMessageIdToAttempts:S}),z=t&&!O?t.additionalKwargs??{}:{},I=t&&!O?t.responseMetadata??{}:{},D=(()=>{if(typeof z.parentCheckpointId=="string")return z.parentCheckpointId;if(typeof I.parentCheckpointId=="string")return I.parentCheckpointId})();return l.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":j,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:l.jsx(Ls,{message:t,messageIndex:n,isStreamingMessage:H||r&&o===t.id,streamingDebounceMs:s,isEditing:c===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:u,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:b,showToolMessages:g,showArtifactPreviews:x,checkpointCandidates:U,activeCheckpointId:k??null,onSelectCheckpoint:E,defaultCheckpointId:q,messageParentCheckpointId:D,attemptMeta:P})})});gh.displayName="MessageRow";const Da=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:b=!1,onScrollAway:g,onAtBottom:x,activeInterrupt:w,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:S,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointMetaById:j,checkpointIndexByKey:O,attemptMetaById:F,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:q,createSyntheticThinkingMessage:P=!0},z)=>{const I=y.useRef(null),D=y.useRef(null),R=y.useRef(!1),A=y.useRef(!1),[B,W]=y.useState(!0),_=y.useMemo(()=>w?e.some(Z=>"type"in Z&&Z.type==="default_message"?!1:Array.isArray(Z==null?void 0:Z.content)&&Z.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===w.id)):!1,[w,e]),V=y.useMemo(()=>{if(!w||_)return null;const Z=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let le;const be=w.value;if(be&&typeof be=="object"&&!Array.isArray(be)){const _e=be.title;typeof _e=="string"&&_e.trim()&&(le=_e.trim())}return{id:`interrupt-${Z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Z,value:be,title:le}]}},[w,_]),ie=y.useMemo(()=>V?[...e,V]:e,[e,V]),Q=y.useMemo(()=>!P||!t?ie:!ie.some(le=>le.role==="assistant")&&ie.length>0?[...ie,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:ie,[ie,t,P]),oe=y.useMemo(()=>k?Q:Q.filter(Z=>(Z==null?void 0:Z.role)!=="tool"),[Q,k]),Y=y.useCallback(Z=>{W(Z),g&&g(!Z),x&&x(Z)},[g,x]),L=y.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),K=y.useMemo(()=>!v||b?!1:B?"auto":!1,[B,v,b]),te=y.useMemo(()=>{if(typeof p!="string")return null;const Z=p.trim();return Z?{id:"default-message",role:"assistant",type:"default_message",content:Z,createdAt:new Date().toISOString()}:null},[p]),G=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>te?l.jsx("div",{className:"p-6 h-full overflow-y-auto",children:l.jsx("div",{className:"w-full max-w-full",children:l.jsx(Ls,{message:te,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):l.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),he=oe.length,fe=he>0;return y.useEffect(()=>{var Z,le;if(he===0){A.current=!1;return}if(!A.current)if(A.current=!0,I.current&&oe.length>0){const be=oe.length-1;(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:be,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},[he,oe.length]),y.useImperativeHandle(z,()=>({scrollToLatest:()=>{var Z,le;if(I.current&&oe.length>0){const be=oe.length-1;(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:be,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},scrollToTop:()=>{var Z,le;I.current&&oe.length>0?(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:0,align:"start",behavior:"auto"}):D.current&&(D.current.scrollTop=0)}}),[oe]),l.jsx("div",{className:G,style:h,children:l.jsx("div",{className:"relative flex-1 min-h-0",children:fe?l.jsx(B0,{ref:Z=>{I.current=Z},scrollerRef:Z=>{D.current=Z instanceof HTMLDivElement?Z:null},data:oe,followOutput:K,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Z,le)=>mh(le,Z),itemContent:(Z,le)=>l.jsx(gh,{message:le,index:Z,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:c,onRegenerate:u,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:C,onInterruptActionStart:T,onInterruptActionEnd:S,showToolMessages:k,showArtifactPreviews:E,checkpointMetaById:j,checkpointIndexByKey:O,attemptMetaById:F,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:q})}):X()})})});Da.displayName="MessageList";const xh={value:""};function $s({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:c=!1,enableMessageEditing:u=!0,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:h={},onMessageSent:p,onExcelUploadSuccess:v,onError:b}){const{api:g}=pi(),{currentThreadId:x}=Ro(),{threadId:w,messages:C,isHistoryLoading:T,isLoading:S,navigateToCheckpoint:k,returnToLatest:E,checkpoint:j,checkpoints:O,interrupt:F,metadata:H,timelineCheckpoints:U,messagePreviews:q}=Po(),{isStreaming:P,error:z,connectionState:I,submit:D,stop:R}=gc(),A=w??x??null,B=(j==null?void 0:j.id)??null,W=(j==null?void 0:j.namespace)??null,_=(H==null?void 0:H.assemblingMessageId)??null,V=F,[ie,Q]=y.useState(!1);y.useEffect(()=>{V||Q(!1)},[V]);const oe=y.useCallback(()=>{Q(!0)},[]),Y=y.useCallback(()=>{Q(!1)},[]),L=!!V||ie,[K,te]=y.useState(null),[G,X]=y.useState(""),[he,fe]=y.useState(null),[Z,le]=y.useState(null),[be,_e]=y.useState([]),[Ne,$e]=y.useState(0),[Xe,nt]=y.useState(0),[Ve,Ke]=y.useState(!1),[ot,kt]=y.useState(null),[lt,Te]=y.useState(null),[Oe,at]=y.useState(!1),[ht,Tt]=y.useState(null),St=y.useRef(!1),[Le,Ht]=y.useState(()=>xh.value),Je=y.useRef(Le),qe=y.useRef(null),dt=y.useCallback(ge=>{xh.value=ge,Ht(ge)},[]),[bt,Ue]=y.useState(!1),Ct=y.useRef(null),{checkpointMetaById:M,checkpointIndexByKey:se,attemptMetaById:me,userMessageIdToAttempts:We}=Iy(O),Pe=U??[],mt=y.useRef(null),Ze=y.useRef(null),Nt=y.useCallback(()=>{mt.current&&(mt.current.value=""),Ze.current&&(Ze.current.value=""),$e(ge=>ge+1),nt(ge=>ge+1)},[]),mo=y.useCallback(ge=>{dt(ge)},[dt]),go=y.useRef(!1);y.useEffect(()=>{go.current&&!P&&(_e([]),Nt()),go.current=P},[P,Nt]);const[Xs,rl]=y.useState("desktop");y.useEffect(()=>{const ge=()=>{const Se=window.innerWidth;rl(Se<640?"phone":Se<1024?"tablet":"desktop")};return ge(),window.addEventListener("resize",ge),()=>window.removeEventListener("resize",ge)},[]),y.useEffect(()=>{St.current=!1},[A]),y.useEffect(()=>{Je.current=Le},[Le]),y.useEffect(()=>{if(!K){qe.current=null;return}qe.current===null&&(qe.current=Je.current),dt(G??"")},[G,K,dt]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){Tt(null);return}try{const Ae=(await g.getAgent("default")).uiDefaultMessage||"";Tt(Ae||null)}catch(Se){console.warn("Failed to fetch default message:",Se),Tt(null)}})()},[g.baseUrl]),y.useEffect(()=>{z&&!Oe&&(b==null||b(z))},[z,Oe,b]);const ol=ge=>{if(ge.length>fs)return`Message too long (${ge.length}/${fs} characters)`;try{return jy(ge),null}catch(Se){return(Se==null?void 0:Se.message)||"Invalid message"}},sl=async ge=>{const Se=ge.trim();if(!(!Se&&be.length===0)){if(Se){const Ae=ol(Se);if(Ae){le(Ae);return}}try{const Ae=K?(he==null?void 0:he.checkpointId)??B??void 0:B??void 0,Ge=K?(he==null?void 0:he.checkpointNs)??W??void 0:W??void 0;await D({text:Se||"",attachments:be},{checkpointId:Ae,checkpointNs:Ge,edit:!!K,originalMessageId:K??void 0}),p==null||p(Se),dt(""),le(null),_e([]),Nt(),te(null),X(""),fe(null)}catch(Ae){const Ge=(Ae==null?void 0:Ae.message)||"Failed to send message";le(Ge),b==null||b(Ge)}}},Js=y.useCallback((ge,Se,Ae)=>{u&&(qe.current=Le,te(ge),X(Se),dt(Se),le(null),fe({checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}))},[Le,u,dt]),N=y.useCallback(()=>{te(null),X(""),fe(null),le(null),dt(qe.current??Le),qe.current=null},[Le,dt]),ee=y.useCallback((ge,Se,Ae)=>{Js(ge,Se,Ae)},[Js]),ce=y.useCallback(ge=>{let Se=null;for(let tn=ge-1;tn>=0;tn--)if(C[tn].role==="user"){Se=C[tn];break}if(!Se)return;const Ae=Array.isArray(Se.content)?Se.content:[],Bn=Ae.filter(tn=>(tn==null?void 0:tn.type)==="text").map(tn=>tn.text).join("")||(()=>{try{return JSON.stringify(Ae,null,2)}catch{return String(Ae)}})();Bn&&D({text:Bn},{checkpointId:B??void 0,checkpointNs:W??void 0,edit:!0,originalMessageId:Se.id})},[C,D,B,W]),Ee=ge=>{const Se=Array.from(ge.target.files||[]);_e(Ae=>[...Ae,...Se]),ge.target.value=""},Qe=ge=>{_e(Se=>{const Ae=Se.filter((Ge,Bn)=>ge!==Bn);return Ae.length===0&&Nt(),Ae})},rt=async ge=>{const Se=(ge.target.files||[])[0];if(Se){kt(null),Te(null),Ke(!0);try{await D({attachments:[Se]},{checkpointId:B??void 0,checkpointNs:W??void 0});const Ae=`Uploaded ${Se.name} - processing through chat stream`;Te(Ae)}catch(Ae){const Ge=Ae instanceof Error?Ae.message:"Failed to upload Excel file";console.error("Excel upload failed",Ae),kt(Ge),b==null||b(Ge)}finally{Ke(!1),ge.target.value="",Nt()}}},Be=async ge=>{if(x){Ue(!0);try{if(!ge){await E(),requestAnimationFrame(()=>{var Ge;(Ge=Ct.current)==null||Ge.scrollToLatest()});return}const Se=O.find(Ge=>Ge.checkpointId===ge),Ae=(Se==null?void 0:Se.checkpointNs)??null;await k(ge,Ae),requestAnimationFrame(()=>{var Ge;(Ge=Ct.current)==null||Ge.scrollToTop()})}finally{Ue(!1)}}},Fe=y.useCallback(async(ge,Se,Ae)=>{await Be(Ae?null:ge)},[Be]),At=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,pt=`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 ${h.messagesArea||""}`,gt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return l.jsxs("div",{className:At,children:[!!z&&!Oe&&l.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[l.jsx("span",{children:z}),l.jsx(et,{variant:"ghost",size:"sm",onClick:()=>at(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:l.jsx(ae.X,{size:16})})]}),l.jsxs("div",{className:`relative ${pt}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Da,{ref:Ct,className:"h-full",style:{height:"100%"},messages:C,isStreaming:P,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xs,enableMessageEditing:u,editingMessageId:K,onEdit:ee,onRegenerate:ce,onCancelEdit:N,emptyMessage:ht??void 0,isNavigatingCheckpoint:bt,activeInterrupt:V,disableInterruptActions:ie,onInterruptActionStart:oe,onInterruptActionEnd:Y,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:M,checkpointIndexByKey:se,attemptMetaById:me,userMessageIdToAttempts:We,activeCheckpointId:B,onSelectCheckpoint:Fe,timelineCheckpoints:Pe,messagePreviews:q,createSyntheticThinkingMessage:!0}),(I==="reconnecting"||I==="connecting")&&l.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),I==="reconnecting"?"Reconnecting…":"Connecting…"]})}),I==="error"&&l.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),S&&l.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[l.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(T||bt)&&l.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[l.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),l.jsxs("div",{className:gt,children:[K&&l.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),l.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),l.jsx(et,{variant:"ghost",size:"sm",onClick:N,className:"text-blue-600 hover:bg-blue-100",children:l.jsx(ae.X,{size:16})})]})}),(a||c)&&l.jsxs("div",{className:"mb-3 space-y-3",children:[a&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:mt,type:"file",multiple:!0,onChange:ge=>Ee(ge),className:"hidden"},Ne),be.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:be.map((ge,Se)=>l.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[l.jsx(ae.Paperclip,{size:14}),l.jsx("span",{className:"truncate max-w-[150px]",children:ge.name}),l.jsx(et,{variant:"ghost",size:"sm",onClick:()=>Qe(Se),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 ${ge.name}`,children:l.jsx(ae.X,{size:12})})]},Se))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Ze,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rt,className:"hidden"},Xe),Ve&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),lt&&!Ve&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:lt}),ot&&!Ve&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ot})]})]}),Z&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Z}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(Ji,{children:[l.jsx(Zi,{asChild:!0,children:l.jsx(et,{type:"button",size:"icon",variant:"outline",disabled:P||L,title:"More input actions",className:h.moreButton||"",children:l.jsx(ae.Plus,{size:16})})}),l.jsxs(ds,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(Yn,{onClick:()=>{var ge;return(ge=mt.current)==null?void 0:ge.click()},className:"cursor-pointer",children:[l.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(Yn,{onClick:()=>{var ge;Ve||(ge=Ze.current)==null||ge.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[l.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),l.jsx("div",{className:"flex-1",children:l.jsx(bx,{initialValue:G,editingMessageId:K,value:Le,onValueChange:mo,placeholder:K?"Edit your message...":t,isStreaming:P,disabled:L,maxLength:fs,onSend:sl,onCancelEdit:N,onStop:R,allowEmptySend:be.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${K?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Z?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var vh=1,uC=.9,dC=.8,fC=.17,La=.1,$a=.999,hC=.9999,pC=.99,mC=/[\\\/_+.#"@\[\(\{&]/,gC=/[\\\/_+.#"@\[\(\{&]/g,xC=/[\s-]/,bh=/[\s-]/g;function Fa(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?vh:pC;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var c=r.charAt(s),u=n.indexOf(c,o),d=0,f,h,p,v;u>=0;)f=Fa(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=vh:mC.test(e.charAt(u-1))?(f*=dC,p=e.slice(o,u-1).match(gC),p&&o>0&&(f*=Math.pow($a,p.length))):xC.test(e.charAt(u-1))?(f*=uC,v=e.slice(o,u-1).match(bh),v&&o>0&&(f*=Math.pow($a,v.length))):(f*=fC,o>0&&(f*=Math.pow($a,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=hC)),(f<La&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Fa(e,t,n,r,u+1,s+2,i),h*La>f&&(f=h*La)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[a]=d,d}function wh(e){return e.toLowerCase().replace(bh," ")}function vC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Fa(e,t,wh(e),wh(t),0,0,{})}var fo='[cmdk-group=""]',Ba='[cmdk-group-items=""]',bC='[cmdk-group-heading=""]',yh='[cmdk-item=""]',Sh=`${yh}:not([aria-disabled="true"])`,za="cmdk-item-select",Cr="data-value",wC=(e,t,n)=>vC(e,t,n),Ch=m.createContext(void 0),ho=()=>m.useContext(Ch),kh=m.createContext(void 0),Ha=()=>m.useContext(kh),Th=m.createContext(void 0),Eh=m.forwardRef((e,t)=>{let n=kr(()=>{var _,V;return{search:"",value:(V=(_=e.value)!=null?_:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=kr(()=>new Set),o=kr(()=>new Map),s=kr(()=>new Map),i=kr(()=>new Set),a=Ih(e),{label:c,children:u,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:v,disablePointerSelection:b=!1,vimBindings:g=!0,...x}=e,w=Pt(),C=Pt(),T=Pt(),S=m.useRef(null),k=_C();rr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),rr(()=>{k(6,q)},[]);let E=m.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,V,ie)=>{var Q,oe,Y,L;if(!Object.is(n.current[_],V)){if(n.current[_]=V,_==="search")U(),F(),k(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let K=document.getElementById(T);K?K.focus():(Q=document.getElementById(w))==null||Q.focus()}if(k(7,()=>{var K;n.current.selectedItemId=(K=P())==null?void 0:K.id,E.emit()}),ie||k(5,q),((oe=a.current)==null?void 0:oe.value)!==void 0){let K=V??"";(L=(Y=a.current).onValueChange)==null||L.call(Y,K);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=m.useMemo(()=>({value:(_,V,ie)=>{var Q;V!==((Q=s.current.get(_))==null?void 0:Q.value)&&(s.current.set(_,{value:V,keywords:ie}),n.current.filtered.items.set(_,O(V,ie)),k(2,()=>{F(),E.emit()}))},item:(_,V)=>(r.current.add(_),V&&(o.current.has(V)?o.current.get(V).add(_):o.current.set(V,new Set([_]))),k(3,()=>{U(),F(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let ie=P();k(4,()=>{U(),(ie==null?void 0:ie.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:T,labelId:C,listInnerRef:S}),[]);function O(_,V){var ie,Q;let oe=(Q=(ie=a.current)==null?void 0:ie.filter)!=null?Q:wC;return _?oe(_,n.current.search,V):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(Q=>{let oe=o.current.get(Q),Y=0;oe.forEach(L=>{let K=_.get(L);Y=Math.max(K,Y)}),V.push([Q,Y])});let ie=S.current;z().sort((Q,oe)=>{var Y,L;let K=Q.getAttribute("id"),te=oe.getAttribute("id");return((Y=_.get(te))!=null?Y:0)-((L=_.get(K))!=null?L:0)}).forEach(Q=>{let oe=Q.closest(Ba);oe?oe.appendChild(Q.parentElement===oe?Q:Q.closest(`${Ba} > *`)):ie.appendChild(Q.parentElement===ie?Q:Q.closest(`${Ba} > *`))}),V.sort((Q,oe)=>oe[1]-Q[1]).forEach(Q=>{var oe;let Y=(oe=S.current)==null?void 0:oe.querySelector(`${fo}[${Cr}="${encodeURIComponent(Q[0])}"]`);Y==null||Y.parentElement.appendChild(Y)})}function H(){let _=z().find(ie=>ie.getAttribute("aria-disabled")!=="true"),V=_==null?void 0:_.getAttribute(Cr);E.setState("value",V||void 0)}function U(){var _,V,ie,Q;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let Y of r.current){let L=(V=(_=s.current.get(Y))==null?void 0:_.value)!=null?V:"",K=(Q=(ie=s.current.get(Y))==null?void 0:ie.keywords)!=null?Q:[],te=O(L,K);n.current.filtered.items.set(Y,te),te>0&&oe++}for(let[Y,L]of o.current)for(let K of L)if(n.current.filtered.items.get(K)>0){n.current.filtered.groups.add(Y);break}n.current.filtered.count=oe}function q(){var _,V,ie;let Q=P();Q&&(((_=Q.parentElement)==null?void 0:_.firstChild)===Q&&((ie=(V=Q.closest(fo))==null?void 0:V.querySelector(bC))==null||ie.scrollIntoView({block:"nearest"})),Q.scrollIntoView({block:"nearest"}))}function P(){var _;return(_=S.current)==null?void 0:_.querySelector(`${yh}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=S.current)==null?void 0:_.querySelectorAll(Sh))||[])}function I(_){let V=z()[_];V&&E.setState("value",V.getAttribute(Cr))}function D(_){var V;let ie=P(),Q=z(),oe=Q.findIndex(L=>L===ie),Y=Q[oe+_];(V=a.current)!=null&&V.loop&&(Y=oe+_<0?Q[Q.length-1]:oe+_===Q.length?Q[0]:Q[oe+_]),Y&&E.setState("value",Y.getAttribute(Cr))}function R(_){let V=P(),ie=V==null?void 0:V.closest(fo),Q;for(;ie&&!Q;)ie=_>0?AC(ie,fo):jC(ie,fo),Q=ie==null?void 0:ie.querySelector(Sh);Q?E.setState("value",Q.getAttribute(Cr)):D(_)}let A=()=>I(z().length-1),B=_=>{_.preventDefault(),_.metaKey?A():_.altKey?R(1):D(1)},W=_=>{_.preventDefault(),_.metaKey?I(0):_.altKey?R(-1):D(-1)};return m.createElement(ye.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:_=>{var V;(V=x.onKeyDown)==null||V.call(x,_);let ie=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||ie))switch(_.key){case"n":case"j":{g&&_.ctrlKey&&B(_);break}case"ArrowDown":{B(_);break}case"p":case"k":{g&&_.ctrlKey&&W(_);break}case"ArrowUp":{W(_);break}case"Home":{_.preventDefault(),I(0);break}case"End":{_.preventDefault(),A();break}case"Enter":{_.preventDefault();let Q=P();if(Q){let oe=new Event(za);Q.dispatchEvent(oe)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:RC},c),Fs(e,_=>m.createElement(kh.Provider,{value:E},m.createElement(Ch.Provider,{value:j},_))))}),yC=m.forwardRef((e,t)=>{var n,r;let o=Pt(),s=m.useRef(null),i=m.useContext(Th),a=ho(),c=Ih(e),u=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;rr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=Nh(o,s,[e.value,e.children,s],e.keywords),f=Ha(),h=Dn(k=>k.value&&k.value===d.current),p=Dn(k=>u||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);m.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(za,v),()=>k.removeEventListener(za,v)},[p,e.onSelect,e.disabled]);function v(){var k,E;b(),(E=(k=c.current).onSelect)==null||E.call(k,d.current)}function b(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:g,value:x,onSelect:w,forceMount:C,keywords:T,...S}=e;return m.createElement(ye.div,{ref:En(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:b,onClick:g?void 0:v},e.children)}),SC=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=m.useRef(null),c=m.useRef(null),u=Pt(),d=ho(),f=Dn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);rr(()=>d.group(i),[]),Nh(i,a,[e.value,e.heading,c]);let h=m.useMemo(()=>({id:i,forceMount:o}),[o]);return m.createElement(ye.div,{ref:En(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&m.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Fs(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},m.createElement(Th.Provider,{value:h},p))))}),CC=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=Dn(i=>!i.search);return!n&&!s?null:m.createElement(ye.div,{ref:En(o,t),...r,"cmdk-separator":"",role:"separator"})}),kC=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Ha(),i=Dn(u=>u.search),a=Dn(u=>u.selectedItemId),c=ho();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ye.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":a,id:c.inputId,type:"text",value:o?e.value:i,onChange:u=>{o||s.setState("search",u.target.value),n==null||n(u.target.value)}})}),TC=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),i=m.useRef(null),a=Dn(u=>u.selectedItemId),c=ho();return m.useEffect(()=>{if(i.current&&s.current){let u=i.current,d=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(f),h.unobserve(u)}}},[]),m.createElement(ye.div,{ref:En(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:c.listId},Fs(e,u=>m.createElement("div",{ref:En(i,c.listInnerRef),"cmdk-list-sizer":""},u)))}),EC=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(Ea,{open:n,onOpenChange:r},m.createElement(Ia,{container:i},m.createElement(ro,{"cmdk-overlay":"",className:o}),m.createElement(oo,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Eh,{ref:t,...a}))))}),IC=m.forwardRef((e,t)=>Dn(n=>n.filtered.count===0)?m.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),NC=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Fs(e,i=>m.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign(Eh,{List:TC,Item:yC,Input:kC,Group:SC,Separator:CC,Dialog:EC,Empty:IC,Loading:NC});function AC(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function jC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ih(e){let t=m.useRef(e);return rr(()=>{t.current=e}),t}var rr=typeof window>"u"?m.useEffect:m.useLayoutEffect;function kr(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Dn(e){let t=Ha(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Nh(e,t,n,r=[]){let o=m.useRef(),s=ho();return rr(()=>{var i;let a=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():o.current}})(),c=r.map(u=>u.trim());s.value(e,a,c),(i=t.current)==null||i.setAttribute(Cr,a),o.current=a}),o}var _C=()=>{let[e,t]=m.useState(),n=kr(()=>new Map);return rr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function MC(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Fs({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(MC(t),{ref:t.ref},n(t.props.children)):n(t)}var RC={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Ah=m.forwardRef(({className:e,...t},n)=>l.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Ah.displayName=zt.displayName;const jh=m.forwardRef(({className:e,...t},n)=>l.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[l.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),l.jsx(zt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));jh.displayName=zt.Input.displayName;const _h=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));_h.displayName=zt.List.displayName;const Mh=m.forwardRef((e,t)=>l.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Mh.displayName=zt.Empty.displayName;const Rh=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Rh.displayName=zt.Group.displayName;const PC=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));PC.displayName=zt.Separator.displayName;const Ph=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Ph.displayName=zt.Item.displayName;function Ua(e,[t,n]){return Math.min(n,Math.max(t,e))}function OC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Wa="ScrollArea",[Oh,RT]=yn(Wa),[DC,Qt]=Oh(Wa),Dh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[b,g]=m.useState(null),[x,w]=m.useState(0),[C,T]=m.useState(0),[S,k]=m.useState(!1),[E,j]=m.useState(!1),O=ze(t,H=>c(H)),F=Do(o);return l.jsx(DC,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:k,scrollbarY:b,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:T,children:l.jsx(ye.div,{dir:F,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Dh.displayName=Wa;var Lh="ScrollAreaViewport",$h=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(Lh,n),a=m.useRef(null),c=ze(t,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),l.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});$h.displayName=Lh;var bn="ScrollAreaScrollbar",Va=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(bn,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"?l.jsx(LC,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx($C,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(Fh,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(qa,{...r,ref:t}):null});Va.displayName=bn;var LC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(bn,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const u=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),l.jsx(Yt,{present:n||s,children:l.jsx(Fh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),$C=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(bn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Us(()=>c("SCROLL_END"),100),[a,c]=OC("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(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,c]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(c("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,c,i]),l.jsx(Yt,{present:n||a!=="hidden",children:l.jsx(qa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Fh=m.forwardRef((e,t)=>{const n=Qt(bn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",c=Us(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Tr(n.viewport,c),Tr(n.content,c),l.jsx(Yt,{present:r||s,children:l.jsx(qa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),qa=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(bn,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Wh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return WC(h,i.current,a,p)}return n==="horizontal"?l.jsx(FC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Vh(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"?l.jsx(BC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Vh(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}),FC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(bn,e.__scopeScrollArea),[i,a]=m.useState(),c=m.useRef(null),u=ze(t,c,s.onScrollbarXChange);return m.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(zh,{"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":Hs(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),Kh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),BC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(bn,e.__scopeScrollArea),[i,a]=m.useState(),c=m.useRef(null),u=ze(t,c,s.onScrollbarYChange);return m.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(zh,{"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":Hs(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),Kh(h,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[zC,Bh]=Oh(bn),zh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Qt(bn,n),[v,b]=m.useState(null),g=ze(t,O=>b(O)),x=m.useRef(null),w=m.useRef(""),C=p.viewport,T=r.content-r.viewport,S=It(d),k=It(c),E=Us(f,10);function j(O){if(x.current){const F=O.clientX-x.current.left,H=O.clientY-x.current.top;u({x:F,y:H})}}return m.useEffect(()=>{const O=F=>{const H=F.target;(v==null?void 0:v.contains(H))&&S(F,T)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[C,v,T,S]),m.useEffect(k,[r,k]),Tr(v,E),Tr(p.content,E),l.jsx(zC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:It(s),onThumbPointerUp:It(i),onThumbPositionChange:k,onThumbPointerDown:It(a),children:l.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),x.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(O))}),onPointerMove:pe(e.onPointerMove,j),onPointerUp:pe(e.onPointerUp,O=>{const F=O.target;F.hasPointerCapture(O.pointerId)&&F.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Bs="ScrollAreaThumb",Hh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Bh(Bs,e.__scopeScrollArea);return l.jsx(Yt,{present:n||o.hasThumb,children:l.jsx(HC,{ref:t,...r})})}),HC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(Bs,n),i=Bh(Bs,n),{onThumbPositionChange:a}=i,c=ze(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Us(()=>{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=VC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),l.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:pe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,b=f.clientY-p.top;i.onThumbPointerDown({x:v,y:b})}),onPointerUp:pe(e.onPointerUp,i.onThumbPointerUp)})});Hh.displayName=Bs;var Ka="ScrollAreaCorner",Uh=m.forwardRef((e,t)=>{const n=Qt(Ka,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(UC,{...e,ref:t}):null});Uh.displayName=Ka;var UC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(Ka,n),[s,i]=m.useState(0),[a,c]=m.useState(0),u=!!(s&&a);return Tr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),Tr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?l.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 zs(e){return e?parseInt(e,10):0}function Wh(e,t){const n=e/t;return isNaN(n)?0:n}function Hs(e){const t=Wh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function WC(e,t,n,r="ltr"){const o=Hs(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return qh([c,u],f)(e)}function Vh(e,t,n="ltr"){const r=Hs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],u=Ua(e,c);return qh([0,i],[0,a])(u)}function qh(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 Kh(e,t){return e>0&&e<t}var VC=(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 Us(e,t){const n=It(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 Tr(e,t){const n=It(t);Et(()=>{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 Gh=Dh,qC=$h,KC=Uh;const Yh=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Gh,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[l.jsx(qC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(Xh,{}),l.jsx(KC,{})]}));Yh.displayName=Gh.displayName;const Xh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Va,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:l.jsx(Hh,{className:"relative flex-1 rounded-full bg-border"})}));Xh.displayName=Va.displayName;const Ws=m.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:ne("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";const GC="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",YC="bg-slate-700 border-slate-600 hover:bg-slate-600",XC="bg-slate-600 border-slate-500";function JC({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:c,onShare:u,onDelete:d,showEditTitle:f,showDeleteButton:h,formatDate:p,getDisplayThreadTitle:v,secondaryLine:b,itemClassName:g,activeItemClassName:x}){const w=n===e.threadId,C=t?`${x??XC}`:`${g??YC}`,T=S=>{S.stopPropagation(),o(e.threadId)};return l.jsxs("div",{onClick:T,className:`${GC} ${C}`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:w?l.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[l.jsx(Ws,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&c()},className:"h-6 text-sm",autoFocus:!0}),l.jsx(et,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:l.jsx(ae.Check,{size:12})}),l.jsx(et,{variant:"ghost",size:"sm",onClick:c,className:"h-6 w-6 p-0",children:l.jsx(ae.X,{size:12})})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),l.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[l.jsx(ae.Calendar,{size:10}),l.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),b&&l.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:b})]})}),l.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:l.jsxs(Ji,{children:[l.jsx(Zi,{asChild:!0,children:l.jsx(et,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:l.jsx(ae.MoreHorizontal,{size:12})})}),l.jsxs(ds,{align:"end",sideOffset:6,className:"w-44",children:[l.jsxs(Yn,{onClick:S=>{S.preventDefault(),u(e.threadId)},children:[l.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&l.jsxs(Yn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[l.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&l.jsxs(Yn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[l.jsx(ae.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&l.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const Jh=25,Zh="thread-manager-view",ZC=e=>e==="default"||e==="shared",QC=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Zh);if(ZC(e))return e}catch{}return null};function ek({defaultView:e}={}){const[t,n]=y.useState(()=>QC()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Zh,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const tk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Ga({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:u,onThreadDelete:d,view:f,defaultView:h,onViewChange:p,viewOptions:v,viewState:b,showHeader:g=!0,shareTargets:x,isLoadingShareTargets:w,shareTargetFilter:C}){const{threads:T,sharedThreads:S,currentThreadId:k,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:O,actions:F,shareInFlight:H,shareStatus:U,clearShareStatus:q}=Ro(),{createThread:P,deleteThread:z,renameThread:I,shareThread:D}=F,{loadThread:R}=Po(),A=i??k,[B,W]=y.useState(Array.isArray(T)?T:[]),_=y.useRef(B.length>0),V=y.useRef(null),ie=y.useRef(0),[Q,oe]=y.useState(null),[Y,L]=y.useState(""),[K,te]=y.useState(!1),[G,X]=y.useState(!1),[he,fe]=y.useState(null),[Z,le]=y.useState(""),be=v&&v.length>0?v:tk,_e=ek({defaultView:h}),Ne=b??_e,$e=f??Ne.view,Xe=y.useCallback(M=>{f||Ne.setView(M),p==null||p(M)},[f,p,Ne]),nt=be.find(M=>M.key===$e)??be[0],Ve=M=>{fe(M),le(""),X(!0)},Ke=()=>{X(!1),fe(null),le(""),q()},ot=y.useCallback(async M=>{if(!(!he||H)&&M.id)try{await D(he,M.id),setTimeout(()=>Ke(),600)}catch(se){console.error("Failed to share thread:",se)}},[Ke,H,he,D]),kt=y.useMemo(()=>{const M=x??[],se=Z.trim().toLowerCase();return se?C?M.filter(me=>C(me,se)):M.filter(me=>`${me.label} ${me.secondaryLabel??""}`.toLowerCase().includes(se)):M},[x,Z,C]),lt=$e==="shared",Te=lt?S:B,Oe=lt?O:j,at=lt?"No shared conversations yet":"No conversations yet",ht=M=>{const se=M.sharedAt?` • ${bt(M.sharedAt)}`:"";return`Shared by ${M.sharedByUserId}${se}`},Tt=M=>"sharedByUserId"in M;y.useEffect(()=>{const M=Array.isArray(T)?T:[];if(M.length>0){_.current=!0,W(M);return}j||(_.current=!1,W(M))},[T,j]),y.useEffect(()=>{if(!V.current)return;const M=V.current.querySelector("[data-radix-scroll-area-viewport]");if(!M)return;let se=null,me=null;return se=requestAnimationFrame(()=>{me=requestAnimationFrame(()=>{M.scrollTop=ie.current})}),()=>{se!==null&&cancelAnimationFrame(se),me!==null&&cancelAnimationFrame(me)}},[B]);const St=async M=>{try{E(M),await R(M),a==null||a(M),c==null||c(M)}catch(se){console.error("Failed to select thread:",se)}},Le=async()=>{try{te(!0);const M=await P();M&&(u==null||u(M),a==null||a(M))}catch(M){console.error("Failed to create thread:",M)}finally{te(!1)}},Ht=async(M,se)=>{if(se.stopPropagation(),!!confirm("Delete this thread?")){if(V.current){const me=V.current.querySelector("[data-radix-scroll-area-viewport]");me&&(ie.current=me.scrollTop)}try{await z(M),d==null||d(M)}catch(me){console.error("Failed to delete thread:",me)}}},Je=(M,se)=>{se.stopPropagation(),oe(M.threadId),L(M.title||`Thread ${M.threadId.slice(0,8)}`)},qe=async M=>{if(Y.trim())try{await I(M,Y.trim()),oe(null),L("")}catch(se){console.error("Failed to update title:",se)}},dt=()=>{oe(null),L("")},bt=M=>{if(!M)return"";try{const se=new Date(M),We=new Date().getTime()-se.getTime(),Pe=Math.floor(We/(1e3*60*60*24));return Pe===0?se.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:se.toLocaleDateString()}catch{return""}},Ue=M=>M.title||`Thread ${M.threadId.slice(0,8)}`,Ct=M=>{const se=Ue(M);return se.length<=Jh?se:`${se.slice(0,Jh)}...`};return l.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[g&&l.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&l.jsx("div",{className:"flex justify-end",children:l.jsxs(et,{onClick:Le,disabled:K||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:K?"Creating...":"New Chat",children:[l.jsx(ae.Edit3,{size:16}),l.jsx("span",{children:"New chat"})]})}),l.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[l.jsx("span",{children:"Current View"}),l.jsxs(Ji,{children:[l.jsx(Zi,{asChild:!0,children:l.jsx(et,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),l.jsx(ds,{align:"start",sideOffset:6,className:"w-40",children:be.map(M=>l.jsxs(Yn,{className:"justify-between text-[12px]",onClick:se=>{se.preventDefault(),Xe(M.key)},children:[l.jsx("span",{children:M.label}),$e===M.key&&l.jsx(ae.Check,{className:"h-3 w-3"})]},M.key))})]})]})]}),l.jsx(Yh,{ref:V,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:l.jsx("div",{className:"p-2 space-y-1 pb-4",children:Oe?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[l.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),l.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Te.length===0?l.jsxs("div",{className:"text-center py-8 text-slate-400",children:[l.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),l.jsx("p",{className:"text-sm text-slate-500",children:at})]}):Te.slice().sort((M,se)=>new Date(se.updatedAt||se.createdAt||"").getTime()-new Date(M.updatedAt||M.createdAt||"").getTime()).map(M=>l.jsx(JC,{thread:M,isActive:A===M.threadId,editingThreadId:Q,editingTitle:Y,onSelect:St,onStartEditing:Je,onEditingTitleChange:se=>L(se),onSaveEditing:qe,onCancelEditing:dt,onShare:()=>Ve(M.threadId),onDelete:Ht,showEditTitle:r,showDeleteButton:n,formatDate:bt,getDisplayThreadTitle:Ct,secondaryLine:lt&&Tt(M)?ht(M):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},M.threadId))})}),l.jsx(Yf,{open:G,onOpenChange:M=>!M&&Ke(),children:l.jsxs(Na,{className:"max-w-md p-0",children:[l.jsx(Aa,{children:l.jsx(ja,{children:"Share thread"})}),l.jsxs(Ah,{children:[l.jsx(jh,{autoFocus:!0,value:Z,onValueChange:M=>le(M),placeholder:"Search for recipients..."}),l.jsxs(_h,{children:[U&&l.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&l.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),l.jsx("span",{className:U.startsWith("Failed")?"text-red-500":U.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:U})]}),l.jsx(Mh,{children:w?l.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),kt.length>0&&l.jsx(Rh,{heading:"Recipients",children:kt.map(M=>l.jsx(Ph,{onSelect:()=>ot(M),children:l.jsxs("div",{className:"flex flex-col items-start text-sm",children:[l.jsx("span",{className:"font-medium",children:M.label}),M.secondaryLabel&&l.jsx("span",{className:"text-xs text-muted-foreground",children:M.secondaryLabel})]})},M.id))})]})]})]})})]})}const nk=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],c=a.length>0,u=y.useMemo(()=>c?[...a].reverse():[],[a,c]),d=t??(a.length?a[a.length-1].id:null);if(!c)return null;const h=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return l.jsxs("div",{className:h,onMouseEnter:s,onMouseLeave:i,children:[l.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[l.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:l.jsx("span",{children:"Timeline"})}),l.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),l.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:u.map(p=>{const v=d===p.id,b=(r==null?void 0:r.get(p.id))??null;return l.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[l.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),l.jsxs("span",{className:"flex-1",children:[l.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),l.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),b&&l.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:b,children:b})]})]},p.id)})})]}),n&&l.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function Er(e){if(!(typeof globalThis>"u"))return globalThis[e]}function rk(e){if(typeof e!="string")return;const t=e.trim();if(t)return wn(t)}function Qh(){const e=[Er("__API_BASE_URL__"),Er("__CHAT_API_BASE_URL__"),Er("__CHAT_API_URL__")];for(const t of e){const n=rk(t);if(n)return n}}function ep(){const e=[Er("__API_AUTH_TOKEN__"),Er("__CHAT_API_KEY__"),Er("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function tp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return wn(t);return wn()}function np(){const e={},t=Qh(),n=ep();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function rp(){const e=np(),t=Tn.getAuthToken(),n=Qh();return{apiBaseUrl:tp(e.baseUrl,Tn.baseUrl,n),apiKey:t||e.apiKey||ep()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const op="chat-settings";function ok(){try{const e=localStorage.getItem(op);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function sk(e){try{const t={...e,apiBaseUrl:wn(e.apiBaseUrl)};localStorage.setItem(op,JSON.stringify(t)),t.apiKey&&Tn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function ik(){const e=rp(),t=ok(),n=Tn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:tp(Tn.baseUrl,r,e.apiBaseUrl)}}function ak(e){Tn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),sk(e)}var lk="Label",sp=m.forwardRef((e,t)=>l.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())}}));sp.displayName=lk;var ip=sp;const ck=xo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),en=m.forwardRef(({className:e,...t},n)=>l.jsx(ip,{ref:n,className:ne(ck(),e),...t}));en.displayName=ip.displayName;function ap(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 lp=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"}),uk="VisuallyHidden",dk=m.forwardRef((e,t)=>l.jsx(ye.span,{...e,ref:t,style:{...lp,...e.style}}));dk.displayName=uk;var fk=[" ","Enter","ArrowUp","ArrowDown"],hk=[" ","Enter"],or="Select",[Vs,qs,pk]=gi(or),[Ir,PT]=yn(or,[pk,Yo]),Ks=Yo(),[mk,Ln]=Ir(or),[gk,xk]=Ir(or),cp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,b=Ks(t),[g,x]=m.useState(null),[w,C]=m.useState(null),[T,S]=m.useState(!1),k=Do(u),[E,j]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:or}),[O,F]=dr({prop:i,defaultProp:a,onChange:c,caller:or}),H=m.useRef(null),U=g?v||!!g.closest("form"):!0,[q,P]=m.useState(new Set),z=Array.from(q).map(I=>I.props.value).join(";");return l.jsx(uu,{...b,children:l.jsxs(mk,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:T,onValueNodeHasChildrenChange:S,contentId:Pt(),value:O,onValueChange:F,open:E,onOpenChange:j,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[l.jsx(Vs.Provider,{scope:t,children:l.jsx(gk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(I=>{P(D=>new Set(D).add(I))},[]),onNativeOptionRemove:m.useCallback(I=>{P(D=>{const R=new Set(D);return R.delete(I),R})},[]),children:n})}),U?l.jsxs(Rp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:I=>F(I.target.value),disabled:h,form:v,children:[O===void 0?l.jsx("option",{value:""}):null,Array.from(q)]},z):null]})})};cp.displayName=or;var up="SelectTrigger",dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Ks(n),i=Ln(up,n),a=i.disabled||r,c=ze(t,i.onTriggerChange),u=qs(n),d=m.useRef("touch"),[f,h,p]=Op(b=>{const g=u().filter(C=>!C.disabled),x=g.find(C=>C.value===i.value),w=Dp(g,b,x);w!==void 0&&i.onValueChange(w.value)}),v=b=>{a||(i.onOpenChange(!0),p()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return l.jsx(du,{asChild:!0,...s,children:l.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":Pp(i.value)?"":void 0,...o,ref:c,onClick:pe(o.onClick,b=>{b.currentTarget.focus(),d.current!=="mouse"&&v(b)}),onPointerDown:pe(o.onPointerDown,b=>{d.current=b.pointerType;const g=b.target;g.hasPointerCapture(b.pointerId)&&g.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(v(b),b.preventDefault())}),onKeyDown:pe(o.onKeyDown,b=>{const g=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&h(b.key),!(g&&b.key===" ")&&fk.includes(b.key)&&(v(),b.preventDefault())})})})});dp.displayName=up;var fp="SelectValue",hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=Ln(fp,n),{onValueNodeHasChildrenChange:u}=c,d=s!==void 0,f=ze(t,c.onValueNodeChange);return Et(()=>{u(d)},[u,d]),l.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Pp(c.value)?l.jsx(l.Fragment,{children:i}):s})});hp.displayName=fp;var vk="SelectIcon",pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});pp.displayName=vk;var bk="SelectPortal",mp=e=>l.jsx(Xo,{asChild:!0,...e});mp.displayName=bk;var sr="SelectContent",gp=m.forwardRef((e,t)=>{const n=Ln(sr,e.__scopeSelect),[r,o]=m.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?vo.createPortal(l.jsx(xp,{scope:e.__scopeSelect,children:l.jsx(Vs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(vp,{...e,ref:t})});gp.displayName=sr;var cn=10,[xp,$n]=Ir(sr),wk="SelectContentImpl",yk=zn.createSlot("SelectContent.RemoveScroll"),vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:b,avoidCollisions:g,...x}=e,w=Ln(sr,n),[C,T]=m.useState(null),[S,k]=m.useState(null),E=ze(t,Y=>T(Y)),[j,O]=m.useState(null),[F,H]=m.useState(null),U=qs(n),[q,P]=m.useState(!1),z=m.useRef(!1);m.useEffect(()=>{if(C)return $i(C)},[C]),bi();const I=m.useCallback(Y=>{const[L,...K]=U().map(X=>X.ref.current),[te]=K.slice(-1),G=document.activeElement;for(const X of Y)if(X===G||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&S&&(S.scrollTop=0),X===te&&S&&(S.scrollTop=S.scrollHeight),X==null||X.focus(),document.activeElement!==G))return},[U,S]),D=m.useCallback(()=>I([j,C]),[I,j,C]);m.useEffect(()=>{q&&D()},[q,D]);const{onOpenChange:R,triggerPointerDownPosRef:A}=w;m.useEffect(()=>{if(C){let Y={x:0,y:0};const L=te=>{var G,X;Y={x:Math.abs(Math.round(te.pageX)-(((G=A.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(te.pageY)-(((X=A.current)==null?void 0:X.y)??0))}},K=te=>{Y.x<=10&&Y.y<=10?te.preventDefault():C.contains(te.target)||R(!1),document.removeEventListener("pointermove",L),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",K,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",K,{capture:!0})}}},[C,R,A]),m.useEffect(()=>{const Y=()=>R(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[R]);const[B,W]=Op(Y=>{const L=U().filter(G=>!G.disabled),K=L.find(G=>G.ref.current===document.activeElement),te=Dp(L,Y,K);te&&setTimeout(()=>te.ref.current.focus())}),_=m.useCallback((Y,L,K)=>{const te=!z.current&&!K;(w.value!==void 0&&w.value===L||te)&&(O(Y),te&&(z.current=!0))},[w.value]),V=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ie=m.useCallback((Y,L,K)=>{const te=!z.current&&!K;(w.value!==void 0&&w.value===L||te)&&H(Y)},[w.value]),Q=r==="popper"?Ya:bp,oe=Q===Ya?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:b,avoidCollisions:g}:{};return l.jsx(xp,{scope:n,content:C,viewport:S,onViewportChange:k,itemRefCallback:_,selectedItem:j,onItemLeave:V,itemTextRefCallback:ie,focusSelectedItem:D,selectedItemText:F,position:r,isPositioned:q,searchRef:B,children:l.jsx(ss,{as:yk,allowPinchZoom:!0,children:l.jsx($o,{asChild:!0,trapped:w.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:pe(o,Y=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),Y.preventDefault()}),children:l.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:l.jsx(Q,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:Y=>Y.preventDefault(),...x,...oe,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,Y=>{const L=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!L&&Y.key.length===1&&W(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let te=U().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const G=Y.target,X=te.indexOf(G);te=te.slice(X+1)}setTimeout(()=>I(te)),Y.preventDefault()}})})})})})})});vp.displayName=wk;var Sk="SelectItemAlignedPosition",bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Ln(sr,n),i=$n(sr,n),[a,c]=m.useState(null),[u,d]=m.useState(null),f=ze(t,E=>d(E)),h=qs(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:b,selectedItem:g,selectedItemText:x,focusSelectedItem:w}=i,C=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&b&&g&&x){const E=s.trigger.getBoundingClientRect(),j=u.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),F=x.getBoundingClientRect();if(s.dir!=="rtl"){const G=F.left-j.left,X=O.left-G,he=E.left-X,fe=E.width+he,Z=Math.max(fe,j.width),le=window.innerWidth-cn,be=Ua(X,[cn,Math.max(cn,le-Z)]);a.style.minWidth=fe+"px",a.style.left=be+"px"}else{const G=j.right-F.right,X=window.innerWidth-O.right-G,he=window.innerWidth-E.right-X,fe=E.width+he,Z=Math.max(fe,j.width),le=window.innerWidth-cn,be=Ua(X,[cn,Math.max(cn,le-Z)]);a.style.minWidth=fe+"px",a.style.right=be+"px"}const H=h(),U=window.innerHeight-cn*2,q=b.scrollHeight,P=window.getComputedStyle(u),z=parseInt(P.borderTopWidth,10),I=parseInt(P.paddingTop,10),D=parseInt(P.borderBottomWidth,10),R=parseInt(P.paddingBottom,10),A=z+I+q+R+D,B=Math.min(g.offsetHeight*5,A),W=window.getComputedStyle(b),_=parseInt(W.paddingTop,10),V=parseInt(W.paddingBottom,10),ie=E.top+E.height/2-cn,Q=U-ie,oe=g.offsetHeight/2,Y=g.offsetTop+oe,L=z+I+Y,K=A-L;if(L<=ie){const G=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const X=u.clientHeight-b.offsetTop-b.offsetHeight,he=Math.max(Q,oe+(G?V:0)+X+D),fe=L+he;a.style.height=fe+"px"}else{const G=H.length>0&&g===H[0].ref.current;a.style.top="0px";const he=Math.max(ie,z+b.offsetTop+(G?_:0)+oe)+K;a.style.height=he+"px",b.scrollTop=L-ie+b.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=B+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,b,g,x,s.dir,r]);Et(()=>C(),[C]);const[T,S]=m.useState();Et(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&v.current===!0&&(C(),w==null||w(),v.current=!1)},[C,w]);return l.jsx(kk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:l.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});bp.displayName=Sk;var Ck="SelectPopperPosition",Ya=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=Ks(n);return l.jsx(fu,{...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)"}})});Ya.displayName=Ck;var[kk,Xa]=Ir(sr,{}),Ja="SelectViewport",wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$n(Ja,n),i=Xa(Ja,n),a=ze(t,s.onViewportChange),c=m.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),l.jsx(Vs.Slot,{scope:n,children:l.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(c.current-d.scrollTop);if(p>0){const v=window.innerHeight-cn*2,b=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(b,g);if(x<v){const w=x+p,C=Math.min(v,w),T=w-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});wp.displayName=Ja;var yp="SelectGroup",[Tk,Ek]=Ir(yp),Ik=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return l.jsx(Tk,{scope:n,id:o,children:l.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ik.displayName=yp;var Sp="SelectLabel",Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ek(Sp,n);return l.jsx(ye.div,{id:o.id,...r,ref:t})});Cp.displayName=Sp;var Gs="SelectItem",[Nk,kp]=Ir(Gs),Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Ln(Gs,n),c=$n(Gs,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=ze(t,w=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,w,r,o)}),b=Pt(),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 l.jsx(Nk,{scope:n,value:r,disabled:o,textId:b,isSelected:u,onItemTextChange:m.useCallback(w=>{f(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:l.jsx(Vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(ye.div,{role:"option","aria-labelledby":b,"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:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:pe(i.onPointerDown,w=>{g.current=w.pointerType}),onPointerMove:pe(i.onPointerMove,w=>{var C;g.current=w.pointerType,o?(C=c.onItemLeave)==null||C.call(c):g.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=c.onItemLeave)==null||C.call(c))}),onKeyDown:pe(i.onKeyDown,w=>{var T;((T=c.searchRef)==null?void 0:T.current)!==""&&w.key===" "||(hk.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})});Tp.displayName=Gs;var po="SelectItemText",Ep=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Ln(po,n),a=$n(po,n),c=kp(po,n),u=xk(po,n),[d,f]=m.useState(null),h=ze(t,x=>f(x),c.onItemTextChange,x=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,x,c.value,c.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:b,onNativeOptionRemove:g}=u;return Et(()=>(b(v),()=>g(v)),[b,g,v]),l.jsxs(l.Fragment,{children:[l.jsx(ye.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?vo.createPortal(s.children,i.valueNode):null]})});Ep.displayName=po;var Ip="SelectItemIndicator",Np=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return kp(Ip,n).isSelected?l.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Np.displayName=Ip;var Za="SelectScrollUpButton",Ap=m.forwardRef((e,t)=>{const n=$n(Za,e.__scopeSelect),r=Xa(Za,e.__scopeSelect),[o,s]=m.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollTop>0;s(u)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(_p,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Ap.displayName=Za;var Qa="SelectScrollDownButton",jp=m.forwardRef((e,t)=>{const n=$n(Qa,e.__scopeSelect),r=Xa(Qa,e.__scopeSelect),[o,s]=m.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?l.jsx(_p,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});jp.displayName=Qa;var _p=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$n("SelectScrollButton",n),i=m.useRef(null),a=qs(n),c=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>c(),[c]),Et(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),l.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{c()})})}),Ak="SelectSeparator",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Mp.displayName=Ak;var el="SelectArrow",jk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ks(n),s=Ln(el,n),i=$n(el,n);return s.open&&i.position==="popper"?l.jsx(hu,{...o,...r,ref:t}):null});jk.displayName=el;var _k="SelectBubbleInput",Rp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=ze(r,o),i=ap(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(ye.select,{...n,style:{...lp,...n.style},ref:s,defaultValue:t})});Rp.displayName=_k;function Pp(e){return e===""||e===void 0}function Op(e){const t=It(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Dp(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=Mk(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const c=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function Mk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Rk=cp,Lp=dp,Pk=hp,Ok=pp,Dk=mp,$p=gp,Lk=wp,Fp=Cp,Bp=Tp,$k=Ep,Fk=Np,zp=Ap,Hp=jp,Up=Mp;const Wp=Rk,Vp=Pk,tl=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Lp,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,l.jsx(Ok,{asChild:!0,children:l.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));tl.displayName=Lp.displayName;const qp=m.forwardRef(({className:e,...t},n)=>l.jsx(zp,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));qp.displayName=zp.displayName;const Kp=m.forwardRef(({className:e,...t},n)=>l.jsx(Hp,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Kp.displayName=Hp.displayName;const nl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(Dk,{children:l.jsxs($p,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[l.jsx(qp,{}),l.jsx(Lk,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(Kp,{})]})}));nl.displayName=$p.displayName;const Bk=m.forwardRef(({className:e,...t},n)=>l.jsx(Fp,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Bk.displayName=Fp.displayName;const ir=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Bp,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Fk,{children:l.jsx(ae.Check,{className:"h-4 w-4"})})}),l.jsx($k,{children:t})]}));ir.displayName=Bp.displayName;const zk=m.forwardRef(({className:e,...t},n)=>l.jsx(Up,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));zk.displayName=Up.displayName;var Hk="Separator",Gp="horizontal",Uk=["horizontal","vertical"],Yp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Gp,...o}=e,s=Wk(r)?r:Gp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return l.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Yp.displayName=Hk;function Wk(e){return Uk.includes(e)}var Xp=Yp;const Jp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(Xp,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Jp.displayName=Xp.displayName;const Vk=Ea,qk=SS,Kk=Ia,Zp=m.forwardRef(({className:e,...t},n)=>l.jsx(ro,{className:ne("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}));Zp.displayName=ro.displayName;const Gk=xo.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"}}),Qp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(Kk,{children:[l.jsx(Zp,{}),l.jsxs(oo,{ref:o,className:ne(Gk({side:e}),t),...r,children:[n,l.jsxs(Gf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[l.jsx(ae.X,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Qp.displayName=oo.displayName;const em=({className:e,...t})=>l.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});em.displayName="SheetHeader";const tm=m.forwardRef(({className:e,...t},n)=>l.jsx(tr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));tm.displayName=tr.displayName;const nm=m.forwardRef(({className:e,...t},n)=>l.jsx(js,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));nm.displayName=js.displayName;var Ys="Switch",[Yk,OT]=yn(Ys),[Xk,Jk]=Yk(Ys),rm=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=ze(t,C=>p(C)),b=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,w]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:Ys});return l.jsxs(Xk,{scope:n,checked:x,disabled:a,children:[l.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":am(x),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:v,onClick:pe(e.onClick,C=>{w(T=>!T),g&&(b.current=C.isPropagationStopped(),b.current||C.stopPropagation())})}),g&&l.jsx(im,{control:h,bubbles:!b.current,name:r,value:c,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});rm.displayName=Ys;var om="SwitchThumb",sm=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Jk(om,n);return l.jsx(ye.span,{"data-state":am(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});sm.displayName=om;var Zk="SwitchBubbleInput",im=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=ze(i,s),c=ap(n),u=eu(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[c,n,r]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});im.displayName=Zk;function am(e){return e?"checked":"unchecked"}var lm=rm,Qk=sm;const Fn=m.forwardRef(({className:e,...t},n)=>l.jsx(lm,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:l.jsx(Qk,{className:ne("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")})}));Fn.displayName=lm.displayName;const eT={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 tT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,c]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=Ra();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{c(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{c(eT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{c(e),d(!1),o(!1)},b=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(Vk,{open:r,onOpenChange:o,children:[l.jsx(qk,{asChild:!0,children:l.jsxs(et,{variant:"outline",size:"sm",className:n,children:[l.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(Ef,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(Qp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(em,{children:[l.jsx(tm,{children:"Chat Settings"}),l.jsx(nm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(ao,{children:[l.jsx(lo,{className:"pb-3",children:l.jsxs(co,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(uo,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(en,{htmlFor:"api-url",children:"API Base URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ws,{id:"api-url",value:a.api.baseUrl,onChange:g=>c(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(et,{variant:"outline",onClick:b,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(en,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(Fn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(en,{htmlFor:"auth-token",children:"Authentication Token"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ws,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>c(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(et,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?l.jsx(ae.EyeOff,{className:"h-4 w-4"}):l.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),l.jsxs(ao,{children:[l.jsx(lo,{className:"pb-3",children:l.jsxs(co,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(uo,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(en,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Wp,{value:a.ui.layout,onValueChange:g=>c(x=>({...x,ui:{...x.ui,layout:g}})),children:[l.jsx(tl,{children:l.jsx(Vp,{})}),l.jsxs(nl,{children:[l.jsx(ir,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(ir,{value:"fullscreen",children:"Fullscreen"}),l.jsx(ir,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(en,{htmlFor:"theme",children:"Theme"}),l.jsxs(Wp,{value:a.ui.theme,onValueChange:g=>c(x=>({...x,ui:{...x.ui,theme:g}})),children:[l.jsx(tl,{children:l.jsx(Vp,{})}),l.jsxs(nl,{children:[l.jsx(ir,{value:"light",children:"Light"}),l.jsx(ir,{value:"dark",children:"Dark"}),l.jsx(ir,{value:"system",children:"System"})]})]})]}),l.jsx(Jp,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(en,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(Fn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(en,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(Fn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(en,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(Fn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(ao,{children:[l.jsx(lo,{className:"pb-3",children:l.jsxs(co,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(uo,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(en,{htmlFor:"auto-save",children:"Auto-save Conversations"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),l.jsx(Fn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(en,{htmlFor:"enable-streaming",children:"Enable Streaming"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),l.jsx(Fn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(en,{htmlFor:"typing-indicator",children:"Typing Indicator"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),l.jsx(Fn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>c(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(et,{variant:"outline",onClick:p,children:[l.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(et,{variant:"outline",onClick:v,children:"Cancel"}),l.jsxs(et,{onClick:h,disabled:!u,children:[l.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function nT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),c=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?l.jsx(Oo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsx($s,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?l.jsx(Oo,{...s,onThreadChange:c,children:l.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:l.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&l.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(Ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}):l.jsx(Oo,{...s,onThreadChange:c,children:l.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&l.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:l.jsx(Ga,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),l.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:l.jsx($s,{onError:s.onError,enableFileUpload:!0})})]})})}Ce.ChatApi=Ql,Ce.ChatInput=vc,Ce.ChatInterface=$s,Ce.ChatProviders=Oo,Ce.ChatSettings=tT,Ce.MarkdownContent=io,Ce.MessageComponent=Ls,Ce.MessageList=Da,Ce.ThreadManager=Ga,Ce.TimelineColumn=nk,Ce.applySettings=ak,Ce.buildMessagePreviewMap=Ug,Ce.chatApiClient=Tn,Ce.default=nT,Ce.del=hi,Ce.get=Gt,Ce.getChatToken=Xl,Ce.getCurrentSettings=ik,Ce.getDefaultApiConfig=np,Ce.getDefaultChatSettings=rp,Ce.onChatTokenChanged=Jl,Ce.post=_o,Ce.put=Zl,Ce.setChatToken=jo,Ce.useApi=pi,Ce.useChatStream=dc,Ce.useMessagesReducer=cc,Ce.useStream=gc,Ce.useThreadState=Po,Ce.useThreads=Ro,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
134
|
+
`}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=ah(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=ah(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 fh{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 hh{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 On{constructor(t){this.options=t||nr,this.options.renderer=this.options.renderer||new Fa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new fh,this.slugger=new hh}static parse(t,n){return new On(n).parse(t)}static parseInline(t,n){return new On(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,v,w,g,x,b,C,T,S,k;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(k=this.options.extensions.renderers[p.type].call({parser:this},p),k!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=k||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,ih(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],C=b.checked,T=b.task,x="",b.task&&(S=this.renderer.checkbox(C),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=S+" "+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=S+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:S}):x+=S),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,T,C);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<E&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
135
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}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 Ls{constructor(t){this.options=t||nr}preprocess(t){return t}postprocess(t){return t}}hm(Ls,"passThroughHooks",new Set(["preprocess","postprocess"]));function nC(e,t,n){return r=>{if(r.message+=`
|
|
136
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(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 ph(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=nC(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(QS(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&&ve.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;ve.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(ve.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&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return ph(Pn.lex,On.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},BS(ve.defaults),ve},ve.getDefaults=nh,ve.defaults=nr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.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=ve.defaults.renderer||new Fa;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=ve.defaults.tokenizer||new $a;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=ve.defaults.hooks||new Ls;for(const s in n.hooks){const i=o[s];Ls.passThroughHooks.has(s)?o[s]=a=>{if(ve.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=ve.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}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=ph(Pn.lexInline,On.parseInline),ve.Parser=On,ve.parser=On.parse,ve.Renderer=Fa,ve.TextRenderer=fh,ve.Lexer=Pn,ve.lexer=Pn.lex,ve.Tokenizer=$a,ve.Slugger=hh,ve.Hooks=Ls,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,On.parse,Pn.lex;function lo({content:e,className:t="",allowHtml:n=!1,style:r}){const o=y.useMemo(()=>{try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=y.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return c.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}const rC={MODE:"library"};function oC(){var i;const e=typeof globalThis<"u"?globalThis.process:void 0,t=typeof((i=e==null?void 0:e.env)==null?void 0:i.NODE_ENV)=="string"?e.env.NODE_ENV:void 0;if(t)return t==="production";const n=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ei&&ei.tagName.toUpperCase()==="SCRIPT"&&ei.src||new URL("index.umd.js",document.baseURI).href}<"u"?rC:void 0,r=typeof(n==null?void 0:n.MODE)=="string"?n.MODE:void 0,o=typeof(n==null?void 0:n.NODE_ENV)=="string"?n.NODE_ENV:void 0;return(r??o)==="production"}function sC(){return!oC()}function iC(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function aC(){return sC()||iC()}function lC({preview:e,idx:t}){return y.useEffect(()=>{aC()&&console.debug(`[MessageComponent] Preview ${t} mounted:`,{src:e.src.substring(0,100),alt:e.alt,label:e.label})},[t,e]),c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),c.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:c.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function cC({artifact:e}){const[t,n]=y.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=y.useState(c.jsx(ae.Clock,{className:"w-4 h-4"})),[s,i]=y.useState("Processing");return y.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(c.jsx(ae.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(c.jsx(ae.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(c.jsx(ae.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(c.jsx(ae.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),c.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"mt-1 flex-shrink-0",children:c.jsx(ae.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),c.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",c.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),c.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,c.jsx("span",{children:s})]}),e.query&&c.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[c.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),c.jsx("p",{className:"line-clamp-2",children:e.query})]}),e.progress_url&&c.jsx("div",{className:"pt-2",children:c.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[c.jsx("span",{children:"Monitor Progress"}),c.jsx(ae.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&c.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function uC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return c.jsx(cC,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}});const n=y.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>fx(o)).filter(o=>o!==null):[],[e]);return n.length>0?c.jsx("div",{className:"space-y-2",children:n.map((r,o)=>c.jsx(lC,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?c.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:c.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",c.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));co.displayName="Card";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));uo.displayName="CardHeader";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));fo.displayName="CardTitle";const mh=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));mh.displayName="CardDescription";const ho=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ho.displayName="CardContent";const gh=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));gh.displayName="CardFooter";function dC({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=dr(s);a=c.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(co,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(uo,{className:"pb-3",children:[c.jsx(fo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(mh,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(ho,{className:"pt-0 pb-3",children:a}),c.jsx(gh,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(et,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),c.jsx(et,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const fC="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function xh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:fC,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:dr(e)}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:dr(e)})}function hC({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=y.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&c.jsx(ae.Loader,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&c.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var u;return c.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[c.jsx("span",{children:((u=a.type)==null?void 0:u.replace(/\./g," "))??"progress"}),c.jsx("span",{children:a.idx??l+1})]}),a.content&&c.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),c.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&c.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&c.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function pC({message:e,viewMode:t,isStreaming:n=!1}){const o=xi(e).name||"tool",s=l=>{if(l==null)return null;const u=typeof l=="string"?gi(l)??l:l;if(u&&typeof u=="object")return c.jsx(xh,{data:u});const d=typeof u=="string"?u:(()=>{try{return dr(u)}catch{return String(u??"")}})();return c.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:u,isMarkdown:d}=sx(l);return d?c.jsx(lo,{content:u,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(f=>f.type!=="tool_call");if(!l)return c.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:c.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const h=(l.text??"").trim();if(!h)return null;const p=$r(h);return i(p)}const u=Lr(l),d=$r(u);return i(d)};return c.jsxs("div",{className:"space-y-2",children:[c.jsx(hC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function mC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=La(),[o,s]=y.useState({}),[i,a]=y.useState(null),[l,u]=y.useState(!1),d=y.useCallback(()=>{u(!1),a(null)},[]),f=y.useCallback(p=>{a(p),u(!0)},[]),h=y.useCallback(async(p,v,w)=>{var g,x;if(!t){p.preventDefault();return}if(o[w]){p.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){p.preventDefault();const T=C[1],S=v.name||`file_${T}`,k=v.mimeType||"application/octet-stream";f({id:T,name:S,mimeType:k});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[w]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const S=await yS(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const k=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");f({id:k.id,name:v.name||k.filename||`file_${k.id}`,mimeType:v.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const k=S instanceof Error?S.message:"Unknown error occurred";(x=T.update)==null||x.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(S=>({...S,[w]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[w]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function gC({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(lo,{content:e,allowHtml:!1}):c.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),c.jsx(et,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function xC({className:e}){const[t,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function vh(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const $s=y.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:u=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:h=!0,customStyles:p={},onEdit:v,onRegenerate:w,onCancelEdit:g,onCopy:x,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:S,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:j,defaultCheckpointId:O=null,messageParentCheckpointId:F=null}){const[H,U]=y.useState(!1),[K,P]=y.useState("preview"),[z,I]=y.useState(!1),{currentThreadId:D}=Do(),{respondToInterrupt:R}=Lo(),A=l==="phone"||l==="half-screen",B=t.role,W=B==="tool",_=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),V=!!_,ie=!(r&&B!=="user"),{uploadingFiles:Q,handleFileClick:oe,fileViewerOpen:Y,currentFileInfo:L,closeFileViewer:q}=mC({allowFileOpen:ie,currentThreadId:D}),te=y.useMemo(()=>{switch(B){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[B]),G=y.useMemo(()=>{if(_)return"";const M=t.content;return Array.isArray(M)?ix(M):""},[_,t]),X=y.useMemo(()=>{if(_)return{};const M=t.content;return Array.isArray(M)?xi(t):{}},[_,t]),he=y.useMemo(()=>W?!!(t.additionalKwargs??{}).toolStreaming:!1,[W,t]),fe=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="image_url"):[]},[_,t]),Z=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="file"):[]},[_,t]),le=y.useMemo(()=>{if(_)return[];const M=t.content;return Array.isArray(M)?M.filter(se=>se.type==="interrupt"):[]},[_,t]),we=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),_e=Oo(we),Ne=b==null?void 0:b.value,$e=y.useMemo(()=>{if(_)return"";const M=t.content;return Array.isArray(M)?ax(M):""},[_,t]),Xe=y.useMemo(()=>_||!h?null:t.artifact||null,[_,t,h]),nt=y.useCallback(async()=>{const M=W?$e:G;async function se(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const We=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":We})]);return}throw new Error("Clipboard API not supported in this context.")}try{await se(M),U(!0),setTimeout(()=>U(!1),2e3),x==null||x(M)}catch(me){console.error("Failed to copy:",me)}},[W,$e,G,x]),Ve=y.useCallback(()=>{if(!v)return;const M=W?$e:G,se="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,M,se)},[v,t.id,W,$e,G,t]),qe=y.useCallback(()=>{w==null||w(n)},[w,n]),ot=y.useCallback(()=>{const se=ne(A?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",te);switch(B){case"user":return c.jsx(ae.User,{className:se});case"assistant":return c.jsx(ae.Bot,{className:se});case"tool":return c.jsx(ae.Wrench,{className:se});default:return c.jsx(ae.Bot,{className:se})}},[A,te,B]),kt=y.useCallback(()=>{const M="group relative mb-4 flex w-full";switch(B){case"user":return ne(M,"justify-end");case"assistant":case"tool":case"system":return ne(M,"justify-start");default:return M}},[B]),lt=y.useCallback(()=>{const M=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",A&&"px-3 py-2 text-sm");if(V)return ne(M,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(B){case"user":return ne(M,"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 ne(M,"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 ne(M,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(M,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(M,"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")}},[A,V,B]),Te=y.useCallback(async M=>{if(C)return;const se=Oo((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!se){console.warn("Interrupt part missing id",M);return}try{T==null||T(),await R(se,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{S==null||S()}},[C,S,T,R]),Oe=y.useCallback(async M=>{if(C)return;const se=Oo((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id));if(!se){console.warn("Interrupt part missing id",M);return}try{T==null||T(),await R(se,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{S==null||S()}},[C,S,T,R]),at=y.useCallback(({part:M,i:se})=>{if(M.type==="text"){const me=M.text??"",We=me.trim(),Pe=gi(We);return Pe&&B!=="tool"?c.jsx(xh,{data:Pe},se):B==="user"&&u&&We.length>d?c.jsx(gC,{text:We,expanded:z,onExpandedChange:I,previewLength:d,isCompact:A},se):c.jsx(lo,{content:me,allowHtml:!1},se)}if(M.type==="image_url"){const me=M;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:me.url,alt:me.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},se)}if(M.type==="file"){const me=M,We=me.name||"file";return c.jsxs("a",{href:me.url,onClick:Pe=>oe(Pe.nativeEvent,me,se),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
137
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[Q[se]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[We,Q[se]?" (processing)":""]})]},se)}if(M.type==="interrupt"){const me=M,We=Oo((me==null?void 0:me.id)??(me==null?void 0:me.interrupt_id)),Pe=!!(_e&&We&&We===_e),mt=Pe?Ne??(me==null?void 0:me.value):me==null?void 0:me.value,Ze=We?{...me,id:We,interrupt_id:We}:me;return c.jsx(dC,{interruptPart:Ze,onApprove:Te,onReject:Oe,disabled:C,isActive:Pe,payload:mt},se)}return null},[oe,Q,Te,Oe,B,u,d,z,A,_e,Ne,b,C,le]),ht=y.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),Tt=y.useCallback(()=>{const M=G.trim().length>0||fe.length>0||Z.length>0||le.length>0;if(!W&&Z.length>0&&!r)return ht();if(!W&&!M&&!r)return null;if(W)return!f&&Xe?null:f?c.jsx(pC,{message:t,viewMode:K,isStreaming:he},t.id):null;if(!W&&!_){const se=t,me=c.jsx("div",{className:"space-y-2",children:se.content.map((We,Pe)=>c.jsx(at,{part:We,i:Pe},Pe))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[me,c.jsx(xC,{className:te})]}):me}},[G,fe.length,Z.length,le.length,r,W,K,f,Xe,ht,te]),St=y.useMemo(()=>_?"Assistant":lx(t),[_,t]),Le=y.useMemo(()=>_?[]:Array.isArray(k)?k:[],[k,_]),Ht=y.useMemo(()=>{var M;return Le.length?O&&Le.some(se=>se.id===O)?O:((M=Le[0])==null?void 0:M.id)??null:null},[O,Le]),Ke=y.useMemo(()=>!Le.length||!E?null:Le.some(M=>M.id===E)?E:null,[E,Le])??Ht,dt=B==="user"&&Le.length>0&&typeof j=="function",wt=y.useCallback((M,se=!1)=>{if(!j)return;const me=(M==null?void 0:M.id)??null,We=(M==null?void 0:M.parentId)??F??null;j(me,We,se)},[F,j]),Ue=y.useMemo(()=>Ke?Le.findIndex(M=>M.id===Ke):-1,[Ke,Le]),Ct=y.useMemo(()=>Ue<0?null:Le[Ue]??null,[Ue,Le]);return W&&!f&&!Xe?null:V&&_?c.jsx("div",{className:ne(kt(),p.container),children:c.jsxs("div",{className:ne(lt(),p.content),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[c.jsx(ae.Bot,{className:ne("h-4 w-4",te)}),a&&c.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),c.jsx(lo,{content:_.content,className:"text-current"})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ne(kt(),p.container),children:c.jsxs("div",{className:ne(lt(),p.content),children:[(i||a||W)&&c.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",A&&"mb-1 pb-1",te,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[ot(),a&&St&&c.jsx("span",{className:ne("font-medium",A?"text-xs":"text-sm"),children:St}),W&&c.jsxs(Rf,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",te,"border border-current/40",A&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":K==="expanded",onClick:()=>P(M=>M==="expanded"?"preview":"expanded"),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),P(se=>se==="expanded"?"preview":"expanded"))},children:[c.jsx("span",{children:X.name??"Tool Output"}),X.toolCallId&&c.jsx("span",{className:"opacity-70",children:X.toolCallId.slice(0,8)}),K==="expanded"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[dt&&Ct&&Ue>=0&&c.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue<Le.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ue>=Le.length-1)return;const M=Le[Ue+1];M&&wt(M)},"aria-label":"Older checkpoint (back in time)",disabled:Ue>=Le.length-1,children:c.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("span",{className:"whitespace-nowrap",children:[Le.length-Ue," / ",Le.length]})}),c.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ue>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ue<=0))if(Ue===1)wt(null,!0);else{const M=Le[Ue-1];M&&wt(M,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ue<=0,children:c.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&c.jsx("time",{className:ne("text-xs opacity-60",te,A&&"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:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx("div",{className:"relative",children:c.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:c.jsx(ae.Copy,{className:ne(H?"text-success":te,A?"h-3 w-3":"h-4 w-4")})})}),B==="user"&&v&&c.jsx(et,{variant:"ghost",size:"sm",onClick:Ve,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:ne(te,A?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&w&&c.jsx(et,{variant:"ghost",size:"sm",onClick:qe,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",te,A&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:ne(te,A?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsxs("div",{className:"relative",children:[Tt(),h&&Xe&&c.jsx("div",{className:"mt-3",children:c.jsx(uC,{artifact:Xe,idx:0})})]}),W&&K==="expanded"&&(X.toolCallId||X.name)&&c.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",A&&"text-xs"),children:[X.name&&c.jsxs("div",{children:["Function: ",X.name]}),X.toolCallId&&c.jsxs("div",{children:["Call ID: ",X.toolCallId]})]}),!(i||a||W)&&s&&!o&&c.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(et,{variant:"ghost",size:"sm",onClick:()=>nt(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:ne(H?"text-success":"text-current",A?"h-3 w-3":"h-4 w-4")})}),B==="user"&&v&&c.jsx(et,{variant:"ghost",size:"sm",onClick:Ve,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:ne("text-current",A?"h-3 w-3":"h-4 w-4")})}),B==="assistant"&&w&&c.jsx(et,{variant:"ghost",size:"sm",onClick:qe,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",A&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:ne("text-current",A?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&c.jsx(FS,{isOpen:Y,onClose:q,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,u,d,f,h,p,v,w;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uc(e.message)===uc(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","attemptMeta"].every(g=>e[g]===t[g]),s=((l=e.customStyles)==null?void 0:l.container)===((u=t.customStyles)==null?void 0:u.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((h=e.customStyles)==null?void 0:h.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((w=t.customStyles)==null?void 0:w.header);if(!o||!s)return!1;const i=vh(e.message),a=vh(t.message);return i.length===a.length});$s.displayName="MessageComponent";function vC(e,t){return y.useMemo(()=>{var d,f,h,p,v;const n=e&&"type"in e&&e.type==="default_message";let r=[],o=null,s={},i={},a=null,l=null,u=null;if(!n&&e){const w=e,g=w.checkpointId??null;s=w.additionalKwargs??{},i=w.responseMetadata??{};const x=g&&t.checkpointMetaById?t.checkpointMetaById.get(g)??null:null;a=typeof s.step=="number"?s.step:typeof i.step=="number"?i.step:(x==null?void 0:x.step)??null;const b=typeof s.source=="string"?s.source:typeof i.source=="string"?i.source:(x==null?void 0:x.source)??null;l=b?String(b):null;const C=a!==null&&l?`${a}:${l}`:null;if(C&&((d=t.checkpointIndexByKey)!=null&&d.has(C))?r=t.checkpointIndexByKey.get(C)??[]:g&&x&&(r=[x]),o=g??((f=r[0])==null?void 0:f.id)??null,u=g?((h=t.attemptMetaById)==null?void 0:h.get(g))??null:null,!u&&(e==null?void 0:e.role)==="user"&&(e!=null&&e.id)&&t.userMessageIdToAttempts){const T=t.userMessageIdToAttempts.get(e.id);if(T&&T.length>0){const S=T[0].checkpointId;u=((p=t.attemptMetaById)==null?void 0:p.get(S))??null,u&&console.log(`[useMessageMetadata] Found attempt by user message ID "${e.id}":`,T.length,"versions")}}if(!u&&r.length>0&&t.attemptMetaById){const T=t.attemptMetaById.get(r[0].id);T&&(u=T)}if(u&&u.attemptCount>1&&t.attemptMetaById){const T=u.baseUserMessageId;if(T){const S=[];for(const[k,E]of t.attemptMetaById.entries())if(E.baseUserMessageId===T){const j=(v=t.checkpointMetaById)==null?void 0:v.get(k);j&&S.push(j)}S.length>0&&(r=S)}}if(u&&u.attemptCount>1&&t.checkpointMetaById&&t.attemptMetaById){const T=[];for(const[S,k]of t.checkpointMetaById.entries()){const E=t.attemptMetaById.get(S);E&&E.attemptCount===u.attemptCount&&E.baseUserMessageId===u.baseUserMessageId&&T.push(k)}T.sort((S,k)=>{const E=S.createdAt?Date.parse(S.createdAt):0;return(k.createdAt?Date.parse(k.createdAt):0)-E}),T.length>0&&(r=T,console.log("[useMessageMetadata] Populated checkpointCandidates with all attempts:",{messageId:e.id,attemptCount:u.attemptCount,candidateIds:r.map(S=>S.id)}))}}return{checkpointCandidates:r,defaultCheckpointId:o,attemptMeta:u,resolvedStep:a,resolvedSource:l}},[e,t.checkpointMetaById,t.checkpointIndexByKey,t.attemptMetaById,t.userMessageIdToAttempts])}const wh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,bh=y.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:u,onRegenerate:d,onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:w,showToolMessages:g,showArtifactPreviews:x,checkpointMetaById:b,checkpointIndexByKey:C,attemptMetaById:T,userMessageIdToAttempts:S,activeCheckpointId:k,onSelectCheckpoint:E}){const j=wh(t,n),O="type"in t&&t.type==="default_message",H=!!t.__syntheticStreaming,{checkpointCandidates:U,defaultCheckpointId:K,attemptMeta:P}=vC(t,{checkpointMetaById:b,checkpointIndexByKey:C,attemptMetaById:T,userMessageIdToAttempts:S}),z=t&&!O?t.additionalKwargs??{}:{},I=t&&!O?t.responseMetadata??{}:{},D=(()=>{if(typeof z.parentCheckpointId=="string")return z.parentCheckpointId;if(typeof I.parentCheckpointId=="string")return I.parentCheckpointId})();return c.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":j,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx($s,{message:t,messageIndex:n,isStreamingMessage:H||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:u,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:h,disableInterruptActions:p,onInterruptActionStart:v,onInterruptActionEnd:w,showToolMessages:g,showArtifactPreviews:x,checkpointCandidates:U,activeCheckpointId:k??null,onSelectCheckpoint:E,defaultCheckpointId:K,messageParentCheckpointId:D,attemptMeta:P})})});bh.displayName="MessageRow";const Ba=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:w=!1,onScrollAway:g,onAtBottom:x,activeInterrupt:b,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:S,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointMetaById:j,checkpointIndexByKey:O,attemptMetaById:F,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K,createSyntheticThinkingMessage:P=!0},z)=>{const I=y.useRef(null),D=y.useRef(null),R=y.useRef(!1),A=y.useRef(!1),[B,W]=y.useState(!0),_=y.useMemo(()=>b?e.some(Z=>"type"in Z&&Z.type==="default_message"?!1:Array.isArray(Z==null?void 0:Z.content)&&Z.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),V=y.useMemo(()=>{if(!b||_)return null;const Z=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let le;const we=b.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const _e=we.title;typeof _e=="string"&&_e.trim()&&(le=_e.trim())}return{id:`interrupt-${Z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Z,value:we,title:le}]}},[b,_]),ie=y.useMemo(()=>V?[...e,V]:e,[e,V]),Q=y.useMemo(()=>!P||!t?ie:!ie.some(le=>le.role==="assistant")&&ie.length>0?[...ie,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:ie,[ie,t,P]),oe=y.useMemo(()=>k?Q:Q.filter(Z=>(Z==null?void 0:Z.role)!=="tool"),[Q,k]),Y=y.useCallback(Z=>{W(Z),g&&g(!Z),x&&x(Z)},[g,x]),L=y.useMemo(()=>{if(a)return async()=>{if(!R.current){R.current=!0;try{await a()}finally{R.current=!1}}}},[a]),q=y.useMemo(()=>!v||w?!1:B?"auto":!1,[B,v,w]),te=y.useMemo(()=>{if(typeof p!="string")return null;const Z=p.trim();return Z?{id:"default-message",role:"assistant",type:"default_message",content:Z,createdAt:new Date().toISOString()}:null},[p]),G=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>te?c.jsx("div",{className:"p-6 h-full overflow-y-auto",children:c.jsx("div",{className:"w-full max-w-full",children:c.jsx($s,{message:te,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):c.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),he=oe.length,fe=he>0;return y.useEffect(()=>{var Z,le;if(he===0){A.current=!1;return}if(!A.current)if(A.current=!0,I.current&&oe.length>0){const we=oe.length-1;(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},[he,oe.length]),y.useImperativeHandle(z,()=>({scrollToLatest:()=>{var Z,le;if(I.current&&oe.length>0){const we=oe.length-1;(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},scrollToTop:()=>{var Z,le;I.current&&oe.length>0?(le=(Z=I.current).scrollToIndex)==null||le.call(Z,{index:0,align:"start",behavior:"auto"}):D.current&&(D.current.scrollTop=0)}}),[oe]),c.jsx("div",{className:G,style:h,children:c.jsx("div",{className:"relative flex-1 min-h-0",children:fe?c.jsx(oS,{ref:Z=>{I.current=Z},scrollerRef:Z=>{D.current=Z instanceof HTMLDivElement?Z:null},data:oe,followOutput:q,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:Y,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Z,le)=>wh(le,Z),itemContent:(Z,le)=>c.jsx(bh,{message:le,index:Z,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:u,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:T,onInterruptActionEnd:S,showToolMessages:k,showArtifactPreviews:E,checkpointMetaById:j,checkpointIndexByKey:O,attemptMetaById:F,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K})}):X()})})});Ba.displayName="MessageList";const yh={value:""};function Fs({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,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:h={},onMessageSent:p,onExcelUploadSuccess:v,onError:w}){const{api:g}=mi(),{currentThreadId:x}=Do(),{threadId:b,messages:C,isHistoryLoading:T,isLoading:S,navigateToCheckpoint:k,returnToLatest:E,checkpoint:j,checkpoints:O,interrupt:F,metadata:H,timelineCheckpoints:U,messagePreviews:K}=Lo(),{isStreaming:P,error:z,connectionState:I,submit:D,stop:R}=Cc(),A=b??x??null,B=(j==null?void 0:j.id)??null,W=(j==null?void 0:j.namespace)??null,_=(H==null?void 0:H.assemblingMessageId)??null,V=F,[ie,Q]=y.useState(!1);y.useEffect(()=>{V||Q(!1)},[V]);const oe=y.useCallback(()=>{Q(!0)},[]),Y=y.useCallback(()=>{Q(!1)},[]),L=!!V||ie,[q,te]=y.useState(null),[G,X]=y.useState(""),[he,fe]=y.useState(null),[Z,le]=y.useState(null),[we,_e]=y.useState([]),[Ne,$e]=y.useState(0),[Xe,nt]=y.useState(0),[Ve,qe]=y.useState(!1),[ot,kt]=y.useState(null),[lt,Te]=y.useState(null),[Oe,at]=y.useState(!1),[ht,Tt]=y.useState(null),St=y.useRef(!1),[Le,Ht]=y.useState(()=>yh.value),Je=y.useRef(Le),Ke=y.useRef(null),dt=y.useCallback(ge=>{yh.value=ge,Ht(ge)},[]),[wt,Ue]=y.useState(!1),Ct=y.useRef(null),{checkpointMetaById:M,checkpointIndexByKey:se,attemptMetaById:me,userMessageIdToAttempts:We}=Vy(O),Pe=U??[],mt=y.useRef(null),Ze=y.useRef(null),Nt=y.useCallback(()=>{mt.current&&(mt.current.value=""),Ze.current&&(Ze.current.value=""),$e(ge=>ge+1),nt(ge=>ge+1)},[]),xo=y.useCallback(ge=>{dt(ge)},[dt]),vo=y.useRef(!1);y.useEffect(()=>{vo.current&&!P&&(_e([]),Nt()),vo.current=P},[P,Nt]);const[Js,al]=y.useState("desktop");y.useEffect(()=>{const ge=()=>{const Se=window.innerWidth;al(Se<640?"phone":Se<1024?"tablet":"desktop")};return ge(),window.addEventListener("resize",ge),()=>window.removeEventListener("resize",ge)},[]),y.useEffect(()=>{St.current=!1},[A]),y.useEffect(()=>{Je.current=Le},[Le]),y.useEffect(()=>{if(!q){Ke.current=null;return}Ke.current===null&&(Ke.current=Je.current),dt(G??"")},[G,q,dt]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){Tt(null);return}try{const Ae=(await g.getAgent("default")).uiDefaultMessage||"";Tt(Ae||null)}catch(Se){console.warn("Failed to fetch default message:",Se),Tt(null)}})()},[g.baseUrl]),y.useEffect(()=>{z&&!Oe&&(w==null||w(z))},[z,Oe,w]);const ll=ge=>{if(ge.length>ms)return`Message too long (${ge.length}/${ms} characters)`;try{return Gy(ge),null}catch(Se){return(Se==null?void 0:Se.message)||"Invalid message"}},cl=async ge=>{const Se=ge.trim();if(!(!Se&&we.length===0)){if(Se){const Ae=ll(Se);if(Ae){le(Ae);return}}try{const Ae=q?(he==null?void 0:he.checkpointId)??B??void 0:B??void 0,Ge=q?(he==null?void 0:he.checkpointNs)??W??void 0:W??void 0;await D({text:Se||"",attachments:we},{checkpointId:Ae,checkpointNs:Ge,edit:!!q,originalMessageId:q??void 0}),p==null||p(Se),dt(""),le(null),_e([]),Nt(),te(null),X(""),fe(null)}catch(Ae){const Ge=(Ae==null?void 0:Ae.message)||"Failed to send message";le(Ge),w==null||w(Ge)}}},Zs=y.useCallback((ge,Se,Ae)=>{u&&(Ke.current=Le,te(ge),X(Se),dt(Se),le(null),fe({checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}))},[Le,u,dt]),N=y.useCallback(()=>{te(null),X(""),fe(null),le(null),dt(Ke.current??Le),Ke.current=null},[Le,dt]),ee=y.useCallback((ge,Se,Ae)=>{Zs(ge,Se,Ae)},[Zs]),ce=y.useCallback(ge=>{let Se=null;for(let tn=ge-1;tn>=0;tn--)if(C[tn].role==="user"){Se=C[tn];break}if(!Se)return;const Ae=Array.isArray(Se.content)?Se.content:[],Bn=Ae.filter(tn=>(tn==null?void 0:tn.type)==="text").map(tn=>tn.text).join("")||(()=>{try{return JSON.stringify(Ae,null,2)}catch{return String(Ae)}})();Bn&&D({text:Bn},{checkpointId:B??void 0,checkpointNs:W??void 0,edit:!0,originalMessageId:Se.id})},[C,D,B,W]),Ee=ge=>{const Se=Array.from(ge.target.files||[]);_e(Ae=>[...Ae,...Se]),ge.target.value=""},Qe=ge=>{_e(Se=>{const Ae=Se.filter((Ge,Bn)=>ge!==Bn);return Ae.length===0&&Nt(),Ae})},rt=async ge=>{const Se=(ge.target.files||[])[0];if(Se){kt(null),Te(null),qe(!0);try{await D({attachments:[Se]},{checkpointId:B??void 0,checkpointNs:W??void 0});const Ae=`Uploaded ${Se.name} - processing through chat stream`;Te(Ae)}catch(Ae){const Ge=Ae instanceof Error?Ae.message:"Failed to upload Excel file";console.error("Excel upload failed",Ae),kt(Ge),w==null||w(Ge)}finally{qe(!1),ge.target.value="",Nt()}}},Be=async ge=>{if(x){Ue(!0);try{if(!ge){await E(),requestAnimationFrame(()=>{var Ge;(Ge=Ct.current)==null||Ge.scrollToLatest()});return}const Se=O.find(Ge=>Ge.checkpointId===ge),Ae=(Se==null?void 0:Se.checkpointNs)??null;await k(ge,Ae),requestAnimationFrame(()=>{var Ge;(Ge=Ct.current)==null||Ge.scrollToTop()})}finally{Ue(!1)}}},Fe=y.useCallback(async(ge,Se,Ae)=>{await Be(Ae?null:ge)},[Be]),At=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,pt=`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 ${h.messagesArea||""}`,gt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return c.jsxs("div",{className:At,children:[!!z&&!Oe&&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:z}),c.jsx(et,{variant:"ghost",size:"sm",onClick:()=>at(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),c.jsxs("div",{className:`relative ${pt}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Ba,{ref:Ct,className:"h-full",style:{height:"100%"},messages:C,isStreaming:P,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Js,enableMessageEditing:u,editingMessageId:q,onEdit:ee,onRegenerate:ce,onCancelEdit:N,emptyMessage:ht??void 0,isNavigatingCheckpoint:wt,activeInterrupt:V,disableInterruptActions:ie,onInterruptActionStart:oe,onInterruptActionEnd:Y,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:M,checkpointIndexByKey:se,attemptMetaById:me,userMessageIdToAttempts:We,activeCheckpointId:B,onSelectCheckpoint:Fe,timelineCheckpoints:Pe,messagePreviews:K,createSyntheticThinkingMessage:!0}),(I==="reconnecting"||I==="connecting")&&c.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),I==="reconnecting"?"Reconnecting…":"Connecting…"]})}),I==="error"&&c.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),S&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(T||wt)&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),c.jsxs("div",{className:gt,children:[q&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(et,{variant:"ghost",size:"sm",onClick:N,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:mt,type:"file",multiple:!0,onChange:ge=>Ee(ge),className:"hidden"},Ne),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((ge,Se)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ge.name}),c.jsx(et,{variant:"ghost",size:"sm",onClick:()=>Qe(Se),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 ${ge.name}`,children:c.jsx(ae.X,{size:12})})]},Se))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Ze,type:"file",accept:".xls,.xlsx,.xlsm",onChange:rt,className:"hidden"},Xe),Ve&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),lt&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:lt}),ot&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ot})]})]}),Z&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Z}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(na,{children:[c.jsx(ra,{asChild:!0,children:c.jsx(et,{type:"button",size:"icon",variant:"outline",disabled:P||L,title:"More input actions",className:h.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(ps,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(Yn,{onClick:()=>{var ge;return(ge=mt.current)==null?void 0:ge.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Yn,{onClick:()=>{var ge;Ve||(ge=Ze.current)==null||ge.click()},className:`cursor-pointer ${Ve?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(Lx,{initialValue:G,editingMessageId:q,value:Le,onValueChange:xo,placeholder:q?"Edit your message...":t,isStreaming:P,disabled:L,maxLength:ms,onSend:cl,onCancelEdit:N,onStop:R,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${q?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${Z?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var Sh=1,wC=.9,bC=.8,yC=.17,za=.1,Ha=.999,SC=.9999,CC=.99,kC=/[\\\/_+.#"@\[\(\{&]/,TC=/[\\\/_+.#"@\[\(\{&]/g,EC=/[\s-]/,Ch=/[\s-]/g;function Ua(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Sh:CC;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),u=n.indexOf(l,o),d=0,f,h,p,v;u>=0;)f=Ua(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=Sh:kC.test(e.charAt(u-1))?(f*=bC,p=e.slice(o,u-1).match(TC),p&&o>0&&(f*=Math.pow(Ha,p.length))):EC.test(e.charAt(u-1))?(f*=wC,v=e.slice(o,u-1).match(Ch),v&&o>0&&(f*=Math.pow(Ha,v.length))):(f*=yC,o>0&&(f*=Math.pow(Ha,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=SC)),(f<za&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Ua(e,t,n,r,u+1,s+2,i),h*za>f&&(f=h*za)),f>d&&(d=f),u=n.indexOf(l,u+1);return i[a]=d,d}function kh(e){return e.toLowerCase().replace(Ch," ")}function IC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Ua(e,t,kh(e),kh(t),0,0,{})}var po='[cmdk-group=""]',Wa='[cmdk-group-items=""]',NC='[cmdk-group-heading=""]',Th='[cmdk-item=""]',Eh=`${Th}:not([aria-disabled="true"])`,Va="cmdk-item-select",kr="data-value",AC=(e,t,n)=>IC(e,t,n),Ih=m.createContext(void 0),mo=()=>m.useContext(Ih),Nh=m.createContext(void 0),Ka=()=>m.useContext(Nh),Ah=m.createContext(void 0),jh=m.forwardRef((e,t)=>{let n=Tr(()=>{var _,V;return{search:"",value:(V=(_=e.value)!=null?_:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Tr(()=>new Set),o=Tr(()=>new Map),s=Tr(()=>new Map),i=Tr(()=>new Set),a=_h(e),{label:l,children:u,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:v,disablePointerSelection:w=!1,vimBindings:g=!0,...x}=e,b=Pt(),C=Pt(),T=Pt(),S=m.useRef(null),k=BC();rr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),rr(()=>{k(6,K)},[]);let E=m.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,V,ie)=>{var Q,oe,Y,L;if(!Object.is(n.current[_],V)){if(n.current[_]=V,_==="search")U(),F(),k(1,H);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(T);q?q.focus():(Q=document.getElementById(b))==null||Q.focus()}if(k(7,()=>{var q;n.current.selectedItemId=(q=P())==null?void 0:q.id,E.emit()}),ie||k(5,K),((oe=a.current)==null?void 0:oe.value)!==void 0){let q=V??"";(L=(Y=a.current).onValueChange)==null||L.call(Y,q);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=m.useMemo(()=>({value:(_,V,ie)=>{var Q;V!==((Q=s.current.get(_))==null?void 0:Q.value)&&(s.current.set(_,{value:V,keywords:ie}),n.current.filtered.items.set(_,O(V,ie)),k(2,()=>{F(),E.emit()}))},item:(_,V)=>(r.current.add(_),V&&(o.current.has(V)?o.current.get(V).add(_):o.current.set(V,new Set([_]))),k(3,()=>{U(),F(),n.current.value||H(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let ie=P();k(4,()=>{U(),(ie==null?void 0:ie.getAttribute("id"))===_&&H(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:T,labelId:C,listInnerRef:S}),[]);function O(_,V){var ie,Q;let oe=(Q=(ie=a.current)==null?void 0:ie.filter)!=null?Q:AC;return _?oe(_,n.current.search,V):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(Q=>{let oe=o.current.get(Q),Y=0;oe.forEach(L=>{let q=_.get(L);Y=Math.max(q,Y)}),V.push([Q,Y])});let ie=S.current;z().sort((Q,oe)=>{var Y,L;let q=Q.getAttribute("id"),te=oe.getAttribute("id");return((Y=_.get(te))!=null?Y:0)-((L=_.get(q))!=null?L:0)}).forEach(Q=>{let oe=Q.closest(Wa);oe?oe.appendChild(Q.parentElement===oe?Q:Q.closest(`${Wa} > *`)):ie.appendChild(Q.parentElement===ie?Q:Q.closest(`${Wa} > *`))}),V.sort((Q,oe)=>oe[1]-Q[1]).forEach(Q=>{var oe;let Y=(oe=S.current)==null?void 0:oe.querySelector(`${po}[${kr}="${encodeURIComponent(Q[0])}"]`);Y==null||Y.parentElement.appendChild(Y)})}function H(){let _=z().find(ie=>ie.getAttribute("aria-disabled")!=="true"),V=_==null?void 0:_.getAttribute(kr);E.setState("value",V||void 0)}function U(){var _,V,ie,Q;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let Y of r.current){let L=(V=(_=s.current.get(Y))==null?void 0:_.value)!=null?V:"",q=(Q=(ie=s.current.get(Y))==null?void 0:ie.keywords)!=null?Q:[],te=O(L,q);n.current.filtered.items.set(Y,te),te>0&&oe++}for(let[Y,L]of o.current)for(let q of L)if(n.current.filtered.items.get(q)>0){n.current.filtered.groups.add(Y);break}n.current.filtered.count=oe}function K(){var _,V,ie;let Q=P();Q&&(((_=Q.parentElement)==null?void 0:_.firstChild)===Q&&((ie=(V=Q.closest(po))==null?void 0:V.querySelector(NC))==null||ie.scrollIntoView({block:"nearest"})),Q.scrollIntoView({block:"nearest"}))}function P(){var _;return(_=S.current)==null?void 0:_.querySelector(`${Th}[aria-selected="true"]`)}function z(){var _;return Array.from(((_=S.current)==null?void 0:_.querySelectorAll(Eh))||[])}function I(_){let V=z()[_];V&&E.setState("value",V.getAttribute(kr))}function D(_){var V;let ie=P(),Q=z(),oe=Q.findIndex(L=>L===ie),Y=Q[oe+_];(V=a.current)!=null&&V.loop&&(Y=oe+_<0?Q[Q.length-1]:oe+_===Q.length?Q[0]:Q[oe+_]),Y&&E.setState("value",Y.getAttribute(kr))}function R(_){let V=P(),ie=V==null?void 0:V.closest(po),Q;for(;ie&&!Q;)ie=_>0?$C(ie,po):FC(ie,po),Q=ie==null?void 0:ie.querySelector(Eh);Q?E.setState("value",Q.getAttribute(kr)):D(_)}let A=()=>I(z().length-1),B=_=>{_.preventDefault(),_.metaKey?A():_.altKey?R(1):D(1)},W=_=>{_.preventDefault(),_.metaKey?I(0):_.altKey?R(-1):D(-1)};return m.createElement(ye.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:_=>{var V;(V=x.onKeyDown)==null||V.call(x,_);let ie=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||ie))switch(_.key){case"n":case"j":{g&&_.ctrlKey&&B(_);break}case"ArrowDown":{B(_);break}case"p":case"k":{g&&_.ctrlKey&&W(_);break}case"ArrowUp":{W(_);break}case"Home":{_.preventDefault(),I(0);break}case"End":{_.preventDefault(),A();break}case"Enter":{_.preventDefault();let Q=P();if(Q){let oe=new Event(Va);Q.dispatchEvent(oe)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:HC},l),Bs(e,_=>m.createElement(Nh.Provider,{value:E},m.createElement(Ih.Provider,{value:j},_))))}),jC=m.forwardRef((e,t)=>{var n,r;let o=Pt(),s=m.useRef(null),i=m.useContext(Ah),a=mo(),l=_h(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;rr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=Mh(o,s,[e.value,e.children,s],e.keywords),f=Ka(),h=Dn(k=>k.value&&k.value===d.current),p=Dn(k=>u||a.filter()===!1?!0:k.search?k.filtered.items.get(o)>0:!0);m.useEffect(()=>{let k=s.current;if(!(!k||e.disabled))return k.addEventListener(Va,v),()=>k.removeEventListener(Va,v)},[p,e.onSelect,e.disabled]);function v(){var k,E;w(),(E=(k=l.current).onSelect)==null||E.call(k,d.current)}function w(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:g,value:x,onSelect:b,forceMount:C,keywords:T,...S}=e;return m.createElement(ye.div,{ref:En(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:w,onClick:g?void 0:v},e.children)}),_C=m.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=m.useRef(null),l=m.useRef(null),u=Pt(),d=mo(),f=Dn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);rr(()=>d.group(i),[]),Mh(i,a,[e.value,e.heading,l]);let h=m.useMemo(()=>({id:i,forceMount:o}),[o]);return m.createElement(ye.div,{ref:En(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&m.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),Bs(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},m.createElement(Ah.Provider,{value:h},p))))}),MC=m.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=m.useRef(null),s=Dn(i=>!i.search);return!n&&!s?null:m.createElement(ye.div,{ref:En(o,t),...r,"cmdk-separator":"",role:"separator"})}),RC=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Ka(),i=Dn(u=>u.search),a=Dn(u=>u.selectedItemId),l=mo();return m.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),m.createElement(ye.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:u=>{o||s.setState("search",u.target.value),n==null||n(u.target.value)}})}),PC=m.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=m.useRef(null),i=m.useRef(null),a=Dn(u=>u.selectedItemId),l=mo();return m.useEffect(()=>{if(i.current&&s.current){let u=i.current,d=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(f),h.unobserve(u)}}},[]),m.createElement(ye.div,{ref:En(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Bs(e,u=>m.createElement("div",{ref:En(i,l.listInnerRef),"cmdk-list-sizer":""},u)))}),OC=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(ja,{open:n,onOpenChange:r},m.createElement(_a,{container:i},m.createElement(so,{"cmdk-overlay":"",className:o}),m.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(jh,{ref:t,...a}))))}),DC=m.forwardRef((e,t)=>Dn(n=>n.filtered.count===0)?m.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),LC=m.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return m.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Bs(e,i=>m.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign(jh,{List:PC,Item:jC,Input:RC,Group:_C,Separator:MC,Dialog:OC,Empty:DC,Loading:LC});function $C(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function FC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function _h(e){let t=m.useRef(e);return rr(()=>{t.current=e}),t}var rr=typeof window>"u"?m.useEffect:m.useLayoutEffect;function Tr(e){let t=m.useRef();return t.current===void 0&&(t.current=e()),t}function Dn(e){let t=Ka(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function Mh(e,t,n,r=[]){let o=m.useRef(),s=mo();return rr(()=>{var i;let a=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():o.current}})(),l=r.map(u=>u.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(kr,a),o.current=a}),o}var BC=()=>{let[e,t]=m.useState(),n=Tr(()=>new Map);return rr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function zC(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Bs({asChild:e,children:t},n){return e&&m.isValidElement(t)?m.cloneElement(zC(t),{ref:t.ref},n(t.props.children)):n(t)}var HC={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Rh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Rh.displayName=zt.displayName;const Ph=m.forwardRef(({className:e,...t},n)=>c.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[c.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),c.jsx(zt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Ph.displayName=zt.Input.displayName;const Oh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Oh.displayName=zt.List.displayName;const Dh=m.forwardRef((e,t)=>c.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Dh.displayName=zt.Empty.displayName;const Lh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Lh.displayName=zt.Group.displayName;const UC=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));UC.displayName=zt.Separator.displayName;const $h=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));$h.displayName=zt.Item.displayName;function qa(e,[t,n]){return Math.min(n,Math.max(t,e))}function WC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Ga="ScrollArea",[Fh,HT]=yn(Ga),[VC,Qt]=Fh(Ga),Bh=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),[C,T]=m.useState(0),[S,k]=m.useState(!1),[E,j]=m.useState(!1),O=ze(t,H=>l(H)),F=Fo(o);return c.jsx(VC,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:k,scrollbarY:w,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:T,children:c.jsx(ye.div,{dir:F,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Bh.displayName=Ga;var zh="ScrollAreaViewport",Hh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(zh,n),a=m.useRef(null),l=ze(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})})]})});Hh.displayName=zh;var wn="ScrollAreaScrollbar",Ya=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(wn,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(KC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(qC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Uh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Xa,{...r,ref:t}):null});Ya.displayName=wn;var KC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(wn,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(Yt,{present:n||s,children:c.jsx(Uh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),qC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ws(()=>l("SCROLL_END"),100),[a,l]=WC("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(Yt,{present:n||a!=="hidden",children:c.jsx(Xa,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:pe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:pe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Uh=m.forwardRef((e,t)=>{const n=Qt(wn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Ws(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Er(n.viewport,l),Er(n.content,l),c.jsx(Yt,{present:r||s,children:c.jsx(Xa,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Xa=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(wn,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=Gh(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 QC(h,i.current,a,p)}return n==="horizontal"?c.jsx(GC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=Yh(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(YC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=Yh(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}),GC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(wn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=ze(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Vh,{"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":Us(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),Jh(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:Hs(i.paddingLeft),paddingEnd:Hs(i.paddingRight)}})}})}),YC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(wn,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=ze(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Vh,{"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":Us(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),Jh(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:Hs(i.paddingTop),paddingEnd:Hs(i.paddingBottom)}})}})}),[XC,Wh]=Fh(wn),Vh=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=Qt(wn,n),[v,w]=m.useState(null),g=ze(t,O=>w(O)),x=m.useRef(null),b=m.useRef(""),C=p.viewport,T=r.content-r.viewport,S=It(d),k=It(l),E=Ws(f,10);function j(O){if(x.current){const F=O.clientX-x.current.left,H=O.clientY-x.current.top;u({x:F,y:H})}}return m.useEffect(()=>{const O=F=>{const H=F.target;(v==null?void 0:v.contains(H))&&S(F,T)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[C,v,T,S]),m.useEffect(k,[r,k]),Er(v,E),Er(p.content,E),c.jsx(XC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:It(s),onThumbPointerUp:It(i),onThumbPositionChange:k,onThumbPointerDown:It(a),children:c.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:pe(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),x.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(O))}),onPointerMove:pe(e.onPointerMove,j),onPointerUp:pe(e.onPointerUp,O=>{const F=O.target;F.hasPointerCapture(O.pointerId)&&F.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),zs="ScrollAreaThumb",Kh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Wh(zs,e.__scopeScrollArea);return c.jsx(Yt,{present:n||o.hasThumb,children:c.jsx(JC,{ref:t,...r})})}),JC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(zs,n),i=Wh(zs,n),{onThumbPositionChange:a}=i,l=ze(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Ws(()=>{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=ek(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:pe(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:pe(e.onPointerUp,i.onThumbPointerUp)})});Kh.displayName=zs;var Ja="ScrollAreaCorner",qh=m.forwardRef((e,t)=>{const n=Qt(Ja,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(ZC,{...e,ref:t}):null});qh.displayName=Ja;var ZC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(Ja,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Er(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Er(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),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 Hs(e){return e?parseInt(e,10):0}function Gh(e,t){const n=e/t;return isNaN(n)?0:n}function Us(e){const t=Gh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function QC(e,t,n,r="ltr"){const o=Us(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 Xh([l,u],f)(e)}function Yh(e,t,n="ltr"){const r=Us(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=qa(e,l);return Xh([0,i],[0,a])(u)}function Xh(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 Jh(e,t){return e>0&&e<t}var ek=(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 Ws(e,t){const n=It(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 Er(e,t){const n=It(t);Et(()=>{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 Zh=Bh,tk=Hh,nk=qh;const Qh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Zh,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[c.jsx(tk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ep,{}),c.jsx(nk,{})]}));Qh.displayName=Zh.displayName;const ep=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ya,{ref:r,orientation:t,className:ne("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(Kh,{className:"relative flex-1 rounded-full bg-border"})}));ep.displayName=Ya.displayName;const Vs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ne("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";const rk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",ok="bg-slate-700 border-slate-600 hover:bg-slate-600",sk="bg-slate-600 border-slate-500";function ik({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:u,onDelete:d,showEditTitle:f,showDeleteButton:h,formatDate:p,getDisplayThreadTitle:v,secondaryLine:w,itemClassName:g,activeItemClassName:x}){const b=n===e.threadId,C=t?`${x??sk}`:`${g??ok}`,T=S=>{S.stopPropagation(),o(e.threadId)};return c.jsxs("div",{onClick:T,className:`${rk} ${C}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:b?c.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[c.jsx(Vs,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),c.jsx(et,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(et,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:c.jsx(ae.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),w&&c.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:w})]})}),c.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:c.jsxs(na,{children:[c.jsx(ra,{asChild:!0,children:c.jsx(et,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:c.jsx(ae.MoreHorizontal,{size:12})})}),c.jsxs(ps,{align:"end",sideOffset:6,className:"w-44",children:[c.jsxs(Yn,{onClick:S=>{S.preventDefault(),u(e.threadId)},children:[c.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&c.jsxs(Yn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[c.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&c.jsxs(Yn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[c.jsx(ae.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const tp=25,np="thread-manager-view",ak=e=>e==="default"||e==="shared",lk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(np);if(ak(e))return e}catch{}return null};function ck({defaultView:e}={}){const[t,n]=y.useState(()=>lk()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(np,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const uk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Za({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,view:f,defaultView:h,onViewChange:p,viewOptions:v,viewState:w,showHeader:g=!0,shareTargets:x,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:T,sharedThreads:S,currentThreadId:k,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:O,actions:F,shareInFlight:H,shareStatus:U,clearShareStatus:K}=Do(),{createThread:P,deleteThread:z,renameThread:I,shareThread:D}=F,{loadThread:R}=Lo(),A=i??k,[B,W]=y.useState(Array.isArray(T)?T:[]),_=y.useRef(B.length>0),V=y.useRef(null),ie=y.useRef(0),[Q,oe]=y.useState(null),[Y,L]=y.useState(""),[q,te]=y.useState(!1),[G,X]=y.useState(!1),[he,fe]=y.useState(null),[Z,le]=y.useState(""),we=v&&v.length>0?v:uk,_e=ck({defaultView:h}),Ne=w??_e,$e=f??Ne.view,Xe=y.useCallback(M=>{f||Ne.setView(M),p==null||p(M)},[f,p,Ne]),nt=we.find(M=>M.key===$e)??we[0],Ve=M=>{fe(M),le(""),X(!0)},qe=()=>{X(!1),fe(null),le(""),K()},ot=y.useCallback(async M=>{if(!(!he||H)&&M.id)try{await D(he,M.id),setTimeout(()=>qe(),600)}catch(se){console.error("Failed to share thread:",se)}},[qe,H,he,D]),kt=y.useMemo(()=>{const M=x??[],se=Z.trim().toLowerCase();return se?C?M.filter(me=>C(me,se)):M.filter(me=>`${me.label} ${me.secondaryLabel??""}`.toLowerCase().includes(se)):M},[x,Z,C]),lt=$e==="shared",Te=lt?S:B,Oe=lt?O:j,at=lt?"No shared conversations yet":"No conversations yet",ht=M=>{const se=M.sharedAt?` • ${wt(M.sharedAt)}`:"";return`Shared by ${M.sharedByUserId}${se}`},Tt=M=>"sharedByUserId"in M;y.useEffect(()=>{const M=Array.isArray(T)?T:[];if(M.length>0){_.current=!0,W(M);return}j||(_.current=!1,W(M))},[T,j]),y.useEffect(()=>{if(!V.current)return;const M=V.current.querySelector("[data-radix-scroll-area-viewport]");if(!M)return;let se=null,me=null;return se=requestAnimationFrame(()=>{me=requestAnimationFrame(()=>{M.scrollTop=ie.current})}),()=>{se!==null&&cancelAnimationFrame(se),me!==null&&cancelAnimationFrame(me)}},[B]);const St=async M=>{try{E(M),await R(M),a==null||a(M),l==null||l(M)}catch(se){console.error("Failed to select thread:",se)}},Le=async()=>{try{te(!0);const M=await P();M&&(u==null||u(M),a==null||a(M))}catch(M){console.error("Failed to create thread:",M)}finally{te(!1)}},Ht=async(M,se)=>{if(se.stopPropagation(),!!confirm("Delete this thread?")){if(V.current){const me=V.current.querySelector("[data-radix-scroll-area-viewport]");me&&(ie.current=me.scrollTop)}try{await z(M),d==null||d(M)}catch(me){console.error("Failed to delete thread:",me)}}},Je=(M,se)=>{se.stopPropagation(),oe(M.threadId),L(M.title||`Thread ${M.threadId.slice(0,8)}`)},Ke=async M=>{if(Y.trim())try{await I(M,Y.trim()),oe(null),L("")}catch(se){console.error("Failed to update title:",se)}},dt=()=>{oe(null),L("")},wt=M=>{if(!M)return"";try{const se=new Date(M),We=new Date().getTime()-se.getTime(),Pe=Math.floor(We/(1e3*60*60*24));return Pe===0?se.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:se.toLocaleDateString()}catch{return""}},Ue=M=>M.title||`Thread ${M.threadId.slice(0,8)}`,Ct=M=>{const se=Ue(M);return se.length<=tp?se:`${se.slice(0,tp)}...`};return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[g&&c.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(et,{onClick:Le,disabled:q||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:q?"Creating...":"New Chat",children:[c.jsx(ae.Edit3,{size:16}),c.jsx("span",{children:"New chat"})]})}),c.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[c.jsx("span",{children:"Current View"}),c.jsxs(na,{children:[c.jsx(ra,{asChild:!0,children:c.jsx(et,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),c.jsx(ps,{align:"start",sideOffset:6,className:"w-40",children:we.map(M=>c.jsxs(Yn,{className:"justify-between text-[12px]",onClick:se=>{se.preventDefault(),Xe(M.key)},children:[c.jsx("span",{children:M.label}),$e===M.key&&c.jsx(ae.Check,{className:"h-3 w-3"})]},M.key))})]})]})]}),c.jsx(Qh,{ref:V,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:Oe?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Te.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:at})]}):Te.slice().sort((M,se)=>new Date(se.updatedAt||se.createdAt||"").getTime()-new Date(M.updatedAt||M.createdAt||"").getTime()).map(M=>c.jsx(ik,{thread:M,isActive:A===M.threadId,editingThreadId:Q,editingTitle:Y,onSelect:St,onStartEditing:Je,onEditingTitleChange:se=>L(se),onSaveEditing:Ke,onCancelEditing:dt,onShare:()=>Ve(M.threadId),onDelete:Ht,showEditTitle:r,showDeleteButton:n,formatDate:wt,getDisplayThreadTitle:Ct,secondaryLine:lt&&Tt(M)?ht(M):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},M.threadId))})}),c.jsx(Qf,{open:G,onOpenChange:M=>!M&&qe(),children:c.jsxs(Ma,{className:"max-w-md p-0",children:[c.jsx(Ra,{children:c.jsx(Pa,{children:"Share thread"})}),c.jsxs(Rh,{children:[c.jsx(Ph,{autoFocus:!0,value:Z,onValueChange:M=>le(M),placeholder:"Search for recipients..."}),c.jsxs(Oh,{children:[U&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&c.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{className:U.startsWith("Failed")?"text-red-500":U.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:U})]}),c.jsx(Dh,{children:b?c.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),kt.length>0&&c.jsx(Lh,{heading:"Recipients",children:kt.map(M=>c.jsx($h,{onSelect:()=>ot(M),children:c.jsxs("div",{className:"flex flex-col items-start text-sm",children:[c.jsx("span",{className:"font-medium",children:M.label}),M.secondaryLabel&&c.jsx("span",{className:"text-xs text-muted-foreground",children:M.secondaryLabel})]})},M.id))})]})]})]})})]})}const dk=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,u=y.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const h=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return c.jsxs("div",{className:h,onMouseEnter:s,onMouseLeave:i,children:[c.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[c.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:c.jsx("span",{children:"Timeline"})}),c.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),c.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:u.map(p=>{const v=d===p.id,w=(r==null?void 0:r.get(p.id))??null;return c.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[c.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),c.jsxs("span",{className:"flex-1",children:[c.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),c.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),w&&c.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:w,children:w})]})]},p.id)})})]}),n&&c.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function Ir(e){if(!(typeof globalThis>"u"))return globalThis[e]}function fk(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function rp(){const e=[Ir("__API_BASE_URL__"),Ir("__CHAT_API_BASE_URL__"),Ir("__CHAT_API_URL__")];for(const t of e){const n=fk(t);if(n)return n}}function op(){const e=[Ir("__API_AUTH_TOKEN__"),Ir("__CHAT_API_KEY__"),Ir("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function sp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function ip(){const e={},t=rp(),n=op();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ap(){const e=ip(),t=Tn.getAuthToken(),n=rp();return{apiBaseUrl:sp(e.baseUrl,Tn.baseUrl,n),apiKey:t||e.apiKey||op()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const lp="chat-settings";function hk(){try{const e=localStorage.getItem(lp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function pk(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem(lp,JSON.stringify(t)),t.apiKey&&Tn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function mk(){const e=ap(),t=hk(),n=Tn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:sp(Tn.baseUrl,r,e.apiBaseUrl)}}function gk(e){Tn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),pk(e)}var xk="Label",cp=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())}}));cp.displayName=xk;var up=cp;const vk=wo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),en=m.forwardRef(({className:e,...t},n)=>c.jsx(up,{ref:n,className:ne(vk(),e),...t}));en.displayName=up.displayName;function dp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var fp=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"}),wk="VisuallyHidden",bk=m.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...fp,...e.style}}));bk.displayName=wk;var yk=[" ","Enter","ArrowUp","ArrowDown"],Sk=[" ","Enter"],or="Select",[Ks,qs,Ck]=yi(or),[Nr,UT]=yn(or,[Ck,Zo]),Gs=Zo(),[kk,Ln]=Nr(or),[Tk,Ek]=Nr(or),hp=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=Gs(t),[g,x]=m.useState(null),[b,C]=m.useState(null),[T,S]=m.useState(!1),k=Fo(u),[E,j]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:or}),[O,F]=fr({prop:i,defaultProp:a,onChange:l,caller:or}),H=m.useRef(null),U=g?v||!!g.closest("form"):!0,[K,P]=m.useState(new Set),z=Array.from(K).map(I=>I.props.value).join(";");return c.jsx(xu,{...w,children:c.jsxs(kk,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:T,onValueNodeHasChildrenChange:S,contentId:Pt(),value:O,onValueChange:F,open:E,onOpenChange:j,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(Ks.Provider,{scope:t,children:c.jsx(Tk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(I=>{P(D=>new Set(D).add(I))},[]),onNativeOptionRemove:m.useCallback(I=>{P(D=>{const R=new Set(D);return R.delete(I),R})},[]),children:n})}),U?c.jsxs(Lp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:I=>F(I.target.value),disabled:h,form:v,children:[O===void 0?c.jsx("option",{value:""}):null,Array.from(K)]},z):null]})})};hp.displayName=or;var pp="SelectTrigger",mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Gs(n),i=Ln(pp,n),a=i.disabled||r,l=ze(t,i.onTriggerChange),u=qs(n),d=m.useRef("touch"),[f,h,p]=Fp(w=>{const g=u().filter(C=>!C.disabled),x=g.find(C=>C.value===i.value),b=Bp(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(vu,{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":$p(i.value)?"":void 0,...o,ref:l,onClick:pe(o.onClick,w=>{w.currentTarget.focus(),d.current!=="mouse"&&v(w)}),onPointerDown:pe(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:pe(o.onKeyDown,w=>{const g=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&h(w.key),!(g&&w.key===" ")&&yk.includes(w.key)&&(v(),w.preventDefault())})})})});mp.displayName=pp;var gp="SelectValue",xp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Ln(gp,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=ze(t,l.onValueNodeChange);return Et(()=>{u(d)},[u,d]),c.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:$p(l.value)?c.jsx(c.Fragment,{children:i}):s})});xp.displayName=gp;var Ik="SelectIcon",vp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});vp.displayName=Ik;var Nk="SelectPortal",wp=e=>c.jsx(Qo,{asChild:!0,...e});wp.displayName=Nk;var sr="SelectContent",bp=m.forwardRef((e,t)=>{const n=Ln(sr,e.__scopeSelect),[r,o]=m.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?bo.createPortal(c.jsx(yp,{scope:e.__scopeSelect,children:c.jsx(Ks.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Sp,{...e,ref:t})});bp.displayName=sr;var cn=10,[yp,$n]=Nr(sr),Ak="SelectContentImpl",jk=zn.createSlot("SelectContent.RemoveScroll"),Sp=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=Ln(sr,n),[C,T]=m.useState(null),[S,k]=m.useState(null),E=ze(t,Y=>T(Y)),[j,O]=m.useState(null),[F,H]=m.useState(null),U=qs(n),[K,P]=m.useState(!1),z=m.useRef(!1);m.useEffect(()=>{if(C)return Ui(C)},[C]),ki();const I=m.useCallback(Y=>{const[L,...q]=U().map(X=>X.ref.current),[te]=q.slice(-1),G=document.activeElement;for(const X of Y)if(X===G||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&S&&(S.scrollTop=0),X===te&&S&&(S.scrollTop=S.scrollHeight),X==null||X.focus(),document.activeElement!==G))return},[U,S]),D=m.useCallback(()=>I([j,C]),[I,j,C]);m.useEffect(()=>{K&&D()},[K,D]);const{onOpenChange:R,triggerPointerDownPosRef:A}=b;m.useEffect(()=>{if(C){let Y={x:0,y:0};const L=te=>{var G,X;Y={x:Math.abs(Math.round(te.pageX)-(((G=A.current)==null?void 0:G.x)??0)),y:Math.abs(Math.round(te.pageY)-(((X=A.current)==null?void 0:X.y)??0))}},q=te=>{Y.x<=10&&Y.y<=10?te.preventDefault():C.contains(te.target)||R(!1),document.removeEventListener("pointermove",L),A.current=null};return A.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",q,{capture:!0})}}},[C,R,A]),m.useEffect(()=>{const Y=()=>R(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[R]);const[B,W]=Fp(Y=>{const L=U().filter(G=>!G.disabled),q=L.find(G=>G.ref.current===document.activeElement),te=Bp(L,Y,q);te&&setTimeout(()=>te.ref.current.focus())}),_=m.useCallback((Y,L,q)=>{const te=!z.current&&!q;(b.value!==void 0&&b.value===L||te)&&(O(Y),te&&(z.current=!0))},[b.value]),V=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ie=m.useCallback((Y,L,q)=>{const te=!z.current&&!q;(b.value!==void 0&&b.value===L||te)&&H(Y)},[b.value]),Q=r==="popper"?Qa:Cp,oe=Q===Qa?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:w,avoidCollisions:g}:{};return c.jsx(yp,{scope:n,content:C,viewport:S,onViewportChange:k,itemRefCallback:_,selectedItem:j,onItemLeave:V,itemTextRefCallback:ie,focusSelectedItem:D,selectedItemText:F,position:r,isPositioned:K,searchRef:B,children:c.jsx(ls,{as:jk,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:pe(o,Y=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),Y.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(Q,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:Y=>Y.preventDefault(),...x,...oe,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:pe(x.onKeyDown,Y=>{const L=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!L&&Y.key.length===1&&W(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let te=U().filter(G=>!G.disabled).map(G=>G.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const G=Y.target,X=te.indexOf(G);te=te.slice(X+1)}setTimeout(()=>I(te)),Y.preventDefault()}})})})})})})});Sp.displayName=Ak;var _k="SelectItemAlignedPosition",Cp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Ln(sr,n),i=$n(sr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=ze(t,E=>d(E)),h=qs(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:w,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,C=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&w&&g&&x){const E=s.trigger.getBoundingClientRect(),j=u.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),F=x.getBoundingClientRect();if(s.dir!=="rtl"){const G=F.left-j.left,X=O.left-G,he=E.left-X,fe=E.width+he,Z=Math.max(fe,j.width),le=window.innerWidth-cn,we=qa(X,[cn,Math.max(cn,le-Z)]);a.style.minWidth=fe+"px",a.style.left=we+"px"}else{const G=j.right-F.right,X=window.innerWidth-O.right-G,he=window.innerWidth-E.right-X,fe=E.width+he,Z=Math.max(fe,j.width),le=window.innerWidth-cn,we=qa(X,[cn,Math.max(cn,le-Z)]);a.style.minWidth=fe+"px",a.style.right=we+"px"}const H=h(),U=window.innerHeight-cn*2,K=w.scrollHeight,P=window.getComputedStyle(u),z=parseInt(P.borderTopWidth,10),I=parseInt(P.paddingTop,10),D=parseInt(P.borderBottomWidth,10),R=parseInt(P.paddingBottom,10),A=z+I+K+R+D,B=Math.min(g.offsetHeight*5,A),W=window.getComputedStyle(w),_=parseInt(W.paddingTop,10),V=parseInt(W.paddingBottom,10),ie=E.top+E.height/2-cn,Q=U-ie,oe=g.offsetHeight/2,Y=g.offsetTop+oe,L=z+I+Y,q=A-L;if(L<=ie){const G=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const X=u.clientHeight-w.offsetTop-w.offsetHeight,he=Math.max(Q,oe+(G?V:0)+X+D),fe=L+he;a.style.height=fe+"px"}else{const G=H.length>0&&g===H[0].ref.current;a.style.top="0px";const he=Math.max(ie,z+w.offsetTop+(G?_:0)+oe)+q;a.style.height=he+"px",w.scrollTop=L-ie+w.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=B+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,w,g,x,s.dir,r]);Et(()=>C(),[C]);const[T,S]=m.useState();Et(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return c.jsx(Rk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Cp.displayName=_k;var Mk="SelectPopperPosition",Qa=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=Gs(n);return c.jsx(wu,{...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)"}})});Qa.displayName=Mk;var[Rk,el]=Nr(sr,{}),tl="SelectViewport",kp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$n(tl,n),i=el(tl,n),a=ze(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(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:pe(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-cn*2,w=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(w,g);if(x<v){const b=x+p,C=Math.min(v,b),T=b-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});kp.displayName=tl;var Tp="SelectGroup",[Pk,Ok]=Nr(Tp),Dk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return c.jsx(Pk,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Dk.displayName=Tp;var Ep="SelectLabel",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ok(Ep,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Ip.displayName=Ep;var Ys="SelectItem",[Lk,Np]=Nr(Ys),Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Ln(Ys,n),l=$n(Ys,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=ze(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),w=Pt(),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(Lk,{scope:n,value:r,disabled:o,textId:w,isSelected:u,onItemTextChange:m.useCallback(b=>{f(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ks.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.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:pe(i.onFocus,()=>p(!0)),onBlur:pe(i.onBlur,()=>p(!1)),onClick:pe(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:pe(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:pe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:pe(i.onPointerMove,b=>{var C;g.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pe(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:pe(i.onKeyDown,b=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(Sk.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});Ap.displayName=Ys;var go="SelectItemText",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Ln(go,n),a=$n(go,n),l=Np(go,n),u=Ek(go,n),[d,f]=m.useState(null),h=ze(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 Et(()=>(w(v),()=>g(v)),[w,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(ye.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?bo.createPortal(s.children,i.valueNode):null]})});jp.displayName=go;var _p="SelectItemIndicator",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Np(_p,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Mp.displayName=_p;var nl="SelectScrollUpButton",Rp=m.forwardRef((e,t)=>{const n=$n(nl,e.__scopeSelect),r=el(nl,e.__scopeSelect),[o,s]=m.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{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(Op,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Rp.displayName=nl;var rl="SelectScrollDownButton",Pp=m.forwardRef((e,t)=>{const n=$n(rl,e.__scopeSelect),r=el(rl,e.__scopeSelect),[o,s]=m.useState(!1),i=ze(t,r.onScrollButtonChange);return Et(()=>{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(Op,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pp.displayName=rl;var Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$n("SelectScrollButton",n),i=m.useRef(null),a=qs(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Et(()=>{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:pe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:pe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:pe(o.onPointerLeave,()=>{l()})})}),$k="SelectSeparator",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Dp.displayName=$k;var ol="SelectArrow",Fk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gs(n),s=Ln(ol,n),i=$n(ol,n);return s.open&&i.position==="popper"?c.jsx(bu,{...o,...r,ref:t}):null});Fk.displayName=ol;var Bk="SelectBubbleInput",Lp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=ze(r,o),i=dp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(ye.select,{...n,style:{...fp,...n.style},ref:s,defaultValue:t})});Lp.displayName=Bk;function $p(e){return e===""||e===void 0}function Fp(e){const t=It(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 Bp(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=zk(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 zk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hk=hp,zp=mp,Uk=xp,Wk=vp,Vk=wp,Hp=bp,Kk=kp,Up=Ip,Wp=Ap,qk=jp,Gk=Mp,Vp=Rp,Kp=Pp,qp=Dp;const Gp=Hk,Yp=Uk,sl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(zp,{ref:r,className:ne("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(Wk,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));sl.displayName=zp.displayName;const Xp=m.forwardRef(({className:e,...t},n)=>c.jsx(Vp,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Xp.displayName=Vp.displayName;const Jp=m.forwardRef(({className:e,...t},n)=>c.jsx(Kp,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Jp.displayName=Kp.displayName;const il=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(Vk,{children:c.jsxs(Hp,{ref:o,className:ne("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(Xp,{}),c.jsx(Kk,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Jp,{})]})}));il.displayName=Hp.displayName;const Yk=m.forwardRef(({className:e,...t},n)=>c.jsx(Up,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Yk.displayName=Up.displayName;const ir=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Wp,{ref:r,className:ne("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(Gk,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(qk,{children:t})]}));ir.displayName=Wp.displayName;const Xk=m.forwardRef(({className:e,...t},n)=>c.jsx(qp,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Xk.displayName=qp.displayName;var Jk="Separator",Zp="horizontal",Zk=["horizontal","vertical"],Qp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Zp,...o}=e,s=Qk(r)?r:Zp,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})});Qp.displayName=Jk;function Qk(e){return Zk.includes(e)}var em=Qp;const tm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(em,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));tm.displayName=em.displayName;const eT=ja,tT=_S,nT=_a,nm=m.forwardRef(({className:e,...t},n)=>c.jsx(so,{className:ne("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}));nm.displayName=so.displayName;const rT=wo.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"}}),rm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(nT,{children:[c.jsx(nm,{}),c.jsxs(io,{ref:o,className:ne(rT({side:e}),t),...r,children:[n,c.jsxs(Zf,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));rm.displayName=io.displayName;const om=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});om.displayName="SheetHeader";const sm=m.forwardRef(({className:e,...t},n)=>c.jsx(tr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));sm.displayName=tr.displayName;const im=m.forwardRef(({className:e,...t},n)=>c.jsx(_s,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));im.displayName=_s.displayName;var Xs="Switch",[oT,WT]=yn(Xs),[sT,iT]=oT(Xs),am=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=ze(t,C=>p(C)),w=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=fr({prop:o,defaultProp:s??!1,onChange:u,caller:Xs});return c.jsxs(sT,{scope:n,checked:x,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":dm(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:pe(e.onClick,C=>{b(T=>!T),g&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),g&&c.jsx(um,{control:h,bubbles:!w.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});am.displayName=Xs;var lm="SwitchThumb",cm=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=iT(lm,n);return c.jsx(ye.span,{"data-state":dm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});cm.displayName=lm;var aT="SwitchBubbleInput",um=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=ze(i,s),l=dp(n),u=au(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}})});um.displayName=aT;function dm(e){return e?"checked":"unchecked"}var fm=am,lT=cm;const Fn=m.forwardRef(({className:e,...t},n)=>c.jsx(fm,{className:ne("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(lT,{className:ne("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")})}));Fn.displayName=fm.displayName;const cT={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 uT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=y.useState(!1),[s,i]=y.useState(!1),[a,l]=y.useState(e),[u,d]=y.useState(!1),{toast:f}=La();y.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),y.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(cT),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(eT,{open:r,onOpenChange:o,children:[c.jsx(tT,{asChild:!0,children:c.jsxs(et,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(Rf,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(rm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(om,{children:[c.jsx(sm,{children:"Chat Settings"}),c.jsx(im,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(ho,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{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(et,{variant:"outline",onClick:w,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Fn,{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(en,{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(et,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ae.EyeOff,{className:"h-4 w-4"}):c.jsx(ae.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(ho,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(Gp,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(sl,{children:c.jsx(Yp,{})}),c.jsxs(il,{children:[c.jsx(ir,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(ir,{value:"fullscreen",children:"Fullscreen"}),c.jsx(ir,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(en,{htmlFor:"theme",children:"Theme"}),c.jsxs(Gp,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(sl,{children:c.jsx(Yp,{})}),c.jsxs(il,{children:[c.jsx(ir,{value:"light",children:"Light"}),c.jsx(ir,{value:"dark",children:"Dark"}),c.jsx(ir,{value:"system",children:"System"})]})]})]}),c.jsx(tm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(en,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Fn,{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(en,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Fn,{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(en,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Fn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(co,{children:[c.jsx(uo,{className:"pb-3",children:c.jsxs(fo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(ho,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(en,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Fn,{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(en,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Fn,{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(en,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Fn,{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(et,{variant:"outline",onClick:p,children:[c.jsx(ae.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(et,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(et,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function dT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=y.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx($o,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Fs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx($o,{...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(Za,{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(Fs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx($o,{...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(Za,{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(Fs,{onError:s.onError,enableFileUpload:!0})})]})})}Ce.ChatApi=rc,Ce.ChatInput=Tc,Ce.ChatInterface=Fs,Ce.ChatProviders=$o,Ce.ChatSettings=uT,Ce.MarkdownContent=lo,Ce.MessageComponent=$s,Ce.MessageList=Ba,Ce.ThreadManager=Za,Ce.TimelineColumn=dk,Ce.applySettings=gk,Ce.buildMessagePreviewMap=qg,Ce.chatApiClient=Tn,Ce.default=dT,Ce.del=pi,Ce.get=Gt,Ce.getChatToken=ec,Ce.getCurrentSettings=mk,Ce.getDefaultApiConfig=ip,Ce.getDefaultChatSettings=ap,Ce.onChatTokenChanged=tc,Ce.post=Ro,Ce.put=nc,Ce.setChatToken=Mo,Ce.useApi=mi,Ce.useChatStream=vc,Ce.useMessagesReducer=pc,Ce.useStream=Cc,Ce.useThreadState=Lo,Ce.useThreads=Do,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|