teodor-new-chat-ui 4.3.394 → 4.3.396
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1458 -1447
- package/dist/index.umd.js +29 -29
- 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,Bn,wo,hm,pm,Zs){"use strict";var uT=Object.defineProperty;var dT=(Ce,y,ae)=>y in Ce?uT(Ce,y,{enumerable:!0,configurable:!0,writable:!0,value:ae}):Ce[y]=ae;var dm=(Ce,y,ae)=>dT(Ce,typeof y!="symbol"?y+"":y,ae);var Qs=typeof document<"u"?document.currentScript:null;function ll(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=ll(y),bo=ll(Zs);var ei={exports:{}},
|
|
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,Bn,wo,hm,pm,Zs){"use strict";var uT=Object.defineProperty;var dT=(Ce,y,ae)=>y in Ce?uT(Ce,y,{enumerable:!0,configurable:!0,writable:!0,value:ae}):Ce[y]=ae;var dm=(Ce,y,ae)=>dT(Ce,typeof y!="symbol"?y+"":y,ae);var Qs=typeof document<"u"?document.currentScript:null;function ll(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=ll(y),bo=ll(Zs);var ei={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 cl;function mm(){if(cl)return
|
|
9
|
+
*/var cl;function mm(){if(cl)return Ar;cl=1;var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c,u){var d,f={},h=null,p=null;u!==void 0&&(h=""+u),c.key!==void 0&&(h=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:h,ref: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,29 +14,29 @@
|
|
|
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 ul;function gm(){return ul||(ul=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"),
|
|
17
|
+
*/var ul;function gm(){return ul||(ul=1,process.env.NODE_ENV!=="production"&&function(){var e=y,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),w=Symbol.iterator,x="@@iterator";function g(I){if(I===null||typeof I!="object")return null;var ne=w&&I[w]||I[x];return typeof ne=="function"?ne:null}var v=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(I){{for(var ne=arguments.length,ce=new Array(ne>1?ne-1:0),Ee=1;Ee<ne;Ee++)ce[Ee-1]=arguments[Ee];S("error",I,ce)}}function S(I,ne,ce){{var Ee=v.ReactDebugCurrentFrame,Ze=Ee.getStackAddendum();Ze!==""&&(ne+="%s",ce=ce.concat([Ze]));var tt=ce.map(function(Be){return String(Be)});tt.unshift("Warning: "+ne),Function.prototype.apply.call(console[I],console,tt)}}var T=!1,C=!1,k=!1,E=!1,A=!1,O;O=Symbol.for("react.module.reference");function $(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===u||I===d||E||I===p||T||C||k||typeof I=="object"&&I!==null&&(I.$$typeof===h||I.$$typeof===f||I.$$typeof===i||I.$$typeof===a||I.$$typeof===c||I.$$typeof===O||I.getModuleId!==void 0))}function H(I,ne,ce){var Ee=I.displayName;if(Ee)return Ee;var Ze=ne.displayName||ne.name||"";return Ze!==""?ce+"("+Ze+")":ce}function U(I){return I.displayName||"Context"}function K(I){if(I==null)return null;if(typeof I.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof I=="object")switch(I.$$typeof){case a:var ne=I;return U(ne)+".Consumer";case i:var ce=I;return U(ce._context)+".Provider";case c:return H(I,I.render,"ForwardRef");case f:var Ee=I.displayName||null;return Ee!==null?Ee:K(I.type)||"Memo";case h:{var Ze=I,tt=Ze._payload,Be=Ze._init;try{return K(Be(tt))}catch{return null}}}return null}var P=Object.assign,Y=0,N,D,M,j,z,W,R;function B(){}B.__reactDisabledLog=!0;function te(){{if(Y===0){N=console.log,D=console.info,M=console.warn,j=console.error,z=console.group,W=console.groupCollapsed,R=console.groupEnd;var I={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}Y++}}function J(){{if(Y--,Y===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},I,{value:N}),info:P({},I,{value:D}),warn:P({},I,{value:M}),error:P({},I,{value:j}),group:P({},I,{value:z}),groupCollapsed:P({},I,{value:W}),groupEnd:P({},I,{value:R})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=v.ReactCurrentDispatcher,G;function L(I,ne,ce){{if(G===void 0)try{throw Error()}catch(Ze){var Ee=Ze.stack.trim().match(/\n( *(at )?)/);G=Ee&&Ee[1]||""}return`
|
|
18
18
|
`+G+I}}var V=!1,Z;{var q=typeof WeakMap=="function"?WeakMap:Map;Z=new q}function X(I,ne){if(!I||V)return"";{var ce=Z.get(I);if(ce!==void 0)return ce}var Ee;V=!0;var Ze=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=re.current,re.current=null,te();try{if(ne){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(Ct){Ee=Ct}Reflect.construct(I,[],Be)}else{try{Be.call()}catch(Ct){Ee=Ct}I.call(Be.prototype)}}else{try{throw Error()}catch(Ct){Ee=Ct}I()}}catch(Ct){if(Ct&&Ee&&typeof Ct.stack=="string"){for(var Fe=Ct.stack.split(`
|
|
19
19
|
`),At=Ee.stack.split(`
|
|
20
20
|
`),pt=Fe.length-1,de=At.length-1;pt>=1&&de>=0&&Fe[pt]!==At[de];)de--;for(;pt>=1&&de>=0;pt--,de--)if(Fe[pt]!==At[de]){if(pt!==1||de!==1)do if(pt--,de--,de<0||Fe[pt]!==At[de]){var Se=`
|
|
21
|
-
`+Fe[pt].replace(" at new "," at ");return I.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",I.displayName)),typeof I=="function"&&Z.set(I,Se),Se}while(pt>=1&&de>=0);break}}}finally{V=!1,re.current=tt,J(),Error.prepareStackTrace=Ze}var Me=I?I.displayName||I.name:"",lt=Me?L(Me):"";return typeof I=="function"&&Z.set(I,lt),lt}function pe(I,ne,ce){return X(I,!1)}function he(I){var ne=I.prototype;return!!(ne&&ne.isReactComponent)}function ee(I,ne,ce){if(I==null)return"";if(typeof I=="function")return X(I,he(I));if(typeof I=="string")return L(I);switch(I){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case
|
|
21
|
+
`+Fe[pt].replace(" at new "," at ");return I.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",I.displayName)),typeof I=="function"&&Z.set(I,Se),Se}while(pt>=1&&de>=0);break}}}finally{V=!1,re.current=tt,J(),Error.prepareStackTrace=Ze}var Me=I?I.displayName||I.name:"",lt=Me?L(Me):"";return typeof I=="function"&&Z.set(I,lt),lt}function pe(I,ne,ce){return X(I,!1)}function he(I){var ne=I.prototype;return!!(ne&&ne.isReactComponent)}function ee(I,ne,ce){if(I==null)return"";if(typeof I=="function")return X(I,he(I));if(typeof I=="string")return L(I);switch(I){case u:return L("Suspense");case d:return L("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case c:return pe(I.render);case f:return ee(I.type,ne,ce);case h:{var Ee=I,Ze=Ee._payload,tt=Ee._init;try{return ee(tt(Ze),ne,ce)}catch{}}}return""}var le=Object.prototype.hasOwnProperty,we={},je=v.ReactDebugCurrentFrame;function Ne(I){if(I){var ne=I._owner,ce=ee(I.type,I._source,ne?ne.type:null);je.setExtraStackFrame(ce)}else je.setExtraStackFrame(null)}function $e(I,ne,ce,Ee,Ze){{var tt=Function.call.bind(le);for(var Be in I)if(tt(I,Be)){var Fe=void 0;try{if(typeof I[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 I[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw At.name="Invariant Violation",At}Fe=I[Be](ne,Be,Ee,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pt){Fe=pt}Fe&&!(Fe instanceof Error)&&(Ne(Ze),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(Ze),b("Failed %s type: %s",ce,Fe.message),Ne(null))}}}var Ye=Array.isArray;function nt(I){return Ye(I)}function Ve(I){{var ne=typeof Symbol=="function"&&Symbol.toStringTag,ce=ne&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ce}}function qe(I){try{return rt(I),!1}catch{return!0}}function rt(I){return""+I}function kt(I){if(qe(I))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(I)),rt(I)}var at=v.ReactCurrentOwner,Te={key:!0,ref:!0,__self:!0,__source:!0},Oe,it;function ht(I){if(le.call(I,"ref")){var ne=Object.getOwnPropertyDescriptor(I,"ref").get;if(ne&&ne.isReactWarning)return!1}return I.ref!==void 0}function Tt(I){if(le.call(I,"key")){var ne=Object.getOwnPropertyDescriptor(I,"key").get;if(ne&&ne.isReactWarning)return!1}return I.key!==void 0}function yt(I,ne){typeof I.ref=="string"&&at.current}function Le(I,ne){{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)",ne))};ce.isReactWarning=!0,Object.defineProperty(I,"key",{get:ce,configurable:!0})}}function Ht(I,ne){{var ce=function(){it||(it=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ne))};ce.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ce,configurable:!0})}}var Xe=function(I,ne,ce,Ee,Ze,tt,Be){var Fe={$$typeof:t,type:I,key:ne,ref:ce,props:Be,_owner:tt};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:Ze}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function Ke(I,ne,ce,Ee,Ze){{var tt,Be={},Fe=null,At=null;ce!==void 0&&(kt(ce),Fe=""+ce),Tt(ne)&&(kt(ne.key),Fe=""+ne.key),ht(ne)&&(At=ne.ref,yt(ne,Ze));for(tt in ne)le.call(ne,tt)&&!Te.hasOwnProperty(tt)&&(Be[tt]=ne[tt]);if(I&&I.defaultProps){var pt=I.defaultProps;for(tt in pt)Be[tt]===void 0&&(Be[tt]=pt[tt])}if(Fe||At){var de=typeof I=="function"?I.displayName||I.name||"Unknown":I;Fe&&Le(Be,de),At&&Ht(Be,de)}return Xe(I,Fe,At,Ze,Ee,at.current,Be)}}var dt=v.ReactCurrentOwner,vt=v.ReactDebugCurrentFrame;function Ue(I){if(I){var ne=I._owner,ce=ee(I.type,I._source,ne?ne.type:null);vt.setExtraStackFrame(ce)}else vt.setExtraStackFrame(null)}var St;St=!1;function _(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function ie(){{if(dt.current){var I=K(dt.current.type);if(I)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+I+"`."}return""}}function ge(I){return""}var We={};function Pe(I){{var ne=ie();if(!ne){var ce=typeof I=="string"?I:I.displayName||I.name;ce&&(ne=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ce+">.")}return ne}}function mt(I,ne){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ce=Pe(ne);if(We[ce])return;We[ce]=!0;var Ee="";I&&I._owner&&I._owner!==dt.current&&(Ee=" It was passed a child from "+K(I._owner.type)+"."),Ue(I),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 Je(I,ne){{if(typeof I!="object")return;if(nt(I))for(var ce=0;ce<I.length;ce++){var Ee=I[ce];_(Ee)&&mt(Ee,ne)}else if(_(I))I._store&&(I._store.validated=!0);else if(I){var Ze=g(I);if(typeof Ze=="function"&&Ze!==I.entries)for(var tt=Ze.call(I),Be;!(Be=tt.next()).done;)_(Be.value)&&mt(Be.value,ne)}}}function Nt(I){{var ne=I.type;if(ne==null||typeof ne=="string")return;var ce;if(typeof ne=="function")ce=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===
|
|
25
|
+
Check the top-level render call using <`+ce+">.")}return ne}}function mt(I,ne){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ce=Pe(ne);if(We[ce])return;We[ce]=!0;var Ee="";I&&I._owner&&I._owner!==dt.current&&(Ee=" It was passed a child from "+K(I._owner.type)+"."),Ue(I),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 Je(I,ne){{if(typeof I!="object")return;if(nt(I))for(var ce=0;ce<I.length;ce++){var Ee=I[ce];_(Ee)&&mt(Ee,ne)}else if(_(I))I._store&&(I._store.validated=!0);else if(I){var Ze=g(I);if(typeof Ze=="function"&&Ze!==I.entries)for(var tt=Ze.call(I),Be;!(Be=tt.next()).done;)_(Be.value)&&mt(Be.value,ne)}}}function Nt(I){{var ne=I.type;if(ne==null||typeof ne=="string")return;var ce;if(typeof ne=="function")ce=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===c||ne.$$typeof===f))ce=ne.propTypes;else return;if(ce){var Ee=K(ne);$e(ce,I.props,"prop",Ee,I)}else if(ne.PropTypes!==void 0&&!St){St=!0;var Ze=K(ne);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ze||"Unknown")}typeof ne.getDefaultProps=="function"&&!ne.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function go(I){{for(var ne=Object.keys(I.props),ce=0;ce<ne.length;ce++){var Ee=ne[ce];if(Ee!=="children"&&Ee!=="key"){Ue(I),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),Ue(null);break}}I.ref!==null&&(Ue(I),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var xo={};function Xs(I,ne,ce,Ee,Ze,tt){{var Be=$(I);if(!Be){var Fe="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).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=ge();At?Fe+=At:Fe+=ie();var pt;I===null?pt="null":nt(I)?pt="array":I!==void 0&&I.$$typeof===t?(pt="<"+(K(I.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):pt=typeof I,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 de=Ke(I,ne,ce,Ze,tt);if(de==null)return de;if(Be){var Se=ne.children;if(Se!==void 0)if(Ee)if(nt(Se)){for(var Me=0;Me<Se.length;Me++)Je(Se[Me],I);Object.freeze&&Object.freeze(Se)}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 Je(Se,I)}if(le.call(ne,"key")){var lt=K(I),Ct=Object.keys(ne).filter(function(cT){return cT!=="key"}),Ut=Ct.length>0?"{key: someKey, "+Ct.join(": ..., ")+": ...}":"{key: someKey}";if(!xo[lt+Ut]){var lT=Ct.length>0?"{"+Ct.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} />`,Ut,lt,lT,lt),xo[lt+Ut]=!0}}return I===r?go(de):Nt(de),de}}function il(I,ne,ce){return Xs(I,ne,ce,!0)}function al(I,ne,ce){return Xs(I,ne,ce,!1)}var Js=al,vo=il;Ar.Fragment=r,Ar.jsx=Js,Ar.jsxs=vo}()),Ar}process.env.NODE_ENV==="production"?ei.exports=mm():ei.exports=gm();var c=ei.exports;function dl(e,t){return function(){return e.apply(t,arguments)}}const{toString:xm}=Object.prototype,{getPrototypeOf:ti}=Object,{iterator:yo,toStringTag:fl}=Symbol,So=(e=>t=>{const n=xm.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:ir}=Array,ar=Co("undefined");function jr(e){return e!==null&&!ar(e)&&e.constructor!==null&&!ar(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hl=nn("ArrayBuffer");function vm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hl(e.buffer),t}const wm=Co("string"),Lt=Co("function"),pl=Co("number"),_r=e=>e!==null&&typeof e=="object",bm=e=>e===!0||e===!1,ko=e=>{if(So(e)!=="object")return!1;const t=ti(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(fl in e)&&!(yo in e)},ym=e=>{if(!_r(e)||jr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Sm=nn("Date"),Cm=nn("File"),km=nn("Blob"),Tm=nn("FileList"),Em=e=>_r(e)&&Lt(e.pipe),Im=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]"))},Nm=nn("URLSearchParams"),[Am,jm,_m,Mm]=["ReadableStream","Request","Response","Headers"].map(nn),Rm=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]),ir(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 ml(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 zn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gl=e=>!ar(e)&&e!==zn;function ni(){const{caseless:e,skipUndefined:t}=gl(this)&&this||{},n={},r=(o,s)=>{const i=e&&ml(n,s)||s;ko(n[i])&&ko(o)?n[i]=ni(n[i],o):ko(o)?n[i]=ni({},o):ir(o)?n[i]=o.slice():(!t||!ar(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Mr(arguments[o],r);return n}const Pm=(e,t,n,{allOwnKeys:r}={})=>(Mr(t,(o,s)=>{n&&Lt(o)?e[s]=dl(o,n):e[s]=o},{allOwnKeys:r}),e),Om=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Dm=(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)},Lm=(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},$m=(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},Fm=e=>{if(!e)return null;if(ir(e))return e;let t=e.length;if(!pl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Bm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ti(Uint8Array)),zm=(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])}},Hm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Um=nn("HTMLFormElement"),Wm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),xl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vm=nn("RegExp"),vl=(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)},Km=e=>{vl(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+"'")})}})},qm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ir(e)?r(e):r(String(e).split(t)),n},Gm=()=>{},Ym=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Xm(e){return!!(e&&Lt(e.append)&&e[fl]==="FormData"&&e[yo])}const Jm=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=ir(r)?[]:{};return Mr(r,(i,a)=>{const l=n(i,o+1);!ar(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Zm=nn("AsyncFunction"),Qm=e=>e&&(_r(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),wl=((e,t)=>e?setImmediate:t?((n,r)=>(zn.addEventListener("message",({source:o,data:s})=>{o===zn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),zn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(zn.postMessage)),eg=typeof queueMicrotask<"u"?queueMicrotask.bind(zn):typeof process<"u"&&process.nextTick||wl,F={isArray:ir,isArrayBuffer:hl,isBuffer:jr,isFormData:Im,isArrayBufferView:vm,isString:wm,isNumber:pl,isBoolean:bm,isObject:_r,isPlainObject:ko,isEmptyObject:ym,isReadableStream:Am,isRequest:jm,isResponse:_m,isHeaders:Mm,isUndefined:ar,isDate:Sm,isFile:Cm,isBlob:km,isRegExp:Vm,isFunction:Lt,isStream:Em,isURLSearchParams:Nm,isTypedArray:Bm,isFileList:Tm,forEach:Mr,merge:ni,extend:Pm,trim:Rm,stripBOM:Om,inherits:Dm,toFlatObject:Lm,kindOf:So,kindOfTest:nn,endsWith:$m,toArray:Fm,forEachEntry:zm,matchAll:Hm,isHTMLForm:Um,hasOwnProperty:xl,hasOwnProp:xl,reduceDescriptors:vl,freezeMethods:Km,toObjectSet:qm,toCamelCase:Wm,noop:Gm,toFiniteNumber:Ym,findKey:ml,global:zn,isContextDefined:gl,isSpecCompliantForm:Xm,toJSONObject:Jm,isAsyncFn:Zm,isThenable:Qm,setImmediate:wl,asap:eg,isIterable:e=>e!=null&&Lt(e[yo])};function _e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}F.inherits(_e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:F.toJSONObject(this.config),code:this.code,status:this.status}}});const bl=_e.prototype,yl={};["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=>{yl[e]={value:e}}),Object.defineProperties(_e,yl),Object.defineProperty(bl,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(bl);F.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return _e.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const tg=null;function ri(e){return F.isPlainObject(e)||F.isArray(e)}function Sl(e){return F.endsWith(e,"[]")?e.slice(0,-2):e}function Cl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Sl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ng(e){return F.isArray(e)&&!e.some(ri)}const rg=F.toFlatObject(F,{},null,function(t){return/^is[A-Z]/.test(t)});function To(e,t,n){if(!F.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=F.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!F.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&F.isSpecCompliantForm(t);if(!F.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(F.isDate(w))return w.toISOString();if(F.isBoolean(w))return w.toString();if(!l&&F.isBlob(w))throw new _e("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(w)||F.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,x,g){let v=w;if(w&&!g&&typeof w=="object"){if(F.endsWith(x,"{}"))x=r?x:x.slice(0,-2),w=JSON.stringify(w);else if(F.isArray(w)&&ng(w)||(F.isFileList(w)||F.endsWith(x,"[]"))&&(v=F.toArray(w)))return x=Sl(x),v.forEach(function(S,T){!(F.isUndefined(S)||S===null)&&t.append(i===!0?Cl([x],T,s):i===null?x:x+"[]",u(S))}),!1}return ri(w)?!0:(t.append(Cl(g,x,s),u(w)),!1)}const f=[],h=Object.assign(rg,{defaultVisitor:d,convertValue:u,isVisitable:ri});function p(w,x){if(!F.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(w),F.forEach(w,function(v,b){(!(F.isUndefined(v)||v===null)&&o.call(t,v,F.isString(b)?b.trim():b,x,h))===!0&&p(v,x?x.concat(b):[b])}),f.pop()}}if(!F.isObject(e))throw new TypeError("data must be an object");return p(e),t}function kl(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&&To(e,this,t)}const Tl=oi.prototype;Tl.append=function(t,n){this._pairs.push([t,n])},Tl.toString=function(t){const n=t?function(r){return t.call(this,r,kl)}:kl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function og(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function El(e,t,n){if(!t)return e;const r=n&&n.encode||og;F.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=F.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 Il{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){F.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sg={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,ig=si&&(!ii||["ReactNative","NativeScript","NS"].indexOf(ii.product)<0),ag=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lg=si&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:si,hasStandardBrowserEnv:ig,hasStandardBrowserWebWorkerEnv:ag,navigator:ii,origin:lg},Symbol.toStringTag,{value:"Module"})),...sg};function cg(e,t){return To(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&F.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function ug(e){return F.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dg(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 Al(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&&F.isArray(o)?o.length:i,l?(F.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!F.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&F.isArray(o[i])&&(o[i]=dg(o[i])),!a)}if(F.isFormData(e)&&F.isFunction(e.entries)){const n={};return F.forEachEntry(e,(r,o)=>{t(ug(r),o,n,0)}),n}return null}function fg(e,t,n){if(F.isString(e))try{return(t||JSON.parse)(e),F.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Rr={transitional:Nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=F.isObject(t);if(s&&F.isHTMLForm(t)&&(t=new FormData(t)),F.isFormData(t))return o?JSON.stringify(Al(t)):t;if(F.isArrayBuffer(t)||F.isBuffer(t)||F.isStream(t)||F.isFile(t)||F.isBlob(t)||F.isReadableStream(t))return t;if(F.isArrayBufferView(t))return t.buffer;if(F.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 cg(t,this.formSerializer).toString();if((a=F.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),fg(t)):t}],transformResponse:[function(t){const n=this.transitional||Rr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(F.isResponse(t)||F.isReadableStream(t))return t;if(t&&F.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData: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}}};F.forEach(["delete","get","head","post","put","patch"],e=>{Rr.headers[e]={}});const hg=F.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"]),pg=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]&&hg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jl=Symbol("internals");function
|
|
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[jl]=this[jl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Pr(i);r[a]||(vg(o,i),r[a]=!0)}return F.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),F.freezeMethods($t);function li(e,t){const n=this||Rr,r=t||n,o=$t.from(r.headers);let s=r.data;return F.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _l(e){return!!(e&&e.__CANCEL__)}function lr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}F.inherits(lr,_e,{__CANCEL__:!0});function Ml(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function wg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function bg(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 yg(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=bg(50,250);return yg(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)},Rl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Pl=e=>(...t)=>F.asap(()=>e(...t)),Sg=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,Cg=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];F.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),F.isString(r)&&i.push("path="+r),F.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 kg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ol(e,t,n){let r=!kg(t);return e&&(r||n==!1)?Tg(e,t):t}const Dl=e=>e instanceof $t?{...e}:e;function Hn(e,t){t=t||{};const n={};function r(u,d,f,h){return F.isPlainObject(u)&&F.isPlainObject(d)?F.merge.call({caseless:h},u,d):F.isPlainObject(d)?F.merge({},d):F.isArray(d)?d.slice():d}function o(u,d,f,h){if(F.isUndefined(d)){if(!F.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!F.isUndefined(d))return r(void 0,d)}function i(u,d){if(F.isUndefined(d)){if(!F.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(Dl(u),Dl(d),f,!0)};return F.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);F.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ll=e=>{const t=Hn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=El(Ol(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),F.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(F.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&&F.isFunction(r)&&(r=r(t)),r||r!==!1&&Sg(t.url))){const l=o&&s&&Cg.read(s);l&&i.set(o,l)}return t},Eg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ll(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function x(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function v(){if(!g)return;const S=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Ml(function(E){n(E),x()},function(E){r(E),x()},C),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new _e(C,_e.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 C=o.transitional||Nl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new _e(T,C.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&F.forEach(i.toJSON(),function(T,C){g.setRequestHeader(C,T)}),F.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=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=S=>{g&&(r(!S||S.type?new lr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=wg(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new _e("Unsupported protocol "+b+":",_e.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ig=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof _e?d:new lr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>F.asap(a),l}},Ng=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},Ag=async function*(e,t){for await(const n of jg(e))yield*Ng(n,t)},jg=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()}},$l=(e,t,n,r)=>{const o=Ag(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})},Fl=64*1024,{isFunction:No}=F,_g=(({Request:e,Response:t})=>({Request:e,Response:t}))(F.global),{ReadableStream:Bl,TextEncoder:zl}=F.global,Hl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Mg=e=>{e=F.merge.call({skipUndefined:!0},_g,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(Bl),l=o&&(typeof zl=="function"?(w=>x=>w.encode(x))(new zl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&Hl(()=>{let w=!1;const x=new n(jt.origin,{body:new Bl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!x}),d=i&&a&&Hl(()=>F.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(x,g)=>{let v=x&&x[w];if(v)return v.call(x);throw new _e(`Response type '${w}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(F.isBlob(w))return w.size;if(F.isSpecCompliantForm(w))return(await new n(jt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(F.isArrayBufferView(w)||F.isArrayBuffer(w))return w.byteLength;if(F.isURLSearchParams(w)&&(w=w+""),F.isString(w))return(await l(w)).byteLength},p=async(w,x)=>{const g=F.toFiniteNumber(w.getContentLength());return g??h(x)};return async w=>{let{url:x,method:g,data:v,signal:b,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:O="same-origin",fetchOptions:$}=Ll(w),H=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Ig([b,S&&S.toAbortSignal()],T),K=null;const P=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let Y;try{if(k&&u&&g!=="get"&&g!=="head"&&(Y=await p(A,v))!==0){let W=new n(x,{method:"POST",body:v,duplex:"half"}),R;if(F.isFormData(v)&&(R=W.headers.get("content-type"))&&A.setContentType(R),W.body){const[B,te]=Rl(Y,Io(Pl(k)));v=$l(W.body,Fl,B,te)}}F.isString(O)||(O=O?"include":"omit");const N=s&&"credentials"in n.prototype,D={...$,signal:U,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:v,duplex:"half",credentials:N?O:void 0};K=s&&new n(x,D);let M=await(s?H(K,$):H(x,D));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&P)){const W={};["status","statusText","headers"].forEach(J=>{W[J]=M[J]});const R=F.toFiniteNumber(M.headers.get("content-length")),[B,te]=C&&Rl(R,Io(Pl(C),!0))||[];M=new r($l(M.body,Fl,B,()=>{te&&te(),P&&P()}),W)}E=E||"text";let z=await f[F.findKey(f,E)||"text"](M,w);return!j&&P&&P(),await new Promise((W,R)=>{Ml(W,R,{data:z,headers:$t.from(M.headers),status:M.status,statusText:M.statusText,config:w,request:K})})}catch(N){throw P&&P(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,w,K),{cause:N.cause||N}):_e.from(N,N&&N.code,w,K)}}},Rg=new Map,Ul=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=Rg;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Mg(t)),d=u;return u};Ul();const ci={http:tg,xhr:Eg,fetch:{get:Ul}};F.forEach(ci,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wl=e=>`- ${e}`,Pg=e=>F.isFunction(e)||e===null||e===!1,Vl={getAdapter:(e,t)=>{e=F.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,!Pg(r)&&(o=ci[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${a}'`);if(o&&(F.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 :
|
|
30
|
+
<%s key={someKey} {...props} />`,Ut,lt,lT,lt),xo[lt+Ut]=!0}}return I===r?go(de):Nt(de),de}}function il(I,ne,ce){return Xs(I,ne,ce,!0)}function al(I,ne,ce){return Xs(I,ne,ce,!1)}var Js=al,vo=il;jr.Fragment=r,jr.jsx=Js,jr.jsxs=vo}()),jr}process.env.NODE_ENV==="production"?ei.exports=mm():ei.exports=gm();var l=ei.exports;function dl(e,t){return function(){return e.apply(t,arguments)}}const{toString:xm}=Object.prototype,{getPrototypeOf:ti}=Object,{iterator:yo,toStringTag:fl}=Symbol,So=(e=>t=>{const n=xm.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:ir}=Array,ar=Co("undefined");function _r(e){return e!==null&&!ar(e)&&e.constructor!==null&&!ar(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const hl=nn("ArrayBuffer");function vm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&hl(e.buffer),t}const wm=Co("string"),Lt=Co("function"),pl=Co("number"),Mr=e=>e!==null&&typeof e=="object",bm=e=>e===!0||e===!1,ko=e=>{if(So(e)!=="object")return!1;const t=ti(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(fl in e)&&!(yo in e)},ym=e=>{if(!Mr(e)||_r(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Sm=nn("Date"),Cm=nn("File"),km=nn("Blob"),Tm=nn("FileList"),Em=e=>Mr(e)&&Lt(e.pipe),Im=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]"))},Nm=nn("URLSearchParams"),[Am,jm,_m,Mm]=["ReadableStream","Request","Response","Headers"].map(nn),Rm=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]),ir(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 ml(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 zn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,gl=e=>!ar(e)&&e!==zn;function ni(){const{caseless:e,skipUndefined:t}=gl(this)&&this||{},n={},r=(o,s)=>{const i=e&&ml(n,s)||s;ko(n[i])&&ko(o)?n[i]=ni(n[i],o):ko(o)?n[i]=ni({},o):ir(o)?n[i]=o.slice():(!t||!ar(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Rr(arguments[o],r);return n}const Pm=(e,t,n,{allOwnKeys:r}={})=>(Rr(t,(o,s)=>{n&&Lt(o)?e[s]=dl(o,n):e[s]=o},{allOwnKeys:r}),e),Om=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Dm=(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)},Lm=(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},$m=(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},Fm=e=>{if(!e)return null;if(ir(e))return e;let t=e.length;if(!pl(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Bm=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ti(Uint8Array)),zm=(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])}},Hm=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Um=nn("HTMLFormElement"),Wm=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),xl=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Vm=nn("RegExp"),vl=(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)},Km=e=>{vl(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+"'")})}})},qm=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ir(e)?r(e):r(String(e).split(t)),n},Gm=()=>{},Ym=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Xm(e){return!!(e&&Lt(e.append)&&e[fl]==="FormData"&&e[yo])}const Jm=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=ir(r)?[]:{};return Rr(r,(i,a)=>{const c=n(i,o+1);!ar(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},Zm=nn("AsyncFunction"),Qm=e=>e&&(Mr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),wl=((e,t)=>e?setImmediate:t?((n,r)=>(zn.addEventListener("message",({source:o,data:s})=>{o===zn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),zn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(zn.postMessage)),eg=typeof queueMicrotask<"u"?queueMicrotask.bind(zn):typeof process<"u"&&process.nextTick||wl,F={isArray:ir,isArrayBuffer:hl,isBuffer:_r,isFormData:Im,isArrayBufferView:vm,isString:wm,isNumber:pl,isBoolean:bm,isObject:Mr,isPlainObject:ko,isEmptyObject:ym,isReadableStream:Am,isRequest:jm,isResponse:_m,isHeaders:Mm,isUndefined:ar,isDate:Sm,isFile:Cm,isBlob:km,isRegExp:Vm,isFunction:Lt,isStream:Em,isURLSearchParams:Nm,isTypedArray:Bm,isFileList:Tm,forEach:Rr,merge:ni,extend:Pm,trim:Rm,stripBOM:Om,inherits:Dm,toFlatObject:Lm,kindOf:So,kindOfTest:nn,endsWith:$m,toArray:Fm,forEachEntry:zm,matchAll:Hm,isHTMLForm:Um,hasOwnProperty:xl,hasOwnProp:xl,reduceDescriptors:vl,freezeMethods:Km,toObjectSet:qm,toCamelCase:Wm,noop:Gm,toFiniteNumber:Ym,findKey:ml,global:zn,isContextDefined:gl,isSpecCompliantForm:Xm,toJSONObject:Jm,isAsyncFn:Zm,isThenable:Qm,setImmediate:wl,asap:eg,isIterable:e=>e!=null&&Lt(e[yo])};function _e(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}F.inherits(_e,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:F.toJSONObject(this.config),code:this.code,status:this.status}}});const bl=_e.prototype,yl={};["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=>{yl[e]={value:e}}),Object.defineProperties(_e,yl),Object.defineProperty(bl,"isAxiosError",{value:!0}),_e.from=(e,t,n,r,o,s)=>{const i=Object.create(bl);F.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 _e.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 tg=null;function ri(e){return F.isPlainObject(e)||F.isArray(e)}function Sl(e){return F.endsWith(e,"[]")?e.slice(0,-2):e}function Cl(e,t,n){return e?e.concat(t).map(function(o,s){return o=Sl(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ng(e){return F.isArray(e)&&!e.some(ri)}const rg=F.toFlatObject(F,{},null,function(t){return/^is[A-Z]/.test(t)});function To(e,t,n){if(!F.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=F.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,g){return!F.isUndefined(g[x])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&F.isSpecCompliantForm(t);if(!F.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(F.isDate(w))return w.toISOString();if(F.isBoolean(w))return w.toString();if(!c&&F.isBlob(w))throw new _e("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(w)||F.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,x,g){let v=w;if(w&&!g&&typeof w=="object"){if(F.endsWith(x,"{}"))x=r?x:x.slice(0,-2),w=JSON.stringify(w);else if(F.isArray(w)&&ng(w)||(F.isFileList(w)||F.endsWith(x,"[]"))&&(v=F.toArray(w)))return x=Sl(x),v.forEach(function(S,T){!(F.isUndefined(S)||S===null)&&t.append(i===!0?Cl([x],T,s):i===null?x:x+"[]",u(S))}),!1}return ri(w)?!0:(t.append(Cl(g,x,s),u(w)),!1)}const f=[],h=Object.assign(rg,{defaultVisitor:d,convertValue:u,isVisitable:ri});function p(w,x){if(!F.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+x.join("."));f.push(w),F.forEach(w,function(v,b){(!(F.isUndefined(v)||v===null)&&o.call(t,v,F.isString(b)?b.trim():b,x,h))===!0&&p(v,x?x.concat(b):[b])}),f.pop()}}if(!F.isObject(e))throw new TypeError("data must be an object");return p(e),t}function kl(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&&To(e,this,t)}const Tl=oi.prototype;Tl.append=function(t,n){this._pairs.push([t,n])},Tl.toString=function(t){const n=t?function(r){return t.call(this,r,kl)}:kl;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function og(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function El(e,t,n){if(!t)return e;const r=n&&n.encode||og;F.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=F.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 Il{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){F.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sg={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,ig=si&&(!ii||["ReactNative","NativeScript","NS"].indexOf(ii.product)<0),ag=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",lg=si&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:si,hasStandardBrowserEnv:ig,hasStandardBrowserWebWorkerEnv:ag,navigator:ii,origin:lg},Symbol.toStringTag,{value:"Module"})),...sg};function cg(e,t){return To(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&F.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function ug(e){return F.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function dg(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 Al(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&&F.isArray(o)?o.length:i,c?(F.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!F.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&F.isArray(o[i])&&(o[i]=dg(o[i])),!a)}if(F.isFormData(e)&&F.isFunction(e.entries)){const n={};return F.forEachEntry(e,(r,o)=>{t(ug(r),o,n,0)}),n}return null}function fg(e,t,n){if(F.isString(e))try{return(t||JSON.parse)(e),F.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Pr={transitional:Nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=F.isObject(t);if(s&&F.isHTMLForm(t)&&(t=new FormData(t)),F.isFormData(t))return o?JSON.stringify(Al(t)):t;if(F.isArrayBuffer(t)||F.isBuffer(t)||F.isStream(t)||F.isFile(t)||F.isBlob(t)||F.isReadableStream(t))return t;if(F.isArrayBufferView(t))return t.buffer;if(F.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 cg(t,this.formSerializer).toString();if((a=F.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return To(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),fg(t)):t}],transformResponse:[function(t){const n=this.transitional||Pr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(F.isResponse(t)||F.isReadableStream(t))return t;if(t&&F.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?_e.from(a,_e.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData: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}}};F.forEach(["delete","get","head","post","put","patch"],e=>{Pr.headers[e]={}});const hg=F.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"]),pg=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]&&hg[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jl=Symbol("internals");function Or(e){return e&&String(e).trim().toLowerCase()}function Eo(e){return e===!1||e==null?e:F.isArray(e)?e.map(Eo):String(e)}function mg(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 gg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ai(e,t,n,r,o){if(F.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!F.isString(t)){if(F.isString(r))return t.indexOf(r)!==-1;if(F.isRegExp(r))return r.test(t)}}function xg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function vg(e,t){const n=F.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,u){const d=Or(c);if(!d)throw new Error("header name must be a non-empty string");const f=F.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=Eo(a))}const i=(a,c)=>F.forEach(a,(u,d)=>s(u,d,c));if(F.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(F.isString(t)&&(t=t.trim())&&!gg(t))i(pg(t),n);else if(F.isObject(t)&&F.isIterable(t)){let a={},c,u;for(const d of t){if(!F.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(c=a[u])?F.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Or(t),t){const r=F.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return mg(o);if(F.isFunction(n))return n.call(this,o,r);if(F.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=F.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ai(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=F.findKey(r,i);a&&(!n||ai(r,r[a],a,n))&&(delete r[a],o=!0)}}return F.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||ai(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return F.forEach(this,(o,s)=>{const i=F.findKey(r,s);if(i){n[i]=Eo(o),delete n[s];return}const a=t?xg(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 F.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&F.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[jl]=this[jl]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Or(i);r[a]||(vg(o,i),r[a]=!0)}return F.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),F.freezeMethods($t);function li(e,t){const n=this||Pr,r=t||n,o=$t.from(r.headers);let s=r.data;return F.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function _l(e){return!!(e&&e.__CANCEL__)}function lr(e,t,n){_e.call(this,e??"canceled",_e.ERR_CANCELED,t,n),this.name="CanceledError"}F.inherits(lr,_e,{__CANCEL__:!0});function Ml(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new _e("Request failed with status code "+n.status,[_e.ERR_BAD_REQUEST,_e.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function wg(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function bg(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 yg(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=bg(50,250);return yg(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)},Rl=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Pl=e=>(...t)=>F.asap(()=>e(...t)),Sg=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,Cg=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];F.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),F.isString(r)&&i.push("path="+r),F.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 kg(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tg(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ol(e,t,n){let r=!kg(t);return e&&(r||n==!1)?Tg(e,t):t}const Dl=e=>e instanceof $t?{...e}:e;function Hn(e,t){t=t||{};const n={};function r(u,d,f,h){return F.isPlainObject(u)&&F.isPlainObject(d)?F.merge.call({caseless:h},u,d):F.isPlainObject(d)?F.merge({},d):F.isArray(d)?d.slice():d}function o(u,d,f,h){if(F.isUndefined(d)){if(!F.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!F.isUndefined(d))return r(void 0,d)}function i(u,d){if(F.isUndefined(d)){if(!F.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(Dl(u),Dl(d),f,!0)};return F.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,h=f(e[d],t[d],d);F.isUndefined(h)&&f!==a||(n[d]=h)}),n}const Ll=e=>{const t=Hn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=El(Ol(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),F.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(F.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&&F.isFunction(r)&&(r=r(t)),r||r!==!1&&Sg(t.url))){const c=o&&s&&Cg.read(s);c&&i.set(o,c)}return t},Eg=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ll(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,d,f,h,p,w;function x(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function v(){if(!g)return;const S=$t.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Ml(function(E){n(E),x()},function(E){r(E),x()},C),g=null}"onloadend"in g?g.onloadend=v:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(v)},g.onabort=function(){g&&(r(new _e("Request aborted",_e.ECONNABORTED,e,g)),g=null)},g.onerror=function(T){const C=T&&T.message?T.message:"Network Error",k=new _e(C,_e.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 C=o.transitional||Nl;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new _e(T,C.clarifyTimeoutError?_e.ETIMEDOUT:_e.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&F.forEach(i.toJSON(),function(T,C){g.setRequestHeader(C,T)}),F.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=Io(u,!0),g.addEventListener("progress",h)),c&&g.upload&&([f,p]=Io(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new lr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=wg(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new _e("Unsupported protocol "+b+":",_e.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Ig=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof _e?d:new lr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new _e(`timeout ${t} of ms exceeded`,_e.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>F.asap(a),c}},Ng=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},Ag=async function*(e,t){for await(const n of jg(e))yield*Ng(n,t)},jg=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()}},$l=(e,t,n,r)=>{const o=Ag(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})},Fl=64*1024,{isFunction:No}=F,_g=(({Request:e,Response:t})=>({Request:e,Response:t}))(F.global),{ReadableStream:Bl,TextEncoder:zl}=F.global,Hl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Mg=e=>{e=F.merge.call({skipUndefined:!0},_g,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(Bl),c=o&&(typeof zl=="function"?(w=>x=>w.encode(x))(new zl):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&Hl(()=>{let w=!1;const x=new n(jt.origin,{body:new Bl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!x}),d=i&&a&&Hl(()=>F.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(x,g)=>{let v=x&&x[w];if(v)return v.call(x);throw new _e(`Response type '${w}' is not supported`,_e.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(F.isBlob(w))return w.size;if(F.isSpecCompliantForm(w))return(await new n(jt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(F.isArrayBufferView(w)||F.isArrayBuffer(w))return w.byteLength;if(F.isURLSearchParams(w)&&(w=w+""),F.isString(w))return(await c(w)).byteLength},p=async(w,x)=>{const g=F.toFiniteNumber(w.getContentLength());return g??h(x)};return async w=>{let{url:x,method:g,data:v,signal:b,cancelToken:S,timeout:T,onDownloadProgress:C,onUploadProgress:k,responseType:E,headers:A,withCredentials:O="same-origin",fetchOptions:$}=Ll(w),H=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Ig([b,S&&S.toAbortSignal()],T),K=null;const P=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let Y;try{if(k&&u&&g!=="get"&&g!=="head"&&(Y=await p(A,v))!==0){let W=new n(x,{method:"POST",body:v,duplex:"half"}),R;if(F.isFormData(v)&&(R=W.headers.get("content-type"))&&A.setContentType(R),W.body){const[B,te]=Rl(Y,Io(Pl(k)));v=$l(W.body,Fl,B,te)}}F.isString(O)||(O=O?"include":"omit");const N=s&&"credentials"in n.prototype,D={...$,signal:U,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:v,duplex:"half",credentials:N?O:void 0};K=s&&new n(x,D);let M=await(s?H(K,$):H(x,D));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&P)){const W={};["status","statusText","headers"].forEach(J=>{W[J]=M[J]});const R=F.toFiniteNumber(M.headers.get("content-length")),[B,te]=C&&Rl(R,Io(Pl(C),!0))||[];M=new r($l(M.body,Fl,B,()=>{te&&te(),P&&P()}),W)}E=E||"text";let z=await f[F.findKey(f,E)||"text"](M,w);return!j&&P&&P(),await new Promise((W,R)=>{Ml(W,R,{data:z,headers:$t.from(M.headers),status:M.status,statusText:M.statusText,config:w,request:K})})}catch(N){throw P&&P(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new _e("Network Error",_e.ERR_NETWORK,w,K),{cause:N.cause||N}):_e.from(N,N&&N.code,w,K)}}},Rg=new Map,Ul=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=Rg;for(;a--;)c=s[a],u=d.get(c),u===void 0&&d.set(c,u=a?new Map:Mg(t)),d=u;return u};Ul();const ci={http:tg,xhr:Eg,fetch:{get:Ul}};F.forEach(ci,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wl=e=>`- ${e}`,Pg=e=>F.isFunction(e)||e===null||e===!1,Vl={getAdapter:(e,t)=>{e=F.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,!Pg(r)&&(o=ci[(a=String(r)).toLowerCase()],o===void 0))throw new _e(`Unknown adapter '${a}'`);if(o&&(F.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
33
|
`+i.map(Wl).join(`
|
|
34
|
-
`):" "+Wl(i[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ci};function ui(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lr(null,e)}function Kl(e){return ui(e),e.headers=$t.from(e.headers),e.data=li.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vl.getAdapter(e.adapter||
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Hn(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&&(F.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&&F.merge(s.common,s[n.method]);s&&F.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=$t.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!l){const w=[Kl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],x=a[f++];try{p=w(p)}catch(g){x.call(this,g);break}}try{d=Kl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Hn(this.defaults,t);const n=Ol(t.baseURL,t.url,t.allowAbsoluteUrls);return El(n,t.params,t.paramsSerializer)}};F.forEach(["delete","get","head","options"],function(t){Un.prototype[t]=function(n,r){return this.request(Hn(r||{},{method:t,url:n,data:(r||{}).data}))}}),F.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Un.prototype[t]=n(),Un.prototype[t+"Form"]=n(!0)});let Dg=class fm{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new lr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new fm(function(o){t=o}),cancel:t}}};function Lg(e){return function(n){return e.apply(null,n)}}function $g(e){return F.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 Yl(e){const t=new Un(e),n=dl(Un.prototype.request,t);return F.extend(n,Un.prototype,t,{allOwnKeys:!0}),F.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Yl(Hn(e,o))},n}const gt=Yl(Rr);gt.Axios=Un,gt.CanceledError=lr,gt.CancelToken=Dg,gt.isCancel=_l,gt.VERSION=ql,gt.toFormData=To,gt.AxiosError=_e,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Lg,gt.isAxiosError=$g,gt.mergeConfig=Hn,gt.AxiosHeaders=$t,gt.formToJSON=e=>Al(F.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=Vl.getAdapter,gt.HttpStatusCode=di,gt.default=gt;const{Axios:vT,AxiosError:wT,CanceledError:bT,isCancel:yT,CancelToken:ST,VERSION:CT,all:kT,Cancel:TT,isAxiosError:ET,spread:IT,toFormData:NT,AxiosHeaders:AT,HttpStatusCode:jT,formToJSON:_T,getAdapter:MT,mergeConfig:RT}=gt,Xl=typeof window<"u"?window.__API_BASE_URL__:void 0,Jl=Xl?bn(Xl):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 fi=new Set;function Zl(){return _o}function Mo(e){_o=e,fi.forEach(t=>t(e))}function Ql(e){return fi.add(e),()=>fi.delete(e)}const Fg=3e4,Bg=9e4,Gt=gt.create({...Jl?{baseURL:Jl}:{},timeout:Fg,withCredentials:!0});Gt.interceptors.request.use(e=>(_o&&(e.headers.Authorization=`Bearer ${_o}`),e)),Gt.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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ro(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ec(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function hi(e,t){return Gt.defaults.baseURL?(await Gt.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 tc{get baseUrl(){const t=Gt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Mo(t.authToken)}getAuthToken(){return Zl()}setAuthToken(t){Mo(t)}onTokenChange(t){return Ql(t)}async listThreads(){const t=await Yt("/threads"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/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 ec(`/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 Ro(`/threads/${t}/share`,{shared_with_user_id:n});return Ft(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ft(n)}async listAgents(){const t=await Yt("/agents"),n=Ft(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ft(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ft(n)}async getState(t){const n=await Yt(`/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 Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Bg});return Ft(n)}async cancelRun(t){const n=await Ro("/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 tc,nc=y.createContext(null);function zg({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(nc.Provider,{value:r,children:e})}function pi(){const e=y.useContext(nc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Hg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Ug(e=[]){const t=[],n=[];for(const r of e)try{const o=await Hg(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}const rc=120;function Wg(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>rc?`${n.slice(0,rc-3)}…`:n:""}function oc(e){return Wg(e.content)||""}function Vg(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=oc(n);r&&t.set(n.id,r)}return t}function Kg(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=oc(o);s&&t.set(r.checkpointId,s)}}return t}function Or(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function cr(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function qg(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 sc(e){const t=Or(e);if(t)return Or(t.configurable)??t}function Wn(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)=>Gg(s,i)).filter(s=>!!s)].sort((s,i)=>ic(i.createdAt)-ic(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 Gg(e,t){var b;if(!e)return null;const r=(Array.isArray((b=e.values)==null?void 0:b.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=Or(e.metadata)??{},s=sc(e.config),i=Or(e.parent_config??e.parentConfig),a=sc(i),l=cr(s,["checkpoint_id","checkpointId"]),u=cr(s,["checkpoint_ns","checkpointNs"]),d=cr(a,["checkpoint_id","checkpointId"]),f=cr(a,["checkpoint_id","checkpointId"])??null,h=cr(a,["checkpoint_ns","checkpointNs"])??null,p=Or(e.config),w=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,x=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(),v={...o,step:qg(o,["step"])??0,source:cr(o,["source"])??null};return{checkpointId:l??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Yg(r,t),metadata:v,config:p??null,parentConfig:i??null,next:x,tasks:w}}function Yg(e,t){return Xg(e,t)}function Xg(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function ic(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Jg(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 Zg({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),w=y.useMemo(()=>Wn(f),[f]).checkpoints,x=Jg(w),[g,v]=y.useState(!1),[b,S]=y.useState(null),[T,C]=y.useState(!1),[k,E]=y.useState(!1),[A,O]=y.useState(!1),[$,H]=y.useState(null),U=y.useRef(o),K=y.useRef(null),P=y.useRef(null),Y=y.useRef(null),N=y.useRef(null),D=y.useRef(!1),M=y.useRef(null),j=y.useRef(new Map);y.useEffect(()=>{U.current=o},[o]);const z=y.useCallback(async q=>{var pe,he;if(!q.threadId)return;const X=q.threadId;(pe=q.onStart)==null||pe.call(q),q.setLoading(!0);try{await q.action(X)}catch(ee){if(U.current===X){const le=String(ee);(he=q.handleError)==null||he.call(q,le),r==null||r(le)}throw ee}finally{q.setLoading(!1)}},[r]),W=y.useCallback(async(q,X)=>{if(!q)return;const pe=`${q}:${X??"latest"}`,he=j.current.get(pe);if(he)return he;const ee=z({threadId:q,setLoading:C,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:je}=Wn(we),Ne=je.find($e=>$e.messages&&$e.messages.length>0)??(X?je.find($e=>$e.checkpointId===X):null)??je[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),v(!!(Ne!=null&&Ne.nextCursor)),S((Ne==null?void 0:Ne.nextCursor)??null)}});j.current.set(pe,ee);try{await ee}finally{j.current.delete(pe)}return U.current===q&&(M.current=pe),ee},[e,t,z]),R=y.useCallback(async(q,X)=>{N.current=q;try{await W(q,X)}finally{N.current===q&&(N.current=null)}},[W]),B=y.useCallback(q=>{P.current=q},[]),te=y.useCallback(q=>{Y.current=q},[]),J=y.useCallback(q=>{const X=q.threadId??U.current;if(!X||U.current&&U.current!==X)return;const{checkpoints:pe}=Wn(q);if(!pe.length)return;const he=pe.find(ee=>ee.messages&&ee.messages.length>0)??pe.find(ee=>!!ee.checkpointId)??pe[0];t((he==null?void 0:he.messages)??[],{checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}),h(q),v(!!(he!=null&&he.nextCursor)),S((he==null?void 0:he.nextCursor)??null),M.current=`${X}:latest`,P.current=null,Y.current=null},[t]),re=y.useCallback(async(q,X)=>{const pe=U.current;await z({threadId:pe,setLoading:O,action:async he=>{const ee=await e.getStateHistory({threadId:he,checkpointId:q,checkpointNs:X??void 0});if(U.current!==he){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${he}, now ${U.current}), discarding stale data`);return}const{checkpoints:le}=Wn(ee),we=le.find(je=>je.checkpointId===q&&(X?je.checkpointNs===X:!0));if(!we){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:q,checkpointNs:X});return}h(ee),t(we.messages??[],{checkpointId:we.checkpointId??null,checkpointNs:we.checkpointNs??null})}}).catch(()=>{})},[e,t,z]),G=y.useCallback((q,X)=>{t(d(),{checkpointId:q??null,checkpointNs:X??null})},[d,t]),L=y.useCallback(async()=>{U.current&&await R(U.current)},[R]),V=y.useCallback(async()=>{const q=U.current;!q||!b||await z({threadId:q,setLoading:E,action:async X=>{const pe=await e.getStateHistory({threadId:X,checkpointId:b});if(U.current!==X)return;const{checkpoints:he}=Wn(pe);if(he.length>0){const ee=he[he.length-1];n((ee==null?void 0:ee.messages)??[]),v(!!(ee!=null&&ee.nextCursor)),S((ee==null?void 0:ee.nextCursor)??null)}}}).catch(()=>{})},[e,b,r,n,z]);y.useEffect(()=>{if(!l||!o||T||u)return;if(P.current===o){P.current=null,K.current=o;return}if(Y.current===o){K.current=o;return}if(N.current===o){N.current=null,K.current=o;return}if(K.current===o)return;K.current=o;const q=!D.current&&!!i&&o===s;let X;q&&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 pe=`${o}:${X??"latest"}`;M.current!==pe&&R(o,X)},[l,o,i,a,s,T,u,R]);const Z=y.useCallback(()=>{h(null),v(!1),S(null),C(!1),E(!1),O(!1),H(null),P.current=null,Y.current=null,K.current=null,M.current=null,N.current=null},[]);return{threadCheckpoints:w,threadTimeline:x,isLoadingThread:T,isHistoryLoading:k,isLoadingCheckpoint:A,threadStateError:$,hasMoreHistory:g,loadThread:R,navigateToCheckpoint:re,loadOlderMessages:V,setCurrentCheckpointId:G,returnToLatest:L,handleStateHistoryEvent:J,markSkipNextLoad:B,markStreamPendingThread:te,resetHistoryState:Z}}const Qg=["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 Qg){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 ex(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 tx({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,w]=y.useState([]),[x,g]=y.useState(!1),[,v]=y.useState(null),[b,S]=y.useState(null),[T,C]=y.useState(!1),k=y.useRef(a),E=y.useRef(new Map);y.useEffect(()=>{k.current=a},[a]);const A=y.useCallback(async()=>{d(!0),h(null);try{const M=await e.listThreads();i(M??[])}catch(M){const j=String(M);h(j),n==null||n(j)}finally{d(!1)}},[e,n]),O=y.useCallback(async()=>{g(!0),v(null);try{const M=await e.listSharedThreads();w(M??[])}catch(M){const j=String(M);v(j),n==null||n(j)}finally{g(!1)}},[e,n]);y.useEffect(()=>{A()},[A]),y.useEffect(()=>{O()},[O]),y.useEffect(()=>{r==null||r(a)},[a,r]);const $=y.useCallback(async M=>{try{const j=await e.createThread(M);return l(j.threadId),await A(),j.threadId}catch(j){const z=String(j);return n==null||n(z),null}},[e,n,A]),H=y.useCallback(async M=>{const j=s;i(W=>W.filter(R=>R.threadId!==M));const z=new AbortController;E.current.set(M,z);try{await e.deleteThread(M),k.current===M&&(l(null),o==null||o())}catch(W){i(j);const R=String(W);n==null||n(R)}finally{E.current.delete(M)}},[e,o,n,s]),U=y.useCallback(async(M,j)=>{try{await e.updateThread(M,j),await A()}catch(z){n==null||n(String(z))}},[e,n,A]),K=y.useCallback(async(M,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(M,j),await O(),S("Shared successfully")}catch(z){const W=ex(z);throw n==null||n(W),S(`Failed to share: ${W}`),new Error(W)}finally{C(!1)}},[e,n,O]),P=y.useCallback(async(M,j)=>{try{await e.unshareThread(M,j),await O()}catch(z){const W=String(z);throw n==null||n(W),z}},[e,n,O]),Y=y.useMemo(()=>({createThread:$,deleteThread:H,renameThread:U,refreshThreads:A,refreshSharedThreads:O,shareThread:K,unshareThread:P}),[$,H,U,A,O,K,P]),N=y.useCallback(M=>{if(!(M!=null&&M.threadId))return;const j={threadId:M.threadId,title:M.title||`Thread ${M.threadId.slice(0,8)}`,createdAt:M.createdAt||new Date().toISOString(),updatedAt:M.updatedAt||new Date().toISOString(),messageCount:M.messageCount??1};i(z=>{let W=!1;const R=z.map(B=>B.threadId===j.threadId?(W=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...B,title:j.title??B.title,updatedAt:j.updatedAt??B.updatedAt,messageCount:j.messageCount??B.messageCount}):B);return W?R:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...z])})},[]),D=y.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:l,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:x,actions:Y,addThreadFromEvent:N,shareInFlight:T,shareStatus:b,clearShareStatus:D}}function mi(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 ac(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Dr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Dr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(ac(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=Dr(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 ur(e){if(typeof e=="string")return e;if(ac(e))return"";try{const t=Dr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function nx(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function rx(e){const t=ur(e);return typeof e=="string"&&nx(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Lr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=mi(t);if(n!==null)return Lr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Lr(e.content):e}function ox(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function gi(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 sx(e){const t=r=>{try{const o=Dr(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 ix(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function lc(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 ax(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function lx(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function cx({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ax(n),i=o?`data:${s};base64,${e}`:t,a=lx(r),l=a.length?a.join(" / "):void 0,u=l?`${l} artifact`:"artifact image";return{src:i,alt:u,label:l}}function ux(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 cx({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function xi(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 $r(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function dx(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 cc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function uc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function fx(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??uc(e);let l="",u=e.slice();if(s){const f=hx(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??"",w={...h,text:p+l};u=[...u.slice(0,u.length-1),w]}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 dc(e){return e.replace(/\s+/g," ").trim()}function hx(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=dc(e),o=dc(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 px(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 $r(e,r,s)}return e}function mx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const gx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function xx(e,t){var n;switch(t.type){case"reset":return{messages:xi(((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=xi(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=xi(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 hc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>hc(o,s),e):e}default:return e}}function fc(e=[]){const[t,n]=y.useReducer(xx,{...gx,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 hc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=mx(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 bx(e,t);if(t.type==="tool.progress")return yx(e,t);if(t.type==="tool.end")return Sx(e,t);if(t.type==="message.delta"){const s=e.assemblingId??cc(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],h=f??{lastSeq:null,lastText:uc(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:w,newMeta:x,changed:g}=fx(l.content,t.delta,h,p);if(!g)return e;const v={...l,content:w},b=$r(i,a,v),S=!f||f.lastSeq!==x.lastSeq||f.lastText!==x.lastText,T=S?{...d,[s]:x}:u;return S?{...e,messages:b,messagesStreamMeta:T}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??cc(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=px(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=Wn(t),i=s.interrupt,a=s.latest,l=i===null?dx(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 vx="tool-";function vi(e){return e.call_id??e.id??null}function pc(e,t,n){const r=e??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:`${vx}${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 wi(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||gi(r).toolCallId===t)return n}return-1}function wx(e){if(e==null)return[];const t=Lr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=ur(t??e);return n?[{type:"text",text:n}]:[]}function mc(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function bx(e,t){const n=vi(t),r=wi(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:$r(e.messages,r,u)}}const s=pc(n,o,t.args);return{...e,messages:[...e.messages,s]}}function yx(e,t){const n=vi(t);if(!n)return e;const r=wi(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=mc(e.messages[r],o);return{...e,messages:$r(e.messages,r,a)}}function Sx(e,t){const n=vi(t);let r=e.messages,o=wi(r,n);if(o===-1){const p=t.name??t.tool??void 0;r=[...r,pc(n,p,{})],o=r.length-1}const s=r[o],i=t.output??t.error??null,a=wx(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=mc(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:$r(r,o,h)}}function gc(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,w]=y.useState(null),[x,g]=y.useState(0),[v,b]=y.useState(!1),S=y.useRef(null),T=y.useRef(!0),C=y.useRef(0),k=y.useRef(null),E=y.useRef(null),A=y.useRef(null),O=y.useRef(null),$=y.useCallback(P=>{o(P)},[]),H=y.useCallback(()=>{h(""),w(null),d(null),E.current=null,A.current=null,O.current=null},[]),U=y.useCallback(()=>{var P;console.debug("[use-chat] stop() invoked - aborting stream"),(P=S.current)==null||P.abort(),S.current=null,k.current=null,l(!1),b(!1),C.current=0,g(0)},[]),K=y.useCallback((P,Y,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h(""),w(null),E.current=null,A.current=null,O.current=null;const D=new AbortController;S.current=D;let M=null,j=null,z=!1;return k.current={threadId:P.threadId??null,headers:{}},(async()=>{var R,B,te,J,re,G,L,V,Z,q,X,pe,he,ee,le,we,je,Ne;const W=$e=>{var Ye;try{const nt=JSON.parse(JSON.stringify($e));return(Ye=nt==null?void 0:nt.payload)!=null&&Ye.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=((R=window.localStorage)==null?void 0:R.getItem("authToken"))||null;let vt=null;try{const St=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");St&&(vt=((te=JSON.parse(St))==null?void 0:te.apiKey)||null)}catch{}const Ue=Ke||dt||vt||null;Ue&&($e={Authorization:`Bearer ${Ue}`})}}catch{}console.debug("[use-chat] POST",t+n,W(P));let Ye={};if(typeof window<"u")try{const Xe=(J=window.localStorage)==null?void 0:J.getItem("authSessionId");Xe&&(Ye={"X-Session-Id":Xe})}catch{}const nt={...$e,...Ye,...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 Xe=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,Xe==null?void 0:Xe.slice(0,500));const Ke=`stream ${qe.status}${Xe?": "+Xe:""}`;throw(re=N==null?void 0:N.onConnectionError)==null||re.call(N,Ke),z=!0,M="error",j=Ke,new Error(Ke)}b(!0);const rt=qe.body.getReader(),kt=new TextDecoder;let at="",Te=[];C.current=0,g(0);let Oe=0,it=null;const ht=()=>{if(Te.length){const Xe=Te.join("");Te=[],T.current&&h(Ke=>Ke+Xe)}it=null},Tt=()=>{typeof window<"u"&&it==null&&(it=requestAnimationFrame(ht))};let yt=Date.now();const Le=setInterval(()=>{var Xe;if(Date.now()-yt>18e5){const Ke="Stream idle timeout";d(Ke),M="error",j=Ke,D.abort(),(Xe=N==null?void 0:N.onError)==null||Xe.call(N,Ke)}},5e3),Ht=1024*1024;try{const Xe=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=Xe??null,vt=String(Ke??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:dt}),(G=N==null?void 0:N.onOpen)==null||G.call(N,{threadId:dt,created:vt});;){const{value:Ue,done:St}=await rt.read();if(St)break;at+=kt.decode(Ue,{stream:!0}),at.length>Ht&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let _;for(;(_=at.indexOf(`
|
|
34
|
+
`):" "+Wl(i[0]):"as no adapter specified";throw new _e("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ci};function ui(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new lr(null,e)}function Kl(e){return ui(e),e.headers=$t.from(e.headers),e.data=li.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vl.getAdapter(e.adapter||Pr.adapter,e)(e).then(function(r){return ui(e),r.data=li.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return _l(r)||(ui(e),r&&r.response&&(r.response.data=li.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const ql="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 Gl={};Ao.transitional=function(t,n,r){function o(s,i){return"[Axios v"+ql+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new _e(o(i," has been removed"+(n?" in "+n:"")),_e.ERR_DEPRECATED);return n&&!Gl[i]&&(Gl[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 Og(e,t,n){if(typeof e!="object")throw new _e("options must be an object",_e.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],c=a===void 0||i(a,s,e);if(c!==!0)throw new _e("option "+s+" must be "+c,_e.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new _e("Unknown option "+s,_e.ERR_BAD_OPTION)}}const jo={assertOptions:Og,validators:Ao},un=jo.validators;let Un=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Il,response:new Il}}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=Hn(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&&(F.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&&F.merge(s.common,s[n.method]);s&&F.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=$t.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(c=c&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const u=[];this.interceptors.response.forEach(function(x){u.push(x.fulfilled,x.rejected)});let d,f=0,h;if(!c){const w=[Kl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],x=a[f++];try{p=w(p)}catch(g){x.call(this,g);break}}try{d=Kl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Hn(this.defaults,t);const n=Ol(t.baseURL,t.url,t.allowAbsoluteUrls);return El(n,t.params,t.paramsSerializer)}};F.forEach(["delete","get","head","options"],function(t){Un.prototype[t]=function(n,r){return this.request(Hn(r||{},{method:t,url:n,data:(r||{}).data}))}}),F.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Hn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Un.prototype[t]=n(),Un.prototype[t+"Form"]=n(!0)});let Dg=class fm{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new lr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new fm(function(o){t=o}),cancel:t}}};function Lg(e){return function(n){return e.apply(null,n)}}function $g(e){return F.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 Yl(e){const t=new Un(e),n=dl(Un.prototype.request,t);return F.extend(n,Un.prototype,t,{allOwnKeys:!0}),F.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Yl(Hn(e,o))},n}const gt=Yl(Pr);gt.Axios=Un,gt.CanceledError=lr,gt.CancelToken=Dg,gt.isCancel=_l,gt.VERSION=ql,gt.toFormData=To,gt.AxiosError=_e,gt.Cancel=gt.CanceledError,gt.all=function(t){return Promise.all(t)},gt.spread=Lg,gt.isAxiosError=$g,gt.mergeConfig=Hn,gt.AxiosHeaders=$t,gt.formToJSON=e=>Al(F.isHTMLForm(e)?new FormData(e):e),gt.getAdapter=Vl.getAdapter,gt.HttpStatusCode=di,gt.default=gt;const{Axios:vT,AxiosError:wT,CanceledError:bT,isCancel:yT,CancelToken:ST,VERSION:CT,all:kT,Cancel:TT,isAxiosError:ET,spread:IT,toFormData:NT,AxiosHeaders:AT,HttpStatusCode:jT,formToJSON:_T,getAdapter:MT,mergeConfig:RT}=gt,Xl=typeof window<"u"?window.__API_BASE_URL__:void 0,Jl=Xl?bn(Xl):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 fi=new Set;function Zl(){return _o}function Mo(e){_o=e,fi.forEach(t=>t(e))}function Ql(e){return fi.add(e),()=>fi.delete(e)}const Fg=3e4,Bg=9e4,Gt=gt.create({...Jl?{baseURL:Jl}:{},timeout:Fg,withCredentials:!0});Gt.interceptors.request.use(e=>(_o&&(e.headers.Authorization=`Bearer ${_o}`),e)),Gt.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 Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ro(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ec(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function hi(e,t){return Gt.defaults.baseURL?(await Gt.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 tc{get baseUrl(){const t=Gt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Mo(t.authToken)}getAuthToken(){return Zl()}setAuthToken(t){Mo(t)}onTokenChange(t){return Ql(t)}async listThreads(){const t=await Yt("/threads"),n=Ft(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/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 ec(`/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 Ro(`/threads/${t}/share`,{shared_with_user_id:n});return Ft(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ft(n)}async listAgents(){const t=await Yt("/agents"),n=Ft(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ft(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ft(n)}async getState(t){const n=await Yt(`/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 Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Bg});return Ft(n)}async cancelRun(t){const n=await Ro("/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 tc,nc=y.createContext(null);function zg({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(nc.Provider,{value:r,children:e})}function pi(){const e=y.useContext(nc);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Hg(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let 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 Ug(e=[]){const t=[],n=[];for(const r of e)try{const o=await Hg(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}const rc=120;function Wg(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>rc?`${n.slice(0,rc-3)}…`:n:""}function oc(e){return Wg(e.content)||""}function Vg(e){const t=new Map;for(const n of e){if(!n.id||n.role!=="user")continue;const r=oc(n);r&&t.set(n.id,r)}return t}function Kg(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=oc(o);s&&t.set(r.checkpointId,s)}}return t}function Dr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function cr(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function qg(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 sc(e){const t=Dr(e);if(t)return Dr(t.configurable)??t}function Wn(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)=>Gg(s,i)).filter(s=>!!s)].sort((s,i)=>ic(i.createdAt)-ic(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 Gg(e,t){var b;if(!e)return null;const r=(Array.isArray((b=e.values)==null?void 0:b.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=Dr(e.metadata)??{},s=sc(e.config),i=Dr(e.parent_config??e.parentConfig),a=sc(i),c=cr(s,["checkpoint_id","checkpointId"]),u=cr(s,["checkpoint_ns","checkpointNs"]),d=cr(a,["checkpoint_id","checkpointId"]),f=cr(a,["checkpoint_id","checkpointId"])??null,h=cr(a,["checkpoint_ns","checkpointNs"])??null,p=Dr(e.config),w=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,x=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(),v={...o,step:qg(o,["step"])??0,source:cr(o,["source"])??null};return{checkpointId:c??null,checkpointNs:u??null,createdAt:g,parentId:d??null,messages:r,nextCursor:f,nextCursorNs:h,interrupt:Yg(r,t),metadata:v,config:p??null,parentConfig:i??null,next:x,tasks:w}}function Yg(e,t){return Xg(e,t)}function Xg(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function ic(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}function Jg(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 Zg({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),w=y.useMemo(()=>Wn(f),[f]).checkpoints,x=Jg(w),[g,v]=y.useState(!1),[b,S]=y.useState(null),[T,C]=y.useState(!1),[k,E]=y.useState(!1),[A,O]=y.useState(!1),[$,H]=y.useState(null),U=y.useRef(o),K=y.useRef(null),P=y.useRef(null),Y=y.useRef(null),N=y.useRef(null),D=y.useRef(!1),M=y.useRef(null),j=y.useRef(new Map);y.useEffect(()=>{U.current=o},[o]);const z=y.useCallback(async q=>{var pe,he;if(!q.threadId)return;const X=q.threadId;(pe=q.onStart)==null||pe.call(q),q.setLoading(!0);try{await q.action(X)}catch(ee){if(U.current===X){const le=String(ee);(he=q.handleError)==null||he.call(q,le),r==null||r(le)}throw ee}finally{q.setLoading(!1)}},[r]),W=y.useCallback(async(q,X)=>{if(!q)return;const pe=`${q}:${X??"latest"}`,he=j.current.get(pe);if(he)return he;const ee=z({threadId:q,setLoading:C,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:je}=Wn(we),Ne=je.find($e=>$e.messages&&$e.messages.length>0)??(X?je.find($e=>$e.checkpointId===X):null)??je[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),v(!!(Ne!=null&&Ne.nextCursor)),S((Ne==null?void 0:Ne.nextCursor)??null)}});j.current.set(pe,ee);try{await ee}finally{j.current.delete(pe)}return U.current===q&&(M.current=pe),ee},[e,t,z]),R=y.useCallback(async(q,X)=>{N.current=q;try{await W(q,X)}finally{N.current===q&&(N.current=null)}},[W]),B=y.useCallback(q=>{P.current=q},[]),te=y.useCallback(q=>{Y.current=q},[]),J=y.useCallback(q=>{const X=q.threadId??U.current;if(!X||U.current&&U.current!==X)return;const{checkpoints:pe}=Wn(q);if(!pe.length)return;const he=pe.find(ee=>ee.messages&&ee.messages.length>0)??pe.find(ee=>!!ee.checkpointId)??pe[0];t((he==null?void 0:he.messages)??[],{checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}),h(q),v(!!(he!=null&&he.nextCursor)),S((he==null?void 0:he.nextCursor)??null),M.current=`${X}:latest`,P.current=null,Y.current=null},[t]),re=y.useCallback(async(q,X)=>{const pe=U.current;await z({threadId:pe,setLoading:O,action:async he=>{const ee=await e.getStateHistory({threadId:he,checkpointId:q,checkpointNs:X??void 0});if(U.current!==he){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${he}, now ${U.current}), discarding stale data`);return}const{checkpoints:le}=Wn(ee),we=le.find(je=>je.checkpointId===q&&(X?je.checkpointNs===X:!0));if(!we){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:q,checkpointNs:X});return}h(ee),t(we.messages??[],{checkpointId:we.checkpointId??null,checkpointNs:we.checkpointNs??null})}}).catch(()=>{})},[e,t,z]),G=y.useCallback((q,X)=>{t(d(),{checkpointId:q??null,checkpointNs:X??null})},[d,t]),L=y.useCallback(async()=>{U.current&&await R(U.current)},[R]),V=y.useCallback(async()=>{const q=U.current;!q||!b||await z({threadId:q,setLoading:E,action:async X=>{const pe=await e.getStateHistory({threadId:X,checkpointId:b});if(U.current!==X)return;const{checkpoints:he}=Wn(pe);if(he.length>0){const ee=he[he.length-1];n((ee==null?void 0:ee.messages)??[]),v(!!(ee!=null&&ee.nextCursor)),S((ee==null?void 0:ee.nextCursor)??null)}}}).catch(()=>{})},[e,b,r,n,z]);y.useEffect(()=>{if(!c||!o||T||u)return;if(P.current===o){P.current=null,K.current=o;return}if(Y.current===o){K.current=o;return}if(N.current===o){N.current=null,K.current=o;return}if(K.current===o)return;K.current=o;const q=!D.current&&!!i&&o===s;let X;q&&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 pe=`${o}:${X??"latest"}`;M.current!==pe&&R(o,X)},[c,o,i,a,s,T,u,R]);const Z=y.useCallback(()=>{h(null),v(!1),S(null),C(!1),E(!1),O(!1),H(null),P.current=null,Y.current=null,K.current=null,M.current=null,N.current=null},[]);return{threadCheckpoints:w,threadTimeline:x,isLoadingThread:T,isHistoryLoading:k,isLoadingCheckpoint:A,threadStateError:$,hasMoreHistory:g,loadThread:R,navigateToCheckpoint:re,loadOlderMessages:V,setCurrentCheckpointId:G,returnToLatest:L,handleStateHistoryEvent:J,markSkipNextLoad:B,markStreamPendingThread:te,resetHistoryState:Z}}const Qg=["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 Qg){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 ex(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 tx({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,w]=y.useState([]),[x,g]=y.useState(!1),[,v]=y.useState(null),[b,S]=y.useState(null),[T,C]=y.useState(!1),k=y.useRef(a),E=y.useRef(new Map);y.useEffect(()=>{k.current=a},[a]);const A=y.useCallback(async()=>{d(!0),h(null);try{const M=await e.listThreads();i(M??[])}catch(M){const j=String(M);h(j),n==null||n(j)}finally{d(!1)}},[e,n]),O=y.useCallback(async()=>{g(!0),v(null);try{const M=await e.listSharedThreads();w(M??[])}catch(M){const j=String(M);v(j),n==null||n(j)}finally{g(!1)}},[e,n]);y.useEffect(()=>{A()},[A]),y.useEffect(()=>{O()},[O]),y.useEffect(()=>{r==null||r(a)},[a,r]);const $=y.useCallback(async M=>{try{const j=await e.createThread(M);return c(j.threadId),await A(),j.threadId}catch(j){const z=String(j);return n==null||n(z),null}},[e,n,A]),H=y.useCallback(async M=>{const j=s;i(W=>W.filter(R=>R.threadId!==M));const z=new AbortController;E.current.set(M,z);try{await e.deleteThread(M),k.current===M&&(c(null),o==null||o())}catch(W){i(j);const R=String(W);n==null||n(R)}finally{E.current.delete(M)}},[e,o,n,s]),U=y.useCallback(async(M,j)=>{try{await e.updateThread(M,j),await A()}catch(z){n==null||n(String(z))}},[e,n,A]),K=y.useCallback(async(M,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(M,j),await O(),S("Shared successfully")}catch(z){const W=ex(z);throw n==null||n(W),S(`Failed to share: ${W}`),new Error(W)}finally{C(!1)}},[e,n,O]),P=y.useCallback(async(M,j)=>{try{await e.unshareThread(M,j),await O()}catch(z){const W=String(z);throw n==null||n(W),z}},[e,n,O]),Y=y.useMemo(()=>({createThread:$,deleteThread:H,renameThread:U,refreshThreads:A,refreshSharedThreads:O,shareThread:K,unshareThread:P}),[$,H,U,A,O,K,P]),N=y.useCallback(M=>{if(!(M!=null&&M.threadId))return;const j={threadId:M.threadId,title:M.title||`Thread ${M.threadId.slice(0,8)}`,createdAt:M.createdAt||new Date().toISOString(),updatedAt:M.updatedAt||new Date().toISOString(),messageCount:M.messageCount??1};i(z=>{let W=!1;const R=z.map(B=>B.threadId===j.threadId?(W=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...B,title:j.title??B.title,updatedAt:j.updatedAt??B.updatedAt,messageCount:j.messageCount??B.messageCount}):B);return W?R:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...z])})},[]),D=y.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:k,setCurrentThreadId:c,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:x,actions:Y,addThreadFromEvent:N,shareInFlight:T,shareStatus:b,clearShareStatus:D}}function mi(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 ac(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(ac(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 ur(e){if(typeof e=="string")return e;if(ac(e))return"";try{const t=Lr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function nx(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function rx(e){const t=ur(e);return typeof e=="string"&&nx(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=mi(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 ox(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function gi(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 sx(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 ix(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function lc(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 ax(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function lx(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function cx({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ax(n),i=o?`data:${s};base64,${e}`:t,a=lx(r),c=a.length?a.join(" / "):void 0,u=c?`${c} artifact`:"artifact image";return{src:i,alt:u,label:c}}function ux(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 cx({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function xi(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 dx(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 cc(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function uc(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function fx(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??uc(e);let c="",u=e.slice();if(s){const f=hx(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??"",w={...h,text:p+c};u=[...u.slice(0,u.length-1),w]}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 dc(e){return e.replace(/\s+/g," ").trim()}function hx(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=dc(e),o=dc(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 px(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 mx(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const gx={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function xx(e,t){var n;switch(t.type){case"reset":return{messages:xi(((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=xi(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=xi(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 hc(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>hc(o,s),e):e}default:return e}}function fc(e=[]){const[t,n]=y.useReducer(xx,{...gx,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 hc(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=mx(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==="tool.start")return bx(e,t);if(t.type==="tool.progress")return yx(e,t);if(t.type==="tool.end")return Sx(e,t);if(t.type==="message.delta"){const s=e.assemblingId??cc(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const c=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],h=f??{lastSeq:null,lastText:uc(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:w,newMeta:x,changed:g}=fx(c.content,t.delta,h,p);if(!g)return e;const v={...c,content:w},b=Fr(i,a,v),S=!f||f.lastSeq!==x.lastSeq||f.lastText!==x.lastText,T=S?{...d,[s]:x}:u;return S?{...e,messages:b,messagesStreamMeta:T}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??cc(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=px(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=Wn(t),i=s.interrupt,a=s.latest,c=i===null?dx(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}const vx="tool-";function vi(e){return e.call_id??e.id??null}function pc(e,t,n){const r=e??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:`${vx}${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 wi(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||gi(r).toolCallId===t)return n}return-1}function wx(e){if(e==null)return[];const t=$r(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=ur(t??e);return n?[{type:"text",text:n}]:[]}function mc(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function bx(e,t){const n=vi(t),r=wi(e.messages,n),o=t.name??t.tool??void 0;if(r>=0){const i=e.messages[r],c={...i.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},u={...i,name:o??i.name,additionalKwargs:c};return{...e,messages:Fr(e.messages,r,u)}}const s=pc(n,o,t.args);return{...e,messages:[...e.messages,s]}}function yx(e,t){const n=vi(t);if(!n)return e;const r=wi(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=mc(e.messages[r],o);return{...e,messages:Fr(e.messages,r,a)}}function Sx(e,t){const n=vi(t);let r=e.messages,o=wi(r,n);if(o===-1){const p=t.name??t.tool??void 0;r=[...r,pc(n,p,{})],o=r.length-1}const s=r[o],i=t.output??t.error??null,a=wx(i),c=[...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=mc(s,u),f=t.artifact??s.artifact,h={...d,name:t.name??t.tool??s.name,content:c,artifact:f,additionalKwargs:{...d.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Fr(r,o,h)}}function gc(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,c]=y.useState(!1),[u,d]=y.useState(null),[f,h]=y.useState(""),[p,w]=y.useState(null),[x,g]=y.useState(0),[v,b]=y.useState(!1),S=y.useRef(null),T=y.useRef(!0),C=y.useRef(0),k=y.useRef(null),E=y.useRef(null),A=y.useRef(null),O=y.useRef(null),$=y.useCallback(P=>{o(P)},[]),H=y.useCallback(()=>{h(""),w(null),d(null),E.current=null,A.current=null,O.current=null},[]),U=y.useCallback(()=>{var P;console.debug("[use-chat] stop() invoked - aborting stream"),(P=S.current)==null||P.abort(),S.current=null,k.current=null,c(!1),b(!1),C.current=0,g(0)},[]),K=y.useCallback((P,Y,N)=>{S.current&&(S.current.abort(),S.current=null),c(!0),d(null),e.autoAppendAssistant!==!1&&h(""),w(null),E.current=null,A.current=null,O.current=null;const D=new AbortController;S.current=D;let M=null,j=null,z=!1;return k.current={threadId:P.threadId??null,headers:{}},(async()=>{var R,B,te,J,re,G,L,V,Z,q,X,pe,he,ee,le,we,je,Ne;const W=$e=>{var Ye;try{const nt=JSON.parse(JSON.stringify($e));return(Ye=nt==null?void 0:nt.payload)!=null&&Ye.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=((R=window.localStorage)==null?void 0:R.getItem("authToken"))||null;let vt=null;try{const St=(B=window.localStorage)==null?void 0:B.getItem("chat-settings");St&&(vt=((te=JSON.parse(St))==null?void 0:te.apiKey)||null)}catch{}const Ue=Ke||dt||vt||null;Ue&&($e={Authorization:`Bearer ${Ue}`})}}catch{}console.debug("[use-chat] POST",t+n,W(P));let Ye={};if(typeof window<"u")try{const Xe=(J=window.localStorage)==null?void 0:J.getItem("authSessionId");Xe&&(Ye={"X-Session-Id":Xe})}catch{}const nt={...$e,...Ye,...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 Xe=await qe.text().catch(()=>"");console.debug("[use-chat] non-OK response",qe.status,Xe==null?void 0:Xe.slice(0,500));const Ke=`stream ${qe.status}${Xe?": "+Xe:""}`;throw(re=N==null?void 0:N.onConnectionError)==null||re.call(N,Ke),z=!0,M="error",j=Ke,new Error(Ke)}b(!0);const rt=qe.body.getReader(),kt=new TextDecoder;let at="",Te=[];C.current=0,g(0);let Oe=0,it=null;const ht=()=>{if(Te.length){const Xe=Te.join("");Te=[],T.current&&h(Ke=>Ke+Xe)}it=null},Tt=()=>{typeof window<"u"&&it==null&&(it=requestAnimationFrame(ht))};let yt=Date.now();const Le=setInterval(()=>{var Xe;if(Date.now()-yt>18e5){const Ke="Stream idle timeout";d(Ke),M="error",j=Ke,D.abort(),(Xe=N==null?void 0:N.onError)==null||Xe.call(N,Ke)}},5e3),Ht=1024*1024;try{const Xe=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=Xe??null,vt=String(Ke??"").toLowerCase()==="true";for(k.current&&!k.current.threadId&&(k.current={...k.current,threadId:dt}),(G=N==null?void 0:N.onOpen)==null||G.call(N,{threadId:dt,created:vt});;){const{value:Ue,done:St}=await rt.read();if(St)break;at+=kt.decode(Ue,{stream:!0}),at.length>Ht&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let _;for(;(_=at.indexOf(`
|
|
37
37
|
|
|
38
|
-
`))>=0;){const ie=at.slice(0,_);at=at.slice(_+2);const ge=kx(ie);if(!ge)continue;let We;try{We=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const Pe=Cx(We)?We.data:We;yt=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=N==null?void 0:N.onGap)==null||L.call(N,{from:Oe,to:mt})),Oe=mt,C.current=mt,g(mt)}if(Pe.type==="checkpoint")E.current=Pe.checkpointId??null,A.current=Pe.checkpointNs??null,w(Pe.checkpointId??null);else if(Pe.type==="state_history"){O.current=Pe;try{const Nt=Wn(Pe).latest;Nt&&(E.current=Nt.checkpointId??null,A.current=Nt.checkpointNs??null,w(Nt.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{Y==null||Y(Pe)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",Pe.type)}if(Pe.type==="message.delta"){const Je=Pe.delta.filter(Nt=>Nt.type==="text").map(Nt=>Nt.text).join("");Je&&e.autoAppendAssistant!==!1&&(Te.push(Je),Tt())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(V=N==null?void 0:N.onHeartbeat)==null||V.call(N,Pe)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(it!==null&&cancelAnimationFrame(it),ht(),Pe.type==="checkpoint")w(Pe.checkpointId);else if(Pe.type==="error"){const Je=Pe;if(d(Je.message),M="error",j=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((Z=Je.message)==null?void 0:Z.includes("token"))||((q=Je.message)==null?void 0:q.includes("401"))||((X=Je.message)==null?void 0:X.includes("unauthorized"))||((pe=Je.message)==null?void 0:pe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(he=N==null?void 0:N.onAuthError)==null||he.call(N,Je.message)}catch(go){console.warn("[use-chat] onAuthError handler failed",go)}D.abort()}}}}ht(),M===null&&!D.signal.aborted&&(M="complete")}catch(Xe){if(Xe.name==="AbortError")M=M??"aborted";else{const Ke=Xe.message||String(Xe);M="error",j=Ke,d(Ke),(ee=N==null?void 0:N.onError)==null||ee.call(N,Ke)}}finally{try{await rt.cancel()}catch{}finally{(le=rt.releaseLock)==null||le.call(rt)}it!==null&&typeof window<"u"&&window.cancelAnimationFrame(it),clearInterval(Le)}}catch($e){if($e.name==="AbortError")M=M??"aborted";else{const Ye=$e.message||String($e);M="error",j=Ye,d(Ye),(we=N==null?void 0:N.onError)==null||we.call(N,Ye),z||((je=N==null?void 0:N.onConnectionError)==null||je.call(N,Ye),z=!0)}}finally{const $e=C.current,Ye=E.current,nt=A.current,Ve=O.current,qe=M??(D.signal.aborted?"aborted":j?"error":"complete");try{(Ne=N==null?void 0:N.onClosed)==null||Ne.call(N,{reason:qe,lastSeq:$e,lastCheckpointId:Ye,lastCheckpointNs:nt,lastStateHistory:Ve,error:j})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}
|
|
39
|
-
`)}const Tx=["message.start","message.delta","message.end"],Ex=["tool.start","tool.end","tool.progress"],Ix=["thread_info","checkpoint"],Nx=["error","interrupt","heartbeat","state_history","cancelled"],Ax=[...Tx,...Ex,...Ix,...Nx],jx=new Set(Ax);function _x(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return jx.has(t)}const xc=200;function Mx({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),w=y.useRef(null),x=y.useRef(null),g=y.useCallback(N=>{try{const D=globalThis.structuredClone;if(typeof D=="function")return D(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),v=y.useCallback((N,D)=>{if(!N)return;const M=p.current.get(N)??[],j=g(D),z=M.length>=xc?[...M.slice(M.length-xc+1),j]:[...M,j];p.current.set(N,z)},[g]),b=y.useCallback(N=>{N&&p.current.set(N,[])},[]),S=y.useCallback(N=>{const D=N??h.current;if(!D)return;const M=p.current.get(D);M!=null&&M.length&&M.forEach(j=>{try{n(j)}catch(z){console.error("[useChatStreamingService] Failed to replay buffered event",z)}})},[n]),T=y.useCallback(N=>{h.current=N.threadId,w.current&&(w.current.threadIdGuess=N.threadId),x.current=N,b(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}},[b,t]),C=y.useCallback(N=>{try{u==null||u(N)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}},[u]),k=y.useCallback(N=>{var j,z,W,R;const D=N;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((j=D.message)==null?void 0:j.includes("token"))||((z=D.message)==null?void 0:z.includes("401"))||((W=D.message)==null?void 0:W.includes("unauthorized"))||((R=D.message)==null?void 0:R.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{l==null||l(D.message)}catch(B){console.warn("[useChatStreamingService] onAuthError handler failed",B)}}},[l]),E=y.useMemo(()=>({thread_info:N=>(T(N),!0),heartbeat:N=>(C(N),!0),error:N=>(k(N),!1)}),[T,C,k]),A=y.useCallback(N=>{var z;const D=N.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 M=E[N.type];if(M&&M(N))return;const j=N.threadId??(N.type==="state_history"?N.threadId:void 0)??h.current??((z=w.current)==null?void 0:z.threadIdGuess)??null;if(N.type==="state_history"){h.current=j??h.current;try{r==null||r(N)}catch(W){console.error("[useChatStreamingService] onStateHistory handler failed",W)}}if(_x(N)){(N.type==="tool.start"||N.type==="tool.end")&&(d==null||d(N)),N.type==="checkpoint"||N.type==="state_history"?b(j??null):v(j??null,N);try{n(N)}catch(W){console.error("[useChatStreamingService] Error in onMessageEvent handler:",W)}return}try{o==null||o(N)}catch(W){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",W)}},[v,b,n,s,r,o,E]),{stream:O,stop:$,isStreaming:H,error:U,setToken:K}=gc({baseUrl:e,token:void 0}),P=y.useCallback((N,D)=>{f.current=null,x.current=null,h.current=N.threadId??null,w.current={request:N,callbacks:D,manualStop:!1,threadIdGuess:N.threadId??null},O(N,A,{onOpen:D==null?void 0:D.onOpen,onError:M=>{var j;(j=D==null?void 0:D.onError)==null||j.call(D,M)},onGap:(D==null?void 0:D.onGap)??s,onConnectionError:M=>{var j;a==null||a(M),(j=D==null?void 0:D.onConnectionError)==null||j.call(D,M)},onAuthError:M=>{var j;l==null||l(M),(j=D==null?void 0:D.onAuthError)==null||j.call(D,M)},onHeartbeat:M=>{var j;try{u==null||u(M)}catch(z){console.warn("[useChatStreamingService] onHeartbeat handler failed",z)}try{(j=D==null?void 0:D.onHeartbeat)==null||j.call(D,M)}catch(z){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",z)}},onClosed:M=>{var R,B,te,J;const j=((R=w.current)==null?void 0:R.manualStop)??!1,z=h.current??((B=w.current)==null?void 0:B.threadIdGuess)??((te=M.lastStateHistory)==null?void 0:te.threadId)??null;(M.reason==="complete"||M.reason==="aborted"&&j)&&b(z);const W={...M,threadId:z,threadInfo:x.current,manualStop:j};try{i==null||i(W)}catch(re){console.warn("[useChatStreamingService] onStreamClosed handler failed",re)}try{(J=D==null?void 0:D.onClosed)==null||J.call(D,W)}catch(re){console.warn("[useChatStreamingService] downstream onClosed handler failed",re)}w.current&&(w.current=null)}})},[b,A,l,a,u,s,i,O]),Y=y.useCallback(()=>{w.current&&(w.current.manualStop=!0),$()},[$]);return y.useMemo(()=>({startStream:P,stop:Y,isStreaming:H,error:U,setAuthToken:K,replayBufferedEvents:S}),[P,Y,H,U,K,S])}const vc=y.createContext(null),wc=y.createContext(null),bc=y.createContext(null);y.createContext(!1);function Rx({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}=pi(),h=y.useMemo(()=>bn(f),[f]),{state:p,seed:w,prepend:x,pushUser:g,onEvent:v}=fc(),{threads:b,currentThreadId:S,setCurrentThreadId:T,currentThreadIdRef:C,isLoadingThreads:k,threadsError:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,addThreadFromEvent:H,shareInFlight:U,shareStatus:K,clearShareStatus:P}=tx({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>w([],{})}),[Y,N]=y.useState(!1),D=y.useCallback(()=>p.messages,[p.messages]),{threadCheckpoints:M,threadTimeline:j,isLoadingThread:z,isHistoryLoading:W,isLoadingCheckpoint:R,threadStateError:B,hasMoreHistory:te,loadThread:J,navigateToCheckpoint:re,loadOlderMessages:G,setCurrentCheckpointId:L,returnToLatest:V,handleStateHistoryEvent:Z,markSkipNextLoad:q,markStreamPendingThread:X,resetHistoryState:pe}=Zg({api:d,seed:w,prepend:x,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:Y,getMessages:D}),he=y.useMemo(()=>Kg(M),[M]),ee=y.useCallback(Te=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Te.threadId),H(Te),C.current!==Te.threadId&&((Te.created??!C.current)&&q(Te.threadId),X(Te.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(Te.threadId))},[H,q,X]),{startStream:le,stop:we,isStreaming:je,error:Ne,setAuthToken:$e}=Mx({baseUrl:h,onThreadInfo:ee,onMessageEvent:v,onStateHistory:Z,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(()=>{N(je)},[je]);const Ye=y.useCallback(async()=>{w([],{}),T(null),we(),pe();try{await d.getAgent("default")}catch(Te){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Te)}},[w,we,d,pe]),nt=y.useCallback(async(Te,Oe,it)=>{const ht=C.current;if(!ht)throw new Error("No active thread to handle interrupt");const Tt=Oe?it??!0:!1;try{const yt={threadId:ht,checkpointId:p.lastCheckpointId??void 0,checkpointNs:p.lastCheckpointNs??void 0,command:{kind:"resume",value:Tt}};le(yt)}catch(yt){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Te}:`,yt),yt}},[p.lastCheckpointId,p.lastCheckpointNs,le]),Ve=y.useCallback(async(Te,Oe)=>{let it=C.current;const ht=(Te==null?void 0:Te.text)??"",Tt=(Te==null?void 0:Te.attachments)??[],yt=(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 Xe=!!(Ht&&Ht.length);if(!it&&!yt&&Tt.length===0&&!Xe)return;if(!it){const mt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Je=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);it=`${mt}${Je}`,q(it),T(it)}const{contentParts:Ke,filesInfo:dt}=await Ug(Tt),vt=[...Ke];yt&&vt.push({type:"text",text:ht});const Ue=Oe==null?void 0:Oe.originalMessageId,St=!!(Oe!=null&&Oe.edit&&Ue),_=!Xe&&vt.length>0;let ie=null;_&&(ie={id:St?Ue:`msg-${Date.now()}`,role:"user",content:vt,createdAt:new Date().toISOString()},St?g(ie,Ue):g(ie));const ge=Xe?Ht:ie?[ie]:[],We={...Le,...dt.length?{files_info:dt}:{}};ge.length?We.messages=ge:"messages"in We||(We.messages=[]);const Pe={threadId:it,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:j};le(Pe)},[d,g,p,le,j]),qe=y.useMemo(()=>({threads:b,currentThreadId:S,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,shareInFlight:U,shareStatus:K,clearShareStatus:P}),[b,S,T,k,E,A,O,$,U,K,P]),rt=y.useMemo(()=>{const Te=p.assemblingId??null;return Te?{assemblingMessageId:Te}:null},[p.assemblingId]),kt=y.useMemo(()=>({threadId:S,messages:p.messages,interrupt:null,checkpoint:{id:p.lastCheckpointId??null,namespace:p.lastCheckpointNs??null},checkpoints:M,timelineCheckpoints:j,metadata:rt,isLoading:z,isHistoryLoading:W,isLoadingCheckpoint:R,error:B,hasMore:te,loadOlder:G,clearState:Ye,navigateToCheckpoint:re,setCurrentCheckpointId:L,returnToLatest:V,loadThread:J,clearThread:Ye,respondToInterrupt:nt,messagePreviews:he}),[S,p,M,j,z,W,R,B,te,G,Ye,re,L,V,J,nt,he,rt]),at=y.useMemo(()=>({isStreaming:je,error:Ne,connectionState:je?"connected":"idle",submit:Ve,send:Ve,stop:we,setAuthToken:$e}),[je,Ne,Ve,we,$e]);return c.jsx(vc.Provider,{value:qe,children:c.jsx(wc.Provider,{value:kt,children:c.jsx(bc.Provider,{value:at,children:e})})})}function Do(){const e=y.useContext(vc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Lo(){const e=y.useContext(wc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function yc(){const e=y.useContext(bc);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(zg,{apiConfig:t,children:c.jsx(Rx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function oe(...e){return pm.twMerge(hm.clsx(e))}const Px=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"}}),Qe=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Bn.Slot:"button";return c.jsx(i,{className:oe(Px({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";const Sc=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:oe("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}));Sc.displayName="Textarea";const Ox=1e4;function Cc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=Ox,value:i,onValueChange:a,onSend:l,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1,validate:w,onValidationError:x}){const g=i!==void 0,[v,b]=y.useState(e),S=(g?i:v)??"",[T,C]=y.useTransition(),k=y.useRef(null),E=y.useRef(0),A=y.useRef(null),O=y.useRef("");y.useEffect(()=>{g||(b(e??""),A.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,g]);const[$,H]=y.useState(null),U=y.useCallback(B=>B.length>s?`Message too long (${B.length}/${s} characters)`:null,[s]),K=y.useMemo(()=>w??U,[w,U]),P=y.useCallback(B=>{const te=K(B);return H(te),x==null||x(te),O.current=B,te},[K,x]),Y=y.useCallback(()=>{const B=k.current;B&&(B.style.height="auto",B.style.height=`${B.scrollHeight}px`)},[]);y.useEffect(()=>{Y()},[Y,S]),y.useEffect(()=>{if(!$)return;const B=(S??"").trim();O.current!==B&&P(B)},[S,$,P]);const N=y.useCallback((B,{fromUser:te})=>{g||b(B),te&&(a==null||a(B))},[g,a]),D=y.useCallback(async B=>{B&&B.preventDefault();const te=(S??"").trim();if(!te&&!p||P(te))return;const J=++E.current;A.current={id:J,shouldClear:!0},C(()=>{var re,G,L;try{const V=l(te);V&&typeof V.then=="function"?V.then(()=>{var Z,q;((Z=A.current)==null?void 0:Z.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((q=A.current)==null?void 0:q.id)===J&&(A.current=null)}).catch(()=>{var Z;((Z=A.current)==null?void 0:Z.id)===J&&(A.current=null)}):(((re=A.current)==null?void 0:re.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((G=A.current)==null?void 0:G.id)===J&&(A.current=null))}catch{((L=A.current)==null?void 0:L.id)===J&&(A.current=null)}})},[S,l,p,g,a,P]),M=y.useCallback(B=>{const te=B.target.value;N(te,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),$&&P(te.trim())},[N,P,$]),j=y.useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),D()):B.key==="Escape"&&t&&(B.preventDefault(),u==null||u())},[D,t,u]),R=`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:B=>void D(B),className:`w-full ${f}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx(Sc,{ref:k,value:S,onChange:M,onKeyDown:j,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&c.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),c.jsx("div",{children:r?c.jsx(Qe,{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(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!p||T,children:c.jsx(ae.Send,{size:16})})})]})})}const Dx=y.memo(Cc);function me(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 kc(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=kc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():kc(e[o],null)}}}}function ze(...e){return m.useCallback(En(...e),e)}function Lx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function yn(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var v;const{scope:h,children:p,...w}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,$x(o,...t)]}function $x(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},Fx=m[" useInsertionEffect ".trim().toString()]||Et;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Bx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=zx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Bx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Fx(()=>{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 zx(e){return typeof e=="function"}var Hx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Hx.reduce((e,t)=>{const n=Bn.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 Tc(e,t){e&&bo.flushSync(()=>e.dispatchEvent(t))}function bi(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:v}=x,b=y.useRef(null),S=y.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:v})};i.displayName=t;const a=e+"CollectionSlot",l=Bn.createSlot(a),u=y.forwardRef((x,g)=>{const{scope:v,children:b}=x,S=s(a,v),T=ze(g,S.collectionRef);return c.jsx(l,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Bn.createSlot(d),p=y.forwardRef((x,g)=>{const{scope:v,children:b,...S}=x,T=y.useRef(null),C=ze(g,T),k=s(d,v);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(x){const g=s(e+"CollectionConsumer",x);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var Ux=m.createContext(void 0);function Fo(e){const t=m.useContext(Ux);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 Wx(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 Vx="DismissableLayer",yi="dismissableLayer.update",Kx="dismissableLayer.pointerDownOutside",qx="dismissableLayer.focusOutside",Ec,Ic=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(Ic),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=ze(t,E=>f(E)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=v,C=Xx(E=>{const A=E.target,O=[...u.branches].some($=>$.contains(A));!T||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Jx(E=>{const A=E.target;[...u.branches].some($=>$.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Wx(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&&(Ec=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Nc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ec)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Nc())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(yi,E),()=>document.removeEventListener(yi,E)},[]),c.jsx(ye.div,{...l,ref:w,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,k.onFocusCapture),onBlurCapture:me(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=Vx;var Gx="DismissableLayerBranch",Yx=m.forwardRef((e,t)=>{const n=m.useContext(Ic),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})});Yx.displayName=Gx;function Xx(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(){Ac(Kx,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 Jx(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&&Ac(qx,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 Nc(){const e=new CustomEvent(yi);document.dispatchEvent(e)}function Ac(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?Tc(o,s):o.dispatchEvent(s)}var Si=0;function Ci(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??jc()),document.body.insertAdjacentElement("beforeend",e[1]??jc()),Si++,()=>{Si===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Si--}},[])}function jc(){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 ki="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",_c={bubbles:!1,cancelable:!0},Zx="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,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:In(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||In(f.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&In(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(v);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Pc.add(p);const x=document.activeElement;if(!a.contains(x)){const v=new CustomEvent(ki,_c);a.addEventListener(ki,u),a.dispatchEvent(v),v.defaultPrevented||(Qx(ov(Mc(a)),{select:!0}),document.activeElement===x&&In(a))}return()=>{a.removeEventListener(ki,u),setTimeout(()=>{const v=new CustomEvent(Ti,_c);a.addEventListener(Ti,d),a.dispatchEvent(v),v.defaultPrevented||In(x??document.body,{select:!0}),a.removeEventListener(Ti,d),Pc.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(g&&v){const b=x.currentTarget,[S,T]=ev(b);S&&T?!x.shiftKey&&v===T?(x.preventDefault(),n&&In(S,{select:!0})):x.shiftKey&&v===S&&(x.preventDefault(),n&&In(T,{select:!0})):v===b&&x.preventDefault()}},[n,r,p.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=Zx;function Qx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}function ev(e){const t=Mc(e),n=Rc(t,e),r=Rc(t.reverse(),e);return[n,r]}function Mc(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 Rc(e,t){for(const n of e)if(!tv(n,{upTo:t}))return n}function tv(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 nv(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&&nv(e)&&t&&e.select()}}var Pc=rv();function rv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Oc(e,t),e.unshift(t)},remove(t){var n;e=Oc(e,t),(n=e[0])==null||n.resume()}}}function Oc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ov(e){return e.filter(t=>t.tagName!=="A")}var sv=m[" useId ".trim().toString()]||(()=>{}),iv=0;function Pt(e){const[t,n]=m.useState(sv());return Et(()=>{n(r=>r??String(iv++))},[e]),t?`radix-${t}`:""}const av=["top","right","bottom","left"],Nn=Math.min,Wt=Math.max,Ho=Math.round,Uo=Math.floor,dn=e=>({x:e,y:e}),lv={left:"right",right:"left",bottom:"top",top:"bottom"},cv={start:"end",end:"start"};function Ei(e,t,n){return Wt(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 Ii(e){return e==="x"?"y":"x"}function Ni(e){return e==="y"?"height":"width"}const uv=new Set(["top","bottom"]);function fn(e){return uv.has(Cn(e))?"y":"x"}function Ai(e){return Ii(fn(e))}function dv(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=Ai(e),s=Ni(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 fv(e){const t=Wo(e);return[ji(e),t,ji(t)]}function ji(e){return e.replace(/start|end/g,t=>cv[t])}const Dc=["left","right"],Lc=["right","left"],hv=["top","bottom"],pv=["bottom","top"];function mv(e,t,n){switch(e){case"top":case"bottom":return n?t?Lc:Dc:t?Dc:Lc;case"left":case"right":return t?hv:pv;default:return[]}}function gv(e,t,n,r){const o=fr(e);let s=mv(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ji)))),s}function Wo(e){return e.replace(/left|right|bottom|top/g,t=>lv[t])}function xv(e){return{top:0,right:0,bottom:0,left:0,...e}}function $c(e){return typeof e!="number"?xv(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 Fc(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=Ai(t),a=Ni(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(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 vv=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}=Fc(u,r,l),h=r,p={},w=0;for(let x=0;x<a.length;x++){const{name:g,fn:v}=a[x],{x:b,y:S,data:T,reset:C}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...T}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=Fc(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Fr(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),w=$c(p),g=a[h?f==="floating"?"reference":"floating":f],v=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,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Vo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(v.top-C.top+w.top)/T.y,bottom:(C.bottom-v.bottom+w.bottom)/T.y,left:(v.left-C.left+w.left)/T.x,right:(C.right-v.right+w.right)/T.x}}const wv=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=$c(d),h={x:n,y:r},p=Ai(o),w=Ni(p),x=await i.getDimensions(u),g=p==="y",v=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",T=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[w]);const A=T/2-C/2,O=E/2-x[w]/2-1,$=Nn(f[v],O),H=Nn(f[b],O),U=$,K=E-x[w]-H,P=E/2-x[w]/2+A,Y=Ei(U,P,K),N=!l.arrow&&fr(o)!=null&&P!==Y&&s.reference[w]/2-(P<U?$:H)-x[w]/2<0,D=N?P<U?P-U:P-K:0;return{[p]:h[p]+D,data:{[p]:Y,centerOffset:P-Y-D,...N&&{alignmentOffset:D}},reset:N}}}),bv=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:x=!0,...g}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Cn(o),b=fn(a),S=Cn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[Wo(a)]:fv(a)),k=w!=="none";!h&&k&&C.push(...gv(a,x,w,T));const E=[a,...C],A=await Fr(t,g),O=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(A[v]),f){const P=dv(o,i,T);O.push(A[P[0]],A[P[1]])}if($=[...$,{placement:o,overflows:O}],!O.every(P=>P<=0)){var H,U;const P=(((H=s.flip)==null?void 0:H.index)||0)+1,Y=E[P];if(Y&&(!(f==="alignment"?b!==fn(Y):!1)||$.every(M=>fn(M.placement)===b?M.overflows[0]>0:!0)))return{data:{index:P,overflows:$},reset:{placement:Y}};let N=(U=$.filter(D=>D.overflows[0]<=0).sort((D,M)=>D.overflows[1]-M.overflows[1])[0])==null?void 0:U.placement;if(!N)switch(p){case"bestFit":{var K;const D=(K=$.filter(M=>{if(k){const j=fn(M.placement);return j===b||j==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(j=>j>0).reduce((j,z)=>j+z,0)]).sort((M,j)=>M[1]-j[1])[0])==null?void 0:K[0];D&&(N=D);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function zc(e){return av.some(t=>e[t]>=0)}const yv=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 Fr(t,{...o,elementContext:"reference"}),i=Bc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:zc(i)}}}case"escaped":{const s=await Fr(t,{...o,altBoundary:!0}),i=Bc(s,n.floating);return{data:{escapedOffsets:i,escaped:zc(i)}}}default:return{}}}}},Hc=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),l=fn(n)==="y",u=Hc.has(i)?-1:1,d=s&&l?-1:1,f=Sn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Cv=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 Sv(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}}}}},kv=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:v,y:b}=g;return{x:v,y:b}}},...l}=Sn(e,t),u={x:n,y:r},d=await Fr(t,l),f=fn(Cn(o)),h=Ii(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=p+d[g],S=p-d[v];p=Ei(b,p,S)}if(i){const g=f==="y"?"top":"left",v=f==="y"?"bottom":"right",b=w+d[g],S=w-d[v];w=Ei(b,w,S)}const x=a.fn({...t,[h]:p,[f]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Tv=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=Ii(f);let p=d[h],w=d[f];const x=Sn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<T?p=T:p>C&&(p=C)}if(u){var v,b;const S=h==="y"?"width":"height",T=Hc.has(Cn(o)),C=s.reference[f]-s.floating[S]+(T&&((v=i.offset)==null?void 0:v[f])||0)+(T?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(T?0:((b=i.offset)==null?void 0:b[f])||0)-(T?g.crossAxis:0);w<C?w=C:w>k&&(w=k)}return{[h]:p,[f]:w}}}},Ev=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 Fr(t,u),f=Cn(o),h=fr(o),p=fn(o)==="y",{width:w,height:x}=s.floating;let g,v;f==="top"||f==="bottom"?(g=f,v=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=w-d.left-d.right,T=Nn(x-d[g],b),C=Nn(w-d[v],S),k=!t.middlewareData.shift;let E=T,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const $=Wt(d.left,0),H=Wt(d.right,0),U=Wt(d.top,0),K=Wt(d.bottom,0);p?A=w-2*($!==0||H!==0?$+H:Wt(d.left,d.right)):E=x-2*(U!==0||K!==0?U+K:Wt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const O=await i.getDimensions(a.floating);return w!==O.width||x!==O.height?{reset:{rects:!0}}:{}}}};function Ko(){return typeof window<"u"}function hr(e){return Uc(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=(Uc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Uc(e){return Ko()?e instanceof Node||e instanceof Vt(e).Node:!1}function rn(e){return Ko()?e instanceof Element||e instanceof Vt(e).Element:!1}function pn(e){return Ko()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function Wc(e){return!Ko()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const Iv=new Set(["inline","contents"]);function Br(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=on(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Iv.has(o)}const Nv=new Set(["table","td","th"]);function Av(e){return Nv.has(hr(e))}const jv=[":popover-open",":modal"];function qo(e){return jv.some(t=>{try{return e.matches(t)}catch{return!1}})}const _v=["transform","translate","scale","rotate","perspective"],Mv=["transform","translate","scale","rotate","perspective","filter"],Rv=["paint","layout","strict","content"];function _i(e){const t=Mi(),n=rn(e)?on(e):e;return _v.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))||Rv.some(r=>(n.contain||"").includes(r))}function Pv(e){let t=An(e);for(;pn(t)&&!pr(t);){if(_i(t))return t;if(qo(t))return null;t=An(t)}return null}function Mi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ov=new Set(["html","body","#document"]);function pr(e){return Ov.has(hr(e))}function on(e){return Vt(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(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Wc(e)&&e.host||hn(e);return Wc(t)?t.host:t}function Vc(e){const t=An(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&Br(t)?t:Vc(t)}function zr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Vc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],Br(o)?o:[],a&&n?zr(a):[])}return t.concat(o,zr(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Kc(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 Pi(e){return rn(e)?e:e.contextElement}function mr(e){const t=Pi(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Kc(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 Dv=dn(0);function qc(e){const t=Vt(e);return!Mi()||!t.visualViewport?Dv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lv(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Vt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=dn(1);t&&(r?rn(r)&&(i=mr(r)):i=mr(e));const a=Lv(s,n,r)?qc(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=Vt(s),p=r&&rn(r)?Vt(r):r;let w=h,x=Ri(w);for(;x&&r&&p!==w;){const g=mr(x),v=x.getBoundingClientRect(),b=on(x),S=v.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,T=v.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=T,w=Vt(x),x=Ri(w)}}return Vo({width:d,height:f,x:l,y:u})}function Yo(e,t){const n=Go(e).scrollLeft;return t?t.left+n:Vn(hn(e)).left+n}function Gc(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 $v(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)&&((hr(r)!=="body"||Br(i))&&(l=Go(r)),pn(r))){const p=Vn(r);u=mr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Gc(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 Fv(e){return Array.from(e.getClientRects())}function Bv(e){const t=hn(e),n=Go(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yo(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Yc=25;function zv(e,t){const n=Vt(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=Mi();(!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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Yc&&(s-=w)}else u<=Yc&&(s+=u);return{width:s,height:i,x:a,y:l}}const Hv=new Set(["absolute","fixed"]);function Uv(e,t){const n=Vn(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,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Xc(e,t,n){let r;if(t==="viewport")r=zv(e,n);else if(t==="document")r=Bv(hn(e));else if(rn(t))r=Uv(t,n);else{const o=qc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vo(r)}function Jc(e,t){const n=An(e);return n===t||!rn(n)||pr(n)?!1:on(n).position==="fixed"||Jc(n,t)}function Wv(e,t){const n=t.get(e);if(n)return n;let r=zr(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),l=_i(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Hv.has(o.position)||Br(i)&&!l&&Jc(e,i))?r=r.filter(d=>d!==i):o=a,i=An(i)}return t.set(e,r),r}function Vv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?qo(t)?[]:Wv(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Xc(t,d,o);return u.top=Wt(f.top,u.top),u.right=Nn(f.right,u.right),u.bottom=Nn(f.bottom,u.bottom),u.left=Wt(f.left,u.left),u},Xc(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Kv(e){const{width:t,height:n}=Kc(e);return{width:t,height:n}}function qv(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=Vn(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((hr(t)!=="body"||Br(o))&&(a=Go(t)),r){const p=Vn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?Gc(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 Oi(e){return on(e).position==="static"}function Zc(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 Qc(e,t){const n=Vt(e);if(qo(e))return n;if(!pn(e)){let o=An(e);for(;o&&!pr(o);){if(rn(o)&&!Oi(o))return o;o=An(o)}return n}let r=Zc(e,t);for(;r&&Av(r)&&Oi(r);)r=Zc(r,t);return r&&pr(r)&&Oi(r)&&!_i(r)?n:r||Pv(e)||n}const Gv=async function(e){const t=this.getOffsetParent||Qc,n=this.getDimensions,r=await n(e.floating);return{reference:qv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yv(e){return on(e).direction==="rtl"}const Xv={convertOffsetParentRelativeRectToViewportRelativeRect:$v,getDocumentElement:hn,getClippingRect:Vv,getOffsetParent:Qc,getElementRects:Gv,getClientRects:Fv,getDimensions:Kv,getScale:mr,isElement:rn,isRTL:Yv};function eu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Jv(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 w=Uo(f),x=Uo(o.clientWidth-(d+h)),g=Uo(o.clientHeight-(f+p)),v=Uo(d),S={rootMargin:-w+"px "+-x+"px "+-g+"px "+-v+"px",threshold:Wt(0,Nn(1,l))||1};let T=!0;function C(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&&!eu(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Zv(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=Pi(e),d=o||s?[...u?zr(u):[],...zr(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?Jv(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,x=l?Vn(e):null;l&&g();function g(){const v=Vn(e);x&&!eu(x,v)&&n(),x=v,w=requestAnimationFrame(g)}return n(),()=>{var v;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const Qv=Cv,ew=kv,tw=bv,nw=Ev,rw=yv,tu=wv,ow=Tv,sw=(e,t,n)=>{const r=new Map,o={platform:Xv,...n},s={...o.platform,_c:r};return vv(e,t,{...o,platform:s})};var iw=typeof document<"u",aw=function(){},Xo=iw?y.useLayoutEffect:aw;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 nu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ru(e,t){const n=nu(e);return Math.round(t*n)/n}function Di(e){const t=m.useRef(e);return Xo(()=>{t.current=e}),t}function lw(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[w,x]=m.useState(null),[g,v]=m.useState(null),b=m.useCallback(M=>{M!==k.current&&(k.current=M,x(M))},[]),S=m.useCallback(M=>{M!==E.current&&(E.current=M,v(M))},[]),T=s||w,C=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),O=l!=null,$=Di(l),H=Di(o),U=Di(u),K=m.useCallback(()=>{if(!k.current||!E.current)return;const M={placement:t,strategy:n,middleware:h};H.current&&(M.platform=H.current),sw(k.current,E.current,M).then(j=>{const z={...j,isPositioned:U.current!==!1};P.current&&!Jo(A.current,z)&&(A.current=z,bo.flushSync(()=>{f(z)}))})},[h,t,n,H,U]);Xo(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const P=m.useRef(!1);Xo(()=>(P.current=!0,()=>{P.current=!1}),[]),Xo(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if($.current)return $.current(T,C,K);K()}},[T,C,K,$,O]);const Y=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),N=m.useMemo(()=>({reference:T,floating:C}),[T,C]),D=m.useMemo(()=>{const M={position:n,left:0,top:0};if(!N.floating)return M;const j=ru(N.floating,d.x),z=ru(N.floating,d.y);return a?{...M,transform:"translate("+j+"px, "+z+"px)",...nu(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:z}},[n,a,N.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:K,refs:Y,elements:N,floatingStyles:D}),[d,K,Y,N,D])}const cw=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?tu({element:r.current,padding:o}).fn(n):{}:r?tu({element:r,padding:o}).fn(n):{}}}},uw=(e,t)=>({...Qv(e),options:[e,t]}),dw=(e,t)=>({...ew(e),options:[e,t]}),fw=(e,t)=>({...ow(e),options:[e,t]}),hw=(e,t)=>({...tw(e),options:[e,t]}),pw=(e,t)=>({...nw(e),options:[e,t]}),mw=(e,t)=>({...rw(e),options:[e,t]}),gw=(e,t)=>({...cw(e),options:[e,t]});var xw="Arrow",ou=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"})})});ou.displayName=xw;var vw=ou;function su(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 Li="Popper",[iu,Zo]=yn(Li),[ww,au]=iu(Li),lu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(ww,{scope:t,anchor:r,onAnchorChange:o,children:n})};lu.displayName=Li;var cu="PopperAnchor",uu=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=au(cu,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})});uu.displayName=cu;var $i="PopperContent",[bw,yw]=iu($i),du=m.forwardRef((e,t)=>{var G,L,V,Z,q,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:w,...x}=e,g=au($i,n),[v,b]=m.useState(null),S=ze(t,pe=>b(pe)),[T,C]=m.useState(null),k=su(T),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,O=r+(s!=="center"?"-"+s:""),$=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:$,boundary:H.filter(Cw),altBoundary:U},{refs:P,floatingStyles:Y,placement:N,isPositioned:D,middlewareData:M}=lw({strategy:"fixed",placement:O,whileElementsMounted:(...pe)=>Zv(...pe,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[uw({mainAxis:o+A,alignmentAxis:i}),l&&dw({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?fw():void 0,...K}),l&&hw({...K}),pw({...K,apply:({elements:pe,rects:he,availableWidth:ee,availableHeight:le})=>{const{width:we,height:je}=he.reference,Ne=pe.floating.style;Ne.setProperty("--radix-popper-available-width",`${ee}px`),Ne.setProperty("--radix-popper-available-height",`${le}px`),Ne.setProperty("--radix-popper-anchor-width",`${we}px`),Ne.setProperty("--radix-popper-anchor-height",`${je}px`)}}),T&&gw({element:T,padding:a}),kw({arrowWidth:E,arrowHeight:A}),h&&mw({strategy:"referenceHidden",...K})]}),[j,z]=pu(N),W=It(w);Et(()=>{D&&(W==null||W())},[D,W]);const R=(G=M.arrow)==null?void 0:G.x,B=(L=M.arrow)==null?void 0:L.y,te=((V=M.arrow)==null?void 0:V.centerOffset)!==0,[J,re]=m.useState();return Et(()=>{v&&re(window.getComputedStyle(v).zIndex)},[v]),c.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:D?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=M.transformOrigin)==null?void 0:Z.x,(q=M.transformOrigin)==null?void 0:q.y].join(" "),...((X=M.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(bw,{scope:n,placedSide:j,onArrowChange:C,arrowX:R,arrowY:B,shouldHideArrow:te,children:c.jsx(ye.div,{"data-side":j,"data-align":z,...x,ref:S,style:{...x.style,animation:D?void 0:"none"}})})})});du.displayName=$i;var fu="PopperArrow",Sw={top:"bottom",right:"left",bottom:"top",left:"right"},hu=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=yw(fu,r),i=Sw[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(vw,{...o,ref:n,style:{...o.style,display:"block"}})})});hu.displayName=fu;function Cw(e){return e!==null}var kw=e=>({name:"transformOrigin",options:e,fn(t){var g,v,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]=pu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",x="";return u==="bottom"?(w=i?f:`${h}px`,x=`${-l}px`):u==="top"?(w=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:w,y:x}}}});function pu(e){const[t,n="center"]=e.split("-");return[t,n]}var mu=lu,gu=uu,xu=du,vu=hu,Tw="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?Zs.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});Qo.displayName=Tw;function Ew(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=Iw(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=ze(r.ref,Nw(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function Iw(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Ew(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 x=es(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=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 Nw(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 Fi="rovingFocusGroup.onEntryFocus",Aw={bubbles:!1,cancelable:!0},Hr="RovingFocusGroup",[Bi,wu,jw]=bi(Hr),[_w,bu]=yn(Hr,[jw]),[Mw,Rw]=_w(Hr),yu=m.forwardRef((e,t)=>c.jsx(Bi.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Bi.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Pw,{...e,ref:t})})}));yu.displayName=Hr;var Pw=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),w=Fo(s),[x,g]=dr({prop:i,defaultProp:a??null,onChange:l,caller:Hr}),[v,b]=m.useState(!1),S=It(u),T=wu(n),C=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Fi,S),()=>A.removeEventListener(Fi,S)},[S]),c.jsx(Mw,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(ye.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{C.current=!0}),onFocus:me(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!v){const $=new CustomEvent(Fi,Aw);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const H=T().filter(N=>N.focusable),U=H.find(N=>N.active),K=H.find(N=>N.id===x),Y=[U,K,...H].filter(Boolean).map(N=>N.ref.current);ku(Y,d)}}C.current=!1}),onBlur:me(e.onBlur,()=>b(!1))})})}),Su="RovingFocusGroupItem",Cu=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=Rw(Su,n),f=d.currentTabStopId===u,h=wu(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(Bi.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:me(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:me(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const v=Lw(g,d.orientation,d.dir);if(v!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const T=S.indexOf(g.currentTarget);S=d.loop?$w(S,T+1):S.slice(T+1)}setTimeout(()=>ku(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Cu.displayName=Su;var Ow={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Lw(e,t,n){const r=Dw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ow[r]}function ku(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $w(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Fw=yu,Bw=Cu,zw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gr=new WeakMap,ts=new WeakMap,ns={},zi=0,Tu=function(e){return e&&(e.host||Tu(e.parentNode))},Hw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Tu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Uw=function(e,t,n,r){var o=Hw(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),w=p!==null&&p!=="false",x=(gr.get(h)||0)+1,g=(s.get(h)||0)+1;gr.set(h,x),s.set(h,g),i.push(h),x===1&&w&&ts.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return d(t),a.clear(),zi++,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||(ts.has(f)||f.removeAttribute(r),ts.delete(f)),p||f.removeAttribute(n)}),zi--,zi||(gr=new WeakMap,gr=new WeakMap,ts=new WeakMap,ns={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=zw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Uw(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 Eu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ww(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",Vw="with-scroll-bars-hidden",Kw="--removed-body-scroll-bar-size";function Ui(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function qw(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 Gw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Iu=new WeakMap;function Yw(e,t){var n=qw(null,function(r){return e.forEach(function(o){return Ui(o,r)})});return Gw(function(){var r=Iu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ui(a,null)}),s.forEach(function(a){o.has(a)||Ui(a,i)})}Iu.set(n,e)},[e]),n}function Xw(e){return e}function Jw(e,t){t===void 0&&(t=Xw);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 Zw(e){e===void 0&&(e={});var t=Jw(null);return t.options=mn({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Eu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,mn({},n))};Nu.isSideCarExport=!0;function Qw(e,t){return e.useMedium(t),Nu}var Au=Zw(),Wi=function(){},ss=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,x=e.inert,g=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,S=e.gapMode,T=Eu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Yw([n,t]),E=mn(mn({},T),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Au,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),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 eb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eb();return t&&e.setAttribute("nonce",t),e}function nb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ob=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tb())&&(nb(t,n),rb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},sb=function(){var e=ob();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ju=function(){var e=sb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},ib={left:0,top:0,right:0,gap:0},Vi=function(e){return parseInt(e||"",10)||0},ab=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[Vi(n),Vi(r),Vi(o)]},lb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ib;var t=ab(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])}},cb=ju(),xr="data-scroll-locked",ub=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
38
|
+
`))>=0;){const ie=at.slice(0,_);at=at.slice(_+2);const ge=kx(ie);if(!ge)continue;let We;try{We=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const Pe=Cx(We)?We.data:We;yt=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=N==null?void 0:N.onGap)==null||L.call(N,{from:Oe,to:mt})),Oe=mt,C.current=mt,g(mt)}if(Pe.type==="checkpoint")E.current=Pe.checkpointId??null,A.current=Pe.checkpointNs??null,w(Pe.checkpointId??null);else if(Pe.type==="state_history"){O.current=Pe;try{const Nt=Wn(Pe).latest;Nt&&(E.current=Nt.checkpointId??null,A.current=Nt.checkpointNs??null,w(Nt.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{Y==null||Y(Pe)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",Pe.type)}if(Pe.type==="message.delta"){const Je=Pe.delta.filter(Nt=>Nt.type==="text").map(Nt=>Nt.text).join("");Je&&e.autoAppendAssistant!==!1&&(Te.push(Je),Tt())}else if(Pe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(V=N==null?void 0:N.onHeartbeat)==null||V.call(N,Pe)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(it!==null&&cancelAnimationFrame(it),ht(),Pe.type==="checkpoint")w(Pe.checkpointId);else if(Pe.type==="error"){const Je=Pe;if(d(Je.message),M="error",j=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((Z=Je.message)==null?void 0:Z.includes("token"))||((q=Je.message)==null?void 0:q.includes("401"))||((X=Je.message)==null?void 0:X.includes("unauthorized"))||((pe=Je.message)==null?void 0:pe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(he=N==null?void 0:N.onAuthError)==null||he.call(N,Je.message)}catch(go){console.warn("[use-chat] onAuthError handler failed",go)}D.abort()}}}}ht(),M===null&&!D.signal.aborted&&(M="complete")}catch(Xe){if(Xe.name==="AbortError")M=M??"aborted";else{const Ke=Xe.message||String(Xe);M="error",j=Ke,d(Ke),(ee=N==null?void 0:N.onError)==null||ee.call(N,Ke)}}finally{try{await rt.cancel()}catch{}finally{(le=rt.releaseLock)==null||le.call(rt)}it!==null&&typeof window<"u"&&window.cancelAnimationFrame(it),clearInterval(Le)}}catch($e){if($e.name==="AbortError")M=M??"aborted";else{const Ye=$e.message||String($e);M="error",j=Ye,d(Ye),(we=N==null?void 0:N.onError)==null||we.call(N,Ye),z||((je=N==null?void 0:N.onConnectionError)==null||je.call(N,Ye),z=!0)}}finally{const $e=C.current,Ye=E.current,nt=A.current,Ve=O.current,qe=M??(D.signal.aborted?"aborted":j?"error":"complete");try{(Ne=N==null?void 0:N.onClosed)==null||Ne.call(N,{reason:qe,lastSeq:$e,lastCheckpointId:Ye,lastCheckpointNs:nt,lastStateHistory:Ve,error:j})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}c(!1),b(!1),S.current=null,C.current=0,g(0),k.current=null}})(),{close:()=>D.abort()}},[t,n,r,e.autoAppendAssistant]);return y.useEffect(()=>()=>{var P;T.current=!1,(P=S.current)==null||P.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:x,connected:v,stream:K,stop:U,clear:H,setToken:$}}function Cx(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function kx(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 Tx=["message.start","message.delta","message.end"],Ex=["tool.start","tool.end","tool.progress"],Ix=["thread_info","checkpoint"],Nx=["error","interrupt","heartbeat","state_history","cancelled"],Ax=[...Tx,...Ex,...Ix,...Nx],jx=new Set(Ax);function _x(e){if(typeof e!="object"||e===null||typeof e.type!="string")return!1;const t=e.type;return jx.has(t)}const xc=200;function Mx({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),w=y.useRef(null),x=y.useRef(null),g=y.useCallback(N=>{try{const D=globalThis.structuredClone;if(typeof D=="function")return D(N)}catch{}try{return JSON.parse(JSON.stringify(N))}catch{return N}},[]),v=y.useCallback((N,D)=>{if(!N)return;const M=p.current.get(N)??[],j=g(D),z=M.length>=xc?[...M.slice(M.length-xc+1),j]:[...M,j];p.current.set(N,z)},[g]),b=y.useCallback(N=>{N&&p.current.set(N,[])},[]),S=y.useCallback(N=>{const D=N??h.current;if(!D)return;const M=p.current.get(D);M!=null&&M.length&&M.forEach(j=>{try{n(j)}catch(z){console.error("[useChatStreamingService] Failed to replay buffered event",z)}})},[n]),T=y.useCallback(N=>{h.current=N.threadId,w.current&&(w.current.threadIdGuess=N.threadId),x.current=N,b(N.threadId),console.log("[useChatStreamingService] 🎯 Received thread_info event:",N);try{t(N)}catch(D){console.error("[useChatStreamingService] Error in onThreadInfo handler:",D)}},[b,t]),C=y.useCallback(N=>{try{u==null||u(N)}catch(D){console.error("[useChatStreamingService] Error in onHeartbeat handler:",D)}},[u]),k=y.useCallback(N=>{var j,z,W,R;const D=N;if(D.error_type==="auth_error"||D.code==="TOKEN_EXPIRED"||((j=D.message)==null?void 0:j.includes("token"))||((z=D.message)==null?void 0:z.includes("401"))||((W=D.message)==null?void 0:W.includes("unauthorized"))||((R=D.message)==null?void 0:R.includes("Unauthorized"))){console.error("[useChatStreamingService] Auth error event detected:",D.message);try{c==null||c(D.message)}catch(B){console.warn("[useChatStreamingService] onAuthError handler failed",B)}}},[c]),E=y.useMemo(()=>({thread_info:N=>(T(N),!0),heartbeat:N=>(C(N),!0),error:N=>(k(N),!1)}),[T,C,k]),A=y.useCallback(N=>{var z;const D=N.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 M=E[N.type];if(M&&M(N))return;const j=N.threadId??(N.type==="state_history"?N.threadId:void 0)??h.current??((z=w.current)==null?void 0:z.threadIdGuess)??null;if(N.type==="state_history"){h.current=j??h.current;try{r==null||r(N)}catch(W){console.error("[useChatStreamingService] onStateHistory handler failed",W)}}if(_x(N)){(N.type==="tool.start"||N.type==="tool.end")&&(d==null||d(N)),N.type==="checkpoint"||N.type==="state_history"?b(j??null):v(j??null,N);try{n(N)}catch(W){console.error("[useChatStreamingService] Error in onMessageEvent handler:",W)}return}try{o==null||o(N)}catch(W){console.error("[useChatStreamingService] Error in onUnhandledEvent handler:",W)}},[v,b,n,s,r,o,E]),{stream:O,stop:$,isStreaming:H,error:U,setToken:K}=gc({baseUrl:e,token:void 0}),P=y.useCallback((N,D)=>{f.current=null,x.current=null,h.current=N.threadId??null,w.current={request:N,callbacks:D,manualStop:!1,threadIdGuess:N.threadId??null},O(N,A,{onOpen:D==null?void 0:D.onOpen,onError:M=>{var j;(j=D==null?void 0:D.onError)==null||j.call(D,M)},onGap:(D==null?void 0:D.onGap)??s,onConnectionError:M=>{var j;a==null||a(M),(j=D==null?void 0:D.onConnectionError)==null||j.call(D,M)},onAuthError:M=>{var j;c==null||c(M),(j=D==null?void 0:D.onAuthError)==null||j.call(D,M)},onHeartbeat:M=>{var j;try{u==null||u(M)}catch(z){console.warn("[useChatStreamingService] onHeartbeat handler failed",z)}try{(j=D==null?void 0:D.onHeartbeat)==null||j.call(D,M)}catch(z){console.warn("[useChatStreamingService] downstream onHeartbeat handler failed",z)}},onClosed:M=>{var R,B,te,J;const j=((R=w.current)==null?void 0:R.manualStop)??!1,z=h.current??((B=w.current)==null?void 0:B.threadIdGuess)??((te=M.lastStateHistory)==null?void 0:te.threadId)??null;(M.reason==="complete"||M.reason==="aborted"&&j)&&b(z);const W={...M,threadId:z,threadInfo:x.current,manualStop:j};try{i==null||i(W)}catch(re){console.warn("[useChatStreamingService] onStreamClosed handler failed",re)}try{(J=D==null?void 0:D.onClosed)==null||J.call(D,W)}catch(re){console.warn("[useChatStreamingService] downstream onClosed handler failed",re)}w.current&&(w.current=null)}})},[b,A,c,a,u,s,i,O]),Y=y.useCallback(()=>{w.current&&(w.current.manualStop=!0),$()},[$]);return y.useMemo(()=>({startStream:P,stop:Y,isStreaming:H,error:U,setAuthToken:K,replayBufferedEvents:S}),[P,Y,H,U,K,S])}const vc=y.createContext(null),wc=y.createContext(null),bc=y.createContext(null);y.createContext(!1);function Rx({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(()=>bn(f),[f]),{state:p,seed:w,prepend:x,pushUser:g,onEvent:v}=fc(),{threads:b,currentThreadId:S,setCurrentThreadId:T,currentThreadIdRef:C,isLoadingThreads:k,threadsError:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,addThreadFromEvent:H,shareInFlight:U,shareStatus:K,clearShareStatus:P}=tx({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>w([],{})}),[Y,N]=y.useState(!1),D=y.useCallback(()=>p.messages,[p.messages]),{threadCheckpoints:M,threadTimeline:j,isLoadingThread:z,isHistoryLoading:W,isLoadingCheckpoint:R,threadStateError:B,hasMoreHistory:te,loadThread:J,navigateToCheckpoint:re,loadOlderMessages:G,setCurrentCheckpointId:L,returnToLatest:V,handleStateHistoryEvent:Z,markSkipNextLoad:q,markStreamPendingThread:X,resetHistoryState:pe}=Zg({api:d,seed:w,prepend:x,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:Y,getMessages:D}),he=y.useMemo(()=>Kg(M),[M]),ee=y.useCallback(Te=>{console.log("[ChatSessionProvider] 🎯 Received thread_info:",Te.threadId),H(Te),C.current!==Te.threadId&&((Te.created??!C.current)&&q(Te.threadId),X(Te.threadId),console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"),T(Te.threadId))},[H,q,X]),{startStream:le,stop:we,isStreaming:je,error:Ne,setAuthToken:$e}=Mx({baseUrl:h,onThreadInfo:ee,onMessageEvent:v,onStateHistory:Z,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(()=>{N(je)},[je]);const Ye=y.useCallback(async()=>{w([],{}),T(null),we(),pe();try{await d.getAgent("default")}catch(Te){console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:",Te)}},[w,we,d,pe]),nt=y.useCallback(async(Te,Oe,it)=>{const ht=C.current;if(!ht)throw new Error("No active thread to handle interrupt");const Tt=Oe?it??!0:!1;try{const yt={threadId:ht,checkpointId:p.lastCheckpointId??void 0,checkpointNs:p.lastCheckpointNs??void 0,command:{kind:"resume",value:Tt}};le(yt)}catch(yt){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${Te}:`,yt),yt}},[p.lastCheckpointId,p.lastCheckpointNs,le]),Ve=y.useCallback(async(Te,Oe)=>{let it=C.current;const ht=(Te==null?void 0:Te.text)??"",Tt=(Te==null?void 0:Te.attachments)??[],yt=(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 Xe=!!(Ht&&Ht.length);if(!it&&!yt&&Tt.length===0&&!Xe)return;if(!it){const mt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Je=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);it=`${mt}${Je}`,q(it),T(it)}const{contentParts:Ke,filesInfo:dt}=await Ug(Tt),vt=[...Ke];yt&&vt.push({type:"text",text:ht});const Ue=Oe==null?void 0:Oe.originalMessageId,St=!!(Oe!=null&&Oe.edit&&Ue),_=!Xe&&vt.length>0;let ie=null;_&&(ie={id:St?Ue:`msg-${Date.now()}`,role:"user",content:vt,createdAt:new Date().toISOString()},St?g(ie,Ue):g(ie));const ge=Xe?Ht:ie?[ie]:[],We={...Le,...dt.length?{files_info:dt}:{}};ge.length?We.messages=ge:"messages"in We||(We.messages=[]);const Pe={threadId:it,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:j};le(Pe)},[d,g,p,le,j]),qe=y.useMemo(()=>({threads:b,currentThreadId:S,setCurrentThreadId:T,isLoading:k,error:E,sharedThreads:A,isLoadingSharedThreads:O,actions:$,shareInFlight:U,shareStatus:K,clearShareStatus:P}),[b,S,T,k,E,A,O,$,U,K,P]),rt=y.useMemo(()=>{const Te=p.assemblingId??null;return Te?{assemblingMessageId:Te}:null},[p.assemblingId]),kt=y.useMemo(()=>({threadId:S,messages:p.messages,interrupt:null,checkpoint:{id:p.lastCheckpointId??null,namespace:p.lastCheckpointNs??null},checkpoints:M,timelineCheckpoints:j,metadata:rt,isLoading:z,isHistoryLoading:W,isLoadingCheckpoint:R,error:B,hasMore:te,loadOlder:G,clearState:Ye,navigateToCheckpoint:re,setCurrentCheckpointId:L,returnToLatest:V,loadThread:J,clearThread:Ye,respondToInterrupt:nt,messagePreviews:he}),[S,p,M,j,z,W,R,B,te,G,Ye,re,L,V,J,nt,he,rt]),at=y.useMemo(()=>({isStreaming:je,error:Ne,connectionState:je?"connected":"idle",submit:Ve,send:Ve,stop:we,setAuthToken:$e}),[je,Ne,Ve,we,$e]);return l.jsx(vc.Provider,{value:qe,children:l.jsx(wc.Provider,{value:kt,children:l.jsx(bc.Provider,{value:at,children:e})})})}function Do(){const e=y.useContext(vc);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Lo(){const e=y.useContext(wc);if(!e)throw new Error("useThreadState must be used within ChatSessionProvider");return e}function yc(){const e=y.useContext(bc);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:c,onThreadChange:u,onToolEnd:d}){return l.jsx(zg,{apiConfig:t,children:l.jsx(Rx,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:c,onConnectionError:i,onThreadChange:u,onToolEnd:d,children:e})})}function oe(...e){return pm.twMerge(hm.clsx(e))}const Px=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"}}),Qe=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Bn.Slot:"button";return l.jsx(i,{className:oe(Px({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";const Sc=m.forwardRef(({className:e,...t},n)=>l.jsx("textarea",{className:oe("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}));Sc.displayName="Textarea";const Ox=1e4;function Cc({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=Ox,value:i,onValueChange:a,onSend:c,onCancelEdit:u,onStop:d,className:f="",textareaClassName:h="",allowEmptySend:p=!1,validate:w,onValidationError:x}){const g=i!==void 0,[v,b]=y.useState(e),S=(g?i:v)??"",[T,C]=y.useTransition(),k=y.useRef(null),E=y.useRef(0),A=y.useRef(null),O=y.useRef("");y.useEffect(()=>{g||(b(e??""),A.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,g]);const[$,H]=y.useState(null),U=y.useCallback(B=>B.length>s?`Message too long (${B.length}/${s} characters)`:null,[s]),K=y.useMemo(()=>w??U,[w,U]),P=y.useCallback(B=>{const te=K(B);return H(te),x==null||x(te),O.current=B,te},[K,x]),Y=y.useCallback(()=>{const B=k.current;B&&(B.style.height="auto",B.style.height=`${B.scrollHeight}px`)},[]);y.useEffect(()=>{Y()},[Y,S]),y.useEffect(()=>{if(!$)return;const B=(S??"").trim();O.current!==B&&P(B)},[S,$,P]);const N=y.useCallback((B,{fromUser:te})=>{g||b(B),te&&(a==null||a(B))},[g,a]),D=y.useCallback(async B=>{B&&B.preventDefault();const te=(S??"").trim();if(!te&&!p||P(te))return;const J=++E.current;A.current={id:J,shouldClear:!0},C(()=>{var re,G,L;try{const V=c(te);V&&typeof V.then=="function"?V.then(()=>{var Z,q;((Z=A.current)==null?void 0:Z.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((q=A.current)==null?void 0:q.id)===J&&(A.current=null)}).catch(()=>{var Z;((Z=A.current)==null?void 0:Z.id)===J&&(A.current=null)}):(((re=A.current)==null?void 0:re.id)===J&&A.current.shouldClear&&(g||(b(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((G=A.current)==null?void 0:G.id)===J&&(A.current=null))}catch{((L=A.current)==null?void 0:L.id)===J&&(A.current=null)}})},[S,c,p,g,a,P]),M=y.useCallback(B=>{const te=B.target.value;N(te,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),$&&P(te.trim())},[N,P,$]),j=y.useCallback(B=>{B.key==="Enter"&&!B.shiftKey?(B.preventDefault(),D()):B.key==="Escape"&&t&&(B.preventDefault(),u==null||u())},[D,t,u]),R=`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:B=>void D(B),className:`w-full ${f}`,children:l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx(Sc,{ref:k,value:S,onChange:M,onKeyDown:j,placeholder:t?"Edit your message...":n,className:R,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),$&&l.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:$})]}),l.jsx("div",{children:r?l.jsx(Qe,{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(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!p||T,children:l.jsx(ae.Send,{size:16})})})]})})}const Dx=y.memo(Cc);function me(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 kc(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=kc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():kc(e[o],null)}}}}function ze(...e){return m.useCallback(En(...e),e)}function Lx(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 v;const{scope:h,children:p,...w}=f,x=((v=h==null?void 0:h[e])==null?void 0:v[c])||a,g=m.useMemo(()=>w,Object.values(w));return l.jsx(x.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var x;const p=((x=h==null?void 0:h[e])==null?void 0:x[c])||a,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,$x(o,...t)]}function $x(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope: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:()=>{},Fx=m[" useInsertionEffect ".trim().toString()]||Et;function dr({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Bx({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=zx(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 Bx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return Fx(()=>{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 zx(e){return typeof e=="function"}var Hx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Hx.reduce((e,t)=>{const n=Bn.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 Tc(e,t){e&&bo.flushSync(()=>e.dispatchEvent(t))}function bi(e){const t=e+"CollectionProvider",[n,r]=yn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:v}=x,b=y.useRef(null),S=y.useRef(new Map).current;return l.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:v})};i.displayName=t;const a=e+"CollectionSlot",c=Bn.createSlot(a),u=y.forwardRef((x,g)=>{const{scope:v,children:b}=x,S=s(a,v),T=ze(g,S.collectionRef);return l.jsx(c,{ref:T,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=Bn.createSlot(d),p=y.forwardRef((x,g)=>{const{scope:v,children:b,...S}=x,T=y.useRef(null),C=ze(g,T),k=s(d,v);return y.useEffect(()=>(k.itemMap.set(T,{ref:T,...S}),()=>void k.itemMap.delete(T))),l.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(x){const g=s(e+"CollectionConsumer",x);return y.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((k,E)=>S.indexOf(k.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var Ux=m.createContext(void 0);function Fo(e){const t=m.useContext(Ux);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 Wx(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 Vx="DismissableLayer",yi="dismissableLayer.update",Kx="dismissableLayer.pointerDownOutside",qx="dismissableLayer.focusOutside",Ec,Ic=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,...c}=e,u=m.useContext(Ic),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=ze(t,E=>f(E)),x=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(g),b=d?x.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,T=b>=v,C=Xx(E=>{const A=E.target,O=[...u.branches].some($=>$.contains(A));!T||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),k=Jx(E=>{const A=E.target;[...u.branches].some($=>$.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Wx(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&&(Ec=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Nc(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Ec)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Nc())},[d,u]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(yi,E),()=>document.removeEventListener(yi,E)},[]),l.jsx(ye.div,{...c,ref:w,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:me(e.onFocusCapture,k.onFocusCapture),onBlurCapture:me(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:me(e.onPointerDownCapture,C.onPointerDownCapture)})});Bo.displayName=Vx;var Gx="DismissableLayerBranch",Yx=m.forwardRef((e,t)=>{const n=m.useContext(Ic),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})});Yx.displayName=Gx;function Xx(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(){Ac(Kx,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 Jx(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&&Ac(qx,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 Nc(){const e=new CustomEvent(yi);document.dispatchEvent(e)}function Ac(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?Tc(o,s):o.dispatchEvent(s)}var Si=0;function Ci(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??jc()),document.body.insertAdjacentElement("beforeend",e[1]??jc()),Si++,()=>{Si===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Si--}},[])}function jc(){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 ki="focusScope.autoFocusOnMount",Ti="focusScope.autoFocusOnUnmount",_c={bubbles:!1,cancelable:!0},Zx="FocusScope",zo=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,x=>c(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let x=function(S){if(p.paused||!a)return;const T=S.target;a.contains(T)?f.current=T:In(f.current,{select:!0})},g=function(S){if(p.paused||!a)return;const T=S.relatedTarget;T!==null&&(a.contains(T)||In(f.current,{select:!0}))},v=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&In(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const b=new MutationObserver(v);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){Pc.add(p);const x=document.activeElement;if(!a.contains(x)){const v=new CustomEvent(ki,_c);a.addEventListener(ki,u),a.dispatchEvent(v),v.defaultPrevented||(Qx(ov(Mc(a)),{select:!0}),document.activeElement===x&&In(a))}return()=>{a.removeEventListener(ki,u),setTimeout(()=>{const v=new CustomEvent(Ti,_c);a.addEventListener(Ti,d),a.dispatchEvent(v),v.defaultPrevented||In(x??document.body,{select:!0}),a.removeEventListener(Ti,d),Pc.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(x=>{if(!n&&!r||p.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(g&&v){const b=x.currentTarget,[S,T]=ev(b);S&&T?!x.shiftKey&&v===T?(x.preventDefault(),n&&In(S,{select:!0})):x.shiftKey&&v===S&&(x.preventDefault(),n&&In(T,{select:!0})):v===b&&x.preventDefault()}},[n,r,p.paused]);return l.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});zo.displayName=Zx;function Qx(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(In(r,{select:t}),document.activeElement!==n)return}function ev(e){const t=Mc(e),n=Rc(t,e),r=Rc(t.reverse(),e);return[n,r]}function Mc(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 Rc(e,t){for(const n of e)if(!tv(n,{upTo:t}))return n}function tv(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 nv(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&&nv(e)&&t&&e.select()}}var Pc=rv();function rv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Oc(e,t),e.unshift(t)},remove(t){var n;e=Oc(e,t),(n=e[0])==null||n.resume()}}}function Oc(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ov(e){return e.filter(t=>t.tagName!=="A")}var sv=m[" useId ".trim().toString()]||(()=>{}),iv=0;function Pt(e){const[t,n]=m.useState(sv());return Et(()=>{n(r=>r??String(iv++))},[e]),t?`radix-${t}`:""}const av=["top","right","bottom","left"],Nn=Math.min,Wt=Math.max,Ho=Math.round,Uo=Math.floor,dn=e=>({x:e,y:e}),lv={left:"right",right:"left",bottom:"top",top:"bottom"},cv={start:"end",end:"start"};function Ei(e,t,n){return Wt(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 Ii(e){return e==="x"?"y":"x"}function Ni(e){return e==="y"?"height":"width"}const uv=new Set(["top","bottom"]);function fn(e){return uv.has(Cn(e))?"y":"x"}function Ai(e){return Ii(fn(e))}function dv(e,t,n){n===void 0&&(n=!1);const r=fr(e),o=Ai(e),s=Ni(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 fv(e){const t=Wo(e);return[ji(e),t,ji(t)]}function ji(e){return e.replace(/start|end/g,t=>cv[t])}const Dc=["left","right"],Lc=["right","left"],hv=["top","bottom"],pv=["bottom","top"];function mv(e,t,n){switch(e){case"top":case"bottom":return n?t?Lc:Dc:t?Dc:Lc;case"left":case"right":return t?hv:pv;default:return[]}}function gv(e,t,n,r){const o=fr(e);let s=mv(Cn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ji)))),s}function Wo(e){return e.replace(/left|right|bottom|top/g,t=>lv[t])}function xv(e){return{top:0,right:0,bottom:0,left:0,...e}}function $c(e){return typeof e!="number"?xv(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 Fc(e,t,n){let{reference:r,floating:o}=e;const s=fn(t),i=Ai(t),a=Ni(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 vv=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}=Fc(u,r,c),h=r,p={},w=0;for(let x=0;x<a.length;x++){const{name:g,fn:v}=a[x],{x:b,y:S,data:T,reset:C}=await v({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...T}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=Fc(u,h,c)),x=-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:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Sn(t,e),w=$c(p),g=a[h?f==="floating"?"reference":"floating":f],v=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:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Vo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:c}):b);return{top:(v.top-C.top+w.top)/T.y,bottom:(C.bottom-v.bottom+w.bottom)/T.y,left:(v.left-C.left+w.left)/T.x,right:(C.right-v.right+w.right)/T.x}}const wv=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=$c(d),h={x:n,y:r},p=Ai(o),w=Ni(p),x=await i.getDimensions(u),g=p==="y",v=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",T=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=k?k[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(k)))&&(E=a.floating[S]||s.floating[w]);const A=T/2-C/2,O=E/2-x[w]/2-1,$=Nn(f[v],O),H=Nn(f[b],O),U=$,K=E-x[w]-H,P=E/2-x[w]/2+A,Y=Ei(U,P,K),N=!c.arrow&&fr(o)!=null&&P!==Y&&s.reference[w]/2-(P<U?$:H)-x[w]/2<0,D=N?P<U?P-U:P-K:0;return{[p]:h[p]+D,data:{[p]:Y,centerOffset:P-Y-D,...N&&{alignmentOffset:D}},reset:N}}}),bv=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:w="none",flipAlignment:x=!0,...g}=Sn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=Cn(o),b=fn(a),S=Cn(a)===a,T=await(c.isRTL==null?void 0:c.isRTL(u.floating)),C=h||(S||!x?[Wo(a)]:fv(a)),k=w!=="none";!h&&k&&C.push(...gv(a,x,w,T));const E=[a,...C],A=await Br(t,g),O=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(A[v]),f){const P=dv(o,i,T);O.push(A[P[0]],A[P[1]])}if($=[...$,{placement:o,overflows:O}],!O.every(P=>P<=0)){var H,U;const P=(((H=s.flip)==null?void 0:H.index)||0)+1,Y=E[P];if(Y&&(!(f==="alignment"?b!==fn(Y):!1)||$.every(M=>fn(M.placement)===b?M.overflows[0]>0:!0)))return{data:{index:P,overflows:$},reset:{placement:Y}};let N=(U=$.filter(D=>D.overflows[0]<=0).sort((D,M)=>D.overflows[1]-M.overflows[1])[0])==null?void 0:U.placement;if(!N)switch(p){case"bestFit":{var K;const D=(K=$.filter(M=>{if(k){const j=fn(M.placement);return j===b||j==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(j=>j>0).reduce((j,z)=>j+z,0)]).sort((M,j)=>M[1]-j[1])[0])==null?void 0:K[0];D&&(N=D);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function zc(e){return av.some(t=>e[t]>=0)}const yv=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=Bc(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:zc(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=Bc(s,n.floating);return{data:{escapedOffsets:i,escaped:zc(i)}}}default:return{}}}}},Hc=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=Hc.has(i)?-1:1,d=s&&c?-1:1,f=Sn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Cv=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}}}}},kv=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:v,y:b}=g;return{x:v,y:b}}},...c}=Sn(e,t),u={x:n,y:r},d=await Br(t,c),f=fn(Cn(o)),h=Ii(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=p+d[g],S=p-d[v];p=Ei(b,p,S)}if(i){const g=f==="y"?"top":"left",v=f==="y"?"bottom":"right",b=w+d[g],S=w-d[v];w=Ei(b,w,S)}const x=a.fn({...t,[h]:p,[f]:w});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Tv=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=Ii(f);let p=d[h],w=d[f];const x=Sn(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<T?p=T:p>C&&(p=C)}if(u){var v,b;const S=h==="y"?"width":"height",T=Hc.has(Cn(o)),C=s.reference[f]-s.floating[S]+(T&&((v=i.offset)==null?void 0:v[f])||0)+(T?0:g.crossAxis),k=s.reference[f]+s.reference[S]+(T?0:((b=i.offset)==null?void 0:b[f])||0)-(T?g.crossAxis:0);w<C?w=C:w>k&&(w=k)}return{[h]:p,[f]:w}}}},Ev=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 Br(t,u),f=Cn(o),h=fr(o),p=fn(o)==="y",{width:w,height:x}=s.floating;let g,v;f==="top"||f==="bottom"?(g=f,v=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=w-d.left-d.right,T=Nn(x-d[g],b),C=Nn(w-d[v],S),k=!t.middlewareData.shift;let E=T,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),k&&!h){const $=Wt(d.left,0),H=Wt(d.right,0),U=Wt(d.top,0),K=Wt(d.bottom,0);p?A=w-2*($!==0||H!==0?$+H:Wt(d.left,d.right)):E=x-2*(U!==0||K!==0?U+K:Wt(d.top,d.bottom))}await c({...t,availableWidth:A,availableHeight:E});const O=await i.getDimensions(a.floating);return w!==O.width||x!==O.height?{reset:{rects:!0}}:{}}}};function Ko(){return typeof window<"u"}function hr(e){return Uc(e)?(e.nodeName||"").toLowerCase():"#document"}function Vt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function hn(e){var t;return(t=(Uc(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Uc(e){return Ko()?e instanceof Node||e instanceof Vt(e).Node:!1}function rn(e){return Ko()?e instanceof Element||e instanceof Vt(e).Element:!1}function pn(e){return Ko()?e instanceof HTMLElement||e instanceof Vt(e).HTMLElement:!1}function Wc(e){return!Ko()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Vt(e).ShadowRoot}const Iv=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)&&!Iv.has(o)}const Nv=new Set(["table","td","th"]);function Av(e){return Nv.has(hr(e))}const jv=[":popover-open",":modal"];function qo(e){return jv.some(t=>{try{return e.matches(t)}catch{return!1}})}const _v=["transform","translate","scale","rotate","perspective"],Mv=["transform","translate","scale","rotate","perspective","filter"],Rv=["paint","layout","strict","content"];function _i(e){const t=Mi(),n=rn(e)?on(e):e;return _v.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))||Rv.some(r=>(n.contain||"").includes(r))}function Pv(e){let t=An(e);for(;pn(t)&&!pr(t);){if(_i(t))return t;if(qo(t))return null;t=An(t)}return null}function Mi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ov=new Set(["html","body","#document"]);function pr(e){return Ov.has(hr(e))}function on(e){return Vt(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(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Wc(e)&&e.host||hn(e);return Wc(t)?t.host:t}function Vc(e){const t=An(e);return pr(t)?e.ownerDocument?e.ownerDocument.body:e.body:pn(t)&&zr(t)?t:Vc(t)}function Hr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Vc(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Vt(o);if(s){const a=Ri(i);return t.concat(i,i.visualViewport||[],zr(o)?o:[],a&&n?Hr(a):[])}return t.concat(o,Hr(o,[],n))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Kc(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 Pi(e){return rn(e)?e:e.contextElement}function mr(e){const t=Pi(e);if(!pn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Kc(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 Dv=dn(0);function qc(e){const t=Vt(e);return!Mi()||!t.visualViewport?Dv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lv(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Vt(e)?!1:t}function Vn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Pi(e);let i=dn(1);t&&(r?rn(r)&&(i=mr(r)):i=mr(e));const a=Lv(s,n,r)?qc(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=Vt(s),p=r&&rn(r)?Vt(r):r;let w=h,x=Ri(w);for(;x&&r&&p!==w;){const g=mr(x),v=x.getBoundingClientRect(),b=on(x),S=v.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,T=v.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=S,u+=T,w=Vt(x),x=Ri(w)}}return Vo({width:d,height:f,x:c,y:u})}function Yo(e,t){const n=Go(e).scrollLeft;return t?t.left+n:Vn(hn(e)).left+n}function Gc(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 $v(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 c={scrollLeft:0,scrollTop:0},u=dn(1);const d=dn(0),f=pn(r);if((f||!f&&!s)&&((hr(r)!=="body"||zr(i))&&(c=Go(r)),pn(r))){const p=Vn(r);u=mr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?Gc(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 Fv(e){return Array.from(e.getClientRects())}function Bv(e){const t=hn(e),n=Go(e),r=e.ownerDocument.body,o=Wt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Wt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Yo(e);const a=-n.scrollTop;return on(r).direction==="rtl"&&(i+=Wt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Yc=25;function zv(e,t){const n=Vt(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=Mi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=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,w=Math.abs(r.clientWidth-f.clientWidth-p);w<=Yc&&(s-=w)}else u<=Yc&&(s+=u);return{width:s,height:i,x:a,y:c}}const Hv=new Set(["absolute","fixed"]);function Uv(e,t){const n=Vn(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 Xc(e,t,n){let r;if(t==="viewport")r=zv(e,n);else if(t==="document")r=Bv(hn(e));else if(rn(t))r=Uv(t,n);else{const o=qc(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Vo(r)}function Jc(e,t){const n=An(e);return n===t||!rn(n)||pr(n)?!1:on(n).position==="fixed"||Jc(n,t)}function Wv(e,t){const n=t.get(e);if(n)return n;let r=Hr(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=_i(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&Hv.has(o.position)||zr(i)&&!c&&Jc(e,i))?r=r.filter(d=>d!==i):o=a,i=An(i)}return t.set(e,r),r}function Vv(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?qo(t)?[]:Wv(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Xc(t,d,o);return u.top=Wt(f.top,u.top),u.right=Nn(f.right,u.right),u.bottom=Nn(f.bottom,u.bottom),u.left=Wt(f.left,u.left),u},Xc(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Kv(e){const{width:t,height:n}=Kc(e);return{width:t,height:n}}function qv(e,t,n){const r=pn(t),o=hn(t),s=n==="fixed",i=Vn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=dn(0);function u(){c.x=Yo(o)}if(r||!r&&!s)if((hr(t)!=="body"||zr(o))&&(a=Go(t)),r){const p=Vn(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?Gc(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 Oi(e){return on(e).position==="static"}function Zc(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 Qc(e,t){const n=Vt(e);if(qo(e))return n;if(!pn(e)){let o=An(e);for(;o&&!pr(o);){if(rn(o)&&!Oi(o))return o;o=An(o)}return n}let r=Zc(e,t);for(;r&&Av(r)&&Oi(r);)r=Zc(r,t);return r&&pr(r)&&Oi(r)&&!_i(r)?n:r||Pv(e)||n}const Gv=async function(e){const t=this.getOffsetParent||Qc,n=this.getDimensions,r=await n(e.floating);return{reference:qv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Yv(e){return on(e).direction==="rtl"}const Xv={convertOffsetParentRelativeRectToViewportRelativeRect:$v,getDocumentElement:hn,getClippingRect:Vv,getOffsetParent:Qc,getElementRects:Gv,getClientRects:Fv,getDimensions:Kv,getScale:mr,isElement:rn,isRTL:Yv};function eu(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Jv(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 w=Uo(f),x=Uo(o.clientWidth-(d+h)),g=Uo(o.clientHeight-(f+p)),v=Uo(d),S={rootMargin:-w+"px "+-x+"px "+-g+"px "+-v+"px",threshold:Wt(0,Nn(1,c))||1};let T=!0;function C(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&&!eu(u,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Zv(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=Pi(e),d=o||s?[...u?Hr(u):[],...Hr(t)]:[];d.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const f=u&&a?Jv(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!c&&p.observe(u),p.observe(t));let w,x=c?Vn(e):null;c&&g();function g(){const v=Vn(e);x&&!eu(x,v)&&n(),x=v,w=requestAnimationFrame(g)}return n(),()=>{var v;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(v=p)==null||v.disconnect(),p=null,c&&cancelAnimationFrame(w)}}const Qv=Cv,ew=kv,tw=bv,nw=Ev,rw=yv,tu=wv,ow=Tv,sw=(e,t,n)=>{const r=new Map,o={platform:Xv,...n},s={...o.platform,_c:r};return vv(e,t,{...o,platform:s})};var iw=typeof document<"u",aw=function(){},Xo=iw?y.useLayoutEffect:aw;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 nu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ru(e,t){const n=nu(e);return Math.round(t*n)/n}function Di(e){const t=m.useRef(e);return Xo(()=>{t.current=e}),t}function lw(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);Jo(h,r)||p(r);const[w,x]=m.useState(null),[g,v]=m.useState(null),b=m.useCallback(M=>{M!==k.current&&(k.current=M,x(M))},[]),S=m.useCallback(M=>{M!==E.current&&(E.current=M,v(M))},[]),T=s||w,C=i||g,k=m.useRef(null),E=m.useRef(null),A=m.useRef(d),O=c!=null,$=Di(c),H=Di(o),U=Di(u),K=m.useCallback(()=>{if(!k.current||!E.current)return;const M={placement:t,strategy:n,middleware:h};H.current&&(M.platform=H.current),sw(k.current,E.current,M).then(j=>{const z={...j,isPositioned:U.current!==!1};P.current&&!Jo(A.current,z)&&(A.current=z,bo.flushSync(()=>{f(z)}))})},[h,t,n,H,U]);Xo(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(M=>({...M,isPositioned:!1})))},[u]);const P=m.useRef(!1);Xo(()=>(P.current=!0,()=>{P.current=!1}),[]),Xo(()=>{if(T&&(k.current=T),C&&(E.current=C),T&&C){if($.current)return $.current(T,C,K);K()}},[T,C,K,$,O]);const Y=m.useMemo(()=>({reference:k,floating:E,setReference:b,setFloating:S}),[b,S]),N=m.useMemo(()=>({reference:T,floating:C}),[T,C]),D=m.useMemo(()=>{const M={position:n,left:0,top:0};if(!N.floating)return M;const j=ru(N.floating,d.x),z=ru(N.floating,d.y);return a?{...M,transform:"translate("+j+"px, "+z+"px)",...nu(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:z}},[n,a,N.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:K,refs:Y,elements:N,floatingStyles:D}),[d,K,Y,N,D])}const cw=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?tu({element:r.current,padding:o}).fn(n):{}:r?tu({element:r,padding:o}).fn(n):{}}}},uw=(e,t)=>({...Qv(e),options:[e,t]}),dw=(e,t)=>({...ew(e),options:[e,t]}),fw=(e,t)=>({...ow(e),options:[e,t]}),hw=(e,t)=>({...tw(e),options:[e,t]}),pw=(e,t)=>({...nw(e),options:[e,t]}),mw=(e,t)=>({...rw(e),options:[e,t]}),gw=(e,t)=>({...cw(e),options:[e,t]});var xw="Arrow",ou=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"})})});ou.displayName=xw;var vw=ou;function su(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 Li="Popper",[iu,Zo]=yn(Li),[ww,au]=iu(Li),lu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return l.jsx(ww,{scope:t,anchor:r,onAnchorChange:o,children:n})};lu.displayName=Li;var cu="PopperAnchor",uu=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=au(cu,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})});uu.displayName=cu;var $i="PopperContent",[bw,yw]=iu($i),du=m.forwardRef((e,t)=>{var G,L,V,Z,q,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:w,...x}=e,g=au($i,n),[v,b]=m.useState(null),S=ze(t,pe=>b(pe)),[T,C]=m.useState(null),k=su(T),E=(k==null?void 0:k.width)??0,A=(k==null?void 0:k.height)??0,O=r+(s!=="center"?"-"+s:""),$=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:$,boundary:H.filter(Cw),altBoundary:U},{refs:P,floatingStyles:Y,placement:N,isPositioned:D,middlewareData:M}=lw({strategy:"fixed",placement:O,whileElementsMounted:(...pe)=>Zv(...pe,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[uw({mainAxis:o+A,alignmentAxis:i}),c&&dw({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?fw():void 0,...K}),c&&hw({...K}),pw({...K,apply:({elements:pe,rects:he,availableWidth:ee,availableHeight:le})=>{const{width:we,height:je}=he.reference,Ne=pe.floating.style;Ne.setProperty("--radix-popper-available-width",`${ee}px`),Ne.setProperty("--radix-popper-available-height",`${le}px`),Ne.setProperty("--radix-popper-anchor-width",`${we}px`),Ne.setProperty("--radix-popper-anchor-height",`${je}px`)}}),T&&gw({element:T,padding:a}),kw({arrowWidth:E,arrowHeight:A}),h&&mw({strategy:"referenceHidden",...K})]}),[j,z]=pu(N),W=It(w);Et(()=>{D&&(W==null||W())},[D,W]);const R=(G=M.arrow)==null?void 0:G.x,B=(L=M.arrow)==null?void 0:L.y,te=((V=M.arrow)==null?void 0:V.centerOffset)!==0,[J,re]=m.useState();return Et(()=>{v&&re(window.getComputedStyle(v).zIndex)},[v]),l.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:D?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=M.transformOrigin)==null?void 0:Z.x,(q=M.transformOrigin)==null?void 0:q.y].join(" "),...((X=M.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:l.jsx(bw,{scope:n,placedSide:j,onArrowChange:C,arrowX:R,arrowY:B,shouldHideArrow:te,children:l.jsx(ye.div,{"data-side":j,"data-align":z,...x,ref:S,style:{...x.style,animation:D?void 0:"none"}})})})});du.displayName=$i;var fu="PopperArrow",Sw={top:"bottom",right:"left",bottom:"top",left:"right"},hu=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=yw(fu,r),i=Sw[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(vw,{...o,ref:n,style:{...o.style,display:"block"}})})});hu.displayName=fu;function Cw(e){return e!==null}var kw=e=>({name:"transformOrigin",options:e,fn(t){var g,v,b;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]=pu(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((v=o.arrow)==null?void 0:v.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let w="",x="";return u==="bottom"?(w=i?f:`${h}px`,x=`${-c}px`):u==="top"?(w=i?f:`${h}px`,x=`${r.floating.height+c}px`):u==="right"?(w=`${-c}px`,x=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+c}px`,x=i?f:`${p}px`),{data:{x:w,y:x}}}});function pu(e){const[t,n="center"]=e.split("-");return[t,n]}var mu=lu,gu=uu,xu=du,vu=hu,Tw="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?Zs.createPortal(l.jsx(ye.div,{...r,ref:t}),i):null});Qo.displayName=Tw;function Ew(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Xt=e=>{const{present:t,children:n}=e,r=Iw(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=ze(r.ref,Nw(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};Xt.displayName="Presence";function Iw(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Ew(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?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 x=es(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(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=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 c("ANIMATION_END")},[t,c]),{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 Nw(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 Fi="rovingFocusGroup.onEntryFocus",Aw={bubbles:!1,cancelable:!0},Ur="RovingFocusGroup",[Bi,wu,jw]=bi(Ur),[_w,bu]=yn(Ur,[jw]),[Mw,Rw]=_w(Ur),yu=m.forwardRef((e,t)=>l.jsx(Bi.Provider,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Bi.Slot,{scope:e.__scopeRovingFocusGroup,children:l.jsx(Pw,{...e,ref:t})})}));yu.displayName=Ur;var Pw=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),w=Fo(s),[x,g]=dr({prop:i,defaultProp:a??null,onChange:c,caller:Ur}),[v,b]=m.useState(!1),S=It(u),T=wu(n),C=m.useRef(!1),[k,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(Fi,S),()=>A.removeEventListener(Fi,S)},[S]),l.jsx(Mw,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:l.jsx(ye.div,{tabIndex:v||k===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:me(e.onMouseDown,()=>{C.current=!0}),onFocus:me(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!v){const $=new CustomEvent(Fi,Aw);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const H=T().filter(N=>N.focusable),U=H.find(N=>N.active),K=H.find(N=>N.id===x),Y=[U,K,...H].filter(Boolean).map(N=>N.ref.current);ku(Y,d)}}C.current=!1}),onBlur:me(e.onBlur,()=>b(!1))})})}),Su="RovingFocusGroupItem",Cu=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=Rw(Su,n),f=d.currentTabStopId===u,h=wu(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),l.jsx(Bi.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:me(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:me(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:me(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const v=Lw(g,d.orientation,d.dir);if(v!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const T=S.indexOf(g.currentTarget);S=d.loop?$w(S,T+1):S.slice(T+1)}setTimeout(()=>ku(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Cu.displayName=Su;var Ow={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Dw(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Lw(e,t,n){const r=Dw(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ow[r]}function ku(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $w(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Fw=yu,Bw=Cu,zw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},gr=new WeakMap,ts=new WeakMap,ns={},zi=0,Tu=function(e){return e&&(e.host||Tu(e.parentNode))},Hw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Tu(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Uw=function(e,t,n,r){var o=Hw(t,Array.isArray(e)?e:[e]);ns[n]||(ns[n]=new WeakMap);var s=ns[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),w=p!==null&&p!=="false",x=(gr.get(h)||0)+1,g=(s.get(h)||0)+1;gr.set(h,x),s.set(h,g),i.push(h),x===1&&w&&ts.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",h,v)}})};return d(t),a.clear(),zi++,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||(ts.has(f)||f.removeAttribute(r),ts.delete(f)),p||f.removeAttribute(n)}),zi--,zi||(gr=new WeakMap,gr=new WeakMap,ts=new WeakMap,ns={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=zw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Uw(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 Eu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ww(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",Vw="with-scroll-bars-hidden",Kw="--removed-body-scroll-bar-size";function Ui(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function qw(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 Gw=typeof window<"u"?m.useLayoutEffect:m.useEffect,Iu=new WeakMap;function Yw(e,t){var n=qw(null,function(r){return e.forEach(function(o){return Ui(o,r)})});return Gw(function(){var r=Iu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ui(a,null)}),s.forEach(function(a){o.has(a)||Ui(a,i)})}Iu.set(n,e)},[e]),n}function Xw(e){return e}function Jw(e,t){t===void 0&&(t=Xw);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 Zw(e){e===void 0&&(e={});var t=Jw(null);return t.options=mn({async:!0,ssr:!1},e),t}var Nu=function(e){var t=e.sideCar,n=Eu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,mn({},n))};Nu.isSideCarExport=!0;function Qw(e,t){return e.useMedium(t),Nu}var Au=Zw(),Wi=function(){},ss=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),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,w=e.noIsolation,x=e.inert,g=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,S=e.gapMode,T=Eu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,k=Yw([n,t]),E=mn(mn({},T),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Au,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?m.cloneElement(m.Children.only(a),mn(mn({},E),{ref:k})):m.createElement(b,mn({},E,{className:c,ref:k}),a))});ss.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ss.classNames={fullWidth:os,zeroRight:rs};var eb=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tb(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=eb();return t&&e.setAttribute("nonce",t),e}function nb(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rb(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ob=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tb())&&(nb(t,n),rb(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},sb=function(){var e=ob();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ju=function(){var e=sb(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},ib={left:0,top:0,right:0,gap:0},Vi=function(e){return parseInt(e||"",10)||0},ab=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[Vi(n),Vi(r),Vi(o)]},lb=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return ib;var t=ab(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])}},cb=ju(),xr="data-scroll-locked",ub=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
40
|
.`.concat(Vw,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -73,37 +73,37 @@ React keys must be passed directly to JSX without using spread:
|
|
|
73
73
|
body[`).concat(xr,`] {
|
|
74
74
|
`).concat(Kw,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},_u=function(){var e=parseInt(document.body.getAttribute(xr)||"0",10);return isFinite(e)?e:0},db=function(){m.useEffect(function(){return document.body.setAttribute(xr,(_u()+1).toString()),function(){var e=_u()-1;e<=0?document.body.removeAttribute(xr):document.body.setAttribute(xr,e.toString())}},[])},fb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;db();var s=m.useMemo(function(){return lb(o)},[o]);return m.createElement(cb,{styles:ub(s,!t,o,n?"":"!important")})},Ki=!1;if(typeof window<"u")try{var is=Object.defineProperty({},"passive",{get:function(){return Ki=!0,!0}});window.addEventListener("test",is,is),window.removeEventListener("test",is,is)}catch{Ki=!1}var vr=Ki?{passive:!1}:!1,hb=function(e){return e.tagName==="TEXTAREA"},Mu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!hb(e)&&n[t]==="visible")},pb=function(e){return Mu(e,"overflowY")},mb=function(e){return Mu(e,"overflowX")},Ru=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Pu(e,r);if(o){var s=Ou(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},gb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},xb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Pu=function(e,t){return e==="v"?pb(t):mb(t)},Ou=function(e,t){return e==="v"?gb(t):xb(t)},vb=function(e,t){return e==="h"&&t==="rtl"?-1:1},wb=function(e,t,n,r,o){var s=vb(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,
|
|
76
|
+
`)},_u=function(){var e=parseInt(document.body.getAttribute(xr)||"0",10);return isFinite(e)?e:0},db=function(){m.useEffect(function(){return document.body.setAttribute(xr,(_u()+1).toString()),function(){var e=_u()-1;e<=0?document.body.removeAttribute(xr):document.body.setAttribute(xr,e.toString())}},[])},fb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;db();var s=m.useMemo(function(){return lb(o)},[o]);return m.createElement(cb,{styles:ub(s,!t,o,n?"":"!important")})},Ki=!1;if(typeof window<"u")try{var is=Object.defineProperty({},"passive",{get:function(){return Ki=!0,!0}});window.addEventListener("test",is,is),window.removeEventListener("test",is,is)}catch{Ki=!1}var vr=Ki?{passive:!1}:!1,hb=function(e){return e.tagName==="TEXTAREA"},Mu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!hb(e)&&n[t]==="visible")},pb=function(e){return Mu(e,"overflowY")},mb=function(e){return Mu(e,"overflowX")},Ru=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Pu(e,r);if(o){var s=Ou(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},gb=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},xb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Pu=function(e,t){return e==="v"?pb(t):mb(t)},Ou=function(e,t){return e==="v"?gb(t):xb(t)},vb=function(e,t){return e==="h"&&t==="rtl"?-1:1},wb=function(e,t,n,r,o){var s=vb(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Ou(e,a),w=p[0],x=p[1],g=p[2],v=x-g-s*w;(w||v)&&Pu(e,a)&&(f+=v,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},as=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Du=function(e){return[e.deltaX,e.deltaY]},Lu=function(e){return e&&"current"in e?e.current:e},bb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},yb=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},Sb=0,wr=[];function Cb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Sb++)[0],s=m.useState(ju)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Ww([e.lockRef.current],(e.shards||[]).map(Lu),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=as(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-v[0],T="deltaY"in x?x.deltaY:b[1]-v[1],C,k=x.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in x&&E==="h"&&k.type==="range")return!1;var A=Ru(E,k);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=Ru(E,k)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||T)&&(r.current=C),!C)return!0;var O=r.current||C;return wb(O,g,x,O==="h"?S:T)},[]),l=m.useCallback(function(x){var g=x;if(!(!wr.length||wr[wr.length-1]!==s)){var v="deltaY"in g?Du(g):as(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&bb(C.delta,v)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Lu).filter(Boolean).filter(function(C){return C.contains(g.target)}),T=S.length>0?a(g,S[0]):!i.current.noIsolation;T&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,v,b){var S={name:x,delta:g,target:v,should:b,shadowParent:kb(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=m.useCallback(function(x){n.current=as(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Du(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,as(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return wr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,vr),document.addEventListener("touchmove",l,vr),document.addEventListener("touchstart",d,vr),function(){wr=wr.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,vr),document.removeEventListener("touchmove",l,vr),document.removeEventListener("touchstart",d,vr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:yb(o)}):null,p?m.createElement(fb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function kb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Tb=Qw(Au,Cb);var ls=m.forwardRef(function(e,t){return m.createElement(ss,mn({},e,{ref:t,sideCar:Tb}))});ls.classNames=ss.classNames;var qi=["Enter"," "],Eb=["ArrowDown","PageUp","Home"],$u=["ArrowUp","PageDown","End"],Ib=[...Eb,...$u],Nb={ltr:[...qi,"ArrowRight"],rtl:[...qi,"ArrowLeft"]},Ab={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ur="Menu",[Wr,jb,_b]=bi(Ur),[Kn,Fu]=yn(Ur,[_b,Zo,bu]),cs=Zo(),Bu=bu(),[Mb,qn]=Kn(Ur),[Rb,Vr]=Kn(Ur),zu=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",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx(mu,{...a,children:c.jsx(Mb,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Rb,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};zu.displayName=Ur;var Pb="MenuAnchor",Gi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(gu,{...o,...r,ref:t})});Gi.displayName=Pb;var Yi="MenuPortal",[Ob,Hu]=Kn(Yi,{forceMount:void 0}),Uu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(Yi,t);return c.jsx(Ob,{scope:t,forceMount:n,children:c.jsx(Xt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:r})})})};Uu.displayName=Yi;var Jt="MenuContent",[Db,Xi]=Kn(Jt),Wu=m.forwardRef((e,t)=>{const n=Hu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Vr(Jt,e.__scopeMenu);return c.jsx(Wr.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(Wr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Lb,{...o,ref:t}):c.jsx($b,{...o,ref:t})})})})}),Lb=m.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu),r=m.useRef(null),o=ze(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(Ji,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$b=m.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu);return c.jsx(Ji,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Fb=Bn.createSlot("MenuContent.ScrollLock"),Ji=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...x}=e,g=qn(Jt,n),v=Vr(Jt,n),b=cs(n),S=Bu(n),T=jb(n),[C,k]=m.useState(null),E=m.useRef(null),A=ze(t,E,g.onContentChange),O=m.useRef(0),$=m.useRef(""),H=m.useRef(0),U=m.useRef(null),K=m.useRef("right"),P=m.useRef(0),Y=w?ls:m.Fragment,N=w?{as:Fb,allowPinchZoom:!0}:void 0,D=j=>{var G,L;const z=$.current+j,W=T().filter(V=>!V.disabled),R=document.activeElement,B=(G=W.find(V=>V.ref.current===R))==null?void 0:G.textValue,te=W.map(V=>V.textValue),J=Jb(te,z,B),re=(L=W.find(V=>V.textValue===J))==null?void 0:L.ref.current;(function V(Z){$.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>V(""),1e3))})(z),re&&setTimeout(()=>re.focus())};m.useEffect(()=>()=>window.clearTimeout(O.current),[]),Ci();const M=m.useCallback(j=>{var W,R;return K.current===((W=U.current)==null?void 0:W.side)&&Qb(j,(R=U.current)==null?void 0:R.area)},[]);return c.jsx(Db,{scope:n,searchRef:$,onItemEnter:m.useCallback(j=>{M(j)&&j.preventDefault()},[M]),onItemLeave:m.useCallback(j=>{var z;M(j)||((z=E.current)==null||z.focus(),k(null))},[M]),onTriggerLeave:m.useCallback(j=>{M(j)&&j.preventDefault()},[M]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(j=>{U.current=j},[]),children:c.jsx(Y,{...N,children:c.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:me(s,j=>{var z;j.preventDefault(),(z=E.current)==null||z.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(Fw,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:me(l,j=>{v.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(xu,{role:"menu","aria-orientation":"vertical","data-state":ad(g.open),"data-radix-menu-content":"",dir:v.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:me(x.onKeyDown,j=>{const W=j.target.closest("[data-radix-menu-content]")===j.currentTarget,R=j.ctrlKey||j.altKey||j.metaKey,B=j.key.length===1;W&&(j.key==="Tab"&&j.preventDefault(),!R&&B&&D(j.key));const te=E.current;if(j.target!==te||!Ib.includes(j.key))return;j.preventDefault();const re=T().filter(G=>!G.disabled).map(G=>G.ref.current);$u.includes(j.key)&&re.reverse(),Yb(re)}),onBlur:me(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(O.current),$.current="")}),onPointerMove:me(e.onPointerMove,qr(j=>{const z=j.target,W=P.current!==j.clientX;if(j.currentTarget.contains(z)&&W){const R=j.clientX>P.current?"right":"left";K.current=R,P.current=j.clientX}}))})})})})})})});Wu.displayName=Jt;var Bb="MenuGroup",Zi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});Zi.displayName=Bb;var zb="MenuLabel",Vu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Vu.displayName=zb;var us="MenuItem",Ku="menu.itemSelect",ds=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=Vr(us,e.__scopeMenu),a=Xi(us,e.__scopeMenu),l=ze(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Ku,{bubbles:!0,cancelable:!0});f.addEventListener(Ku,p=>r==null?void 0:r(p),{once:!0}),Tc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(qu,{...o,ref:l,disabled:n,onClick:me(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:me(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:me(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ds.displayName=us;var qu=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xi(us,n),a=Bu(n),l=m.useRef(null),u=ze(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Wr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(Bw,{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:me(e.onPointerMove,qr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:me(e.onPointerLeave,qr(w=>i.onItemLeave(w))),onFocus:me(e.onFocus,()=>f(!0)),onBlur:me(e.onBlur,()=>f(!1))})})})}),Hb="MenuCheckboxItem",Gu=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(Qu,{scope:e.__scopeMenu,checked:n,children:c.jsx(ds,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...o,ref:t,"data-state":ea(n),onSelect:me(o.onSelect,()=>r==null?void 0:r(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Gu.displayName=Hb;var Yu="MenuRadioGroup",[Ub,Wb]=Kn(Yu,{value:void 0,onValueChange:()=>{}}),Xu=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return c.jsx(Ub,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Zi,{...o,ref:t})})});Xu.displayName=Yu;var Ju="MenuRadioItem",Zu=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Wb(Ju,e.__scopeMenu),s=n===o.value;return c.jsx(Qu,{scope:e.__scopeMenu,checked:s,children:c.jsx(ds,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ea(s),onSelect:me(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Zu.displayName=Ju;var Qi="MenuItemIndicator",[Qu,Vb]=Kn(Qi,{checked:!1}),ed=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Vb(Qi,n);return c.jsx(Xt,{present:r||fs(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":ea(s.checked)})})});ed.displayName=Qi;var Kb="MenuSeparator",td=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});td.displayName=Kb;var qb="MenuArrow",nd=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return c.jsx(vu,{...o,...r,ref:t})});nd.displayName=qb;var Gb="MenuSub",[PT,rd]=Kn(Gb),Kr="MenuSubTrigger",od=m.forwardRef((e,t)=>{const n=qn(Kr,e.__scopeMenu),r=Vr(Kr,e.__scopeMenu),o=rd(Kr,e.__scopeMenu),s=Xi(Kr,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(Gi,{asChild:!0,...u,children:c.jsx(qu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ad(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:me(e.onPointerMove,qr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:me(e.onPointerLeave,qr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(w=n.content)==null?void 0:w.dataset.side,g=x==="right",v=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:me(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Nb[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});od.displayName=Kr;var sd="MenuSubContent",id=m.forwardRef((e,t)=>{const n=Hu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Vr(Jt,e.__scopeMenu),a=rd(sd,e.__scopeMenu),l=m.useRef(null),u=ze(t,l);return c.jsx(Wr.Provider,{scope:e.__scopeMenu,children:c.jsx(Xt,{present:r||s.open,children:c.jsx(Wr.Slot,{scope:e.__scopeMenu,children:c.jsx(Ji,{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:me(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:me(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:me(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Ab[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});id.displayName=sd;function ad(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ea(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function Yb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Xb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Jb(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=Xb(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 Zb(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 Qb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Zb(n,t)}function qr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ey=zu,ty=Gi,ny=Uu,ry=Wu,oy=Zi,sy=Vu,iy=ds,ay=Gu,ly=Xu,cy=Zu,uy=ed,dy=td,fy=nd,hy=od,py=id,hs="DropdownMenu",[my,OT]=yn(hs,[Fu]),Ot=Fu(),[gy,ld]=my(hs),cd=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]=dr({prop:o,defaultProp:s??!1,onChange:i,caller:hs});return c.jsx(gy,{scope:t,triggerId:Pt(),triggerRef:u,contentId:Pt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(ey,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};cd.displayName=hs;var ud="DropdownMenuTrigger",dd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ld(ud,n),i=Ot(n);return c.jsx(ty,{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:me(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:me(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});dd.displayName=ud;var xy="DropdownMenuPortal",fd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return c.jsx(ny,{...r,...n})};fd.displayName=xy;var hd="DropdownMenuContent",pd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ld(hd,n),s=Ot(n),i=m.useRef(!1);return c.jsx(ry,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:me(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:me(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)"}})});pd.displayName=hd;var vy="DropdownMenuGroup",wy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(oy,{...o,...r,ref:t})});wy.displayName=vy;var by="DropdownMenuLabel",md=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(sy,{...o,...r,ref:t})});md.displayName=by;var yy="DropdownMenuItem",gd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(iy,{...o,...r,ref:t})});gd.displayName=yy;var Sy="DropdownMenuCheckboxItem",xd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ay,{...o,...r,ref:t})});xd.displayName=Sy;var Cy="DropdownMenuRadioGroup",ky=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(ly,{...o,...r,ref:t})});ky.displayName=Cy;var Ty="DropdownMenuRadioItem",vd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(cy,{...o,...r,ref:t})});vd.displayName=Ty;var Ey="DropdownMenuItemIndicator",wd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(uy,{...o,...r,ref:t})});wd.displayName=Ey;var Iy="DropdownMenuSeparator",bd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(dy,{...o,...r,ref:t})});bd.displayName=Iy;var Ny="DropdownMenuArrow",Ay=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(fy,{...o,...r,ref:t})});Ay.displayName=Ny;var jy="DropdownMenuSubTrigger",yd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(hy,{...o,...r,ref:t})});yd.displayName=jy;var _y="DropdownMenuSubContent",Sd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return c.jsx(py,{...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)"}})});Sd.displayName=_y;var My=cd,Ry=dd,Py=fd,Cd=pd,kd=md,Td=gd,Ed=xd,Id=vd,Nd=wd,Ad=bd,jd=yd,_d=Sd;const ta=My,na=Ry,Oy=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(jd,{ref:o,className:oe("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"})]}));Oy.displayName=jd.displayName;const Dy=m.forwardRef(({className:e,...t},n)=>c.jsx(_d,{ref:n,className:oe("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}));Dy.displayName=_d.displayName;const ps=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(Py,{children:c.jsx(Cd,{ref:r,sideOffset:t,className:oe("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=Cd.displayName;const Gn=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Td,{ref:r,className:oe("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}));Gn.displayName=Td.displayName;const Ly=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Ed,{ref:o,className:oe("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(Nd,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));Ly.displayName=Ed.displayName;const $y=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Id,{ref:r,className:oe("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(Nd,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));$y.displayName=Id.displayName;const Fy=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(kd,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Fy.displayName=kd.displayName;const By=m.forwardRef(({className:e,...t},n)=>c.jsx(Ad,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));By.displayName=Ad.displayName;function zy(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 Hy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="number"?n:null}function Uy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function Wy(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=Hy(d.metadata,"step"),p=Uy(d.metadata,"source"),w={id:f,step:h,source:p,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null};if(s.set(f,w),h!==null&&p){const x=`${h}:${p}`,g=i.get(x)??[];g.push(w),i.set(x,g)}}const{attemptMetaById:l,userMessageIdToAttempts:u}=zy(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=0,jn=1,br=2,Md=4;function Rd(e){return()=>e}function Vy(e){e()}function Pd(e,t){return n=>e(t(n))}function Od(e,t){return()=>e(t)}function Ky(e,t){return n=>e(t,n)}function ra(e){return e!==void 0}function qy(...e){return()=>{e.map(Vy)}}function yr(){}function gs(e,t){return t(e),e}function Gy(e,t){return t(e)}function ct(...e){return e}function et(e,t){return e(jn,t)}function Re(e,t){e(ms,t)}function oa(e){e(br)}function xt(e){return e(Md)}function xe(e,t){return et(e,Ky(t,ms))}function sn(e,t){const n=e(jn,r=>{n(),t(r)});return n}function Dd(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ld(e,t){return e===t}function ut(e=Ld){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=>Pd(t,e)}function gn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=Yy(...t);return(r,o)=>{switch(r){case br:oa(e);return;case jn:return et(e,n(o))}}}function xn(e,t){return n=>r=>{n(t=e(t,r))}}function Yn(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);et(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 Yy(...e){return t=>e.reduceRight(Gy,t)}function Xy(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=et(e,s),t):(r(),yr);case br:r(),n=null;return}}}function se(e){let t=e;const n=He();return(r,o)=>{switch(r){case ms:t=o;break;case jn:{o(t);break}case Md:return t}return n(r,o)}}function _t(e,t){return gs(se(t),n=>xe(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case ms:e.slice().forEach(r=>{r(n)});return;case br:e.splice(0,e.length);return;case jn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return gs(He(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Jy(),singleton:n}}const Jy=()=>Symbol();function Zy(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=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);et(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case br:{oa(t);return}case jn:return r===o&&i(n),et(t,i)}}}function ke(e,t=Ld){return Q(e,ut(t))}function sa(...e){return function(t,n){switch(t){case br:return;case jn:return qy(...e.map(r=>et(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 Qy={0:"debug",3:"error",1:"log",2:"warn"},e0=()=>typeof globalThis>"u"?window:globalThis,_n=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=e0().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[Qy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Xn(e,t,n){return ia(e,t,n).callbackRef}function ia(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 t0(e,t,n,r,o,s,i,a,l){const u=y.useCallback(d=>{const f=n0(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:v}),s==null||s(a?$d("column-gap",getComputedStyle(d).columnGap,o):$d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ia(u,n,l)}function n0(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 $d(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 Fd(e,t,n){const r=y.useRef(null),o=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ia(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=Ge(()=>{const e=He(),t=He(),n=se(0),r=He(),o=se(0),s=He(),i=He(),a=se(0),l=se(0),u=se(0),d=se(0),f=He(),h=He(),p=se(!1),w=se(!1),x=se(!1);return xe(Q(e,ue(({scrollTop:g})=>g)),t),xe(Q(e,ue(({scrollHeight:g})=>g)),i),xe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Gr={lvl:0};function Bd(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===Gr}function Yr(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?Yr(e.l,t):Yr(e.r,t)}function an(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=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 ot(e)?Ud(t,n,1):t===e.k?bt(e,{k:t,v:n}):t<e.k?Wd(bt(e,{l:qt(e.l,t,n)})):Wd(bt(e,{r:qt(e.r,t,n)}))}function Sr(){return Gr}function xs(e,t,n){if(ot(e))return[];const r=an(e,t)[0];return r0(la(e,r,n))}function aa(e,t){if(ot(e))return Gr;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Hd(r);return vs(bt(e,{k:s,l:zd(r),v:i}))}}else return t<n?vs(bt(e,{l:aa(r,t)})):vs(bt(e,{r:aa(o,t)}))}function Jn(e){return ot(e)?[]:[...Jn(e.l),{k:e.k,v:e.v},...Jn(e.r)]}function la(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(la(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(la(s,t,n))),a}function vs(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(ca(t))return Vd(bt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return bt(t.r,{l:bt(t,{r:t.r.l}),lvl:n,r:bt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ca(e))return ua(bt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=ca(o)?r.lvl-1:r.lvl;return bt(o,{l:bt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ua(bt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function bt(e,t){return Ud(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 zd(e){return ot(e.r)?e.l:vs(bt(e,{r:zd(e.r)}))}function ca(e){return ot(e)||e.lvl>e.r.lvl}function Hd(e){return ot(e.r)?[e.k,e.v]:Hd(e.r)}function Ud(e,t,n,r=Gr,o=Gr){return{k:e,l:r,lvl:n,r:o,v:t}}function Wd(e){return ua(Vd(e))}function Vd(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?bt(t,{r:bt(e,{l:t.r})}):e}function ua(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?bt(n,{l:bt(e,{r:n.l}),lvl:t+1}):e}function r0(e){return Bd(e,({k:t,v:n})=>({index:t,value:n}))}function Kd(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Xr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const da=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function qd(e,t,n){return e[ws(e,t,n)]}function ws(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 o0(e,t,n,r){const o=ws(e,t,r),s=ws(e,n,r,o);return e.slice(o,s+1)}function Mn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bs(e){return!ot(e.groupOffsetTree)}function fa({index:e},t){return t===e?0:t<e?-1:1}function s0(){return{groupIndices:[],groupOffsetTree:Sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Sr()}}function i0(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=qt(e,0,s);continue}const a=xs(e,i-1,o+1);if(a.some(h0(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=aa(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=qt(e,o+1,h));u&&(e=qt(e,i,s))}return[e,n]}function a0(e){return typeof e.groupIndex<"u"}function l0({offset:e},t){return t===e?0:t<e?-1:1}function Jr(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=qd(t,e,fa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Gd(e,t){if(!bs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Yd(e,t,n){if(a0(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Gd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function c0(e,t,n,r=0){return r>0&&(t=Math.max(t,qd(e,r,fa).offset)),Bd(o0(e,t,n,l0),f0)}function u0(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,x)=>qt(qt(w,x,h),x+1,p),i)}else[i,a]=i0(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,Jr(p,f,o)),Sr()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function d0(e){return Jn(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 Xd(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 ha(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ws(o,t-1,fa),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 xs(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 f0(e){return{index:e.index,value:e}}function h0(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 p0={offsetHeight:"height",offsetWidth:"width"},vn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=_t(r,0),s=He(),i=He(),a=se(0),l=se([]),u=se(void 0),d=se(void 0),f=se((C,k)=>Mn(C,p0[k])),h=se(void 0),p=se(0),w=s0(),x=_t(Q(n,De(l,e,p),xn(u0,w),ut()),w),g=_t(Q(l,ut(),xn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(Q(l,Ie(C=>C.length>0),De(x,p),ue(([C,k,E])=>{const A=C.reduce((O,$,H)=>qt(O,$,Jr($,k.offsetTree,E)||H),Sr());return{...k,groupIndices:C,groupOffsetTree:A}})),x),xe(Q(r,De(x),Ie(([C,{lastIndex:k}])=>C<k),ue(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),xe(u,d);const v=_t(Q(u,ue(C=>C===void 0)),!0);xe(Q(d,Ie(C=>C!==void 0&&ot(xt(x).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Kt(Q(n,De(x),xn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:w}),ue(C=>C.changed)));et(Q(a,xn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:k}=xt(x);if(C>0)Re(t,!0),Re(s,C+Xd(C,k));else if(C<0){const E=xt(g);E.length>0&&(C-=Xd(-C,E)),Re(i,C)}}),et(Q(a,De(e)),([C,k])=>{C<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const S=Kt(s);xe(Q(s,De(x),ue(([C,k])=>{const E=k.groupIndices.length>0,A=[],O=k.lastSize;if(E){const $=Yr(k.sizeTree,0);let H=0,U=0;for(;H<C;){const P=k.groupIndices[U],Y=k.groupIndices.length===U+1?1/0:k.groupIndices[U+1]-P-1;A.push({endIndex:P,size:$,startIndex:P}),A.push({endIndex:P+1+Y-1,size:O,startIndex:P+1}),U++,H+=Y+1}const K=Jn(k.sizeTree);return H!==C&&K.shift(),K.reduce((P,{k:Y,v:N})=>{let D=P.ranges;return P.prevSize!==0&&(D=[...P.ranges,{endIndex:Y+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:Y+C,prevSize:N,ranges:D}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Jn(k.sizeTree).reduce(($,{k:H,v:U})=>({prevIndex:H+C,prevSize:U,ranges:[...$.ranges,{endIndex:H+C-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const T=Kt(Q(i,De(x,p),ue(([C,{offsetTree:k},E])=>{const A=-C;return Jr(A,k,E)})));return xe(Q(i,De(x,p),ue(([C,k,E])=>{if(k.groupIndices.length>0){if(ot(k.sizeTree))return k;let A=Sr();const O=xt(g);let $=0,H=0,U=0;for(;$<-C;){U=O[H];const K=O[H+1]-U-1;H++,$+=K+1}if(A=Jn(k.sizeTree).reduce((K,{k:P,v:Y})=>qt(K,Math.max(0,P+C),Y),A),$!==-C){const K=Yr(k.sizeTree,U);A=qt(A,0,K);const P=an(k.sizeTree,-C+1)[1];A=qt(A,1,P)}return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}else{const A=Jn(k.sizeTree).reduce((O,{k:$,v:H})=>qt(O,Math.max(0,$+C),H),Sr());return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},ct(_n,da),{singleton:!0});function m0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Jd=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Kt(Q(s,ue(m0)));return xe(Q(a,ue(l=>l.totalCount)),n),xe(Q(a,ue(l=>l.groupIndices)),e),xe(Q(wt(o,t,r),Ie(([l,u])=>bs(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=Ge(([{log:e}])=>{const t=se(!1),n=Kt(Q(t,Ie(r=>r),ut()));return et(t,r=>{r&&xt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ct(_n),{singleton:!0}),g0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Zd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!g0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Zr=Ge(([{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(),w=He(),x=se(0);let g=null,v=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),v&&(clearTimeout(v),v=null),Re(l,!1)}return xe(Q(p,De(n,f,r,x,a,i,h),De(e,s,o),ue(([[T,C,k,E,A,O,$,H],U,K,P])=>{const Y=Zd(T),{align:N,behavior:D,offset:M}=Y,j=E-1,z=Yd(Y,C,j);let W=Jr(z,C.offsetTree,U)+O;N==="end"?(W+=K+an(C.sizeTree,z)[1]-k+P,z===j&&(W+=$)):N==="center"?W+=(K+an(C.sizeTree,z)[1]-k+P)/2:W-=A,M&&(W+=M);const R=B=>{S(),B?(H("retrying to scroll to",{location:T},Bt.DEBUG),Re(p,T)):(Re(w,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),D==="smooth"){let B=!1;b=et(t,te=>{B=B||te}),g=sn(d,()=>{R(B)})}else g=sn(Q(t,x0(150)),R);return v=setTimeout(()=>{S()},1200),Re(l,!0),H("scrolling from index to",{behavior:D,index:z,top:W},Bt.DEBUG),{behavior:D,top:W}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:x}},ct(vn,Dt,_n),{singleton:!0});function x0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pa(e,t){e==0?t():requestAnimationFrame(()=>{pa(e-1,t)})}function ma(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Qr=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),u=se(!0);return xe(Q(i,De(l),Ie(([d,f])=>!!f),gn(!1)),a),xe(Q(i,De(l),Ie(([d,f])=>!!f),gn(!1)),u),et(Q(wt(t,i),De(a,n,e,u),Ie(([[,d],f,{sizeTree:h},p,w])=>d&&(!ot(h)||ra(p))&&!f&&!w),De(l)),([,d])=>{sn(o,()=>{Re(u,!0)}),pa(4,()=>{sn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ct(vn,Dt,Zr,Rn),{singleton:!0});function Qd(e,t){return Math.abs(e-t)<1.01}const eo="up",to="down",v0="none",w0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},b0=0,no=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=He(),u=He(),d=se(4),f=se(b0),h=_t(Q(sa(Q(ke(o),Yn(1),gn(!0)),Q(ke(o),Yn(1),gn(!1),Dd(100))),ut()),!1),p=_t(Q(sa(Q(n,gn(!0)),Q(n,gn(!1),Dd(200))),ut()),!1);xe(Q(wt(ke(o),ke(f)),ue(([b,S])=>b<=S),ut()),a),xe(Q(a,kn(50)),u);const w=Kt(Q(wt(r,ke(s),ke(t),ke(e),ke(d)),xn((b,[{scrollHeight:S,scrollTop:T},C,k,E,A])=>{const O=T+C-S>-A,$={scrollHeight:S,scrollTop:T,viewportHeight:C};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:$}}let H;return $.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":C<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:$}},w0),ut((b,S)=>b&&b.atBottom===S.atBottom))),x=_t(Q(r,xn((b,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(Qd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const k=S-(T+C)<1;return b.scrollTop!==T&&k?{changed:!0,jump:b.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(b=>b.changed),ue(b=>b.jump)),0);xe(Q(w,ue(b=>b.atBottom)),i),xe(Q(i,kn(50)),l);const g=se(to);xe(Q(r,ue(({scrollTop:b})=>b),ut(),xn((b,S)=>xt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?eo:to,prevScrollTop:S},{direction:to,prevScrollTop:0}),ue(b=>b.direction)),g),xe(Q(r,kn(50),gn(v0)),g);const v=se(0);return xe(Q(h,Ie(b=>!b),gn(0)),v),xe(Q(o,kn(100),De(h),Ie(([b,S])=>!!S),xn(([b,S],[T])=>[S,T],[0,0]),ue(([b,S])=>S-b)),v),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:v}},ct(Dt)),ys="top",Ss="bottom",ef="none";function tf(e,t,n){return typeof e=="number"?n===eo&&t===ys||n===to&&t===Ss?e:0:n===eo?t===ys?e.main:e.reverse:t===Ss?e.main:e.reverse}function nf(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ga=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=se(0),a=se(0),l=se(0),u=_t(Q(wt(ke(r),ke(o),ke(n),ke(s,Xr),ke(l),ke(i),ke(t),ke(e),ke(a)),ue(([d,f,h,[p,w],x,g,v,b,S])=>{const T=d-b,C=g+v,k=Math.max(h-T,0);let E=ef;const A=nf(S,ys),O=nf(S,Ss);return p-=b,p+=h+v,w+=h+v,w-=b,p>d+C-A&&(E=eo),w<d-k+f+O&&(E=to),E!==ef?[Math.max(T-h-tf(x,ys,E)-A,0),T-k-v+f+tf(x,Ss,E)+O]:null}),Ie(d=>d!=null),ut(Xr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},ct(Dt),{singleton:!0});function y0(e,t,n){if(bs(t)){const r=Gd(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 xa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Cs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:of(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:of(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function rf(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=ma(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Cs(u,[],a,o,n,r)}function of(e,t,n){if(e.length===0)return[];if(!bs(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=xs(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Zn=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:w}])=>{const x=se([]),g=se(0),v=He();xe(s.topItemsIndexes,x);const b=_t(Q(wt(p,w,ke(l,Xr),ke(o),ke(r),ke(u),d,ke(x),ke(t),ke(n),e),Ie(([k,E,,A,,,,,,,O])=>{const $=O&&O.length!==A;return k&&!E&&!$}),ue(([,,[k,E],A,O,$,H,U,K,P,Y])=>{const N=O,{offsetTree:D,sizeTree:M}=N,j=xt(g);if(A===0)return{...xa,totalCount:A};if(k===0&&E===0)return j===0?{...xa,totalCount:A}:rf(j,$,O,K,P,Y||[]);if(ot(M))return j>0?null:Cs(y0(ma($,A),N,Y),[],A,P,N,K);const z=[];if(U.length>0){const J=U[0],re=U[U.length-1];let G=0;for(const L of xs(M,J,re)){const V=L.value,Z=Math.max(L.start,J),q=Math.min(L.end,re);for(let X=Z;X<=q;X++)z.push({data:Y==null?void 0:Y[X],index:X,offset:G,size:V}),G+=V}}if(!H)return Cs([],z,A,P,N,K);const W=U.length>0?U[U.length-1]+1:0,R=c0(D,k,E,W);if(R.length===0)return null;const B=A-1,te=gs([],J=>{for(const re of R){const G=re.value;let L=G.offset,V=re.start;const Z=G.size;if(G.offset<k){V+=Math.floor((k-G.offset+P)/(Z+P));const X=V-re.start;L+=X*Z+X*P}V<W&&(L+=(W-V)*Z,V=W);const q=Math.min(re.end,B);for(let X=V;X<=q&&!(L>=E);X++)J.push({data:Y==null?void 0:Y[X],index:X,offset:L,size:Z}),L+=Z+P}});return Cs(te,z,A,P,N,K)}),Ie(k=>k!==null),ut()),xa);xe(Q(e,Ie(ra),ue(k=>k==null?void 0:k.length)),o),xe(Q(b,ue(k=>k.topListHeight)),f),xe(f,a),xe(Q(b,ue(k=>[k.top,k.bottom])),i),xe(Q(b,ue(k=>k.items)),v);const S=Kt(Q(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(Xr),ue(([k])=>k))),T=Kt(Q(b,kn(200),Ie(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),ut())),C=Kt(Q(b,Ie(({items:k})=>k.length>0),ue(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),ut(Kd)));return{endReached:S,initialItemCount:g,itemsRendered:v,listState:b,rangeChanged:C,startReached:T,topItemsIndexes:x,...h}},ct(vn,Jd,ga,Qr,Zr,no,Rn,da),{singleton:!0}),sf=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=_t(Q(wt(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,Zn),{singleton:!0}),S0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(Q(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,sf),{singleton:!0}),af=Ge(()=>({context:se(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,lf=Ge(([{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(Q(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,h,p,w,x,g,v,b],S])=>{const{align:T,behavior:C,calculateViewLocation:k=C0,done:E,...A}=f,O=Yd(f,h,w-1),$=Jr(O,h.offsetTree,S)+x+g,H=$+an(h.sizeTree,O)[1],U=b+g,K=b+p-v,P=k({itemBottom:H,itemTop:$,locationParams:{align:T,behavior:C,...A},viewportBottom:K,viewportTop:U});return P?E&&sn(Q(i,Ie(Y=>!Y),Yn(xt(i)?1:2)),E):E&&E(),P}),Ie(f=>f!==null)),u),{scrollIntoView:d}},ct(vn,Dt,Zr,Zn,_n),{singleton:!0});function cf(e){return e?e==="smooth"?"smooth":"auto":!1}const k0=(e,t)=>typeof e=="function"?cf(e(t)):t&&cf(e),T0=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const w=se(!1),x=He();let g=null;function v(C){Re(i,{align:"end",behavior:C,index:"LAST"})}et(Q(wt(Q(ke(t),Yn(1)),l),De(ke(w),s,a,f),ue(([[C,k],E,A,O,$])=>{let H=k&&O,U="auto";return H&&(U=k0(E,A||$),H=H&&!!U),{followOutputBehavior:U,shouldFollow:H,totalCount:C}}),Ie(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(C)}):g=sn(e,()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(C),g=null})});function b(C){const k=sn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),v("auto"))});setTimeout(k,100)}et(Q(wt(ke(w),t,u),Ie(([C,,k])=>C&&k),xn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:C})=>C),De(w,t)),([,C])=>{xt(a)&&b(C!==!1)}),et(x,()=>{b(xt(w)!==!1)}),et(wt(ke(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=se(null),T=He();return xe(sa(Q(ke(r),ue(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),Q(ke(t))),T),et(Q(wt(Q(T,Yn(1)),l),De(ke(S),a,f,h),ue(([[C,k],E,A,O,$])=>k&&A&&(E==null?void 0:E({context:$,totalCount:C,scrollingInProgress:O}))),Ie(C=>!!C),kn(0)),C=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Re(p,C)}):g=sn(e,()=>{xt(d)("scrolling into view",{}),Re(p,C),g=null})}),{autoscrollToBottom:x,followOutput:w,scrollIntoViewOnChange:S}},ct(vn,no,Zr,Qr,Rn,_n,Dt,af,lf)),E0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(Q(a,De(s),Ie(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],u,d,f,h,p=[]])=>rf(l,u,d,f,h,p))),i),{}),ct(vn,Qr,Zn,Rn),{singleton:!0}),I0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return et(Q(e,De(r),Ie(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{sn(Q(n,Yn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},ct(Rn,Dt,Zn),{singleton:!0}),uf=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=He(),r=se(!1);return xe(Q(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),et(Q(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(no),{singleton:!0}),va=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=se(!1),i=se(void 0);return xe(Q(wt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),xe(Q(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)),N0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=He(),d=se(void 0),f=se(null),h=se(null);return xe(a,f),xe(l,h),et(Q(u,De(t,r,i,f,h,n)),([p,w,x,g,v,b,S])=>{const T=d0(w.sizeTree);g&&v!==null&&b!==null&&(x=v.scrollTop-b.offsetTop),x-=S,p({ranges:T,scrollTop:x})}),xe(Q(d,Ie(ra),ue(A0)),o),xe(Q(s,De(d),Ie(([,p])=>p!==void 0),ut(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ct(vn,Dt,Qr,Rn,va));function A0(e){return{align:"start",index:0,offset:e.scrollTop}}const j0=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(Q(t,Ie(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(Zn));function df(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const _0=df(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),M0=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:w}])=>{const x=Kt(Q(l,De(i),xn(([,v,b,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},A])=>{const O=T+k;let $=0;return b===E&&v.length>0&&C.length>0&&(C[0].originalIndex===0&&v[0].originalIndex===0||($=O-S,$!==0&&($+=A))),[$,C,E,O]},[0,[],0,0]),Ie(([v])=>v!==0),De(r,a,n,o,p,w),Ie(([,v,b,S,,,T])=>!T&&!S&&v!==0&&b===eo),ue(([[v],,,,,b])=>(b("Upward scrolling compensation",{amount:v},Bt.DEBUG),v))));function g(v){v>0?(Re(t,{behavior:"auto",top:-v}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-v}))}return et(Q(x,De(e,s)),([v,b,S])=>{S&&_0()?Re(e,b-v):g(-v)}),et(Q(wt(_t(s,!1),e,w),Ie(([v,b,S])=>!v&&!S&&b!==0),ue(([v,b])=>b),kn(1)),g),xe(Q(f,ue(v=>({top:-v}))),t),et(Q(u,De(h,d),ue(([v,{groupIndices:b,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(v);{let E=0;const A=Yr(T,0);let O=0,$=0;for(;O<v;){O++,E+=A;let H=b.length===$+1?1/0:b[$+1]-b[$]-1;O+H>v&&(E-=A,H=v-O+1),O+=H,E+=k(H),$++}return E}})),v=>{Re(e,v),requestAnimationFrame(()=>{Re(t,{top:v}),requestAnimationFrame(()=>{Re(e,0),Re(w,!1)})})}),{deviation:e}},ct(Dt,no,Zn,vn,_n,da)),R0=Ge(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),ct(ga,E0,Rn,uf,sf,I0,S0,va,lf,_n,af)),ff=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w},x,g,v,{listState:b,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},O])=>(xe(T.rangeChanged,O.scrollSeekRangeChanged),xe(Q(O.windowViewportRect,ue($=>$.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...v,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...T,...O,...x,sizes:l,...g}),ct(vn,Qr,Dt,N0,T0,Zn,Zr,M0,j0,Jd,R0));function P0(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 ks=typeof document<"u"?y.useLayoutEffect:y.useEffect;function hf(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=y.createContext({});function l(g,v){g.propsReady&&Re(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Re(S,v[b])}for(const b of o)if(b in v){const S=g[t.optional[b]];Re(S,v[b])}g.propsReady&&Re(g.propsReady,!0)}function u(g){return s.reduce((v,b)=>(v[b]=S=>{const T=g[t.methods[b]];Re(T,S)},v),{})}function d(g){return i.reduce((v,b)=>(v[b]=Xy(g[t.events[b]]),v),{})}const f=y.forwardRef((g,v)=>{const{children:b,...S}=g,[T]=y.useState(()=>gs(Zy(e),E=>{l(E,S)})),[C]=y.useState(Od(d,T));ks(()=>{for(const E of i)E in S&&et(C[E],S[E]);return()=>{Object.values(C).map(oa)}},[S,C,T]),ks(()=>{l(T,S)}),y.useImperativeHandle(v,Rd(u(T)));const k=n;return c.jsx(a.Provider,{value:T,children:n?c.jsx(k,{...P0([...r,...o,...i],S),children:b}):b})}),h=g=>{const v=y.useContext(a);return y.useCallback(b=>{Re(v[g],b)},[v,g])},p=g=>{const v=y.useContext(a)[g],b=y.useCallback(S=>et(v,S),[v]);return y.useSyncExternalStore(b,()=>xt(v),()=>xt(v))},w=g=>{const v=y.useContext(a)[g],[b,S]=y.useState(Od(xt,v));return ks(()=>et(v,T=>{T!==b&&S(Rd(T))}),[v,b]),b},x=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,v)=>{const b=y.useContext(a)[g];ks(()=>et(b,v),[v,b])},useEmitterValue:x,usePublisher:h}}const pf=y.createContext(void 0),mf=y.createContext(void 0),gf=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wa(e){return"self"in e}function O0(e){return"body"in e}function xf(e,t,n,r=yr,o,s){const i=y.useRef(null),a=y.useRef(null),l=y.useRef(null),u=y.useCallback(h=>{let p,w,x;const g=h.target;if(O0(g)||wa(g)){const b=wa(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:w})};h.suppressFlushSync?v():Zs.flushSync(v),a.current!==null&&(x===a.current||x<=0||x===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);y.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let x,g,v;wa(p)?(g=Math.max(Mn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Mn(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),Qd(x,g)||h.top===v){e({scrollHeight:g,scrollTop:v,viewportHeight:x}),w&&t(!0);return}w?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const ba="-webkit-sticky",vf="sticky",ya=df(()=>{if(typeof document>"u")return vf;const e=document.createElement("div");return e.style.position=ba,e.style.position===ba?ba:vf});function Sa(e){return e}const D0=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Sa),o=se("div"),s=se(yr),i=(a,l=null)=>_t(Q(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")}}),L0=Ge(([e,t])=>({...e,...t}),ct(ff,D0)),$0=({height:e})=>c.jsx("div",{style:{height:e}}),F0={overflowAnchor:"none",position:ya(),zIndex:1},wf={overflowAnchor:"none"},B0={...wf,display:"inline-block",height:"100%"},bf=y.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=Zt("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=Zt("windowScrollContainerState"),i=Zt("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),p=Ae("log"),w=Zt("gap"),x=Ae("horizontalDirection"),{callbackRef:g}=t0(n,h,f,e?yr:a,p,w,o,x,Ae("skipAnimationFrameInResizeObserver")),[v,b]=y.useState(0);Ca("deviation",P=>{v!==P&&b(P)});const S=Ae("EmptyPlaceholder"),T=Ae("ScrollSeekPlaceholder")||$0,C=Ae("ListComponent"),k=Ae("ItemComponent"),E=Ae("GroupComponent"),A=Ae("computeItemKey"),O=Ae("isSeeking"),$=Ae("groupIndices").length>0,H=Ae("alignToBottom"),U=Ae("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:v!==0?v:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Mt(S,u)}):c.jsx(C,{...Mt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:K,children:(e?t.topItems:t.items).map(P=>{const Y=P.originalIndex,N=A(Y+t.firstItemIndex,P.data,u);return O?y.createElement(T,{...Mt(T,u),height:P.size,index:P.index,key:N,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(E,{...Mt(E,u),"data-index":Y,"data-item-index":P.index,"data-known-size":P.size,key:N,style:F0},d(P.index,u)):y.createElement(k,{...Mt(k,u),...W0(k,P.data),"data-index":Y,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:N,style:x?B0:wf},$?l(P.index,P.groupIndex,P.data,u):l(P.index,P.data,u))})})}),z0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},H0={outline:"none",overflowX:"auto",position:"relative"},Ts=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),U0={position:ya(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function W0(e,t){return{item:typeof e=="string"?void 0:t}}const V0=y.memo(function(){const e=Ae("HeaderComponent"),t=Zt("headerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null}),K0=y.memo(function(){const e=Ae("FooterComponent"),t=Zt("footerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Mt(e,o)})}):null});function yf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:w}=xf(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?H0:z0,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Sf({useEmitter:e,useEmitterValue:t,usePublisher:n}){return y.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=y.useRef(null),w=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:v}=xf(a,u,l,w,h);return gf(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",v),e("scrollBy",x),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(l,s),children:r})})}const q0=({children:e})=>{const t=y.useContext(pf),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=y.useMemo(()=>Pd(n,l=>Mn(l,s?"width":"height")),[n,s]),a=Xn(i,!0,Ae("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Ts(o),children:e})},G0=({children:e})=>{const t=y.useContext(pf),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=Ae("customScrollParent"),s=Fd(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return y.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Ts(i),children:e})},Y0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...U0,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Mt(t,o),children:e})},X0=y.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?Q0:Z0,{...e,context:o,children:[n&&c.jsx(Y0,{children:c.jsx(bf,{showTopList:!0})}),c.jsxs(r||t?G0:q0,{children:[c.jsx(V0,{}),c.jsx(bf,{}),c.jsx(K0,{})]})]})}),{Component:J0,useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}=hf(L0,{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"}},X0),Z0=yf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),Q0=Sf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),eS=J0;ct(ff,Ge(()=>{const e=se(u=>c.jsxs("td",{children:["Item $",u]})),t=se(null),n=se(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=se(null),o=se(null),s=se({}),i=se(Sa),a=se(yr),l=(u,d=null)=>_t(Q(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")}})),ya();const Cf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},tS={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:kf,floor:Es,max:ro,min:ka,round:Tf}=Math;function Ef(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function nS(e){return{...tS,items:e}}function Is(e,t){return e&&e.width===t.width&&e.height===t.height}function rS(e,t){return e&&e.column===t.column&&e.row===t.row}const oS=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:w,propsReady:x},{customScrollParent:g,useWindowScroll:v,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T},C])=>{const k=se(0),E=se(0),A=se(Cf),O=se({height:0,width:0}),$=se({height:0,width:0}),H=He(),U=He(),K=se(0),P=se(null),Y=se({column:0,row:0}),N=He(),D=He(),M=se(!1),j=se(0),z=se(!0),W=se(!1),R=se(!1);et(Q(w,De(j),Ie(([L,V])=>!!V)),()=>{Re(z,!1)}),et(Q(wt(w,z,$,O,j,W),Ie(([L,V,Z,q,,X])=>L&&!V&&Z.height!==0&&q.height!==0&&!X)),([,,,,L])=>{Re(W,!0),pa(1,()=>{Re(H,L)}),sn(Q(u),()=>{Re(t,[0,0]),Re(z,!0)})}),xe(Q(D,Ie(L=>L!=null&&L.scrollTop>0),gn(0)),E),et(Q(w,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Re(O,L.viewport),Re($,L.item),Re(Y,L.gap),L.scrollTop>0&&(Re(M,!0),sn(Q(u,Yn(1)),V=>{Re(M,!1)}),Re(l,{top:L.scrollTop})))}),xe(Q(O,ue(({height:L})=>L)),f),xe(Q(wt(ke(O,Is),ke($,Is),ke(Y,(L,V)=>L&&L.column===V.column&&L.row===V.row),ke(u)),ue(([L,V,Z,q])=>({gap:Z,item:V,scrollTop:q,viewport:L}))),N),xe(Q(wt(ke(k),r,ke(Y,rS),ke($,Is),ke(O,Is),ke(P),ke(E),ke(M),ke(z),ke(j)),Ie(([,,,,,,,L])=>!L),ue(([L,[V,Z],q,X,pe,he,ee,,le,we])=>{const{column:je,row:Ne}=q,{height:$e,width:Ye}=X,{width:nt}=pe;if(ee===0&&(L===0||nt===0))return Cf;if(Ye===0){const ht=ma(we,L),Tt=ht+Math.max(ee-1,0);return nS(Ef(ht,Tt,he))}const Ve=If(nt,Ye,je);let qe,rt;le?V===0&&Z===0&&ee>0?(qe=0,rt=ee-1):(qe=Ve*Es((V+Ne)/($e+Ne)),rt=Ve*kf((Z+Ne)/($e+Ne))-1,rt=ka(L-1,ro(rt,Ve-1)),qe=ka(rt,ro(0,qe))):(qe=0,rt=-1);const kt=Ef(qe,rt,he),{bottom:at,top:Te}=Nf(pe,q,X,kt),Oe=kf(L/Ve),it=Oe*$e+(Oe-1)*Ne-at;return{bottom:at,itemHeight:$e,items:kt,itemWidth:Ye,offsetBottom:it,offsetTop:Te,top:Te}})),A),xe(Q(P,Ie(L=>L!==null),ue(L=>L.length)),k),xe(Q(wt(O,$,A,Y),Ie(([L,V,{items:Z}])=>Z.length>0&&V.height!==0&&L.height!==0),ue(([L,V,{items:Z},q])=>{const{bottom:X,top:pe}=Nf(L,q,V,Z);return[pe,X]}),ut(Xr)),t);const B=se(!1);xe(Q(u,De(B),ue(([L,V])=>V||L!==0)),B);const te=Kt(Q(wt(A,k),Ie(([{items:L}])=>L.length>0),De(B),Ie(([[L,V],Z])=>{const q=L.items[L.items.length-1].index===V-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===V)&&q}),ue(([[,L]])=>L-1),ut())),J=Kt(Q(ke(A),Ie(({items:L})=>L.length>0&&L[0].index===0),gn(0),ut())),re=Kt(Q(ke(A),De(M),Ie(([{items:L},V])=>L.length>0&&!V),ue(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(Kd),kn(0)));xe(re,p.scrollSeekRangeChanged),xe(Q(H,De(O,$,k,Y),ue(([L,V,Z,q,X])=>{const pe=Zd(L),{align:he,behavior:ee,offset:le}=pe;let we=pe.index;we==="LAST"&&(we=q-1),we=ro(0,we,ka(q-1,we));let je=Ta(V,X,Z,we);return he==="end"?je=Tf(je-V.height+Z.height):he==="center"&&(je=Tf(je-V.height/2+Z.height/2)),le&&(je+=le),{behavior:ee,top:je}})),l);const G=_t(Q(A,ue(L=>L.offsetBottom+L.bottom)),0);return xe(Q(T,ue(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:g,data:P,deviation:K,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:v,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T,...p,gridState:A,horizontalDirection:R,initialTopMostItemIndex:j,totalListHeight:G,...h,endReached:te,propsReady:x,rangeChanged:re,startReached:J,stateChanged:N,stateRestoreInProgress:M,...C}},ct(ga,Dt,no,uf,Rn,va,_n));function If(e,t,n){return ro(1,Es((e+n)/(Es(t)+n)))}function Nf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ta(e,t,n,r[0].index);return{bottom:Ta(e,t,n,r[r.length-1].index)+o,top:s}}function Ta(e,t,n,r){const o=If(e.width,n.width,t.column),s=Es(r/o),i=s*n.height+ro(0,s-1)*t.row;return i>0?i+t.row:i}const sS=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Sa),i=se("div"),a=se(yr),l=(f,h=null)=>_t(Q(t,ue(p=>p[f]),ut()),h),u=se(!1),d=se(!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")}}),iS=Ge(([e,t])=>({...e,...t}),ct(oS,sS)),aS=y.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=Qt("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=Qt("itemDimensions"),h=Qt("gap"),p=ft("log"),w=ft("stateRestoreInProgress"),x=Qt("reportReadyState"),g=Xn(y.useMemo(()=>v=>{const b=v.parentElement.parentElement.scrollHeight;i(b);const S=v.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}h({column:jf("column-gap",getComputedStyle(v).columnGap,p),row:jf("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return gf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),w?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(v=>{const b=o(v.index,v.data,d);return s?c.jsx(u,{...Mt(u,d),height:e.itemHeight,index:v.index,width:e.itemWidth},b):y.createElement(a,{...Mt(a,d),className:n,"data-index":v.index,key:b},r(v.index,v.data,d))})})}),lS=y.memo(function(){const e=ft("HeaderComponent"),t=Qt("headerHeight"),n=ft("headerFooterTag"),r=Xn(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}),cS=y.memo(function(){const e=ft("FooterComponent"),t=Qt("footerHeight"),n=ft("headerFooterTag"),r=Xn(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}),uS=({children:e})=>{const t=y.useContext(mf),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=Xn(y.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Ts(!1),children:e})},dS=({children:e})=>{const t=y.useContext(mf),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=ft("customScrollParent"),s=Fd(n,o,!1);return y.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Ts(!1),children:e})},fS=y.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?pS:hS,o=n||t?dS:uS,s=ft("context");return c.jsx(r,{...e,...Mt(r,s),children:c.jsxs(o,{children:[c.jsx(lS,{}),c.jsx(aS,{}),c.jsx(cS,{})]})})}),{useEmitter:Af,useEmitterValue:ft,usePublisher:Qt}=hf(iS,{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"}},fS),hS=yf({useEmitter:Af,useEmitterValue:ft,usePublisher:Qt}),pS=Sf({useEmitter:Af,useEmitterValue:ft,usePublisher:Qt});function jf(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 mS=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 _f({className:e,variant:t,...n}){return c.jsx("div",{className:oe(mS({variant:t}),e),...n})}async function Mf(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Rf(e,t){return await(await Mf(`/files/${e}/view`,t)).text()}async function gS(e,t){const n=await Mf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/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 xS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}var Ns="Dialog",[Pf,LT]=yn(Ns),[vS,ln]=Pf(Ns),Of=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=m.useRef(null),l=m.useRef(null),[u,d]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:Ns});return c.jsx(vS,{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})};Of.displayName=Ns;var Df="DialogTrigger",Lf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Df,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":Na(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});Lf.displayName=Df;var Ea="DialogPortal",[wS,$f]=Pf(Ea,{forceMount:void 0}),Ff=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=ln(Ea,t);return c.jsx(wS,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(Xt,{present:n||s.open,children:c.jsx(Qo,{asChild:!0,container:o,children:i})}))})};Ff.displayName=Ea;var As="DialogOverlay",Bf=m.forwardRef((e,t)=>{const n=$f(As,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(As,e.__scopeDialog);return s.modal?c.jsx(Xt,{present:r||s.open,children:c.jsx(yS,{...o,ref:t})}):null});Bf.displayName=As;var bS=Bn.createSlot("DialogOverlay.RemoveScroll"),yS=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(As,n);return c.jsx(ls,{as:bS,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ye.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qn="DialogContent",zf=m.forwardRef((e,t)=>{const n=$f(Qn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(Qn,e.__scopeDialog);return c.jsx(Xt,{present:r||s.open,children:s.modal?c.jsx(SS,{...o,ref:t}):c.jsx(CS,{...o,ref:t})})});zf.displayName=Qn;var SS=m.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=m.useRef(null),o=ze(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(Hf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),CS=m.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(Hf,{...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()}})}),Hf=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=ln(Qn,n),l=m.useRef(null),u=ze(t,l);return Ci(),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":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(kS,{titleId:a.titleId}),c.jsx(ES,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",Uf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Ia,n);return c.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Uf.displayName=Ia;var Wf="DialogDescription",Vf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Wf,n);return c.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Vf.displayName=Wf;var Kf="DialogClose",qf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Kf,n);return c.jsx(ye.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});qf.displayName=Kf;function Na(e){return e?"open":"closed"}var Gf="DialogTitleWarning",[$T,Yf]=Lx(Gf,{contentName:Qn,titleName:Ia,docsSlug:"dialog"}),kS=({titleId:e})=>{const t=Yf(Gf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},Sb=0,wr=[];function Cb(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(Sb++)[0],s=m.useState(ju)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Ww([e.lockRef.current],(e.shards||[]).map(Lu),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=as(x),b=n.current,S="deltaX"in x?x.deltaX:b[0]-v[0],T="deltaY"in x?x.deltaY:b[1]-v[1],C,k=x.target,E=Math.abs(S)>Math.abs(T)?"h":"v";if("touches"in x&&E==="h"&&k.type==="range")return!1;var A=Ru(E,k);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=Ru(E,k)),!A)return!1;if(!r.current&&"changedTouches"in x&&(S||T)&&(r.current=C),!C)return!0;var O=r.current||C;return wb(O,g,x,O==="h"?S:T)},[]),c=m.useCallback(function(x){var g=x;if(!(!wr.length||wr[wr.length-1]!==s)){var v="deltaY"in g?Du(g):as(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&bb(C.delta,v)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var S=(i.current.shards||[]).map(Lu).filter(Boolean).filter(function(C){return C.contains(g.target)}),T=S.length>0?a(g,S[0]):!i.current.noIsolation;T&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(x,g,v,b){var S={name:x,delta:g,target:v,should:b,shadowParent:kb(v)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(T){return T!==S})},1)},[]),d=m.useCallback(function(x){n.current=as(x),r.current=void 0},[]),f=m.useCallback(function(x){u(x.type,Du(x),x.target,a(x,e.lockRef.current))},[]),h=m.useCallback(function(x){u(x.type,as(x),x.target,a(x,e.lockRef.current))},[]);m.useEffect(function(){return wr.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(){wr=wr.filter(function(x){return x!==s}),document.removeEventListener("wheel",c,vr),document.removeEventListener("touchmove",c,vr),document.removeEventListener("touchstart",d,vr)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:yb(o)}):null,p?m.createElement(fb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function kb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Tb=Qw(Au,Cb);var ls=m.forwardRef(function(e,t){return m.createElement(ss,mn({},e,{ref:t,sideCar:Tb}))});ls.classNames=ss.classNames;var qi=["Enter"," "],Eb=["ArrowDown","PageUp","Home"],$u=["ArrowUp","PageDown","End"],Ib=[...Eb,...$u],Nb={ltr:[...qi,"ArrowRight"],rtl:[...qi,"ArrowLeft"]},Ab={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wr="Menu",[Vr,jb,_b]=bi(Wr),[Kn,Fu]=yn(Wr,[_b,Zo,bu]),cs=Zo(),Bu=bu(),[Mb,qn]=Kn(Wr),[Rb,Kr]=Kn(Wr),zu=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=cs(t),[c,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",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),l.jsx(mu,{...a,children:l.jsx(Mb,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:u,children:l.jsx(Rb,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};zu.displayName=Wr;var Pb="MenuAnchor",Gi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return l.jsx(gu,{...o,...r,ref:t})});Gi.displayName=Pb;var Yi="MenuPortal",[Ob,Hu]=Kn(Yi,{forceMount:void 0}),Uu=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=qn(Yi,t);return l.jsx(Ob,{scope:t,forceMount:n,children:l.jsx(Xt,{present:n||s.open,children:l.jsx(Qo,{asChild:!0,container:o,children:r})})})};Uu.displayName=Yi;var Jt="MenuContent",[Db,Xi]=Kn(Jt),Wu=m.forwardRef((e,t)=>{const n=Hu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Kr(Jt,e.__scopeMenu);return l.jsx(Vr.Provider,{scope:e.__scopeMenu,children:l.jsx(Xt,{present:r||s.open,children:l.jsx(Vr.Slot,{scope:e.__scopeMenu,children:i.modal?l.jsx(Lb,{...o,ref:t}):l.jsx($b,{...o,ref:t})})})})}),Lb=m.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu),r=m.useRef(null),o=ze(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),l.jsx(Ji,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),$b=m.forwardRef((e,t)=>{const n=qn(Jt,e.__scopeMenu);return l.jsx(Ji,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Fb=Bn.createSlot("MenuContent.ScrollLock"),Ji=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:w,...x}=e,g=qn(Jt,n),v=Kr(Jt,n),b=cs(n),S=Bu(n),T=jb(n),[C,k]=m.useState(null),E=m.useRef(null),A=ze(t,E,g.onContentChange),O=m.useRef(0),$=m.useRef(""),H=m.useRef(0),U=m.useRef(null),K=m.useRef("right"),P=m.useRef(0),Y=w?ls:m.Fragment,N=w?{as:Fb,allowPinchZoom:!0}:void 0,D=j=>{var G,L;const z=$.current+j,W=T().filter(V=>!V.disabled),R=document.activeElement,B=(G=W.find(V=>V.ref.current===R))==null?void 0:G.textValue,te=W.map(V=>V.textValue),J=Jb(te,z,B),re=(L=W.find(V=>V.textValue===J))==null?void 0:L.ref.current;(function V(Z){$.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>V(""),1e3))})(z),re&&setTimeout(()=>re.focus())};m.useEffect(()=>()=>window.clearTimeout(O.current),[]),Ci();const M=m.useCallback(j=>{var W,R;return K.current===((W=U.current)==null?void 0:W.side)&&Qb(j,(R=U.current)==null?void 0:R.area)},[]);return l.jsx(Db,{scope:n,searchRef:$,onItemEnter:m.useCallback(j=>{M(j)&&j.preventDefault()},[M]),onItemLeave:m.useCallback(j=>{var z;M(j)||((z=E.current)==null||z.focus(),k(null))},[M]),onTriggerLeave:m.useCallback(j=>{M(j)&&j.preventDefault()},[M]),pointerGraceTimerRef:H,onPointerGraceIntentChange:m.useCallback(j=>{U.current=j},[]),children:l.jsx(Y,{...N,children:l.jsx(zo,{asChild:!0,trapped:o,onMountAutoFocus:me(s,j=>{var z;j.preventDefault(),(z=E.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:l.jsx(Fw,{asChild:!0,...S,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:me(c,j=>{v.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(xu,{role:"menu","aria-orientation":"vertical","data-state":ad(g.open),"data-radix-menu-content":"",dir:v.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:me(x.onKeyDown,j=>{const W=j.target.closest("[data-radix-menu-content]")===j.currentTarget,R=j.ctrlKey||j.altKey||j.metaKey,B=j.key.length===1;W&&(j.key==="Tab"&&j.preventDefault(),!R&&B&&D(j.key));const te=E.current;if(j.target!==te||!Ib.includes(j.key))return;j.preventDefault();const re=T().filter(G=>!G.disabled).map(G=>G.ref.current);$u.includes(j.key)&&re.reverse(),Yb(re)}),onBlur:me(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(O.current),$.current="")}),onPointerMove:me(e.onPointerMove,Gr(j=>{const z=j.target,W=P.current!==j.clientX;if(j.currentTarget.contains(z)&&W){const R=j.clientX>P.current?"right":"left";K.current=R,P.current=j.clientX}}))})})})})})})});Wu.displayName=Jt;var Bb="MenuGroup",Zi=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"group",...r,ref:t})});Zi.displayName=Bb;var zb="MenuLabel",Vu=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{...r,ref:t})});Vu.displayName=zb;var us="MenuItem",Ku="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=Xi(us,e.__scopeMenu),c=ze(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(Ku,{bubbles:!0,cancelable:!0});f.addEventListener(Ku,p=>r==null?void 0:r(p),{once:!0}),Tc(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return l.jsx(qu,{...o,ref:c,disabled:n,onClick:me(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:me(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:me(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||qi.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ds.displayName=us;var qu=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Xi(us,n),a=Bu(n),c=m.useRef(null),u=ze(t,c),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=c.current;w&&p((w.textContent??"").trim())},[s.children]),l.jsx(Vr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:l.jsx(Bw,{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:me(e.onPointerMove,Gr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:me(e.onPointerLeave,Gr(w=>i.onItemLeave(w))),onFocus:me(e.onFocus,()=>f(!0)),onBlur:me(e.onBlur,()=>f(!1))})})})}),Hb="MenuCheckboxItem",Gu=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return l.jsx(Qu,{scope:e.__scopeMenu,checked:n,children:l.jsx(ds,{role:"menuitemcheckbox","aria-checked":fs(n)?"mixed":n,...o,ref:t,"data-state":ea(n),onSelect:me(o.onSelect,()=>r==null?void 0:r(fs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Gu.displayName=Hb;var Yu="MenuRadioGroup",[Ub,Wb]=Kn(Yu,{value:void 0,onValueChange:()=>{}}),Xu=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=It(r);return l.jsx(Ub,{scope:e.__scopeMenu,value:n,onValueChange:s,children:l.jsx(Zi,{...o,ref:t})})});Xu.displayName=Yu;var Ju="MenuRadioItem",Zu=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Wb(Ju,e.__scopeMenu),s=n===o.value;return l.jsx(Qu,{scope:e.__scopeMenu,checked:s,children:l.jsx(ds,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ea(s),onSelect:me(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Zu.displayName=Ju;var Qi="MenuItemIndicator",[Qu,Vb]=Kn(Qi,{checked:!1}),ed=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Vb(Qi,n);return l.jsx(Xt,{present:r||fs(s.checked)||s.checked===!0,children:l.jsx(ye.span,{...o,ref:t,"data-state":ea(s.checked)})})});ed.displayName=Qi;var Kb="MenuSeparator",td=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return l.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});td.displayName=Kb;var qb="MenuArrow",nd=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=cs(n);return l.jsx(vu,{...o,...r,ref:t})});nd.displayName=qb;var Gb="MenuSub",[PT,rd]=Kn(Gb),qr="MenuSubTrigger",od=m.forwardRef((e,t)=>{const n=qn(qr,e.__scopeMenu),r=Kr(qr,e.__scopeMenu),o=rd(qr,e.__scopeMenu),s=Xi(qr,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(Gi,{asChild:!0,...u,children:l.jsx(qu,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":ad(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:me(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:me(e.onPointerLeave,Gr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(w=n.content)==null?void 0:w.dataset.side,g=x==="right",v=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+v,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:me(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Nb[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});od.displayName=qr;var sd="MenuSubContent",id=m.forwardRef((e,t)=>{const n=Hu(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=qn(Jt,e.__scopeMenu),i=Kr(Jt,e.__scopeMenu),a=rd(sd,e.__scopeMenu),c=m.useRef(null),u=ze(t,c);return l.jsx(Vr.Provider,{scope:e.__scopeMenu,children:l.jsx(Xt,{present:r||s.open,children:l.jsx(Vr.Slot,{scope:e.__scopeMenu,children:l.jsx(Ji,{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:me(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:me(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:me(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Ab[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});id.displayName=sd;function ad(e){return e?"open":"closed"}function fs(e){return e==="indeterminate"}function ea(e){return fs(e)?"indeterminate":e?"checked":"unchecked"}function Yb(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Xb(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Jb(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=Xb(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 Zb(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 Qb(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Zb(n,t)}function Gr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ey=zu,ty=Gi,ny=Uu,ry=Wu,oy=Zi,sy=Vu,iy=ds,ay=Gu,ly=Xu,cy=Zu,uy=ed,dy=td,fy=nd,hy=od,py=id,hs="DropdownMenu",[my,OT]=yn(hs,[Fu]),Ot=Fu(),[gy,ld]=my(hs),cd=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:hs});return l.jsx(gy,{scope:t,triggerId:Pt(),triggerRef:u,contentId:Pt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:l.jsx(ey,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};cd.displayName=hs;var ud="DropdownMenuTrigger",dd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=ld(ud,n),i=Ot(n);return l.jsx(ty,{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:me(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:me(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});dd.displayName=ud;var xy="DropdownMenuPortal",fd=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return l.jsx(ny,{...r,...n})};fd.displayName=xy;var hd="DropdownMenuContent",pd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=ld(hd,n),s=Ot(n),i=m.useRef(!1);return l.jsx(ry,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:me(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:me(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)"}})});pd.displayName=hd;var vy="DropdownMenuGroup",wy=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(oy,{...o,...r,ref:t})});wy.displayName=vy;var by="DropdownMenuLabel",md=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(sy,{...o,...r,ref:t})});md.displayName=by;var yy="DropdownMenuItem",gd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(iy,{...o,...r,ref:t})});gd.displayName=yy;var Sy="DropdownMenuCheckboxItem",xd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(ay,{...o,...r,ref:t})});xd.displayName=Sy;var Cy="DropdownMenuRadioGroup",ky=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(ly,{...o,...r,ref:t})});ky.displayName=Cy;var Ty="DropdownMenuRadioItem",vd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(cy,{...o,...r,ref:t})});vd.displayName=Ty;var Ey="DropdownMenuItemIndicator",wd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(uy,{...o,...r,ref:t})});wd.displayName=Ey;var Iy="DropdownMenuSeparator",bd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(dy,{...o,...r,ref:t})});bd.displayName=Iy;var Ny="DropdownMenuArrow",Ay=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(fy,{...o,...r,ref:t})});Ay.displayName=Ny;var jy="DropdownMenuSubTrigger",yd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(hy,{...o,...r,ref:t})});yd.displayName=jy;var _y="DropdownMenuSubContent",Sd=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return l.jsx(py,{...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)"}})});Sd.displayName=_y;var My=cd,Ry=dd,Py=fd,Cd=pd,kd=md,Td=gd,Ed=xd,Id=vd,Nd=wd,Ad=bd,jd=yd,_d=Sd;const ta=My,na=Ry,Oy=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>l.jsxs(jd,{ref:o,className:oe("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"})]}));Oy.displayName=jd.displayName;const Dy=m.forwardRef(({className:e,...t},n)=>l.jsx(_d,{ref:n,className:oe("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}));Dy.displayName=_d.displayName;const ps=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>l.jsx(Py,{children:l.jsx(Cd,{ref:r,sideOffset:t,className:oe("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=Cd.displayName;const Gn=m.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(Td,{ref:r,className:oe("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}));Gn.displayName=Td.displayName;const Ly=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>l.jsxs(Ed,{ref:o,className:oe("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(Nd,{children:l.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));Ly.displayName=Ed.displayName;const $y=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Id,{ref:r,className:oe("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(Nd,{children:l.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));$y.displayName=Id.displayName;const Fy=m.forwardRef(({className:e,inset:t,...n},r)=>l.jsx(kd,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Fy.displayName=kd.displayName;const By=m.forwardRef(({className:e,...t},n)=>l.jsx(Ad,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));By.displayName=Ad.displayName;function zy(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 Hy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="number"?n:null}function Uy(e,t){if(!e||typeof e!="object")return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function Wy(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=Hy(d.metadata,"step"),p=Uy(d.metadata,"source"),w={id:f,step:h,source:p,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null};if(s.set(f,w),h!==null&&p){const x=`${h}:${p}`,g=i.get(x)??[];g.push(w),i.set(x,g)}}const{attemptMetaById:c,userMessageIdToAttempts:u}=zy(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 ms=0,jn=1,br=2,Md=4;function Rd(e){return()=>e}function Vy(e){e()}function Pd(e,t){return n=>e(t(n))}function Od(e,t){return()=>e(t)}function Ky(e,t){return n=>e(t,n)}function ra(e){return e!==void 0}function qy(...e){return()=>{e.map(Vy)}}function yr(){}function gs(e,t){return t(e),e}function Gy(e,t){return t(e)}function ct(...e){return e}function et(e,t){return e(jn,t)}function Re(e,t){e(ms,t)}function oa(e){e(br)}function xt(e){return e(Md)}function xe(e,t){return et(e,Ky(t,ms))}function sn(e,t){const n=e(jn,r=>{n(),t(r)});return n}function Dd(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ld(e,t){return e===t}function ut(e=Ld){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=>Pd(t,e)}function gn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=Yy(...t);return(r,o)=>{switch(r){case br:oa(e);return;case jn:return et(e,n(o))}}}function xn(e,t){return n=>r=>{n(t=e(t,r))}}function Yn(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);et(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 Yy(...e){return t=>e.reduceRight(Gy,t)}function Xy(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=et(e,s),t):(r(),yr);case br:r(),n=null;return}}}function se(e){let t=e;const n=He();return(r,o)=>{switch(r){case ms:t=o;break;case jn:{o(t);break}case Md:return t}return n(r,o)}}function _t(e,t){return gs(se(t),n=>xe(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case ms:e.slice().forEach(r=>{r(n)});return;case br:e.splice(0,e.length);return;case jn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Kt(e){return gs(He(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Jy(),singleton:n}}const Jy=()=>Symbol();function Zy(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);et(s,c=>{n[i]=c,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case br:{oa(t);return}case jn:return r===o&&i(n),et(t,i)}}}function ke(e,t=Ld){return Q(e,ut(t))}function sa(...e){return function(t,n){switch(t){case br:return;case jn:return qy(...e.map(r=>et(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 Qy={0:"debug",3:"error",1:"log",2:"warn"},e0=()=>typeof globalThis>"u"?window:globalThis,_n=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=e0().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[Qy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Xn(e,t,n){return ia(e,t,n).callbackRef}function ia(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 t0(e,t,n,r,o,s,i,a,c){const u=y.useCallback(d=>{const f=n0(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const x=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:v}),s==null||s(a?$d("column-gap",getComputedStyle(d).columnGap,o):$d("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ia(u,n,c)}function n0(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 $d(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 Fd(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(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ia(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=Ge(()=>{const e=He(),t=He(),n=se(0),r=He(),o=se(0),s=He(),i=He(),a=se(0),c=se(0),u=se(0),d=se(0),f=He(),h=He(),p=se(!1),w=se(!1),x=se(!1);return xe(Q(e,ue(({scrollTop:g})=>g)),t),xe(Q(e,ue(({scrollHeight:g})=>g)),i),xe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Yr={lvl:0};function Bd(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 ot(e){return e===Yr}function Xr(e,t){if(!ot(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(ot(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 ot(e)?Ud(t,n,1):t===e.k?bt(e,{k:t,v:n}):t<e.k?Wd(bt(e,{l:qt(e.l,t,n)})):Wd(bt(e,{r:qt(e.r,t,n)}))}function Sr(){return Yr}function xs(e,t,n){if(ot(e))return[];const r=an(e,t)[0];return r0(la(e,r,n))}function aa(e,t){if(ot(e))return Yr;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Hd(r);return vs(bt(e,{k:s,l:zd(r),v:i}))}}else return t<n?vs(bt(e,{l:aa(r,t)})):vs(bt(e,{r:aa(o,t)}))}function Jn(e){return ot(e)?[]:[...Jn(e.l),{k:e.k,v:e.v},...Jn(e.r)]}function la(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(la(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(la(s,t,n))),a}function vs(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(ca(t))return Vd(bt(e,{lvl:n-1}));if(!ot(t)&&!ot(t.r))return bt(t.r,{l:bt(t,{r:t.r.l}),lvl:n,r:bt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ca(e))return ua(bt(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=ca(o)?r.lvl-1:r.lvl;return bt(o,{l:bt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:ua(bt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function bt(e,t){return Ud(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 zd(e){return ot(e.r)?e.l:vs(bt(e,{r:zd(e.r)}))}function ca(e){return ot(e)||e.lvl>e.r.lvl}function Hd(e){return ot(e.r)?[e.k,e.v]:Hd(e.r)}function Ud(e,t,n,r=Yr,o=Yr){return{k:e,l:r,lvl:n,r:o,v:t}}function Wd(e){return ua(Vd(e))}function Vd(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?bt(t,{r:bt(e,{l:t.r})}):e}function ua(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?bt(n,{l:bt(e,{r:n.l}),lvl:t+1}):e}function r0(e){return Bd(e,({k:t,v:n})=>({index:t,value:n}))}function Kd(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 da=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function qd(e,t,n){return e[ws(e,t,n)]}function ws(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 o0(e,t,n,r){const o=ws(e,t,r),s=ws(e,n,r,o);return e.slice(o,s+1)}function Mn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bs(e){return!ot(e.groupOffsetTree)}function fa({index:e},t){return t===e?0:t<e?-1:1}function s0(){return{groupIndices:[],groupOffsetTree:Sr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Sr()}}function i0(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=qt(e,0,s);continue}const a=xs(e,i-1,o+1);if(a.some(h0(r)))continue;let c=!1,u=!1;for(const{end:d,start:f,value:h}of a)c?(o>=f||s===h)&&(e=aa(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 a0(e){return typeof e.groupIndex<"u"}function l0({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}=qd(t,e,fa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Gd(e,t){if(!bs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Yd(e,t,n){if(a0(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Gd(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function c0(e,t,n,r=0){return r>0&&(t=Math.max(t,qd(e,r,fa).offset)),Bd(o0(e,t,n,l0),f0)}function u0(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,x)=>qt(qt(w,x,h),x+1,p),i)}else[i,a]=i0(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f}=ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>qt(h,p,Zr(p,f,o)),Sr()),lastIndex:c,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function d0(e){return Jn(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 Xd(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 ha(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=ws(o,t-1,fa),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 xs(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 f0(e){return{index:e.index,value:e}}function h0(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 p0={offsetHeight:"height",offsetWidth:"width"},vn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=_t(r,0),s=He(),i=He(),a=se(0),c=se([]),u=se(void 0),d=se(void 0),f=se((C,k)=>Mn(C,p0[k])),h=se(void 0),p=se(0),w=s0(),x=_t(Q(n,De(c,e,p),xn(u0,w),ut()),w),g=_t(Q(c,ut(),xn((C,k)=>({current:k,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(Q(c,Ie(C=>C.length>0),De(x,p),ue(([C,k,E])=>{const A=C.reduce((O,$,H)=>qt(O,$,Zr($,k.offsetTree,E)||H),Sr());return{...k,groupIndices:C,groupOffsetTree:A}})),x),xe(Q(r,De(x),Ie(([C,{lastIndex:k}])=>C<k),ue(([C,{lastIndex:k,lastSize:E}])=>[{endIndex:k,size:E,startIndex:C}])),n),xe(u,d);const v=_t(Q(u,ue(C=>C===void 0)),!0);xe(Q(d,Ie(C=>C!==void 0&&ot(xt(x).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=Kt(Q(n,De(x),xn(({sizes:C},[k,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:w}),ue(C=>C.changed)));et(Q(a,xn((C,k)=>({diff:C.prev-k,prev:k}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:k}=xt(x);if(C>0)Re(t,!0),Re(s,C+Xd(C,k));else if(C<0){const E=xt(g);E.length>0&&(C-=Xd(-C,E)),Re(i,C)}}),et(Q(a,De(e)),([C,k])=>{C<0&&k("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const S=Kt(s);xe(Q(s,De(x),ue(([C,k])=>{const E=k.groupIndices.length>0,A=[],O=k.lastSize;if(E){const $=Xr(k.sizeTree,0);let H=0,U=0;for(;H<C;){const P=k.groupIndices[U],Y=k.groupIndices.length===U+1?1/0:k.groupIndices[U+1]-P-1;A.push({endIndex:P,size:$,startIndex:P}),A.push({endIndex:P+1+Y-1,size:O,startIndex:P+1}),U++,H+=Y+1}const K=Jn(k.sizeTree);return H!==C&&K.shift(),K.reduce((P,{k:Y,v:N})=>{let D=P.ranges;return P.prevSize!==0&&(D=[...P.ranges,{endIndex:Y+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:Y+C,prevSize:N,ranges:D}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Jn(k.sizeTree).reduce(($,{k:H,v:U})=>({prevIndex:H+C,prevSize:U,ranges:[...$.ranges,{endIndex:H+C-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const T=Kt(Q(i,De(x,p),ue(([C,{offsetTree:k},E])=>{const A=-C;return Zr(A,k,E)})));return xe(Q(i,De(x,p),ue(([C,k,E])=>{if(k.groupIndices.length>0){if(ot(k.sizeTree))return k;let A=Sr();const O=xt(g);let $=0,H=0,U=0;for(;$<-C;){U=O[H];const K=O[H+1]-U-1;H++,$+=K+1}if(A=Jn(k.sizeTree).reduce((K,{k:P,v:Y})=>qt(K,Math.max(0,P+C),Y),A),$!==-C){const K=Xr(k.sizeTree,U);A=qt(A,0,K);const P=an(k.sizeTree,-C+1)[1];A=qt(A,1,P)}return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}else{const A=Jn(k.sizeTree).reduce((O,{k:$,v:H})=>qt(O,Math.max(0,$+C),H),Sr());return{...k,sizeTree:A,...ha(k.offsetTree,0,A,E)}}})),x),{beforeUnshiftWith:S,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:c,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:T,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:v,unshiftWith:s}},ct(_n,da),{singleton:!0});function m0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Jd=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Kt(Q(s,ue(m0)));return xe(Q(a,ue(c=>c.totalCount)),n),xe(Q(a,ue(c=>c.groupIndices)),e),xe(Q(wt(o,t,r),Ie(([c,u])=>bs(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=Ge(([{log:e}])=>{const t=se(!1),n=Kt(Q(t,Ie(r=>r),ut()));return et(t,r=>{r&&xt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},ct(_n),{singleton:!0}),g0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Zd(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!g0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Qr=Ge(([{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(),w=He(),x=se(0);let g=null,v=null,b=null;function S(){g&&(g(),g=null),b&&(b(),b=null),v&&(clearTimeout(v),v=null),Re(c,!1)}return xe(Q(p,De(n,f,r,x,a,i,h),De(e,s,o),ue(([[T,C,k,E,A,O,$,H],U,K,P])=>{const Y=Zd(T),{align:N,behavior:D,offset:M}=Y,j=E-1,z=Yd(Y,C,j);let W=Zr(z,C.offsetTree,U)+O;N==="end"?(W+=K+an(C.sizeTree,z)[1]-k+P,z===j&&(W+=$)):N==="center"?W+=(K+an(C.sizeTree,z)[1]-k+P)/2:W-=A,M&&(W+=M);const R=B=>{S(),B?(H("retrying to scroll to",{location:T},Bt.DEBUG),Re(p,T)):(Re(w,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),D==="smooth"){let B=!1;b=et(t,te=>{B=B||te}),g=sn(d,()=>{R(B)})}else g=sn(Q(t,x0(150)),R);return v=setTimeout(()=>{S()},1200),Re(c,!0),H("scrolling from index to",{behavior:D,index:z,top:W},Bt.DEBUG),{behavior:D,top:W}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:x}},ct(vn,Dt,_n),{singleton:!0});function x0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function pa(e,t){e==0?t():requestAnimationFrame(()=>{pa(e-1,t)})}function ma(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const eo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),c=se(0),u=se(!0);return xe(Q(i,De(c),Ie(([d,f])=>!!f),gn(!1)),a),xe(Q(i,De(c),Ie(([d,f])=>!!f),gn(!1)),u),et(Q(wt(t,i),De(a,n,e,u),Ie(([[,d],f,{sizeTree:h},p,w])=>d&&(!ot(h)||ra(p))&&!f&&!w),De(c)),([,d])=>{sn(o,()=>{Re(u,!0)}),pa(4,()=>{sn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:a}},ct(vn,Dt,Qr,Rn),{singleton:!0});function Qd(e,t){return Math.abs(e-t)<1.01}const to="up",no="down",v0="none",w0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},b0=0,ro=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),c=He(),u=He(),d=se(4),f=se(b0),h=_t(Q(sa(Q(ke(o),Yn(1),gn(!0)),Q(ke(o),Yn(1),gn(!1),Dd(100))),ut()),!1),p=_t(Q(sa(Q(n,gn(!0)),Q(n,gn(!1),Dd(200))),ut()),!1);xe(Q(wt(ke(o),ke(f)),ue(([b,S])=>b<=S),ut()),a),xe(Q(a,kn(50)),u);const w=Kt(Q(wt(r,ke(s),ke(t),ke(e),ke(d)),xn((b,[{scrollHeight:S,scrollTop:T},C,k,E,A])=>{const O=T+C-S>-A,$={scrollHeight:S,scrollTop:T,viewportHeight:C};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:$}}let H;return $.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":C<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:$}},w0),ut((b,S)=>b&&b.atBottom===S.atBottom))),x=_t(Q(r,xn((b,{scrollHeight:S,scrollTop:T,viewportHeight:C})=>{if(Qd(b.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const k=S-(T+C)<1;return b.scrollTop!==T&&k?{changed:!0,jump:b.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(b=>b.changed),ue(b=>b.jump)),0);xe(Q(w,ue(b=>b.atBottom)),i),xe(Q(i,kn(50)),c);const g=se(no);xe(Q(r,ue(({scrollTop:b})=>b),ut(),xn((b,S)=>xt(p)?{direction:b.direction,prevScrollTop:S}:{direction:S<b.prevScrollTop?to:no,prevScrollTop:S},{direction:no,prevScrollTop:0}),ue(b=>b.direction)),g),xe(Q(r,kn(50),gn(v0)),g);const v=se(0);return xe(Q(h,Ie(b=>!b),gn(0)),v),xe(Q(o,kn(100),De(h),Ie(([b,S])=>!!S),xn(([b,S],[T])=>[S,T],[0,0]),ue(([b,S])=>S-b)),v),{atBottomState:w,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:v}},ct(Dt)),ys="top",Ss="bottom",ef="none";function tf(e,t,n){return typeof e=="number"?n===to&&t===ys||n===no&&t===Ss?e:0:n===to?t===ys?e.main:e.reverse:t===Ss?e.main:e.reverse}function nf(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ga=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=se(0),a=se(0),c=se(0),u=_t(Q(wt(ke(r),ke(o),ke(n),ke(s,Jr),ke(c),ke(i),ke(t),ke(e),ke(a)),ue(([d,f,h,[p,w],x,g,v,b,S])=>{const T=d-b,C=g+v,k=Math.max(h-T,0);let E=ef;const A=nf(S,ys),O=nf(S,Ss);return p-=b,p+=h+v,w+=h+v,w-=b,p>d+C-A&&(E=to),w<d-k+f+O&&(E=no),E!==ef?[Math.max(T-h-tf(x,ys,E)-A,0),T-k-v+f+tf(x,Ss,E)+O]:null}),Ie(d=>d!=null),ut(Jr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:u}},ct(Dt),{singleton:!0});function y0(e,t,n){if(bs(t)){const r=Gd(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 xa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Cs(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 x=e[e.length-1];d=x.offset+x.size}const f=n-i,h=a+f*c+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:of(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:of(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function rf(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=ma(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Cs(u,[],a,o,n,r)}function of(e,t,n){if(e.length===0)return[];if(!bs(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=xs(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 Zn=Ge(([{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:w}])=>{const x=se([]),g=se(0),v=He();xe(s.topItemsIndexes,x);const b=_t(Q(wt(p,w,ke(c,Jr),ke(o),ke(r),ke(u),d,ke(x),ke(t),ke(n),e),Ie(([k,E,,A,,,,,,,O])=>{const $=O&&O.length!==A;return k&&!E&&!$}),ue(([,,[k,E],A,O,$,H,U,K,P,Y])=>{const N=O,{offsetTree:D,sizeTree:M}=N,j=xt(g);if(A===0)return{...xa,totalCount:A};if(k===0&&E===0)return j===0?{...xa,totalCount:A}:rf(j,$,O,K,P,Y||[]);if(ot(M))return j>0?null:Cs(y0(ma($,A),N,Y),[],A,P,N,K);const z=[];if(U.length>0){const J=U[0],re=U[U.length-1];let G=0;for(const L of xs(M,J,re)){const V=L.value,Z=Math.max(L.start,J),q=Math.min(L.end,re);for(let X=Z;X<=q;X++)z.push({data:Y==null?void 0:Y[X],index:X,offset:G,size:V}),G+=V}}if(!H)return Cs([],z,A,P,N,K);const W=U.length>0?U[U.length-1]+1:0,R=c0(D,k,E,W);if(R.length===0)return null;const B=A-1,te=gs([],J=>{for(const re of R){const G=re.value;let L=G.offset,V=re.start;const Z=G.size;if(G.offset<k){V+=Math.floor((k-G.offset+P)/(Z+P));const X=V-re.start;L+=X*Z+X*P}V<W&&(L+=(W-V)*Z,V=W);const q=Math.min(re.end,B);for(let X=V;X<=q&&!(L>=E);X++)J.push({data:Y==null?void 0:Y[X],index:X,offset:L,size:Z}),L+=Z+P}});return Cs(te,z,A,P,N,K)}),Ie(k=>k!==null),ut()),xa);xe(Q(e,Ie(ra),ue(k=>k==null?void 0:k.length)),o),xe(Q(b,ue(k=>k.topListHeight)),f),xe(f,a),xe(Q(b,ue(k=>[k.top,k.bottom])),i),xe(Q(b,ue(k=>k.items)),v);const S=Kt(Q(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=Kt(Q(b,kn(200),Ie(({items:k,topItems:E})=>k.length>0&&k[0].originalIndex===E.length),ue(({items:k})=>k[0].index),ut())),C=Kt(Q(b,Ie(({items:k})=>k.length>0),ue(({items:k})=>{let E=0,A=k.length-1;for(;k[E].type==="group"&&E<A;)E++;for(;k[A].type==="group"&&A>E;)A--;return{endIndex:k[A].index,startIndex:k[E].index}}),ut(Kd)));return{endReached:S,initialItemCount:g,itemsRendered:v,listState:b,rangeChanged:C,startReached:T,topItemsIndexes:x,...h}},ct(vn,Jd,ga,eo,Qr,ro,Rn,da),{singleton:!0}),sf=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=_t(Q(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,Zn),{singleton:!0}),S0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(Q(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,sf),{singleton:!0}),af=Ge(()=>({context:se(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,lf=Ge(([{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(Q(d,De(t,c,n,s,o,r,a),De(e),ue(([[f,h,p,w,x,g,v,b],S])=>{const{align:T,behavior:C,calculateViewLocation:k=C0,done:E,...A}=f,O=Yd(f,h,w-1),$=Zr(O,h.offsetTree,S)+x+g,H=$+an(h.sizeTree,O)[1],U=b+g,K=b+p-v,P=k({itemBottom:H,itemTop:$,locationParams:{align:T,behavior:C,...A},viewportBottom:K,viewportTop:U});return P?E&&sn(Q(i,Ie(Y=>!Y),Yn(xt(i)?1:2)),E):E&&E(),P}),Ie(f=>f!==null)),u),{scrollIntoView:d}},ct(vn,Dt,Qr,Zn,_n),{singleton:!0});function cf(e){return e?e==="smooth"?"smooth":"auto":!1}const k0=(e,t)=>typeof e=="function"?cf(e(t)):t&&cf(e),T0=Ge(([{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 w=se(!1),x=He();let g=null;function v(C){Re(i,{align:"end",behavior:C,index:"LAST"})}et(Q(wt(Q(ke(t),Yn(1)),c),De(ke(w),s,a,f),ue(([[C,k],E,A,O,$])=>{let H=k&&O,U="auto";return H&&(U=k0(E,A||$),H=H&&!!U),{followOutputBehavior:U,shouldFollow:H,totalCount:C}}),Ie(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:k})=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(C)}):g=sn(e,()=>{xt(d)("following output to ",{totalCount:k},Bt.DEBUG),v(C),g=null})});function b(C){const k=sn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(xt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),v("auto"))});setTimeout(k,100)}et(Q(wt(ke(w),t,u),Ie(([C,,k])=>C&&k),xn(({value:C},[,k])=>({refreshed:C===k,value:k}),{refreshed:!1,value:0}),Ie(({refreshed:C})=>C),De(w,t)),([,C])=>{xt(a)&&b(C!==!1)}),et(x,()=>{b(xt(w)!==!1)}),et(wt(ke(w),o),([C,k])=>{C&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=se(null),T=He();return xe(sa(Q(ke(r),ue(C=>{var k;return(k=C==null?void 0:C.length)!=null?k:0})),Q(ke(t))),T),et(Q(wt(Q(T,Yn(1)),c),De(ke(S),a,f,h),ue(([[C,k],E,A,O,$])=>k&&A&&(E==null?void 0:E({context:$,totalCount:C,scrollingInProgress:O}))),Ie(C=>!!C),kn(0)),C=>{g&&(g(),g=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Re(p,C)}):g=sn(e,()=>{xt(d)("scrolling into view",{}),Re(p,C),g=null})}),{autoscrollToBottom:x,followOutput:w,scrollIntoViewOnChange:S}},ct(vn,ro,Qr,eo,Rn,_n,Dt,af,lf)),E0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(Q(a,De(s),Ie(([,c])=>c!==0),De(o,r,t,n,e),ue(([[,c],u,d,f,h,p=[]])=>rf(c,u,d,f,h,p))),i),{}),ct(vn,eo,Zn,Rn),{singleton:!0}),I0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return et(Q(e,De(r),Ie(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{sn(Q(n,Yn(1),Ie(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},ct(Rn,Dt,Zn),{singleton:!0}),uf=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=He(),r=se(!1);return xe(Q(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),et(Q(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(ro),{singleton:!0}),va=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=se(!1),i=se(void 0);return xe(Q(wt(n,r),ue(([{scrollHeight:a,scrollTop:c,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:u}))),e),xe(Q(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)),N0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const u=He(),d=se(void 0),f=se(null),h=se(null);return xe(a,f),xe(c,h),et(Q(u,De(t,r,i,f,h,n)),([p,w,x,g,v,b,S])=>{const T=d0(w.sizeTree);g&&v!==null&&b!==null&&(x=v.scrollTop-b.offsetTop),x-=S,p({ranges:T,scrollTop:x})}),xe(Q(d,Ie(ra),ue(A0)),o),xe(Q(s,De(d),Ie(([,p])=>p!==void 0),ut(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},ct(vn,Dt,eo,Rn,va));function A0(e){return{align:"start",index:0,offset:e.scrollTop}}const j0=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(Q(t,Ie(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ct(Zn));function df(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const _0=df(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),M0=Ge(([{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:w}])=>{const x=Kt(Q(c,De(i),xn(([,v,b,S],[{bottom:T,items:C,offsetBottom:k,totalCount:E},A])=>{const O=T+k;let $=0;return b===E&&v.length>0&&C.length>0&&(C[0].originalIndex===0&&v[0].originalIndex===0||($=O-S,$!==0&&($+=A))),[$,C,E,O]},[0,[],0,0]),Ie(([v])=>v!==0),De(r,a,n,o,p,w),Ie(([,v,b,S,,,T])=>!T&&!S&&v!==0&&b===to),ue(([[v],,,,,b])=>(b("Upward scrolling compensation",{amount:v},Bt.DEBUG),v))));function g(v){v>0?(Re(t,{behavior:"auto",top:-v}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-v}))}return et(Q(x,De(e,s)),([v,b,S])=>{S&&_0()?Re(e,b-v):g(-v)}),et(Q(wt(_t(s,!1),e,w),Ie(([v,b,S])=>!v&&!S&&b!==0),ue(([v,b])=>b),kn(1)),g),xe(Q(f,ue(v=>({top:-v}))),t),et(Q(u,De(h,d),ue(([v,{groupIndices:b,lastSize:S,sizeTree:T},C])=>{function k(E){return E*(S+C)}if(b.length===0)return k(v);{let E=0;const A=Xr(T,0);let O=0,$=0;for(;O<v;){O++,E+=A;let H=b.length===$+1?1/0:b[$+1]-b[$]-1;O+H>v&&(E-=A,H=v-O+1),O+=H,E+=k(H),$++}return E}})),v=>{Re(e,v),requestAnimationFrame(()=>{Re(t,{top:v}),requestAnimationFrame(()=>{Re(e,0),Re(w,!1)})})}),{deviation:e}},ct(Dt,ro,Zn,vn,_n,da)),R0=Ge(([e,t,n,r,o,s,i,a,c,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...u,...d}),ct(ga,E0,Rn,uf,sf,I0,S0,va,lf,_n,af)),ff=Ge(([{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:w},x,g,v,{listState:b,topItemsIndexes:S,...T},{scrollToIndex:C},k,{topItemCount:E},{groupCounts:A},O])=>(xe(T.rangeChanged,O.scrollSeekRangeChanged),xe(Q(O.windowViewportRect,ue($=>$.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...v,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...T,...O,...x,sizes:c,...g}),ct(vn,eo,Dt,N0,T0,Zn,Qr,M0,j0,Jd,R0));function P0(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 ks=typeof document<"u"?y.useLayoutEffect:y.useEffect;function hf(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,v){g.propsReady&&Re(g.propsReady,!1);for(const b of r){const S=g[t.required[b]];Re(S,v[b])}for(const b of o)if(b in v){const S=g[t.optional[b]];Re(S,v[b])}g.propsReady&&Re(g.propsReady,!0)}function u(g){return s.reduce((v,b)=>(v[b]=S=>{const T=g[t.methods[b]];Re(T,S)},v),{})}function d(g){return i.reduce((v,b)=>(v[b]=Xy(g[t.events[b]]),v),{})}const f=y.forwardRef((g,v)=>{const{children:b,...S}=g,[T]=y.useState(()=>gs(Zy(e),E=>{c(E,S)})),[C]=y.useState(Od(d,T));ks(()=>{for(const E of i)E in S&&et(C[E],S[E]);return()=>{Object.values(C).map(oa)}},[S,C,T]),ks(()=>{c(T,S)}),y.useImperativeHandle(v,Rd(u(T)));const k=n;return l.jsx(a.Provider,{value:T,children:n?l.jsx(k,{...P0([...r,...o,...i],S),children:b}):b})}),h=g=>{const v=y.useContext(a);return y.useCallback(b=>{Re(v[g],b)},[v,g])},p=g=>{const v=y.useContext(a)[g],b=y.useCallback(S=>et(v,S),[v]);return y.useSyncExternalStore(b,()=>xt(v),()=>xt(v))},w=g=>{const v=y.useContext(a)[g],[b,S]=y.useState(Od(xt,v));return ks(()=>et(v,T=>{T!==b&&S(Rd(T))}),[v,b]),b},x=y.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,v)=>{const b=y.useContext(a)[g];ks(()=>et(b,v),[v,b])},useEmitterValue:x,usePublisher:h}}const pf=y.createContext(void 0),mf=y.createContext(void 0),gf=typeof document<"u"?y.useLayoutEffect:y.useEffect;function wa(e){return"self"in e}function O0(e){return"body"in e}function xf(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,w,x;const g=h.target;if(O0(g)||wa(g)){const b=wa(g)?g:g.defaultView;x=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else x=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const v=()=>{e({scrollHeight:p,scrollTop:Math.max(x,0),viewportHeight:w})};h.suppressFlushSync?v():Zs.flushSync(v),a.current!==null&&(x===a.current||x<=0||x===p-w)&&(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 w=h.behavior==="smooth";let x,g,v;wa(p)?(g=Math.max(Mn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),x=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],x=Mn(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const b=g-x;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),Qd(x,g)||h.top===v){e({scrollHeight:g,scrollTop:v,viewportHeight:x}),w&&t(!0);return}w?(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 ba="-webkit-sticky",vf="sticky",ya=df(()=>{if(typeof document>"u")return vf;const e=document.createElement("div");return e.style.position=ba,e.style.position===ba?ba:vf});function Sa(e){return e}const D0=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Sa),o=se("div"),s=se(yr),i=(a,c=null)=>_t(Q(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")}}),L0=Ge(([e,t])=>({...e,...t}),ct(ff,D0)),$0=({height:e})=>l.jsx("div",{style:{height:e}}),F0={overflowAnchor:"none",position:ya(),zIndex:1},wf={overflowAnchor:"none"},B0={...wf,display:"inline-block",height:"100%"},bf=y.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=Zt("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=Zt("windowScrollContainerState"),i=Zt("scrollContainerState"),a=o||r?s:i,c=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),h=Ae("itemSize"),p=Ae("log"),w=Zt("gap"),x=Ae("horizontalDirection"),{callbackRef:g}=t0(n,h,f,e?yr:a,p,w,o,x,Ae("skipAnimationFrameInResizeObserver")),[v,b]=y.useState(0);Ca("deviation",P=>{v!==P&&b(P)});const S=Ae("EmptyPlaceholder"),T=Ae("ScrollSeekPlaceholder")||$0,C=Ae("ListComponent"),k=Ae("ItemComponent"),E=Ae("GroupComponent"),A=Ae("computeItemKey"),O=Ae("isSeeking"),$=Ae("groupIndices").length>0,H=Ae("alignToBottom"),U=Ae("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:v!==0?v:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?l.jsx(S,{...Mt(S,u)}):l.jsx(C,{...Mt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:K,children:(e?t.topItems:t.items).map(P=>{const Y=P.originalIndex,N=A(Y+t.firstItemIndex,P.data,u);return O?y.createElement(T,{...Mt(T,u),height:P.size,index:P.index,key:N,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(E,{...Mt(E,u),"data-index":Y,"data-item-index":P.index,"data-known-size":P.size,key:N,style:F0},d(P.index,u)):y.createElement(k,{...Mt(k,u),...W0(k,P.data),"data-index":Y,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:N,style:x?B0:wf},$?c(P.index,P.groupIndex,P.data,u):c(P.index,P.data,u))})})}),z0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},H0={outline:"none",overflowX:"auto",position:"relative"},Ts=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),U0={position:ya(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function W0(e,t){return{item:typeof e=="string"?void 0:t}}const V0=y.memo(function(){const e=Ae("HeaderComponent"),t=Zt("headerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null}),K0=y.memo(function(){const e=Ae("FooterComponent"),t=Zt("footerHeight"),n=Ae("HeaderFooterTag"),r=Xn(y.useMemo(()=>s=>{t(Mn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?l.jsx(n,{ref:r,children:l.jsx(e,{...Mt(e,o)})}):null});function yf({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:w}=xf(a,u,c,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),l.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?H0:z0,...o},tabIndex:0,...i,...Mt(c,s),children:r})})}function Sf({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),w=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:v}=xf(a,u,c,w,h);return gf(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",v),e("scrollBy",x),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 q0=({children:e})=>{const t=y.useContext(pf),n=Zt("viewportHeight"),r=Zt("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=y.useMemo(()=>Pd(n,c=>Mn(c,s?"width":"height")),[n,s]),a=Xn(i,!0,Ae("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),l.jsx("div",{"data-viewport-type":"element",ref:a,style:Ts(o),children:e})},G0=({children:e})=>{const t=y.useContext(pf),n=Zt("windowViewportRect"),r=Zt("fixedItemHeight"),o=Ae("customScrollParent"),s=Fd(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("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:Ts(i),children:e})},Y0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...U0,marginTop:`${n}px`},o=Ae("context");return l.jsx(t,{style:r,...Mt(t,o),children:e})},X0=y.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return l.jsxs(r||t?Q0:Z0,{...e,context:o,children:[n&&l.jsx(Y0,{children:l.jsx(bf,{showTopList:!0})}),l.jsxs(r||t?G0:q0,{children:[l.jsx(V0,{}),l.jsx(bf,{}),l.jsx(K0,{})]})]})}),{Component:J0,useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}=hf(L0,{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"}},X0),Z0=yf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),Q0=Sf({useEmitter:Ca,useEmitterValue:Ae,usePublisher:Zt}),eS=J0;ct(ff,Ge(()=>{const e=se(u=>l.jsxs("td",{children:["Item $",u]})),t=se(null),n=se(u=>l.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=se(null),o=se(null),s=se({}),i=se(Sa),a=se(yr),c=(u,d=null)=>_t(Q(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")}})),ya();const Cf={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},tS={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:kf,floor:Es,max:oo,min:ka,round:Tf}=Math;function Ef(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function nS(e){return{...tS,items:e}}function Is(e,t){return e&&e.width===t.width&&e.height===t.height}function rS(e,t){return e&&e.column===t.column&&e.row===t.row}const oS=Ge(([{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:w,propsReady:x},{customScrollParent:g,useWindowScroll:v,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T},C])=>{const k=se(0),E=se(0),A=se(Cf),O=se({height:0,width:0}),$=se({height:0,width:0}),H=He(),U=He(),K=se(0),P=se(null),Y=se({column:0,row:0}),N=He(),D=He(),M=se(!1),j=se(0),z=se(!0),W=se(!1),R=se(!1);et(Q(w,De(j),Ie(([L,V])=>!!V)),()=>{Re(z,!1)}),et(Q(wt(w,z,$,O,j,W),Ie(([L,V,Z,q,,X])=>L&&!V&&Z.height!==0&&q.height!==0&&!X)),([,,,,L])=>{Re(W,!0),pa(1,()=>{Re(H,L)}),sn(Q(u),()=>{Re(t,[0,0]),Re(z,!0)})}),xe(Q(D,Ie(L=>L!=null&&L.scrollTop>0),gn(0)),E),et(Q(w,De(D),Ie(([,L])=>L!=null)),([,L])=>{L&&(Re(O,L.viewport),Re($,L.item),Re(Y,L.gap),L.scrollTop>0&&(Re(M,!0),sn(Q(u,Yn(1)),V=>{Re(M,!1)}),Re(c,{top:L.scrollTop})))}),xe(Q(O,ue(({height:L})=>L)),f),xe(Q(wt(ke(O,Is),ke($,Is),ke(Y,(L,V)=>L&&L.column===V.column&&L.row===V.row),ke(u)),ue(([L,V,Z,q])=>({gap:Z,item:V,scrollTop:q,viewport:L}))),N),xe(Q(wt(ke(k),r,ke(Y,rS),ke($,Is),ke(O,Is),ke(P),ke(E),ke(M),ke(z),ke(j)),Ie(([,,,,,,,L])=>!L),ue(([L,[V,Z],q,X,pe,he,ee,,le,we])=>{const{column:je,row:Ne}=q,{height:$e,width:Ye}=X,{width:nt}=pe;if(ee===0&&(L===0||nt===0))return Cf;if(Ye===0){const ht=ma(we,L),Tt=ht+Math.max(ee-1,0);return nS(Ef(ht,Tt,he))}const Ve=If(nt,Ye,je);let qe,rt;le?V===0&&Z===0&&ee>0?(qe=0,rt=ee-1):(qe=Ve*Es((V+Ne)/($e+Ne)),rt=Ve*kf((Z+Ne)/($e+Ne))-1,rt=ka(L-1,oo(rt,Ve-1)),qe=ka(rt,oo(0,qe))):(qe=0,rt=-1);const kt=Ef(qe,rt,he),{bottom:at,top:Te}=Nf(pe,q,X,kt),Oe=kf(L/Ve),it=Oe*$e+(Oe-1)*Ne-at;return{bottom:at,itemHeight:$e,items:kt,itemWidth:Ye,offsetBottom:it,offsetTop:Te,top:Te}})),A),xe(Q(P,Ie(L=>L!==null),ue(L=>L.length)),k),xe(Q(wt(O,$,A,Y),Ie(([L,V,{items:Z}])=>Z.length>0&&V.height!==0&&L.height!==0),ue(([L,V,{items:Z},q])=>{const{bottom:X,top:pe}=Nf(L,q,V,Z);return[pe,X]}),ut(Jr)),t);const B=se(!1);xe(Q(u,De(B),ue(([L,V])=>V||L!==0)),B);const te=Kt(Q(wt(A,k),Ie(([{items:L}])=>L.length>0),De(B),Ie(([[L,V],Z])=>{const q=L.items[L.items.length-1].index===V-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===V)&&q}),ue(([[,L]])=>L-1),ut())),J=Kt(Q(ke(A),Ie(({items:L})=>L.length>0&&L[0].index===0),gn(0),ut())),re=Kt(Q(ke(A),De(M),Ie(([{items:L},V])=>L.length>0&&!V),ue(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ut(Kd),kn(0)));xe(re,p.scrollSeekRangeChanged),xe(Q(H,De(O,$,k,Y),ue(([L,V,Z,q,X])=>{const pe=Zd(L),{align:he,behavior:ee,offset:le}=pe;let we=pe.index;we==="LAST"&&(we=q-1),we=oo(0,we,ka(q-1,we));let je=Ta(V,X,Z,we);return he==="end"?je=Tf(je-V.height+Z.height):he==="center"&&(je=Tf(je-V.height/2+Z.height/2)),le&&(je+=le),{behavior:ee,top:je}})),c);const G=_t(Q(A,ue(L=>L.offsetBottom+L.bottom)),0);return xe(Q(T,ue(L=>({height:L.visibleHeight,width:L.visibleWidth}))),O),{customScrollParent:g,data:P,deviation:K,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:c,scrollToIndex:H,scrollTop:u,smoothScrollTargetReached:d,totalCount:k,useWindowScroll:v,viewportDimensions:O,windowScrollContainerState:b,windowScrollTo:S,windowViewportRect:T,...p,gridState:A,horizontalDirection:R,initialTopMostItemIndex:j,totalListHeight:G,...h,endReached:te,propsReady:x,rangeChanged:re,startReached:J,stateChanged:N,stateRestoreInProgress:M,...C}},ct(ga,Dt,ro,uf,Rn,va,_n));function If(e,t,n){return oo(1,Es((e+n)/(Es(t)+n)))}function Nf(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ta(e,t,n,r[0].index);return{bottom:Ta(e,t,n,r[r.length-1].index)+o,top:s}}function Ta(e,t,n,r){const o=If(e.width,n.width,t.column),s=Es(r/o),i=s*n.height+oo(0,s-1)*t.row;return i>0?i+t.row:i}const sS=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Sa),i=se("div"),a=se(yr),c=(f,h=null)=>_t(Q(t,ue(p=>p[f]),ut()),h),u=se(!1),d=se(!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")}}),iS=Ge(([e,t])=>({...e,...t}),ct(oS,sS)),aS=y.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=Qt("scrollHeight"),a=ft("ItemComponent"),c=ft("ListComponent"),u=ft("ScrollSeekPlaceholder"),d=ft("context"),f=Qt("itemDimensions"),h=Qt("gap"),p=ft("log"),w=ft("stateRestoreInProgress"),x=Qt("reportReadyState"),g=Xn(y.useMemo(()=>v=>{const b=v.parentElement.parentElement.scrollHeight;i(b);const S=v.firstChild;if(S){const{height:T,width:C}=S.getBoundingClientRect();f({height:T,width:C})}h({column:jf("column-gap",getComputedStyle(v).columnGap,p),row:jf("row-gap",getComputedStyle(v).rowGap,p)})},[i,f,h,p]),!0,!1);return gf(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),w?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(v=>{const b=o(v.index,v.data,d);return s?l.jsx(u,{...Mt(u,d),height:e.itemHeight,index:v.index,width:e.itemWidth},b):y.createElement(a,{...Mt(a,d),className:n,"data-index":v.index,key:b},r(v.index,v.data,d))})})}),lS=y.memo(function(){const e=ft("HeaderComponent"),t=Qt("headerHeight"),n=ft("headerFooterTag"),r=Xn(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}),cS=y.memo(function(){const e=ft("FooterComponent"),t=Qt("footerHeight"),n=ft("headerFooterTag"),r=Xn(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}),uS=({children:e})=>{const t=y.useContext(mf),n=Qt("itemDimensions"),r=Qt("viewportDimensions"),o=Xn(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:Ts(!1),children:e})},dS=({children:e})=>{const t=y.useContext(mf),n=Qt("windowViewportRect"),r=Qt("itemDimensions"),o=ft("customScrollParent"),s=Fd(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:Ts(!1),children:e})},fS=y.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?pS:hS,o=n||t?dS:uS,s=ft("context");return l.jsx(r,{...e,...Mt(r,s),children:l.jsxs(o,{children:[l.jsx(lS,{}),l.jsx(aS,{}),l.jsx(cS,{})]})})}),{useEmitter:Af,useEmitterValue:ft,usePublisher:Qt}=hf(iS,{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"}},fS),hS=yf({useEmitter:Af,useEmitterValue:ft,usePublisher:Qt}),pS=Sf({useEmitter:Af,useEmitterValue:ft,usePublisher:Qt});function jf(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 mS=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 _f({className:e,variant:t,...n}){return l.jsx("div",{className:oe(mS({variant:t}),e),...n})}async function Mf(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function Rf(e,t){return await(await Mf(`/files/${e}/view`,t)).text()}async function gS(e,t){const n=await Mf(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/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 xS(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}var Ns="Dialog",[Pf,LT]=yn(Ns),[vS,ln]=Pf(Ns),Of=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(vS,{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})};Of.displayName=Ns;var Df="DialogTrigger",Lf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Df,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":Na(o.open),...r,ref:s,onClick:me(e.onClick,o.onOpenToggle)})});Lf.displayName=Df;var Ea="DialogPortal",[wS,$f]=Pf(Ea,{forceMount:void 0}),Ff=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=ln(Ea,t);return l.jsx(wS,{scope:t,forceMount:n,children:m.Children.map(r,i=>l.jsx(Xt,{present:n||s.open,children:l.jsx(Qo,{asChild:!0,container:o,children:i})}))})};Ff.displayName=Ea;var As="DialogOverlay",Bf=m.forwardRef((e,t)=>{const n=$f(As,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(As,e.__scopeDialog);return s.modal?l.jsx(Xt,{present:r||s.open,children:l.jsx(yS,{...o,ref:t})}):null});Bf.displayName=As;var bS=Bn.createSlot("DialogOverlay.RemoveScroll"),yS=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(As,n);return l.jsx(ls,{as:bS,allowPinchZoom:!0,shards:[o.contentRef],children:l.jsx(ye.div,{"data-state":Na(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Qn="DialogContent",zf=m.forwardRef((e,t)=>{const n=$f(Qn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=ln(Qn,e.__scopeDialog);return l.jsx(Xt,{present:r||s.open,children:s.modal?l.jsx(SS,{...o,ref:t}):l.jsx(CS,{...o,ref:t})})});zf.displayName=Qn;var SS=m.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=m.useRef(null),o=ze(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),l.jsx(Hf,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:me(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:me(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:me(e.onFocusOutside,s=>s.preventDefault())})}),CS=m.forwardRef((e,t)=>{const n=ln(Qn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return l.jsx(Hf,{...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()}})}),Hf=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=ln(Qn,n),c=m.useRef(null),u=ze(t,c);return Ci(),l.jsxs(l.Fragment,{children:[l.jsx(zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:l.jsx(Bo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Na(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(kS,{titleId:a.titleId}),l.jsx(ES,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Ia="DialogTitle",Uf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Ia,n);return l.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Uf.displayName=Ia;var Wf="DialogDescription",Vf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Wf,n);return l.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Vf.displayName=Wf;var Kf="DialogClose",qf=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=ln(Kf,n);return l.jsx(ye.button,{type:"button",...r,ref:t,onClick:me(e.onClick,()=>o.onOpenChange(!1))})});qf.displayName=Kf;function Na(e){return e?"open":"closed"}var Gf="DialogTitleWarning",[$T,Yf]=Lx(Gf,{contentName:Qn,titleName:Ia,docsSlug:"dialog"}),kS=({titleId:e})=>{const t=Yf(Gf),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
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},TS="DialogDescriptionWarning",ES=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yf(TS).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},Aa=Of,IS=Lf,ja=Ff,oo=Bf,so=zf,er=Uf,js=Vf,Xf=qf;const Jf=Aa,NS=ja,Zf=m.forwardRef(({className:e,...t},n)=>c.jsx(oo,{ref:n,className:oe("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}));Zf.displayName=oo.displayName;const _a=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===er||(u==null?void 0:u.displayName)===er.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(NS,{children:[c.jsx(Zf,{}),c.jsxs(so,{ref:r,className:oe("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(er,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Xf,{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"})]})]})]})});_a.displayName=so.displayName;const Ma=({className:e,...t})=>c.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ma.displayName="DialogHeader";const Ra=m.forwardRef(({className:e,...t},n)=>c.jsx(er,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Ra.displayName=er.displayName;const AS=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));AS.displayName=js.displayName;const jS=1,_S=1e6;let Pa=0;function MS(){return Pa=(Pa+1)%Number.MAX_SAFE_INTEGER,Pa.toString()}const Oa=new Map,Qf=e=>{if(Oa.has(e))return;const t=setTimeout(()=>{Oa.delete(e),io({type:"REMOVE_TOAST",toastId:e})},_S);Oa.set(e,t)},RS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,jS)};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?Qf(n):e.toasts.forEach(r=>{Qf(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 io(e){Ms=RS(Ms,e),_s.forEach(t=>{t(Ms)})}function PS({...e}){const t=MS(),n=o=>io({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>io({type:"DISMISS_TOAST",toastId:t});return io({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Da(){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:PS,dismiss:n=>io({type:"DISMISS_TOAST",toastId:n})}}function OS({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}=Da(),h=y.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const v=await Rf(n);l(v)}catch(v){console.error("Failed to load file:",v),d(v instanceof Error?v.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await gS(n),f({title:"Download started",description:`Downloading ${r}`})}catch(v){console.error("Failed to download file:",v),f({title:"Download failed",description:String(v),variant:"destructive"})}},w=async()=>{if(n)try{const v=await Rf(n),b=new Blob([v],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(v){console.error("Failed to open file externally:",v),f({title:"Failed to open file",description:String(v),variant:"destructive"})}},x=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Qe,{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(Jf,{open:e,onOpenChange:t,children:c.jsxs(_a,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Ma,{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(Ra,{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(Qe,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Qe,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function eh(){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 tr=eh();function DS(e){tr=e}const th=/[&<>"']/,LS=new RegExp(th.source,"g"),nh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$S=new RegExp(nh.source,"g"),FS={"&":"&","<":"<",">":">",'"':""","'":"'"},rh=e=>FS[e];function Rt(e,t){if(t){if(th.test(e))return e.replace(LS,rh)}else if(nh.test(e))return e.replace($S,rh);return e}const BS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function oh(e){return e.replace(BS,(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 zS=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(zS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const HS=/[^\w:]/g,US=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function sh(e,t,n){if(e){let r;try{r=decodeURIComponent(oh(n)).replace(HS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!US.test(n)&&(n=qS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Rs={},WS=/^[^:]+:\/*[^/]*$/,VS=/^([^:]+:)[\s\S]*$/,KS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function qS(e,t){Rs[" "+e]||(WS.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(VS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(KS,"$1")+t:e+t}const Ps={exec:function(){}};function ih(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 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 GS(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 YS(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 ah(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function lh(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 XS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
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},TS="DialogDescriptionWarning",ES=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Yf(TS).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},Aa=Of,IS=Lf,ja=Ff,so=Bf,io=zf,er=Uf,js=Vf,Xf=qf;const Jf=Aa,NS=ja,Zf=m.forwardRef(({className:e,...t},n)=>l.jsx(so,{ref:n,className:oe("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}));Zf.displayName=so.displayName;const _a=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===er||(u==null?void 0:u.displayName)===er.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(NS,{children:[l.jsx(Zf,{}),l.jsxs(io,{ref:r,className:oe("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(er,{className:"sr-only",children:"Dialog"}),t,l.jsxs(Xf,{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"})]})]})]})});_a.displayName=io.displayName;const Ma=({className:e,...t})=>l.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ma.displayName="DialogHeader";const Ra=m.forwardRef(({className:e,...t},n)=>l.jsx(er,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Ra.displayName=er.displayName;const AS=m.forwardRef(({className:e,...t},n)=>l.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));AS.displayName=js.displayName;const jS=1,_S=1e6;let Pa=0;function MS(){return Pa=(Pa+1)%Number.MAX_SAFE_INTEGER,Pa.toString()}const Oa=new Map,Qf=e=>{if(Oa.has(e))return;const t=setTimeout(()=>{Oa.delete(e),ao({type:"REMOVE_TOAST",toastId:e})},_S);Oa.set(e,t)},RS=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,jS)};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?Qf(n):e.toasts.forEach(r=>{Qf(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 ao(e){Ms=RS(Ms,e),_s.forEach(t=>{t(Ms)})}function PS({...e}){const t=MS(),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 Da(){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:PS,dismiss:n=>ao({type:"DISMISS_TOAST",toastId:n})}}function OS({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}=Da(),h=y.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const v=await Rf(n);c(v)}catch(v){console.error("Failed to load file:",v),d(v instanceof Error?v.message:"Failed to load file")}finally{i(!1)}}},[n]);y.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await gS(n),f({title:"Download started",description:`Downloading ${r}`})}catch(v){console.error("Failed to download file:",v),f({title:"Download failed",description:String(v),variant:"destructive"})}},w=async()=>{if(n)try{const v=await Rf(n),b=new Blob([v],{type:o}),S=URL.createObjectURL(b);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(v){console.error("Failed to open file externally:",v),f({title:"Failed to open file",description:String(v),variant:"destructive"})}},x=()=>s?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(Qe,{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(Jf,{open:e,onOpenChange:t,children:l.jsxs(_a,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[l.jsx(Ma,{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(Ra,{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(Qe,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[l.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),l.jsxs(Qe,{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:x()})]})})}function eh(){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 tr=eh();function DS(e){tr=e}const th=/[&<>"']/,LS=new RegExp(th.source,"g"),nh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,$S=new RegExp(nh.source,"g"),FS={"&":"&","<":"<",">":">",'"':""","'":"'"},rh=e=>FS[e];function Rt(e,t){if(t){if(th.test(e))return e.replace(LS,rh)}else if(nh.test(e))return e.replace($S,rh);return e}const BS=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function oh(e){return e.replace(BS,(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 zS=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(zS,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const HS=/[^\w:]/g,US=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function sh(e,t,n){if(e){let r;try{r=decodeURIComponent(oh(n)).replace(HS,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!US.test(n)&&(n=qS(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Rs={},WS=/^[^:]+:\/*[^/]*$/,VS=/^([^:]+:)[\s\S]*$/,KS=/^([^:]+:\/*[^/]*)[\s\S]*$/;function qS(e,t){Rs[" "+e]||(WS.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(VS,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(KS,"$1")+t:e+t}const Ps={exec:function(){}};function ih(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 GS(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 YS(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 ah(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function lh(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 XS(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).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(`
|
|
85
85
|
`)}class La{constructor(t){this.options=t||tr}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:Os(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=XS(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=Os(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,
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=XS(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=Os(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,u,d,f,h,p,w,x=n[1].trim();const g=x.length>1,v={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const b=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,T=>" ".repeat(3*T.length)),f=t.split(`
|
|
88
|
-
`,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),
|
|
88
|
+
`,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),c=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
89
89
|
`,t=t.substring(f.length+1),w=!0),!w){const T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
|
|
90
90
|
`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(k.test(f)||E.test(f)||T.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
91
|
-
`+f.slice(i);else{if(
|
|
92
|
-
`+f}!
|
|
91
|
+
`+f.slice(i);else{if(c||d.search(/[^ ]/)>=4||k.test(d)||E.test(d)||C.test(d))break;p+=`
|
|
92
|
+
`+f}!c&&!f.trim()&&(c=!0),r+=h+`
|
|
93
93
|
`,t=t.substring(h.length+1),d=f.slice(i)}}v.loose||(u?v.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),v.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),v.raw+=r}v.items[v.items.length-1].raw=r.trimRight(),v.items[v.items.length-1].text=p.trimRight(),v.raw=v.raw.trimRight();const S=v.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,v.items[a].tokens=this.lexer.blockTokens(v.items[a].text,[]),!v.loose){const T=v.items[a].tokens.filter(k=>k.type==="space"),C=T.length>0&&T.some(k=>/\n.*\n/.test(k.raw));v.loose=C}if(v.loose)for(a=0;a<S;a++)v.items[a].loose=!0;return v}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):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:ih(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,
|
|
95
|
-
`?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=Os(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=GS(n[2],"()");if(i>-1){const
|
|
94
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,c;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=ih(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
+
`?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=Os(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=GS(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),lh(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 lh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,c,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=a.length,o[3]||o[4]){u+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=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:Ps,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=st(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=st(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=st(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=st(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=st(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=st(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=st(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=st(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:st(`^ *(?: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:Ps,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
|
|
96
96
|
]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const fe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ps,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:Ps,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};fe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",fe.punctuation=st(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=st(be._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=st(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=st(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=st(fe.emStrong.rDelimUnd,"g").replace(/punct/g,fe._punctuation).getRegex(),fe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,fe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,fe._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])?)+(?![-_])/,fe.autolink=st(fe.autolink).replace("scheme",fe._scheme).replace("email",fe._email).getRegex(),fe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,fe.tag=st(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=st(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=st(fe.reflink).replace("label",fe._label).replace("ref",be._label).getRegex(),fe.nolink=st(fe.nolink).replace("ref",be._label).getRegex(),fe.reflinkSearch=st(fe.reflinkSearch,"g").replace("reflink",fe.reflink).replace("nolink",fe.nolink).getRegex(),fe.normal={...fe},fe.pedantic={...fe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:st(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:st(fe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},fe.gfm.url=st(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:st(fe.br).replace("{2,}","*").getRegex(),text:st(fe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function JS(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 ch(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||tr,this.options.tokenizer=this.options.tokenizer||new La,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:fe.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:fe}}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,`
|
|
97
|
-
`),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,
|
|
97
|
+
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c,u)=>c+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`: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+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
100
100
|
`+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+=`
|
|
101
101
|
`+r.raw,o.text+=`
|
|
102
|
-
`+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
|
|
102
|
+
`+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 c=t.slice(1);let u;this.options.extensions.startBlock.forEach(function(d){u=d.call({lexer:this},c),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+=`
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+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+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+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,
|
|
106
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+ah("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)+"["+ah("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(c||(u=""),c=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ch)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ch))){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,JS)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),c=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class $a{constructor(t){this.options=t||tr}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$/,"")+`
|
|
107
107
|
`,o?'<pre><code class="'+this.options.langPrefix+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Rt(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -123,7 +123,7 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}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=sh(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=sh(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 uh{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 dh{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||tr,this.options.renderer=this.options.renderer||new $a,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uh,this.slugger=new dh}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,
|
|
127
|
-
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const
|
|
128
|
-
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 fh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=ZS(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(YS(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 fh(Pn.lex,On.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},DS(ve.defaults),ve},ve.getDefaults=eh,ve.defaults=tr,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 $a;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 La;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 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 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=fh(Pn.lexInline,On.parseInline),ve.Parser=On,ve.parser=On.parse,ve.Renderer=$a,ve.TextRenderer=uh,ve.Lexer=Pn,ve.lexer=Pn.lex,ve.Tokenizer=La,ve.Slugger=dh,ve.Hooks=Ds,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,On.parse,Pn.lex;function ao({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:oe("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 QS={MODE:"library"};function eC(){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"?QS: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 tC(){return!eC()}function nC(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function rC(){return tC()||nC()}function oC({preview:e,idx:t}){return y.useEffect(()=>{rC()&&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 sC({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 iC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return c.jsx(sC,{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=>ux(o)).filter(o=>o!==null):[],[e]);return n.length>0?c.jsx("div",{className:"space-y-2",children:n.map((r,o)=>c.jsx(oC,{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 lo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const hh=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));hh.displayName="CardDescription";const fo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));fo.displayName="CardContent";const ph=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));ph.displayName="CardFooter";function aC({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=ur(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(lo,{className:oe("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(co,{className:"pb-3",children:[c.jsx(uo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(hh,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(fo,{className:"pt-0 pb-3",children:a}),c.jsx(ph,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Qe,{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(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const lC="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 mh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:lC,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:ur(e)}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ur(e)})}function cC({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 uC({message:e,viewMode:t,isStreaming:n=!1}){const o=gi(e).name||"tool",s=l=>{if(l==null)return null;const u=typeof l=="string"?mi(l)??l:l;if(u&&typeof u=="object")return c.jsx(mh,{data:u});const d=typeof u=="string"?u:(()=>{try{return ur(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}=rx(l);return d?c.jsx(ao,{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=Lr(h);return i(p)}const u=Dr(l),d=Lr(u);return i(d)};return c.jsxs("div",{className:"space-y-2",children:[c.jsx(cC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function dC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Da(),[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,w,x)=>{var g,v;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const b=String(w.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const T=S[1],C=w.name||`file_${T}`,k=w.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(b.startsWith("data:")){p.preventDefault(),s(C=>({...C,[x]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await xS(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const k=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(w.name??""))?!1:typeof w.size=="number"&&typeof E.size=="number"?E.size===w.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${w.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:w.name||k.filename||`file_${k.id}`,mimeType:w.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${w.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(v=T.update)==null||v.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[x]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function fC({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:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(ao,{content:e,allowHtml:!1}):c.jsxs("pre",{className:oe("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(Qe,{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 hC({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:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function gh(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:l="desktop",truncateUserMessages:u=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,showArtifactPreviews:h=!0,customStyles:p={},onEdit:w,onRegenerate:x,onCancelEdit:g,onCopy:v,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:A,defaultCheckpointId:O=null,messageParentCheckpointId:$=null}){const[H,U]=y.useState(!1),[K,P]=y.useState("preview"),[Y,N]=y.useState(!1),{currentThreadId:D}=Do(),{respondToInterrupt:M}=Lo(),j=l==="phone"||l==="half-screen",z=t.role,W=z==="tool",R=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),B=!!R,te=!(r&&z!=="user"),{uploadingFiles:J,handleFileClick:re,fileViewerOpen:G,currentFileInfo:L,closeFileViewer:V}=dC({allowFileOpen:te,currentThreadId:D}),Z=y.useMemo(()=>{switch(z){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[z]),q=y.useMemo(()=>{if(R)return"";const _=t.content;return Array.isArray(_)?ox(_):""},[R,t]),X=y.useMemo(()=>{if(R)return{};const _=t.content;return Array.isArray(_)?gi(t):{}},[R,t]),pe=y.useMemo(()=>W?!!(t.additionalKwargs??{}).toolStreaming:!1,[W,t]),he=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="image_url"):[]},[R,t]),ee=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="file"):[]},[R,t]),le=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="interrupt"):[]},[R,t]),we=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),je=Oo(we),Ne=b==null?void 0:b.value,$e=y.useMemo(()=>{if(R)return"";const _=t.content;return Array.isArray(_)?sx(_):""},[R,t]),Ye=y.useMemo(()=>R||!h?null:t.artifact||null,[R,t,h]),nt=y.useCallback(async()=>{const _=W?$e:q;async function ie(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const We=new Blob([ge],{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 ie(_),U(!0),setTimeout(()=>U(!1),2e3),v==null||v(_)}catch(ge){console.error("Failed to copy:",ge)}},[W,$e,q,v]),Ve=y.useCallback(()=>{if(!w)return;const _=W?$e:q,ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};w(t.id,_,ie)},[w,t.id,W,$e,q,t]),qe=y.useCallback(()=>{x==null||x(n)},[x,n]),rt=y.useCallback(()=>{const ie=oe(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(z){case"user":return c.jsx(ae.User,{className:ie});case"assistant":return c.jsx(ae.Bot,{className:ie});case"tool":return c.jsx(ae.Wrench,{className:ie});default:return c.jsx(ae.Bot,{className:ie})}},[j,Z,z]),kt=y.useCallback(()=>{const _="group relative mb-4 flex w-full";switch(z){case"user":return oe(_,"justify-end");case"assistant":case"tool":case"system":return oe(_,"justify-start");default:return _}},[z]),at=y.useCallback(()=>{const _=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(B)return oe(_,"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(z){case"user":return oe(_,"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 oe(_,"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 oe(_,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(_,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(_,"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")}},[j,B,z]),Te=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),Oe=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),it=y.useCallback(({part:_,i:ie})=>{if(_.type==="text"){const ge=_.text??"",We=ge.trim(),Pe=mi(We);return Pe&&z!=="tool"?c.jsx(mh,{data:Pe},ie):z==="user"&&u&&We.length>d?c.jsx(fC,{text:We,expanded:Y,onExpandedChange:N,previewLength:d,isCompact:j},ie):c.jsx(ao,{content:ge,allowHtml:!1},ie)}if(_.type==="image_url"){const ge=_;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:ge.url,alt:ge.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ie)}if(_.type==="file"){const ge=_,We=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:Pe=>re(Pe.nativeEvent,ge,ie),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ie]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[We,J[ie]?" (processing)":""]})]},ie)}if(_.type==="interrupt"){const ge=_,We=Oo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id)),Pe=!!(je&&We&&We===je),mt=Pe?Ne??(ge==null?void 0:ge.value):ge==null?void 0:ge.value,Je=We?{...ge,id:We,interrupt_id:We}:ge;return c.jsx(aC,{interruptPart:Je,onApprove:Te,onReject:Oe,disabled:S,isActive:Pe,payload:mt},ie)}return null},[re,J,Te,Oe,z,u,d,Y,j,je,Ne,b,S,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 _=q.trim().length>0||he.length>0||ee.length>0||le.length>0;if(!W&&ee.length>0&&!r)return ht();if(!W&&!_&&!r)return null;if(W)return!f&&Ye?null:f?c.jsx(uC,{message:t,viewMode:K,isStreaming:pe},t.id):null;if(!W&&!R){const ie=t,ge=c.jsx("div",{className:"space-y-2",children:ie.content.map((We,Pe)=>c.jsx(it,{part:We,i:Pe},Pe))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[ge,c.jsx(hC,{className:Z})]}):ge}},[q,he.length,ee.length,le.length,r,W,K,f,Ye,ht,Z]),yt=y.useMemo(()=>R?"Assistant":ix(t),[R,t]),Le=y.useMemo(()=>R?[]:Array.isArray(k)?k:[],[k,R]),Ht=y.useMemo(()=>{var _;return Le.length?O&&Le.some(ie=>ie.id===O)?O:((_=Le[0])==null?void 0:_.id)??null:null},[O,Le]),Ke=y.useMemo(()=>!Le.length||!E?null:Le.some(_=>_.id===E)?E:null,[E,Le])??Ht,dt=z==="user"&&Le.length>0&&typeof A=="function",vt=y.useCallback((_,ie=!1)=>{if(!A)return;const ge=(_==null?void 0:_.id)??null,We=(_==null?void 0:_.parentId)??$??null;A(ge,We,ie)},[$,A]),Ue=y.useMemo(()=>Ke?Le.findIndex(_=>_.id===Ke):-1,[Ke,Le]),St=y.useMemo(()=>Ue<0?null:Le[Ue]??null,[Ue,Le]);return W&&!f&&!Ye?null:B&&R?c.jsx("div",{className:oe(kt(),p.container),children:c.jsxs("div",{className:oe(at(),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:oe("h-4 w-4",Z)}),a&&c.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),c.jsx(ao,{content:R.content,className:"text-current"})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:oe(kt(),p.container),children:c.jsxs("div",{className:oe(at(),p.content),children:[(i||a||W)&&c.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Z,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&yt&&c.jsx("span",{className:oe("font-medium",j?"text-xs":"text-sm"),children:yt}),W&&c.jsxs(_f,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",Z,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":K==="expanded",onClick:()=>P(_=>_==="expanded"?"preview":"expanded"),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),P(ie=>ie==="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&&St&&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:oe("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 _=Le[Ue+1];_&&vt(_)},"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:oe("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)vt(null,!0);else{const _=Le[Ue-1];_&&vt(_,!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:oe("text-xs opacity-60",Z,j&&"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:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx("div",{className:"relative",children:c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:c.jsx(ae.Copy,{className:oe(H?"text-success":Z,j?"h-3 w-3":"h-4 w-4")})})}),z==="user"&&w&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsxs("div",{className:"relative",children:[Tt(),h&&Ye&&c.jsx("div",{className:"mt-3",children:c.jsx(iC,{artifact:Ye,idx:0})})]}),W&&K==="expanded"&&(X.toolCallId||X.name)&&c.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"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:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:oe(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="user"&&w&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&c.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&c.jsx(OS,{isOpen:G,onClose:V,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,u,d,f,h,p,w,x;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&lc(e.message)===lc(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)&&((w=e.customStyles)==null?void 0:w.header)===((x=t.customStyles)==null?void 0:x.header);if(!o||!s)return!1;const i=gh(e.message),a=gh(t.message);return i.length===a.length});Ls.displayName="MessageComponent";function pC(e,t){return y.useMemo(()=>{var d,f,h,p,w;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 x=e,g=x.checkpointId??null;s=x.additionalKwargs??{},i=x.responseMetadata??{};const v=g&&t.checkpointMetaById?t.checkpointMetaById.get(g)??null:null;a=typeof s.step=="number"?s.step:typeof i.step=="number"?i.step:(v==null?void 0:v.step)??null;const b=typeof s.source=="string"?s.source:typeof i.source=="string"?i.source:(v==null?void 0:v.source)??null;l=b?String(b):null;const S=a!==null&&l?`${a}:${l}`:null;if(S&&((d=t.checkpointIndexByKey)!=null&&d.has(S))?r=t.checkpointIndexByKey.get(S)??[]:g&&v&&(r=[v]),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 C=T[0].checkpointId;u=((p=t.attemptMetaById)==null?void 0:p.get(C))??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 C=[];for(const[k,E]of t.attemptMetaById.entries())if(E.baseUserMessageId===T){const A=(w=t.checkpointMetaById)==null?void 0:w.get(k);A&&C.push(A)}C.length>0&&(r=C)}}if(u&&u.attemptCount>1&&t.checkpointMetaById&&t.attemptMetaById){const T=[];for(const[C,k]of t.checkpointMetaById.entries()){const E=t.attemptMetaById.get(C);E&&E.attemptCount===u.attemptCount&&E.baseUserMessageId===u.baseUserMessageId&&T.push(k)}T.sort((C,k)=>{const E=C.createdAt?Date.parse(C.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(C=>C.id)}))}}return{checkpointCandidates:r,defaultCheckpointId:o,attemptMeta:u,resolvedStep:a,resolvedSource:l}},[e,t.checkpointMetaById,t.checkpointIndexByKey,t.attemptMetaById,t.userMessageIdToAttempts])}const xh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,vh=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:w,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:v,checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C,activeCheckpointId:k,onSelectCheckpoint:E}){const A=xh(t,n),O="type"in t&&t.type==="default_message",H=!!t.__syntheticStreaming,{checkpointCandidates:U,defaultCheckpointId:K,attemptMeta:P}=pC(t,{checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C}),Y=t&&!O?t.additionalKwargs??{}:{},N=t&&!O?t.responseMetadata??{}:{},D=(()=>{if(typeof Y.parentCheckpointId=="string")return Y.parentCheckpointId;if(typeof N.parentCheckpointId=="string")return N.parentCheckpointId})();return c.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":A,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(Ls,{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:w,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:v,checkpointCandidates:U,activeCheckpointId:k??null,onSelectCheckpoint:E,defaultCheckpointId:K,messageParentCheckpointId:D,attemptMeta:P})})});vh.displayName="MessageRow";const Fa=y.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:w=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:v,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K,createSyntheticThinkingMessage:P=!0},Y)=>{const N=y.useRef(null),D=y.useRef(null),M=y.useRef(!1),j=y.useRef(!1),[z,W]=y.useState(!0),R=y.useMemo(()=>b?e.some(ee=>"type"in ee&&ee.type==="default_message"?!1:Array.isArray(ee==null?void 0:ee.content)&&ee.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),B=y.useMemo(()=>{if(!b||R)return null;const ee=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 je=we.title;typeof je=="string"&&je.trim()&&(le=je.trim())}return{id:`interrupt-${ee}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ee,value:we,title:le}]}},[b,R]),te=y.useMemo(()=>B?[...e,B]:e,[e,B]),J=y.useMemo(()=>!P||!t?te:!te.some(le=>le.role==="assistant")&&te.length>0?[...te,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:te,[te,t,P]),re=y.useMemo(()=>k?J:J.filter(ee=>(ee==null?void 0:ee.role)!=="tool"),[J,k]),G=y.useCallback(ee=>{W(ee),g&&g(!ee),v&&v(ee)},[g,v]),L=y.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),V=y.useMemo(()=>!w||x?!1:z?"auto":!1,[z,w,x]),Z=y.useMemo(()=>{if(typeof p!="string")return null;const ee=p.trim();return ee?{id:"default-message",role:"assistant",type:"default_message",content:ee,createdAt:new Date().toISOString()}:null},[p]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>Z?c.jsx("div",{className:"p-6 h-full overflow-y-auto",children:c.jsx("div",{className:"w-full max-w-full",children:c.jsx(Ls,{message:Z,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!"}),pe=re.length,he=pe>0;return y.useEffect(()=>{var ee,le;if(pe===0){j.current=!1;return}if(!j.current)if(j.current=!0,N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},[pe,re.length]),y.useImperativeHandle(Y,()=>({scrollToLatest:()=>{var ee,le;if(N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},scrollToTop:()=>{var ee,le;N.current&&re.length>0?(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:0,align:"start",behavior:"auto"}):D.current&&(D.current.scrollTop=0)}}),[re]),c.jsx("div",{className:q,style:h,children:c.jsx("div",{className:"relative flex-1 min-h-0",children:he?c.jsx(eS,{ref:ee=>{N.current=ee},scrollerRef:ee=>{D.current=ee instanceof HTMLDivElement?ee:null},data:re,followOutput:V,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ee,le)=>xh(le,ee),itemContent:(ee,le)=>c.jsx(vh,{message:le,index:ee,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:u,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k,showArtifactPreviews:E,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K})}):X()})})});Fa.displayName="MessageList";const wh={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:l=!1,enableMessageEditing:u=!0,showToolMessages:d=!0,showArtifactPreviews:f=!0,customStyles:h={},onMessageSent:p,onExcelUploadSuccess:w,onError:x}){const{api:g}=pi(),{currentThreadId:v}=Do(),{threadId:b,messages:S,isHistoryLoading:T,isLoading:C,navigateToCheckpoint:k,returnToLatest:E,checkpoint:A,checkpoints:O,interrupt:$,metadata:H,timelineCheckpoints:U,messagePreviews:K}=Lo(),{isStreaming:P,error:Y,connectionState:N,submit:D,stop:M}=yc(),j=b??v??null,z=(A==null?void 0:A.id)??null,W=(A==null?void 0:A.namespace)??null,R=(H==null?void 0:H.assemblingMessageId)??null,B=$,[te,J]=y.useState(!1);y.useEffect(()=>{B||J(!1)},[B]);const re=y.useCallback(()=>{J(!0)},[]),G=y.useCallback(()=>{J(!1)},[]),L=!!B||te,[V,Z]=y.useState(null),[q,X]=y.useState(""),[pe,he]=y.useState(null),[ee,le]=y.useState(null),[we,je]=y.useState([]),[Ne,$e]=y.useState(0),[Ye,nt]=y.useState(0),[Ve,qe]=y.useState(!1),[rt,kt]=y.useState(null),[at,Te]=y.useState(null),[Oe,it]=y.useState(!1),[ht,Tt]=y.useState(null),yt=y.useRef(!1),[Le,Ht]=y.useState(()=>wh.value),Xe=y.useRef(Le),Ke=y.useRef(null),dt=y.useCallback(de=>{wh.value=de,Ht(de)},[]),[vt,Ue]=y.useState(!1),St=y.useRef(null),{checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We}=Wy(O),Pe=U??[],mt=y.useRef(null),Je=y.useRef(null),Nt=y.useCallback(()=>{mt.current&&(mt.current.value=""),Je.current&&(Je.current.value=""),$e(de=>de+1),nt(de=>de+1)},[]),go=y.useCallback(de=>{dt(de)},[dt]),xo=y.useRef(!1);y.useEffect(()=>{xo.current&&!P&&(je([]),Nt()),xo.current=P},[P,Nt]);const[Xs,il]=y.useState("desktop");y.useEffect(()=>{const de=()=>{const Se=window.innerWidth;il(Se<640?"phone":Se<1024?"tablet":"desktop")};return de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[]),y.useEffect(()=>{yt.current=!1},[j]),y.useEffect(()=>{Xe.current=Le},[Le]),y.useEffect(()=>{if(!V){Ke.current=null;return}Ke.current===null&&(Ke.current=Xe.current),dt(q??"")},[q,V,dt]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){Tt(null);return}try{const Me=(await g.getAgent("default")).uiDefaultMessage||"";Tt(Me||null)}catch(Se){console.warn("Failed to fetch default message:",Se),Tt(null)}})()},[g.baseUrl]),y.useEffect(()=>{Y&&!Oe&&(x==null||x(Y))},[Y,Oe,x]);const al=async de=>{const Se=de.trim();if(!(!Se&&we.length===0))try{const Me=V?(pe==null?void 0:pe.checkpointId)??z??void 0:z??void 0,lt=V?(pe==null?void 0:pe.checkpointNs)??W??void 0:W??void 0;await D({text:Se||"",attachments:we},{checkpointId:Me,checkpointNs:lt,edit:!!V,originalMessageId:V??void 0}),p==null||p(Se),dt(""),le(null),je([]),Nt(),Z(null),X(""),he(null)}catch(Me){const lt=(Me==null?void 0:Me.message)||"Failed to send message";le(lt),x==null||x(lt)}},Js=y.useCallback((de,Se,Me)=>{u&&(Ke.current=Le,Z(de),X(Se),dt(Se),le(null),he({checkpointId:(Me==null?void 0:Me.checkpointId)??null,checkpointNs:(Me==null?void 0:Me.checkpointNs)??null}))},[Le,u,dt]),vo=y.useCallback(()=>{Z(null),X(""),he(null),le(null),dt(Ke.current??Le),Ke.current=null},[Le,dt]),I=y.useCallback((de,Se,Me)=>{Js(de,Se,Me)},[Js]),ne=y.useCallback(de=>{let Se=null;for(let Ut=de-1;Ut>=0;Ut--)if(S[Ut].role==="user"){Se=S[Ut];break}if(!Se)return;const Me=Array.isArray(Se.content)?Se.content:[],Ct=Me.filter(Ut=>(Ut==null?void 0:Ut.type)==="text").map(Ut=>Ut.text).join("")||(()=>{try{return JSON.stringify(Me,null,2)}catch{return String(Me)}})();Ct&&D({text:Ct},{checkpointId:z??void 0,checkpointNs:W??void 0,edit:!0,originalMessageId:Se.id})},[S,D,z,W]),ce=de=>{const Se=Array.from(de.target.files||[]);je(Me=>[...Me,...Se]),de.target.value=""},Ee=de=>{je(Se=>{const Me=Se.filter((lt,Ct)=>de!==Ct);return Me.length===0&&Nt(),Me})},Ze=async de=>{const Se=(de.target.files||[])[0];if(Se){kt(null),Te(null),qe(!0);try{await D({attachments:[Se]},{checkpointId:z??void 0,checkpointNs:W??void 0});const Me=`Uploaded ${Se.name} - processing through chat stream`;Te(Me)}catch(Me){const lt=Me instanceof Error?Me.message:"Failed to upload Excel file";console.error("Excel upload failed",Me),kt(lt),x==null||x(lt)}finally{qe(!1),de.target.value="",Nt()}}},tt=async de=>{if(v){Ue(!0);try{if(!de){await E(),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToLatest()});return}const Se=O.find(lt=>lt.checkpointId===de),Me=(Se==null?void 0:Se.checkpointNs)??null;await k(de,Me),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToTop()})}finally{Ue(!1)}}},Be=y.useCallback(async(de,Se,Me)=>{await tt(Me?null:de)},[tt]),Fe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,At=`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||""}`,pt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return c.jsxs("div",{className:Fe,children:[!!Y&&!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:Y}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>it(!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 ${At}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Fa,{ref:St,className:"h-full",style:{height:"100%"},messages:S,isStreaming:P,streamingAssistantId:R,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xs,enableMessageEditing:u,editingMessageId:V,onEdit:I,onRegenerate:ne,onCancelEdit:vo,emptyMessage:ht??void 0,isNavigatingCheckpoint:vt,activeInterrupt:B,disableInterruptActions:te,onInterruptActionStart:re,onInterruptActionEnd:G,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We,activeCheckpointId:z,onSelectCheckpoint:Be,timelineCheckpoints:Pe,messagePreviews:K,createSyntheticThinkingMessage:!0}),(N==="reconnecting"||N==="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"}),N==="reconnecting"?"Reconnecting…":"Connecting…"]})}),N==="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"}),C&&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||vt)&&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:pt,children:[V&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:vo,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:de=>ce(de),className:"hidden"},Ne),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((de,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:de.name}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Ee(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 ${de.name}`,children:c.jsx(ae.X,{size:12})})]},Se))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Je,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ze,className:"hidden"},Ye),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..."]}),at&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:at}),rt&&!Ve&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:rt})]})]}),ee&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ee}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{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(Gn,{onClick:()=>{var de;return(de=mt.current)==null?void 0:de.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(Gn,{onClick:()=>{var de;Ve||(de=Je.current)==null||de.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(Dx,{initialValue:q,editingMessageId:V,value:Le,onValueChange:go,placeholder:V?"Edit your message...":t,isStreaming:P,disabled:L,onSend:al,onCancelEdit:vo,onStop:M,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ee?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var bh=1,mC=.9,gC=.8,xC=.17,Ba=.1,za=.999,vC=.9999,wC=.99,bC=/[\\\/_+.#"@\[\(\{&]/,yC=/[\\\/_+.#"@\[\(\{&]/g,SC=/[\s-]/,yh=/[\s-]/g;function Ha(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?bh:wC;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,w;u>=0;)f=Ha(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=bh:bC.test(e.charAt(u-1))?(f*=gC,p=e.slice(o,u-1).match(yC),p&&o>0&&(f*=Math.pow(za,p.length))):SC.test(e.charAt(u-1))?(f*=mC,w=e.slice(o,u-1).match(yh),w&&o>0&&(f*=Math.pow(za,w.length))):(f*=xC,o>0&&(f*=Math.pow(za,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=vC)),(f<Ba&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Ha(e,t,n,r,u+1,s+2,i),h*Ba>f&&(f=h*Ba)),f>d&&(d=f),u=n.indexOf(l,u+1);return i[a]=d,d}function Sh(e){return e.toLowerCase().replace(yh," ")}function CC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Ha(e,t,Sh(e),Sh(t),0,0,{})}var ho='[cmdk-group=""]',Ua='[cmdk-group-items=""]',kC='[cmdk-group-heading=""]',Ch='[cmdk-item=""]',kh=`${Ch}:not([aria-disabled="true"])`,Wa="cmdk-item-select",Cr="data-value",TC=(e,t,n)=>CC(e,t,n),Th=m.createContext(void 0),po=()=>m.useContext(Th),Eh=m.createContext(void 0),Va=()=>m.useContext(Eh),Ih=m.createContext(void 0),Nh=m.forwardRef((e,t)=>{let n=kr(()=>{var R,B;return{search:"",value:(B=(R=e.value)!=null?R:e.defaultValue)!=null?B:"",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=Ah(e),{label:l,children:u,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:w,disablePointerSelection:x=!1,vimBindings:g=!0,...v}=e,b=Pt(),S=Pt(),T=Pt(),C=m.useRef(null),k=DC();nr(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),nr(()=>{k(6,K)},[]);let E=m.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,B,te)=>{var J,re,G,L;if(!Object.is(n.current[R],B)){if(n.current[R]=B,R==="search")U(),$(),k(1,H);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(T);V?V.focus():(J=document.getElementById(b))==null||J.focus()}if(k(7,()=>{var V;n.current.selectedItemId=(V=P())==null?void 0:V.id,E.emit()}),te||k(5,K),((re=a.current)==null?void 0:re.value)!==void 0){let V=B??"";(L=(G=a.current).onValueChange)==null||L.call(G,V);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),A=m.useMemo(()=>({value:(R,B,te)=>{var J;B!==((J=s.current.get(R))==null?void 0:J.value)&&(s.current.set(R,{value:B,keywords:te}),n.current.filtered.items.set(R,O(B,te)),k(2,()=>{$(),E.emit()}))},item:(R,B)=>(r.current.add(R),B&&(o.current.has(B)?o.current.get(B).add(R):o.current.set(B,new Set([R]))),k(3,()=>{U(),$(),n.current.value||H(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let te=P();k(4,()=>{U(),(te==null?void 0:te.getAttribute("id"))===R&&H(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:T,labelId:S,listInnerRef:C}),[]);function O(R,B){var te,J;let re=(J=(te=a.current)==null?void 0:te.filter)!=null?J:TC;return R?re(R,n.current.search,B):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(J=>{let re=o.current.get(J),G=0;re.forEach(L=>{let V=R.get(L);G=Math.max(V,G)}),B.push([J,G])});let te=C.current;Y().sort((J,re)=>{var G,L;let V=J.getAttribute("id"),Z=re.getAttribute("id");return((G=R.get(Z))!=null?G:0)-((L=R.get(V))!=null?L:0)}).forEach(J=>{let re=J.closest(Ua);re?re.appendChild(J.parentElement===re?J:J.closest(`${Ua} > *`)):te.appendChild(J.parentElement===te?J:J.closest(`${Ua} > *`))}),B.sort((J,re)=>re[1]-J[1]).forEach(J=>{var re;let G=(re=C.current)==null?void 0:re.querySelector(`${ho}[${Cr}="${encodeURIComponent(J[0])}"]`);G==null||G.parentElement.appendChild(G)})}function H(){let R=Y().find(te=>te.getAttribute("aria-disabled")!=="true"),B=R==null?void 0:R.getAttribute(Cr);E.setState("value",B||void 0)}function U(){var R,B,te,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let re=0;for(let G of r.current){let L=(B=(R=s.current.get(G))==null?void 0:R.value)!=null?B:"",V=(J=(te=s.current.get(G))==null?void 0:te.keywords)!=null?J:[],Z=O(L,V);n.current.filtered.items.set(G,Z),Z>0&&re++}for(let[G,L]of o.current)for(let V of L)if(n.current.filtered.items.get(V)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=re}function K(){var R,B,te;let J=P();J&&(((R=J.parentElement)==null?void 0:R.firstChild)===J&&((te=(B=J.closest(ho))==null?void 0:B.querySelector(kC))==null||te.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function P(){var R;return(R=C.current)==null?void 0:R.querySelector(`${Ch}[aria-selected="true"]`)}function Y(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(kh))||[])}function N(R){let B=Y()[R];B&&E.setState("value",B.getAttribute(Cr))}function D(R){var B;let te=P(),J=Y(),re=J.findIndex(L=>L===te),G=J[re+R];(B=a.current)!=null&&B.loop&&(G=re+R<0?J[J.length-1]:re+R===J.length?J[0]:J[re+R]),G&&E.setState("value",G.getAttribute(Cr))}function M(R){let B=P(),te=B==null?void 0:B.closest(ho),J;for(;te&&!J;)te=R>0?PC(te,ho):OC(te,ho),J=te==null?void 0:te.querySelector(kh);J?E.setState("value",J.getAttribute(Cr)):D(R)}let j=()=>N(Y().length-1),z=R=>{R.preventDefault(),R.metaKey?j():R.altKey?M(1):D(1)},W=R=>{R.preventDefault(),R.metaKey?N(0):R.altKey?M(-1):D(-1)};return m.createElement(ye.div,{ref:t,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:R=>{var B;(B=v.onKeyDown)==null||B.call(v,R);let te=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||te))switch(R.key){case"n":case"j":{g&&R.ctrlKey&&z(R);break}case"ArrowDown":{z(R);break}case"p":case"k":{g&&R.ctrlKey&&W(R);break}case"ArrowUp":{W(R);break}case"Home":{R.preventDefault(),N(0);break}case"End":{R.preventDefault(),j();break}case"Enter":{R.preventDefault();let J=P();if(J){let re=new Event(Wa);J.dispatchEvent(re)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:$C},l),Fs(e,R=>m.createElement(Eh.Provider,{value:E},m.createElement(Th.Provider,{value:A},R))))}),EC=m.forwardRef((e,t)=>{var n,r;let o=Pt(),s=m.useRef(null),i=m.useContext(Ih),a=po(),l=Ah(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;nr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=jh(o,s,[e.value,e.children,s],e.keywords),f=Va(),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(Wa,w),()=>k.removeEventListener(Wa,w)},[p,e.onSelect,e.disabled]);function w(){var k,E;x(),(E=(k=l.current).onSelect)==null||E.call(k,d.current)}function x(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:g,value:v,onSelect:b,forceMount:S,keywords:T,...C}=e;return m.createElement(ye.div,{ref:En(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:x,onClick:g?void 0:w},e.children)}),IC=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=po(),f=Dn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);nr(()=>d.group(i),[]),jh(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),Fs(e,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},m.createElement(Ih.Provider,{value:h},p))))}),NC=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"})}),AC=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Va(),i=Dn(u=>u.search),a=Dn(u=>u.selectedItemId),l=po();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)}})}),jC=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=po();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},Fs(e,u=>m.createElement("div",{ref:En(i,l.listInnerRef),"cmdk-list-sizer":""},u)))}),_C=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(Aa,{open:n,onOpenChange:r},m.createElement(ja,{container:i},m.createElement(oo,{"cmdk-overlay":"",className:o}),m.createElement(so,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Nh,{ref:t,...a}))))}),MC=m.forwardRef((e,t)=>Dn(n=>n.filtered.count===0)?m.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),RC=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(Nh,{List:jC,Item:EC,Input:AC,Group:IC,Separator:NC,Dialog:_C,Empty:MC,Loading:RC});function PC(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function OC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ah(e){let t=m.useRef(e);return nr(()=>{t.current=e}),t}var nr=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=Va(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function jh(e,t,n,r=[]){let o=m.useRef(),s=po();return nr(()=>{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(Cr,a),o.current=a}),o}var DC=()=>{let[e,t]=m.useState(),n=kr(()=>new Map);return nr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function LC(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(LC(t),{ref:t.ref},n(t.props.children)):n(t)}var $C={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const _h=m.forwardRef(({className:e,...t},n)=>c.jsx(zt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));_h.displayName=zt.displayName;const Mh=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:oe("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})]}));Mh.displayName=zt.Input.displayName;const Rh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Rh.displayName=zt.List.displayName;const Ph=m.forwardRef((e,t)=>c.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Ph.displayName=zt.Empty.displayName;const Oh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Group,{ref:n,className:oe("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}));Oh.displayName=zt.Group.displayName;const FC=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));FC.displayName=zt.Separator.displayName;const Dh=m.forwardRef(({className:e,...t},n)=>c.jsx(zt.Item,{ref:n,className:oe("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}));Dh.displayName=zt.Item.displayName;function Ka(e,[t,n]){return Math.min(n,Math.max(t,e))}function BC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var qa="ScrollArea",[Lh,FT]=yn(qa),[zC,en]=Lh(qa),$h=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[x,g]=m.useState(null),[v,b]=m.useState(0),[S,T]=m.useState(0),[C,k]=m.useState(!1),[E,A]=m.useState(!1),O=ze(t,H=>l(H)),$=Fo(o);return c.jsx(zC,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:T,children:c.jsx(ye.div,{dir:$,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});$h.displayName=qa;var Fh="ScrollAreaViewport",Bh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=en(Fh,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})})]})});Bh.displayName=Fh;var wn="ScrollAreaScrollbar",Ga=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(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(HC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(UC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(zh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ya,{...r,ref:t}):null});Ga.displayName=wn;var HC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(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(Xt,{present:n||s,children:c.jsx(zh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),UC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Us(()=>l("SCROLL_END"),100),[a,l]=BC("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(Xt,{present:n||a!=="hidden",children:c.jsx(Ya,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:me(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:me(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),zh=m.forwardRef((e,t)=>{const n=en(wn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=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,l),Tr(n.content,l),c.jsx(Xt,{present:r||s,children:c.jsx(Ya,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ya=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=en(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=Kh(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 YC(h,i.current,a,p)}return n==="horizontal"?c.jsx(WC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=qh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(VC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=qh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),WC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(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(Uh,{"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),Yh(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:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),VC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(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(Uh,{"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),Yh(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:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[KC,Hh]=Lh(wn),Uh=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=en(wn,n),[w,x]=m.useState(null),g=ze(t,O=>x(O)),v=m.useRef(null),b=m.useRef(""),S=p.viewport,T=r.content-r.viewport,C=It(d),k=It(l),E=Us(f,10);function A(O){if(v.current){const $=O.clientX-v.current.left,H=O.clientY-v.current.top;u({x:$,y:H})}}return m.useEffect(()=>{const O=$=>{const H=$.target;(w==null?void 0:w.contains(H))&&C($,T)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,w,T,C]),m.useEffect(k,[r,k]),Tr(w,E),Tr(p.content,E),c.jsx(KC,{scope:n,scrollbar:w,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:me(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),v.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(O))}),onPointerMove:me(e.onPointerMove,A),onPointerUp:me(e.onPointerUp,O=>{const $=O.target;$.hasPointerCapture(O.pointerId)&&$.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),Bs="ScrollAreaThumb",Wh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Hh(Bs,e.__scopeScrollArea);return c.jsx(Xt,{present:n||o.hasThumb,children:c.jsx(qC,{ref:t,...r})})}),qC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=en(Bs,n),i=Hh(Bs,n),{onThumbPositionChange:a}=i,l=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=XC(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:me(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:w,y:x})}),onPointerUp:me(e.onPointerUp,i.onThumbPointerUp)})});Wh.displayName=Bs;var Xa="ScrollAreaCorner",Vh=m.forwardRef((e,t)=>{const n=en(Xa,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(GC,{...e,ref:t}):null});Vh.displayName=Xa;var GC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=en(Xa,n),[s,i]=m.useState(0),[a,l]=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),l(d)}),Tr(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 zs(e){return e?parseInt(e,10):0}function Kh(e,t){const n=e/t;return isNaN(n)?0:n}function Hs(e){const t=Kh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function YC(e,t,n,r="ltr"){const o=Hs(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 Gh([l,u],f)(e)}function qh(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,l=n==="ltr"?[0,i]:[i*-1,0],u=Ka(e,l);return Gh([0,i],[0,a])(u)}function Gh(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 Yh(e,t){return e>0&&e<t}var XC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function 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 Xh=$h,JC=Bh,ZC=Vh;const Jh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Xh,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[c.jsx(JC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(Zh,{}),c.jsx(ZC,{})]}));Jh.displayName=Xh.displayName;const Zh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Ga,{ref:r,orientation:t,className:oe("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(Wh,{className:"relative flex-1 rounded-full bg-border"})}));Zh.displayName=Ga.displayName;const Ws=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:oe("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 QC="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",ek="bg-slate-700 border-slate-600 hover:bg-slate-600",tk="bg-slate-600 border-slate-500";function nk({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:w,secondaryLine:x,itemClassName:g,activeItemClassName:v}){const b=n===e.threadId,S=t?`${v??tk}`:`${g??ek}`,T=C=>{C.stopPropagation(),o(e.threadId)};return c.jsxs("div",{onClick:T,className:`${QC} ${S}`,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:C=>C.stopPropagation(),children:[c.jsx(Ws,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),c.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(Qe,{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:w(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)})]}),x&&c.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:x})]})}),c.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:c.jsxs(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{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(Gn,{onClick:C=>{C.preventDefault(),u(e.threadId)},children:[c.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&c.jsxs(Gn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[c.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&c.jsxs(Gn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},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 Qh=25,ep="thread-manager-view",rk=e=>e==="default"||e==="shared",ok=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(ep);if(rk(e))return e}catch{}return null};function sk({defaultView:e}={}){const[t,n]=y.useState(()=>ok()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ep,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const ik=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Ja({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:w,viewState:x,showHeader:g=!0,shareTargets:v,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:T,sharedThreads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:O,actions:$,shareInFlight:H,shareStatus:U,clearShareStatus:K}=Do(),{createThread:P,deleteThread:Y,renameThread:N,shareThread:D}=$,{loadThread:M}=Lo(),j=i??k,[z,W]=y.useState(Array.isArray(T)?T:[]),R=y.useRef(z.length>0),B=y.useRef(null),te=y.useRef(0),[J,re]=y.useState(null),[G,L]=y.useState(""),[V,Z]=y.useState(!1),[q,X]=y.useState(!1),[pe,he]=y.useState(null),[ee,le]=y.useState(""),we=w&&w.length>0?w:ik,je=sk({defaultView:h}),Ne=x??je,$e=f??Ne.view,Ye=y.useCallback(_=>{f||Ne.setView(_),p==null||p(_)},[f,p,Ne]),nt=we.find(_=>_.key===$e)??we[0],Ve=_=>{he(_),le(""),X(!0)},qe=()=>{X(!1),he(null),le(""),K()},rt=y.useCallback(async _=>{if(!(!pe||H)&&_.id)try{await D(pe,_.id),setTimeout(()=>qe(),600)}catch(ie){console.error("Failed to share thread:",ie)}},[qe,H,pe,D]),kt=y.useMemo(()=>{const _=v??[],ie=ee.trim().toLowerCase();return ie?S?_.filter(ge=>S(ge,ie)):_.filter(ge=>`${ge.label} ${ge.secondaryLabel??""}`.toLowerCase().includes(ie)):_},[v,ee,S]),at=$e==="shared",Te=at?C:z,Oe=at?O:A,it=at?"No shared conversations yet":"No conversations yet",ht=_=>{const ie=_.sharedAt?` • ${vt(_.sharedAt)}`:"";return`Shared by ${_.sharedByUserId}${ie}`},Tt=_=>"sharedByUserId"in _;y.useEffect(()=>{const _=Array.isArray(T)?T:[];if(_.length>0){R.current=!0,W(_);return}A||(R.current=!1,W(_))},[T,A]),y.useEffect(()=>{if(!B.current)return;const _=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!_)return;let ie=null,ge=null;return ie=requestAnimationFrame(()=>{ge=requestAnimationFrame(()=>{_.scrollTop=te.current})}),()=>{ie!==null&&cancelAnimationFrame(ie),ge!==null&&cancelAnimationFrame(ge)}},[z]);const yt=async _=>{try{E(_),await M(_),a==null||a(_),l==null||l(_)}catch(ie){console.error("Failed to select thread:",ie)}},Le=async()=>{try{Z(!0);const _=await P();_&&(u==null||u(_),a==null||a(_))}catch(_){console.error("Failed to create thread:",_)}finally{Z(!1)}},Ht=async(_,ie)=>{if(ie.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const ge=B.current.querySelector("[data-radix-scroll-area-viewport]");ge&&(te.current=ge.scrollTop)}try{await Y(_),d==null||d(_)}catch(ge){console.error("Failed to delete thread:",ge)}}},Xe=(_,ie)=>{ie.stopPropagation(),re(_.threadId),L(_.title||`Thread ${_.threadId.slice(0,8)}`)},Ke=async _=>{if(G.trim())try{await N(_,G.trim()),re(null),L("")}catch(ie){console.error("Failed to update title:",ie)}},dt=()=>{re(null),L("")},vt=_=>{if(!_)return"";try{const ie=new Date(_),We=new Date().getTime()-ie.getTime(),Pe=Math.floor(We/(1e3*60*60*24));return Pe===0?ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ie.toLocaleDateString()}catch{return""}},Ue=_=>_.title||`Thread ${_.threadId.slice(0,8)}`,St=_=>{const ie=Ue(_);return ie.length<=Qh?ie:`${ie.slice(0,Qh)}...`};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(Qe,{onClick:Le,disabled:V||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:V?"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(ta,{children:[c.jsx(na,{asChild:!0,children:c.jsx(Qe,{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(_=>c.jsxs(Gn,{className:"justify-between text-[12px]",onClick:ie=>{ie.preventDefault(),Ye(_.key)},children:[c.jsx("span",{children:_.label}),$e===_.key&&c.jsx(ae.Check,{className:"h-3 w-3"})]},_.key))})]})]})]}),c.jsx(Jh,{ref:B,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:it})]}):Te.slice().sort((_,ie)=>new Date(ie.updatedAt||ie.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>c.jsx(nk,{thread:_,isActive:j===_.threadId,editingThreadId:J,editingTitle:G,onSelect:yt,onStartEditing:Xe,onEditingTitleChange:ie=>L(ie),onSaveEditing:Ke,onCancelEditing:dt,onShare:()=>Ve(_.threadId),onDelete:Ht,showEditTitle:r,showDeleteButton:n,formatDate:vt,getDisplayThreadTitle:St,secondaryLine:at&&Tt(_)?ht(_):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},_.threadId))})}),c.jsx(Jf,{open:q,onOpenChange:_=>!_&&qe(),children:c.jsxs(_a,{className:"max-w-md p-0",children:[c.jsx(Ma,{children:c.jsx(Ra,{children:"Share thread"})}),c.jsxs(_h,{children:[c.jsx(Mh,{autoFocus:!0,value:ee,onValueChange:_=>le(_),placeholder:"Search for recipients..."}),c.jsxs(Rh,{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(Ph,{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(Oh,{heading:"Recipients",children:kt.map(_=>c.jsx(Dh,{onSelect:()=>rt(_),children:c.jsxs("div",{className:"flex flex-col items-start text-sm",children:[c.jsx("span",{className:"font-medium",children:_.label}),_.secondaryLabel&&c.jsx("span",{className:"text-xs text-muted-foreground",children:_.secondaryLabel})]})},_.id))})]})]})]})})]})}const ak=({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 w=d===p.id,x=(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 ${w?"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 ${w?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${w?"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}`:""]}),x&&c.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:x,children:x})]})]},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 Er(e){if(!(typeof globalThis>"u"))return globalThis[e]}function lk(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function tp(){const e=[Er("__API_BASE_URL__"),Er("__CHAT_API_BASE_URL__"),Er("__CHAT_API_URL__")];for(const t of e){const n=lk(t);if(n)return n}}function np(){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 rp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function op(){const e={},t=tp(),n=np();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function sp(){const e=op(),t=Tn.getAuthToken(),n=tp();return{apiBaseUrl:rp(e.baseUrl,Tn.baseUrl,n),apiKey:t||e.apiKey||np()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const ip="chat-settings";function ck(){try{const e=localStorage.getItem(ip);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function uk(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem(ip,JSON.stringify(t)),t.apiKey&&Tn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function dk(){const e=sp(),t=ck(),n=Tn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:rp(Tn.baseUrl,r,e.apiBaseUrl)}}function fk(e){Tn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),uk(e)}var hk="Label",ap=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())}}));ap.displayName=hk;var lp=ap;const pk=wo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tn=m.forwardRef(({className:e,...t},n)=>c.jsx(lp,{ref:n,className:oe(pk(),e),...t}));tn.displayName=lp.displayName;function cp(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 up=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"}),mk="VisuallyHidden",gk=m.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...up,...e.style}}));gk.displayName=mk;var xk=[" ","Enter","ArrowUp","ArrowDown"],vk=[" ","Enter"],rr="Select",[Vs,Ks,wk]=bi(rr),[Ir,BT]=yn(rr,[wk,Zo]),qs=Zo(),[bk,Ln]=Ir(rr),[yk,Sk]=Ir(rr),dp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:w}=e,x=qs(t),[g,v]=m.useState(null),[b,S]=m.useState(null),[T,C]=m.useState(!1),k=Fo(u),[E,A]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:rr}),[O,$]=dr({prop:i,defaultProp:a,onChange:l,caller:rr}),H=m.useRef(null),U=g?w||!!g.closest("form"):!0,[K,P]=m.useState(new Set),Y=Array.from(K).map(N=>N.props.value).join(";");return c.jsx(mu,{...x,children:c.jsxs(bk,{required:p,scope:t,trigger:g,onTriggerChange:v,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:Pt(),value:O,onValueChange:$,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[c.jsx(Vs.Provider,{scope:t,children:c.jsx(yk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(N=>{P(D=>new Set(D).add(N))},[]),onNativeOptionRemove:m.useCallback(N=>{P(D=>{const M=new Set(D);return M.delete(N),M})},[]),children:n})}),U?c.jsxs(Op,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:N=>$(N.target.value),disabled:h,form:w,children:[O===void 0?c.jsx("option",{value:""}):null,Array.from(K)]},Y):null]})})};dp.displayName=rr;var fp="SelectTrigger",hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=qs(n),i=Ln(fp,n),a=i.disabled||r,l=ze(t,i.onTriggerChange),u=Ks(n),d=m.useRef("touch"),[f,h,p]=Lp(x=>{const g=u().filter(S=>!S.disabled),v=g.find(S=>S.value===i.value),b=$p(g,x,v);b!==void 0&&i.onValueChange(b.value)}),w=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(gu,{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":Dp(i.value)?"":void 0,...o,ref:l,onClick:me(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&w(x)}),onPointerDown:me(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(w(x),x.preventDefault())}),onKeyDown:me(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&xk.includes(x.key)&&(w(),x.preventDefault())})})})});hp.displayName=fp;var pp="SelectValue",mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Ln(pp,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:Dp(l.value)?c.jsx(c.Fragment,{children:i}):s})});mp.displayName=pp;var Ck="SelectIcon",gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gp.displayName=Ck;var kk="SelectPortal",xp=e=>c.jsx(Qo,{asChild:!0,...e});xp.displayName=kk;var or="SelectContent",vp=m.forwardRef((e,t)=>{const n=Ln(or,e.__scopeSelect),[r,o]=m.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?bo.createPortal(c.jsx(wp,{scope:e.__scopeSelect,children:c.jsx(Vs.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(bp,{...e,ref:t})});vp.displayName=or;var cn=10,[wp,$n]=Ir(or),Tk="SelectContentImpl",Ek=Bn.createSlot("SelectContent.RemoveScroll"),bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:x,avoidCollisions:g,...v}=e,b=Ln(or,n),[S,T]=m.useState(null),[C,k]=m.useState(null),E=ze(t,G=>T(G)),[A,O]=m.useState(null),[$,H]=m.useState(null),U=Ks(n),[K,P]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return Hi(S)},[S]),Ci();const N=m.useCallback(G=>{const[L,...V]=U().map(X=>X.ref.current),[Z]=V.slice(-1),q=document.activeElement;for(const X of G)if(X===q||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&C&&(C.scrollTop=0),X===Z&&C&&(C.scrollTop=C.scrollHeight),X==null||X.focus(),document.activeElement!==q))return},[U,C]),D=m.useCallback(()=>N([A,S]),[N,A,S]);m.useEffect(()=>{K&&D()},[K,D]);const{onOpenChange:M,triggerPointerDownPosRef:j}=b;m.useEffect(()=>{if(S){let G={x:0,y:0};const L=Z=>{var q,X;G={x:Math.abs(Math.round(Z.pageX)-(((q=j.current)==null?void 0:q.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((X=j.current)==null?void 0:X.y)??0))}},V=Z=>{G.x<=10&&G.y<=10?Z.preventDefault():S.contains(Z.target)||M(!1),document.removeEventListener("pointermove",L),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",V,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",V,{capture:!0})}}},[S,M,j]),m.useEffect(()=>{const G=()=>M(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[M]);const[z,W]=Lp(G=>{const L=U().filter(q=>!q.disabled),V=L.find(q=>q.ref.current===document.activeElement),Z=$p(L,G,V);Z&&setTimeout(()=>Z.ref.current.focus())}),R=m.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&(O(G),Z&&(Y.current=!0))},[b.value]),B=m.useCallback(()=>S==null?void 0:S.focus(),[S]),te=m.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&H(G)},[b.value]),J=r==="popper"?Za:yp,re=J===Za?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(wp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:R,selectedItem:A,onItemLeave:B,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:$,position:r,isPositioned:K,searchRef:z,children:c.jsx(ls,{as:Ek,allowPinchZoom:!0,children:c.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:me(o,G=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),G.preventDefault()}),children:c.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:G=>G.preventDefault(),...v,...re,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:me(v.onKeyDown,G=>{const L=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!L&&G.key.length===1&&W(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let Z=U().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(G.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const q=G.target,X=Z.indexOf(q);Z=Z.slice(X+1)}setTimeout(()=>N(Z)),G.preventDefault()}})})})})})})});bp.displayName=Tk;var Ik="SelectItemAlignedPosition",yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Ln(or,n),i=$n(or,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=ze(t,E=>d(E)),h=Ks(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:v,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&v){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),$=v.getBoundingClientRect();if(s.dir!=="rtl"){const q=$.left-A.left,X=O.left-q,pe=E.left-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.left=we+"px"}else{const q=A.right-$.right,X=window.innerWidth-O.right-q,pe=window.innerWidth-E.right-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.right=we+"px"}const H=h(),U=window.innerHeight-cn*2,K=x.scrollHeight,P=window.getComputedStyle(u),Y=parseInt(P.borderTopWidth,10),N=parseInt(P.paddingTop,10),D=parseInt(P.borderBottomWidth,10),M=parseInt(P.paddingBottom,10),j=Y+N+K+M+D,z=Math.min(g.offsetHeight*5,j),W=window.getComputedStyle(x),R=parseInt(W.paddingTop,10),B=parseInt(W.paddingBottom,10),te=E.top+E.height/2-cn,J=U-te,re=g.offsetHeight/2,G=g.offsetTop+re,L=Y+N+G,V=j-L;if(L<=te){const q=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const X=u.clientHeight-x.offsetTop-x.offsetHeight,pe=Math.max(J,re+(q?B:0)+X+D),he=L+pe;a.style.height=he+"px"}else{const q=H.length>0&&g===H[0].ref.current;a.style.top="0px";const pe=Math.max(te,Y+x.offsetTop+(q?R:0)+re)+V;a.style.height=pe+"px",x.scrollTop=L-te+x.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=z+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,v,s.dir,r]);Et(()=>S(),[S]);const[T,C]=m.useState();Et(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return c.jsx(Ak,{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}})})})});yp.displayName=Ik;var Nk="SelectPopperPosition",Za=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=qs(n);return c.jsx(xu,{...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)"}})});Za.displayName=Nk;var[Ak,Qa]=Ir(or,{}),el="SelectViewport",Sp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$n(el,n),i=Qa(el,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(Vs.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:me(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const w=window.innerHeight-cn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),v=Math.max(x,g);if(v<w){const b=v+p,S=Math.min(w,b),T=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Sp.displayName=el;var Cp="SelectGroup",[jk,_k]=Ir(Cp),Mk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return c.jsx(jk,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Mk.displayName=Cp;var kp="SelectLabel",Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_k(kp,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Tp.displayName=kp;var Gs="SelectItem",[Rk,Ep]=Ir(Gs),Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Ln(Gs,n),l=$n(Gs,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=ze(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=Pt(),g=m.useRef("touch"),v=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(Rk,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:me(i.onFocus,()=>p(!0)),onBlur:me(i.onBlur,()=>p(!1)),onClick:me(i.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:me(i.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:me(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:me(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:me(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:me(i.onKeyDown,b=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(vk.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});Ip.displayName=Gs;var mo="SelectItemText",Np=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Ln(mo,n),a=$n(mo,n),l=Ep(mo,n),u=Sk(mo,n),[d,f]=m.useState(null),h=ze(t,v=>f(v),l.onItemTextChange,v=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,v,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Et(()=>(x(w),()=>g(w)),[x,g,w]),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]})});Np.displayName=mo;var Ap="SelectItemIndicator",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ep(Ap,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});jp.displayName=Ap;var tl="SelectScrollUpButton",_p=m.forwardRef((e,t)=>{const n=$n(tl,e.__scopeSelect),r=Qa(tl,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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});_p.displayName=tl;var nl="SelectScrollDownButton",Mp=m.forwardRef((e,t)=>{const n=$n(nl,e.__scopeSelect),r=Qa(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.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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Mp.displayName=nl;var Rp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$n("SelectScrollButton",n),i=m.useRef(null),a=Ks(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:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{l()})})}),Pk="SelectSeparator",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Pp.displayName=Pk;var rl="SelectArrow",Ok=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qs(n),s=Ln(rl,n),i=$n(rl,n);return s.open&&i.position==="popper"?c.jsx(vu,{...o,...r,ref:t}):null});Ok.displayName=rl;var Dk="SelectBubbleInput",Op=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=ze(r,o),i=cp(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:{...up,...n.style},ref:s,defaultValue:t})});Op.displayName=Dk;function Dp(e){return e===""||e===void 0}function Lp(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 $p(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=Lk(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 Lk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $k=dp,Fp=hp,Fk=mp,Bk=gp,zk=xp,Bp=vp,Hk=Sp,zp=Tp,Hp=Ip,Uk=Np,Wk=jp,Up=_p,Wp=Mp,Vp=Pp;const Kp=$k,qp=Fk,ol=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Fp,{ref:r,className:oe("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(Bk,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ol.displayName=Fp.displayName;const Gp=m.forwardRef(({className:e,...t},n)=>c.jsx(Up,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Gp.displayName=Up.displayName;const Yp=m.forwardRef(({className:e,...t},n)=>c.jsx(Wp,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Yp.displayName=Wp.displayName;const sl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(zk,{children:c.jsxs(Bp,{ref:o,className:oe("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(Gp,{}),c.jsx(Hk,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Yp,{})]})}));sl.displayName=Bp.displayName;const Vk=m.forwardRef(({className:e,...t},n)=>c.jsx(zp,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Vk.displayName=zp.displayName;const sr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Hp,{ref:r,className:oe("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(Wk,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(Uk,{children:t})]}));sr.displayName=Hp.displayName;const Kk=m.forwardRef(({className:e,...t},n)=>c.jsx(Vp,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Kk.displayName=Vp.displayName;var qk="Separator",Xp="horizontal",Gk=["horizontal","vertical"],Jp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Xp,...o}=e,s=Yk(r)?r:Xp,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})});Jp.displayName=qk;function Yk(e){return Gk.includes(e)}var Zp=Jp;const Qp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(Zp,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Qp.displayName=Zp.displayName;const Xk=Aa,Jk=IS,Zk=ja,em=m.forwardRef(({className:e,...t},n)=>c.jsx(oo,{className:oe("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}));em.displayName=oo.displayName;const Qk=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"}}),tm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(Zk,{children:[c.jsx(em,{}),c.jsxs(so,{ref:o,className:oe(Qk({side:e}),t),...r,children:[n,c.jsxs(Xf,{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"})]})]})]}));tm.displayName=so.displayName;const nm=({className:e,...t})=>c.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});nm.displayName="SheetHeader";const rm=m.forwardRef(({className:e,...t},n)=>c.jsx(er,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));rm.displayName=er.displayName;const om=m.forwardRef(({className:e,...t},n)=>c.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));om.displayName=js.displayName;var Ys="Switch",[eT,zT]=yn(Ys),[tT,nT]=eT(Ys),sm=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=ze(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[v,b]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:Ys});return c.jsxs(tT,{scope:n,checked:v,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":cm(v),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:me(e.onClick,S=>{b(T=>!T),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(lm,{control:h,bubbles:!x.current,name:r,value:l,checked:v,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sm.displayName=Ys;var im="SwitchThumb",am=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nT(im,n);return c.jsx(ye.span,{"data-state":cm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});am.displayName=im;var rT="SwitchBubbleInput",lm=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=ze(i,s),l=cp(n),u=su(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lm.displayName=rT;function cm(e){return e?"checked":"unchecked"}var um=sm,oT=am;const Fn=m.forwardRef(({className:e,...t},n)=>c.jsx(um,{className:oe("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(oT,{className:oe("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=um.displayName;const sT={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 iT({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}=Da();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(sT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const v=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${v.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(Xk,{open:r,onOpenChange:o,children:[c.jsx(Jk,{asChild:!0,children:c.jsxs(Qe,{variant:"outline",size:"sm",className:n,children:[c.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(_f,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(tm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(nm,{children:[c.jsx(rm,{children:"Chat Settings"}),c.jsx(om,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ws,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(v=>({...v,api:{...v.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Qe,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Fn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(v=>({...v,api:{...v.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ws,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(v=>({...v,api:{...v.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Qe,{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(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(Kp,{value:a.ui.layout,onValueChange:g=>l(v=>({...v,ui:{...v.ui,layout:g}})),children:[c.jsx(ol,{children:c.jsx(qp,{})}),c.jsxs(sl,{children:[c.jsx(sr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(sr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(tn,{htmlFor:"theme",children:"Theme"}),c.jsxs(Kp,{value:a.ui.theme,onValueChange:g=>l(v=>({...v,ui:{...v.ui,theme:g}})),children:[c.jsx(ol,{children:c.jsx(qp,{})}),c.jsxs(sl,{children:[c.jsx(sr,{value:"light",children:"Light"}),c.jsx(sr,{value:"dark",children:"Dark"}),c.jsx(sr,{value:"system",children:"System"})]})]})]}),c.jsx(Qp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Fn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Fn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(tn,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Fn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(v=>({...v,ui:{...v.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(lo,{children:[c.jsx(co,{className:"pb-3",children:c.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[c.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(fo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Qe,{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(Qe,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Qe,{onClick:h,disabled:!u,children:[c.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function aT({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($s,{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(Ja,{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($s,{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(Ja,{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($s,{onError:s.onError,enableFileUpload:!0})})]})})}Ce.ChatApi=tc,Ce.ChatInput=Cc,Ce.ChatInterface=$s,Ce.ChatProviders=$o,Ce.ChatSettings=iT,Ce.MarkdownContent=ao,Ce.MessageComponent=Ls,Ce.MessageList=Fa,Ce.ThreadManager=Ja,Ce.TimelineColumn=ak,Ce.applySettings=fk,Ce.buildMessagePreviewMap=Vg,Ce.chatApiClient=Tn,Ce.default=aT,Ce.del=hi,Ce.get=Yt,Ce.getChatToken=Zl,Ce.getCurrentSettings=dk,Ce.getDefaultApiConfig=op,Ce.getDefaultChatSettings=sp,Ce.onChatTokenChanged=Ql,Ce.post=Ro,Ce.put=ec,Ce.setChatToken=Mo,Ce.useApi=pi,Ce.useChatStream=gc,Ce.useMessagesReducer=fc,Ce.useStream=yc,Ce.useThreadState=Lo,Ce.useThreads=Do,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
126
|
+
`}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=sh(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=sh(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 uh{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 dh{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||tr,this.options.renderer=this.options.renderer||new $a,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new uh,this.slugger=new dh}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,c,u,d,f,h,p,w,x,g,v,b,S,T,C,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,oh(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="",c=u.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=p.ordered,x=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],S=b.checked,T=b.task,v="",b.task&&(C=this.renderer.checkbox(S),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):v+=C),v+=this.parse(b.tokens,g),h+=this.renderer.listitem(v,T,S);r+=this.renderer.list(h,w,x);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<E&&t[o+1].type==="text";)p=t[++o],h+=`
|
|
127
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Ds{constructor(t){this.options=t||tr}preprocess(t){return t}postprocess(t){return t}}dm(Ds,"passThroughHooks",new Set(["preprocess","postprocess"]));function ZS(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
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 fh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=ZS(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(YS(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 fh(Pn.lex,On.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},DS(ve.defaults),ve},ve.getDefaults=eh,ve.defaults=tr,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 $a;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 La;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=fh(Pn.lexInline,On.parseInline),ve.Parser=On,ve.parser=On.parse,ve.Renderer=$a,ve.TextRenderer=uh,ve.Lexer=Pn,ve.lexer=Pn.lex,ve.Tokenizer=La,ve.Slugger=dh,ve.Hooks=Ds,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,On.parse,Pn.lex;function Cr({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:oe("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 QS={MODE:"library"};function eC(){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"?QS: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 tC(){return!eC()}function nC(){return typeof window>"u"?!1:window.__ARTIFACT_DEBUG__===!0}function rC(){return tC()||nC()}function oC({preview:e,idx:t}){return y.useEffect(()=>{rC()&&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 sC({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})]}),typeof e.results=="string"&&e.results.trim()&&l.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[l.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),l.jsx(Cr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),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 iC({artifact:e,idx:t=0}){if((e==null?void 0:e.type)==="research_task_info")return l.jsx(sC,{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=>ux(o)).filter(o=>o!==null):[],[e]);return n.length>0?l.jsx("div",{className:"space-y-2",children:n.map((r,o)=>l.jsx(oC,{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 lo=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));lo.displayName="Card";const co=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));co.displayName="CardHeader";const uo=m.forwardRef(({className:e,...t},n)=>l.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));uo.displayName="CardTitle";const hh=m.forwardRef(({className:e,...t},n)=>l.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));hh.displayName="CardDescription";const fo=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));fo.displayName="CardContent";const ph=m.forwardRef(({className:e,...t},n)=>l.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));ph.displayName="CardFooter";function aC({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=ur(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(lo,{className:oe("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(co,{className:"pb-3",children:[l.jsx(uo,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),l.jsx(hh,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a&&l.jsx(fo,{className:"pt-0 pb-3",children:a}),l.jsx(ph,{className:"pt-0",children:l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsx(Qe,{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(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const lC="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 mh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?l.jsx("div",{className:lC,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:ur(e)}):l.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:ur(e)})}function cC({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 uC({message:e,viewMode:t,isStreaming:n=!1}){const o=gi(e).name||"tool",s=c=>{if(c==null)return null;const u=typeof c=="string"?mi(c)??c:c;if(u&&typeof u=="object")return l.jsx(mh,{data:u});const d=typeof u=="string"?u:(()=>{try{return ur(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}=rx(c);return d?l.jsx(Cr,{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=$r(h);return i(p)}const u=Lr(c),d=$r(u);return i(d)};return l.jsxs("div",{className:"space-y-2",children:[l.jsx(cC,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function dC(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Da(),[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,w,x)=>{var g,v;if(!t){p.preventDefault();return}if(o[x]){p.preventDefault();return}try{const b=String(w.url??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const T=S[1],C=w.name||`file_${T}`,k=w.mimeType||"application/octet-stream";f({id:T,name:C,mimeType:k});return}if(b.startsWith("data:")){p.preventDefault(),s(C=>({...C,[x]:!0}));const T=r({title:"Fetching file...",description:"",open:!0});try{const C=await xS(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const k=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(w.name??""))?!1:typeof w.size=="number"&&typeof E.size=="number"?E.size===w.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${w.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:w.name||k.filename||`file_${k.id}`,mimeType:w.mimeType||k.mime_type||"application/octet-stream"}),(g=T.update)==null||g.call(T,{id:T.id,title:"Success",description:`Opened ${w.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const k=C instanceof Error?C.message:"Unknown error occurred";(v=T.update)==null||v.call(T,{id:T.id,title:"Failed",description:k}),r({title:"Failed to fetch file",description:k,open:!0})}finally{s(C=>({...C,[x]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[x]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:h,fileViewerOpen:c,currentFileInfo:i,closeFileViewer:d}}function fC({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:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?l.jsx(Cr,{content:e,allowHtml:!1}):l.jsxs("pre",{className:oe("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(Qe,{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 hC({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:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function gh(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:w,onRegenerate:x,onCancelEdit:g,onCopy:v,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,checkpointCandidates:k=[],activeCheckpointId:E=null,onSelectCheckpoint:A,defaultCheckpointId:O=null,messageParentCheckpointId:$=null}){const[H,U]=y.useState(!1),[K,P]=y.useState("preview"),[Y,N]=y.useState(!1),{currentThreadId:D}=Do(),{respondToInterrupt:M}=Lo(),j=c==="phone"||c==="half-screen",z=t.role,W=z==="tool",R=y.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),B=!!R,te=!(r&&z!=="user"),{uploadingFiles:J,handleFileClick:re,fileViewerOpen:G,currentFileInfo:L,closeFileViewer:V}=dC({allowFileOpen:te,currentThreadId:D}),Z=y.useMemo(()=>{switch(z){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[z]),q=y.useMemo(()=>{if(R)return"";const _=t.content;return Array.isArray(_)?ox(_):""},[R,t]),X=y.useMemo(()=>{if(R)return{};const _=t.content;return Array.isArray(_)?gi(t):{}},[R,t]),pe=y.useMemo(()=>W?!!(t.additionalKwargs??{}).toolStreaming:!1,[W,t]),he=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="image_url"):[]},[R,t]),ee=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="file"):[]},[R,t]),le=y.useMemo(()=>{if(R)return[];const _=t.content;return Array.isArray(_)?_.filter(ie=>ie.type==="interrupt"):[]},[R,t]),we=(b==null?void 0:b.id)??(b==null?void 0:b.interrupt_id),je=Oo(we),Ne=b==null?void 0:b.value,$e=y.useMemo(()=>{if(R)return"";const _=t.content;return Array.isArray(_)?sx(_):""},[R,t]),Ye=y.useMemo(()=>R||!h?null:t.artifact||null,[R,t,h]),nt=y.useCallback(async()=>{const _=W?$e:q;async function ie(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const We=new Blob([ge],{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 ie(_),U(!0),setTimeout(()=>U(!1),2e3),v==null||v(_)}catch(ge){console.error("Failed to copy:",ge)}},[W,$e,q,v]),Ve=y.useCallback(()=>{if(!w)return;const _=W?$e:q,ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};w(t.id,_,ie)},[w,t.id,W,$e,q,t]),qe=y.useCallback(()=>{x==null||x(n)},[x,n]),rt=y.useCallback(()=>{const ie=oe(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(z){case"user":return l.jsx(ae.User,{className:ie});case"assistant":return l.jsx(ae.Bot,{className:ie});case"tool":return l.jsx(ae.Wrench,{className:ie});default:return l.jsx(ae.Bot,{className:ie})}},[j,Z,z]),kt=y.useCallback(()=>{const _="group relative mb-4 flex w-full";switch(z){case"user":return oe(_,"justify-end");case"assistant":case"tool":case"system":return oe(_,"justify-start");default:return _}},[z]),at=y.useCallback(()=>{const _=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(B)return oe(_,"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(z){case"user":return oe(_,"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 oe(_,"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 oe(_,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(_,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(_,"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")}},[j,B,z]),Te=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),Oe=y.useCallback(async _=>{if(S)return;const ie=Oo((_==null?void 0:_.id)??(_==null?void 0:_.interrupt_id));if(!ie){console.warn("Interrupt part missing id",_);return}try{T==null||T(),await M(ie,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,T,M]),it=y.useCallback(({part:_,i:ie})=>{if(_.type==="text"){const ge=_.text??"",We=ge.trim(),Pe=mi(We);return Pe&&z!=="tool"?l.jsx(mh,{data:Pe},ie):z==="user"&&u&&We.length>d?l.jsx(fC,{text:We,expanded:Y,onExpandedChange:N,previewLength:d,isCompact:j},ie):l.jsx(Cr,{content:ge,allowHtml:!1},ie)}if(_.type==="image_url"){const ge=_;return l.jsx("div",{className:"my-2",children:l.jsx("img",{src:ge.url,alt:ge.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},ie)}if(_.type==="file"){const ge=_,We=ge.name||"file";return l.jsxs("a",{href:ge.url,onClick:Pe=>re(Pe.nativeEvent,ge,ie),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[J[ie]?l.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,l.jsxs("span",{className:"truncate max-w-[180px]",children:[We,J[ie]?" (processing)":""]})]},ie)}if(_.type==="interrupt"){const ge=_,We=Oo((ge==null?void 0:ge.id)??(ge==null?void 0:ge.interrupt_id)),Pe=!!(je&&We&&We===je),mt=Pe?Ne??(ge==null?void 0:ge.value):ge==null?void 0:ge.value,Je=We?{...ge,id:We,interrupt_id:We}:ge;return l.jsx(aC,{interruptPart:Je,onApprove:Te,onReject:Oe,disabled:S,isActive:Pe,payload:mt},ie)}return null},[re,J,Te,Oe,z,u,d,Y,j,je,Ne,b,S,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 _=q.trim().length>0||he.length>0||ee.length>0||le.length>0;if(!W&&ee.length>0&&!r)return ht();if(!W&&!_&&!r)return null;if(W)return!f&&Ye?null:f?l.jsx(uC,{message:t,viewMode:K,isStreaming:pe},t.id):null;if(!W&&!R){const ie=t,ge=l.jsx("div",{className:"space-y-2",children:ie.content.map((We,Pe)=>l.jsx(it,{part:We,i:Pe},Pe))});return r?l.jsxs("div",{"aria-busy":"true",role:"status",children:[ge,l.jsx(hC,{className:Z})]}):ge}},[q,he.length,ee.length,le.length,r,W,K,f,Ye,ht,Z]),yt=y.useMemo(()=>R?"Assistant":ix(t),[R,t]),Le=y.useMemo(()=>R?[]:Array.isArray(k)?k:[],[k,R]),Ht=y.useMemo(()=>{var _;return Le.length?O&&Le.some(ie=>ie.id===O)?O:((_=Le[0])==null?void 0:_.id)??null:null},[O,Le]),Ke=y.useMemo(()=>!Le.length||!E?null:Le.some(_=>_.id===E)?E:null,[E,Le])??Ht,dt=z==="user"&&Le.length>0&&typeof A=="function",vt=y.useCallback((_,ie=!1)=>{if(!A)return;const ge=(_==null?void 0:_.id)??null,We=(_==null?void 0:_.parentId)??$??null;A(ge,We,ie)},[$,A]),Ue=y.useMemo(()=>Ke?Le.findIndex(_=>_.id===Ke):-1,[Ke,Le]),St=y.useMemo(()=>Ue<0?null:Le[Ue]??null,[Ue,Le]);return W&&!f&&!Ye?null:B&&R?l.jsx("div",{className:oe(kt(),p.container),children:l.jsxs("div",{className:oe(at(),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:oe("h-4 w-4",Z)}),a&&l.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),l.jsx(Cr,{content:R.content,className:"text-current"})]})}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:oe(kt(),p.container),children:l.jsxs("div",{className:oe(at(),p.content),children:[(i||a||W)&&l.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Z,p.header),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[rt(),a&&yt&&l.jsx("span",{className:oe("font-medium",j?"text-xs":"text-sm"),children:yt}),W&&l.jsxs(_f,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",Z,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":K==="expanded",onClick:()=>P(_=>_==="expanded"?"preview":"expanded"),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),P(ie=>ie==="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)}),K==="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&&St&&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:oe("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 _=Le[Ue+1];_&&vt(_)},"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:oe("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)vt(null,!0);else{const _=Le[Ue-1];_&&vt(_,!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:oe("text-xs opacity-60",Z,j&&"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:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[l.jsx("div",{className:"relative",children:l.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:l.jsx(ae.Copy,{className:oe(H?"text-success":Z,j?"h-3 w-3":"h-4 w-4")})})}),z==="user"&&w&&l.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Edit message",children:l.jsx(ae.Edit,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&l.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",Z,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:l.jsx(ae.RotateCcw,{className:oe(Z,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),l.jsxs("div",{className:"relative",children:[Tt(),h&&Ye&&l.jsx("div",{className:"mt-3",children:l.jsx(iC,{artifact:Ye,idx:0})})]}),W&&K==="expanded"&&(X.toolCallId||X.name)&&l.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"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:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[l.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:l.jsx(ae.Copy,{className:oe(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="user"&&w&&l.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ve,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:l.jsx(ae.Edit,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&x&&l.jsx(Qe,{variant:"ghost",size:"sm",onClick:qe,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:l.jsx(ae.RotateCcw,{className:oe("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&l.jsx(OS,{isOpen:G,onClose:V,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var c,u,d,f,h,p,w,x;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&lc(e.message)===lc(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)&&((w=e.customStyles)==null?void 0:w.header)===((x=t.customStyles)==null?void 0:x.header);if(!o||!s)return!1;const i=gh(e.message),a=gh(t.message);return i.length===a.length});Ls.displayName="MessageComponent";function pC(e,t){return y.useMemo(()=>{var d,f,h,p,w;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 x=e,g=x.checkpointId??null;s=x.additionalKwargs??{},i=x.responseMetadata??{};const v=g&&t.checkpointMetaById?t.checkpointMetaById.get(g)??null:null;a=typeof s.step=="number"?s.step:typeof i.step=="number"?i.step:(v==null?void 0:v.step)??null;const b=typeof s.source=="string"?s.source:typeof i.source=="string"?i.source:(v==null?void 0:v.source)??null;c=b?String(b):null;const S=a!==null&&c?`${a}:${c}`:null;if(S&&((d=t.checkpointIndexByKey)!=null&&d.has(S))?r=t.checkpointIndexByKey.get(S)??[]:g&&v&&(r=[v]),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 C=T[0].checkpointId;u=((p=t.attemptMetaById)==null?void 0:p.get(C))??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 C=[];for(const[k,E]of t.attemptMetaById.entries())if(E.baseUserMessageId===T){const A=(w=t.checkpointMetaById)==null?void 0:w.get(k);A&&C.push(A)}C.length>0&&(r=C)}}if(u&&u.attemptCount>1&&t.checkpointMetaById&&t.attemptMetaById){const T=[];for(const[C,k]of t.checkpointMetaById.entries()){const E=t.attemptMetaById.get(C);E&&E.attemptCount===u.attemptCount&&E.baseUserMessageId===u.baseUserMessageId&&T.push(k)}T.sort((C,k)=>{const E=C.createdAt?Date.parse(C.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(C=>C.id)}))}}return{checkpointCandidates:r,defaultCheckpointId:o,attemptMeta:u,resolvedStep:a,resolvedSource:c}},[e,t.checkpointMetaById,t.checkpointIndexByKey,t.attemptMetaById,t.userMessageIdToAttempts])}const xh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,vh=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:w,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:v,checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C,activeCheckpointId:k,onSelectCheckpoint:E}){const A=xh(t,n),O="type"in t&&t.type==="default_message",H=!!t.__syntheticStreaming,{checkpointCandidates:U,defaultCheckpointId:K,attemptMeta:P}=pC(t,{checkpointMetaById:b,checkpointIndexByKey:S,attemptMetaById:T,userMessageIdToAttempts:C}),Y=t&&!O?t.additionalKwargs??{}:{},N=t&&!O?t.responseMetadata??{}:{},D=(()=>{if(typeof Y.parentCheckpointId=="string")return Y.parentCheckpointId;if(typeof N.parentCheckpointId=="string")return N.parentCheckpointId})();return l.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":A,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:w,onInterruptActionEnd:x,showToolMessages:g,showArtifactPreviews:v,checkpointCandidates:U,activeCheckpointId:k??null,onSelectCheckpoint:E,defaultCheckpointId:K,messageParentCheckpointId:D,attemptMeta:P})})});vh.displayName="MessageRow";const Fa=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:w=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:v,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k=!0,showArtifactPreviews:E=!0,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K,createSyntheticThinkingMessage:P=!0},Y)=>{const N=y.useRef(null),D=y.useRef(null),M=y.useRef(!1),j=y.useRef(!1),[z,W]=y.useState(!0),R=y.useMemo(()=>b?e.some(ee=>"type"in ee&&ee.type==="default_message"?!1:Array.isArray(ee==null?void 0:ee.content)&&ee.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),B=y.useMemo(()=>{if(!b||R)return null;const ee=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 je=we.title;typeof je=="string"&&je.trim()&&(le=je.trim())}return{id:`interrupt-${ee}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ee,value:we,title:le}]}},[b,R]),te=y.useMemo(()=>B?[...e,B]:e,[e,B]),J=y.useMemo(()=>!P||!t?te:!te.some(le=>le.role==="assistant")&&te.length>0?[...te,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:te,[te,t,P]),re=y.useMemo(()=>k?J:J.filter(ee=>(ee==null?void 0:ee.role)!=="tool"),[J,k]),G=y.useCallback(ee=>{W(ee),g&&g(!ee),v&&v(ee)},[g,v]),L=y.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),V=y.useMemo(()=>!w||x?!1:z?"auto":!1,[z,w,x]),Z=y.useMemo(()=>{if(typeof p!="string")return null;const ee=p.trim();return ee?{id:"default-message",role:"assistant",type:"default_message",content:ee,createdAt:new Date().toISOString()}:null},[p]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>Z?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:Z,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!"}),pe=re.length,he=pe>0;return y.useEffect(()=>{var ee,le;if(pe===0){j.current=!1;return}if(!j.current)if(j.current=!0,N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},[pe,re.length]),y.useImperativeHandle(Y,()=>({scrollToLatest:()=>{var ee,le;if(N.current&&re.length>0){const we=re.length-1;(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:we,align:"end",behavior:"auto"})}else D.current&&(D.current.scrollTop=D.current.scrollHeight)},scrollToTop:()=>{var ee,le;N.current&&re.length>0?(le=(ee=N.current).scrollToIndex)==null||le.call(ee,{index:0,align:"start",behavior:"auto"}):D.current&&(D.current.scrollTop=0)}}),[re]),l.jsx("div",{className:q,style:h,children:l.jsx("div",{className:"relative flex-1 min-h-0",children:he?l.jsx(eS,{ref:ee=>{N.current=ee},scrollerRef:ee=>{D.current=ee instanceof HTMLDivElement?ee:null},data:re,followOutput:V,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ee,le)=>xh(le,ee),itemContent:(ee,le)=>l.jsx(vh,{message:le,index:ee,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:c,onRegenerate:u,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:T,onInterruptActionEnd:C,showToolMessages:k,showArtifactPreviews:E,checkpointMetaById:A,checkpointIndexByKey:O,attemptMetaById:$,userMessageIdToAttempts:H,activeCheckpointId:U,onSelectCheckpoint:K})}):X()})})});Fa.displayName="MessageList";const wh={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:w,onError:x}){const{api:g}=pi(),{currentThreadId:v}=Do(),{threadId:b,messages:S,isHistoryLoading:T,isLoading:C,navigateToCheckpoint:k,returnToLatest:E,checkpoint:A,checkpoints:O,interrupt:$,metadata:H,timelineCheckpoints:U,messagePreviews:K}=Lo(),{isStreaming:P,error:Y,connectionState:N,submit:D,stop:M}=yc(),j=b??v??null,z=(A==null?void 0:A.id)??null,W=(A==null?void 0:A.namespace)??null,R=(H==null?void 0:H.assemblingMessageId)??null,B=$,[te,J]=y.useState(!1);y.useEffect(()=>{B||J(!1)},[B]);const re=y.useCallback(()=>{J(!0)},[]),G=y.useCallback(()=>{J(!1)},[]),L=!!B||te,[V,Z]=y.useState(null),[q,X]=y.useState(""),[pe,he]=y.useState(null),[ee,le]=y.useState(null),[we,je]=y.useState([]),[Ne,$e]=y.useState(0),[Ye,nt]=y.useState(0),[Ve,qe]=y.useState(!1),[rt,kt]=y.useState(null),[at,Te]=y.useState(null),[Oe,it]=y.useState(!1),[ht,Tt]=y.useState(null),yt=y.useRef(!1),[Le,Ht]=y.useState(()=>wh.value),Xe=y.useRef(Le),Ke=y.useRef(null),dt=y.useCallback(de=>{wh.value=de,Ht(de)},[]),[vt,Ue]=y.useState(!1),St=y.useRef(null),{checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We}=Wy(O),Pe=U??[],mt=y.useRef(null),Je=y.useRef(null),Nt=y.useCallback(()=>{mt.current&&(mt.current.value=""),Je.current&&(Je.current.value=""),$e(de=>de+1),nt(de=>de+1)},[]),go=y.useCallback(de=>{dt(de)},[dt]),xo=y.useRef(!1);y.useEffect(()=>{xo.current&&!P&&(je([]),Nt()),xo.current=P},[P,Nt]);const[Xs,il]=y.useState("desktop");y.useEffect(()=>{const de=()=>{const Se=window.innerWidth;il(Se<640?"phone":Se<1024?"tablet":"desktop")};return de(),window.addEventListener("resize",de),()=>window.removeEventListener("resize",de)},[]),y.useEffect(()=>{yt.current=!1},[j]),y.useEffect(()=>{Xe.current=Le},[Le]),y.useEffect(()=>{if(!V){Ke.current=null;return}Ke.current===null&&(Ke.current=Xe.current),dt(q??"")},[q,V,dt]),y.useEffect(()=>{(async()=>{if(!g.baseUrl){Tt(null);return}try{const Me=(await g.getAgent("default")).uiDefaultMessage||"";Tt(Me||null)}catch(Se){console.warn("Failed to fetch default message:",Se),Tt(null)}})()},[g.baseUrl]),y.useEffect(()=>{Y&&!Oe&&(x==null||x(Y))},[Y,Oe,x]);const al=async de=>{const Se=de.trim();if(!(!Se&&we.length===0))try{const Me=V?(pe==null?void 0:pe.checkpointId)??z??void 0:z??void 0,lt=V?(pe==null?void 0:pe.checkpointNs)??W??void 0:W??void 0;await D({text:Se||"",attachments:we},{checkpointId:Me,checkpointNs:lt,edit:!!V,originalMessageId:V??void 0}),p==null||p(Se),dt(""),le(null),je([]),Nt(),Z(null),X(""),he(null)}catch(Me){const lt=(Me==null?void 0:Me.message)||"Failed to send message";le(lt),x==null||x(lt)}},Js=y.useCallback((de,Se,Me)=>{u&&(Ke.current=Le,Z(de),X(Se),dt(Se),le(null),he({checkpointId:(Me==null?void 0:Me.checkpointId)??null,checkpointNs:(Me==null?void 0:Me.checkpointNs)??null}))},[Le,u,dt]),vo=y.useCallback(()=>{Z(null),X(""),he(null),le(null),dt(Ke.current??Le),Ke.current=null},[Le,dt]),I=y.useCallback((de,Se,Me)=>{Js(de,Se,Me)},[Js]),ne=y.useCallback(de=>{let Se=null;for(let Ut=de-1;Ut>=0;Ut--)if(S[Ut].role==="user"){Se=S[Ut];break}if(!Se)return;const Me=Array.isArray(Se.content)?Se.content:[],Ct=Me.filter(Ut=>(Ut==null?void 0:Ut.type)==="text").map(Ut=>Ut.text).join("")||(()=>{try{return JSON.stringify(Me,null,2)}catch{return String(Me)}})();Ct&&D({text:Ct},{checkpointId:z??void 0,checkpointNs:W??void 0,edit:!0,originalMessageId:Se.id})},[S,D,z,W]),ce=de=>{const Se=Array.from(de.target.files||[]);je(Me=>[...Me,...Se]),de.target.value=""},Ee=de=>{je(Se=>{const Me=Se.filter((lt,Ct)=>de!==Ct);return Me.length===0&&Nt(),Me})},Ze=async de=>{const Se=(de.target.files||[])[0];if(Se){kt(null),Te(null),qe(!0);try{await D({attachments:[Se]},{checkpointId:z??void 0,checkpointNs:W??void 0});const Me=`Uploaded ${Se.name} - processing through chat stream`;Te(Me)}catch(Me){const lt=Me instanceof Error?Me.message:"Failed to upload Excel file";console.error("Excel upload failed",Me),kt(lt),x==null||x(lt)}finally{qe(!1),de.target.value="",Nt()}}},tt=async de=>{if(v){Ue(!0);try{if(!de){await E(),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToLatest()});return}const Se=O.find(lt=>lt.checkpointId===de),Me=(Se==null?void 0:Se.checkpointNs)??null;await k(de,Me),requestAnimationFrame(()=>{var lt;(lt=St.current)==null||lt.scrollToTop()})}finally{Ue(!1)}}},Be=y.useCallback(async(de,Se,Me)=>{await tt(Me?null:de)},[tt]),Fe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${h.container||""}`,At=`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||""}`,pt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${h.inputArea||""}`;return l.jsxs("div",{className:Fe,children:[!!Y&&!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:Y}),l.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>it(!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 ${At}`,style:r?{maxHeight:r}:void 0,children:[l.jsx(Fa,{ref:St,className:"h-full",style:{height:"100%"},messages:S,isStreaming:P,streamingAssistantId:R,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Xs,enableMessageEditing:u,editingMessageId:V,onEdit:I,onRegenerate:ne,onCancelEdit:vo,emptyMessage:ht??void 0,isNavigatingCheckpoint:vt,activeInterrupt:B,disableInterruptActions:te,onInterruptActionStart:re,onInterruptActionEnd:G,showToolMessages:d,showArtifactPreviews:f,checkpointMetaById:_,checkpointIndexByKey:ie,attemptMetaById:ge,userMessageIdToAttempts:We,activeCheckpointId:z,onSelectCheckpoint:Be,timelineCheckpoints:Pe,messagePreviews:K,createSyntheticThinkingMessage:!0}),(N==="reconnecting"||N==="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"}),N==="reconnecting"?"Reconnecting…":"Connecting…"]})}),N==="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"}),C&&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||vt)&&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:pt,children:[V&&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(Qe,{variant:"ghost",size:"sm",onClick:vo,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:de=>ce(de),className:"hidden"},Ne),we.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((de,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:de.name}),l.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Ee(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 ${de.name}`,children:l.jsx(ae.X,{size:12})})]},Se))})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:Je,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Ze,className:"hidden"},Ye),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..."]}),at&&!Ve&&l.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:at}),rt&&!Ve&&l.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:rt})]})]}),ee&&l.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ee}),l.jsxs("div",{className:"flex items-end gap-2",children:[(a||c)&&l.jsxs(ta,{children:[l.jsx(na,{asChild:!0,children:l.jsx(Qe,{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(ps,{align:"start",sideOffset:6,className:"w-52",children:[a&&l.jsxs(Gn,{onClick:()=>{var de;return(de=mt.current)==null?void 0:de.click()},className:"cursor-pointer",children:[l.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),c&&l.jsxs(Gn,{onClick:()=>{var de;Ve||(de=Je.current)==null||de.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(Dx,{initialValue:q,editingMessageId:V,value:Le,onValueChange:go,placeholder:V?"Edit your message...":t,isStreaming:P,disabled:L,onSend:al,onCancelEdit:vo,onStop:M,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ee?"border-red-400":""} ${h.textarea||""}`})})]})]})]})}var bh=1,mC=.9,gC=.8,xC=.17,Ba=.1,za=.999,vC=.9999,wC=.99,bC=/[\\\/_+.#"@\[\(\{&]/,yC=/[\\\/_+.#"@\[\(\{&]/g,SC=/[\s-]/,yh=/[\s-]/g;function Ha(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?bh:wC;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,w;u>=0;)f=Ha(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=bh:bC.test(e.charAt(u-1))?(f*=gC,p=e.slice(o,u-1).match(yC),p&&o>0&&(f*=Math.pow(za,p.length))):SC.test(e.charAt(u-1))?(f*=mC,w=e.slice(o,u-1).match(yh),w&&o>0&&(f*=Math.pow(za,w.length))):(f*=xC,o>0&&(f*=Math.pow(za,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=vC)),(f<Ba&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(h=Ha(e,t,n,r,u+1,s+2,i),h*Ba>f&&(f=h*Ba)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[a]=d,d}function Sh(e){return e.toLowerCase().replace(yh," ")}function CC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Ha(e,t,Sh(e),Sh(t),0,0,{})}var ho='[cmdk-group=""]',Ua='[cmdk-group-items=""]',kC='[cmdk-group-heading=""]',Ch='[cmdk-item=""]',kh=`${Ch}:not([aria-disabled="true"])`,Wa="cmdk-item-select",kr="data-value",TC=(e,t,n)=>CC(e,t,n),Th=m.createContext(void 0),po=()=>m.useContext(Th),Eh=m.createContext(void 0),Va=()=>m.useContext(Eh),Ih=m.createContext(void 0),Nh=m.forwardRef((e,t)=>{let n=Tr(()=>{var R,B;return{search:"",value:(B=(R=e.value)!=null?R:e.defaultValue)!=null?B:"",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=Ah(e),{label:c,children:u,value:d,onValueChange:f,filter:h,shouldFilter:p,loop:w,disablePointerSelection:x=!1,vimBindings:g=!0,...v}=e,b=Pt(),S=Pt(),T=Pt(),C=m.useRef(null),k=DC();nr(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),nr(()=>{k(6,K)},[]);let E=m.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,B,te)=>{var J,re,G,L;if(!Object.is(n.current[R],B)){if(n.current[R]=B,R==="search")U(),$(),k(1,H);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let V=document.getElementById(T);V?V.focus():(J=document.getElementById(b))==null||J.focus()}if(k(7,()=>{var V;n.current.selectedItemId=(V=P())==null?void 0:V.id,E.emit()}),te||k(5,K),((re=a.current)==null?void 0:re.value)!==void 0){let V=B??"";(L=(G=a.current).onValueChange)==null||L.call(G,V);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),A=m.useMemo(()=>({value:(R,B,te)=>{var J;B!==((J=s.current.get(R))==null?void 0:J.value)&&(s.current.set(R,{value:B,keywords:te}),n.current.filtered.items.set(R,O(B,te)),k(2,()=>{$(),E.emit()}))},item:(R,B)=>(r.current.add(R),B&&(o.current.has(B)?o.current.get(B).add(R):o.current.set(B,new Set([R]))),k(3,()=>{U(),$(),n.current.value||H(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let te=P();k(4,()=>{U(),(te==null?void 0:te.getAttribute("id"))===R&&H(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:T,labelId:S,listInnerRef:C}),[]);function O(R,B){var te,J;let re=(J=(te=a.current)==null?void 0:te.filter)!=null?J:TC;return R?re(R,n.current.search,B):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(J=>{let re=o.current.get(J),G=0;re.forEach(L=>{let V=R.get(L);G=Math.max(V,G)}),B.push([J,G])});let te=C.current;Y().sort((J,re)=>{var G,L;let V=J.getAttribute("id"),Z=re.getAttribute("id");return((G=R.get(Z))!=null?G:0)-((L=R.get(V))!=null?L:0)}).forEach(J=>{let re=J.closest(Ua);re?re.appendChild(J.parentElement===re?J:J.closest(`${Ua} > *`)):te.appendChild(J.parentElement===te?J:J.closest(`${Ua} > *`))}),B.sort((J,re)=>re[1]-J[1]).forEach(J=>{var re;let G=(re=C.current)==null?void 0:re.querySelector(`${ho}[${kr}="${encodeURIComponent(J[0])}"]`);G==null||G.parentElement.appendChild(G)})}function H(){let R=Y().find(te=>te.getAttribute("aria-disabled")!=="true"),B=R==null?void 0:R.getAttribute(kr);E.setState("value",B||void 0)}function U(){var R,B,te,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let re=0;for(let G of r.current){let L=(B=(R=s.current.get(G))==null?void 0:R.value)!=null?B:"",V=(J=(te=s.current.get(G))==null?void 0:te.keywords)!=null?J:[],Z=O(L,V);n.current.filtered.items.set(G,Z),Z>0&&re++}for(let[G,L]of o.current)for(let V of L)if(n.current.filtered.items.get(V)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=re}function K(){var R,B,te;let J=P();J&&(((R=J.parentElement)==null?void 0:R.firstChild)===J&&((te=(B=J.closest(ho))==null?void 0:B.querySelector(kC))==null||te.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function P(){var R;return(R=C.current)==null?void 0:R.querySelector(`${Ch}[aria-selected="true"]`)}function Y(){var R;return Array.from(((R=C.current)==null?void 0:R.querySelectorAll(kh))||[])}function N(R){let B=Y()[R];B&&E.setState("value",B.getAttribute(kr))}function D(R){var B;let te=P(),J=Y(),re=J.findIndex(L=>L===te),G=J[re+R];(B=a.current)!=null&&B.loop&&(G=re+R<0?J[J.length-1]:re+R===J.length?J[0]:J[re+R]),G&&E.setState("value",G.getAttribute(kr))}function M(R){let B=P(),te=B==null?void 0:B.closest(ho),J;for(;te&&!J;)te=R>0?PC(te,ho):OC(te,ho),J=te==null?void 0:te.querySelector(kh);J?E.setState("value",J.getAttribute(kr)):D(R)}let j=()=>N(Y().length-1),z=R=>{R.preventDefault(),R.metaKey?j():R.altKey?M(1):D(1)},W=R=>{R.preventDefault(),R.metaKey?N(0):R.altKey?M(-1):D(-1)};return m.createElement(ye.div,{ref:t,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:R=>{var B;(B=v.onKeyDown)==null||B.call(v,R);let te=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||te))switch(R.key){case"n":case"j":{g&&R.ctrlKey&&z(R);break}case"ArrowDown":{z(R);break}case"p":case"k":{g&&R.ctrlKey&&W(R);break}case"ArrowUp":{W(R);break}case"Home":{R.preventDefault(),N(0);break}case"End":{R.preventDefault(),j();break}case"Enter":{R.preventDefault();let J=P();if(J){let re=new Event(Wa);J.dispatchEvent(re)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:$C},c),Fs(e,R=>m.createElement(Eh.Provider,{value:E},m.createElement(Th.Provider,{value:A},R))))}),EC=m.forwardRef((e,t)=>{var n,r;let o=Pt(),s=m.useRef(null),i=m.useContext(Ih),a=po(),c=Ah(e),u=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;nr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=jh(o,s,[e.value,e.children,s],e.keywords),f=Va(),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(Wa,w),()=>k.removeEventListener(Wa,w)},[p,e.onSelect,e.disabled]);function w(){var k,E;x(),(E=(k=c.current).onSelect)==null||E.call(k,d.current)}function x(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:g,value:v,onSelect:b,forceMount:S,keywords:T,...C}=e;return m.createElement(ye.div,{ref:En(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:x,onClick:g?void 0:w},e.children)}),IC=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=po(),f=Dn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);nr(()=>d.group(i),[]),jh(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(Ih.Provider,{value:h},p))))}),NC=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"})}),AC=m.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Va(),i=Dn(u=>u.search),a=Dn(u=>u.selectedItemId),c=po();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)}})}),jC=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=po();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)))}),_C=m.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return m.createElement(Aa,{open:n,onOpenChange:r},m.createElement(ja,{container:i},m.createElement(so,{"cmdk-overlay":"",className:o}),m.createElement(io,{"aria-label":e.label,"cmdk-dialog":"",className:s},m.createElement(Nh,{ref:t,...a}))))}),MC=m.forwardRef((e,t)=>Dn(n=>n.filtered.count===0)?m.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),RC=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(Nh,{List:jC,Item:EC,Input:AC,Group:IC,Separator:NC,Dialog:_C,Empty:MC,Loading:RC});function PC(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function OC(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Ah(e){let t=m.useRef(e);return nr(()=>{t.current=e}),t}var nr=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=Va(),n=()=>e(t.snapshot());return m.useSyncExternalStore(t.subscribe,n,n)}function jh(e,t,n,r=[]){let o=m.useRef(),s=po();return nr(()=>{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(kr,a),o.current=a}),o}var DC=()=>{let[e,t]=m.useState(),n=Tr(()=>new Map);return nr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function LC(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(LC(t),{ref:t.ref},n(t.props.children)):n(t)}var $C={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const _h=m.forwardRef(({className:e,...t},n)=>l.jsx(zt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));_h.displayName=zt.displayName;const Mh=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:oe("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})]}));Mh.displayName=zt.Input.displayName;const Rh=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Rh.displayName=zt.List.displayName;const Ph=m.forwardRef((e,t)=>l.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Ph.displayName=zt.Empty.displayName;const Oh=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Group,{ref:n,className:oe("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}));Oh.displayName=zt.Group.displayName;const FC=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));FC.displayName=zt.Separator.displayName;const Dh=m.forwardRef(({className:e,...t},n)=>l.jsx(zt.Item,{ref:n,className:oe("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}));Dh.displayName=zt.Item.displayName;function Ka(e,[t,n]){return Math.min(n,Math.max(t,e))}function BC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var qa="ScrollArea",[Lh,FT]=yn(qa),[zC,en]=Lh(qa),$h=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,w]=m.useState(null),[x,g]=m.useState(null),[v,b]=m.useState(0),[S,T]=m.useState(0),[C,k]=m.useState(!1),[E,A]=m.useState(!1),O=ze(t,H=>c(H)),$=Fo(o);return l.jsx(zC,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:k,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:T,children:l.jsx(ye.div,{dir:$,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});$h.displayName=qa;var Fh="ScrollAreaViewport",Bh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=en(Fh,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})})]})});Bh.displayName=Fh;var wn="ScrollAreaScrollbar",Ga=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(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"?l.jsx(HC,{...r,ref:t,forceMount:n}):o.type==="scroll"?l.jsx(UC,{...r,ref:t,forceMount:n}):o.type==="auto"?l.jsx(zh,{...r,ref:t,forceMount:n}):o.type==="always"?l.jsx(Ya,{...r,ref:t}):null});Ga.displayName=wn;var HC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,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(Xt,{present:n||s,children:l.jsx(zh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),UC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=en(wn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Us(()=>c("SCROLL_END"),100),[a,c]=BC("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(Xt,{present:n||a!=="hidden",children:l.jsx(Ya,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:me(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:me(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),zh=m.forwardRef((e,t)=>{const n=en(wn,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 Er(n.viewport,c),Er(n.content,c),l.jsx(Xt,{present:r||s,children:l.jsx(Ya,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ya=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=en(wn,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=Kh(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 YC(h,i.current,a,p)}return n==="horizontal"?l.jsx(WC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=qh(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?l.jsx(VC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=qh(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),WC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(wn,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(Uh,{"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),Yh(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)}})}})}),VC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=en(wn,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(Uh,{"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),Yh(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)}})}})}),[KC,Hh]=Lh(wn),Uh=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=en(wn,n),[w,x]=m.useState(null),g=ze(t,O=>x(O)),v=m.useRef(null),b=m.useRef(""),S=p.viewport,T=r.content-r.viewport,C=It(d),k=It(c),E=Us(f,10);function A(O){if(v.current){const $=O.clientX-v.current.left,H=O.clientY-v.current.top;u({x:$,y:H})}}return m.useEffect(()=>{const O=$=>{const H=$.target;(w==null?void 0:w.contains(H))&&C($,T)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,w,T,C]),m.useEffect(k,[r,k]),Er(w,E),Er(p.content,E),l.jsx(KC,{scope:n,scrollbar:w,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:me(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),v.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(O))}),onPointerMove:me(e.onPointerMove,A),onPointerUp:me(e.onPointerUp,O=>{const $=O.target;$.hasPointerCapture(O.pointerId)&&$.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),v.current=null})})})}),Bs="ScrollAreaThumb",Wh=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Hh(Bs,e.__scopeScrollArea);return l.jsx(Xt,{present:n||o.hasThumb,children:l.jsx(qC,{ref:t,...r})})}),qC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=en(Bs,n),i=Hh(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=XC(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:me(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:w,y:x})}),onPointerUp:me(e.onPointerUp,i.onThumbPointerUp)})});Wh.displayName=Bs;var Xa="ScrollAreaCorner",Vh=m.forwardRef((e,t)=>{const n=en(Xa,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?l.jsx(GC,{...e,ref:t}):null});Vh.displayName=Xa;var GC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=en(Xa,n),[s,i]=m.useState(0),[a,c]=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),c(d)}),Er(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 Kh(e,t){const n=e/t;return isNaN(n)?0:n}function Hs(e){const t=Kh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function YC(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 Gh([c,u],f)(e)}function qh(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=Ka(e,c);return Gh([0,i],[0,a])(u)}function Gh(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 Yh(e,t){return e>0&&e<t}var XC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function 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 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 Xh=$h,JC=Bh,ZC=Vh;const Jh=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Xh,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[l.jsx(JC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),l.jsx(Zh,{}),l.jsx(ZC,{})]}));Jh.displayName=Xh.displayName;const Zh=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>l.jsx(Ga,{ref:r,orientation:t,className:oe("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(Wh,{className:"relative flex-1 rounded-full bg-border"})}));Zh.displayName=Ga.displayName;const Ws=m.forwardRef(({className:e,type:t,...n},r)=>l.jsx("input",{type:t,className:oe("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 QC="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",ek="bg-slate-700 border-slate-600 hover:bg-slate-600",tk="bg-slate-600 border-slate-500";function nk({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:w,secondaryLine:x,itemClassName:g,activeItemClassName:v}){const b=n===e.threadId,S=t?`${v??tk}`:`${g??ek}`,T=C=>{C.stopPropagation(),o(e.threadId)};return l.jsxs("div",{onClick:T,className:`${QC} ${S}`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex-1 min-w-0",children:b?l.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[l.jsx(Ws,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&c()},className:"h-6 text-sm",autoFocus:!0}),l.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:l.jsx(ae.Check,{size:12})}),l.jsx(Qe,{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:w(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)})]}),x&&l.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:x})]})}),l.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:l.jsxs(ta,{children:[l.jsx(na,{asChild:!0,children:l.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:l.jsx(ae.MoreHorizontal,{size:12})})}),l.jsxs(ps,{align:"end",sideOffset:6,className:"w-44",children:[l.jsxs(Gn,{onClick:C=>{C.preventDefault(),u(e.threadId)},children:[l.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&l.jsxs(Gn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[l.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),h&&d&&l.jsxs(Gn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},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 Qh=25,ep="thread-manager-view",rk=e=>e==="default"||e==="shared",ok=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(ep);if(rk(e))return e}catch{}return null};function sk({defaultView:e}={}){const[t,n]=y.useState(()=>ok()??e??"default");y.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ep,t)}catch{}},[t]);const r=y.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const ik=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Ja({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:w,viewState:x,showHeader:g=!0,shareTargets:v,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:T,sharedThreads:C,currentThreadId:k,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:O,actions:$,shareInFlight:H,shareStatus:U,clearShareStatus:K}=Do(),{createThread:P,deleteThread:Y,renameThread:N,shareThread:D}=$,{loadThread:M}=Lo(),j=i??k,[z,W]=y.useState(Array.isArray(T)?T:[]),R=y.useRef(z.length>0),B=y.useRef(null),te=y.useRef(0),[J,re]=y.useState(null),[G,L]=y.useState(""),[V,Z]=y.useState(!1),[q,X]=y.useState(!1),[pe,he]=y.useState(null),[ee,le]=y.useState(""),we=w&&w.length>0?w:ik,je=sk({defaultView:h}),Ne=x??je,$e=f??Ne.view,Ye=y.useCallback(_=>{f||Ne.setView(_),p==null||p(_)},[f,p,Ne]),nt=we.find(_=>_.key===$e)??we[0],Ve=_=>{he(_),le(""),X(!0)},qe=()=>{X(!1),he(null),le(""),K()},rt=y.useCallback(async _=>{if(!(!pe||H)&&_.id)try{await D(pe,_.id),setTimeout(()=>qe(),600)}catch(ie){console.error("Failed to share thread:",ie)}},[qe,H,pe,D]),kt=y.useMemo(()=>{const _=v??[],ie=ee.trim().toLowerCase();return ie?S?_.filter(ge=>S(ge,ie)):_.filter(ge=>`${ge.label} ${ge.secondaryLabel??""}`.toLowerCase().includes(ie)):_},[v,ee,S]),at=$e==="shared",Te=at?C:z,Oe=at?O:A,it=at?"No shared conversations yet":"No conversations yet",ht=_=>{const ie=_.sharedAt?` • ${vt(_.sharedAt)}`:"";return`Shared by ${_.sharedByUserId}${ie}`},Tt=_=>"sharedByUserId"in _;y.useEffect(()=>{const _=Array.isArray(T)?T:[];if(_.length>0){R.current=!0,W(_);return}A||(R.current=!1,W(_))},[T,A]),y.useEffect(()=>{if(!B.current)return;const _=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!_)return;let ie=null,ge=null;return ie=requestAnimationFrame(()=>{ge=requestAnimationFrame(()=>{_.scrollTop=te.current})}),()=>{ie!==null&&cancelAnimationFrame(ie),ge!==null&&cancelAnimationFrame(ge)}},[z]);const yt=async _=>{try{E(_),await M(_),a==null||a(_),c==null||c(_)}catch(ie){console.error("Failed to select thread:",ie)}},Le=async()=>{try{Z(!0);const _=await P();_&&(u==null||u(_),a==null||a(_))}catch(_){console.error("Failed to create thread:",_)}finally{Z(!1)}},Ht=async(_,ie)=>{if(ie.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const ge=B.current.querySelector("[data-radix-scroll-area-viewport]");ge&&(te.current=ge.scrollTop)}try{await Y(_),d==null||d(_)}catch(ge){console.error("Failed to delete thread:",ge)}}},Xe=(_,ie)=>{ie.stopPropagation(),re(_.threadId),L(_.title||`Thread ${_.threadId.slice(0,8)}`)},Ke=async _=>{if(G.trim())try{await N(_,G.trim()),re(null),L("")}catch(ie){console.error("Failed to update title:",ie)}},dt=()=>{re(null),L("")},vt=_=>{if(!_)return"";try{const ie=new Date(_),We=new Date().getTime()-ie.getTime(),Pe=Math.floor(We/(1e3*60*60*24));return Pe===0?ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Pe===1?"Yesterday":Pe<7?`${Pe} days ago`:ie.toLocaleDateString()}catch{return""}},Ue=_=>_.title||`Thread ${_.threadId.slice(0,8)}`,St=_=>{const ie=Ue(_);return ie.length<=Qh?ie:`${ie.slice(0,Qh)}...`};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(Qe,{onClick:Le,disabled:V||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:V?"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(ta,{children:[l.jsx(na,{asChild:!0,children:l.jsx(Qe,{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(ps,{align:"start",sideOffset:6,className:"w-40",children:we.map(_=>l.jsxs(Gn,{className:"justify-between text-[12px]",onClick:ie=>{ie.preventDefault(),Ye(_.key)},children:[l.jsx("span",{children:_.label}),$e===_.key&&l.jsx(ae.Check,{className:"h-3 w-3"})]},_.key))})]})]})]}),l.jsx(Jh,{ref:B,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:it})]}):Te.slice().sort((_,ie)=>new Date(ie.updatedAt||ie.createdAt||"").getTime()-new Date(_.updatedAt||_.createdAt||"").getTime()).map(_=>l.jsx(nk,{thread:_,isActive:j===_.threadId,editingThreadId:J,editingTitle:G,onSelect:yt,onStartEditing:Xe,onEditingTitleChange:ie=>L(ie),onSaveEditing:Ke,onCancelEditing:dt,onShare:()=>Ve(_.threadId),onDelete:Ht,showEditTitle:r,showDeleteButton:n,formatDate:vt,getDisplayThreadTitle:St,secondaryLine:at&&Tt(_)?ht(_):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},_.threadId))})}),l.jsx(Jf,{open:q,onOpenChange:_=>!_&&qe(),children:l.jsxs(_a,{className:"max-w-md p-0",children:[l.jsx(Ma,{children:l.jsx(Ra,{children:"Share thread"})}),l.jsxs(_h,{children:[l.jsx(Mh,{autoFocus:!0,value:ee,onValueChange:_=>le(_),placeholder:"Search for recipients..."}),l.jsxs(Rh,{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(Ph,{children:b?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(Oh,{heading:"Recipients",children:kt.map(_=>l.jsx(Dh,{onSelect:()=>rt(_),children:l.jsxs("div",{className:"flex flex-col items-start text-sm",children:[l.jsx("span",{className:"font-medium",children:_.label}),_.secondaryLabel&&l.jsx("span",{className:"text-xs text-muted-foreground",children:_.secondaryLabel})]})},_.id))})]})]})]})})]})}const ak=({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 w=d===p.id,x=(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 ${w?"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 ${w?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:l.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${w?"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}`:""]}),x&&l.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:x,children:x})]})]},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 Ir(e){if(!(typeof globalThis>"u"))return globalThis[e]}function lk(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function tp(){const e=[Ir("__API_BASE_URL__"),Ir("__CHAT_API_BASE_URL__"),Ir("__CHAT_API_URL__")];for(const t of e){const n=lk(t);if(n)return n}}function np(){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 rp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function op(){const e={},t=tp(),n=np();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function sp(){const e=op(),t=Tn.getAuthToken(),n=tp();return{apiBaseUrl:rp(e.baseUrl,Tn.baseUrl,n),apiKey:t||e.apiKey||np()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const ip="chat-settings";function ck(){try{const e=localStorage.getItem(ip);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function uk(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem(ip,JSON.stringify(t)),t.apiKey&&Tn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function dk(){const e=sp(),t=ck(),n=Tn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:rp(Tn.baseUrl,r,e.apiBaseUrl)}}function fk(e){Tn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),uk(e)}var hk="Label",ap=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())}}));ap.displayName=hk;var lp=ap;const pk=wo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tn=m.forwardRef(({className:e,...t},n)=>l.jsx(lp,{ref:n,className:oe(pk(),e),...t}));tn.displayName=lp.displayName;function cp(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 up=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"}),mk="VisuallyHidden",gk=m.forwardRef((e,t)=>l.jsx(ye.span,{...e,ref:t,style:{...up,...e.style}}));gk.displayName=mk;var xk=[" ","Enter","ArrowUp","ArrowDown"],vk=[" ","Enter"],rr="Select",[Vs,Ks,wk]=bi(rr),[Nr,BT]=yn(rr,[wk,Zo]),qs=Zo(),[bk,Ln]=Nr(rr),[yk,Sk]=Nr(rr),dp=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:w}=e,x=qs(t),[g,v]=m.useState(null),[b,S]=m.useState(null),[T,C]=m.useState(!1),k=Fo(u),[E,A]=dr({prop:r,defaultProp:o??!1,onChange:s,caller:rr}),[O,$]=dr({prop:i,defaultProp:a,onChange:c,caller:rr}),H=m.useRef(null),U=g?w||!!g.closest("form"):!0,[K,P]=m.useState(new Set),Y=Array.from(K).map(N=>N.props.value).join(";");return l.jsx(mu,{...x,children:l.jsxs(bk,{required:p,scope:t,trigger:g,onTriggerChange:v,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:C,contentId:Pt(),value:O,onValueChange:$,open:E,onOpenChange:A,dir:k,triggerPointerDownPosRef:H,disabled:h,children:[l.jsx(Vs.Provider,{scope:t,children:l.jsx(yk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(N=>{P(D=>new Set(D).add(N))},[]),onNativeOptionRemove:m.useCallback(N=>{P(D=>{const M=new Set(D);return M.delete(N),M})},[]),children:n})}),U?l.jsxs(Op,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:O,onChange:N=>$(N.target.value),disabled:h,form:w,children:[O===void 0?l.jsx("option",{value:""}):null,Array.from(K)]},Y):null]})})};dp.displayName=rr;var fp="SelectTrigger",hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=qs(n),i=Ln(fp,n),a=i.disabled||r,c=ze(t,i.onTriggerChange),u=Ks(n),d=m.useRef("touch"),[f,h,p]=Lp(x=>{const g=u().filter(S=>!S.disabled),v=g.find(S=>S.value===i.value),b=$p(g,x,v);b!==void 0&&i.onValueChange(b.value)}),w=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return l.jsx(gu,{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":Dp(i.value)?"":void 0,...o,ref:c,onClick:me(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&w(x)}),onPointerDown:me(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(w(x),x.preventDefault())}),onKeyDown:me(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&xk.includes(x.key)&&(w(),x.preventDefault())})})})});hp.displayName=fp;var pp="SelectValue",mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=Ln(pp,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:Dp(c.value)?l.jsx(l.Fragment,{children:i}):s})});mp.displayName=pp;var Ck="SelectIcon",gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return l.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gp.displayName=Ck;var kk="SelectPortal",xp=e=>l.jsx(Qo,{asChild:!0,...e});xp.displayName=kk;var or="SelectContent",vp=m.forwardRef((e,t)=>{const n=Ln(or,e.__scopeSelect),[r,o]=m.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?bo.createPortal(l.jsx(wp,{scope:e.__scopeSelect,children:l.jsx(Vs.Slot,{scope:e.__scopeSelect,children:l.jsx("div",{children:e.children})})}),s):null}return l.jsx(bp,{...e,ref:t})});vp.displayName=or;var cn=10,[wp,$n]=Nr(or),Tk="SelectContentImpl",Ek=Bn.createSlot("SelectContent.RemoveScroll"),bp=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:w,hideWhenDetached:x,avoidCollisions:g,...v}=e,b=Ln(or,n),[S,T]=m.useState(null),[C,k]=m.useState(null),E=ze(t,G=>T(G)),[A,O]=m.useState(null),[$,H]=m.useState(null),U=Ks(n),[K,P]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(S)return Hi(S)},[S]),Ci();const N=m.useCallback(G=>{const[L,...V]=U().map(X=>X.ref.current),[Z]=V.slice(-1),q=document.activeElement;for(const X of G)if(X===q||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&C&&(C.scrollTop=0),X===Z&&C&&(C.scrollTop=C.scrollHeight),X==null||X.focus(),document.activeElement!==q))return},[U,C]),D=m.useCallback(()=>N([A,S]),[N,A,S]);m.useEffect(()=>{K&&D()},[K,D]);const{onOpenChange:M,triggerPointerDownPosRef:j}=b;m.useEffect(()=>{if(S){let G={x:0,y:0};const L=Z=>{var q,X;G={x:Math.abs(Math.round(Z.pageX)-(((q=j.current)==null?void 0:q.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((X=j.current)==null?void 0:X.y)??0))}},V=Z=>{G.x<=10&&G.y<=10?Z.preventDefault():S.contains(Z.target)||M(!1),document.removeEventListener("pointermove",L),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",V,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",V,{capture:!0})}}},[S,M,j]),m.useEffect(()=>{const G=()=>M(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[M]);const[z,W]=Lp(G=>{const L=U().filter(q=>!q.disabled),V=L.find(q=>q.ref.current===document.activeElement),Z=$p(L,G,V);Z&&setTimeout(()=>Z.ref.current.focus())}),R=m.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&(O(G),Z&&(Y.current=!0))},[b.value]),B=m.useCallback(()=>S==null?void 0:S.focus(),[S]),te=m.useCallback((G,L,V)=>{const Z=!Y.current&&!V;(b.value!==void 0&&b.value===L||Z)&&H(G)},[b.value]),J=r==="popper"?Za:yp,re=J===Za?{side:a,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:x,avoidCollisions:g}:{};return l.jsx(wp,{scope:n,content:S,viewport:C,onViewportChange:k,itemRefCallback:R,selectedItem:A,onItemLeave:B,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:$,position:r,isPositioned:K,searchRef:z,children:l.jsx(ls,{as:Ek,allowPinchZoom:!0,children:l.jsx(zo,{asChild:!0,trapped:b.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:me(o,G=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),G.preventDefault()}),children:l.jsx(Bo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:l.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:G=>G.preventDefault(),...v,...re,onPlaced:()=>P(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:me(v.onKeyDown,G=>{const L=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!L&&G.key.length===1&&W(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let Z=U().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(G.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const q=G.target,X=Z.indexOf(q);Z=Z.slice(X+1)}setTimeout(()=>N(Z)),G.preventDefault()}})})})})})})});bp.displayName=Tk;var Ik="SelectItemAlignedPosition",yp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Ln(or,n),i=$n(or,n),[a,c]=m.useState(null),[u,d]=m.useState(null),f=ze(t,E=>d(E)),h=Ks(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:v,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&v){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),$=v.getBoundingClientRect();if(s.dir!=="rtl"){const q=$.left-A.left,X=O.left-q,pe=E.left-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.left=we+"px"}else{const q=A.right-$.right,X=window.innerWidth-O.right-q,pe=window.innerWidth-E.right-X,he=E.width+pe,ee=Math.max(he,A.width),le=window.innerWidth-cn,we=Ka(X,[cn,Math.max(cn,le-ee)]);a.style.minWidth=he+"px",a.style.right=we+"px"}const H=h(),U=window.innerHeight-cn*2,K=x.scrollHeight,P=window.getComputedStyle(u),Y=parseInt(P.borderTopWidth,10),N=parseInt(P.paddingTop,10),D=parseInt(P.borderBottomWidth,10),M=parseInt(P.paddingBottom,10),j=Y+N+K+M+D,z=Math.min(g.offsetHeight*5,j),W=window.getComputedStyle(x),R=parseInt(W.paddingTop,10),B=parseInt(W.paddingBottom,10),te=E.top+E.height/2-cn,J=U-te,re=g.offsetHeight/2,G=g.offsetTop+re,L=Y+N+G,V=j-L;if(L<=te){const q=H.length>0&&g===H[H.length-1].ref.current;a.style.bottom="0px";const X=u.clientHeight-x.offsetTop-x.offsetHeight,pe=Math.max(J,re+(q?B:0)+X+D),he=L+pe;a.style.height=he+"px"}else{const q=H.length>0&&g===H[0].ref.current;a.style.top="0px";const pe=Math.max(te,Y+x.offsetTop+(q?R:0)+re)+V;a.style.height=pe+"px",x.scrollTop=L-te+x.offsetTop}a.style.margin=`${cn}px 0`,a.style.minHeight=z+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,v,s.dir,r]);Et(()=>S(),[S]);const[T,C]=m.useState();Et(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const k=m.useCallback(E=>{E&&w.current===!0&&(S(),b==null||b(),w.current=!1)},[S,b]);return l.jsx(Ak,{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}})})})});yp.displayName=Ik;var Nk="SelectPopperPosition",Za=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=cn,...s}=e,i=qs(n);return l.jsx(xu,{...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)"}})});Za.displayName=Nk;var[Ak,Qa]=Nr(or,{}),el="SelectViewport",Sp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=$n(el,n),i=Qa(el,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:me(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 w=window.innerHeight-cn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),v=Math.max(x,g);if(v<w){const b=v+p,S=Math.min(w,b),T=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Sp.displayName=el;var Cp="SelectGroup",[jk,_k]=Nr(Cp),Mk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return l.jsx(jk,{scope:n,id:o,children:l.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Mk.displayName=Cp;var kp="SelectLabel",Tp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_k(kp,n);return l.jsx(ye.div,{id:o.id,...r,ref:t})});Tp.displayName=kp;var Gs="SelectItem",[Rk,Ep]=Nr(Gs),Ip=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),w=ze(t,b=>{var S;return(S=c.itemRefCallback)==null?void 0:S.call(c,b,r,o)}),x=Pt(),g=m.useRef("touch"),v=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return l.jsx(Rk,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:l.jsx(Vs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:l.jsx(ye.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:me(i.onFocus,()=>p(!0)),onBlur:me(i.onBlur,()=>p(!1)),onClick:me(i.onClick,()=>{g.current!=="mouse"&&v()}),onPointerUp:me(i.onPointerUp,()=>{g.current==="mouse"&&v()}),onPointerDown:me(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:me(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=c.onItemLeave)==null||S.call(c):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:me(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=c.onItemLeave)==null||S.call(c))}),onKeyDown:me(i.onKeyDown,b=>{var T;((T=c.searchRef)==null?void 0:T.current)!==""&&b.key===" "||(vk.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});Ip.displayName=Gs;var mo="SelectItemText",Np=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Ln(mo,n),a=$n(mo,n),c=Ep(mo,n),u=Sk(mo,n),[d,f]=m.useState(null),h=ze(t,v=>f(v),c.onItemTextChange,v=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,v,c.value,c.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Et(()=>(x(w),()=>g(w)),[x,g,w]),l.jsxs(l.Fragment,{children:[l.jsx(ye.span,{id:c.textId,...s,ref:h}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?bo.createPortal(s.children,i.valueNode):null]})});Np.displayName=mo;var Ap="SelectItemIndicator",jp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Ep(Ap,n).isSelected?l.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});jp.displayName=Ap;var tl="SelectScrollUpButton",_p=m.forwardRef((e,t)=>{const n=$n(tl,e.__scopeSelect),r=Qa(tl,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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});_p.displayName=tl;var nl="SelectScrollDownButton",Mp=m.forwardRef((e,t)=>{const n=$n(nl,e.__scopeSelect),r=Qa(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=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(Rp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Mp.displayName=nl;var Rp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=$n("SelectScrollButton",n),i=m.useRef(null),a=Ks(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:me(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:me(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:me(o.onPointerLeave,()=>{c()})})}),Pk="SelectSeparator",Pp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return l.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Pp.displayName=Pk;var rl="SelectArrow",Ok=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qs(n),s=Ln(rl,n),i=$n(rl,n);return s.open&&i.position==="popper"?l.jsx(vu,{...o,...r,ref:t}):null});Ok.displayName=rl;var Dk="SelectBubbleInput",Op=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=ze(r,o),i=cp(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:{...up,...n.style},ref:s,defaultValue:t})});Op.displayName=Dk;function Dp(e){return e===""||e===void 0}function Lp(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 $p(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=Lk(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 Lk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var $k=dp,Fp=hp,Fk=mp,Bk=gp,zk=xp,Bp=vp,Hk=Sp,zp=Tp,Hp=Ip,Uk=Np,Wk=jp,Up=_p,Wp=Mp,Vp=Pp;const Kp=$k,qp=Fk,ol=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Fp,{ref:r,className:oe("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(Bk,{asChild:!0,children:l.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ol.displayName=Fp.displayName;const Gp=m.forwardRef(({className:e,...t},n)=>l.jsx(Up,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Gp.displayName=Up.displayName;const Yp=m.forwardRef(({className:e,...t},n)=>l.jsx(Wp,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Yp.displayName=Wp.displayName;const sl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>l.jsx(zk,{children:l.jsxs(Bp,{ref:o,className:oe("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(Gp,{}),l.jsx(Hk,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(Yp,{})]})}));sl.displayName=Bp.displayName;const Vk=m.forwardRef(({className:e,...t},n)=>l.jsx(zp,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Vk.displayName=zp.displayName;const sr=m.forwardRef(({className:e,children:t,...n},r)=>l.jsxs(Hp,{ref:r,className:oe("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(Wk,{children:l.jsx(ae.Check,{className:"h-4 w-4"})})}),l.jsx(Uk,{children:t})]}));sr.displayName=Hp.displayName;const Kk=m.forwardRef(({className:e,...t},n)=>l.jsx(Vp,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Kk.displayName=Vp.displayName;var qk="Separator",Xp="horizontal",Gk=["horizontal","vertical"],Jp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=Xp,...o}=e,s=Yk(r)?r:Xp,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})});Jp.displayName=qk;function Yk(e){return Gk.includes(e)}var Zp=Jp;const Qp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>l.jsx(Zp,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Qp.displayName=Zp.displayName;const Xk=Aa,Jk=IS,Zk=ja,em=m.forwardRef(({className:e,...t},n)=>l.jsx(so,{className:oe("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}));em.displayName=so.displayName;const Qk=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"}}),tm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>l.jsxs(Zk,{children:[l.jsx(em,{}),l.jsxs(io,{ref:o,className:oe(Qk({side:e}),t),...r,children:[n,l.jsxs(Xf,{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"})]})]})]}));tm.displayName=io.displayName;const nm=({className:e,...t})=>l.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});nm.displayName="SheetHeader";const rm=m.forwardRef(({className:e,...t},n)=>l.jsx(er,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));rm.displayName=er.displayName;const om=m.forwardRef(({className:e,...t},n)=>l.jsx(js,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));om.displayName=js.displayName;var Ys="Switch",[eT,zT]=yn(Ys),[tT,nT]=eT(Ys),sm=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),w=ze(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[v,b]=dr({prop:o,defaultProp:s??!1,onChange:u,caller:Ys});return l.jsxs(tT,{scope:n,checked:v,disabled:a,children:[l.jsx(ye.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":cm(v),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:w,onClick:me(e.onClick,S=>{b(T=>!T),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&l.jsx(lm,{control:h,bubbles:!x.current,name:r,value:c,checked:v,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sm.displayName=Ys;var im="SwitchThumb",am=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nT(im,n);return l.jsx(ye.span,{"data-state":cm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});am.displayName=im;var rT="SwitchBubbleInput",lm=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=ze(i,s),c=cp(n),u=su(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 w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[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}})});lm.displayName=rT;function cm(e){return e?"checked":"unchecked"}var um=sm,oT=am;const Fn=m.forwardRef(({className:e,...t},n)=>l.jsx(um,{className:oe("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(oT,{className:oe("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=um.displayName;const sT={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 iT({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}=Da();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(sT),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{c(e),d(!1),o(!1)},x=async()=>{try{const v=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${v.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return l.jsxs(Xk,{open:r,onOpenChange:o,children:[l.jsx(Jk,{asChild:!0,children:l.jsxs(Qe,{variant:"outline",size:"sm",className:n,children:[l.jsx(ae.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&l.jsx(_f,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),l.jsxs(tm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[l.jsxs(nm,{children:[l.jsx(rm,{children:"Chat Settings"}),l.jsx(om,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),l.jsxs("div",{className:"space-y-6 py-6",children:[l.jsxs(lo,{children:[l.jsx(co,{className:"pb-3",children:l.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.Server,{className:"h-5 w-5"}),"API Configuration"]})}),l.jsxs(fo,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(tn,{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(v=>({...v,api:{...v.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),l.jsx(Qe,{variant:"outline",onClick:x,children:"Test"})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(tn,{htmlFor:"enable-auth",children:"Enable Authentication"}),l.jsx(Fn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>c(v=>({...v,api:{...v.api,enableAuth:g}}))})]}),a.api.enableAuth&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(tn,{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(v=>({...v,api:{...v.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),l.jsx(Qe,{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(lo,{children:[l.jsx(co,{className:"pb-3",children:l.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),l.jsxs(fo,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(tn,{htmlFor:"layout",children:"Layout Style"}),l.jsxs(Kp,{value:a.ui.layout,onValueChange:g=>c(v=>({...v,ui:{...v.ui,layout:g}})),children:[l.jsx(ol,{children:l.jsx(qp,{})}),l.jsxs(sl,{children:[l.jsx(sr,{value:"sidebar",children:"Sidebar Layout"}),l.jsx(sr,{value:"fullscreen",children:"Fullscreen"}),l.jsx(sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(tn,{htmlFor:"theme",children:"Theme"}),l.jsxs(Kp,{value:a.ui.theme,onValueChange:g=>c(v=>({...v,ui:{...v.ui,theme:g}})),children:[l.jsx(ol,{children:l.jsx(qp,{})}),l.jsxs(sl,{children:[l.jsx(sr,{value:"light",children:"Light"}),l.jsx(sr,{value:"dark",children:"Dark"}),l.jsx(sr,{value:"system",children:"System"})]})]})]}),l.jsx(Qp,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(tn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),l.jsx(Fn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>c(v=>({...v,ui:{...v.ui,showTimestamps:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(tn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),l.jsx(Fn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>c(v=>({...v,ui:{...v.ui,showAgentNames:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(tn,{htmlFor:"compact-messages",children:"Compact Messages"}),l.jsx(Fn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>c(v=>({...v,ui:{...v.ui,compactMessages:g}}))})]})]})]})]}),l.jsxs(lo,{children:[l.jsx(co,{className:"pb-3",children:l.jsxs(uo,{className:"text-lg flex items-center gap-2",children:[l.jsx(ae.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),l.jsxs(fo,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,autoSave:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,enableStreaming:g}}))})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx(tn,{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(v=>({...v,behavior:{...v.behavior,showTypingIndicator:g}}))})]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[l.jsxs(Qe,{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(Qe,{variant:"outline",onClick:w,children:"Cancel"}),l.jsxs(Qe,{onClick:h,disabled:!u,children:[l.jsx(ae.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function aT({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($o,{...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($o,{...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(Ja,{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($o,{...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(Ja,{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=tc,Ce.ChatInput=Cc,Ce.ChatInterface=$s,Ce.ChatProviders=$o,Ce.ChatSettings=iT,Ce.MarkdownContent=Cr,Ce.MessageComponent=Ls,Ce.MessageList=Fa,Ce.ThreadManager=Ja,Ce.TimelineColumn=ak,Ce.applySettings=fk,Ce.buildMessagePreviewMap=Vg,Ce.chatApiClient=Tn,Ce.default=aT,Ce.del=hi,Ce.get=Yt,Ce.getChatToken=Zl,Ce.getCurrentSettings=dk,Ce.getDefaultApiConfig=op,Ce.getDefaultChatSettings=sp,Ce.onChatTokenChanged=Ql,Ce.post=Ro,Ce.put=ec,Ce.setChatToken=Mo,Ce.useApi=pi,Ce.useChatStream=gc,Ce.useMessagesReducer=fc,Ce.useStream=yc,Ce.useThreadState=Lo,Ce.useThreads=Do,Object.defineProperties(Ce,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|